diff options
Diffstat (limited to 'lib/Sietima/Role/SubscriberOnly/Moderate.pm')
-rw-r--r-- | lib/Sietima/Role/SubscriberOnly/Moderate.pm | 256 |
1 files changed, 140 insertions, 116 deletions
diff --git a/lib/Sietima/Role/SubscriberOnly/Moderate.pm b/lib/Sietima/Role/SubscriberOnly/Moderate.pm index c4d62c9..2cc8e34 100644 --- a/lib/Sietima/Role/SubscriberOnly/Moderate.pm +++ b/lib/Sietima/Role/SubscriberOnly/Moderate.pm @@ -5,46 +5,14 @@ use Email::Stuffer; use Email::MIME; use namespace::clean; -# VERSION +our $VERSION = '1.0.1'; # VERSION # ABSTRACT: moderate messages from non-subscribers -=head1 SYNOPSIS - - my $sietima = Sietima->with_traits('SubscribersOnly::Moderate')->new({ - %args, - owner => 'listmaster@example.com', - mail_store => { - class => 'Sietima::MailStore::FS', - root => '/tmp', - }, - }); - -=head1 DESCRIPTION - -A L<< C<Sietima> >> list with this role applied will accept incoming -emails coming from non-subscribers, and store it for moderation. Each -such email will be forwarded (as an attachment) to the list's owner. - -The owner will the be able to delete the message, or allow it. - -This is a "sub-role" of L<< -C<SubscribersOnly>|Sietima::Role::SubscriberOnly >>, L<< -C<WithMailStore>|Sietima::Role::WithMailStore >>, and L<< -C<WithOwner>|Sietima::Role::WithOwner >>. - -=cut with 'Sietima::Role::SubscriberOnly', 'Sietima::Role::WithMailStore', 'Sietima::Role::WithOwner'; -=method C<munge_mail_from_non_subscriber> - -L<Stores|Sietima::MailStore/store> the email with the C<moderation> -tag, and forwards it to the L<list -owner|Sietima::Role::WithOwner/owner>. - -=cut sub munge_mail_from_non_subscriber ($self,$mail) { my $id = $self->mail_store->store($mail,'moderation'); @@ -67,17 +35,6 @@ sub munge_mail_from_non_subscriber ($self,$mail) { return; } -=method C<resume> - - $sietima->resume($mail_id); - -Given an identifier returned when L<storing|Sietima::MailStore/store> -an email, this method retrieves the email and re-processes it via L<< -C<ignoring_subscriberonly>|Sietima::Role::SubscriberOnly/ignoring_subscriberonly ->>. This will make sure that the email is not caught again by the -subscriber-only filter. - -=cut sub resume ($self,$mail_id) { my $mail = $self->mail_store->retrieve_by_id($mail_id); @@ -87,32 +44,11 @@ sub resume ($self,$mail_id) { $self->mail_store->remove($mail_id); } -=method C<drop> - - $sietima->drop($mail_id); - -Given an identifier returned when L<storing|Sietima::MailStore/store> -an email, this method deletes the email from the store. - -=cut sub drop ($self,$mail_id) { $self->mail_store->remove($mail_id); } -=method C<list_mails_in_moderation_queue> - - $sietima->list_mails_in_moderation_queue($sietima_runner); - -This method L<retrieves all the -identifiers|Sietima::MailStore/retrieve_by_tags> of messages tagged -C<moderation>, and L<prints them out|App::Spec::Runner/out> via the -L<< C<Sietima::Runner> >> object. - -This method is usually invoked from the command line, see L<< -/C<command_line_spec> >>. - -=cut sub list_mails_in_moderation_queue ($self,$runner,@) { my $mails = $self->mail_store->retrieve_by_tags('moderation'); @@ -127,18 +63,6 @@ sub list_mails_in_moderation_queue ($self,$runner,@) { } } -=method C<show_mail_from_moderation_queue> - - $sietima->show_mail_from_moderation_queue($sietima_runner); - -This method L<retrieves the email|Sietima::MailStore/retrieve_by_id> -of the message requested from the command line, and L<prints it -out|App::Spec::Runner/out> via the L<< C<Sietima::Runner> >> object. - -This method is usually invoked from the command line, see L<< -/C<command_line_spec> >>. - -=cut sub show_mail_from_moderation_queue ($self,$runner,@) { my $id = $runner->parameters->{'mail-id'}; @@ -147,45 +71,6 @@ sub show_mail_from_moderation_queue ($self,$runner,@) { $runner->out($mail->as_string =~ s{\r\n}{\n}gr); } -=modif C<command_line_spec> - -This method adds the following sub-commands for the command line: - -=over - -=item C<list-held> - - $ sietima list-held - -Invokes the L<< /C<list_mails_in_moderation_queue> >> method, printing -the identifiers of all messages held for moderation. - -=item C<show-held> - - $ sietima show-held 32946p6eu7867 - -Invokes the L<< /C<show_mail_from_moderation_queue> >> method, -printing one message held for moderation; the identifier is expected -as a positional parameter. - -=item C<resume-held> - - $ sietima resume-held 32946p6eu7867 - -Invokes the L<< /C<resume> >> method, causing the held message to be -processed normally; the identifier is expected as a positional -parameter. - -=item C<drop-held> - - $ sietima drop-held 32946p6eu7867 - -Invokes the L<< /C<drop> >> method, removing the held message; the -identifier is expected as a positional parameter. - -=back - -=cut around command_line_spec => sub ($orig,$self) { my $spec = $self->$orig(); @@ -235,3 +120,142 @@ around command_line_spec => sub ($orig,$self) { }; 1; + +__END__ + +=pod + +=encoding UTF-8 + +=head1 NAME + +Sietima::Role::SubscriberOnly::Moderate - moderate messages from non-subscribers + +=head1 VERSION + +version 1.0.1 + +=head1 SYNOPSIS + + my $sietima = Sietima->with_traits('SubscribersOnly::Moderate')->new({ + %args, + owner => 'listmaster@example.com', + mail_store => { + class => 'Sietima::MailStore::FS', + root => '/tmp', + }, + }); + +=head1 DESCRIPTION + +A L<< C<Sietima> >> list with this role applied will accept incoming +emails coming from non-subscribers, and store it for moderation. Each +such email will be forwarded (as an attachment) to the list's owner. + +The owner will the be able to delete the message, or allow it. + +This is a "sub-role" of L<< +C<SubscribersOnly>|Sietima::Role::SubscriberOnly >>, L<< +C<WithMailStore>|Sietima::Role::WithMailStore >>, and L<< +C<WithOwner>|Sietima::Role::WithOwner >>. + +=head1 METHODS + +=head2 C<munge_mail_from_non_subscriber> + +L<Stores|Sietima::MailStore/store> the email with the C<moderation> +tag, and forwards it to the L<list +owner|Sietima::Role::WithOwner/owner>. + +=head2 C<resume> + + $sietima->resume($mail_id); + +Given an identifier returned when L<storing|Sietima::MailStore/store> +an email, this method retrieves the email and re-processes it via L<< +C<ignoring_subscriberonly>|Sietima::Role::SubscriberOnly/ignoring_subscriberonly +>>. This will make sure that the email is not caught again by the +subscriber-only filter. + +=head2 C<drop> + + $sietima->drop($mail_id); + +Given an identifier returned when L<storing|Sietima::MailStore/store> +an email, this method deletes the email from the store. + +=head2 C<list_mails_in_moderation_queue> + + $sietima->list_mails_in_moderation_queue($sietima_runner); + +This method L<retrieves all the +identifiers|Sietima::MailStore/retrieve_by_tags> of messages tagged +C<moderation>, and L<prints them out|App::Spec::Runner/out> via the +L<< C<Sietima::Runner> >> object. + +This method is usually invoked from the command line, see L<< +/C<command_line_spec> >>. + +=head2 C<show_mail_from_moderation_queue> + + $sietima->show_mail_from_moderation_queue($sietima_runner); + +This method L<retrieves the email|Sietima::MailStore/retrieve_by_id> +of the message requested from the command line, and L<prints it +out|App::Spec::Runner/out> via the L<< C<Sietima::Runner> >> object. + +This method is usually invoked from the command line, see L<< +/C<command_line_spec> >>. + +=head1 MODIFIED METHODS + +=head2 C<command_line_spec> + +This method adds the following sub-commands for the command line: + +=over + +=item C<list-held> + + $ sietima list-held + +Invokes the L<< /C<list_mails_in_moderation_queue> >> method, printing +the identifiers of all messages held for moderation. + +=item C<show-held> + + $ sietima show-held 32946p6eu7867 + +Invokes the L<< /C<show_mail_from_moderation_queue> >> method, +printing one message held for moderation; the identifier is expected +as a positional parameter. + +=item C<resume-held> + + $ sietima resume-held 32946p6eu7867 + +Invokes the L<< /C<resume> >> method, causing the held message to be +processed normally; the identifier is expected as a positional +parameter. + +=item C<drop-held> + + $ sietima drop-held 32946p6eu7867 + +Invokes the L<< /C<drop> >> method, removing the held message; the +identifier is expected as a positional parameter. + +=back + +=head1 AUTHOR + +Gianni Ceccarelli <dakkar@thenautilus.net> + +=head1 COPYRIGHT AND LICENSE + +This software is copyright (c) 2017 by Gianni Ceccarelli <dakkar@thenautilus.net>. + +This is free software; you can redistribute it and/or modify it under +the same terms as the Perl 5 programming language system itself. + +=cut |