2021-01-12 04:58:27 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Jobs
|
|
|
|
class PostUpdateTopicTrackingState < ::Jobs::Base
|
|
|
|
def execute(args)
|
|
|
|
post = Post.find_by(id: args[:post_id])
|
2021-08-25 11:17:56 +08:00
|
|
|
return if !post&.topic
|
2021-01-12 04:58:27 +08:00
|
|
|
|
2021-08-25 11:17:56 +08:00
|
|
|
topic = post.topic
|
|
|
|
|
|
|
|
if topic.private_message?
|
|
|
|
PrivateMessageTopicTrackingState.publish_unread(post) if post.post_number > 1
|
|
|
|
|
|
|
|
TopicGroup.new_message_update(topic.last_poster, topic.id, post.post_number)
|
|
|
|
else
|
2021-07-30 11:31:36 +08:00
|
|
|
TopicTrackingState.publish_unmuted(post.topic)
|
2021-01-12 04:58:27 +08:00
|
|
|
if post.post_number > 1
|
2021-07-30 11:31:36 +08:00
|
|
|
TopicTrackingState.publish_muted(post.topic)
|
2021-01-12 04:58:27 +08:00
|
|
|
TopicTrackingState.publish_unread(post)
|
|
|
|
end
|
2021-07-30 11:31:36 +08:00
|
|
|
TopicTrackingState.publish_latest(post.topic, post.whisper?)
|
2021-01-12 04:58:27 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|