Class: Jobs::DeleteTopic

Inherits:
TopicTimerBase show all
Defined in:
app/jobs/regular/delete_topic.rb

Instance Method Summary collapse

Methods inherited from TopicTimerBase

#execute

Methods inherited from Base

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

Instance Method Details

#execute_timer_action(topic_timer, topic) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'app/jobs/regular/delete_topic.rb', line 5

def execute_timer_action(topic_timer, topic)
  if Guardian.new(topic_timer.user).can_delete?(topic)
    first_post = topic.ordered_posts.first

    PostDestroyer.new(
      topic_timer.user,
      first_post,
      context: I18n.t("topic_statuses.auto_deleted_by_timer"),
    ).destroy

    topic_timer.trash!(Discourse.system_user)
  end
end