line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mail::BIMI::Record::Location; |
2
|
|
|
|
|
|
|
# ABSTRACT: Class to model a BIMI location |
3
|
|
|
|
|
|
|
our $VERSION = '3.20210225'; # VERSION |
4
|
30
|
|
|
30
|
|
566
|
use 5.20.0; |
|
30
|
|
|
|
|
124
|
|
5
|
30
|
|
|
30
|
|
195
|
use Moose; |
|
30
|
|
|
|
|
70
|
|
|
30
|
|
|
|
|
250
|
|
6
|
30
|
|
|
30
|
|
212315
|
use Mail::BIMI::Prelude; |
|
30
|
|
|
|
|
91
|
|
|
30
|
|
|
|
|
302
|
|
7
|
30
|
|
|
30
|
|
9383
|
use Mail::BIMI::Indicator; |
|
30
|
|
|
|
|
86
|
|
|
30
|
|
|
|
|
17729
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
extends 'Mail::BIMI::Base'; |
10
|
|
|
|
|
|
|
with 'Mail::BIMI::Role::HasError'; |
11
|
|
|
|
|
|
|
has is_location_valid => ( is => 'rw', lazy => 1, builder => '_build_is_location_valid' ); |
12
|
|
|
|
|
|
|
has uri => ( is => 'rw', isa => 'Maybe[Str]', required => 1, |
13
|
|
|
|
|
|
|
documentation => 'inputs: URI of Indicator', ); |
14
|
|
|
|
|
|
|
has is_valid => ( is => 'rw', lazy => 1, builder => '_build_is_valid', |
15
|
|
|
|
|
|
|
documentation => 'Is this Location record valid' ); |
16
|
|
|
|
|
|
|
has indicator => ( is => 'rw', lazy => 1, builder => '_build_indicator', |
17
|
|
|
|
|
|
|
documentation => 'Mail::BIMI::Indicator object for this location' ); |
18
|
|
|
|
|
|
|
has is_relevant => ( is => 'rw', lazy => 1, default => sub{return 1}, |
19
|
|
|
|
|
|
|
documentation => 'Is the location relevant' ); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
34
|
|
|
34
|
|
72
|
sub _build_is_location_valid($self) { |
|
34
|
|
|
|
|
73
|
|
|
34
|
|
|
|
|
66
|
|
23
|
|
|
|
|
|
|
# Check is_valid without checking indicator, because recursion! |
24
|
34
|
100
|
|
|
|
1029
|
if ( !defined $self->uri ) { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
25
|
4
|
|
|
|
|
26
|
$self->add_error('MISSING_L_TAG'); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
elsif ( $self->uri eq '' ) { |
28
|
3
|
|
|
|
|
24
|
$self->add_error('EMPTY_L_TAG'); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
elsif ( ! ( $self->uri =~ /^https:\/\// ) ) { |
31
|
2
|
|
|
|
|
18
|
$self->add_error('INVALID_TRANSPORT_L'); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
else { |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
34
|
100
|
|
|
|
977
|
return 0 if $self->errors->@*; |
37
|
25
|
|
|
|
|
752
|
return 1; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
31
|
|
|
31
|
|
86
|
sub _build_is_valid($self) { |
|
31
|
|
|
|
|
67
|
|
|
31
|
|
|
|
|
66
|
|
41
|
31
|
100
|
|
|
|
1011
|
return 0 if !$self->is_location_valid; |
42
|
25
|
50
|
|
|
|
751
|
if ( !$self->indicator->is_valid ) { |
43
|
0
|
|
|
|
|
0
|
$self->add_error_object( $self->indicator->errors ); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
25
|
50
|
|
|
|
790
|
return 0 if $self->errors->@*; |
47
|
25
|
|
|
|
|
260
|
$self->log_verbose('Location is valid'); |
48
|
25
|
|
|
|
|
764
|
return 1; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
31
|
|
|
31
|
|
55
|
sub _build_indicator($self) { |
|
31
|
|
|
|
|
67
|
|
|
31
|
|
|
|
|
58
|
|
52
|
31
|
100
|
|
|
|
895
|
return if !$self->is_location_valid; |
53
|
25
|
50
|
|
|
|
756
|
return if !$self->is_relevant; |
54
|
25
|
|
|
|
|
681
|
return Mail::BIMI::Indicator->new( uri => $self->uri, bimi_object => $self->bimi_object, source => 'Location' ); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
|
58
|
14
|
|
|
14
|
1
|
32
|
sub finish($self) { |
|
14
|
|
|
|
|
29
|
|
|
14
|
|
|
|
|
74
|
|
59
|
14
|
100
|
|
|
|
497
|
$self->indicator->finish if $self->indicator; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
1; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
__END__ |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=pod |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=encoding UTF-8 |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 NAME |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
Mail::BIMI::Record::Location - Class to model a BIMI location |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 VERSION |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
version 3.20210225 |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 DESCRIPTION |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Class for representing, validating, and processing a BIMI location attribute |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 INPUTS |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
These values are used as inputs for lookups and verifications, they are typically set by the caller based on values found in the message being processed |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head2 uri |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
is=rw required |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
URI of Indicator |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
These values are derived from lookups and verifications made based upon the input values, it is however possible to override these with other values should you wish to, for example, validate a record before it is published in DNS, or validate an Indicator which is only available locally |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head2 errors |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
is=rw |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head2 indicator |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
is=rw |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Mail::BIMI::Indicator object for this location |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head2 is_location_valid |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
is=rw |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head2 is_relevant |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
is=rw |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
Is the location relevant |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head2 is_valid |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
is=rw |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
Is this Location record valid |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head2 warnings |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
is=rw |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head1 CONSUMES |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=over 4 |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=item * L<Mail::BIMI::Role::HasError> |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=back |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head1 EXTENDS |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=over 4 |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=item * L<Mail::BIMI::Base> |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=back |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=head1 METHODS |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head2 I<finish()> |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
Finish and clean up, write cache if enabled. |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head1 REQUIRES |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=over 4 |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=item * L<Mail::BIMI::Indicator|Mail::BIMI::Indicator> |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=item * L<Mail::BIMI::Prelude|Mail::BIMI::Prelude> |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=item * L<Moose|Moose> |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=back |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=head1 AUTHOR |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
Marc Bradshaw <marc@marcbradshaw.net> |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
This software is copyright (c) 2020 by Marc Bradshaw. |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
169
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=cut |