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-08-24 23:17:56 -04:00
|
|
|
return if !post&.topic
|
2021-01-11 15:58:27 -05:00
|
|
|
|
2021-08-24 23:17:56 -04:00
|
|
|
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
|
2021-07-29 23:31:36 -04:00
|
|
|
TopicTrackingState.publish_unmuted(post.topic)
|
2021-01-11 15:58:27 -05:00
|
|
|
if post.post_number > 1
|
2021-07-29 23:31:36 -04:00
|
|
|
TopicTrackingState.publish_muted(post.topic)
|
2021-01-11 15:58:27 -05:00
|
|
|
TopicTrackingState.publish_unread(post)
|
|
|
|
end
|
2021-07-29 23:31:36 -04:00
|
|
|
TopicTrackingState.publish_latest(post.topic, post.whisper?)
|
2021-01-11 15:58:27 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|