mirror of
https://github.com/discourse/discourse-solved.git
synced 2025-02-17 17:14:58 +00:00
FIX: granular webhooks (#248)
After those core changes we need additional translations https://github.com/discourse/discourse/pull/23070
This commit is contained in:
parent
9fbf43e2f0
commit
7e59ece789
@ -1,3 +1,4 @@
|
|||||||
|
< 3.2.0.beta2-dev: 9fbf43e2f077e86f0a1ff769af6036d4e78bfff1
|
||||||
3.1.999: b5d487d6a5bfe2571d936eec5911d02a5f3fcc32
|
3.1.999: b5d487d6a5bfe2571d936eec5911d02a5f3fcc32
|
||||||
3.1.0.beta1: 62fe282c756ac7de43a22a09b0d675882a507743
|
3.1.0.beta1: 62fe282c756ac7de43a22a09b0d675882a507743
|
||||||
2.9.0.beta11: 882dd61e11f9bab8e99510296938b0cdbc3269c4
|
2.9.0.beta11: 882dd61e11f9bab8e99510296938b0cdbc3269c4
|
||||||
|
@ -48,8 +48,9 @@ en:
|
|||||||
admin:
|
admin:
|
||||||
web_hooks:
|
web_hooks:
|
||||||
solved_event:
|
solved_event:
|
||||||
name: "Solved Event"
|
group_name: "Solved Event"
|
||||||
details: "When a user marks a post as the accepted or unaccepted answer."
|
accepted_solution: "When an user marks a post as the accepted answer"
|
||||||
|
unaccepted_solution: "When an user marks a post as the unaccepted answer"
|
||||||
api:
|
api:
|
||||||
scopes:
|
scopes:
|
||||||
descriptions:
|
descriptions:
|
||||||
|
@ -160,7 +160,7 @@ SQL
|
|||||||
topic.save!
|
topic.save!
|
||||||
post.save!
|
post.save!
|
||||||
|
|
||||||
if WebHook.active_web_hooks(:solved).exists?
|
if WebHook.active_web_hooks(:accepted_solution).exists?
|
||||||
payload = WebHook.generate_payload(:post, post)
|
payload = WebHook.generate_payload(:post, post)
|
||||||
WebHook.enqueue_solved_hooks(:accepted_solution, post, payload)
|
WebHook.enqueue_solved_hooks(:accepted_solution, post, payload)
|
||||||
end
|
end
|
||||||
@ -201,7 +201,7 @@ SQL
|
|||||||
|
|
||||||
notification.destroy! if notification
|
notification.destroy! if notification
|
||||||
|
|
||||||
if WebHook.active_web_hooks(:solved).exists?
|
if WebHook.active_web_hooks(:unaccepted_solution).exists?
|
||||||
payload = WebHook.generate_payload(:post, post)
|
payload = WebHook.generate_payload(:post, post)
|
||||||
WebHook.enqueue_solved_hooks(:unaccepted_solution, post, payload)
|
WebHook.enqueue_solved_hooks(:unaccepted_solution, post, payload)
|
||||||
end
|
end
|
||||||
@ -420,7 +420,7 @@ SQL
|
|||||||
|
|
||||||
class ::WebHook
|
class ::WebHook
|
||||||
def self.enqueue_solved_hooks(event, post, payload = nil)
|
def self.enqueue_solved_hooks(event, post, payload = nil)
|
||||||
if active_web_hooks("solved").exists? && post.present?
|
if active_web_hooks(event).exists? && post.present?
|
||||||
payload ||= WebHook.generate_payload(:post, post)
|
payload ||= WebHook.generate_payload(:post, post)
|
||||||
|
|
||||||
WebHook.enqueue_hooks(
|
WebHook.enqueue_hooks(
|
||||||
@ -605,7 +605,7 @@ SQL
|
|||||||
WHERE tc.name = '#{::DiscourseSolved::ACCEPTED_ANSWER_POST_ID_CUSTOM_FIELD}' AND
|
WHERE tc.name = '#{::DiscourseSolved::ACCEPTED_ANSWER_POST_ID_CUSTOM_FIELD}' AND
|
||||||
tc.value IS NOT NULL
|
tc.value IS NOT NULL
|
||||||
) AND topics.id IN (
|
) AND topics.id IN (
|
||||||
SELECT top.id
|
SELECT top.id
|
||||||
FROM topics top
|
FROM topics top
|
||||||
INNER JOIN category_custom_fields cc
|
INNER JOIN category_custom_fields cc
|
||||||
ON top.category_id = cc.category_id
|
ON top.category_id = cc.category_id
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
Fabricator(:solved_web_hook, from: :web_hook) do
|
Fabricator(:solved_web_hook, from: :web_hook) do
|
||||||
transient solved_hook: WebHookEventType.find_by(name: "solved")
|
after_build do |web_hook|
|
||||||
|
web_hook.web_hook_event_types =
|
||||||
after_build { |web_hook, transients| web_hook.web_hook_event_types = [transients[:solved_hook]] }
|
WebHookEventType.where(name: %w[accepted_solution unaccepted_solution])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user