discourse/lib/bookmark_reminder_notification_handler.rb
Régis Hanol ca3a2d2c88
FIX: don't clear reminder on deleted bookmarks (#35987)
When sending a bookmark notification and the user has opted to
automatically delete the bookmark, we should not be trying to clear the
reminder since the bookmark was just deleted.

Internal ref - t/146349
2025-11-12 17:47:07 +01:00

27 lines
640 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)
bookmark.registered_bookmarkable.send_reminder_notification(bookmark)
if bookmark.auto_delete_when_reminder_sent?
BookmarkManager.new(bookmark.user).destroy(bookmark.id)
else
bookmark.clear_reminder!
end
else
bookmark.clear_reminder!
end
end
end
end