Commit 3c89d30e authored by sikeda's avatar sikeda
Browse files

[dev] Refactoring: New package Sympa::Alarm to manage spool on memorty for listmaster notification.

- Sympa::Alarm::flush() to flush or purge the spool was separated from send_notify_to_listmaster().
- send_notify_to_listmaster() now takes context (site ('*'), robot, List) as the first argument.
- As a side work, mail_tt2/automatic_bounce_management.tt2 was separated from listmaster_notification.tt2 and listowner_notification.tt2.


git-svn-id: https://subversion.renater.fr/sympa/branches/sympa-6.2-branch@11336 05aa8bb8-cd2b-0410-b1d7-8918dfa770ce
parent 73f8d7af
Subject: [% FILTER qencode %][%|loc(list.name)%]List %1 automatic bounce management[%END%][%END%]
[% IF action == 'notify_bouncers' -%]
[%|loc(total,list.name)%]Because we received MANY non-delivery reports, the %1 subscribers listed below have been
notified that they might be removed from list %2:[%END%]
[% ELSIF action == 'remove_bouncers' -%]
[%|loc(total,list.name)%]Because we received MANY non-delivery reports, the %1 subscribers listed below have been
removed from list %2:[%END%]
[% ELSIF action == 'none' -%]
[%|loc(total,list.name)%]Because we received MANY non-delivery reports, the %1 subscribers listed below have been
selected by Sympa as severe bouncing addresses:[%END%]
[%END%]
[% FOREACH user IN user_list -%]
[% user %]
[% END %]
[%|loc%]Managing bouncing subscribers:[%END%] [% conf.wwsympa_url %]/reviewbouncing/[% list.name %]
......@@ -78,12 +78,15 @@ Subject: [% FILTER qencode %][%|loc%]DataBase connection restored[%END%][%END%]
[%|loc(db_name)%]Connection to database %1 restored.[%END%]
[% ELSIF type == 'bulk_error' -%]
Subject: [% FILTER qencode %][%|loc%]Bulk mailer error[%END%][%END%]
[%|loc(listname)%]Sympa failed to store a message for list %1 in the bulk mailer. You should check log files !![%END%]
[%|loc(message_id)%]Sympa failed to store a message <%1> in the bulk mailer. You should check log files !![%END%]
[% ELSIF type == 'bulk_failed' -%]
Subject: [% FILTER qencode %][%|loc%]Bulk mailer error[%END%][%END%]
[%|loc(message_id)%]Sympa failed to process a message <%1> in the bulk spool. You should check log files!![%END%]
[% ELSIF type == 'loop_command' -%]
Subject: [% FILTER qencode %][%|loc%]Loop detected[%END%][%END%]
......@@ -153,22 +156,6 @@ Subject: [% FILTER qencode %][%|loc%]incorrect format of edit_list.conf[%END%][%
[%|loc(param0)%]Until then we recommend your remove %1;
default configuration will be used.[%END%]
[% ELSIF type == 'subscribers_limit_exceeded' -%]
Subject: [% FILTER qencode %][%|loc(listname)%]Limit of users count reached for list %1[%END%][%END%]
[%|loc(listname,max_number_of_subscribers)%]Sympa could not include subscribers to list %1 because the maximum number of users was reached for this list. This limit is defined to %2.[%END%]
[% ELSIF type == 'sync_include_failed' -%]
Subject: [% FILTER qencode %][%|loc(listname)%]subscribers update failed for list %1[%END%][%END%]
[%|loc%]Sympa could not include subscribers from the following external data sources:[%END%]
[% FOREACH e IN errors %]
[%|loc(e.name,e.type)%]Include of datasource %1 (type %2) failed.[% END %]
[% END %]
[%|loc%]Check Sympa log files for more precise information[%END%]
[% ELSIF type == 'sync_include_admin_failed' -%]
Subject: [% FILTER qencode %][%|loc(param0)%]admins update failed for list %1[%END%][%END%]
......@@ -264,33 +251,12 @@ Subject: [% FILTER qencode %][%|loc(param0)%]list %1 in status error_config[%END
[%|loc%]The list status has been set to error_config.[%END%]
[%|loc%]Check Sympa log files for more precise information.[%END%]
[% ELSIF type == 'automatic_bounce_management' -%]
Subject: [% FILTER qencode %][%|loc(list.name)%]List %1 automatic bounce management[%END%][%END%]
[% IF action == 'notify_bouncers' -%]
[%|loc(total,list.name)%]Because we received MANY non-delivery reports, the %1 subscribers listed below have been
notified that they might be removed from list %2:[%END%]
[% ELSIF action == 'remove_bouncers' -%]
[%|loc(total,list.name)%]Because we received MANY non-delivery reports, the %1 subscribers listed below have been
removed from list %2:[%END%]
[% ELSIF action == 'none' -%]
[%|loc(total,list.name)%]Because we received MANY non-delivery reports, the %1 subscribers listed below have been
selected by Sympa as severe bouncing addresses:[%END%]
[%END%]
[% FOREACH user IN user_list -%]
[% user %]
[% END %]
[%|loc%]Managing bouncing subscribers:[%END%] [% conf.wwsympa_url %]/reviewbouncing/[% list.name %]
[%# INTERNAL SERVER ERROR : MAIL -%]
[% ELSIF type == 'mail_intern_error' -%]
Subject: [% FILTER qencode %][%|loc(list.name)%]Listmaster: internal server error [%END%][%END%]
Subject: [% FILTER qencode %][%|loc%]Listmaster: internal server error [%END%][%END%]
[%|loc(who)%] User %1 has encountered an internal server error[%END%]
([%action%][% IF msg_id %] - MSG_ID[%|loc%]:[%END%] [%msg_id%][%END%][% IF cmd %] - COMMAND[%|loc%]:[%END%] [%cmd%][%END%][% IF list.name %] - LIST[%|loc%]:[%END%] [%list.name%]@[%conf.host%][%END%])[%|loc%]:[%END%]
([%action%][% IF msg_id %] - MSG_ID[%|loc%]:[%END%] [%msg_id%][%END%][% IF cmd %] - COMMAND[%|loc%]:[%END%] [%cmd%][%END%][% IF list.name %] - LIST[%|loc%]:[%END%] [%list.name%]@[%list.host%][%END%])[%|loc%]:[%END%]
[%IF error%][%error%]
[%END%]
......@@ -300,7 +266,7 @@ Subject: [% FILTER qencode %][%|loc(list.name)%]Listmaster: internal server erro
[% ELSIF type == 'bounce_intern_error' -%]
Subject: [% FILTER qencode %][%|loc(list.name)%]Listmaster: internal server error [%END%][%END%]
[%|loc(error)%]The following error occurred whila managing bounces: %&[%END%]
[%|loc(error)%]The following error occurred while managing bounces: %1[%END%]
[%|loc%]See logs for more details.[%END%]
......
......@@ -38,26 +38,6 @@ Some of the customizations have been removed because they no longer respect the
[%END%]
[% ELSIF type == 'automatic_bounce_management' -%]
Subject: [% FILTER qencode %][%|loc(list.name)%]List %1 automatic bounce management[%END%][%END%]
[% IF action == 'notify_bouncers' -%]
[%|loc(total,list.name)%]Because we received many non-delivery reports, the %1 subscribers listed below have been
notified that they might be removed from list %2:[%END%]
[% ELSIF action == 'remove_bouncers' -%]
[%|loc(total,list.name)%]Because we received many non-delivery reports, the %1 subscribers listed below have been
removed from list %2:[%END%]
[% ELSIF action == 'none' -%]
[%|loc(total,list.name)%]Because we received many non-delivery reports, the %1 subscribers listed below have been
selected by Sympa as severe bouncing addresses:[%END%]
[%END%]
[% FOREACH user = user_list -%]
[% user %]
[%END%]
[%|loc%]Managing bouncing subscribers:[%END%] [% conf.wwsympa_url %]/reviewbouncing/[% list.name %]
[% ELSIF type == 'subrequest' -%]
Subject: [% FILTER qencode %][%|loc(list.name)%]Subscription request to list %1[%END%][%END%]
......
......@@ -60,6 +60,7 @@ use Data::Dumper; # tentative
BEGIN { eval 'use Crypt::OpenSSL::X509'; }
 
use Sympa::Admin;
use Sympa::Alarm;
use Sympa::Archive;
use Sympa::Auth;
use Conf;
......@@ -1028,7 +1029,7 @@ while ($query = new_loop()) {
Sympa::List::init_list_cache();
 
# Process grouped notifications
Sympa::Robot::send_notify_to_listmaster(undef, undef, undef, 1);
Sympa::Alarm::flush();
 
## Check effective ID
unless ($EUID eq (getpwnam(Sympa::Constants::USER))[2]) {
......@@ -1310,8 +1311,8 @@ while ($query = new_loop()) {
# affected to another anonymous session.
undef $ENV{'HTTP_COOKIE'};
unless (defined $session) {
Sympa::Robot::send_notify_to_listmaster(
'failed_to_create_web_session', $robot);
tools::send_notify_to_listmaster($robot,
'failed_to_create_web_session', {});
wwslog('info', 'Failed to create session');
$session = Sympa::Session->new($robot, {});
}
......@@ -1979,7 +1980,7 @@ while ($query = new_loop()) {
) {
my $error = tt2::get_error();
$param->{'tt2_error'} = $error;
Sympa::Robot::send_notify_to_listmaster('web_tt2_error', $robot,
tools::send_notify_to_listmaster($robot, 'web_tt2_error',
[$error]);
}
 
......@@ -2013,7 +2014,7 @@ while ($query = new_loop()) {
) {
my $error = tt2::get_error();
$param->{'tt2_error'} = $error;
Sympa::Robot::send_notify_to_listmaster('web_tt2_error', $robot,
tools::send_notify_to_listmaster($robot, 'web_tt2_error',
[$error]);
}
# close FILE;
......@@ -2037,7 +2038,7 @@ while ($query = new_loop()) {
}
 
# Purge grouped notifications
Sympa::Robot::send_notify_to_listmaster(undef, undef, undef, undef, 1);
Sympa::Alarm::flush('purge');
 
##############################################################
#-#\#|#/#-#\#|#/#-#\#|#/#-#\#|#/#-#\#|#/#-#\#|#/#-#\#|#/#-#\#|#/
......@@ -3007,7 +3008,7 @@ sub send_html {
# "Not Found" response for random help page.
print "Status: 404 Not Found\n";
} else {
Sympa::Robot::send_notify_to_listmaster('web_tt2_error', $robot,
tools::send_notify_to_listmaster($robot, 'web_tt2_error',
[$error]);
}
 
......@@ -8056,8 +8057,8 @@ sub do_skinsedit {
tt2::parse_tt2($param, 'css.tt2', \*CSS, $tt2_include_path)) {
my $error = tt2::get_error();
$param->{'tt2_error'} = $error;
Sympa::Robot::send_notify_to_listmaster('web_tt2_error',
$robot, [$error]);
tools::send_notify_to_listmaster($robot, 'web_tt2_error',
[$error]);
wwslog('info', 'Error while installing %s', $css_file);
}
close(CSS);
......@@ -11292,7 +11293,7 @@ Creates a list using a list template
 
=item * check_param_in
 
=item * Sympa::Robot::send_notify_to_listmaster
=item * tools::send_notify_to_listmaster
 
=item * Sympa::Report::reject_report_web
 
......@@ -11482,13 +11483,8 @@ sub do_create_list {
if ($param->{'create_action'} =~ /notify/) {
wwslog('info', 'Notify listmaster');
 
Sympa::Robot::send_notify_to_listmaster(
'request_list_creation',
$robot,
{ 'list' => $list,
'email' => $param->{'user'}{'email'}
}
);
tools::send_notify_to_listmaster($list, 'request_list_creation',
{'email' => $param->{'user'}{'email'}});
}
 
web_db_log(
......@@ -21524,11 +21520,10 @@ sub do_change_email {
my $admin_user = $list->get_list_admin($role, $old_email);
if ($admin_user->{'included'}) {
## Notify listmaster
Sympa::Robot::send_notify_to_listmaster(
tools::send_notify_to_listmaster(
$list,
'failed_to_change_included_admin',
$robot,
{ 'list' => $list,
'current_email' => $old_email,
{ 'current_email' => $old_email,
'new_email' => $new_email,
'datasource' =>
$list->get_datasource_name($admin_user->{'id'})
......@@ -21569,9 +21564,9 @@ sub do_change_email {
}
## Notify listmasters that list owners/moderators email have changed
if (keys %updated_lists) {
Sympa::Robot::send_notify_to_listmaster(
'listowner_email_changed',
tools::send_notify_to_listmaster(
$robot,
'listowner_email_changed',
{ 'list' => $list,
'previous_email' => $old_email,
'new_email' => $new_email,
......@@ -23996,8 +23991,7 @@ sub do_css {
unless (tt2::parse_tt2($param, 'css.tt2', \*STDOUT, $tt2_include_path)) {
my $error = tt2::get_error();
$param->{'tt2_error'} = $error;
Sympa::Robot::send_notify_to_listmaster('web_tt2_error', $robot,
[$error]);
tools::send_notify_to_listmaster($robot, 'web_tt2_error', [$error]);
wwslog('info', '/%s: error', $in{'file'});
}
 
......@@ -24846,9 +24840,9 @@ sub do_automatic_lists_request {
wwslog('err',
'Failed to instantiate family %s. This family does not exist',
$in{'family'});
Sympa::Robot::send_notify_to_listmaster(
'automatic_list_creation_failed',
tools::send_notify_to_listmaster(
$robot,
'automatic_list_creation_failed',
[ "Failed to instantiate family $in{'family'}. This family does not exist."
]
);
......@@ -24907,9 +24901,9 @@ sub do_automatic_lists {
Log::do_log('err',
"Failed to create the dynamic list $listname: family $family_name does not exist."
);
Sympa::Robot::send_notify_to_listmaster(
'automatic_list_creation_failed',
tools::send_notify_to_listmaster(
$robot,
'automatic_list_creation_failed',
[ "Failed to create the dynamic list $listname: family $family_name does not exist."
]
);
......@@ -24926,9 +24920,11 @@ sub do_automatic_lists {
) {
Log::do_log('err', 'Failed to create the dynamic list %s',
$listname);
Sympa::Robot::send_notify_to_listmaster(
tools::send_notify_to_listmaster(
$robot,
'automatic_list_creation_failed',
$robot, ["Failed to create the dynamic list $listname."]);
["Failed to create the dynamic list $listname."]
);
return undef;
}
}
......
......@@ -759,8 +759,8 @@ sub checkfiles {
if (defined $Conf{'cafile'} && $Conf{'cafile'}) {
unless (-f $Conf{'cafile'} && -r $Conf{'cafile'}) {
Log::do_log('err', 'Cannot access cafile %s', $Conf{'cafile'});
Sympa::Robot::send_notify_to_listmaster('cannot_access_cafile',
$Conf{'domain'}, [$Conf{'cafile'}]);
tools::send_notify_to_listmaster('*', 'cannot_access_cafile',
[$Conf{'cafile'}]);
$config_err++;
}
}
......@@ -768,8 +768,8 @@ sub checkfiles {
if (defined $Conf{'capath'} && $Conf{'capath'}) {
unless (-d $Conf{'capath'} && -x $Conf{'capath'}) {
Log::do_log('err', 'Cannot access capath %s', $Conf{'capath'});
Sympa::Robot::send_notify_to_listmaster('cannot_access_capath',
$Conf{'domain'}, [$Conf{'capath'}]);
tools::send_notify_to_listmaster('*', 'cannot_access_capath',
[$Conf{'capath'}]);
$config_err++;
}
}
......@@ -781,9 +781,11 @@ sub checkfiles {
'Error in config: queuebounce and bounce_path parameters pointing to the same directory (%s)',
$Conf{'queuebounce'}
);
Sympa::Robot::send_notify_to_listmaster(
tools::send_notify_to_listmaster(
'*',
'queuebounce_and_bounce_path_are_the_same',
$Conf{'domain'}, [$Conf{'queuebounce'}]);
[$Conf{'queuebounce'}]
);
$config_err++;
}
......@@ -795,9 +797,9 @@ sub checkfiles {
'Error in config: queue and queueautomatic parameters pointing to the same directory (%s)',
$Conf{'queue'}
);
Sympa::Robot::send_notify_to_listmaster(
tools::send_notify_to_listmaster('*',
'queue_and_queueautomatic_are_the_same',
$Conf{'domain'}, [$Conf{'queue'}]);
[$Conf{'queue'}]);
$config_err++;
}
......@@ -864,8 +866,8 @@ sub checkfiles {
## Create directory if required
unless (-d $dir) {
unless (tools::mkdir_all($dir, 0755)) {
Sympa::Robot::send_notify_to_listmaster('cannot_mkdir',
$robot, ["Could not create directory $dir: $ERRNO"]);
tools::send_notify_to_listmaster($robot, 'cannot_mkdir',
["Could not create directory $dir: $ERRNO"]);
Log::do_log('err', 'Failed to create directory %s: %m', $dir);
return undef;
}
......@@ -890,8 +892,8 @@ sub checkfiles {
rename $dir . '/' . $css, $dir . '/' . $css . '.' . time;
unless (open(CSS, ">$dir/$css")) {
Sympa::Robot::send_notify_to_listmaster(
'cannot_open_file', $robot,
tools::send_notify_to_listmaster($robot,
'cannot_open_file',
["Could not open file $dir/$css: $ERRNO"]);
Log::do_log(
'err',
......@@ -908,8 +910,8 @@ sub checkfiles {
) {
my $error = tt2::get_error();
$param->{'tt2_error'} = $error;
Sympa::Robot::send_notify_to_listmaster('web_tt2_error',
$robot, [$error]);
tools::send_notify_to_listmaster($robot, 'web_tt2_error',
[$error]);
Log::do_log('err', 'Error while installing %s/%s',
$dir, $css);
}
......@@ -925,9 +927,9 @@ sub checkfiles {
}
if ($css_updated) {
## Notify main listmaster
Sympa::Robot::send_notify_to_listmaster(
tools::send_notify_to_listmaster(
'*',
'css_updated',
$Conf{'domain'},
[ "Static CSS files have been updated ; check log file for details"
]
);
......@@ -2190,9 +2192,9 @@ sub _load_single_robot_config {
$config_file);
unless (-r $config_file) {
Log::do_log('err', 'No read access on %s', $config_file);
Sympa::Robot::send_notify_to_listmaster(
tools::send_notify_to_listmaster(
'*',
'cannot_access_robot_conf',
$Conf{'domain'},
[ "No read access on $config_file. you should change privileges on this file to activate this virtual host. "
]
);
......
......@@ -70,8 +70,8 @@ sub fatal_err {
if ($EVAL_ERROR && ($warning_date < time - $warning_timeout)) {
$warning_date = time + $warning_timeout;
unless (
Sympa::Robot::send_notify_to_listmaster(
'logs_failed', $Conf::Conf{'domain'}, [$EVAL_ERROR]
tools::send_notify_to_listmaster(
'*', 'logs_failed', [$EVAL_ERROR]
)
) {
print STDERR "No logs available, can't send warning message";
......@@ -82,8 +82,8 @@ sub fatal_err {
my $full_msg = sprintf $m, @_;
## Notify listmaster
Sympa::Robot::send_notify_to_listmaster('sympa_died',
$Conf::Conf{'domain'}, [$full_msg]);
#FIXME: Add entry to listmaster_notification.tt2
tools::send_notify_to_listmaster('*', 'sympa_died', [$full_msg]);
printf STDERR "$m\n", @_;
exit(1);
......@@ -204,8 +204,8 @@ sub do_log {
};
if ($EVAL_ERROR and $warning_date < time - $warning_timeout) {
$warning_date = time + $warning_timeout;
Sympa::Robot::send_notify_to_listmaster('logs_failed',
$Conf::Conf{'domain'}, [$EVAL_ERROR]);
#FIXIME: Add entry to listmaster_notification.tt2
tools::send_notify_to_listmaster('*', 'logs_failed', [$EVAL_ERROR]);
}
}
......@@ -237,8 +237,8 @@ sub do_connect {
if ($EVAL_ERROR && ($warning_date < time - $warning_timeout)) {
$warning_date = time + $warning_timeout;
unless (
Sympa::Robot::send_notify_to_listmaster(
'logs_failed', $Conf::Conf{'domain'}, [$EVAL_ERROR]
tools::send_notify_to_listmaster(
'*', 'logs_failed', [$EVAL_ERROR]
)
) {
print STDERR "No logs available, can't send warning message";
......
......@@ -25,6 +25,7 @@ nobase_modules_DATA = \
Sympa/Archive.pm \
Sympa/Auth.pm \
Bounce.pm \
Sympa/Alarm.pm \
Sympa/Bulk.pm \
Sympa/Commands.pm \
Conf.pm \
......
......@@ -334,11 +334,9 @@ sub probe_db {
$Sympa::List::use_db = 1;
## Notify listmaster
Sympa::Robot::send_notify_to_listmaster(
'db_struct_updated',
Conf::get_robot_conf('*', 'domain'),
{'report' => \@report}
) if @report;
tools::send_notify_to_listmaster('*', 'db_struct_updated',
{'report' => \@report})
if @report;
return 1;
}
......
......@@ -890,11 +890,10 @@ sub rename_list {
# set list status to pending if creation list is moderated
if ($r_action =~ /listmaster/) {
$list->{'admin'}{'status'} = 'pending';
Sympa::Robot::send_notify_to_listmaster(
tools::send_notify_to_listmaster(
$list,
'request_list_renaming',
$list->{'domain'},
{ 'list' => $list,
'new_listname' => $param{'new_listname'},
{ 'new_listname' => $param{'new_listname'},
'old_listname' => $old_listname,
'email' => $param{'user_email'},
'mode' => $param{'mode'}
......@@ -1696,11 +1695,10 @@ sub change_user_email {
$list->get_list_admin($role, $in{'current_email'});
if ($admin_user->{'included'}) {
## Notify listmaster
Sympa::Robot::send_notify_to_listmaster(
tools::send_notify_to_listmaster(
$list,
'failed_to_change_included_admin',
$robot_id,
{ 'list' => $list,
'current_email' => $in{'current_email'},
{ 'current_email' => $in{'current_email'},
'new_email' => $in{'new_email'},
'datasource' =>
$list->get_datasource_name($admin_user->{'id'})
......@@ -1734,9 +1732,9 @@ sub change_user_email {
}
## Notify listmasters that list owners/moderators email have changed
if (keys %updated_lists) {
Sympa::Robot::send_notify_to_listmaster(
'listowner_email_changed',
tools::send_notify_to_listmaster(
$robot_id,
'listowner_email_changed',
{ 'previous_email' => $in{'current_email'},
'new_email' => $in{'new_email'},
'updated_lists' => keys %updated_lists
......
# -*- indent-tabs-mode: nil; -*-
# vim:ft=perl:et:sw=4
# $Id$
# Sympa - SYsteme de Multi-Postage Automatique
#
# Copyright (c) 1997, 1998, 1999 Institut Pasteur & Christophe Wolfhugel
# Copyright (c) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
# 2006, 2007, 2008, 2009, 2010, 2011 Comite Reseau des Universites
# Copyright (c) 2011, 2012, 2013, 2014 GIP RENATER
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
package Sympa::Alarm;
use strict;
use warnings;
use Conf;
use Log;
use Sympa::Mail;
use Sympa::Message;
use tools;
our %listmaster_messages_stack;
sub store {
my $message = shift;
my $operation = shift;
my $email = $message->{rcpt};
my $robot_id;
if (ref $message->{context} eq 'Sympa::List') {
$robot_id = $message->{context}->{'domain'};
} elsif ($message->{context} and $message->{context} ne '*') {
$robot_id = $message->{context};
} else {
$robot_id = '*';
}
$listmaster_messages_stack{$robot_id}{$operation}{'first'} = time
unless $listmaster_messages_stack{$robot_id}{$operation} {'first'};
$listmaster_messages_stack{$robot_id}{$operation}{'counter'}++;
$listmaster_messages_stack{$robot_id}{$operation}{'last'} = time;
if ($listmaster_messages_stack{$robot_id}{$operation}{'counter'} > 3) {
# stack if too much messages w/ same code
Log::do_log('info', 'Stacking message about "%s" for %s (%s)',
$operation, $email, $robot_id)
unless $operation eq 'logs_failed';
push
@{$listmaster_messages_stack{$robot_id}{$operation}
{'messages'}{$email}}, $message->as_string;
return 1;
} else {
return Sympa::Mail::sending(
$message,
$email,
Conf::get_robot_conf($robot_id, 'request'),
priority => Conf::get_robot_conf($robot_id, 'sympa_priority')
);
}
}
sub flush {
my $purge = shift;
foreach my $robot_id (keys %listmaster_messages_stack) {
foreach my $operation (
keys %{$listmaster_messages_stack{$robot_id}}) {
my $first_age =
time -
$listmaster_messages_stack{$robot_id}{$operation}{'first'};
my $last_age =
time -
$listmaster_messages_stack{$robot_id}{$operation}{'last'};
# not old enough to send and first not too old
next
unless $purge or $last_age > 30 or $first_age > 60;
next
unless $listmaster_messages_stack{$robot_id}{$operation}{'messages'};
my %messages =
%{$listmaster_messages_stack{$robot_id}{$operation}{'messages'}};
Log::do_log(
'info', 'Got messages about "%s" (%s)',
$operation, join(', ', keys %messages)
);
##### bulk send
foreach my $email (keys %messages) {
my $param = {
to => $email,
auto_submitted => 'auto-generated',
operation => $operation,
notification_messages => $messages{$email},
boundary => '----------=_'
. tools::get_message_id($robot_id)
};
Log::do_log('info', 'Send messages to %s', $email);
# Skip DB access because DB is not accessible