summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBob Micheletto <Micheletto@users.noreply.github.com>2018-05-21 23:44:49 +0200
committerdklawren <dklawren@users.noreply.github.com>2018-05-21 23:44:49 +0200
commit8c039ca6047d0dd761e561def6618071dd955544 (patch)
tree6870b9a1b1e5dd214d7bac63676ec0b74d937df7
parentb6f1553569efeaa0682ff9247c7fc0e93552609d (diff)
downloadbugzilla-8c039ca6047d0dd761e561def6618071dd955544.tar.gz
bugzilla-8c039ca6047d0dd761e561def6618071dd955544.tar.xz
Removes branching logic for bounce types and disables e-mail for any bounce.
-rwxr-xr-xses/index.cgi67
1 files changed, 25 insertions, 42 deletions
diff --git a/ses/index.cgi b/ses/index.cgi
index 8abd98e24..e36956b1d 100755
--- a/ses/index.cgi
+++ b/ses/index.cgi
@@ -104,57 +104,40 @@ sub handle_notification {
sub process_bounce {
my ($notification) = @_;
- my $type = $notification->{bounce}->{bounceType};
- if ( $type eq 'Transient' ) {
+ # disable each account that is bouncing
+ foreach my $recipient ( @{ $notification->{bounce}->{bouncedRecipients} } ) {
+ my $address = $recipient->{emailAddress};
+ my $reason = sprintf '(%s) %s', $recipient->{action} // 'error', $recipient->{diagnosticCode} // 'unknown';
- # just log transient bounces
- foreach my $recipient ( @{ $notification->{bounce}->{bouncedRecipients} } ) {
- my $address = $recipient->{emailAddress};
- Bugzilla->audit("transient bounce for <$address>");
- }
- }
+ my $user = Bugzilla::User->new( { name => $address, cache => 1 } );
+ if ($user) {
- elsif ( $type eq 'Permanent' ) {
-
- # disable each account that is permanently bouncing
- foreach my $recipient ( @{ $notification->{bounce}->{bouncedRecipients} } ) {
- my $address = $recipient->{emailAddress};
- my $reason = sprintf '(%s) %s', $recipient->{action} // 'error', $recipient->{diagnosticCode} // 'unknown';
-
- my $user = Bugzilla::User->new( { name => $address, cache => 1 } );
- if ($user) {
-
- # never auto-disable admin accounts
- if ( $user->in_group('admin') ) {
- Bugzilla->audit("ignoring permanent bounce for admin <$address>: $reason");
- }
-
- else {
- my $template = Bugzilla->template_inner();
- my $vars = {
- mta => $notification->{bounce}->{reportingMTA} // 'unknown',
- reason => $reason,
- };
- my $disable_text;
- $template->process( 'admin/users/bounce-disabled.txt.tmpl', $vars, \$disable_text )
- || die $template->error();
-
- $user->set_disabledtext($disable_text);
- $user->set_disable_mail(1);
- $user->update();
- Bugzilla->audit( "permanent bounce for <$address> disabled userid-" . $user->id . ": $reason" );
- }
+ # never auto-disable admin accounts
+ if ( $user->in_group('admin') ) {
+ Bugzilla->audit("ignoring bounce for admin <$address>: $reason");
}
else {
- Bugzilla->audit("permanent bounce for <$address> has no user: $reason");
+ my $template = Bugzilla->template_inner();
+ my $vars = {
+ mta => $notification->{bounce}->{reportingMTA} // 'unknown',
+ reason => $reason,
+ };
+ my $disable_text;
+ $template->process( 'admin/users/bounce-disabled.txt.tmpl', $vars, \$disable_text )
+ || die $template->error();
+
+ $user->set_disabledtext($disable_text);
+ $user->set_disable_mail(1);
+ $user->update();
+ Bugzilla->audit( "bounce for <$address> disabled userid-" . $user->id . ": $reason" );
}
}
- }
- else {
- WARN("Unsupported bounce type: $type\n");
+ else {
+ Bugzilla->audit("bounce for <$address> has no user: $reason");
+ }
}
respond( 200 => 'OK' );