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