Commit acff79bc authored by sikeda's avatar sikeda
Browse files

[dev] Introducing Sympa::Spindle::ToAuth and Sympa::Spindle::ToRequest to hold requests.


git-svn-id: https://subversion.renater.fr/sympa/branches/sympa-6.2-branch@12645 05aa8bb8-cd2b-0410-b1d7-8918dfa770ce
parent a7fe9a85
......@@ -102,6 +102,7 @@ nobase_modules_DATA = \
Sympa/Spindle/ResendArchive.pm \
Sympa/Spindle/ToAlarm.pm \
Sympa/Spindle/ToArchive.pm \
Sympa/Spindle/ToAuth.pm \
Sympa/Spindle/ToDigest.pm \
Sympa/Spindle/ToEditor.pm \
Sympa/Spindle/ToHeld.pm \
......@@ -109,6 +110,7 @@ nobase_modules_DATA = \
Sympa/Spindle/ToMailer.pm \
Sympa/Spindle/ToModeration.pm \
Sympa/Spindle/ToOutgoing.pm \
Sympa/Spindle/ToRequest.pm \
Sympa/Spindle/TransformDigestFinal.pm \
Sympa/Spindle/TransformIncoming.pm \
Sympa/Spindle/TransformOutgoing.pm \
......
......@@ -9,6 +9,8 @@ Sympa::Internals::Workflow - Overview on workflow of Sympa
Following picture roughly describes interaction among several classes in
workflow of Sympa. For more details see documentation on each class.
=head2 Message processing
<<archived.pl>>
Archive => [ProcessArchive] => (list archive)
......@@ -41,15 +43,16 @@ workflow of Sympa. For more details see documentation on each class.
\ +-> [ToEditor] => Outgoing
+-> [DoMessage] /
\ /---> [ToHeld] => Held
*2 +-> [AuthorizeMessage]
*3 (CONFIRM) +-> [AuthorizeMessage]
: / \---> [ToModeration] => Mod.
Held => [ProcessHeld] -------+ \
+-> [DistributeMessage]
*2 +--> (reject) / \
: / / \
Moderation => [ProcessModeration] / \
\ / \
+-----------+ \
*3 (DISTRIBUTE) / \
(REJECT) +--> (reject) / \
: / / \
Moderation => [ProcessModeration] / \
\ / \
+----------+ \
\
+-------------------------------------------+
\
......@@ -71,6 +74,21 @@ workflow of Sympa. For more details see documentation on each class.
: \
*1 +----------> [ToMailer] => (Mailer)
=head2 Command processing
<< sympa_msg.pl >>
*2
: +-> (reject)
(message) => [ProcessMessage] /
\ /---> [ToAuth] => (authkey)
+-> [AuthorizeRequest]
\---> [ToRequest] => Request
\
+-> [DispatchRequest]
:
*3
=begin comment
These have not been implemented yet.
......@@ -79,19 +97,9 @@ These have not been implemented yet.
Task => [ProcessTask] => Task
<<Others>>
Request => [ValidateAdd]
Request => [ValidateDel]
Request => [ValidateClose]
Request => [ValidatePurge]
=end comment
=head3 Legend
=head2 Legend
=over
......@@ -128,6 +136,10 @@ L<Sympa::Archive> class.
L<Sympa::Message::Template> class.
=item C<(message)>
L<Sympa::Request::Message> class.
=back
=head1 SEE ALSO
......
......@@ -119,81 +119,12 @@ sub _twist {
} elsif ($action =~ /\Arequest_auth\b(?:\s*[[]\s*(\S+)\s*[]])?/i) {
my $to = $1;
if ($to and $to eq 'email') {
$to = $request->{email} || $sender;
} else {
$to = $sender;
$request->{sender_to_confirm} = $request->{email};
}
$log->syslog('debug2', 'Auth requested from %s', $sender);
unless (Sympa::request_auth(%$request, sender => $to)) {
my $error = sprintf
'Unable to request authentication for command "%s"',
$request->{action};
Sympa::Report::reject_report_cmd($request, 'intern', $error);
return undef;
}
$log->syslog(
'info',
'%s for %s from %s, auth requested (%.2f seconds)',
uc $request->{action},
$that,
$sender,
Time::HiRes::time() - $self->{start_time}
);
return 1;
return ['Sympa::Spindle::ToAuth'];
} elsif ($action =~ /\Aowner\b/i and ref $that eq 'Sympa::List') {
Sympa::Report::notice_report_cmd($request, 'req_forward')
unless $action =~ /,\s*quiet\b/i;
my $tpl =
{subscribe => 'subrequest', signoff => 'sigrequest'}
->{$request->{action}};
my $owner_action =
{subscribe => 'add', signoff => 'del'}->{$request->{action}};
# Send a notice to the owners.
unless (
$that->send_notify_to_owner(
$tpl,
{ 'who' => $sender,
'keyauth' => Sympa::compute_auth(
context => $that,
email => $request->{email},
action => $owner_action,
),
'replyto' => Sympa::get_address($that, 'sympa'),
'gecos' => $request->{gecos},
}
)
) {
#FIXME: Why is error reported only in this case?
$log->syslog('info',
'Unable to send notify "%s" to %s list owner',
$tpl, $that);
Sympa::Report::reject_report_cmd(
$request, 'intern',
sprintf('Unable to send subrequest to %s list owner',
$that->get_id)
);
}
my $spool_req = Sympa::Spool::Request->new;
my $add_request = Sympa::Request->new_from_tuples(
%$request,
action => $owner_action,
date => $message->{date}, # Keep date of message.
);
if ($spool_req->store($add_request)) {
$log->syslog(
'info',
'%s for %s from %s forwarded to the owners of the list (%.2f seconds)',
uc $request->{action},
$that,
$sender,
Time::HiRes::time() - $self->{start_time}
);
}
return 1;
$request->{quiet} ||= ($action =~ /,\s*quiet\b/i);
return ['Sympa::Spindle::ToRequest'];
} elsif ($action =~ /\Areject\b/i) {
if (defined $result->{'tt2'}) {
unless (
......
# -*- 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, 2016 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::ToAuth;
use strict;
use warnings;
use Time::HiRes qw();
use Sympa;
use Sympa::Log;
use Sympa::Report;
use base qw(Sympa::Spindle);
my $log = Sympa::Log->instance;
sub _twist {
my $self = shift;
my $request = shift;
my $sender = $request->{sender};
my $to = $request->{sender_to_confirm} || $sender;
$log->syslog('debug2', 'Auth requested from %s', $sender);
unless (Sympa::request_auth(%$request, sender => $to)) {
my $error = sprintf
'Unable to request authentication for command "%s"',
$request->{action};
Sympa::Report::reject_report_cmd($request, 'intern', $error);
return undef;
}
$log->syslog(
'info',
'%s for %s from %s, auth requested (%.2f seconds)',
uc $request->{action},
$request->{context},
$sender,
Time::HiRes::time() - $self->{start_time}
);
return 1;
}
1;
# -*- 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, 2016 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::ToRequest;
use strict;
use warnings;
use Time::HiRes qw();
use Sympa;
use Sympa::Log;
use Sympa::Report;
use Sympa::Request;
use Sympa::Spool::Request;
use base qw(Sympa::Spindle);
my $log = Sympa::Log->instance;
sub _twist {
my $self = shift;
my $request = shift;
my $list = $request->{context};
my $message = $request->{message};
my $sender = $request->{sender};
Sympa::Report::notice_report_cmd($request, 'req_forward')
unless $request->{quiet};
my $tpl =
{subscribe => 'subrequest', signoff => 'sigrequest'}
->{$request->{action}};
my $owner_action =
{subscribe => 'add', signoff => 'del'}->{$request->{action}};
# Send a notice to the owners.
unless (
$list->send_notify_to_owner(
$tpl,
{ 'who' => $sender,
'keyauth' => Sympa::compute_auth(
context => $list,
email => $request->{email},
action => $owner_action,
),
'replyto' => Sympa::get_address($list, 'sympa'),
'gecos' => $request->{gecos},
}
)
) {
#FIXME: Why is error reported only in this case?
$log->syslog('info',
'Unable to send notify "%s" to %s list owner',
$tpl, $list);
Sympa::Report::reject_report_cmd(
$request, 'intern',
sprintf('Unable to send subrequest to %s list owner',
$list->get_id)
);
}
my $spool_req = Sympa::Spool::Request->new;
my $add_request = Sympa::Request->new_from_tuples(
%$request,
action => $owner_action,
date => $message->{date}, # Keep date of message.
);
if ($spool_req->store($add_request)) {
$log->syslog(
'info',
'%s for %s from %s forwarded to the owners of the list (%.2f seconds)',
uc $request->{action},
$list,
$sender,
Time::HiRes::time() - $self->{start_time}
);
}
return 1;
}
1;
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