2019-05-03 06:17:27 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-05-12 00:52:15 +08:00
|
|
|
module Jobs
|
2021-01-19 11:30:58 +08:00
|
|
|
class DeleteTopic < ::Jobs::TopicTimerBase
|
|
|
|
def execute_timer_action(topic_timer, topic)
|
2017-05-12 06:23:18 +08:00
|
|
|
if Guardian.new(topic_timer.user).can_delete?(topic)
|
2017-05-12 00:52:15 +08:00
|
|
|
first_post = topic.ordered_posts.first
|
2021-01-19 11:30:58 +08:00
|
|
|
|
|
|
|
PostDestroyer.new(
|
|
|
|
topic_timer.user, first_post, context: I18n.t("topic_statuses.auto_deleted_by_timer")
|
|
|
|
).destroy
|
|
|
|
|
2017-05-12 10:28:51 +08:00
|
|
|
topic_timer.trash!(Discourse.system_user)
|
2017-05-12 00:52:15 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2017-05-12 06:23:18 +08:00
|
|
|
end
|