From 7dc675fedb5b2631a8bafd0fb691eac485eff0af Mon Sep 17 00:00:00 2001 From: Byron Jones Date: Tue, 4 Nov 2014 13:38:46 +0800 Subject: Bug 1092037: backport bug 1062739 to bmo (add the ability for administrators to limit the number of emails sent to a user per minute and hour) --- Bugzilla/Job/Mailer.pm | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'Bugzilla/Job/Mailer.pm') diff --git a/Bugzilla/Job/Mailer.pm b/Bugzilla/Job/Mailer.pm index 09c387326..e3b94894a 100644 --- a/Bugzilla/Job/Mailer.pm +++ b/Bugzilla/Job/Mailer.pm @@ -22,6 +22,9 @@ package Bugzilla::Job::Mailer; use strict; +use warnings; + +use Bugzilla::Constants; use Bugzilla::Mailer; BEGIN { eval "use base qw(TheSchwartz::Worker)"; } @@ -43,15 +46,24 @@ sub retry_delay { sub work { my ($class, $job) = @_; - my $msg = $job->arg->{msg}; - my $success = eval { MessageToMTA($msg, 1); 1; }; - if (!$success) { - $job->failed($@); + eval { $class->process_job($job->arg) }; + if (my $error = $@) { + if ($error eq EMAIL_LIMIT_EXCEPTION) { + $job->declined(); + } + else { + $job->failed($error); + } undef $@; - } + } else { $job->completed; } } +sub process_job { + my ($class, $arg) = @_; + MessageToMTA($arg, 1); +} + 1; -- cgit v1.2.3-24-g4f1b