From c51c80466caf8d962e0c60864bc0e0a7c1fc9bbd Mon Sep 17 00:00:00 2001 From: Alan Guo Xiang Tan Date: Thu, 29 Jul 2021 14:48:37 +0800 Subject: [PATCH] DEV: Move private message topic tracking state publish into sidekiq. Same intend as b1f32f2f5717c4f55b902485794e62b8cecd8522. --- .../regular/post_update_topic_tracking_state.rb | 15 +++++++++++---- lib/post_jobs_enqueuer.rb | 5 ----- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/app/jobs/regular/post_update_topic_tracking_state.rb b/app/jobs/regular/post_update_topic_tracking_state.rb index 6eaaeb288b4..cb3506cc539 100644 --- a/app/jobs/regular/post_update_topic_tracking_state.rb +++ b/app/jobs/regular/post_update_topic_tracking_state.rb @@ -5,14 +5,21 @@ module Jobs def execute(args) post = Post.find_by(id: args[:post_id]) + topic = post&.topic + return unless topic + + if post.topic.private_message? + TopicTrackingState.publish_private_message(topic, post: post) + TopicGroup.new_message_update(topic.last_poster, topic.id, post.post_number) + else + TopicTrackingState.publish_unmuted(topic) - if post && post.topic - TopicTrackingState.publish_unmuted(post.topic) if post.post_number > 1 - TopicTrackingState.publish_muted(post.topic) + TopicTrackingState.publish_muted(topic) TopicTrackingState.publish_unread(post) end - TopicTrackingState.publish_latest(post.topic, post.whisper?) + + TopicTrackingState.publish_latest(topic, post.whisper?) end end diff --git a/lib/post_jobs_enqueuer.rb b/lib/post_jobs_enqueuer.rb index 4809fdc1e86..2fc56b460f0 100644 --- a/lib/post_jobs_enqueuer.rb +++ b/lib/post_jobs_enqueuer.rb @@ -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