line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::SpamcupNG::Summary::Receiver; |
2
|
7
|
|
|
7
|
|
50
|
use warnings; |
|
7
|
|
|
|
|
17
|
|
|
7
|
|
|
|
|
228
|
|
3
|
7
|
|
|
7
|
|
63
|
use strict; |
|
7
|
|
|
|
|
15
|
|
|
7
|
|
|
|
|
173
|
|
4
|
7
|
|
|
7
|
|
61
|
use parent qw(Class::Accessor); |
|
7
|
|
|
|
|
14
|
|
|
7
|
|
|
|
|
164
|
|
5
|
7
|
|
|
7
|
|
488
|
use Hash::Util 'lock_hash'; |
|
7
|
|
|
|
|
13
|
|
|
7
|
|
|
|
|
34
|
|
6
|
7
|
|
|
7
|
|
411
|
use Carp 'confess'; |
|
7
|
|
|
|
|
15
|
|
|
7
|
|
|
|
|
351
|
|
7
|
|
|
|
|
|
|
|
8
|
7
|
|
|
7
|
|
44
|
use App::SpamcupNG::Summary; |
|
7
|
|
|
|
|
14
|
|
|
7
|
|
|
|
|
59
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.016'; # VERSION |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=pod |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 NAME |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
App::SpamcupNG::Summary::Receiver - representation of a SPAM report receiver |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 DESCRIPTION |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
This class was created to facilitate the handling of submitted SPAM reports for |
21
|
|
|
|
|
|
|
the interested parties. Sometimes a party doesn't actually receive a report and |
22
|
|
|
|
|
|
|
that is expected by design. |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=over |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=item email: the "e-mail" of the report |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=item report_id: the ID of the sent report |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=back |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
Sometimes a SPAM report is not sent to an e-mail address, Spamcop calls that |
35
|
|
|
|
|
|
|
"devnull'ing": the report is just stored for statistical reasons, no real |
36
|
|
|
|
|
|
|
e-mail address receive the report. |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
In those cases, only the indication of the domain that would receive the SPAM |
39
|
|
|
|
|
|
|
report is stored, without a report sent ID (actually this ID exists, but the |
40
|
|
|
|
|
|
|
web interface does not exports that info). |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=cut |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# TODO: follow best practice |
45
|
|
|
|
|
|
|
my @fields = ( 'email', 'report_id' ); |
46
|
|
|
|
|
|
|
__PACKAGE__->mk_ro_accessors(@fields); |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head1 METHODS |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head2 new |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
Creates a new instance. |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
Expects as parameter a array reference, where the first index is the "email" |
55
|
|
|
|
|
|
|
and the second the SPAM report sent ID. |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
The first parameter cannot be C<undef>, while the second is acceptabled. |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=cut |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub new { |
62
|
8
|
|
|
8
|
1
|
24
|
my ( $class, $attribs_ref ) = @_; |
63
|
8
|
50
|
|
|
|
22
|
confess 'Expects an array reference as parameter' |
64
|
|
|
|
|
|
|
unless ( ref($attribs_ref) eq 'ARRAY' ); |
65
|
8
|
50
|
|
|
|
23
|
confess 'email cannot be undef' unless ( $attribs_ref->[0] ); |
66
|
|
|
|
|
|
|
|
67
|
8
|
|
|
|
|
23
|
my $self = { |
68
|
|
|
|
|
|
|
report_id => $attribs_ref->[1], |
69
|
|
|
|
|
|
|
email => $attribs_ref->[0], |
70
|
|
|
|
|
|
|
}; |
71
|
|
|
|
|
|
|
|
72
|
8
|
|
|
|
|
19
|
bless $self, $class; |
73
|
8
|
|
|
|
|
13
|
lock_hash( %{$self} ); |
|
8
|
|
|
|
|
60
|
|
74
|
8
|
|
|
|
|
187
|
return $self; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head2 as_text |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Returns the receiver attributes as strings, separated by commas. |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
If some of attributes are C<undef>, the string C<not avaialable> will be used |
82
|
|
|
|
|
|
|
instead. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=cut |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub as_text { |
87
|
9
|
|
|
9
|
1
|
17
|
my $self = shift; |
88
|
9
|
|
|
|
|
13
|
my @dump; |
89
|
9
|
|
|
|
|
19
|
push( @dump, $self->{email} ); |
90
|
9
|
|
66
|
|
|
36
|
push( @dump, ( $self->{report_id} || App::SpamcupNG::Summary->na ) ); |
91
|
9
|
|
|
|
|
42
|
return join( ',', @dump ); |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head2 is_devnulled |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Returns true (1) if the receiver was stored for statistics only or if it was |
97
|
|
|
|
|
|
|
indeed reported to a domain, false (0) otherwise. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=cut |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub is_devnulled { |
102
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
103
|
0
|
0
|
|
|
|
|
return defined( $self->{report_id} ) ? 0 : 1; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head1 SEE ALSO |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=over |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=item * |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
L<Class::Accessor> |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=back |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head1 AUTHOR |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Alceu Rodrigues de Freitas Junior, E<lt>arfreitas@cpan.orgE<gt> |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
This software is copyright (c) 2018 of Alceu Rodrigues de Freitas Junior, |
123
|
|
|
|
|
|
|
E<lt>arfreitas@cpan.orgE<gt> |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
This file is part of App-SpamcupNG distribution. |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
App-SpamcupNG is free software: you can redistribute it and/or modify it under |
128
|
|
|
|
|
|
|
the terms of the GNU General Public License as published by the Free Software |
129
|
|
|
|
|
|
|
Foundation, either version 3 of the License, or (at your option) any later |
130
|
|
|
|
|
|
|
version. |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
App-SpamcupNG is distributed in the hope that it will be useful, but WITHOUT |
133
|
|
|
|
|
|
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
134
|
|
|
|
|
|
|
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License along with |
137
|
|
|
|
|
|
|
App-SpamcupNG. If not, see <http://www.gnu.org/licenses/>. |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=cut |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
1; |