mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 09:36:19 -05:00
FIX: show event name in webhook headers
This commit is contained in:
parent
2d859ba0ed
commit
7423140825
2 changed files with 7 additions and 6 deletions
|
@ -49,7 +49,7 @@ module Jobs
|
|||
'X-Discourse-Event-Id' => web_hook_event.id,
|
||||
'X-Discourse-Event-Type' => @opts[:event_type]
|
||||
}
|
||||
headers['X-Discourse-Event'] = @opts[:event_name] if @opts[:event_name].present?
|
||||
headers['X-Discourse-Event'] = @opts[:event_name].to_s if @opts[:event_name].present?
|
||||
|
||||
if @web_hook.secret.present?
|
||||
headers['X-Discourse-Event-Signature'] = "sha256=" + OpenSSL::HMAC.hexdigest("sha256", @web_hook.secret, body)
|
||||
|
|
|
@ -40,18 +40,18 @@ class WebHook < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
def self.enqueue_topic_hooks(topic, user)
|
||||
WebHook.enqueue_hooks(:topic, topic_id: topic.id, user_id: user&.id, category_id: topic&.category&.id)
|
||||
def self.enqueue_topic_hooks(event, topic, user)
|
||||
WebHook.enqueue_hooks(:topic, topic_id: topic.id, user_id: user&.id, category_id: topic&.category&.id, event_name: event.to_s)
|
||||
end
|
||||
|
||||
%i(topic_destroyed topic_recovered).each do |event|
|
||||
DiscourseEvent.on(event) do |topic, user|
|
||||
WebHook.enqueue_topic_hooks(topic, user)
|
||||
WebHook.enqueue_topic_hooks(event, topic, user)
|
||||
end
|
||||
end
|
||||
|
||||
DiscourseEvent.on(:topic_created) do |topic, _, user|
|
||||
WebHook.enqueue_topic_hooks(topic, user)
|
||||
WebHook.enqueue_topic_hooks(:topic_created, topic, user)
|
||||
end
|
||||
|
||||
%i(post_created
|
||||
|
@ -63,7 +63,8 @@ class WebHook < ActiveRecord::Base
|
|||
post_id: post.id,
|
||||
topic_id: post&.topic&.id,
|
||||
user_id: user&.id,
|
||||
category_id: post.topic&.category&.id
|
||||
category_id: post.topic&.category&.id,
|
||||
event_name: event.to_s
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue