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

[dev] Now functions to send messages in Sympa package use...

[dev] Now functions to send messages in Sympa package use Sympa::Spindle::ProcessTemplate.  Sympa::Spindle::ToAlarm and Sympa::Spindle::ToMailer claesses were added.

After all, most of dependency loops among Sympa internal modules are dissolved.


git-svn-id: https://subversion.renater.fr/sympa/branches/sympa-6.2-branch@12602 05aa8bb8-cd2b-0410-b1d7-8918dfa770ce
parent 0c978115
......@@ -95,11 +95,13 @@ nobase_modules_DATA = \
Sympa/Spindle/ProcessOutgoing.pm \
Sympa/Spindle/ProcessTemplate.pm \
Sympa/Spindle/ResendArchive.pm \
Sympa/Spindle/ToAlarm.pm \
Sympa/Spindle/ToArchive.pm \
Sympa/Spindle/ToDigest.pm \
Sympa/Spindle/ToEditor.pm \
Sympa/Spindle/ToHeld.pm \
Sympa/Spindle/ToList.pm \
Sympa/Spindle/ToMailer.pm \
Sympa/Spindle/ToModeration.pm \
Sympa/Spindle/ToOutgoing.pm \
Sympa/Spindle/TransformDigestFinal.pm \
......
......@@ -49,13 +49,11 @@ use Digest::MD5;
use English qw(-no_match_vars);
use Scalar::Util qw();
use Sympa::Alarm;
use Sympa::Bulk;
use Conf;
use Sympa::Constants;
use Sympa::Language;
use Sympa::Log;
use Sympa::Message::Template;
use Sympa::Spindle::ProcessTemplate;
use Sympa::Ticket;
use tools;
use Sympa::Tools::Data;
......@@ -660,7 +658,7 @@ sub send_dsn {
(eval { DateTime->now(time_zone => 'local') } || DateTime->now)
->strftime('%a, %{day} %b %Y %H:%M:%S %z');
my $dsn_message = Sympa::Message::Template->new(
my $spindle = Sympa::Spindle::ProcessTemplate->new(
context => $that,
template => 'delivery_status_notification',
rcpt => $sender,
......@@ -674,13 +672,11 @@ sub send_dsn {
'action' => $action,
'status' => $status,
'diagnostic_code' => $diag,
}
);
if ($dsn_message) {
},
# Set envelope sender. DSN _must_ have null envelope sender.
$dsn_message->{envelope_sender} = '<>';
}
unless ($dsn_message and Sympa::Bulk->new->store($dsn_message, $sender)) {
envelope_sender => '<>',
);
unless ($spindle and $spindle->spin and $spindle->{finish} eq 'success') {
$log->syslog('err', 'Unable to send DSN to %s', $sender);
return undef;
}
......@@ -723,15 +719,14 @@ sub send_file {
my $context = shift || {};
my %options = @_;
my $message = Sympa::Message::Template->new(
my $spindle = Sympa::Spindle::ProcessTemplate->new(
context => $that,
template => $tpl,
rcpt => $who,
data => $context,
%options
);
unless ($message and defined Sympa::Bulk->new->store($message, $who)) {
unless ($spindle and $spindle->spin and $spindle->{finish} eq 'success') {
$log->syslog('err', 'Could not send template %s to %s', $tpl, $who);
return undef;
}
......@@ -855,19 +850,17 @@ sub send_notify_to_listmaster {
or $operation eq 'no_db'
or $operation eq 'db_restored');
my $notif_message = Sympa::Message::Template->new(
my $spindle = Sympa::Spindle::ProcessTemplate->new(
context => $that,
template => 'listmaster_notification',
rcpt => $email,
data => $ts->{'data'}
);
data => $ts->{'data'},
unless (
$notif_message
and defined Sympa::Alarm->instance->store(
$notif_message, $email, operation => $operation
)
) {
splicing_to => ['Sympa::Spindle::ToAlarm'],
);
unless ($spindle
and $spindle->spin
and $spindle->{finish} eq 'success') {
$log->syslog(
'notice',
'Unable to send template "listmaster_notification" to %s listmaster %s',
......
# -*- 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, 2015 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::Spindle::ToAlarm;
use strict;
use warnings;
use Sympa::Alarm;
use base qw(Sympa::Spindle);
sub _twist {
my $self = shift;
my $message = shift;
return Sympa::Alarm->instance->store($message, $message->{rcpt},
operation => $self->{data}{type}) ? 1 : undef;
}
1;
__END__
# -*- 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, 2015 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::Spindle::ToMailer;
use strict;
use warnings;
use Sympa::Mailer;
use base qw(Sympa::Spindle);
sub _twist {
my $self = shift;
my $message = shift;
# ToDo: Consider envid and tag.
return Sympa::Mailer->instance->store($message, $message->{rcpt})
? 1
: undef;
}
1;
__END__
Markdown is supported
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