summaryrefslogtreecommitdiffstats
path: root/Bugzilla/Job
diff options
context:
space:
mode:
authorByron Jones <glob@mozilla.com>2014-10-31 08:20:42 +0100
committerByron Jones <glob@mozilla.com>2014-10-31 08:20:42 +0100
commit908480c98aa48a9d1caf09ee00f3cfe0863afec2 (patch)
treea15dc741c3fe821865291a0789fda1607d2a67a4 /Bugzilla/Job
parentf1fda7c8b9cf4646374cc708c14942e5feed82d1 (diff)
downloadbugzilla-908480c98aa48a9d1caf09ee00f3cfe0863afec2.tar.gz
bugzilla-908480c98aa48a9d1caf09ee00f3cfe0863afec2.tar.xz
Bug 1062739: add the ability for administrators to limit the number of emails sent to a user per minute and hour
r=dylan,a=glob
Diffstat (limited to 'Bugzilla/Job')
-rw-r--r--Bugzilla/Job/BugMail.pm16
-rw-r--r--Bugzilla/Job/Mailer.pm20
2 files changed, 18 insertions, 18 deletions
diff --git a/Bugzilla/Job/BugMail.pm b/Bugzilla/Job/BugMail.pm
index e0b7f5448..b4887c470 100644
--- a/Bugzilla/Job/BugMail.pm
+++ b/Bugzilla/Job/BugMail.pm
@@ -14,19 +14,9 @@ use warnings;
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 cd1c23445..7e7549de8 100644
--- a/Bugzilla/Job/Mailer.pm
+++ b/Bugzilla/Job/Mailer.pm
@@ -11,6 +11,7 @@ use 5.10.1;
use strict;
use warnings;
+use Bugzilla::Constants;
use Bugzilla::Mailer;
BEGIN { eval "use parent qw(TheSchwartz::Worker)"; }
@@ -32,15 +33,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;