mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 02:19:27 +08:00
FIX: Ensure group-filtered group user event webhooks fire (#21254)
Group user event webhooks filtered by group fail silently because the `group_ids` job arg wasn't being passed into the job. This change add's `group_ids` to the `EmitWebHookEvent` jobs queued for `user_added_to_group` and `user_removed_from_group` events.
This commit is contained in:
parent
3c4241c0b6
commit
37cc056c1b
|
@ -810,6 +810,7 @@ class Group < ActiveRecord::Base
|
|||
:user_removed_from_group,
|
||||
id: group_user.id,
|
||||
payload: payload,
|
||||
group_ids: [self.id],
|
||||
)
|
||||
end
|
||||
|
||||
|
|
|
@ -100,6 +100,7 @@ DiscourseEvent.on(:user_added_to_group) do |user, group, options|
|
|||
group_user,
|
||||
:user_added_to_group,
|
||||
WebHookGroupUserSerializer,
|
||||
group_ids: [group.id],
|
||||
)
|
||||
end
|
||||
|
||||
|
|
|
@ -558,7 +558,10 @@ RSpec.describe WebHook do
|
|||
|
||||
job_args = Jobs::EmitWebHookEvent.jobs.last["args"].first
|
||||
expect(job_args["event_name"]).to eq("user_added_to_group")
|
||||
expect(job_args["group_ids"]).to contain_exactly(group.id)
|
||||
|
||||
payload = JSON.parse(job_args["payload"])
|
||||
|
||||
expect(payload["group_id"]).to eq(group.id)
|
||||
expect(payload["user_id"]).to eq(user.id)
|
||||
expect(payload["notification_level"]).to eq(group.default_notification_level)
|
||||
|
@ -577,7 +580,10 @@ RSpec.describe WebHook do
|
|||
|
||||
job_args = Jobs::EmitWebHookEvent.jobs.last["args"].first
|
||||
expect(job_args["event_name"]).to eq("user_removed_from_group")
|
||||
expect(job_args["group_ids"]).to contain_exactly(group.id)
|
||||
|
||||
payload = JSON.parse(job_args["payload"])
|
||||
|
||||
expect(payload["group_id"]).to eq(group.id)
|
||||
expect(payload["user_id"]).to eq(user.id)
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user