diff options
author | Byron Jones <glob@mozilla.com> | 2014-11-04 06:38:46 +0100 |
---|---|---|
committer | Byron Jones <glob@mozilla.com> | 2014-11-04 06:38:46 +0100 |
commit | 7dc675fedb5b2631a8bafd0fb691eac485eff0af (patch) | |
tree | 548488280f00fc5e03ef841a2f997fa3fbb1ff73 /Bugzilla/Job | |
parent | 300d1ba13e050aa1e954dde640092c448184cbba (diff) | |
download | bugzilla-7dc675fedb5b2631a8bafd0fb691eac485eff0af.tar.gz bugzilla-7dc675fedb5b2631a8bafd0fb691eac485eff0af.tar.xz |
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)
Diffstat (limited to 'Bugzilla/Job')
-rw-r--r-- | Bugzilla/Job/BugMail.pm | 16 | ||||
-rw-r--r-- | Bugzilla/Job/Mailer.pm | 22 |
2 files changed, 20 insertions, 18 deletions
diff --git a/Bugzilla/Job/BugMail.pm b/Bugzilla/Job/BugMail.pm index 9c176b005..403d936ad 100644 --- a/Bugzilla/Job/BugMail.pm +++ b/Bugzilla/Job/BugMail.pm @@ -13,19 +13,9 @@ use strict; use Bugzilla::BugMail; BEGIN { eval "use parent qw(Bugzilla::Job::Mailer)"; } -sub work { - my ($class, $job) = @_; - my $success = eval { - Bugzilla::BugMail::dequeue($job->arg->{vars}); - 1; - }; - if (!$success) { - $job->failed($@); - undef $@; - } - else { - $job->completed; - } +sub process_job { + my ($class, $arg) = @_; + Bugzilla::BugMail::dequeue($arg->{vars}); } 1; 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; |