FEATURE: Display unread and new counts for messages. (#14059)

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.
This commit is contained in:
Alan Guo Xiang Tan
2021-08-25 11:17:56 +08:00
committed by GitHub
parent 4387bc1261
commit f66007ec83
32 changed files with 1149 additions and 362 deletions

View File

@@ -20,11 +20,6 @@ class PostJobsEnqueuer
after_topic_create
make_visible
end
if @topic.private_message?
TopicTrackingState.publish_private_message(@topic, post: @post)
TopicGroup.new_message_update(@topic.last_poster, @topic.id, @post.post_number)
end
end
private
@@ -46,6 +41,7 @@ class PostJobsEnqueuer
end
def make_visible
return if @topic.private_message?
return unless SiteSetting.embed_unlisted?
return unless @post.post_number > 1
return if @topic.visible?
@@ -73,12 +69,18 @@ class PostJobsEnqueuer
@topic.posters = @topic.posters_summary
@topic.posts_count = 1
TopicTrackingState.publish_new(@topic)
klass =
if @topic.private_message?
PrivateMessageTopicTrackingState
else
TopicTrackingState
end
klass.publish_new(@topic)
end
def skip_after_create?
@opts[:import_mode] ||
@topic.private_message? ||
@post.post_type == Post.types[:moderator_action] ||
@post.post_type == Post.types[:small_action]
end