diff --git a/app/controllers/webhooks_controller.rb b/app/controllers/webhooks_controller.rb index 90edfe99a77..da480adcc25 100644 --- a/app/controllers/webhooks_controller.rb +++ b/app/controllers/webhooks_controller.rb @@ -29,9 +29,9 @@ class WebhooksController < ActionController::Base # by the "dropped" event and we don't want to increase bounce score twice # for the same message if event == "bounced".freeze && params["error"]["4."] - process_bounce(message_id, Email::Receiver::SOFT_BOUNCE_SCORE) + process_bounce(message_id, SiteSetting.soft_bounce_score) elsif event == "dropped".freeze - process_bounce(message_id, Email::Receiver::HARD_BOUNCE_SCORE) + process_bounce(message_id, SiteSetting.hard_bounce_score) end mailgun_success @@ -43,12 +43,12 @@ class WebhooksController < ActionController::Base message_id = (event["smtp-id"] || "").tr("<>", "") if event["event"] == "bounce".freeze if event["status"]["4."] - process_bounce(message_id, Email::Receiver::SOFT_BOUNCE_SCORE) + process_bounce(message_id, SiteSetting.soft_bounce_score) else - process_bounce(message_id, Email::Receiver::HARD_BOUNCE_SCORE) + process_bounce(message_id, SiteSetting.hard_bounce_score) end elsif event["event"] == "dropped".freeze - process_bounce(message_id, Email::Receiver::HARD_BOUNCE_SCORE) + process_bounce(message_id, SiteSetting.hard_bounce_score) end end @@ -61,9 +61,9 @@ class WebhooksController < ActionController::Base message_id = event["CustomID"] if event["event"] == "bounce".freeze if event["hard_bounce"] - process_bounce(message_id, Email::Receiver::HARD_BOUNCE_SCORE) + process_bounce(message_id, SiteSetting.hard_bounce_score) else - process_bounce(message_id, Email::Receiver::SOFT_BOUNCE_SCORE) + process_bounce(message_id, SiteSetting.soft_bounce_score) end end end @@ -79,9 +79,9 @@ class WebhooksController < ActionController::Base case event["event"] when "hard_bounce" - process_bounce(message_id, Email::Receiver::HARD_BOUNCE_SCORE) + process_bounce(message_id, SiteSetting.hard_bounce_score) when "soft_bounce" - process_bounce(message_id, Email::Receiver::SOFT_BOUNCE_SCORE) + process_bounce(message_id, SiteSetting.soft_bounce_score) end end diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index 7792d56ff68..e03c775a9e6 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -1210,6 +1210,9 @@ en: ignore_by_title: "Ignore incoming emails based on their title." mailgun_api_key: "Mailgun Secret API key used to verify webhook messages." + soft_bounce_score: "Score added to the user when a temporary bounce happens." + hard_bounce_score: "Score added to the user when a permanent bounce happens." + manual_polling_enabled: "Push emails using the API for email replies." pop3_polling_enabled: "Poll via POP3 for email replies." pop3_polling_ssl: "Use SSL while connecting to the POP3 server. (Recommended)" diff --git a/config/site_settings.yml b/config/site_settings.yml index d52898e1a5a..f6dce976f23 100644 --- a/config/site_settings.yml +++ b/config/site_settings.yml @@ -622,6 +622,8 @@ email: mailgun_api_key: default: '' regex: '^key-\h{32}$' + soft_bounce_score: 1 + hard_bounce_score: 2 files: diff --git a/lib/email/receiver.rb b/lib/email/receiver.rb index 1160b88f814..7f9f4f5af66 100644 --- a/lib/email/receiver.rb +++ b/lib/email/receiver.rb @@ -136,9 +136,6 @@ module Email end end - SOFT_BOUNCE_SCORE ||= 1 - HARD_BOUNCE_SCORE ||= 2 - def is_bounce? return false unless @mail.bounced? || verp @@ -152,9 +149,9 @@ module Email email ||= @from_email if @mail.error_status.present? && @mail.error_status.start_with?("4.") - Email::Receiver.update_bounce_score(email, SOFT_BOUNCE_SCORE) + Email::Receiver.update_bounce_score(email, SiteSetting.soft_bounce_score) else - Email::Receiver.update_bounce_score(email, HARD_BOUNCE_SCORE) + Email::Receiver.update_bounce_score(email, SiteSetting.hard_bounce_score) end true