| 1 | package Sietima::Role::ReplyTo; | ||||||||||||||||||||||||||||||||
| 2 | 2 | ▶ | use Moo::Role; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use Sietima::Policy; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use Types::Standard qw(Bool); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use List::AllUtils qw(part); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use namespace::clean; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||
| 8 | 2 | our $VERSION = '1.1.5'; # VERSION | |||||||||||||||||||||||||||||||
| 9 | # ABSTRACT: munge the C<Reply-To> header | ||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||
| 12 | 2 | with 'Sietima::Role::WithPostAddress'; | |||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||
| 15 | 2 | has munge_reply_to => ( | |||||||||||||||||||||||||||||||
| 16 | is => 'ro', | ||||||||||||||||||||||||||||||||
| 17 | isa => Bool, | ||||||||||||||||||||||||||||||||
| 18 | default => 0, | ||||||||||||||||||||||||||||||||
| 19 | ); | ||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||
| 22 | 5 | ▶ | around munge_mail => sub ($orig,$self,$mail) { | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=6 SCAR=17.9
| |||||||||||||||||||||||||||||||||
| 23 | 5 | my @messages = $self->$orig($mail); | |||||||||||||||||||||||||||||||
| 24 | 5 | my @ret; | |||||||||||||||||||||||||||||||
| 25 | 5 | for my $m (@messages) { | |||||||||||||||||||||||||||||||
| 26 | 10 | ▶ | my ($leave,$munge) = part { | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||
| 27 | 10 | my $m = $_->prefs->{munge_reply_to}; | |||||||||||||||||||||||||||||||
| 28 | 10 | ▶ | defined $m ? ( | ||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||
| 29 | $m ? 1 : 0 | ||||||||||||||||||||||||||||||||
| 30 | ) : ( $self->munge_reply_to ? 1 : 0 ) | ||||||||||||||||||||||||||||||||
| 31 | 5 | } $m->to->@*; | |||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||
| 33 | 5 | ▶ | if (not ($munge and $munge->@*)) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
$munge && @$munge
MC/DC50%1/2
$munge && @$munge
$munge
@$munge
Truth table66%2/3
A && B
A= $mungeB= @$munge
| |||||||||||||||||||||||||||||||||
| 34 | # nothing to do | ||||||||||||||||||||||||||||||||
| 35 | 1 | push @ret,$m; | |||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||
| 37 | ▶ | elsif (not ($leave and $leave->@*)) { | |||||||||||||||||||||||||||||||
|
Condition66%2/3
$leave && @$leave
MC/DC50%1/2
$leave && @$leave
$leave
@$leave
Truth table66%2/3
A && B
A= $leaveB= @$leave
| |||||||||||||||||||||||||||||||||
| 38 | # all these recipients want munging | ||||||||||||||||||||||||||||||||
| 39 | 2 | $m->mail->header_str_set('Reply-To',$self->post_address->address); | |||||||||||||||||||||||||||||||
| 40 | 2 | push @ret,$m; | |||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||
| 42 | else { | ||||||||||||||||||||||||||||||||
| 43 | # some want it, some don't: create two different messages | ||||||||||||||||||||||||||||||||
| 44 | 2 | my $leave_message = Sietima::Message->new({ | |||||||||||||||||||||||||||||||
| 45 | mail => $m->mail, | ||||||||||||||||||||||||||||||||
| 46 | from => $m->from, | ||||||||||||||||||||||||||||||||
| 47 | to => $leave, | ||||||||||||||||||||||||||||||||
| 48 | }); | ||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||
| 50 | 2 | my $munged_mail = Email::MIME->new($m->mail->as_string); | |||||||||||||||||||||||||||||||
| 51 | 2 | $munged_mail->header_str_set('Reply-To',$self->post_address->address); | |||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||
| 53 | 2 | my $munged_message = Sietima::Message->new({ | |||||||||||||||||||||||||||||||
| 54 | mail => $munged_mail, | ||||||||||||||||||||||||||||||||
| 55 | from => $m->from, | ||||||||||||||||||||||||||||||||
| 56 | to => $munge, | ||||||||||||||||||||||||||||||||
| 57 | }); | ||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||
| 59 | 2 | push @ret,$leave_message,$munged_message; | |||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||
| 62 | 5 | return @ret; | |||||||||||||||||||||||||||||||
| 63 | 2 | }; | |||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||
| 65 | 2 | 1; | |||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||
| 67 | __END__ | ||||||||||||||||||||||||||||||||