mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: automatically delete replies on a topic after N days. (#9209)
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user