diff options
Diffstat (limited to 'lib/Sietima/Role/ReplyTo.pm')
-rw-r--r-- | lib/Sietima/Role/ReplyTo.pm | 49 |
1 files changed, 27 insertions, 22 deletions
diff --git a/lib/Sietima/Role/ReplyTo.pm b/lib/Sietima/Role/ReplyTo.pm index 5962451..c9de1a4 100644 --- a/lib/Sietima/Role/ReplyTo.pm +++ b/lib/Sietima/Role/ReplyTo.pm @@ -26,14 +26,21 @@ Sietima::Role::ReplyTo - munge the C<Reply-To> header =head1 DESCRIPTION A L<< C<Sietima> >> list with this role applied will, on request, set -the C<Reply-To:> header to the value of the L<< /C<post_address> >> -attribute. +the C<Reply-To:> header to the value of the L<< +C<post_address>|Sietima::Role::WithPostAddress >> attribute. This behaviour can be selected both at the list level (with the L<< /C<munge_reply_to> >> attribute) and at the subscriber level (with the C<munge_reply_to> preference). By default, the C<Reply-To:> header is not touched. +This is a "sub-role" of L<< +C<WithPostAddress>|Sietima::Role::WithPostAddress >>. + +=cut + +with 'Sietima::Role::WithPostAddress'; + =head1 ATTRIBUTES =head2 C<munge_reply_to> @@ -51,23 +58,28 @@ has munge_reply_to => ( default => 0, ); -=head2 C<post_address> +=head1 MODIFIED METHODS -An L<< C<Email::Address> >> object, defaults to the value of the L<< -C<return_path>|Sietima/return_path >> attribute. This is the address -that the mailing list receives messages at. +=head2 C<munge_mail> -This role extends the L<< C<list_addresses>|Sietima/list_addresses >> -method to include this address. +For each message returned by the original method, this method +partitions the subscribers, who are recipients of the message, +according to their C<munge_reply_to> preference (or the L<< +/C<munge_reply_to> >> attribute, if a subscriber does not have the +preference set). -=cut +If no recipients want the C<Reply-To:> header modified, this method +will just pass the message through. -has post_address => ( - is => 'lazy', - isa => Address, - coerce => AddressFromStr, -); -sub _build_post_address($self) { $self->return_path } +If all recipients want the C<Reply-To:> header modified, this method +will set the header, and pass the modified message. + +If some recipients want the C<Reply-To:> header modified, and some +don't, this method will clone the message, modify the header in one +copy, set the appropriate part of the recipients to each copy, and +pass both through. + +=cut around munge_mail => sub ($orig,$self,$mail) { my @messages = $self->$orig($mail); @@ -112,11 +124,4 @@ around munge_mail => sub ($orig,$self,$mail) { return @ret; }; -around list_addresses => sub ($orig,$self) { - return +{ - $self->$orig->%*, - post => $self->post_address, - }; -}; - 1; |