mirror of
https://github.com/discourse/discourse.git
synced 2024-12-02 05:29:17 -06:00
6d422a8033
The user can select what happens with a bookamrk after it expires. New option allow bookmark's reminder to be kept even after it has expired. After a bookmark's reminder notification is created, the reminder date will be highlighted in red until the user resets the reminder date. User can do that using the new Clear Reminder button from the dropdown.
28 lines
951 B
Ruby
28 lines
951 B
Ruby
# frozen_string_literal: true
|
|
|
|
module Jobs
|
|
|
|
# Runs periodically to send out bookmark reminders, capped at 300 at a time.
|
|
# Any leftovers will be caught in the next run, because the reminder_at column
|
|
# is set to NULL once a reminder has been sent.
|
|
class BookmarkReminderNotifications < ::Jobs::Scheduled
|
|
every 5.minutes
|
|
|
|
def self.max_reminder_notifications_per_run
|
|
@@max_reminder_notifications_per_run ||= 300
|
|
@@max_reminder_notifications_per_run
|
|
end
|
|
|
|
def self.max_reminder_notifications_per_run=(max)
|
|
@@max_reminder_notifications_per_run = max
|
|
end
|
|
|
|
def execute(args = nil)
|
|
bookmarks = Bookmark.pending_reminders.includes(:user).where(reminder_last_sent_at: nil).order('reminder_at ASC')
|
|
bookmarks.limit(BookmarkReminderNotifications.max_reminder_notifications_per_run).each do |bookmark|
|
|
BookmarkReminderNotificationHandler.send_notification(bookmark)
|
|
end
|
|
end
|
|
end
|
|
end
|