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:
Vinoth Kannan
2018-12-05 14:44:06 +05:30
committed by GitHub
parent 1a71f98d28
commit d33d031742
11 changed files with 72 additions and 0 deletions

View File

@ -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