FEATURE: automatically delete replies on a topic after N days. (#9209)

This commit is contained in:
Vinoth Kannan
2020-03-19 21:06:31 +05:30
committed by GitHub
parent 0cd502a558
commit aad12822b7
16 changed files with 241 additions and 125 deletions

View File

@@ -49,7 +49,8 @@ class TopicTimer < ActiveRecord::Base
publish_to_category: 3,
delete: 4,
reminder: 5,
bump: 6
bump: 6,
delete_replies: 7
)
end
@@ -73,14 +74,6 @@ class TopicTimer < ActiveRecord::Base
end
end
def duration
if (self.execute_at && self.created_at)
((self.execute_at - self.created_at) / 1.hour).round(2)
else
0
end
end
def public_type?
!!self.class.public_types[self.status_type]
end
@@ -120,6 +113,14 @@ class TopicTimer < ActiveRecord::Base
Jobs.cancel_scheduled_job(:bump_topic, topic_timer_id: id)
end
def cancel_auto_delete_replies_job
Jobs.cancel_scheduled_job(:delete_replies, topic_timer_id: id)
end
def schedule_auto_delete_replies_job(time)
Jobs.enqueue_at(time, :delete_replies, topic_timer_id: id)
end
def schedule_auto_bump_job(time)
Jobs.enqueue_at(time, :bump_topic, topic_timer_id: id)
end