From ed980d6059ac994499f1a75b4a56796e00184ff7 Mon Sep 17 00:00:00 2001 From: dakkar Date: Tue, 7 Feb 2017 18:32:55 +0000 Subject: rename 'admin' to 'owner' --- example/sietima | 4 +-- lib/Sietima/Role/Headers.pm | 3 -- lib/Sietima/Role/SubscriberOnly/Moderate.pm | 14 ++++---- lib/Sietima/Role/WithAdmin.pm | 50 -------------------------- lib/Sietima/Role/WithOwner.pm | 50 ++++++++++++++++++++++++++ t/tests/sietima/multi-role/debounce-moderate.t | 4 +-- t/tests/sietima/role/headers.t | 6 ++-- t/tests/sietima/role/subscriberonly/moderate.t | 8 ++--- 8 files changed, 68 insertions(+), 71 deletions(-) delete mode 100644 lib/Sietima/Role/WithAdmin.pm create mode 100644 lib/Sietima/Role/WithOwner.pm diff --git a/example/sietima b/example/sietima index 261a943..3e9e294 100755 --- a/example/sietima +++ b/example/sietima @@ -8,14 +8,14 @@ Sietima::CmdLine->new({ NoMail ReplyTo Headers - WithAdmin + WithOwner Debounce SubjectTag SubscriberOnly::Moderate WithMailStore )], args => { - admin => 'dakkar@thenautilus.net', + owner => 'dakkar@thenautilus.net', mail_store => { class => 'Sietima::MailStore::FS', root => '/tmp/sietima-store', diff --git a/lib/Sietima/Role/Headers.pm b/lib/Sietima/Role/Headers.pm index 27f79fb..166b355 100644 --- a/lib/Sietima/Role/Headers.pm +++ b/lib/Sietima/Role/Headers.pm @@ -67,9 +67,6 @@ sub _add_headers_to($self,$message) { ); } - # little renaming - $addresses->{owner} = delete $addresses->{admin}; - # if nobody declared a "post" address, let's guess it's the same # as the address we send from $addresses->{post} //= $return_path; diff --git a/lib/Sietima/Role/SubscriberOnly/Moderate.pm b/lib/Sietima/Role/SubscriberOnly/Moderate.pm index 0c56040..c0e4a01 100644 --- a/lib/Sietima/Role/SubscriberOnly/Moderate.pm +++ b/lib/Sietima/Role/SubscriberOnly/Moderate.pm @@ -13,7 +13,7 @@ Sietima::Role::SubscriberOnly::Moderate - moderate messages from non-subscribers my $sietima = Sietima->with_traits('SubscribersOnly::Moderate')->new({ %args, - admin => 'listmaster@example.com', + owner => 'listmaster@example.com', mail_store => { class => 'Sietima::MailStore::FS', root => '/tmp', @@ -24,26 +24,26 @@ Sietima::Role::SubscriberOnly::Moderate - moderate messages from non-subscribers A L<< C >> 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 admin. +such email will be forwarded (as an attachment) to the list's owner. -The admin will the be able to delete the message, or allow it. +The owner will the be able to delete the message, or allow it. This is a "sub-role" of L<< C|Sietima::Role::SubscriberOnly >>, L<< C|Sietima::Role::WithMailStore >>, and L<< -C|Sietima::Role::WithAdmin >>. +C|Sietima::Role::WithOwner >>. =cut with 'Sietima::Role::SubscriberOnly', 'Sietima::Role::WithMailStore', - 'Sietima::Role::WithAdmin'; + 'Sietima::Role::WithOwner'; sub munge_mail_from_non_subscriber ($self,$mail) { my $id = $self->mail_store->store($mail,'moderation'); my $notice = Email::Stuffer ->from($self->return_path->address) - ->to($self->admin->address) + ->to($self->owner->address) ->subject("Message held for moderation - ".$mail->header_str('subject')) ->text_body("Use id $id to refer to it") ->attach( @@ -53,7 +53,7 @@ sub munge_mail_from_non_subscriber ($self,$mail) { ); $self->transport->send($notice->email,{ from => $self->return_path, - to => [ $self->admin ], + to => [ $self->owner ], }); return; } diff --git a/lib/Sietima/Role/WithAdmin.pm b/lib/Sietima/Role/WithAdmin.pm deleted file mode 100644 index 2781bf8..0000000 --- a/lib/Sietima/Role/WithAdmin.pm +++ /dev/null @@ -1,50 +0,0 @@ -package Sietima::Role::WithAdmin; -use Moo::Role; -use Sietima::Policy; -use Sietima::Types qw(Address AddressFromStr); -use namespace::clean; - -=head1 NAME - -Sietima::Role::WithAdmin - role for lists with an owner / admin - -=head1 SYNOPSIS - - my $sietima = Sietima->with_traits('WithAdmin')->new({ - %args, - admin => 'listmaster@example.com', - }); - -=head1 DESCRIPTION - -This role adds an L<< /C >> attribute, and exposes it via the -L<< C|Sietima/list_addresses >> method. - -On its own, this role is not very useful, but other roles (like L<< -C|Sietima::Role::SubscriberOnly::Moderate ->>) can have uses for an admin / owner address. - -=head1 ATTRIBUTES - -=head2 C - -Required instance of L<< C >>, coercible from a -string. This is the address of the owner / admin of the list. - -=cut - -has admin => ( - is => 'ro', - isa => Address, - required => 1, - coerce => AddressFromStr, -); - -around list_addresses => sub($orig,$self) { - return +{ - $self->$orig->%*, - admin => $self->admin, - }; -}; - -1; diff --git a/lib/Sietima/Role/WithOwner.pm b/lib/Sietima/Role/WithOwner.pm new file mode 100644 index 0000000..dccb904 --- /dev/null +++ b/lib/Sietima/Role/WithOwner.pm @@ -0,0 +1,50 @@ +package Sietima::Role::WithOwner; +use Moo::Role; +use Sietima::Policy; +use Sietima::Types qw(Address AddressFromStr); +use namespace::clean; + +=head1 NAME + +Sietima::Role::WithOwner - role for lists with an owner + +=head1 SYNOPSIS + + my $sietima = Sietima->with_traits('WithOwner')->new({ + %args, + owner => 'listmaster@example.com', + }); + +=head1 DESCRIPTION + +This role adds an L<< /C >> attribute, and exposes it via the +L<< C|Sietima/list_addresses >> method. + +On its own, this role is not very useful, but other roles (like L<< +C|Sietima::Role::SubscriberOnly::Moderate +>>) can have uses for an owner address. + +=head1 ATTRIBUTES + +=head2 C + +Required instance of L<< C >>, coercible from a +string. This is the address of the owner of the list. + +=cut + +has owner => ( + is => 'ro', + isa => Address, + required => 1, + coerce => AddressFromStr, +); + +around list_addresses => sub($orig,$self) { + return +{ + $self->$orig->%*, + owner => $self->owner, + }; +}; + +1; diff --git a/t/tests/sietima/multi-role/debounce-moderate.t b/t/tests/sietima/multi-role/debounce-moderate.t index 8612df0..e61c551 100644 --- a/t/tests/sietima/multi-role/debounce-moderate.t +++ b/t/tests/sietima/multi-role/debounce-moderate.t @@ -8,13 +8,13 @@ sub test_one($traits,$should_send=1) { 'one@users.example.com', 'two@users.example.com', ); - my $admin = 'admin@lists.example.com'; + my $owner = 'owner@lists.example.com'; my $ms = Test::Sietima::MailStore->new(); my $s = make_sietima( with_traits => $traits, subscribers => \@subscriber_addresses, - admin => $admin, + owner => $owner, mail_store => $ms, ); diff --git a/t/tests/sietima/role/headers.t b/t/tests/sietima/role/headers.t index 7b3e4b7..3052781 100644 --- a/t/tests/sietima/role/headers.t +++ b/t/tests/sietima/role/headers.t @@ -17,9 +17,9 @@ package Sietima::Role::ForTesting { }; my $s = make_sietima( - with_traits => ['Headers','WithAdmin','ForTesting'], + with_traits => ['Headers','WithOwner','ForTesting'], name => 'test-list', - admin => 'admin@example.com', + owner => 'owner@example.com', subscribers => [ 'one@users.example.com', 'two@users.example.com', @@ -33,7 +33,7 @@ subtest 'list headers should be added' => sub { object { call sub { +{ shift->header_str_pairs } } => hash { field 'List-Id' => 'test-list '; - field 'List-Owner' => ''; + field 'List-Owner' => ''; field 'List-Post' => ''; field 'List-Test1' => ''; field 'List-Test-2' => 'http://test.example.com'; diff --git a/t/tests/sietima/role/subscriberonly/moderate.t b/t/tests/sietima/role/subscriberonly/moderate.t index c4e3005..44999bd 100644 --- a/t/tests/sietima/role/subscriberonly/moderate.t +++ b/t/tests/sietima/role/subscriberonly/moderate.t @@ -7,12 +7,12 @@ my @subscriber_addresses = ( 'one@users.example.com', 'two@users.example.com', ); -my $admin = 'admin@lists.example.com'; +my $owner = 'owner@lists.example.com'; my $ms = Test::Sietima::MailStore->new(); my $s = make_sietima( with_traits => ['SubscriberOnly::Moderate'], subscribers => \@subscriber_addresses, - admin => $admin, + owner => $owner, mail_store => $ms, ); @@ -38,7 +38,7 @@ sub test_from_non_sub() { o => object { call [header_str => 'subject'] => match qr{\bheld for moderation\b}; call [header_str => 'from'] => match qr{\b\Q$from\E\b}; - call [header_str => 'to'] => match qr{\b\Q$admin\E\b}; + call [header_str => 'to'] => match qr{\b\Q$owner\E\b}; call_list parts => [ object { call body => match qr{Use id \S+ to refer to it}; @@ -51,7 +51,7 @@ sub test_from_non_sub() { ]; }, from => $from, - to => [$admin], + to => [$owner], }], ); } -- cgit v1.2.3