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' --- 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 +++++++++++++++++++++++++++++ 4 files changed, 57 insertions(+), 60 deletions(-) delete mode 100644 lib/Sietima/Role/WithAdmin.pm create mode 100644 lib/Sietima/Role/WithOwner.pm (limited to 'lib') 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; -- cgit v1.2.3