mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: Promote polymorphic bookmarks to default and migrate (#16729)
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.
This commit is contained in:
@@ -369,18 +369,10 @@ class PostSerializer < BasicPostSerializer
|
||||
end
|
||||
|
||||
def post_bookmark
|
||||
if SiteSetting.use_polymorphic_bookmarks
|
||||
if @topic_view.present?
|
||||
@post_bookmark ||= @topic_view.bookmarks.find { |bookmark| bookmark.bookmarkable == object }
|
||||
else
|
||||
@post_bookmark ||= Bookmark.find_by(user: scope.user, bookmarkable: object)
|
||||
end
|
||||
if @topic_view.present?
|
||||
@post_bookmark ||= @topic_view.bookmarks.find { |bookmark| bookmark.bookmarkable == object }
|
||||
else
|
||||
if @topic_view.present?
|
||||
@post_bookmark ||= @topic_view.bookmarks.find { |bookmark| bookmark.post_id == object.id && !bookmark.for_topic }
|
||||
else
|
||||
@post_bookmark ||= object.bookmarks.find_by(user: scope.user, for_topic: false)
|
||||
end
|
||||
@post_bookmark ||= Bookmark.find_by(user: scope.user, bookmarkable: object)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user