aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordakkar <dakkar@thenautilus.net>2016-12-27 16:27:33 +0000
committerdakkar <dakkar@thenautilus.net>2016-12-27 16:27:33 +0000
commit080d8bda10e5acc2aa2fa4aeed5a352997be4c65 (patch)
tree182dc45fbc4471871f49fcd39821fbf8dcc0c8b5
parentminor cli fixes (diff)
downloadSietima-080d8bda10e5acc2aa2fa4aeed5a352997be4c65.tar.gz
Sietima-080d8bda10e5acc2aa2fa4aeed5a352997be4c65.tar.bz2
Sietima-080d8bda10e5acc2aa2fa4aeed5a352997be4c65.zip
list & show moderation queue contents
-rw-r--r--lib/Sietima/Role/SubscriberOnly/Moderate.pm35
1 files changed, 35 insertions, 0 deletions
diff --git a/lib/Sietima/Role/SubscriberOnly/Moderate.pm b/lib/Sietima/Role/SubscriberOnly/Moderate.pm
index 8f49bed..7e231ed 100644
--- a/lib/Sietima/Role/SubscriberOnly/Moderate.pm
+++ b/lib/Sietima/Role/SubscriberOnly/Moderate.pm
@@ -35,8 +35,39 @@ sub drop ($self,$mail_id) {
$self->mail_store->remove($mail_id);
}
+sub list_mails_in_moderation_queue ($self,$runner,@) {
+ my $mails = $self->mail_store->retrieve_by_tags('moderation');
+ $runner->out(sprintf 'There are %d messages held for moderation:',scalar($mails->@*));
+ for my $mail ($mails->@*) {
+ $runner->out(sprintf '* %s %s "%s" (%s)',
+ $mail->{id},
+ $mail->{mail}->header_str('From')//'<no from>',
+ $mail->{mail}->header_str('Subject')//'<no subject>',
+ $mail->{mail}->header_str('Date')//'<no date>',
+ );
+ }
+}
+
+sub show_mail_from_moderation_queue ($self,$runner,@) {
+ my $id = $runner->parameters->{'mail-id'};
+ my $mail = $self->mail_store->retrieve_by_id($id);
+ $runner->out("Message $id:");
+ $runner->out($mail->as_string);
+}
+
around command_line_spec => sub ($orig,$self) {
my $spec = $self->$orig();
+ $spec->{subcommands}{'show-held'} = {
+ op => 'show_mail_from_moderation_queue',
+ summary => 'shows the given mail, currently held for moderation',
+ parameters => [
+ {
+ name => 'mail-id',
+ required => 1,
+ summary => 'id of the mail to show',
+ },
+ ],
+ };
$spec->{subcommands}{'resume-held'} = {
op => sub ($self,$runner,$args) {
$self->resume($runner->parameters->{'mail-id'});
@@ -63,6 +94,10 @@ around command_line_spec => sub ($orig,$self) {
},
],
};
+ $spec->{subcommands}{'list-held'} = {
+ op => 'list_mails_in_moderation_queue',
+ summary => 'list all mails currently held for moderation',
+ };
return $spec;
};