Revert "Temporarily undo tag_serializer changes due to an error"

This reverts commit dc03059a7b.
This commit is contained in:
Jeremy Kescher 2022-07-18 06:48:08 +02:00
parent dc03059a7b
commit 92268f5da7
No known key found for this signature in database
GPG key ID: 48DFE4BB15BA5940

View file

@ -5,6 +5,8 @@ class REST::TagSerializer < ActiveModel::Serializer
attributes :name, :url, :history
attribute :following, if: :current_user?
def url
tag_url(object)
end
@ -12,4 +14,16 @@ class REST::TagSerializer < ActiveModel::Serializer
def name
object.display_name
end
def following
if instance_options && instance_options[:relationships]
instance_options[:relationships].following_map[object.id] || false
else
TagFollow.where(tag_id: object.id, account_id: current_user.account_id).exists?
end
end
def current_user?
!current_user.nil?
end
end