From eb14983dfa87f94394d759f739c96ea6e19bfd81 Mon Sep 17 00:00:00 2001 From: riking Date: Mon, 30 Jun 2014 14:39:28 -0700 Subject: [PATCH 1/3] Change pop3 auth errors from admin message to dashboard notice --- app/jobs/scheduled/poll_mailbox.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/jobs/scheduled/poll_mailbox.rb b/app/jobs/scheduled/poll_mailbox.rb index efaa743f9c7..a19e43d8bf6 100644 --- a/app/jobs/scheduled/poll_mailbox.rb +++ b/app/jobs/scheduled/poll_mailbox.rb @@ -70,9 +70,7 @@ module Jobs pop.finish end rescue Net::POPAuthenticationError => e - # inform admins about the error (1 message per hour to prevent too much SPAM) - data = { limit_once_per: 1.hour, message_params: { error: e }} - GroupMessage.create(Group[:admins].name, :email_error_notification, data) + Discourse.handle_exception(e, { context: "signing in for incoming email" }) end end From 07cedb7946abcab2158f91f415120b3c9d524ec7 Mon Sep 17 00:00:00 2001 From: riking Date: Mon, 30 Jun 2014 15:16:16 -0700 Subject: [PATCH 2/3] Fix specs, handle_exception calls --- app/jobs/scheduled/poll_mailbox.rb | 4 ++-- spec/jobs/poll_mailbox_spec.rb | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/jobs/scheduled/poll_mailbox.rb b/app/jobs/scheduled/poll_mailbox.rb index a19e43d8bf6..a71e745bc26 100644 --- a/app/jobs/scheduled/poll_mailbox.rb +++ b/app/jobs/scheduled/poll_mailbox.rb @@ -47,7 +47,7 @@ module Jobs client_message = RejectionMailer.send_rejection(message.from, message.body, message.to, message_template) Email::Sender.new(client_message, message_template).send else - Discourse.handle_exception(e, { context: "incoming email", mail: mail_string }) + Discourse.handle_exception(e, { context: { code: "unknown error for incoming email", mail: mail_string} }) end ensure mail.delete @@ -70,7 +70,7 @@ module Jobs pop.finish end rescue Net::POPAuthenticationError => e - Discourse.handle_exception(e, { context: "signing in for incoming email" }) + Discourse.handle_exception(e, { context: { code: "signing in for incoming email" } }) end end diff --git a/spec/jobs/poll_mailbox_spec.rb b/spec/jobs/poll_mailbox_spec.rb index 543edabb261..f83b25404af 100644 --- a/spec/jobs/poll_mailbox_spec.rb +++ b/spec/jobs/poll_mailbox_spec.rb @@ -28,12 +28,13 @@ describe Jobs::PollMailbox do describe ".poll_pop3s" do - it "informs admins on pop authentication error" do + it "logs an error on pop authentication error" do error = Net::POPAuthenticationError.new data = { limit_once_per: 1.hour, message_params: { error: error }} Net::POP3.expects(:start).raises(error) - GroupMessage.expects(:create).with("admins", :email_error_notification, data) + + Discourse.expects(:handle_exception) poller.poll_pop3s end From a7b8f25c505b973fe27a0bd54f25533be16ac34e Mon Sep 17 00:00:00 2001 From: riking Date: Mon, 30 Jun 2014 15:17:05 -0700 Subject: [PATCH 3/3] Even better fix --- app/jobs/scheduled/poll_mailbox.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/jobs/scheduled/poll_mailbox.rb b/app/jobs/scheduled/poll_mailbox.rb index a71e745bc26..564d20c6c58 100644 --- a/app/jobs/scheduled/poll_mailbox.rb +++ b/app/jobs/scheduled/poll_mailbox.rb @@ -47,7 +47,7 @@ module Jobs client_message = RejectionMailer.send_rejection(message.from, message.body, message.to, message_template) Email::Sender.new(client_message, message_template).send else - Discourse.handle_exception(e, { context: { code: "unknown error for incoming email", mail: mail_string} }) + Discourse.handle_exception(e, { code: "unknown error for incoming email", mail: mail_string} ) end ensure mail.delete @@ -70,7 +70,7 @@ module Jobs pop.finish end rescue Net::POPAuthenticationError => e - Discourse.handle_exception(e, { context: { code: "signing in for incoming email" } }) + Discourse.handle_exception(e, { code: "signing in for incoming email" } ) end end