mirror of
https://github.com/discourse/discourse.git
synced 2025-05-24 03:36:18 +08:00
FIX: Do not log 'personal message view' when sending webhook (#21375)
Similar to the issue resolved by 3b55de90e5
This commit is contained in:
@ -68,7 +68,7 @@ class WebHook < ActiveRecord::Base
|
|||||||
if active_web_hooks("topic").exists? && topic.present?
|
if active_web_hooks("topic").exists? && topic.present?
|
||||||
payload ||=
|
payload ||=
|
||||||
begin
|
begin
|
||||||
topic_view = TopicView.new(topic.id, Discourse.system_user)
|
topic_view = TopicView.new(topic.id, Discourse.system_user, skip_staff_action: true)
|
||||||
WebHook.generate_payload(:topic, topic_view, WebHookTopicViewSerializer)
|
WebHook.generate_payload(:topic, topic_view, WebHookTopicViewSerializer)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -219,6 +219,29 @@ RSpec.describe WebHook do
|
|||||||
expect(payload["tags"]).to contain_exactly(tag.name)
|
expect(payload["tags"]).to contain_exactly(tag.name)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should not log a personal message view when processing new topic" do
|
||||||
|
SiteSetting.log_personal_messages_views = true
|
||||||
|
Fabricate(:topic_web_hook)
|
||||||
|
|
||||||
|
post =
|
||||||
|
PostCreator.create!(
|
||||||
|
user,
|
||||||
|
raw: "raw",
|
||||||
|
title: "title",
|
||||||
|
skip_validations: true,
|
||||||
|
archetype: Archetype.private_message,
|
||||||
|
target_usernames: user.username,
|
||||||
|
)
|
||||||
|
topic_id = post.topic.id
|
||||||
|
job_args = Jobs::EmitWebHookEvent.jobs.last["args"].first
|
||||||
|
|
||||||
|
expect(job_args["event_name"]).to eq("topic_created")
|
||||||
|
payload = JSON.parse(job_args["payload"])
|
||||||
|
expect(payload["id"]).to eq(topic_id)
|
||||||
|
|
||||||
|
expect(UserHistory.where(action: UserHistory.actions[:check_personal_message]).count).to eq(0)
|
||||||
|
end
|
||||||
|
|
||||||
describe "when topic has been deleted" do
|
describe "when topic has been deleted" do
|
||||||
it "should not enqueue a post/topic edited hooks" do
|
it "should not enqueue a post/topic edited hooks" do
|
||||||
topic.trash!
|
topic.trash!
|
||||||
|
Reference in New Issue
Block a user