Commit 0325b12d authored by sikeda's avatar sikeda
Browse files

[-dev] Copyedit. Sync tt2 entry names in code to process requests with those in WWSympa.


git-svn-id: https://subversion.renater.fr/sympa/branches/sympa-6.2-branch@12664 05aa8bb8-cd2b-0410-b1d7-8918dfa770ce
parent dbfe8241
......@@ -89,34 +89,33 @@ been subscribed (or unsubscribed) to the list.[%END-%]
[%- FOREACH u_err = user_errors -%]
> [% u_err.cmd -%]
[% IF u_err.entry == 'not_understood' -%]
[% IF u_err.entry == 'unknown_action' -%]
[%|loc%]Command not understood: ignoring end of message.[%END%]
[% ELSIF u_err.entry == 'no_verify_sign' -%]
[%|loc%]Your message was not a multipart/signed message or Sympa could not verify the signature
(be aware that Sympa can't check signature if you use the subject header to write a command).[%END-%]
[% ELSIF u_err.entry == 'error_syntax' -%]
[% ELSIF u_err.entry == 'syntax_errors' -%]
[%|loc%]Command syntax error.[%END%]
[% ELSIF u_err.entry == 'no_existing_list' -%]
[% ELSIF u_err.entry == 'unknown_list' -%]
[%|loc(u_err.listname)%]List '%1' does not exist.[%END%]
[% ELSIF u_err.entry == 'no_subscriber_preference' -%]
[%|loc(u_err.listname)%]%1 mailing list does not provide subscriber preferences.[%END%]
[% ELSIF u_err.entry == 'your_email_not_found' -%]
[%|loc(u_err.email,u_err.listname)%]Your e-mail address %1 has not been found in the list %2. Maybe
you subscribed from a different e-mail address ?[%END-%]
[% ELSIF u_err.entry == 'not_subscriber' -%]
[%|loc(u_err.email,u_err.listname)%]Your e-mail address %1 has not been found in the list %2. Maybe you subscribed from a different e-mail address?[%END-%]
[% ELSIF u_err.entry == 'email_not_found' -%]
[% ELSIF u_err.entry == 'user_not_subscriber' -%]
[%|loc(u_err.email,u_err.listname)%]E-mail address %1 has not been found in the list %2.[%END%]
[% ELSIF u_err.entry == 'no_digest' -%]
[%|loc(u_err.listname)%]List %1 does not accept the DIGEST mode.
Your configuration regarding this command has not been updated.[%END-%]
[% ELSIF u_err.entry == 'available_reception_mode' -%]
[% ELSIF u_err.entry == 'not_available_reception_mode' -%]
[%|loc(u_err.listname)%]List %1 allows only these reception modes: [%END -%]
[%- FOREACH m = u_err.reception_modes -%]
[%- IF loop.size >= 2 && loop.count == loop.size -%]
......@@ -158,11 +157,11 @@ Your configuration regarding this command has not been updated.[%END-%]
[%|loc(u_err.command)%]The authentication process failed. You probably confirmed your "%1" command using a different email address. Please try using your canonical address.[%END-%]
[% END -%]
[% ELSIF u_err.entry == 'unfound_message' -%]
[% ELSIF u_err.entry == 'already_moderated' -%]
[%|loc(u_err.listname,u_err.key)%]Unable to access the message on list %1 with key %2.
Warning: this message may already have been sent by one of the list's editor.[%END%]
[% ELSIF u_err.entry == 'unfound_file_message' -%]
[% ELSIF u_err.entry == 'already_confirmed' -%]
[%|loc(u_err.key)%]Unable to access the message authenticated with key %1. The message may already been confirmed.[%END%]
[% ELSE %]
......
......@@ -70,10 +70,10 @@
[% ELSIF u_err.msg == 'no_subscriber' %][%|loc%]List has no subscribers[%END%]
[% ELSIF u_err.msg == 'no_page' %][%|loc(u_err.page)%]No page %1[%END%]
[% ELSIF u_err.msg == 'no_filter' %][%|loc%]Missing filter[%END%]
[% ELSIF u_err.msg == 'not_subscriber' %]
[% IF u_err.email %] [%|loc(u_err.email)%]Not subscribed: %1[%END%]
[% ELSE %][%|loc(u_err.list)%]You are not subscribed to list %1[%END%]
[% END %]
[% ELSIF u_err.msg == 'user_not_subscriber' ~%]
[%|loc(u_err.email)%]Not subscribed: %1[%END%]
[% ELSIF u_err.msg == 'not_subscriber' ~%]
[%|loc(u_err.list)%]You are not subscribed to list %1[%END%]
[% ELSIF u_err.msg == 'custom_attribute' %][%|loc%]Check the additional information[%END%]
[% ELSIF u_err.msg == 'not_available_reception_mode' %][%|loc(u_err.reception_mode)%]%1 is not an available reception mode[%END%]
[% ELSIF u_err.msg == 'file_not_editable' %][%|loc(u_err.file)%]%1: file not editable[%END%]
......
......@@ -8402,7 +8402,7 @@ sub do_del {
my $user_entry = $list->get_list_member($email);
 
unless (defined($user_entry)) {
Sympa::Report::reject_report_web('user', 'not_subscriber',
Sympa::Report::reject_report_web('user', 'user_not_subscriber',
{'email' => $email},
$param->{'action'}, $list);
 
......@@ -11808,7 +11808,7 @@ sub do_resetbounce {
my $escaped_email = tools::escape_chars($email);
 
unless ($list->is_list_member($email)) {
Sympa::Report::reject_report_web('user', 'not_subscriber',
Sympa::Report::reject_report_web('user', 'user_not_subscriber',
{'email' => $email},
$param->{'action'}, $list);
wwslog('info', '%s not subscribed', $email);
......
......@@ -143,16 +143,22 @@ our %comms = (
set => {
cmd_regexp => qr'set'i,
arg_regexp =>
qr'(\S+)\s+(digest|digestplain|nomail|normal|not_me|each|mail|conceal|noconceal|summary|notice|txt|html|urlize)\s*\z'i,
arg_keys => [qw(localpart mode)],
qr'(\S+)\s+(?:(digest|digestplain|nomail|normal|not_me|each|mail|summary|notice|txt|html|urlize)|(conceal|noconceal))\s*\z'i,
arg_keys => [qw(localpart reception visibility)],
filter => sub {
my $r = shift;
$r->{mode} = lc($r->{mode} || '');
# SET EACH is a synonym for SET MAIL.
$r->{mode} = 'mail'
if grep { $r->{mode} eq $_ }
qw(each eachmail nodigest normal);
$r->{email} = $r->{sender};
if ($r->{reception}) {
$r->{reception} = lc $r->{reception};
# SET EACH is a synonym for SET MAIL.
$r->{reception} = 'mail'
if grep { $r->{reception} eq $_ }
qw(each eachmail nodigest normal);
}
if ($r->{visibility}) {
$r->{visibility} = lc $r->{visibility};
}
$r;
},
# No scenario. Only list members are allowed.
......@@ -160,16 +166,22 @@ our %comms = (
global_set => {
cmd_regexp => qr'set\s+[*]'i,
arg_regexp =>
qr'(digest|digestplain|nomail|normal|not_me|each|mail|conceal|noconceal|summary|notice|txt|html|urlize)\s*\z'i,
arg_keys => [qw(mode)],
qr'(?:(digest|digestplain|nomail|normal|not_me|each|mail|summary|notice|txt|html|urlize)|(conceal|noconceal))\s*\z'i,
arg_keys => [qw(reception visibility)],
filter => sub {
my $r = shift;
$r->{mode} = lc($r->{mode} || '');
# SET EACH is a synonym for SET MAIL.
$r->{mode} = 'mail'
if grep { $r->{mode} eq $_ }
qw(each eachmail nodigest normal);
$r->{email} = $r->{sender};
if ($r->{reception}) {
$r->{reception} = lc $r->{reception};
# SET EACH is a synonym for SET MAIL.
$r->{reception} = 'mail'
if grep { $r->{reception} eq $_ }
qw(each eachmail nodigest normal);
}
if ($r->{visibility}) {
$r->{visibility} = lc $r->{visibility};
}
$r;
},
},
......
......@@ -204,7 +204,7 @@ sub _parse {
auth => $auth,
cmd_line => $line,
context => $robot,
error => 'syntax_error',
error => 'syntax_errors',
quiet => $quiet,
( map { ($_ => $message->{$_}) }
qw(date sender dkim_pass smime_signed)
......@@ -228,7 +228,7 @@ sub _parse {
# Reject the command if this list is unknown to us.
$request->{error} = 'unknown_list';
} elsif ($filter and not $filter->($request)) {
$request->{error} = 'syntax_error';
$request->{error} = 'syntax_errors';
}
return $request;
......
......@@ -144,10 +144,29 @@ sub _twist {
$that, $sender
);
return 'not_allowed';
} else {
#NOTREACHED
die 'bug in logic. Ask developer';
}
$log->syslog(
'info',
'%s for %s from %s aborted, unknown requested action "%s" in scenario "%s"',
uc $request->{action},
$that,
$sender,
$action,
$scenario
);
my $error = sprintf 'Unknown requested action in scenario: %s',
$request->{action};
Sympa::send_notify_to_listmaster(
$request->{context},
'mail_intern_error',
{ error => $error,
who => $sender,
action => 'Command process',
}
);
$self->add_stash($request, 'intern');
return undef;
}
# Checks the authentication and return method
......
......@@ -74,23 +74,18 @@ sub _error {
my $self = shift;
my $request = shift;
my $robot =
(ref $request->{context} eq 'Sympa::List')
? $request->{context}->{'domain'}
: ($request->{context} || '*');
my $entry = $request->{error};
if ($entry eq 'syntax_error') {
$self->add_stash($request, 'user', 'error_syntax');
if ($entry eq 'syntax_errors') {
$self->add_stash($request, 'user', 'syntax_errors');
$log->syslog('notice', 'Command syntax error');
} elsif ($entry eq 'unknown_list') {
$self->add_stash($request, 'user', 'no_existing_list',
{'listname' => $request->{localpart}});
$self->add_stash($request, 'user', 'unknown_list');
$log->syslog(
'info',
'%s from %s refused, unknown list for robot %s',
uc $request->{action},
$request->{sender}, $robot
$request->{sender}, $request->{context}
);
} else {
Sympa::send_notify_to_listmaster(
......@@ -114,7 +109,7 @@ sub unknown {
my $request = shift;
$log->syslog('notice', 'Unknown command found: %s', $request->{cmd_line});
$self->add_stash($request, 'user', 'not_understood');
$self->add_stash($request, 'user', 'unknown_action');
return undef;
}
......@@ -275,8 +270,14 @@ sub stats {
my $request = shift;
unless (ref $request->{context} eq 'Sympa::List') {
$request->{error} = 'unknown_list';
return _error($self, $request);
$self->add_stash($request, 'user', 'unknown_list');
$log->syslog(
'info',
'%s from %s refused, unknown list for robot %s',
uc $request->{action},
$request->{sender}, $request->{context}
);
return 1;
}
my $list = $request->{context};
my $listname = $list->{'name'};
......@@ -328,8 +329,14 @@ sub get {
my $request = shift;
unless (ref $request->{context} eq 'Sympa::List') {
$request->{error} = 'unknown_list';
return _error($self, $request);
$self->add_stash($request, 'user', 'unknown_list');
$log->syslog(
'info',
'%s from %s refused, unknown list for robot %s',
uc $request->{action},
$request->{sender}, $request->{context}
);
return 1;
}
my $list = $request->{context};
my $which = $list->{'name'};
......@@ -427,8 +434,14 @@ sub last {
my $request = shift;
unless (ref $request->{context} eq 'Sympa::List') {
$request->{error} = 'unknown_list';
return _error($self, $request);
$self->add_stash($request, 'user', 'unknown_list');
$log->syslog(
'info',
'%s from %s refused, unknown list for robot %s',
uc $request->{action},
$request->{sender}, $request->{context}
);
return 1;
}
my $list = $request->{context};
my $which = $list->{'name'};
......@@ -520,8 +533,14 @@ sub index {
my $request = shift;
unless (ref $request->{context} eq 'Sympa::List') {
$request->{error} = 'unknown_list';
return _error($self, $request);
$self->add_stash($request, 'user', 'unknown_list');
$log->syslog(
'info',
'%s from %s refused, unknown list for robot %s',
uc $request->{action},
$request->{sender}, $request->{context}
);
return 1;
}
my $list = $request->{context};
my $which = $list->{'name'};
......@@ -589,8 +608,14 @@ sub review {
my $request = shift;
unless (ref $request->{context} eq 'Sympa::List') {
$request->{error} = 'unknown_list';
return _error($self, $request);
$self->add_stash($request, 'user', 'unknown_list');
$log->syslog(
'info',
'%s from %s refused, unknown list for robot %s',
uc $request->{action},
$request->{sender}, $request->{context}
);
return 1;
}
my $list = $request->{context};
my $listname = $list->{'name'};
......@@ -659,8 +684,14 @@ sub verify {
my $request = shift;
unless (ref $request->{context} eq 'Sympa::List') {
$request->{error} = 'unknown_list';
return _error($self, $request);
$self->add_stash($request, 'user', 'unknown_list');
$log->syslog(
'info',
'%s from %s refused, unknown list for robot %s',
uc $request->{action},
$request->{sender}, $request->{context}
);
return 1;
}
my $list = $request->{context};
my $listname = $list->{'name'};
......@@ -707,8 +738,14 @@ sub subscribe {
my $request = shift;
unless (ref $request->{context} eq 'Sympa::List') {
$request->{error} = 'unknown_list';
return _error($self, $request);
$self->add_stash($request, 'user', 'unknown_list');
$log->syslog(
'info',
'%s from %s refused, unknown list for robot %s',
uc $request->{action},
$request->{sender}, $request->{context}
);
return 1;
}
my $list = $request->{context};
my $which = $list->{'name'};
......@@ -827,8 +864,14 @@ sub info {
my $request = shift;
unless (ref $request->{context} eq 'Sympa::List') {
$request->{error} = 'unknown_list';
return _error($self, $request);
$self->add_stash($request, 'user', 'unknown_list');
$log->syslog(
'info',
'%s from %s refused, unknown list for robot %s',
uc $request->{action},
$request->{sender}, $request->{context}
);
return 1;
}
my $list = $request->{context};
my $listname = $list->{'name'};
......@@ -959,8 +1002,14 @@ sub signoff {
my $email = $request->{email};
unless (ref $request->{context} eq 'Sympa::List') {
$request->{error} = 'unknown_list';
return _error($self, $request);
$self->add_stash($request, 'user', 'unknown_list');
$log->syslog(
'info',
'%s from %s refused, unknown list for robot %s',
uc $request->{action},
$request->{sender}, $request->{context}
);
return 1;
}
my $list = $request->{context};
my $which = $list->{'name'};
......@@ -972,10 +1021,13 @@ sub signoff {
# command.
my $user_entry = $list->get_list_member($email);
unless (defined $user_entry) {
$self->add_stash($request, 'user', 'your_email_not_found',
{'email' => $email});
$log->syslog('info', 'SIG %s from %s refused, not on list',
$which, $email);
unless ($email eq $sender) { # Request from other user?
$self->add_stash($request, 'user', 'user_not_subscriber');
} else {
$self->add_stash($request, 'user', 'not_subscriber');
}
$log->syslog('info', 'SIG %s from %s refused, %s not on list',
$which, $sender, $email);
# Tell the owner somebody tried to unsubscribe.
if ($request->{notify}) {
......@@ -1061,8 +1113,14 @@ sub add {
my $request = shift;
unless (ref $request->{context} eq 'Sympa::List') {
$request->{error} = 'unknown_list';
return _error($self, $request);
$self->add_stash($request, 'user', 'unknown_list');
$log->syslog(
'info',
'%s from %s refused, unknown list for robot %s',
uc $request->{action},
$request->{sender}, $request->{context}
);
return 1;
}
my $list = $request->{context};
my $which = $list->{'name'};
......@@ -1184,8 +1242,14 @@ sub invite {
my $request = shift;
unless (ref $request->{context} eq 'Sympa::List') {
$request->{error} = 'unknown_list';
return _error($self, $request);
$self->add_stash($request, 'user', 'unknown_list');
$log->syslog(
'info',
'%s from %s refused, unknown list for robot %s',
uc $request->{action},
$request->{sender}, $request->{context}
);
return 1;
}
my $list = $request->{context};
my $which = $list->{'name'};
......@@ -1442,8 +1506,14 @@ sub remind {
my $sender = $request->{sender};
unless (ref $request->{context} eq 'Sympa::List') {
$request->{error} = 'unknown_list';
return _error($self, $request);
$self->add_stash($request, 'user', 'unknown_list');
$log->syslog(
'info',
'%s from %s refused, unknown list for robot %s',
uc $request->{action},
$request->{sender}, $request->{context}
);
return 1;
}
my $list = $request->{context};
my $listname = $list->{'name'};
......@@ -1509,8 +1579,14 @@ sub del {
my $request = shift;
unless (ref $request->{context} eq 'Sympa::List') {
$request->{error} = 'unknown_list';
return _error($self, $request);
$self->add_stash($request, 'user', 'unknown_list');
$log->syslog(
'info',
'%s from %s refused, unknown list for robot %s',
uc $request->{action},
$request->{sender}, $request->{context}
);
return 1;
}
my $list = $request->{context};
my $which = $list->{'name'};
......@@ -1524,9 +1600,8 @@ sub del {
# just reject the message.
my $user_entry = $list->get_list_member($who);
unless ((defined $user_entry)) {
$self->add_stash($request, 'user', 'your_email_not_found',
{'email' => $who});
unless (defined $user_entry) {
$self->add_stash($request, 'user', 'user_not_subscriber');
$log->syslog('info', 'DEL %s %s from %s refused, not on list',
$which, $who, $sender);
return 'not_allowed';
......@@ -1618,7 +1693,6 @@ sub global_set {
my $request = shift;
my $sender = $request->{sender};
my $mode = $request->{mode};
my $auth_method =
$request->{smime_signed} ? 'smime'
......@@ -1672,96 +1746,77 @@ sub set {
my $self = shift;
my $request = shift;
my $sender = $request->{sender};
my $mode = $request->{mode};
my $sender = $request->{sender};
my $email = $request->{email};
my $reception = $request->{reception};
my $visibility = $request->{visibility};
unless (ref $request->{context} eq 'Sympa::List') {
$request->{error} = 'unknown_list';
return _error($self, $request);
$self->add_stash($request, 'user', 'unknown_list');
$log->syslog(
'info',
'%s from %s refused, unknown list for robot %s',
uc $request->{action},
$request->{sender}, $request->{context}
);
return 1;
}
my $list = $request->{context};
my $which = $list->{'name'};
$language->set_lang($list->{'admin'}{'lang'});
## Check if we know this email on the list and remove it. Otherwise
## just reject the message.
unless ($list->is_list_member($sender)) {
$self->add_stash($request, 'user', 'email_not_found',
{'email' => $sender});
$log->syslog('info', 'SET %s %s from %s refused, not on list',
$which, $mode, $sender);
# Check if we know this email on the list and remove it. Otherwise
# just reject the message.
unless ($list->is_list_member($email)) {
unless ($email eq $sender) { # Request from owner?
$self->add_stash($request, 'user', 'user_not_subscriber');
} else {
$self->add_stash($request, 'user', 'not_subscriber');
}
$log->syslog('info', 'SET %s %s%s from %s refused, %s not on list',
$which, $reception, $visibility, $sender, $email);
return 'not allowed';
}
## May set to DIGEST
if ($mode =~ /^(digest|digestplain|summary)/ and !$list->is_digest()) {
# May set to DIGEST.
if ( $reception
and grep { $reception eq $_ } qw(digest digestplain summary)
and not $list->is_digest) {
$self->add_stash($request, 'user', 'no_digest');
$log->syslog('info', 'SET %s DIGEST from %s refused, no digest mode',
$which, $sender);
$log->syslog('info', 'SET %s %s from %s refused, no digest mode',
$which, $reception, $sender);
return 'not_allowed';
}
if ($mode =~
/^(mail|nomail|digest|digestplain|summary|notice|txt|html|urlize|not_me)/
) {
# Verify that the mode is allowed
if (!$list->is_available_reception_mode($mode)) {
$self->add_stash(
$request, 'user',
'available_reception_mode',
{ 'modes' => join(' ', $list->available_reception_mode()),
'reception_modes' => [$list->available_reception_mode()]
}
);
$log->syslog('info',
'SET %s %s from %s refused, mode not available',
$which, $mode, $sender);
return 'not_allowed';
}
my $update_mode = $mode;
$update_mode = '' if $update_mode eq 'mail';
unless (
$list->update_list_member(
$sender,
reception => $update_mode,
update_date => time
)
) {
my $error =
"Failed to change subscriber '$sender' options for list $which";
Sympa::send_notify_to_listmaster(
$list,
'mail_intern_error',
{ error => $error,
who => $sender,
action => 'Command process',
}
);
$self->add_stash($request, 'intern');
$log->syslog('info', 'SET %s %s from %s refused, update failed',
$which, $mode, $sender);
return 'failed';
}
$self->add_stash($request, 'notice', 'config_updated');
$log->syslog('info', 'SET %s %s from %s accepted (%.2f seconds)',
$which, $mode, $sender,
Time::HiRes::time() - $self->{start_time});
# Verify that the mode is allowed.