about summary refs log tree commit diff
path: root/app/serializers/rest
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2022-07-17 22:07:20 +0200
committerClaire <claire.github-309c@sitedethib.com>2022-07-17 22:07:20 +0200
commitcd87d7dcef814ad86fb15334680cb0e3232437a9 (patch)
tree63db8838568ea440bb3cb9797cdbaf5c4952e9e7 /app/serializers/rest
parent9094c2f52c24e1c00b594e7c11cd00e4a07eb431 (diff)
parentc3f0621a59a74d0e20e6db6170894871c48e8f0f (diff)
Merge branch 'main' into glitch-soc/merge-upstream
- `.env.production.sample`:
  Our sample config file is very different from upstream since it is much more
  complete. Upstream added documentation for a few env variables.
  Copied the new variables/documentation from upstream.
- `app/lib/feed_manager.rb`:
  Upstream added a timeline type (hashtags), while glitch-soc already had an
  extra one (direct messages). Not really a conflict but textually close
  changes.
  Ported upstream's changes.
- `app/models/custom_emoji.rb`:
  Upstream upped the custom emoji size limit, while glitch-soc had configurable
  limits.
  Upped the default limits accordingly.
- `streaming/index.js`:
  Upstream reworked how hastags were normalized. Minor conflict due to
  glitch-soc's handling of instance-local posts.
  Ported upstream's changes.
Diffstat (limited to 'app/serializers/rest')
-rw-r--r--app/serializers/rest/featured_tag_serializer.rb4
-rw-r--r--app/serializers/rest/tag_serializer.rb18
2 files changed, 22 insertions, 0 deletions
diff --git a/app/serializers/rest/featured_tag_serializer.rb b/app/serializers/rest/featured_tag_serializer.rb
index 96adcc7d0..8abcd9b90 100644
--- a/app/serializers/rest/featured_tag_serializer.rb
+++ b/app/serializers/rest/featured_tag_serializer.rb
@@ -12,4 +12,8 @@ class REST::FeaturedTagSerializer < ActiveModel::Serializer
   def url
     short_account_tag_url(object.account, object.tag)
   end
+
+  def name
+    object.display_name
+  end
 end
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