mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 06:29:30 +08:00
fcc2e7ebbf
This commit migrates all bookmarks to be polymorphic (using the bookmarkable_id and bookmarkable_type) columns. It also deletes all the old code guarded behind the use_polymorphic_bookmarks setting and changes that setting to true for all sites and by default for the sake of plugins. No data is deleted in the migrations, the old post_id and for_topic columns for bookmarks will be dropped later on.
41 lines
907 B
Ruby
41 lines
907 B
Ruby
# frozen_string_literal: true
|
|
|
|
class BookmarkReminderNotificationHandler
|
|
attr_reader :bookmark
|
|
|
|
def initialize(bookmark)
|
|
@bookmark = bookmark
|
|
end
|
|
|
|
def send_notification
|
|
return if bookmark.blank?
|
|
Bookmark.transaction do
|
|
if !bookmark.registered_bookmarkable.can_send_reminder?(bookmark)
|
|
clear_reminder
|
|
else
|
|
bookmark.registered_bookmarkable.send_reminder_notification(bookmark)
|
|
|
|
if bookmark.auto_delete_when_reminder_sent?
|
|
BookmarkManager.new(bookmark.user).destroy(bookmark.id)
|
|
end
|
|
|
|
clear_reminder
|
|
end
|
|
end
|
|
end
|
|
|
|
private
|
|
|
|
def clear_reminder
|
|
Rails.logger.debug(
|
|
"Clearing bookmark reminder for bookmark_id #{bookmark.id}. reminder at: #{bookmark.reminder_at}"
|
|
)
|
|
|
|
if bookmark.auto_clear_reminder_when_reminder_sent?
|
|
bookmark.reminder_at = nil
|
|
end
|
|
|
|
bookmark.clear_reminder!
|
|
end
|
|
end
|