Skip to content

Commit

Permalink
FIX: granular webhooks (#498)
Browse files Browse the repository at this point in the history
After those core changes we need additional translations

discourse/discourse#23070
  • Loading branch information
lis2 authored Oct 9, 2023
1 parent df34e91 commit 0c01e8f
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
1 change: 1 addition & 0 deletions .discourse-compatibility
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
< 3.2.0.beta2-dev: df34e91b55d0d068bd983fd6a9fd7d3235cfc1fe
3.1.999: 0cbf10b8055370445bd36536e51986bf48bdc57e
3.1.0.beta3: 9c270cac9abc1c2b30574d8c655fb3a90546236b
2.9.0.beta8: 28bc8ab78a09551548c87f511ade3d64e1b04bc3
Expand Down
5 changes: 3 additions & 2 deletions config/locales/client.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions lib/assigner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ def assign(assign_to, note: nil, skip_small_action_post: false, status: nil)
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,
Expand Down Expand Up @@ -413,7 +413,7 @@ def unassign(silent: false, deactivate: false)
end

# Create a webhook event
if WebHook.active_web_hooks(:assign).exists?
if WebHook.active_web_hooks(:unassigned).exists?
type = :unassigned
payload = {
type: type,
Expand Down
4 changes: 1 addition & 3 deletions lib/discourse_assign/web_hook_extension.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ module WebHookExtension
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
Expand Down
6 changes: 3 additions & 3 deletions spec/fabricators/assign_hook_fabricator.rb
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 0c01e8f

Please sign in to comment.