mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 09:42:07 +08:00
f66007ec83
There are certain design decisions that were made in this commit. Private messages implements its own version of topic tracking state because there are significant differences between regular and private_message topics. Regular topics have to track categories and tags while private messages do not. It is much easier to design the new topic tracking state if we maintain two different classes, instead of trying to mash this two worlds together. One MessageBus channel per user and one MessageBus channel per group. This allows each user and each group to have their own channel backlog instead of having one global channel which requires the client to filter away unrelated messages.
34 lines
799 B
Ruby
34 lines
799 B
Ruby
# frozen_string_literal: true
|
|
|
|
module Jobs
|
|
class PostUpdateTopicTrackingState < ::Jobs::Base
|
|
|
|
def execute(args)
|
|
post = Post.find_by(id: args[:post_id])
|
|
return if !post&.topic
|
|
|
|
topic = post.topic
|
|
|
|
if topic.private_message?
|
|
if post.post_number > 1
|
|
PrivateMessageTopicTrackingState.publish_unread(post)
|
|
end
|
|
|
|
TopicGroup.new_message_update(
|
|
topic.last_poster,
|
|
topic.id,
|
|
post.post_number
|
|
)
|
|
else
|
|
TopicTrackingState.publish_unmuted(post.topic)
|
|
if post.post_number > 1
|
|
TopicTrackingState.publish_muted(post.topic)
|
|
TopicTrackingState.publish_unread(post)
|
|
end
|
|
TopicTrackingState.publish_latest(post.topic, post.whisper?)
|
|
end
|
|
end
|
|
|
|
end
|
|
end
|