]>
git.proxmox.com Git - pmg-api.git/blob - PMG/RuleDB/Accept.pm
1387e2428453650d4a1d505ce77581ac3ae3d7a6
1 package PMG
::RuleDB
::Accept
;
13 use PMG
::RuleDB
::Object
;
15 use base
qw(PMG::RuleDB::Object);
42 my ($type, $ogroup) = @_;
44 my $class = ref($type) || $type;
46 my $self = $class->SUPER::new
($class->otype(), $ogroup);
52 my ($type, $ruledb, $id, $ogroup, $value) = @_;
54 my $class = ref($type) || $type;
56 my $obj = $class->new($ogroup);
59 $obj->{digest
} = Digest
::SHA
::sha1_hex
($id, $ogroup);
65 my ($self, $ruledb) = @_;
67 defined($self->{ogroup
}) || return undef;
69 if (defined($self->{id
})) {
77 my $sth = $ruledb->{dbh
}->prepare(
78 "INSERT INTO Object (Objectgroup_ID, ObjectType) VALUES (?, ?);");
80 $sth->execute($self->ogroup, $self->otype);
82 $self->{id
} = PMG
::Utils
::lastid
($ruledb->{dbh
}, 'object_id_seq');
89 my ($self, $queue, $ruledb, $mod_group, $targets,
90 $msginfo, $vars, $marks) = @_;
92 my $subgroups = $mod_group->subgroups($targets, 1);
94 my $rulename = $vars->{RULE
};
96 foreach my $ta (@$subgroups) {
97 my ($tg, $entity) = (@$ta[0], @$ta[1]);
99 PMG
::Utils
::remove_marks
($entity);
101 if ($msginfo->{testmode
}) {
102 my $fh = $msginfo->{test_fh
};
103 print $fh "accept from: $msginfo->{sender}\n";
104 printf $fh "accept to: %s\n", join (',', @$tg);
105 print $fh "accept content:\n";
108 print $fh "accept end\n";
109 $queue->set_status($tg, 'delivered');
111 my ($qid, $code, $mess) = PMG
::Utils
::reinject_mail
(
112 $entity, $msginfo->{sender
}, $tg,
113 $msginfo->{xforward
}, $msginfo->{fqdn
});
116 syslog
('info', "%s: accept mail to <%s> (rule: %s, %s)", $queue->{logid
}, encode
('UTF-8', $_), $rulename, $qid);
118 $queue->set_status ($tg, 'delivered', $qid);
121 syslog
('err', "%s: reinject mail to <%s> (rule: %s) failed", $queue->{logid
}, encode
('UTF-8', $_), $rulename);
124 my $resp = substr($code, 0, 1);
125 if ($resp eq '4' || $resp eq '5') {
126 $queue->set_status($tg, 'error', $code, $mess);
133 # warn if no subgroups
139 return "accept message";
146 =head1 PMG::RuleDB::Accept