| 1 | package Mail::Decency::Core::SessionItem; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 20 | ▶ | use Moose; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | |||||||||||||||||||||
| 5 | 20 | ▶ | use version 0.74; our $VERSION = qv( "v0.1.4" ); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | |||||||||||||||||||||
| 7 | =head1 NAME | ||||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | Mail::Decency::Core::SessionItem | ||||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | =head1 DESCRIPTION | ||||||||||||||||||||
| 12 | |||||||||||||||||||||
| 13 | Represents an session item for either policy or content filter. | ||||||||||||||||||||
| 14 | Base class, don't instantiate! | ||||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | =head1 CLASS ATTRIBUTES | ||||||||||||||||||||
| 17 | |||||||||||||||||||||
| 18 | =head2 id | ||||||||||||||||||||
| 19 | |||||||||||||||||||||
| 20 | The primary identifier | ||||||||||||||||||||
| 21 | |||||||||||||||||||||
| 22 | =cut | ||||||||||||||||||||
| 23 | |||||||||||||||||||||
| 24 | 20 | has id => ( is => 'rw', isa => "Str", required => 1 ); | |||||||||||||||||||
| 25 | |||||||||||||||||||||
| 26 | =head2 spam_score | ||||||||||||||||||||
| 27 | |||||||||||||||||||||
| 28 | Current spam score | ||||||||||||||||||||
| 29 | |||||||||||||||||||||
| 30 | =cut | ||||||||||||||||||||
| 31 | |||||||||||||||||||||
| 32 | 20 | has spam_score => ( is => 'rw', isa => 'Num', default => 0 ); | |||||||||||||||||||
| 33 | |||||||||||||||||||||
| 34 | =head2 spam_details | ||||||||||||||||||||
| 35 | |||||||||||||||||||||
| 36 | List of details for spam | ||||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | =cut | ||||||||||||||||||||
| 39 | |||||||||||||||||||||
| 40 | 0 | ▶ | has spam_details => ( is => 'rw', isa => 'ArrayRef[Str]', default => sub { [] } ); | ||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||
| 41 | |||||||||||||||||||||
| 42 | =head2 flags | ||||||||||||||||||||
| 43 | |||||||||||||||||||||
| 44 | Hashref of flags which can be set | ||||||||||||||||||||
| 45 | |||||||||||||||||||||
| 46 | =cut | ||||||||||||||||||||
| 47 | |||||||||||||||||||||
| 48 | 0 | ▶ | has flags => ( is => 'rw', isa => 'HashRef[Int]', default => sub { {} } ); | ||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||
| 49 | |||||||||||||||||||||
| 50 | =head2 cache | ||||||||||||||||||||
| 51 | |||||||||||||||||||||
| 52 | Accessor to the parentl cache | ||||||||||||||||||||
| 53 | |||||||||||||||||||||
| 54 | =cut | ||||||||||||||||||||
| 55 | |||||||||||||||||||||
| 56 | 20 | has cache => ( is => 'rw', isa => 'Mail::Decency::Helper::Cache', required => 1, weak_ref => 1 ); | |||||||||||||||||||
| 57 | |||||||||||||||||||||
| 58 | =head2 from | ||||||||||||||||||||
| 59 | |||||||||||||||||||||
| 60 | Sender of the current mail | ||||||||||||||||||||
| 61 | |||||||||||||||||||||
| 62 | =cut | ||||||||||||||||||||
| 63 | |||||||||||||||||||||
| 64 | 0 | ▶ | has from => ( is => 'rw', isa => "Str", trigger => sub { | ||||||||||||||||||
|
Subroutine
__ANON__: not called CC=6 SCAR=37.4
| |||||||||||||||||||||
| 65 | 0 | my ( $self, $from ) = @_; | |||||||||||||||||||
| 66 | 0 | ▶ | my ( $prefix, $domain ) = split( /\@/, $from || "" ); | ||||||||||||||||||
|
Condition0%0/2
$from || ''
MC/DC0%0/1
$from || ''
$from
Truth table0%0/2
A
A= $from
| |||||||||||||||||||||
| 67 | 0 | ▶ | $self->from_prefix( $prefix || "" ) if $prefix; | ||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$prefix || ''
MC/DC0%0/1
$prefix || ''
$prefix
Truth table0%0/2
A
A= $prefix
| |||||||||||||||||||||
| 68 | 0 | ▶ | $self->from_domain( $domain || "" ) if $domain; | ||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$domain || ''
MC/DC0%0/1
$domain || ''
$domain
Truth table0%0/2
A
A= $domain
| |||||||||||||||||||||
| 69 | 20 | } ); | |||||||||||||||||||
| 70 | |||||||||||||||||||||
| 71 | =head2 from_prefix | ||||||||||||||||||||
| 72 | |||||||||||||||||||||
| 73 | The prefix part of the mail FROM | ||||||||||||||||||||
| 74 | |||||||||||||||||||||
| 75 | =cut | ||||||||||||||||||||
| 76 | |||||||||||||||||||||
| 77 | 20 | has from_prefix => ( is => 'rw', isa => "Str" ); | |||||||||||||||||||
| 78 | |||||||||||||||||||||
| 79 | =head2 from_domain | ||||||||||||||||||||
| 80 | |||||||||||||||||||||
| 81 | The domain part of the mail FROM | ||||||||||||||||||||
| 82 | |||||||||||||||||||||
| 83 | =cut | ||||||||||||||||||||
| 84 | |||||||||||||||||||||
| 85 | 20 | has from_domain => ( is => 'rw', isa => "Str" ); | |||||||||||||||||||
| 86 | |||||||||||||||||||||
| 87 | =head2 to | ||||||||||||||||||||
| 88 | |||||||||||||||||||||
| 89 | Recipient of the current mail | ||||||||||||||||||||
| 90 | |||||||||||||||||||||
| 91 | =cut | ||||||||||||||||||||
| 92 | |||||||||||||||||||||
| 93 | 0 | ▶ | has to => ( is => 'rw', isa => "Str", trigger => sub { | ||||||||||||||||||
|
Subroutine
__ANON__: not called CC=6 SCAR=37.4
| |||||||||||||||||||||
| 94 | 0 | my ( $self, $to ) = @_; | |||||||||||||||||||
| 95 | 0 | ▶ | my ( $prefix, $domain ) = split( /\@/, $to || "" ); | ||||||||||||||||||
|
Condition0%0/2
$to || ''
MC/DC0%0/1
$to || ''
$to
Truth table0%0/2
A
A= $to
| |||||||||||||||||||||
| 96 | 0 | ▶ | $self->to_prefix( $prefix || "" ) if $prefix; | ||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$prefix || ''
MC/DC0%0/1
$prefix || ''
$prefix
Truth table0%0/2
A
A= $prefix
| |||||||||||||||||||||
| 97 | 0 | ▶ | $self->to_domain( $domain || "" ) if $domain; | ||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$domain || ''
MC/DC0%0/1
$domain || ''
$domain
Truth table0%0/2
A
A= $domain
| |||||||||||||||||||||
| 98 | 20 | } ); | |||||||||||||||||||
| 99 | |||||||||||||||||||||
| 100 | =head2 to_prefix | ||||||||||||||||||||
| 101 | |||||||||||||||||||||
| 102 | The prefix part ot the RCPT TO | ||||||||||||||||||||
| 103 | |||||||||||||||||||||
| 104 | =cut | ||||||||||||||||||||
| 105 | |||||||||||||||||||||
| 106 | 20 | has to_prefix => ( is => 'rw', isa => "Str" ); | |||||||||||||||||||
| 107 | |||||||||||||||||||||
| 108 | =head2 to_domain | ||||||||||||||||||||
| 109 | |||||||||||||||||||||
| 110 | The domain part ot the RCPT TO | ||||||||||||||||||||
| 111 | |||||||||||||||||||||
| 112 | =cut | ||||||||||||||||||||
| 113 | |||||||||||||||||||||
| 114 | 20 | has to_domain => ( is => 'rw', isa => "Str" ); | |||||||||||||||||||
| 115 | |||||||||||||||||||||
| 116 | =head1 METHODS | ||||||||||||||||||||
| 117 | |||||||||||||||||||||
| 118 | =head2 add_spam_score | ||||||||||||||||||||
| 119 | |||||||||||||||||||||
| 120 | add score | ||||||||||||||||||||
| 121 | |||||||||||||||||||||
| 122 | =cut | ||||||||||||||||||||
| 123 | |||||||||||||||||||||
| 124 | 0 | ▶ | sub add_spam_score { | ||||||||||||||||||
|
Subroutine
add_spam_score: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 125 | 0 | my ( $self, $add ) = @_; | |||||||||||||||||||
| 126 | 0 | return $self->spam_score( $self->spam_score + $add ); | |||||||||||||||||||
| 127 | } | ||||||||||||||||||||
| 128 | |||||||||||||||||||||
| 129 | |||||||||||||||||||||
| 130 | =head2 add_spam_details | ||||||||||||||||||||
| 131 | |||||||||||||||||||||
| 132 | Adds spam details to the list | ||||||||||||||||||||
| 133 | |||||||||||||||||||||
| 134 | =cut | ||||||||||||||||||||
| 135 | |||||||||||||||||||||
| 136 | 0 | ▶ | sub add_spam_details { | ||||||||||||||||||
|
Subroutine
add_spam_details: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||
| 137 | 0 | my ( $self, @details ) = @_; | |||||||||||||||||||
| 138 | 0 | ▶ | push @{ $self->spam_details }, grep { defined $_ && $_ ne "" } @details; | ||||||||||||||||||
|
Condition0%0/3
defined $_ && $_ ne ''
MC/DC0%0/2
defined $_ && $_ ne ''
defined $_
$_ ne ''
Truth table0%0/3
A && B
A= defined $_B= $_ ne ''
| |||||||||||||||||||||
| 139 | 0 | return; | |||||||||||||||||||
| 140 | } | ||||||||||||||||||||
| 141 | |||||||||||||||||||||
| 142 | |||||||||||||||||||||
| 143 | =head2 (del|set|has)_flag | ||||||||||||||||||||
| 144 | |||||||||||||||||||||
| 145 | Set, remove or query wheter has flag | ||||||||||||||||||||
| 146 | |||||||||||||||||||||
| 147 | =cut | ||||||||||||||||||||
| 148 | |||||||||||||||||||||
| 149 | 0 | ▶ | sub has_flag { | ||||||||||||||||||
|
Subroutine
has_flag: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 150 | 0 | my ( $self, $flag ) = @_; | |||||||||||||||||||
| 151 | 0 | return defined $self->flags->{ $flag }; | |||||||||||||||||||
| 152 | } | ||||||||||||||||||||
| 153 | |||||||||||||||||||||
| 154 | 0 | ▶ | sub set_flag { | ||||||||||||||||||
|
Subroutine
set_flag: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 155 | 0 | my ( $self, $flag ) = @_; | |||||||||||||||||||
| 156 | 0 | return $self->flags->{ $flag } = 1; | |||||||||||||||||||
| 157 | } | ||||||||||||||||||||
| 158 | |||||||||||||||||||||
| 159 | 0 | ▶ | sub del_flag { | ||||||||||||||||||
|
Subroutine
del_flag: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 160 | 0 | my ( $self, $flag ) = @_; | |||||||||||||||||||
| 161 | 0 | return delete $self->flags->{ $flag }; | |||||||||||||||||||
| 162 | } | ||||||||||||||||||||
| 163 | |||||||||||||||||||||
| 164 | |||||||||||||||||||||
| 165 | =head2 unset | ||||||||||||||||||||
| 166 | |||||||||||||||||||||
| 167 | =cut | ||||||||||||||||||||
| 168 | |||||||||||||||||||||
| 169 | 0 | ▶ | sub unset { | ||||||||||||||||||
|
Subroutine
unset: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||
| 170 | 0 | my ( $self ) = @_; | |||||||||||||||||||
| 171 | 0 | delete $self->{ $_ } for keys %$self | |||||||||||||||||||
| 172 | } | ||||||||||||||||||||
| 173 | |||||||||||||||||||||
| 174 | |||||||||||||||||||||
| 175 | =head1 AUTHOR | ||||||||||||||||||||
| 176 | |||||||||||||||||||||
| 177 | Ulrich Kautz <uk@fortrabbit.de> | ||||||||||||||||||||
| 178 | |||||||||||||||||||||
| 179 | =head1 COPYRIGHT | ||||||||||||||||||||
| 180 | |||||||||||||||||||||
| 181 | Copyright (c) 2010 the L</AUTHOR> as listed above | ||||||||||||||||||||
| 182 | |||||||||||||||||||||
| 183 | =head1 LICENCSE | ||||||||||||||||||||
| 184 | |||||||||||||||||||||
| 185 | This library is free software and may be distributed under the same terms as perl itself. | ||||||||||||||||||||
| 186 | |||||||||||||||||||||
| 187 | =cut | ||||||||||||||||||||
| 188 | |||||||||||||||||||||
| 189 | 20 | 1; | |||||||||||||||||||