diff options
author | Claire <claire.github-309c@sitedethib.com> | 2022-07-17 23:10:31 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-17 23:10:31 +0200 |
commit | ab1488a6ad93f572e1d184cb9653f76fd408474f (patch) | |
tree | f1dd126f4745eb99243f390169fb957a72f5acc6 /app/serializers/rest/tag_serializer.rb | |
parent | 325ebb76b19bd20e1b76d8bc26c11cab02f6571c (diff) | |
parent | 6c0d73a675d62f676b005c06593fd69e9a7bc0e5 (diff) |
Merge pull request #1804 from ClearlyClaire/glitch-soc/merge-upstream
Merge upstream changes
Diffstat (limited to 'app/serializers/rest/tag_serializer.rb')
-rw-r--r-- | app/serializers/rest/tag_serializer.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/app/serializers/rest/tag_serializer.rb b/app/serializers/rest/tag_serializer.rb index 74aa571a4..7801e77d1 100644 --- a/app/serializers/rest/tag_serializer.rb +++ b/app/serializers/rest/tag_serializer.rb @@ -5,7 +5,25 @@ class REST::TagSerializer < ActiveModel::Serializer attributes :name, :url, :history + attribute :following, if: :current_user? + def url tag_url(object) end + + 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 |