| 1 | 27 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 2 | package Siesta::Message; | ||||||||||||||||||||||||||||
| 3 | 27 | ▶ | use Siesta; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 27 | ▶ | use Siesta::Deferred; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 27 | ▶ | use Mail::Address; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 27 | ▶ | use Carp qw( carp croak ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 27 | ▶ | use Storable qw(dclone); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 27 | ▶ | use base qw( Email::Simple Class::Accessor::Fast ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 27 | __PACKAGE__->mk_accessors(qw( plugins )); | |||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | =head1 NAME | ||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | Siesta::Message - a message in the system | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | =head1 METHODS | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | =cut | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | # make a bunch of header-based accessors | ||||||||||||||||||||||||||||
| 20 | 27 | for (qw( to_raw from_raw subject )) { | |||||||||||||||||||||||||||
| 21 | 81 | my $header = $_; | |||||||||||||||||||||||||||
| 22 | 81 | my $sub_name = $header; | |||||||||||||||||||||||||||
| 23 | 81 | $header =~ s/_raw$//; | |||||||||||||||||||||||||||
| 24 | 44 | ▶ | my $sub = sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 25 | 44 | my $self = shift; | |||||||||||||||||||||||||||
| 26 | 44 | ▶ | if (@_) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 27 | 13 | $self->header_set( $header, shift ); | |||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||
| 29 | 44 | return $self->header( $header ); | |||||||||||||||||||||||||||
| 30 | 81 | }; | |||||||||||||||||||||||||||
| 31 | 27 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 32 | 81 | *{ $sub_name } = $sub; | |||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 31 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||
| 36 | 31 | my $referent = shift; | |||||||||||||||||||||||||||
| 37 | 31 | ▶ | my $class = ref $referent || $referent; | ||||||||||||||||||||||||||
|
Condition33%1/3
ref $referent || $referent
MC/DC0%0/2
ref $referent || $referent
ref $referent
$referent
Truth table33%1/3
A || B
A= ref $referentB= $referent
| |||||||||||||||||||||||||||||
| 38 | 31 | ▶ | my $data = shift || ""; | ||||||||||||||||||||||||||
|
Condition100%2/2
shift() || ''
MC/DC100%1/1
shift() || ''
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 31 | ▶ | if (ref $data eq 'GLOB') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 41 | 2 | $data = join '', <$data>; | |||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||
| 43 | # chomp out From_ lines from naughty MTAs | ||||||||||||||||||||||||||||
| 44 | 31 | $data =~ s/^From .+$//m; | |||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | 31 | my $self = $class->SUPER::new( $data ); | |||||||||||||||||||||||||||
| 47 | 31 | $self->plugins( [] ); | |||||||||||||||||||||||||||
| 48 | 31 | return $self; | |||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | =head2 to | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | a list of addresses that the message was to | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | =cut | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | 7 | ▶ | sub to { | ||||||||||||||||||||||||||
|
Subroutine
to: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 59 | 7 | my $self = shift; | |||||||||||||||||||||||||||
| 60 | 7 | map { $_->address } Mail::Address->parse( $self->header('To') ); | |||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | =head2 from | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | the email address that the message was from | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | =cut | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | 27 | ▶ | sub from { | ||||||||||||||||||||||||||
|
Subroutine
from: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 70 | 27 | my $self = shift; | |||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | 27 | ( map { $_->address } Mail::Address->parse( $self->header('From') ) )[0]; | |||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | =head2 subject | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | =head2 reply | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | =cut | ||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | 13 | ▶ | sub reply { | ||||||||||||||||||||||||||
|
Subroutine
reply: called CC=6 SCAR=18.2
Pod
documented
| |||||||||||||||||||||||||||||
| 82 | 13 | my $self = shift; | |||||||||||||||||||||||||||
| 83 | 13 | my %args = @_; | |||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | 13 | my $new = Siesta::Message->new; | |||||||||||||||||||||||||||
| 86 | 13 | ▶ | $new->body_set( $args{body} || $self->body ); | ||||||||||||||||||||||||||
|
Condition33%1/3
$args{'body'} || $self->body
MC/DC0%0/2
$args{'body'} || $self->body
$args{'body'}
$self->body
Truth table33%1/3
A || B
A= $args{'body'}B= $self->body
| |||||||||||||||||||||||||||||
| 87 | 13 | ▶ | $new->header_set( 'To', $args{to} || $self->from ); | ||||||||||||||||||||||||||
|
Condition66%2/3
$args{'to'} || $self->from
MC/DC0%0/2
$args{'to'} || $self->from
$args{'to'}
$self->from
Truth table66%2/3
A || B
A= $args{'to'}B= $self->from
| |||||||||||||||||||||||||||||
| 88 | 13 | ▶ | $new->header_set( 'From', $args{from} || ( $self->to )[0] ); | ||||||||||||||||||||||||||
|
Condition66%2/3
$args{'from'} || ($self->to)[0]
MC/DC0%0/2
$args{'from'} || ($self->to)[0]
$args{'from'}
($self->to)[0]
Truth table66%2/3
A || B
A= $args{'from'}B= ($self->to)[0]
| |||||||||||||||||||||||||||||
| 89 | $new->header_set( 'Subject', $args{subject} || | ||||||||||||||||||||||||||||
| 90 | 13 | ▶ | "Re: " . ( $self->subject || "Your mail" ) ); | ||||||||||||||||||||||||||
|
Condition100%4/4
$args{'subject'} || 'Re: ' . ($self->subject || 'Your mail')
$self->subject || 'Your mail'
MC/DC100%1/1
$args{'subject'} || 'Re: ' . ($self->subject || 'Your mail')
$args{'subject'}
MC/DC100%1/1
$self->subject || 'Your mail'
$self->subject
Truth table100%2/2
A
A= $args{'subject'}
Truth table100%2/2
A
A= $self->subject
| |||||||||||||||||||||||||||||
| 91 | 13 | $new->header_set( 'In-Reply-To', $self->header( 'Message-Id' ) ); | |||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | 13 | $new->send; | |||||||||||||||||||||||||||
| 94 | 13 | Siesta->log("Message->reply sending" . $new->as_string, 10); | |||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | =head2 send | ||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | =cut | ||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | 13 | ▶ | sub send { | ||||||||||||||||||||||||||
|
Subroutine
send: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 102 | 13 | my $self = shift; | |||||||||||||||||||||||||||
| 103 | 13 | return Siesta->sender->send( $self, @_ ); | |||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | =head2 clone | ||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | =cut | ||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | 1 | ▶ | sub clone { | ||||||||||||||||||||||||||
|
Subroutine
clone: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 111 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | 1 | return dclone $self; | |||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | =head2 defer | ||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | =cut | ||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | 8 | ▶ | sub defer { | ||||||||||||||||||||||||||
|
Subroutine
defer: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 121 | 8 | my $self = shift; | |||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||
| 123 | Siesta::Deferred->create({ | ||||||||||||||||||||||||||||
| 124 | @_, | ||||||||||||||||||||||||||||
| 125 | 8 | plugins => join(',', @{ $self->plugins } ), | |||||||||||||||||||||||||||
| 126 | message => $self, | ||||||||||||||||||||||||||||
| 127 | }); | ||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||
| 131 | # XXX compatibility shim, excise soonest | ||||||||||||||||||||||||||||
| 132 | 0 | ▶ | sub resume { | ||||||||||||||||||||||||||
|
Subroutine
resume: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 133 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 134 | 0 | my $id = shift; | |||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | 0 | carp "Siesta::Message->resume is deprected, use resume on a Siesta::Deferred object instead"; | |||||||||||||||||||||||||||
| 137 | 0 | my $deferred = Siesta::Deferred->retrieve( $id ); | |||||||||||||||||||||||||||
| 138 | 0 | $deferred->resume; | |||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||
| 141 | 2 | ▶ | sub process { | ||||||||||||||||||||||||||
|
Subroutine
process: called CC=4 SCAR=14.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 142 | 2 | my $self = shift; | |||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||
| 144 | 2 | ▶ | while ( my $plugin = shift @{ $self->plugins } ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 145 | # SIESTA_NON_STOP is used by 20fullsend.t to ensure | ||||||||||||||||||||||||||||
| 146 | # excercising of everything. it means "run the next plugin, | ||||||||||||||||||||||||||||
| 147 | # even if the last one said to stop" | ||||||||||||||||||||||||||||
| 148 | 17 | Siesta->log("... doing " . $plugin->name, 1); | |||||||||||||||||||||||||||
| 149 | 17 | ▶ | return if $plugin->process($self) && !$ENV{SIESTA_NON_STOP}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$plugin->process($self) and not $ENV{"SIESTA_NON_STOP"}
MC/DC0%0/2
$plugin->process($self) and not $ENV{"SIESTA_NON_STOP"}
$plugin->process($self)
not $ENV{"SIESTA_NON_STOP"}
Truth table66%2/3
A and not(B)
A= $plugin->process($self)B= not $ENV{"SIESTA_NON_STOP"}
| |||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||
| 153 | 27 | 1; | |||||||||||||||||||||||||||