Commit b0703b7c authored by sikeda's avatar sikeda
Browse files

[-change] send_confirm_to_editor(), send_confirm_to_sender(),...

[-change] send_confirm_to_editor(), send_confirm_to_sender(), reject_report_msg(), notice_report_msg(), send_report_cmd(): Set delivery dates of messages sent by robot the future date to ensure 1 second will be elapsed since last message, instead of inserting sleep(1).


git-svn-id: https://subversion.renater.fr/sympa/branches/sympa-6.2-branch@11377 05aa8bb8-cd2b-0410-b1d7-8918dfa770ce
parent 4519fc78
......@@ -2746,7 +2746,6 @@ sub distribute {
);
unless ($quiet) {
sleep 1;
unless (
Sympa::Report::notice_report_msg(
'message_distributed', $sender,
......@@ -2754,8 +2753,10 @@ sub distribute {
$list
)
) {
Log::do_log('notice',
"Commands::distribute(): Unable to send template 'message_report', entry 'message_distributed' to $sender"
Log::do_log(
'notice',
'Unable to send template "message_report", entry "message_distributed" to %s',
$sender
);
}
}
......@@ -3043,7 +3044,6 @@ sub confirm {
}
unless ($quiet || ($action =~ /quiet/i)) {
sleep 1;
unless (
Sympa::Report::notice_report_msg(
'message_confirmed', $sender,
......
......@@ -3011,8 +3011,15 @@ sub send_confirm_to_editor {
);
}
#XXX tt2::allow_absolute_path();
unless (tools::send_file($list, 'moderate', $recipient, $param)) {
my $confirm_message =
Sympa::Message->new_from_template($list, 'moderate', $recipient,
$param);
if ($confirm_message) {
# Ensure 1 second elapsed since last message
$confirm_message->{'date'} = time + 1;
}
unless ($confirm_message
and defined Sympa::Bulk::store($confirm_message, $recipient)) {
Log::do_log('notice', 'Unable to send template "moderate" to %s',
$recipient);
return undef;
......@@ -3059,9 +3066,6 @@ sub send_confirm_to_sender {
my $list = $message->{context};
my $sender = $message->{'sender'};
## Ensure 1 second elapsed since last message
sleep(1);
my ($i, @rcpt);
my $authqueue = $Conf::Conf{'queueauth'};
......@@ -3091,8 +3095,15 @@ sub send_confirm_to_sender {
#'file' => $message->{'filename'}, # obsoleted (<=6.1)
};
#XXX tt2::allow_absolute_path();
unless (tools::send_file($list, 'send_auth', $sender, $param)) {
my $confirm_message =
Sympa::Message->new_from_template($list, 'send_auth', $sender,
$param);
if ($confirm_message) {
# Ensure 1 second elapsed since last message
$confirm_message->{'date'} = time + 1;
}
unless ($confirm_message
and defined Sympa::Bulk::store($confirm_message, $sender)) {
Log::do_log('notice', 'Unable to send template "send_auth" to %s',
$sender);
return undef;
......@@ -5367,8 +5378,7 @@ sub update_list_member {
foreach my $path ($self->find_picture_paths($who)) {
my $extension = [reverse split /\./, $path]->[0];
my $new_path = $self->get_picture_path(
Digest::MD5::md5_hex($values->{'email'}) . '.'
. $extension);
Digest::MD5::md5_hex($values->{'email'}) . '.' . $extension);
unless (rename $path, $new_path) {
Log::do_log('err', 'Failed to rename %s to %s : %m',
$path, $new_path);
......
......@@ -602,9 +602,13 @@ sub new_from_template {
Conf::get_robot_conf($robot_id, 'request');
}
# Set default delivery date.
$message->{'date'} = time;
return $message;
}
#TODO: This would be merged in new_from_template() because used only by it.
sub _new_from_template {
Log::do_log('debug2', '(%s, %s, %s, %s, %s)', @_);
my $class = shift;
......
......@@ -27,8 +27,10 @@ package Sympa::Report;
use strict;
use warnings;
use Sympa::Bulk;
use Log;
use Sympa::Robot;
use Sympa::Message;
use tools;
### MESSAGE DIFFUSION REPORT ###
......@@ -58,6 +60,8 @@ sub reject_report_msg {
my ($type, $error, $user, $param, $robot, $msg_string, $list) = @_;
Log::do_log('debug2', '(%s, %s, %s)', $type, $error, $user);
undef $list unless ref $list eq 'Sympa::List';
unless ($type eq 'intern'
or $type eq 'intern_quiet'
or $type eq 'user'
......@@ -100,18 +104,16 @@ sub reject_report_msg {
$param->{'original_msg'} = _get_msg_as_hash($param->{'message'});
}
if (ref($list) eq 'Sympa::List') {
unless (tools::send_file($list, 'message_report', $user, $param)) {
Log::do_log('notice',
"Sympa::Report::reject_report_msg(): Unable to send template 'message_report' to '$user'"
);
}
} else {
unless (tools::send_file($robot, 'message_report', $user, $param)) {
Log::do_log('notice',
"Sympa::Report::reject_report_msg(): Unable to send template 'message_report' to '$user'"
);
}
my $report_message = Sympa::Message->new_from_template(($list || $robot),
'message_report', $user, $param);
if ($report_message) {
# Ensure 1 second elapsed since last message
$report_message->{'date'} = time + 1;
}
unless ($report_message
and defined Sympa::Bulk::store($report_message, $user)) {
Log::do_log('notice',
'Unable to send template "message_report" to "%s"', $user);
}
if ($type eq 'intern') {
......@@ -200,6 +202,8 @@ sub _get_msg_as_hash {
sub notice_report_msg {
my ($entry, $user, $param, $robot, $list) = @_;
undef $list unless ref $list eq 'Sympa::List';
$param->{'to'} = $user;
$param->{'type'} = 'success';
$param->{'entry'} = $entry;
......@@ -224,18 +228,16 @@ sub notice_report_msg {
$param->{'original_msg'} = _get_msg_as_hash($param->{'message'});
}
if (ref($list) eq 'Sympa::List') {
unless (tools::send_file($list, 'message_report', $user, $param)) {
Log::do_log('notice',
"Sympa::Report::notice_report_msg(): Unable to send template 'message_report' to '$user'"
);
}
} else {
unless (tools::send_file($robot, 'message_report', $user, $param)) {
Log::do_log('notice',
"Sympa::Report::notice_report_msg(): Unable to send template 'message_report' to '$user'"
);
}
my $report_message = Sympa::Message->new_from_template(($list || $robot),
'message_report', $user, $param);
if ($report_message) {
# Ensure 1 second elapsed since last message
$report_message->{'date'} = time + 1;
}
unless ($report_message
and defined Sympa::Bulk::store($report_message, $user)) {
Log::do_log('notice',
'Unable to send template "message_report" to "%s"', $user);
}
return 1;
......@@ -354,10 +356,17 @@ sub send_report_cmd {
'globals' => \@global_error_cmd,
};
unless (tools::send_file($robot, 'command_report', $sender, $data)) {
my $report_message =
Sympa::Message->new_from_template($robot, 'command_report', $sender,
$data);
if ($report_message) {
# Ensure 1 second elapsed since last message
$report_message->{'date'} = time + 1;
}
unless ($report_message
and defined Sympa::Bulk::store($report_message, $sender)) {
Log::do_log('notice',
"Sympa::Report::send_report_cmd() : Unable to send template 'command_report' to $sender"
);
'Unable to send template "command_report" to %s', $sender);
}
init_report_cmd();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment