mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 07:53:49 +08:00
FEATURE: sparkpost webhook
This commit is contained in:
@ -88,6 +88,28 @@ class WebhooksController < ActionController::Base
|
||||
render nothing: true, status: 200
|
||||
end
|
||||
|
||||
def sparkpost
|
||||
events = params["_json"] || [params]
|
||||
events.each do |event|
|
||||
message_id = event["msys"]["message_event"]["campaign_id"] rescue nil
|
||||
bounce_class = event["msys"]["message_event"]["bounce_class"] rescue nil
|
||||
next unless message_id && bounce_class
|
||||
|
||||
bounce_class = bounce_class.to_i
|
||||
|
||||
# bounce class definitions: https://support.sparkpost.com/customer/portal/articles/1929896
|
||||
if bounce_class < 80
|
||||
if bounce_class == 10 || bounce_class == 25 || bounce_class == 30
|
||||
process_bounce(message_id, SiteSetting.hard_bounce_score)
|
||||
else
|
||||
process_bounce(message_id, SiteSetting.soft_bounce_score)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
render nothing: true, status: 200
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def mailgun_failure
|
||||
|
Reference in New Issue
Block a user