]> git.proxmox.com Git - pmg-api.git/blob - src/PMG/RuleDB/EMail.pm
prefix message-id in attachment-quarantine
[pmg-api.git] / src / PMG / RuleDB / EMail.pm
1 package PMG::RuleDB::EMail;
2
3 use strict;
4 use warnings;
5 use DBI;
6
7 use PMG::RuleDB::WhoRegex;
8
9 use base qw(PMG::RuleDB::WhoRegex);
10
11 sub otype {
12 return 1001;
13 }
14
15 sub otype_text {
16 return 'Mail address';
17 }
18
19 sub new {
20 my ($type, $address, $ogroup) = @_;
21 my $class = ref($type) || $type;
22
23 $address //= 'unknown@domain.tld';
24
25 my $self = $class->SUPER::new($address, $ogroup);
26
27 return $self;
28 }
29
30 sub who_match {
31 my ($self, $addr) = @_;
32
33 return (lc ($addr) eq lc ($self->address));
34 }
35
36
37 sub short_desc {
38 my $self = shift;
39
40 my $desc = $self->{address};
41
42 return $desc;
43 }
44
45 sub properties {
46 my ($class) = @_;
47
48 return {
49 email => {
50 description => "Email address.",
51 type => 'string', format => 'email',
52 },
53 };
54 }
55
56 sub get {
57 my ($self) = @_;
58
59 return { email => $self->{address} };
60 }
61
62 sub update {
63 my ($self, $param) = @_;
64
65 $self->{address} = $param->{email};
66 }
67
68 1;
69
70 __END__
71
72 =head1 PMG::RuleDB::EMail
73
74 A WHO object to check email addresses.
75
76 =head2 Attribues
77
78 =head3 address
79
80 An Email address. We use case insensitive compares.
81
82 =head2 Examples
83
84 $obj = PMG::RuleDB::Email->new ('you@yourdomain.com');
85