mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 02:50:00 +08: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
|
||||
|
||||
def trigger_queued_post_event
|
||||
DiscourseEvent.trigger(:queued_post, self)
|
||||
DiscourseEvent.trigger(:queued_post_created, self)
|
||||
true
|
||||
end
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ class WebHookEventType < ActiveRecord::Base
|
|||
CATEGORY = 5
|
||||
TAG = 6
|
||||
FLAG = 7
|
||||
APPROVAL = 8
|
||||
QUEUED_POST = 8
|
||||
|
||||
has_and_belongs_to_many :web_hooks
|
||||
|
||||
|
|
|
@ -90,11 +90,11 @@ end
|
|||
end
|
||||
|
||||
%i(
|
||||
queued_post
|
||||
queued_post_created
|
||||
approved_post
|
||||
rejected_post
|
||||
).each do |event|
|
||||
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
|
||||
|
|
|
@ -3027,9 +3027,9 @@ en:
|
|||
flag_event:
|
||||
name: "Flag Event"
|
||||
details: "When a flag is created, agreed, disagreed or ignored."
|
||||
approval_event:
|
||||
name: "Approval Event"
|
||||
details: "When a new post is queued, approved or rejected."
|
||||
queued_post_event:
|
||||
name: "Post Approval Event"
|
||||
details: "When a new queued post is created, approved or rejected."
|
||||
delivery_status:
|
||||
title: "Delivery Status"
|
||||
inactive: "Inactive"
|
||||
|
|
|
@ -34,6 +34,6 @@ WebHookEventType.seed do |b|
|
|||
end
|
||||
|
||||
WebHookEventType.seed do |b|
|
||||
b.id = WebHookEventType::APPROVAL
|
||||
b.name = "approval"
|
||||
b.id = WebHookEventType::QUEUED_POST
|
||||
b.name = "queued_post"
|
||||
end
|
||||
|
|
|
@ -77,10 +77,10 @@ Fabricator(:flag_web_hook, from: :web_hook) do
|
|||
end
|
||||
end
|
||||
|
||||
Fabricator(:approval_web_hook, from: :web_hook) do
|
||||
transient approval_hook: WebHookEventType.find_by(name: 'approval')
|
||||
Fabricator(:queued_post_web_hook, from: :web_hook) do
|
||||
transient queued_post_hook: WebHookEventType.find_by(name: 'queued_post')
|
||||
|
||||
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
|
||||
|
|
|
@ -171,7 +171,7 @@ describe QueuedPost do
|
|||
it 'triggers a extensibility event' do
|
||||
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)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -418,12 +418,12 @@ describe WebHook do
|
|||
expect(payload["id"]).to eq(post_action.id)
|
||||
end
|
||||
|
||||
it 'should enqueue the right hooks for post approval events' do
|
||||
Fabricate(:approval_web_hook)
|
||||
it 'should enqueue the right hooks for queued post events' do
|
||||
Fabricate(:queued_post_web_hook)
|
||||
queued_post = Fabricate(:queued_post)
|
||||
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"])
|
||||
expect(payload["id"]).to eq(queued_post.id)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user