FEATURE: Polymorphic bookmarks pt. 3 (reminders, imports, exports, refactors) (#16591)

A bit of a mixed bag, this addresses several edge areas of bookmarks and makes them compatible with polymorphic bookmarks (hidden behind the `use_polymorphic_bookmarks` site setting). The main ones are:

* ExportUserArchive compatibility
* SyncTopicUserBookmarked job compatibility
* Sending different notifications for the bookmark reminders based on the bookmarkable type
* Import scripts compatibility
* BookmarkReminderNotificationHandler compatibility

This PR also refactors the `register_bookmarkable` API so it accepts a class descended from a `BaseBookmarkable` class instead. This was done because we kept having to add more and more lambdas/properties inline and it was very messy, so a factory pattern is cleaner. The classes can be tested independently as well.

Some later PRs will address some other areas like the discourse narrative bot, advanced search, reports, and the .ics endpoint for bookmarks.
This commit is contained in:
Martin Brennan
2022-05-09 09:37:23 +10:00
committed by GitHub
parent c99a6b10fb
commit 222c8d9b6a
33 changed files with 880 additions and 271 deletions

View File

@ -243,6 +243,7 @@ module DiscourseNarrativeBot
post
end
# TODO (martin) [POLYBOOK] Fix up narrative bot bookmark interactions in a separate PR.
def missing_bookmark
return unless valid_topic?(@post.topic_id)
return if @post.user_id == self.discobot_user.id
@ -253,6 +254,7 @@ module DiscourseNarrativeBot
false
end
# TODO (martin) [POLYBOOK] Fix up narrative bot bookmark interactions in a separate PR.
def reply_to_bookmark
return unless valid_topic?(@post.topic_id)
return unless @post.user_id == self.discobot_user.id