sub genreply ($$@) {
my $head = shift;
- my $success = shift;
+ my $nrvalid = shift; # number of valid commands.
my @content = @_;
# Send reply to:
# - Requester (optionally)
- # - The list (only if successfully processed)
+ # - The list (only if successfully processed at least one command)
# - Dist list (optionally)
push @to_field, $request_from
if $c{ControlReplyToRequestor} and $request_from;
- push @to_field, $c{ListAddress} if $c{ControlReplyToList} and $success;
+ push @to_field, $c{ListAddress} if $c{ControlReplyToList} and $nrvalid > 0;
push @bcc_field, $c{ControlDistAddress} if $c{ControlDistAddress};
my $msubject = "Processed: " . $head->get('subject');
'X-Emesinae-Message:' => "control",
'X-Emesinae-Control-From:' => $request_from,
+ 'X-Emesinae-Control-Number-Commands:' => $nrvalid,
);
- if ($success) {
+ if ($nrvalid > 0) {
# Insert both control and reply messages into DB with the correct type.
my $mcontrol =
push @reply, "Processing commands for " . $c{ControlAddressFull} . ":";
push @reply, "";
+my $nrcommands = 0;
while (<$body>) {
chomp();
push @reply, "> $_";
$cmds{$1} or die "Unknown command `$1'.";
validate_from($1) if $cmds{$1}{Priv};
$cmds{$1}{Cmd}($2) or $done = 1;
+ $nrcommands++;
};
if ($@) {
chomp($@);
"Contact " . $c{OwnerAddressFull} . " with any infrastructure issues",
);
-spool_reply( genreply( $head, 1, @reply ) );
+spool_reply( genreply( $head, $nrcommands, @reply ) );
exit(0);