Sietima/Role/ReplyTo.pm

filter: Statementstmt 100% 36 / 36 Branchbran 100% 10 / 10 Conditioncond 66.6% 4 / 6 MC/DCmcdc 50.0% 2 / 4 Subroutinesub 100% 7 / 7 Podpod n/a totaltotal 93.6% 59 / 63 CC 9 SCAR 13.4
CC
9
Cov
96%
__ANON__
6.0
__ANON__
4.0
BEGIN
1.0
CRAP 3.8
« Sietima/HeaderURI.pm ↑ Summary Sietima/MailStore/FS.pm »
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
BranchTrueFalseTotal
defined $m ? : 2 8 10
$m ? : 1 1 2
$self->munge_reply_to ? : 5 3 8
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
BranchTrueFalseTotal
if (not $munge && @$munge) { } 1 4 5
elsif (not $leave && @$leave) { } 2 2 4
Condition66%2/3
$munge && @$munge
!ll&&!rl&&r
104
MC/DC50%1/2
$munge && @$munge
$munge @$munge
Truth table66%2/3
A && B
A= $mungeB= @$munge
ABresult
0X0
100
111
34 # nothing to do
35 1 push @ret,$m;
36 }
37 ▶ elsif (not ($leave and $leave->@*)) {
Condition66%2/3
$leave && @$leave
!ll&&!rl&&r
202
MC/DC50%1/2
$leave && @$leave
$leave @$leave
Truth table66%2/3
A && B
A= $leaveB= @$leave
ABresult
0X0
100
111
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__
« Sietima/HeaderURI.pm ↑ Summary Sietima/MailStore/FS.pm »