FEATURE: Automatically timed delete stub topics after entire topic is merged into another topic (#13187)

When a topic is fully merged into another topic we close it. Now we want also to set a timer for deleting this topic. By default, stub topics will be deleted in 7 days. Users can change this period or disable auto-deleting by setting the period to 0.
This commit is contained in:
Andrei Prigorshnev
2021-05-28 17:33:10 +04:00
committed by GitHub
parent 47e09700fe
commit 74f7150324
4 changed files with 70 additions and 3 deletions

View File

@@ -79,7 +79,7 @@ class PostMover
update_bookmarks
if moving_all_posts
@original_topic.update_status('closed', true, @user)
close_topic_and_schedule_deletion
end
destination_topic.reload
@@ -546,4 +546,17 @@ class PostMover
topic_id: topic.id
)
end
def close_topic_and_schedule_deletion
@original_topic.update_status('closed', true, @user)
days_to_deleting = SiteSetting.delete_merged_stub_topics_after_days
if days_to_deleting > 0
@original_topic.set_or_create_timer(
TopicTimer.types[:delete],
days_to_deleting * 24,
by_user: @user
)
end
end
end