Commit 0a14343e authored by IKEDA Soji's avatar IKEDA Soji
Browse files

sympa.pl: --del can take a --role option

parent 307df4ef
......@@ -56,23 +56,28 @@ sub _twist {
my $robot = $list->{'domain'};
my $sender = $request->{sender};
my $who = $request->{email};
my $role = $request->{role} || 'member';
$language->set_lang($list->{'admin'}{'lang'});
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;
}
my @stash;
$list->delete_list_member(
[$who],
exclude => 1,
operation => 'del',
stash => \@stash
);
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;
}
$list->delete_list_member(
[$who],
exclude => 1,
operation => 'del',
stash => \@stash
);
} else {
$list->delete_list_admin($role, [$who], stash => \@stash);
}
foreach my $report (@stash) {
$self->add_stash($request, @$report);
if ($report->[0] eq 'intern') {
......@@ -88,6 +93,8 @@ sub _twist {
}
return undef if grep { $_->[0] eq 'user' or $_->[0] eq 'intern' } @stash;
return 1 unless $role eq 'member'; # FIXME: Send report?
# Only when deletion was done by request, bounce information will be
# cleared. Note that tracking information will be kept.
my $tracking = Sympa::Tracking->new(context => $list);
......
......@@ -579,6 +579,12 @@ if ($main::options{'dump'} or $main::options{'dump_users'}) {
exit 1;
}
$main::options{'role'} //= 'member';
unless (grep {$main::options{'role'} eq $_} qw(member owner editor)) {
printf STDERR "Unknown role \"%s\".\n", $main::options{'role'};
exit 1;
}
my @emails;
my $content = do { local $RS; <STDIN> };
foreach (split /\r\n|\r|\n/, $content) {
......@@ -596,6 +602,7 @@ if ($main::options{'dump'} or $main::options{'dump_users'}) {
my $spindle = Sympa::Spindle::ProcessRequest->new(
context => $list,
action => 'del',
role => $main::options{'role'},
email => [@emails],
force => 1,
quiet => $main::options{'quiet'},
......@@ -1857,7 +1864,7 @@ S<[ C<-l, --lang>=I<lang> ]> S<[ C<-m, --mail> ]>
S<[ C<-h, --help> ]> S<[ C<-v, --version> ]>
S<>
S<[ C<--add>=I<list>@I<domain> [--role=I<role>] [--quiet] [--notify] [--force] ]>
S<[ C<--del>=I<list>@I<domain> [--quiet] [--notify] [--force] ]>
S<[ C<--del>=I<list>@I<domain> [--role=I<role>] [--quiet] [--notify] [--force] ]>
S<[ C<--open_list>=I<list>[I<@robot>] [--notify] ]>
S<[ C<--close_list>=I<list>[I<@robot>] ]>
S<[ C<--purge_list>=I<list>[I<@robot>] ]>
......@@ -1919,7 +1926,7 @@ Sample:
mary.blacksmith@another.company.com Mary Blacksmith
Note:
This option was added on Sympa 6.2.67b.1.
This option was added on Sympa 6.2.67b.2.
=item C<--add_list=>I<family_name> C<--robot=>I<robot_name>
C<--input_file=>I</path/to/file.xml>
......@@ -1956,7 +1963,8 @@ C<--input_file=>I</path/to/file.xml >
Create a list with the XML file under robot robot_name.
=item C<--del=>I<list>@I<domain> [ C<--quiet> ] [ C<--notify> ] [ C<--force> ]
=item C<--del=>I<list>@I<domain> [ C<--role>=I<role> ]
[ C<--quiet> ] [ C<--notify> ] [ C<--force> ]
Delete email(s) from the list. Data are read from standard input.
The data should contain one email address per line.
......@@ -1968,7 +1976,7 @@ Sample:
mary.blacksmith@another.company.com
Note:
This options was added on Sympa 6.2.67b.1.
This options was added on Sympa 6.2.67b.2.
=item C<--dump=>I<list>@I<domain>|C<ALL>
......
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