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