mirror of
https://github.com/discourse/discourse.git
synced 2025-05-23 19:04:11 +08:00
FEATURE: Filter topic and post web hook events by tags (#6726)
* FEATURE: Filter topic and post web hook events by tags * Add a spec test with unmatched tags
This commit is contained in:
@ -2,6 +2,7 @@ class WebHook < ActiveRecord::Base
|
||||
has_and_belongs_to_many :web_hook_event_types
|
||||
has_and_belongs_to_many :groups
|
||||
has_and_belongs_to_many :categories
|
||||
has_and_belongs_to_many :tags
|
||||
|
||||
has_many :web_hook_events, dependent: :destroy
|
||||
|
||||
@ -15,6 +16,10 @@ class WebHook < ActiveRecord::Base
|
||||
|
||||
before_save :strip_url
|
||||
|
||||
def tag_names=(tag_names_arg)
|
||||
DiscourseTagging.add_or_create_tags_by_name(self, tag_names_arg, unlimited: true)
|
||||
end
|
||||
|
||||
def self.content_types
|
||||
@content_types ||= Enum.new('application/json' => 1,
|
||||
'application/x-www-form-urlencoded' => 2)
|
||||
@ -68,6 +73,7 @@ class WebHook < ActiveRecord::Base
|
||||
WebHook.enqueue_hooks(:topic, event,
|
||||
id: topic.id,
|
||||
category_id: topic&.category_id,
|
||||
tag_ids: topic&.tags.pluck(:id),
|
||||
payload: payload
|
||||
)
|
||||
end
|
||||
@ -80,6 +86,7 @@ class WebHook < ActiveRecord::Base
|
||||
WebHook.enqueue_hooks(:post, event,
|
||||
id: post.id,
|
||||
category_id: post&.topic&.category_id,
|
||||
tag_ids: post&.topic&.tags.pluck(:id),
|
||||
payload: payload
|
||||
)
|
||||
end
|
||||
|
Reference in New Issue
Block a user