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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user