Skip to content

Commit

Permalink
DEV: Move private message topic tracking state publish into sidekiq.
Browse files Browse the repository at this point in the history
Same intend as b1f32f2.
  • Loading branch information
tgxworld committed Jul 29, 2021
1 parent 543a2d7 commit c51c804
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
15 changes: 11 additions & 4 deletions app/jobs/regular/post_update_topic_tracking_state.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,21 @@ class PostUpdateTopicTrackingState < ::Jobs::Base

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

Expand Down
5 changes: 0 additions & 5 deletions lib/post_jobs_enqueuer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@ def enqueue_jobs
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
Expand Down

0 comments on commit c51c804

Please sign in to comment.