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..95e144988 --- /dev/null +++ b/src/lib/Sympa/CLI/bouncers.pm @@ -0,0 +1,80 @@ +# -*- indent-tabs-mode: nil; -*- +# vim:ft=perl:et:sw=4 + +# Sympa - SYsteme de Multi-Postage Automatique +# +# Copyright 2022 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 + +=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 new file mode 100644 index 000000000..9a5ab7591 --- /dev/null +++ b/src/lib/Sympa/CLI/bouncers/del.pm @@ -0,0 +1,95 @@ +# -*- indent-tabs-mode: nil; -*- +# vim:ft=perl:et:sw=4 + +# Sympa - SYsteme de Multi-Postage Automatique +# +# Copyright 2022 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. + +=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 new file mode 100644 index 000000000..a9b25e6d3 --- /dev/null +++ b/src/lib/Sympa/CLI/bouncers/reset.pm @@ -0,0 +1,97 @@ +# -*- indent-tabs-mode: nil; -*- +# vim:ft=perl:et:sw=4 + +# Sympa - SYsteme de Multi-Postage Automatique +# +# Copyright 2022 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 + +=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 new file mode 100644 index 000000000..a0321eff5 --- /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 2022 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..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 # . # @@ -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..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