mirror of
https://github.com/discourse/discourse.git
synced 2024-12-21 09:13:44 +08:00
e58e7a49f5
Followup 76c56c8284
The change introduced above made it so the expired
bookmark reminders were cleared when using the bulk
action menu for bookmarks. However this also affected
clearing reminders for bookmarks when sending notifications.
When clearing bookmark reminders after sending notifications,
we take into account the auto delete preference:
* never - The bookmark `reminder_at` date should not be cleared,
and the bookmark is kept.
* clear_reminder - The bookmark `reminder_at` date is cleared and
the bookmark is kept
The `never` option made it so "expired" bookmark reminder show
on the user's bookmark list.
This commit fixes the change from the other commit and only
forces clearing of `reminder_at` if using the bookmark bulk
action service.
27 lines
626 B
Ruby
27 lines
626 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.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
|
|
|
|
bookmark.clear_reminder!
|
|
end
|
|
end
|
|
end
|
|
end
|