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-07-30 11:31:36 +08:00
|
|
|
if post && post.topic
|
|
|
|
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
|