mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 07:52:19 +08:00
FIX: Wildcard webhooks could send duplicated events.
This commit is contained in:
parent
b295c03001
commit
9644569a28
|
@ -34,6 +34,7 @@ class WebHook < ActiveRecord::Base
|
|||
WebHook.where(active: true)
|
||||
.joins(:web_hook_event_types)
|
||||
.where("web_hooks.wildcard_web_hook = ? OR web_hook_event_types.name = ?", true, type.to_s)
|
||||
.uniq
|
||||
end
|
||||
|
||||
def self.enqueue_hooks(type, opts = {})
|
||||
|
|
|
@ -43,6 +43,13 @@ describe WebHook do
|
|||
end
|
||||
|
||||
describe '#find_by_type' do
|
||||
it "returns unique hooks" do
|
||||
post_hook.web_hook_event_types << WebHookEventType.find_by(name: 'topic')
|
||||
post_hook.update!(wildcard_web_hook: true)
|
||||
|
||||
expect(WebHook.find_by_type(:post)).to eq([post_hook])
|
||||
end
|
||||
|
||||
it 'find relevant hooks' do
|
||||
expect(WebHook.find_by_type(:post)).to eq([post_hook])
|
||||
expect(WebHook.find_by_type(:topic)).to eq([topic_hook])
|
||||
|
|
Loading…
Reference in New Issue
Block a user