From 1c569753881b1478a84fce06b7f7d716b22258e9 Mon Sep 17 00:00:00 2001 From: Luc Didry Date: Tue, 26 Jan 2021 15:22:06 +0100 Subject: [PATCH 1/2] =?UTF-8?q?=E2=9C=A8=20=E2=80=94=20Add=20`review`,=20`?= =?UTF-8?q?bouncers=20del`=20and=20`bouncers=20reset`=20to=20sympa=20CLI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix #1058 and #1102 --- src/lib/Makefile.am | 4 ++ src/lib/Sympa/CLI/bouncers.pm | 76 ++++++++++++++++++++ src/lib/Sympa/CLI/bouncers/del.pm | 91 +++++++++++++++++++++++ src/lib/Sympa/CLI/bouncers/reset.pm | 93 ++++++++++++++++++++++++ src/lib/Sympa/CLI/review.pm | 104 +++++++++++++++++++++++++++ src/lib/Sympa/List.pm | 6 ++ src/lib/Sympa/Request/Handler/del.pm | 3 +- src/sbin/sympa.pl.in | 15 ++++ 8 files changed, 391 insertions(+), 1 deletion(-) create mode 100644 src/lib/Sympa/CLI/bouncers.pm create mode 100644 src/lib/Sympa/CLI/bouncers/del.pm create mode 100644 src/lib/Sympa/CLI/bouncers/reset.pm create mode 100644 src/lib/Sympa/CLI/review.pm diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am index ce689ce2f..4107c97d2 100644 --- a/src/lib/Makefile.am +++ b/src/lib/Makefile.am @@ -30,6 +30,9 @@ nobase_dist_modules_DATA = \ Sympa/Internals/Workflow.pod CLI_modules = \ Sympa/CLI/add.pm \ + Sympa/CLI/bouncers.pm \ + Sympa/CLI/bouncers/del.pm \ + Sympa/CLI/bouncers/reset.pm \ Sympa/CLI/check.pm \ Sympa/CLI/close.pm \ Sympa/CLI/conf_2_db.pm \ @@ -49,6 +52,7 @@ CLI_modules = \ Sympa/CLI/rebuildarc.pm \ Sympa/CLI/reload_list_config.pm \ Sympa/CLI/restore.pm \ + Sympa/CLI/review.pm \ Sympa/CLI/send_digest.pm \ Sympa/CLI/show_pending_lists.pm \ Sympa/CLI/sync_list_db.pm \ diff --git a/src/lib/Sympa/CLI/bouncers.pm b/src/lib/Sympa/CLI/bouncers.pm new file mode 100644 index 000000000..b40d6d375 --- /dev/null +++ b/src/lib/Sympa/CLI/bouncers.pm @@ -0,0 +1,76 @@ +# -*- indent-tabs-mode: nil; -*- +# vim:ft=perl:et:sw=4 + +# Sympa - SYsteme de Multi-Postage Automatique +# +# Copyright 2021 The Sympa Community. See the +# AUTHORS.md file at the top-level directory of this distribution and at +# . +# +# 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 . + +package Sympa::CLI::bouncers; + +use strict; +use warnings; + +use parent qw(Sympa::CLI); + +use constant _options => qw(); +use constant _args => qw(); +use constant _need_priv => 0; + +sub _run { + my $class = shift; + my $options = shift; + my @argv = @_; + + Sympa::CLI->run(qw(help bouncers)); +} + +1; +__END__ + +=encoding utf-8 + +=head1 NAME + +sympa-bouncers - Manipulate list bounced users + +=head1 SYNOPSIS + +C I ... + +=head1 DESCRIPTION + +TBD. + +=head1 SUB-COMMANDS + +Currently following sub-commands are available. +To see detail of each sub-command, run 'C I'. + +=over + +=item L<"sympa bouncers del ..."|sympa-bouncers-del(1)> + +Unsubscribe bounced users from a list + +=item L<"sympa bouncers reset ..."|sympa-bouncers-reset(1)> + +Reset the bounce status of all bounced users of a list + +=back + +=cut diff --git a/src/lib/Sympa/CLI/bouncers/del.pm b/src/lib/Sympa/CLI/bouncers/del.pm new file mode 100644 index 000000000..ce46a9ddc --- /dev/null +++ b/src/lib/Sympa/CLI/bouncers/del.pm @@ -0,0 +1,91 @@ +# -*- indent-tabs-mode: nil; -*- +# vim:ft=perl:et:sw=4 + +# Sympa - SYsteme de Multi-Postage Automatique +# +# Copyright 2021 The Sympa Community. See the +# AUTHORS.md file at the top-level directory of this distribution and at +# . +# +# 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 . + +package Sympa::CLI::bouncers::del; + +use strict; +use warnings; + +use Sympa; +use Sympa::List; +use Sympa::Spindle::ProcessRequest; + +use parent qw(Sympa::CLI::bouncers); + +use constant _options => qw(); +use constant _args => qw(list); +use constant _need_priv => 1; + +sub _run { + my $class = shift; + my $options = shift; + my $list = shift; + + my @bounced; + for ( + my $i = $list->get_first_bouncing_list_member(); + $i; + $i = $list->get_next_bouncing_list_member() + ) { + push @bounced, $i->{email}; + } + + unless (scalar @bounced) { + printf STDERR "No bounced users in list %s.\n", $list->get_id; + exit 1; + } + + my $spindle = Sympa::Spindle::ProcessRequest->new( + context => $list, + action => 'del', + role => 'member', + email => [@bounced], + sender => Sympa::get_address($list, 'listmaster'), + scenario_context => {skip => 1}, + ); + unless ($spindle and $spindle->spin and $class->_report($spindle)) { + printf STDERR "Failed to delete email addresses from %s.\n", + $list->get_id; + exit 1; + } + + exit 0; +} + +1; +__END__ + +=encoding utf-8 + +=head1 NAME + +sympa-bouncers-del - Unsubscribe bounced users from a list + +=head1 SYNOPSIS + +C I[ C<@>I ] + +=head1 DESCRIPTION + +Unsubscribe bounced users from a list. + +=cut diff --git a/src/lib/Sympa/CLI/bouncers/reset.pm b/src/lib/Sympa/CLI/bouncers/reset.pm new file mode 100644 index 000000000..3499fc02f --- /dev/null +++ b/src/lib/Sympa/CLI/bouncers/reset.pm @@ -0,0 +1,93 @@ +# -*- indent-tabs-mode: nil; -*- +# vim:ft=perl:et:sw=4 + +# Sympa - SYsteme de Multi-Postage Automatique +# +# Copyright 2021 The Sympa Community. See the +# AUTHORS.md file at the top-level directory of this distribution and at +# . +# +# 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 . + +package Sympa::CLI::bouncers::reset; + +use strict; +use warnings; + +use Sympa; +use Sympa::List; +use Sympa::Spindle::ProcessRequest; + +use parent qw(Sympa::CLI::bouncers); + +use constant _options => qw(); +use constant _args => qw(list); +use constant _need_priv => 1; + +sub _run { + my $class = shift; + my $options = shift; + my $list = shift; + + my ($errors, $users) = (0, 0); + for ( + my $i = $list->get_first_bouncing_list_member(); + $i; + $i = $list->get_next_bouncing_list_member() + ) { + if ($list->update_list_member( + $i->{email}, + bounce => undef, + update_date => time, + bounce_score => 0 + ) + ) { + $users++; + } else { + printf STDERR "Unable to cancel bounce error for %s.\n", $i->{email}; + } + $errors++; + } + + if ($errors) { + my $text = + ($users > 1) + ? "Canceled %i bounce errors on %i.\n" + : "Canceled %i bounce error on %i.\n"; + printf $text, $users, $errors; + } else { + print "No bounce errors to cancel.\n"; + } + + exit 0; +} + +1; +__END__ + +=encoding utf-8 + +=head1 NAME + +sympa-bouncers-reset - Reset the bounce status of all bounced users of a list + +=head1 SYNOPSIS + +C I[ C<@>I ] + +=head1 DESCRIPTION + +Reset the bounce status of all bounced users of a list + +=cut diff --git a/src/lib/Sympa/CLI/review.pm b/src/lib/Sympa/CLI/review.pm new file mode 100644 index 000000000..3d5c49ef3 --- /dev/null +++ b/src/lib/Sympa/CLI/review.pm @@ -0,0 +1,104 @@ +# -*- indent-tabs-mode: nil; -*- +# vim:ft=perl:et:sw=4 + +# Sympa - SYsteme de Multi-Postage Automatique +# +# Copyright 2021 The Sympa Community. See the +# AUTHORS.md file at the top-level directory of this distribution and at +# . +# +# 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 . + +package Sympa::CLI::review; + +use strict; +use warnings; +use English qw(-no_match_vars); + +use Sympa; +use Sympa::List; + +use parent qw(Sympa::CLI); + +use constant _options => qw(status); +use constant _args => qw(list); + +sub _run { + my $class = shift; + my $options = shift; + my $list = shift; + + if ($list) { + my @members = $list->get_members( + 'unconcealed_member', + order => 'email' + ); + my @bounced = (); + my @suspended = (); + + printf "%i member(s) in list %s.\n", + scalar(@members), $list->get_id; + for my $member (@members) { + printf "%s\n", $member->{email}; + push @bounced, $member->{'email'} + if defined $member->{'bounce'}; + push @suspended, $member->{'email'} + if defined $member->{'suspend'}; + } + + if ($options->{'status'}) { + print "------------------\n"; + + printf "%i bounced member(s) in list %s.\n", + scalar(@bounced), $list->get_id; + for my $member (@bounced) { + printf "%s\n", $member; + } + + printf "%i suspended member(s) in list %s.\n", + scalar(@suspended), $list->get_id; + for my $member (@suspended) { + printf "%s\n", $member; + } + } + + exit 0; + } else { + printf STDERR "Error : please provide the name of a list\n"; + exit 1; + } +} + +1; +__END__ + +=encoding utf-8 + +=head1 NAME + +sympa-review - Show subscribers of the list. + +=head1 SYNOPSIS + +C S<[ C<--status> ]> I[ C<@>I ] + +=head1 DESCRIPTION + +Show subscribers of the list. + +=head1 HISTORY + +This option was added on Sympa 6.2.69b. + +=cut diff --git a/src/lib/Sympa/List.pm b/src/lib/Sympa/List.pm index 8af2106a7..3149c49a7 100644 --- a/src/lib/Sympa/List.pm +++ b/src/lib/Sympa/List.pm @@ -6418,6 +6418,12 @@ I. Returns the number of messages sent to the list. FIXME +=item get_first_bouncing_list_member ( ) + +I. +Get first bouncing user. +FIXME + =item get_next_bouncing_list_member ( ) I. diff --git a/src/lib/Sympa/Request/Handler/del.pm b/src/lib/Sympa/Request/Handler/del.pm index e85e720cb..89ce44e29 100644 --- a/src/lib/Sympa/Request/Handler/del.pm +++ b/src/lib/Sympa/Request/Handler/del.pm @@ -126,7 +126,8 @@ sub _report_member { $who); } } - $self->add_stash($request, 'notice', 'removed', {'email' => $who}); + $self->add_stash($request, 'notice', 'removed', + {'email' => $who, 'listname' => $list->get_id}); $log->syslog( 'info', 'DEL %s %s from %s accepted (%.2f seconds, %d subscribers)', diff --git a/src/sbin/sympa.pl.in b/src/sbin/sympa.pl.in index e9295229c..0cb700ee2 100644 --- a/src/sbin/sympa.pl.in +++ b/src/sbin/sympa.pl.in @@ -426,6 +426,9 @@ S<[ C<--dump_users> C<--list>=I@I|ALL [ C<--role>=I ] ]> S<[ C<--restore_users> C<--list>=I@I|ALL [ C<--role>=I ] ]> S<[ C<--show_pending_lists>=I ]> S<[ C<--rebuildarc>=I[I<@robot>] ]> +S<[ C [C<--status>] I[I<@robot>] ]> +S<[ C C I[I<@robot>] ]> +S<[ C C I[I<@robot>] ]> =head2 Options @@ -754,6 +757,18 @@ New command line format: TBD. +=item C [C<--status>] I[I<@robot>] + +Show the subscribers of the list. + +=item C C I[I<@robot>] + +Cancel the errors of the subscribers of the list. + +=item C C I[I<@robot>] + +Unsubscribe the users of the list who are in error status + =item C<--reload_list_config> [ C<--list=>I@I ] [ C<--robot=>I ] From ffb3c769d150f529464dce37d9987a34c613404c Mon Sep 17 00:00:00 2001 From: IKEDA Soji Date: Sat, 5 Mar 2022 18:38:31 +0900 Subject: [PATCH 2/2] Update copyright years. Small fixes on the documentation. --- src/lib/Sympa/CLI/bouncers.pm | 6 +++++- src/lib/Sympa/CLI/bouncers/del.pm | 6 +++++- src/lib/Sympa/CLI/bouncers/reset.pm | 6 +++++- src/lib/Sympa/CLI/review.pm | 2 +- src/lib/Sympa/Request/Handler/del.pm | 2 +- src/sbin/sympa.pl.in | 25 +++++++++---------------- 6 files changed, 26 insertions(+), 21 deletions(-) diff --git a/src/lib/Sympa/CLI/bouncers.pm b/src/lib/Sympa/CLI/bouncers.pm index b40d6d375..95e144988 100644 --- a/src/lib/Sympa/CLI/bouncers.pm +++ b/src/lib/Sympa/CLI/bouncers.pm @@ -3,7 +3,7 @@ # Sympa - SYsteme de Multi-Postage Automatique # -# Copyright 2021 The Sympa Community. See the +# Copyright 2022 The Sympa Community. See the # AUTHORS.md file at the top-level directory of this distribution and at # . # @@ -73,4 +73,8 @@ Reset the bounce status of all bounced users of a list =back +=head1 HISTORY + +This option was added on Sympa 6.2.69b. + =cut diff --git a/src/lib/Sympa/CLI/bouncers/del.pm b/src/lib/Sympa/CLI/bouncers/del.pm index ce46a9ddc..9a5ab7591 100644 --- a/src/lib/Sympa/CLI/bouncers/del.pm +++ b/src/lib/Sympa/CLI/bouncers/del.pm @@ -3,7 +3,7 @@ # Sympa - SYsteme de Multi-Postage Automatique # -# Copyright 2021 The Sympa Community. See the +# Copyright 2022 The Sympa Community. See the # AUTHORS.md file at the top-level directory of this distribution and at # . # @@ -88,4 +88,8 @@ C I[ C<@>I ] Unsubscribe bounced users from a list. +=head1 HISTORY + +This option was added on Sympa 6.2.69b. + =cut diff --git a/src/lib/Sympa/CLI/bouncers/reset.pm b/src/lib/Sympa/CLI/bouncers/reset.pm index 3499fc02f..a9b25e6d3 100644 --- a/src/lib/Sympa/CLI/bouncers/reset.pm +++ b/src/lib/Sympa/CLI/bouncers/reset.pm @@ -3,7 +3,7 @@ # Sympa - SYsteme de Multi-Postage Automatique # -# Copyright 2021 The Sympa Community. See the +# Copyright 2022 The Sympa Community. See the # AUTHORS.md file at the top-level directory of this distribution and at # . # @@ -90,4 +90,8 @@ C I[ C<@>I ] Reset the bounce status of all bounced users of a list +=head1 HISTORY + +This option was added on Sympa 6.2.69b. + =cut diff --git a/src/lib/Sympa/CLI/review.pm b/src/lib/Sympa/CLI/review.pm index 3d5c49ef3..a0321eff5 100644 --- a/src/lib/Sympa/CLI/review.pm +++ b/src/lib/Sympa/CLI/review.pm @@ -3,7 +3,7 @@ # Sympa - SYsteme de Multi-Postage Automatique # -# Copyright 2021 The Sympa Community. See the +# Copyright 2022 The Sympa Community. See the # AUTHORS.md file at the top-level directory of this distribution and at # . # diff --git a/src/lib/Sympa/Request/Handler/del.pm b/src/lib/Sympa/Request/Handler/del.pm index 89ce44e29..d509230ad 100644 --- a/src/lib/Sympa/Request/Handler/del.pm +++ b/src/lib/Sympa/Request/Handler/del.pm @@ -8,7 +8,7 @@ # 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, 2017 GIP RENATER -# Copyright 2017, 2021 The Sympa Community. See the +# Copyright 2017, 2021, 2022 The Sympa Community. See the # AUTHORS.md file at the top-level directory of this distribution and at # . # diff --git a/src/sbin/sympa.pl.in b/src/sbin/sympa.pl.in index 0cb700ee2..d41f8afca 100644 --- a/src/sbin/sympa.pl.in +++ b/src/sbin/sympa.pl.in @@ -9,7 +9,7 @@ # 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, 2017 GIP RENATER -# Copyright 2017, 2018, 2019, 2020, 2021 The Sympa Community. See the +# Copyright 2017, 2018, 2019, 2020, 2021, 2022 The Sympa Community. See the # AUTHORS.md file at the top-level directory of this distribution and at # . # @@ -294,6 +294,10 @@ To see detail of each command, run 'C I'. Add users to the list +=item L<"sympa bouncers"|sympa-bouncers(1)> + +Manipulate list bounced users + =item L<"sympa check"|sympa-check(1)> Check environment @@ -370,6 +374,10 @@ Recreate config cache of the lists Restore users of the lists +=item L<"sympa review"|sympa-review(1)> + +Show subscribers of the list + =item L<"sympa send_digest"|sympa-send_digest(1)> Send digest @@ -426,9 +434,6 @@ S<[ C<--dump_users> C<--list>=I@I|ALL [ C<--role>=I ] ]> S<[ C<--restore_users> C<--list>=I@I|ALL [ C<--role>=I ] ]> S<[ C<--show_pending_lists>=I ]> S<[ C<--rebuildarc>=I[I<@robot>] ]> -S<[ C [C<--status>] I[I<@robot>] ]> -S<[ C C I[I<@robot>] ]> -S<[ C C I[I<@robot>] ]> =head2 Options @@ -757,18 +762,6 @@ New command line format: TBD. -=item C [C<--status>] I[I<@robot>] - -Show the subscribers of the list. - -=item C C I[I<@robot>] - -Cancel the errors of the subscribers of the list. - -=item C C I[I<@robot>] - -Unsubscribe the users of the list who are in error status - =item C<--reload_list_config> [ C<--list=>I@I ] [ C<--robot=>I ]