File Coverage

blib/lib/Siesta/Plugin/Moderated.pm
Criterion Covered Total %
statement 18 23 78.2
branch 1 4 25.0
condition n/a
subroutine 7 7 100.0
pod 2 3 66.6
total 28 37 75.6


line stmt bran cond sub pod time code
1             # $Id: $
2             package Siesta::Plugin::Moderated;
3 3     3   2289 use strict;
  3         8  
  3         131  
4 3     3   19 use Siesta::Plugin;
  3         6  
  3         22  
5 3     3   83 use base 'Siesta::Plugin';
  3         6  
  3         253  
6 3     3   17 use Siesta::Deferred;
  3         6  
  3         42  
7              
8             sub description {
9 1     1 0 498 "force all posts to be moderated by the list owner";
10             }
11              
12             # TODO let someone who's not the owner be a moderator
13              
14             sub process {
15 1     1 1 4 my $self = shift;
16 1         3 my $mail = shift;
17 1         9 my $list = $self->list;
18              
19 1 50       65 return unless $self->pref('moderated');
20              
21             # This job would be great if it wasn't for the fucking customers.
22 0         0 my $id = $mail->defer(
23             why => "moderated",
24             who => $list->owner,
25             );
26              
27              
28 0         0 $mail->reply( to => $list->owner->email,
29             from => $list->address('resume'),
30             subject => "deferred message",
31             body => Siesta->bake('moderated_approve',
32             list => $list,
33             mail => $mail,
34             deferred => $id),
35             );
36              
37 0 0       0 return 1 unless $self->pref('tell_user');
38              
39 0         0 $mail->reply( from => $list->return_path,
40             body => Siesta->bake('moderated') );
41              
42 0         0 return 1;
43             }
44              
45             sub options {
46             +{
47 1     1 1 20 'moderated'
48             => {
49             description => "should we hold all posts to be okayed by the list-owner",
50             type => "boolean",
51             default => 0,
52             },
53             'tell_user'
54             => {
55             description => "should we tell the user if their post is being held?",
56             type => "boolean",
57             default => 0,
58             },
59             };
60             }
61              
62             1;