mirror of
https://github.com/discourse/discourse.git
synced 2024-11-27 21:33:38 +08:00
4037cdb6db
We have a .ics endpoint for user bookmarks, this commit makes it so polymorphic bookmarks work on that endpoint, using the serializer associated with the RegisteredBookmarkable.
20 lines
560 B
Ruby
20 lines
560 B
Ruby
# frozen_string_literal: true
|
|
|
|
class UserBookmarkListSerializer < ApplicationSerializer
|
|
attributes :more_bookmarks_url, :bookmarks
|
|
|
|
def bookmarks
|
|
if SiteSetting.use_polymorphic_bookmarks
|
|
object.bookmarks.map do |bm|
|
|
bm.registered_bookmarkable.serializer.new(bm, scope: scope, root: false)
|
|
end
|
|
else
|
|
object.bookmarks.map { |bm| UserBookmarkSerializer.new(bm, scope: scope, root: false) }
|
|
end
|
|
end
|
|
|
|
def include_more_bookmarks_url?
|
|
@include_more_bookmarks_url ||= object.bookmarks.size == object.per_page
|
|
end
|
|
end
|