mirror of
https://github.com/discourse/discourse.git
synced 2025-02-20 11:48:26 -06:00
Rename approval web hook event type to queued post
This commit is contained in:
parent
5059dad8f0
commit
af5b88f8e2
@ -18,7 +18,7 @@ class QueuedPost < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def trigger_queued_post_event
|
def trigger_queued_post_event
|
||||||
DiscourseEvent.trigger(:queued_post, self)
|
DiscourseEvent.trigger(:queued_post_created, self)
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ class WebHookEventType < ActiveRecord::Base
|
|||||||
CATEGORY = 5
|
CATEGORY = 5
|
||||||
TAG = 6
|
TAG = 6
|
||||||
FLAG = 7
|
FLAG = 7
|
||||||
APPROVAL = 8
|
QUEUED_POST = 8
|
||||||
|
|
||||||
has_and_belongs_to_many :web_hooks
|
has_and_belongs_to_many :web_hooks
|
||||||
|
|
||||||
|
@ -90,11 +90,11 @@ end
|
|||||||
end
|
end
|
||||||
|
|
||||||
%i(
|
%i(
|
||||||
queued_post
|
queued_post_created
|
||||||
approved_post
|
approved_post
|
||||||
rejected_post
|
rejected_post
|
||||||
).each do |event|
|
).each do |event|
|
||||||
DiscourseEvent.on(event) do |queued_post|
|
DiscourseEvent.on(event) do |queued_post|
|
||||||
WebHook.enqueue_object_hooks(:approval, queued_post, event, QueuedPostSerializer)
|
WebHook.enqueue_object_hooks(:queued_post, queued_post, event, QueuedPostSerializer)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -3027,9 +3027,9 @@ en:
|
|||||||
flag_event:
|
flag_event:
|
||||||
name: "Flag Event"
|
name: "Flag Event"
|
||||||
details: "When a flag is created, agreed, disagreed or ignored."
|
details: "When a flag is created, agreed, disagreed or ignored."
|
||||||
approval_event:
|
queued_post_event:
|
||||||
name: "Approval Event"
|
name: "Post Approval Event"
|
||||||
details: "When a new post is queued, approved or rejected."
|
details: "When a new queued post is created, approved or rejected."
|
||||||
delivery_status:
|
delivery_status:
|
||||||
title: "Delivery Status"
|
title: "Delivery Status"
|
||||||
inactive: "Inactive"
|
inactive: "Inactive"
|
||||||
|
@ -34,6 +34,6 @@ WebHookEventType.seed do |b|
|
|||||||
end
|
end
|
||||||
|
|
||||||
WebHookEventType.seed do |b|
|
WebHookEventType.seed do |b|
|
||||||
b.id = WebHookEventType::APPROVAL
|
b.id = WebHookEventType::QUEUED_POST
|
||||||
b.name = "approval"
|
b.name = "queued_post"
|
||||||
end
|
end
|
||||||
|
@ -77,10 +77,10 @@ Fabricator(:flag_web_hook, from: :web_hook) do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Fabricator(:approval_web_hook, from: :web_hook) do
|
Fabricator(:queued_post_web_hook, from: :web_hook) do
|
||||||
transient approval_hook: WebHookEventType.find_by(name: 'approval')
|
transient queued_post_hook: WebHookEventType.find_by(name: 'queued_post')
|
||||||
|
|
||||||
after_build do |web_hook, transients|
|
after_build do |web_hook, transients|
|
||||||
web_hook.web_hook_event_types = [transients[:approval_hook]]
|
web_hook.web_hook_event_types = [transients[:queued_post_hook]]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -171,7 +171,7 @@ describe QueuedPost do
|
|||||||
it 'triggers a extensibility event' do
|
it 'triggers a extensibility event' do
|
||||||
event = DiscourseEvent.track_events { subject.save! }.first
|
event = DiscourseEvent.track_events { subject.save! }.first
|
||||||
|
|
||||||
expect(event[:event_name]).to eq(:queued_post)
|
expect(event[:event_name]).to eq(:queued_post_created)
|
||||||
expect(event[:params].first).to eq(subject)
|
expect(event[:params].first).to eq(subject)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -418,12 +418,12 @@ describe WebHook do
|
|||||||
expect(payload["id"]).to eq(post_action.id)
|
expect(payload["id"]).to eq(post_action.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should enqueue the right hooks for post approval events' do
|
it 'should enqueue the right hooks for queued post events' do
|
||||||
Fabricate(:approval_web_hook)
|
Fabricate(:queued_post_web_hook)
|
||||||
queued_post = Fabricate(:queued_post)
|
queued_post = Fabricate(:queued_post)
|
||||||
job_args = Jobs::EmitWebHookEvent.jobs.last["args"].first
|
job_args = Jobs::EmitWebHookEvent.jobs.last["args"].first
|
||||||
|
|
||||||
expect(job_args["event_name"]).to eq("queued_post")
|
expect(job_args["event_name"]).to eq("queued_post_created")
|
||||||
payload = JSON.parse(job_args["payload"])
|
payload = JSON.parse(job_args["payload"])
|
||||||
expect(payload["id"]).to eq(queued_post.id)
|
expect(payload["id"]).to eq(queued_post.id)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user