Commit a1cf5458 authored by IKEDA Soji's avatar IKEDA Soji
Browse files

Corrections on the last commit

parent 51cde006
...@@ -66,49 +66,42 @@ sub _twist { ...@@ -66,49 +66,42 @@ sub _twist {
die 'bug in logic. Ask developer' die 'bug in logic. Ask developer'
unless grep { $role eq $_ } qw(member owner editor); unless grep { $role eq $_ } qw(member owner editor);
unless ($request->{force} or $list->is_subscription_allowed) {
$log->syslog('info', 'List %s not open', $list);
$self->add_stash($request, 'user', 'list_not_open',
{'status' => $list->{'admin'}{'status'}});
return undef;
}
$language->set_lang($list->{'admin'}{'lang'}); $language->set_lang($list->{'admin'}{'lang'});
unless (Sympa::Tools::Text::valid_email($email)) { unless (Sympa::Tools::Text::valid_email($email)) {
$self->add_stash($request, 'user', 'incorrect_email', $self->add_stash($request, 'user', 'incorrect_email',
{'email' => $email}); {'email' => $email});
$log->syslog('err', $log->syslog('err',
'ADD command rejected; incorrect email "%s"', $email); 'request "add" rejected; incorrect email "%s"', $email);
return undef;
}
if (Sympa::Tools::Domains::is_blocklisted($email)) {
$self->add_stash($request, 'user', 'blocklisted_domain',
{'email' => $email});
$log->syslog('err',
'ADD command rejected; blocklisted domain for "%s"', $email);
return undef;
}
if ($list->is_list_member($email)) {
$self->add_stash($request, 'user', 'already_subscriber',
{'email' => $email, 'listname' => $list->{'name'}});
$log->syslog('err',
'ADD command rejected; user "%s" already member of list "%s"',
$email, $which);
return undef; return undef;
} }
my @stash; my @stash;
if ($role eq 'member') { if ($role eq 'member') {
unless ($request->{force} or $list->is_subscription_allowed) {
$log->syslog('info', 'List %s not open', $list);
$self->add_stash($request, 'user', 'list_not_open',
{'status' => $list->{'admin'}{'status'}});
return undef;
}
if (Sympa::Tools::Domains::is_blocklisted($email)) {
$self->add_stash($request, 'user', 'blocklisted_domain',
{'email' => $email});
$log->syslog('err',
'request "add" rejected; blocklisted domain for "%s"',
$email);
return undef;
}
$list->add_list_member( $list->add_list_member(
{email => $email, gecos => $comment, custom_attribute => $ca}, {email => $email, gecos => $comment, custom_attribute => $ca},
stash => \@stash); stash => \@stash);
} else { } else {
$list->add_list_admin($role, $list->add_list_admin(
$role,
{email => $email, gecos => $comment}, {email => $email, gecos => $comment},
stash => \@stash); stash => \@stash
);
} }
foreach my $report (@stash) { foreach my $report (@stash) {
$self->add_stash($request, @$report); $self->add_stash($request, @$report);
...@@ -125,6 +118,8 @@ sub _twist { ...@@ -125,6 +118,8 @@ sub _twist {
} }
return undef if grep { $_->[0] eq 'user' or $_->[0] eq 'intern' } @stash; return undef if grep { $_->[0] eq 'user' or $_->[0] eq 'intern' } @stash;
return 1 unless $role eq 'member'; #FIXME: Send report?
$self->add_stash($request, 'notice', 'now_subscriber', $self->add_stash($request, 'notice', 'now_subscriber',
{'email' => $email, listname => $list->{'name'}}); {'email' => $email, listname => $list->{'name'}});
......
...@@ -83,21 +83,6 @@ sub _twist { ...@@ -83,21 +83,6 @@ sub _twist {
return undef; return undef;
} }
# Unless rejected by scenario, don't go further if the user is subscribed
# already.
my $user_entry = $list->get_list_member($email);
if (defined $user_entry) {
$self->add_stash($request, 'user', 'already_subscriber',
{'email' => $email, 'listname' => $list->{'name'}});
$log->syslog(
'err',
'User %s is subscribed to %s already. Ignoring subscription request',
$email,
$list
);
return undef;
}
# If a list is not 'open' and allow_subscribe_if_pending has been set to # If a list is not 'open' and allow_subscribe_if_pending has been set to
# 'off' returns undef. # 'off' returns undef.
unless ($list->{'admin'}{'status'} eq 'open' unless ($list->{'admin'}{'status'} eq 'open'
......
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