]> git.proxmox.com Git - pmg-api.git/blame - PMG/RuleDB/ReportSpam.pm
bump version to 5.2-2
[pmg-api.git] / PMG / RuleDB / ReportSpam.pm
CommitLineData
f4fe6fc4
DM
1package PMG::RuleDB::ReportSpam;
2
3use strict;
4use warnings;
f4fe6fc4
DM
5use DBI;
6
7use PVE::SafeSyslog;
8
9use PMG::Utils;
10use PMG::ModGroup;
11use PMG::RuleDB::Object;
12
13use base qw(PMG::RuleDB::Object);
14
15sub otype {
16 return 4008;
17}
18
19sub oclass {
20 return 'action';
21}
22
23sub otype_text {
24 return 'Report Spam';
25}
26
f4fe6fc4
DM
27sub oisedit {
28 return 0;
29}
30
31sub final {
32 return 1;
33}
34
35sub priority {
36 return 97;
37}
38
39sub new {
40 my ($type, $ogroup) = @_;
41
42 my $class = ref($type) || $type;
43
7a2cf7e6 44 my $self = $class->SUPER::new($class->otype(), $ogroup);
f4fe6fc4
DM
45
46 return $self;
47}
48
49sub load_attr {
50 my ($type, $ruledb, $id, $ogroup, $value) = @_;
51
52 my $class = ref($type) || $type;
53
54 my $obj = $class->new($ogroup);
55 $obj->{id} = $id;
56
57 return $obj;
58}
59
60sub save {
61 my ($self, $ruledb) = @_;
62
63 defined($self->{ogroup}) || return undef;
64
65 if (defined ($self->{id})) {
66 # update
67
68 # nothing to update
69
70 } else {
71 # insert
72
73 my $sth = $ruledb->{dbh}->prepare(
74 "INSERT INTO Object (Objectgroup_ID, ObjectType) VALUES (?, ?);");
75
76 $sth->execute($self->ogroup, $self->otype);
77
78 $self->{id} = PMG::Utils::lastid($ruledb->{dbh}, 'object_id_seq');
79 }
80
81 return $self->{id};
82}
83
84sub execute {
85 my ($self, $queue, $ruledb, $mod_group, $targets,
86 $msginfo, $vars, $marks) = @_;
87
88 my $subgroups = $mod_group->subgroups($targets);
89
90 foreach my $ta (@$subgroups) {
91 my ($tg, $entity) = (@$ta[0], @$ta[1]);
92
93 if ($msginfo->{testmode}) {
94 my $fh = $msginfo->{test_fh};
95 print $fh "report as spam\n";
96 } else {
97
98 my $spamtest = $queue->{sa};
99
100 $queue->{fh}->seek (0, 0);
101 *SATMP = \*{$queue->{fh}};
102 my $mail = $spamtest->parse(\*SATMP);
103
104 $spamtest->report_as_spam($mail);
105
106 $mail->finish();
107 }
108 $queue->set_status ($tg, 'delivered');
109 }
110}
111
112sub short_desc {
113 my $self = shift;
114
115 return "";
116}
117
1181;
119__END__
120
121=head1 PMG::RuleDB::ReportSpam
122
123Report as SPAM.