FIX: granular webhooks (#498)

After those core changes we need additional translations

https://github.com/discourse/discourse/pull/23070
This commit is contained in:
Krzysztof Kotlarek 2023-10-09 14:26:40 +11:00 committed by GitHub
parent df34e91b55
commit 0c01e8fdfd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 10 additions and 10 deletions

View File

@ -1,3 +1,4 @@
< 3.2.0.beta2-dev: df34e91b55d0d068bd983fd6a9fd7d3235cfc1fe
3.1.999: 0cbf10b8055370445bd36536e51986bf48bdc57e
3.1.0.beta3: 9c270cac9abc1c2b30574d8c655fb3a90546236b
2.9.0.beta8: 28bc8ab78a09551548c87f511ade3d64e1b04bc3

View File

@ -102,8 +102,9 @@ en:
admin:
web_hooks:
assign_event:
name: "Assign Event"
details: "When a user assigns or unassigns a topic."
group_name: "Assign Events"
assigned: "When an user assigns a topic"
unassigned: "When an user unassigns a topic"
search:
advanced:
in:

View File

@ -335,7 +335,7 @@ class ::Assigner
end
# Create a webhook event
if WebHook.active_web_hooks(:assign).exists?
if WebHook.active_web_hooks(:assigned).exists?
assigned_to_type = :assigned
payload = {
type: assigned_to_type,
@ -413,7 +413,7 @@ class ::Assigner
end
# Create a webhook event
if WebHook.active_web_hooks(:assign).exists?
if WebHook.active_web_hooks(:unassigned).exists?
type = :unassigned
payload = {
type: type,

View File

@ -5,9 +5,7 @@ module DiscourseAssign
def self.prepended(base)
base.class_eval do
def self.enqueue_assign_hooks(event, payload)
if active_web_hooks("assign").exists?
WebHook.enqueue_hooks(:assign, event, payload: payload)
end
WebHook.enqueue_hooks(:assign, event, payload: payload) if active_web_hooks(event).exists?
end
end
end

View File

@ -1,7 +1,7 @@
# frozen_string_literal: true
Fabricator(:assign_web_hook, from: :web_hook) do
transient assign_hook: WebHookEventType.find_by(name: "assign")
after_build { |web_hook, transients| web_hook.web_hook_event_types = [transients[:assign_hook]] }
after_build do |web_hook|
web_hook.web_hook_event_types = WebHookEventType.where(name: %w[assigned unassigned])
end
end