FIX: Pass category and tag IDs to the emit webhook event job. (#15568)

* FIX: Pass category and tag IDs to the emit webhook event job.

Like webhooks won't fire when they're scoped to specific categories or tags because we're not passing the data to the job that emits it.

* Update config/initializers/012-web_hook_events.rb

Co-authored-by: Dan Ungureanu <dan@ungureanu.me>

Co-authored-by: Dan Ungureanu <dan@ungureanu.me>
This commit is contained in:
Roman Rizzi
2022-01-14 11:17:38 -03:00
committed by GitHub
parent f56eff2303
commit 8b3d50713d
2 changed files with 54 additions and 17 deletions

View File

@@ -117,5 +117,12 @@ end
DiscourseEvent.on(:like_created) do |post_action|
user = post_action.user
group_ids = user.groups.map(&:id)
WebHook.enqueue_object_hooks(:like, post_action, :post_liked, WebHookLikeSerializer, group_ids: group_ids)
topic = Topic.includes(:tags).joins(:posts).find_by(posts: { id: post_action.post_id })
category_id = topic&.category_id
tag_ids = topic&.tag_ids
WebHook.enqueue_object_hooks(:like,
post_action, :post_liked, WebHookLikeSerializer,
group_ids: group_ids, category_id: category_id, tag_ids: tag_ids
)
end