]>
git.proxmox.com Git - pmg-api.git/blob - PMG/RuleDB/Accept.pm
1 package PMG
::RuleDB
::Accept
;
12 use PMG
::RuleDB
::Object
;
14 use base
qw(PMG::RuleDB::Object);
41 my ($type, $ogroup) = @_;
43 my $class = ref($type) || $type;
45 my $self = $class->SUPER::new
($class->otype(), $ogroup);
51 my ($type, $ruledb, $id, $ogroup, $value) = @_;
53 my $class = ref($type) || $type;
55 my $obj = $class->new($ogroup);
58 $obj->{digest
} = Digest
::SHA
::sha1_hex
($id, $ogroup);
64 my ($self, $ruledb) = @_;
66 defined($self->{ogroup
}) || return undef;
68 if (defined($self->{id
})) {
76 my $sth = $ruledb->{dbh
}->prepare(
77 "INSERT INTO Object (Objectgroup_ID, ObjectType) VALUES (?, ?);");
79 $sth->execute($self->ogroup, $self->otype);
81 $self->{id
} = PMG
::Utils
::lastid
($ruledb->{dbh
}, 'object_id_seq');
88 my ($self, $queue, $ruledb, $mod_group, $targets,
89 $msginfo, $vars, $marks) = @_;
91 my $subgroups = $mod_group->subgroups($targets, 1);
93 foreach my $ta (@$subgroups) {
94 my ($tg, $entity) = (@$ta[0], @$ta[1]);
96 PMG
::Utils
::remove_marks
($entity);
98 if ($msginfo->{testmode
}) {
99 my $fh = $msginfo->{test_fh
};
100 print $fh "accept from: $msginfo->{sender}\n";
101 printf $fh "accept to: %s\n", join (',', @$tg);
102 print $fh "accept content:\n";
105 print $fh "accept end\n";
106 $queue->set_status($tg, 'delivered');
108 my ($qid, $code, $mess) = PMG
::Utils
::reinject_mail
(
109 $entity, $msginfo->{sender
}, $tg,
110 $msginfo->{xforward
}, $msginfo->{fqdn
});
113 syslog
('info', "%s: accept mail to <%s> (%s)", $queue->{logid
}, $_, $qid);
115 $queue->set_status ($tg, 'delivered', $qid);
118 syslog
('err', "%s: reinject mail to <%s> failed", $queue->{logid
}, $_);
121 my $resp = substr($code, 0, 1);
122 if ($resp eq '4' || $resp eq '5') {
123 $queue->set_status($tg, 'error', $code, $mess);
130 # warn if no subgroups
136 return "accept message";
143 =head1 PMG::RuleDB::Accept