Merge pull request #2486 from riking/no_group_messages

Change pop3 auth errors from admin message to dashboard notice
This commit is contained in:
Sam 2014-07-01 10:02:19 +10:00
commit 20074a3140
2 changed files with 5 additions and 6 deletions

View File

@ -47,7 +47,7 @@ module Jobs
client_message = RejectionMailer.send_rejection(message.from, message.body, message.to, message_template) client_message = RejectionMailer.send_rejection(message.from, message.body, message.to, message_template)
Email::Sender.new(client_message, message_template).send Email::Sender.new(client_message, message_template).send
else else
Discourse.handle_exception(e, { context: "incoming email", mail: mail_string }) Discourse.handle_exception(e, { code: "unknown error for incoming email", mail: mail_string} )
end end
ensure ensure
mail.delete mail.delete
@ -70,9 +70,7 @@ module Jobs
pop.finish pop.finish
end end
rescue Net::POPAuthenticationError => e rescue Net::POPAuthenticationError => e
# inform admins about the error (1 message per hour to prevent too much SPAM) Discourse.handle_exception(e, { code: "signing in for incoming email" } )
data = { limit_once_per: 1.hour, message_params: { error: e }}
GroupMessage.create(Group[:admins].name, :email_error_notification, data)
end end
end end

View File

@ -28,12 +28,13 @@ describe Jobs::PollMailbox do
describe ".poll_pop3s" 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 error = Net::POPAuthenticationError.new
data = { limit_once_per: 1.hour, message_params: { error: error }} data = { limit_once_per: 1.hour, message_params: { error: error }}
Net::POP3.expects(:start).raises(error) Net::POP3.expects(:start).raises(error)
GroupMessage.expects(:create).with("admins", :email_error_notification, data)
Discourse.expects(:handle_exception)
poller.poll_pop3s poller.poll_pop3s
end end