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:
parent
49b6a49c76
commit
a97647158c
15 changed files with 195 additions and 50 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue