Class: Jobs::PostUpdateTopicTrackingState

Inherits:
Base
  • Object
show all
Defined in:
app/jobs/regular/post_update_topic_tracking_state.rb

Instance Method Summary collapse

Methods inherited from Base

acquire_cluster_concurrency_lock!, clear_cluster_concurrency_lock!, cluster_concurrency, cluster_concurrency_redis_key, delayed_perform, #error_context, get_cluster_concurrency, #last_db_duration, #log, #perform, #perform_immediately

Instance Method Details

#execute(args) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/jobs/regular/post_update_topic_tracking_state.rb', line 5

def execute(args)
  post = Post.find_by(id: args[:post_id])
  return if !post&.topic

  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
    TopicTrackingState.publish_unmuted(post.topic)
    if post.post_number > 1
      TopicTrackingState.publish_muted(post.topic)
      TopicTrackingState.publish_unread(post)
    end
    TopicTrackingState.publish_latest(post.topic, post.whisper?)
  end
end