Unverified Commit 587f94ca authored by IKEDA Soji's avatar IKEDA Soji Committed by GitHub
Browse files

Merge pull request #1098 & #1357 from ikedas/ldidry/fix-1058 by ldidry & ikedas

 — Add "bouncers reset", "bouncers del" and "bouncers [--status] review" commands to sympa.pl
parents 99598954 ffb3c769
......@@ -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 \
......
# -*- 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
# <https://github.com/sympa-community/sympa.git>.
#
# 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 <http://www.gnu.org/licenses/>.
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<sympa bouncers> I<sub-command> ...
=head1 DESCRIPTION
TBD.
=head1 SUB-COMMANDS
Currently following sub-commands are available.
To see detail of each sub-command, run 'C<sympal.pl help bouncers> I<sub-command>'.
=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
# -*- 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
# <https://github.com/sympa-community/sympa.git>.
#
# 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 <http://www.gnu.org/licenses/>.
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<sympa bouncers del> I<list>[ C<@>I<domain> ]
=head1 DESCRIPTION
Unsubscribe bounced users from a list.
=head1 HISTORY
This option was added on Sympa 6.2.69b.
=cut
# -*- 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
# <https://github.com/sympa-community/sympa.git>.
#
# 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 <http://www.gnu.org/licenses/>.
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<sympa bouncers reset> I<list>[ C<@>I<domain> ]
=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
# -*- 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
# <https://github.com/sympa-community/sympa.git>.
#
# 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 <http://www.gnu.org/licenses/>.
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<sympa review> S<[ C<--status> ]> I<list>[ C<@>I<domain> ]
=head1 DESCRIPTION
Show subscribers of the list.
=head1 HISTORY
This option was added on Sympa 6.2.69b.
=cut
......@@ -6418,6 +6418,12 @@ I<Instance method>.
Returns the number of messages sent to the list.
FIXME
=item get_first_bouncing_list_member ( )
I<Instance method>.
Get first bouncing user.
FIXME
=item get_next_bouncing_list_member ( )
I<Instance method>.
......
......@@ -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
# <https://github.com/sympa-community/sympa.git>.
#
......@@ -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)',
......
......@@ -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
# <https://github.com/sympa-community/sympa.git>.
#
......@@ -294,6 +294,10 @@ To see detail of each command, run 'C<sympa help> I<command>'.
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
......
Supports Markdown
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