From 3efd2284c8fd21c0a828b1ce5be913a83682019e Mon Sep 17 00:00:00 2001 From: dakkar Date: Wed, 4 Jan 2017 16:07:14 +0000 Subject: fix&test malformed moderation email --- TODO.md | 1 - lib/Sietima/Role/SubscriberOnly/Moderate.pm | 4 ++-- t/lib/Test/Sietima.pm | 1 + t/tests/sietima/role/subscriberonly/moderate.t | 4 ++++ 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/TODO.md b/TODO.md index 487e90b..c47b836 100644 --- a/TODO.md +++ b/TODO.md @@ -4,7 +4,6 @@ * messy permissions, we should set some umask (we'd like group-writable mailstore) * `Moderate`+`Debounce` means resuming fails to send - * moderation notice email is badly formed * maybe auto-mkpath for `::MailStore::FS`? * list footer * append to plain text single part diff --git a/lib/Sietima/Role/SubscriberOnly/Moderate.pm b/lib/Sietima/Role/SubscriberOnly/Moderate.pm index 8bfef2f..966f2d3 100644 --- a/lib/Sietima/Role/SubscriberOnly/Moderate.pm +++ b/lib/Sietima/Role/SubscriberOnly/Moderate.pm @@ -12,8 +12,8 @@ with 'Sietima::Role::SubscriberOnly', sub munge_mail_from_non_subscriber ($self,$mail) { my $id = $self->mail_store->store($mail,'moderation'); my $notice = Email::Stuffer - ->from($self->return_path) - ->to($self->admin) + ->from($self->return_path->address) + ->to($self->admin->address) ->subject("Message held for moderation - ".$mail->header_str('subject')) ->text_body("Use id $id to refer to it") ->attach($mail->as_string, content_type => 'message/rfc822'); diff --git a/t/lib/Test/Sietima.pm b/t/lib/Test/Sietima.pm index d7b720c..a94a51c 100644 --- a/t/lib/Test/Sietima.pm +++ b/t/lib/Test/Sietima.pm @@ -86,6 +86,7 @@ sub deliveries_are (%args) { field to => bag { item $_ for $m->{to}->@*; }; + field from => $m->{from} if $m->{from}; etc(); }; } diff --git a/t/tests/sietima/role/subscriberonly/moderate.t b/t/tests/sietima/role/subscriberonly/moderate.t index be996e3..c4e3005 100644 --- a/t/tests/sietima/role/subscriberonly/moderate.t +++ b/t/tests/sietima/role/subscriberonly/moderate.t @@ -30,12 +30,15 @@ subtest 'from subscriber' => sub { }; sub test_from_non_sub() { + my $from = $s->return_path->address; test_sending( sietima => $s, mail => { from=>'someone@users.example.com' }, mails => [{ 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_list parts => [ object { call body => match qr{Use id \S+ to refer to it}; @@ -47,6 +50,7 @@ sub test_from_non_sub() { }, ]; }, + from => $from, to => [$admin], }], ); -- cgit v1.2.3