mirror of
https://github.com/discourse/discourse.git
synced 2025-09-04 08:47:37 +08:00
Don't enqueue topic webhook unless a post has a topic
This commit is contained in:
parent
7bcc0c1da9
commit
9d0807224b
2 changed files with 26 additions and 3 deletions
|
@ -18,8 +18,13 @@ end
|
||||||
end
|
end
|
||||||
|
|
||||||
DiscourseEvent.on(:post_edited) do |post, topic_changed|
|
DiscourseEvent.on(:post_edited) do |post, topic_changed|
|
||||||
WebHook.enqueue_post_hooks(:post_edited, post)
|
if post.topic
|
||||||
WebHook.enqueue_topic_hooks(:topic_edited, post.topic) if post.is_first_post? && topic_changed
|
WebHook.enqueue_post_hooks(:post_edited, post)
|
||||||
|
|
||||||
|
if post.is_first_post? && topic_changed
|
||||||
|
WebHook.enqueue_topic_hooks(:topic_edited, post.topic)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
%i(
|
%i(
|
||||||
|
|
|
@ -145,6 +145,24 @@ describe WebHook do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'when topic has been deleted' do
|
||||||
|
it 'should not enqueue a post/topic edited hooks' do
|
||||||
|
topic.trash!
|
||||||
|
post.reload
|
||||||
|
|
||||||
|
PostRevisor.new(post, topic).revise!(
|
||||||
|
post.user,
|
||||||
|
{
|
||||||
|
category_id: Category.last.id,
|
||||||
|
raw: "#{post.raw} new"
|
||||||
|
},
|
||||||
|
{}
|
||||||
|
)
|
||||||
|
|
||||||
|
expect(Jobs::EmitWebHookEvent.jobs.count).to eq(0)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
it 'should enqueue the right hooks for post events' do
|
it 'should enqueue the right hooks for post events' do
|
||||||
Fabricate(:web_hook)
|
Fabricate(:web_hook)
|
||||||
|
|
||||||
|
@ -188,7 +206,7 @@ describe WebHook do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should enqueue the right hooks for user events' do
|
it 'should enqueue the right hooks for user events' do
|
||||||
_user_web_hook = Fabricate(:user_web_hook, active: true)
|
Fabricate(:user_web_hook, active: true)
|
||||||
|
|
||||||
Sidekiq::Testing.fake! do
|
Sidekiq::Testing.fake! do
|
||||||
user
|
user
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue