FEATURE: Topic timer for bumping a topic in the future

This commit is contained in:
David Taylor
2019-01-04 13:08:04 +00:00
parent c5b7bda198
commit 5bf16d7d10
6 changed files with 82 additions and 3 deletions

View File

@ -42,7 +42,8 @@ class TopicTimer < ActiveRecord::Base
open: 2,
publish_to_category: 3,
delete: 4,
reminder: 5
reminder: 5,
bump: 6
)
end
@ -108,6 +109,14 @@ class TopicTimer < ActiveRecord::Base
Jobs.cancel_scheduled_job(:topic_reminder, topic_timer_id: id)
end
def cancel_auto_bump_job
Jobs.cancel_scheduled_job(:bump_topic, topic_timer_id: id)
end
def schedule_auto_bump_job(time)
Jobs.enqueue_at(time, :bump_topic, topic_timer_id: id)
end
def schedule_auto_open_job(time)
return unless topic
topic.update_status('closed', true, user) if !topic.closed