Commit c261ab93 authored by sikeda's avatar sikeda
Browse files

[-dev] Give appropriate command lines in notification messages.


git-svn-id: https://subversion.renater.fr/sympa/branches/sympa-6.2-branch@12747 05aa8bb8-cd2b-0410-b1d7-8918dfa770ce
parent 376089d2
......@@ -13,7 +13,13 @@ X-Loop: [% conf.email %]@[% conf.host %]
[% END -%]
[%- FOREACH notice = notices -%]
> [% notice.cmd -%]
> [% IF notice.cmd == 'subscribe' ~%]
[%|loc(notice.listname)%]Subscription request to list %1[%END%]
[%~ ELSIF notice.cmd == 'signoff' ~%]
[%|loc(notice.listname)%]UNsubscription request from list %1[%END%]
[%~ ELSE ~%]
[% notice.cmd %]
[%~ END -%]
> [% notice.entry %]
[% IF notice.entry == 'smime' -%]
......@@ -70,7 +76,13 @@ been subscribed (or unsubscribed) to the list.[%END-%]
[% END -%]
[%- FOREACH auth = auths -%]
> [% auth.cmd -%]
> [% IF auth.cmd == 'subscribe' ~%]
[%|loc(auth.listname)%]Subscription request to list %1[%END%]
[%~ ELSIF auth.cmd == 'signoff' ~%]
[%|loc(auth.listname)%]UNsubscription request from list %1[%END%]
[%~ ELSE ~%]
[% auth.cmd %]
[%~ END -%]
[% SET reason = auth.entry -%] [% PROCESS authorization_reject.tt2 -%]
[% END -%]
......@@ -88,7 +100,13 @@ been subscribed (or unsubscribed) to the list.[%END-%]
[% END -%]
[%- FOREACH u_err = user_errors -%]
> [% u_err.cmd -%]
> [% IF u_err.cmd == 'subscribe' ~%]
[%|loc(u_err.listname)%]Subscription request to list %1[%END%]
[%~ ELSIF u_err.cmd == 'signoff' ~%]
[%|loc(u_err.listname)%]UNsubscription request from list %1[%END%]
[%~ ELSE ~%]
[% u_err.cmd %]
[%~ END -%]
[% IF u_err.entry == 'unknown_action' -%]
[%|loc%]Command not understood: ignoring end of message.[%END%]
......@@ -187,7 +205,13 @@ Warning: this message may already have been sent by one of the list's editor.[%E
[% END -%]
[%- FOREACH i_err = intern_errors -%]
> [% i_err.cmd %]
> [% IF i_err.cmd == 'subscribe' ~%]
[%|loc(i_err.listname)%]Subscription request to list %1[%END%]
[%~ ELSIF i_err.cmd == 'signoff' ~%]
[%|loc(i_err.listname)%]UNsubscription request from list %1[%END%]
[%~ ELSE ~%]
[% i_err.cmd %]
[%~ END -%]
[% END -%]
[% END -%]
......
......@@ -6,11 +6,11 @@ Subject: [% FILTER qencode %][%|loc(list.name)%]Invitation to join list %1[%END%
[%|loc(list.subject)%]This list is about %1, so you are probably concerned.[%END%]
[%|loc%]To subscribe just hit the following link:[%END%]
[% | mailtourl({subject=>"auth ${keyauth} sub ${list.name} ${user.email}"}) ~%]
[% | mailtourl({subject => "AUTH ${keyauth} ${cmd}"}) ~%]
[% conf.email %]@[% conf.host %]
[%~ END %]
[%|loc(conf.email,conf.host)%]Or send a message to %1@%2 with the following subject:[%END%]
AUTH [% keyauth %] SUB [% list.name %] [% user.email %]
AUTH [% keyauth %] [% cmd %]
[%|loc%]If you don't want to subscribe just ignore this message.[%END%]
[%# $Id$ ~%]
To: [% to %]
Subject: [% FILTER qencode %][%command%][%END%]
Subject: [% FILTER qencode %]AUTH [%keyauth%] [%cmd%][%END%]
[% IF type == 'signoff' -%]
[%|loc(list.name)-%]You asked for your e-mail address to be removed from list '%1'.[%- END -%]
......@@ -22,7 +22,7 @@ Subject: [% FILTER qencode %][%command%][%END%]
[%- END -%]
[% sympa = BLOCK %][% conf.email %]@[% conf.host %][%END%]
[%|loc(sympa,command) %]If you want this action to be taken, please
[%|loc(sympa,"AUTH ${keyauth} ${cmd}") %]If you want this action to be taken, please
- reply to this mail
OR
......@@ -30,7 +30,7 @@ OR
%2
OR
- hit the following mailto[% END %]
[% | mailtourl({subject => "$command"}) ~%]
[% | mailtourl({subject => "AUTH ${keyauth} ${cmd}"}) ~%]
[% conf.email %]@[% conf.host %]
[%~ END %]
......
......@@ -247,8 +247,14 @@ our %comms = (
cmd_regexp => qr'sig|signoff|uns|unsub|unsubscribe'i,
arg_regexp => qr{([^\s\@]+)(?:\@([-.\w]+))?(?:\s+($_email_re))?\z},
arg_keys => [qw(localpart domainpart email)],
cmd_format => 'SIG %1$s %3$s',
filter => sub {
cmd_format => sub {
my $r = shift;
return ($r->{sender} and $r->{sender} eq $r->{email})
? 'SIG %s'
: 'SIG %1$s %3$s';
},
filter => sub {
my $r = shift;
# email is defined if command is "unsubscribe <listname> <e-mail>".
......@@ -273,8 +279,14 @@ our %comms = (
cmd_regexp => qr'(?:sig|signoff|uns|unsub|unsubscribe)\s+[*]'i,
arg_regexp => qr{($_email_re)?\z},
arg_keys => [qw(email)],
cmd_format => 'SIG * %s',
filter => sub {
cmd_format => sub {
my $r = shift;
return ($r->{sender} and $r->{sender} eq $r->{email})
? 'SIG *'
: 'SIG * %s';
},
filter => sub {
my $r = shift;
# email is defined if command is "unsubscribe * <e-mail>".
......
......@@ -28,6 +28,7 @@ use strict;
use warnings;
use Scalar::Util qw();
use Sympa;
use Sympa::CommandDef;
use Sympa::Log;
use Sympa::Tools::Data;
......@@ -107,9 +108,11 @@ sub new_from_tuples {
}
sub cmd_line {
my $self = shift;
my $self = shift;
my %options = @_;
return $self->{cmd_line} if $self->{cmd_line};
return $self->{cmd_line}
if $self->{cmd_line} and not $options{canonic};
return undef
if not $self->{action}
or $self->{action} eq 'unknown';
......@@ -119,8 +122,18 @@ sub cmd_line {
return undef
unless $cmd_format;
$cmd_format = $cmd_format->($self) if ref $cmd_format;
my %attrs = %{$self};
my $context = $self->{context};
if (ref $context eq 'Sympa::List') {
@attrs{qw(localpart domainpart)} =
split /\@/, Sympa::get_address($context);
} else {
$attrs{domainpart} = $context;
}
return sprintf $cmd_format,
map { defined $_ ? $_ : '' } @{$self}{@{$arg_keys || []}};
map { defined $_ ? $_ : '' } @attrs{@{$arg_keys || []}};
}
sub dup {
......@@ -272,7 +285,7 @@ Gets deep copy of instance.
I<Serializer>.
Returns serialized data of object.
=item cmd_line ( )
=item cmd_line ( [ canonic =E<gt> 1 ] )
I<Instance method>.
TBD.
......
......@@ -123,17 +123,16 @@ sub _twist {
);
my $keyauth = $spool_req->store($req_subscribe);
my $cmd_line = $req_subscribe->cmd_line(canonic => 1);
unless (
Sympa::send_file(
$list, 'invite', $email,
{ user => {email => $email, gecos => $comment},
requested_by => $sender,
keyauth => $keyauth,
cmd => $cmd_line,
# Compat. <= 6.2.14.
subject => sprintf(
'auth %s sub %s %s',
$keyauth, $list->{'name'}, $comment
)
subject => sprintf('AUTH %s %s', $keyauth, $cmd_line),
}
)
) {
......
......@@ -97,6 +97,7 @@ sub _load {
email => $message->{sender},
#FIXME: smime_signed?
(map { ($_ => $message->{$_}) } qw(date sender dkim_pass)),
cmd_line => $action, # Fake command line.
)
];
}
......
......@@ -1512,13 +1512,16 @@ sub subscribe {
}
# Send notice to the user.
my $cmd_line = $request->cmd_line;
my $cmd_line = $request->cmd_line(canonic => 1);
unless (
Sympa::send_file(
$list,
'request_auth',
$sender,
{ command => sprintf('AUTH %s %s', $keyauth, $cmd_line),
{ cmd => $cmd_line,
# Compat. <= 6.2.14.
command => sprintf('AUTH %s %s', $keyauth, $cmd_line),
keyauth => $keyauth,
type => $request->{action},
to => $sender,
auto_submitted => 'auto-replied',
......
......@@ -54,13 +54,16 @@ sub _twist {
}
# Send notice to the user.
my $cmd_line = $request->cmd_line;
my $cmd_line = $request->cmd_line(canonic => 1);
unless (
Sympa::send_file(
$that,
'request_auth',
$to,
{ command => sprintf('AUTH %s %s', $keyauth, $cmd_line),
{ cmd => $cmd_line,
# Compat. <= 6.2.14.
command => sprintf('AUTH %s %s', $keyauth, $cmd_line),
keyauth => $keyauth,
type => $request->{action},
to => $to,
auto_submitted => 'auto-replied',
......
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