mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-06 05:24:51 +08:00
When a PM post is flagged as spam and hidden, the topic becomes
invisible and a small_action post is created. This bumped
highest_post_number, making the topic appear "unread". But the PM list
query filters out invisible topics for non-staff users, creating a
mismatch: the count badge says (1), the list says "You don't have any
messages."
Root cause: the 2019 commit (2312cacc) that excluded small_action posts
from PM counters in reset_highest did not apply the same rule to
next_post_number, which still bumped highest_post_number on creation.
This fix applies the PM small_action exclusion consistently:
- next_post_number: use post_type to detect PM small_actions and only
bump highest_staff_post_number (not highest_post_number), matching
reset_highest behavior. The archetype check only runs for small_action
posts, keeping the hot path unchanged.
- report_raw_sql: add visibility filter for non-staff users so the
tracking state count matches the list query.
- publish_unread: scope PM small_action notifications to staff group
only (same pattern already used for whispers), so non-staff clients
don't receive stale highest_post_number via MessageBus.
- TopicGroup.new_message_update: skip for PM small_actions to avoid
advancing group read pointers to small_action post numbers.
41 lines
1.1 KiB
Ruby
41 lines
1.1 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
RSpec.describe Jobs::PostUpdateTopicTrackingState do
|
|
subject(:job) { described_class.new }
|
|
|
|
fab!(:post)
|
|
|
|
it "should publish messages" do
|
|
messages = MessageBus.track_publish { job.execute({ post_id: post.id }) }
|
|
expect(messages.size).not_to eq(0)
|
|
end
|
|
|
|
it "should not publish messages for deleted topics" do
|
|
post.topic.trash!
|
|
messages = MessageBus.track_publish { job.execute({ post_id: post.id }) }
|
|
expect(messages.size).to eq(0)
|
|
end
|
|
|
|
it "should not update topic groups for small_action posts in private messages" do
|
|
user = Fabricate(:user, refresh_auto_groups: true)
|
|
recipient = Fabricate(:user)
|
|
pm =
|
|
create_post(
|
|
user: user,
|
|
target_usernames: [recipient.username],
|
|
archetype: Archetype.private_message,
|
|
)
|
|
|
|
small_action =
|
|
Fabricate(
|
|
:post,
|
|
topic: pm.topic,
|
|
user: Discourse.system_user,
|
|
post_type: Post.types[:small_action],
|
|
action_code: "visible.disabled",
|
|
)
|
|
|
|
TopicGroup.expects(:new_message_update).never
|
|
job.execute({ post_id: small_action.id })
|
|
end
|
|
end
|