2021-01-11 15:58:27 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Jobs
|
|
|
|
class PostUpdateTopicTrackingState < ::Jobs::Base
|
|
|
|
|
|
|
|
def execute(args)
|
|
|
|
post = Post.find_by(id: args[:post_id])
|
2021-07-29 02:48:37 -04:00
|
|
|
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)
|
2021-01-11 15:58:27 -05:00
|
|
|
|
|
|
|
if post.post_number > 1
|
2021-07-29 02:48:37 -04:00
|
|
|
TopicTrackingState.publish_muted(topic)
|
2021-01-11 15:58:27 -05:00
|
|
|
TopicTrackingState.publish_unread(post)
|
|
|
|
end
|
2021-07-29 02:48:37 -04:00
|
|
|
|
|
|
|
TopicTrackingState.publish_latest(topic, post.whisper?)
|
2021-01-11 15:58:27 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|