File Coverage

blib/lib/Siesta/Plugin/UnSubscribe.pm
Criterion Covered Total %
statement 20 20 100.0
branch 2 2 100.0
condition n/a
subroutine 5 5 100.0
pod 1 2 50.0
total 28 29 96.5


line stmt bran cond sub pod time code
1             # $Id: UnSubscribe.pm 1243 2003-07-21 16:50:06Z richardc $
2             package Siesta::Plugin::UnSubscribe;
3 4     4   3709 use strict;
  4         12  
  4         171  
4 4     4   25 use Siesta::Plugin;
  4         57  
  4         62  
5 4     4   127 use base 'Siesta::Plugin';
  4         9  
  4         1477  
6              
7             sub description {
8 1     1 0 536 'A system plugin used for unsubscribing a member to the list';
9             }
10              
11             sub process {
12 3     3 1 37 my $self = shift;
13 3         6 my $mail = shift;
14 3         27 my $list = $self->list;
15              
16 3         2913 my $email = $mail->from;
17 3 100       94 if ( $list->remove_member($email) ) {
18 2         59 $mail->reply(
19             from => $list->address( 'admin' ),
20             to => $list->owner->email,
21             body => "$email LEFT " . $list->name
22             );
23              
24 2         17 $mail->reply(
25             from => $list->address( 'unsubscribe' ),
26             body => Siesta->bake('unsubscribe_success',
27             list => $list,
28             message => $mail ) );
29             }
30             else {
31 1         8 $mail->reply(
32             to => $list->owner->email,
33             from => $list->address( 'admin' ),
34             body => "$email FAIL LEFT " . $list->name
35             );
36              
37 1         8 $mail->reply(
38             from => $list->address( 'admin' ),
39             body => Siesta->bake('unsubscribe_failure',
40             list => $list,
41             message => $mail ) );
42             }
43 3         78 return 1;
44             }
45              
46             1;