Add REST API for featuring and unfeaturing a hashtag (#34489)

Co-authored-by: Matt Jankowski <matt@jankowski.online>
Co-authored-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
Eugen Rochko 2025-04-25 17:12:05 +02:00 committed by GitHub
parent 49b6a49c76
commit a97647158c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 195 additions and 50 deletions

View file

@ -6,6 +6,7 @@ class REST::TagSerializer < ActiveModel::Serializer
attributes :id, :name, :url, :history
attribute :following, if: :current_user?
attribute :featuring, if: :current_user?
def id
object.id.to_s
@ -27,6 +28,14 @@ class REST::TagSerializer < ActiveModel::Serializer
end
end
def featuring
if instance_options && instance_options[:relationships]
instance_options[:relationships].featuring_map[object.id] || false
else
FeaturedTag.exists?(tag_id: object.id, account_id: current_user.account_id)
end
end
def current_user?
!current_user.nil?
end