mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 22:01:14 +08:00
extract bounce scores into site settings
This commit is contained in:
@ -29,9 +29,9 @@ class WebhooksController < ActionController::Base
|
|||||||
# by the "dropped" event and we don't want to increase bounce score twice
|
# by the "dropped" event and we don't want to increase bounce score twice
|
||||||
# for the same message
|
# for the same message
|
||||||
if event == "bounced".freeze && params["error"]["4."]
|
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
|
elsif event == "dropped".freeze
|
||||||
process_bounce(message_id, Email::Receiver::HARD_BOUNCE_SCORE)
|
process_bounce(message_id, SiteSetting.hard_bounce_score)
|
||||||
end
|
end
|
||||||
|
|
||||||
mailgun_success
|
mailgun_success
|
||||||
@ -43,12 +43,12 @@ class WebhooksController < ActionController::Base
|
|||||||
message_id = (event["smtp-id"] || "").tr("<>", "")
|
message_id = (event["smtp-id"] || "").tr("<>", "")
|
||||||
if event["event"] == "bounce".freeze
|
if event["event"] == "bounce".freeze
|
||||||
if event["status"]["4."]
|
if event["status"]["4."]
|
||||||
process_bounce(message_id, Email::Receiver::SOFT_BOUNCE_SCORE)
|
process_bounce(message_id, SiteSetting.soft_bounce_score)
|
||||||
else
|
else
|
||||||
process_bounce(message_id, Email::Receiver::HARD_BOUNCE_SCORE)
|
process_bounce(message_id, SiteSetting.hard_bounce_score)
|
||||||
end
|
end
|
||||||
elsif event["event"] == "dropped".freeze
|
elsif event["event"] == "dropped".freeze
|
||||||
process_bounce(message_id, Email::Receiver::HARD_BOUNCE_SCORE)
|
process_bounce(message_id, SiteSetting.hard_bounce_score)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -61,9 +61,9 @@ class WebhooksController < ActionController::Base
|
|||||||
message_id = event["CustomID"]
|
message_id = event["CustomID"]
|
||||||
if event["event"] == "bounce".freeze
|
if event["event"] == "bounce".freeze
|
||||||
if event["hard_bounce"]
|
if event["hard_bounce"]
|
||||||
process_bounce(message_id, Email::Receiver::HARD_BOUNCE_SCORE)
|
process_bounce(message_id, SiteSetting.hard_bounce_score)
|
||||||
else
|
else
|
||||||
process_bounce(message_id, Email::Receiver::SOFT_BOUNCE_SCORE)
|
process_bounce(message_id, SiteSetting.soft_bounce_score)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -79,9 +79,9 @@ class WebhooksController < ActionController::Base
|
|||||||
|
|
||||||
case event["event"]
|
case event["event"]
|
||||||
when "hard_bounce"
|
when "hard_bounce"
|
||||||
process_bounce(message_id, Email::Receiver::HARD_BOUNCE_SCORE)
|
process_bounce(message_id, SiteSetting.hard_bounce_score)
|
||||||
when "soft_bounce"
|
when "soft_bounce"
|
||||||
process_bounce(message_id, Email::Receiver::SOFT_BOUNCE_SCORE)
|
process_bounce(message_id, SiteSetting.soft_bounce_score)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1210,6 +1210,9 @@ en:
|
|||||||
ignore_by_title: "Ignore incoming emails based on their title."
|
ignore_by_title: "Ignore incoming emails based on their title."
|
||||||
mailgun_api_key: "Mailgun Secret API key used to verify webhook messages."
|
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."
|
manual_polling_enabled: "Push emails using the API for email replies."
|
||||||
pop3_polling_enabled: "Poll via POP3 for email replies."
|
pop3_polling_enabled: "Poll via POP3 for email replies."
|
||||||
pop3_polling_ssl: "Use SSL while connecting to the POP3 server. (Recommended)"
|
pop3_polling_ssl: "Use SSL while connecting to the POP3 server. (Recommended)"
|
||||||
|
@ -622,6 +622,8 @@ email:
|
|||||||
mailgun_api_key:
|
mailgun_api_key:
|
||||||
default: ''
|
default: ''
|
||||||
regex: '^key-\h{32}$'
|
regex: '^key-\h{32}$'
|
||||||
|
soft_bounce_score: 1
|
||||||
|
hard_bounce_score: 2
|
||||||
|
|
||||||
|
|
||||||
files:
|
files:
|
||||||
|
@ -136,9 +136,6 @@ module Email
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
SOFT_BOUNCE_SCORE ||= 1
|
|
||||||
HARD_BOUNCE_SCORE ||= 2
|
|
||||||
|
|
||||||
def is_bounce?
|
def is_bounce?
|
||||||
return false unless @mail.bounced? || verp
|
return false unless @mail.bounced? || verp
|
||||||
|
|
||||||
@ -152,9 +149,9 @@ module Email
|
|||||||
email ||= @from_email
|
email ||= @from_email
|
||||||
|
|
||||||
if @mail.error_status.present? && @mail.error_status.start_with?("4.")
|
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
|
else
|
||||||
Email::Receiver.update_bounce_score(email, HARD_BOUNCE_SCORE)
|
Email::Receiver.update_bounce_score(email, SiteSetting.hard_bounce_score)
|
||||||
end
|
end
|
||||||
|
|
||||||
true
|
true
|
||||||
|
Reference in New Issue
Block a user