From 714da2b50f0b027abe4b5b759c5fa3bbd3815089 Mon Sep 17 00:00:00 2001 From: dakkar Date: Tue, 14 Feb 2017 22:22:56 +0000 Subject: new role: ManualSubscription --- lib/Sietima.pm | 2 ++ lib/Sietima/Role/ManualSubscription.pm | 53 ++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 lib/Sietima/Role/ManualSubscription.pm (limited to 'lib') diff --git a/lib/Sietima.pm b/lib/Sietima.pm index e317147..98859ab 100644 --- a/lib/Sietima.pm +++ b/lib/Sietima.pm @@ -51,6 +51,8 @@ prevents the sender from receiving copies of their own messages avoids mail-loops using a C header = L<< C|Sietima::Role::Headers >> adds C headers to all outgoing messages += L<< C|Sietima::Role::ManualSubscription >> +specifies that to (un)subscribe, people should write to the list owner = L<< C|Sietima::Role::NoMail >> avoids sending messages to subscribers who don't want them = L<< C|Sietima::Role::ReplyTo >> diff --git a/lib/Sietima/Role/ManualSubscription.pm b/lib/Sietima/Role/ManualSubscription.pm new file mode 100644 index 0000000..fd75f80 --- /dev/null +++ b/lib/Sietima/Role/ManualSubscription.pm @@ -0,0 +1,53 @@ +package Sietima::Role::ManualSubscription; +use Moo::Role; +use Sietima::Policy; +use URI; +use namespace::clean; + +# VERSION +# ABSTRACT: adds standard list-related headers to messages + +with 'Sietima::Role::WithOwner'; + +=head1 SYNOPSIS + + my $sietima = Sietima->with_traits( + 'Headers', + 'ManualSubscription', + )->new({ + %args, + owner => 'listmaster@example.com', + }); + +=head1 DESCRIPTION + +A L<< C >> list with this role (and L<< +C|Sietima::Role::Headers >>) applied will add, to each +outgoing message, headers specifying that to subscribe and +unsubscribe, people sould email the list owner. + +=modif C + +This method declares two "addresses", C and +C. Both are C URLs for the list +L, with different subjects. + +=cut + +around list_addresses => sub($orig,$self) { + my $list_name = $self->name // 'the list'; + my $mail_owner_uri = URI->new($self->owner,'mailto'); + my $sub_uri = $mail_owner_uri->clone; + $sub_uri->query_form(subject => "Please add me to $list_name"); + my $unsub_uri = $mail_owner_uri->clone; + $unsub_uri->query_form(subject => "Please remove me from $list_name"); + + return +{ + $self->$orig->%*, + subscribe => $sub_uri, + unsubscribe => $unsub_uri, + }; +}; + + +1; -- cgit v1.2.3