about summary refs log tree commit diff
path: root/app/serializers/rest
diff options
context:
space:
mode:
authorThibaut Girka <thib@sitedethib.com>2019-09-13 18:13:43 +0200
committerThibaut Girka <thib@sitedethib.com>2019-09-13 18:13:43 +0200
commit74c5b2bd08f844aac03ca6f9653bac4f4eea3a43 (patch)
treeef0f56bc549ae22b134c749decadbd69f783b7e4 /app/serializers/rest
parentc7f71b974f1a57cd93f86e5a678018d4aea8e728 (diff)
parent18331fefa2246facc818226043b1f9cc67cf6c1a (diff)
Merge branch 'master' into glitch-soc/merge-upstream
Conflicts:
- Gemfile
- app/controllers/api/v1/search_controller.rb
  Conflict because we changed the number of default results to be
  configurable
- app/lib/settings/scoped_settings.rb
  Addition of a new “noindex” site-wide setting,
  conflict due to our change of the two other site-wide settings
  (default flavour and skin instead of theme)
- spec/controllers/application_controller_spec.rb
  Addition of a new “noindex” site-wide setting,
  conflict due to our change of the two other site-wide settings
  (default flavour and skin instead of theme)
Diffstat (limited to 'app/serializers/rest')
-rw-r--r--app/serializers/rest/featured_tag_serializer.rb9
-rw-r--r--app/serializers/rest/marker_serializer.rb13
-rw-r--r--app/serializers/rest/search_serializer.rb7
-rw-r--r--app/serializers/rest/v2/search_serializer.rb7
4 files changed, 23 insertions, 13 deletions
diff --git a/app/serializers/rest/featured_tag_serializer.rb b/app/serializers/rest/featured_tag_serializer.rb
new file mode 100644
index 000000000..08121ff16
--- /dev/null
+++ b/app/serializers/rest/featured_tag_serializer.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class REST::FeaturedTagSerializer < ActiveModel::Serializer
+  attributes :id, :name, :statuses_count, :last_status_at
+
+  def id
+    object.id.to_s
+  end
+end
diff --git a/app/serializers/rest/marker_serializer.rb b/app/serializers/rest/marker_serializer.rb
new file mode 100644
index 000000000..2eaf3d507
--- /dev/null
+++ b/app/serializers/rest/marker_serializer.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+class REST::MarkerSerializer < ActiveModel::Serializer
+  attributes :last_read_id, :version, :updated_at
+
+  def last_read_id
+    object.last_read_id.to_s
+  end
+
+  def version
+    object.lock_version
+  end
+end
diff --git a/app/serializers/rest/search_serializer.rb b/app/serializers/rest/search_serializer.rb
index 157f543ae..ee9b421eb 100644
--- a/app/serializers/rest/search_serializer.rb
+++ b/app/serializers/rest/search_serializer.rb
@@ -1,12 +1,7 @@
 # frozen_string_literal: true
 
 class REST::SearchSerializer < ActiveModel::Serializer
-  attributes :hashtags
-
   has_many :accounts, serializer: REST::AccountSerializer
   has_many :statuses, serializer: REST::StatusSerializer
-
-  def hashtags
-    object.hashtags.map(&:name)
-  end
+  has_many :hashtags, serializer: REST::TagSerializer
 end
diff --git a/app/serializers/rest/v2/search_serializer.rb b/app/serializers/rest/v2/search_serializer.rb
deleted file mode 100644
index cdb6b3a53..000000000
--- a/app/serializers/rest/v2/search_serializer.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-# frozen_string_literal: true
-
-class REST::V2::SearchSerializer < ActiveModel::Serializer
-  has_many :accounts, serializer: REST::AccountSerializer
-  has_many :statuses, serializer: REST::StatusSerializer
-  has_many :hashtags, serializer: REST::TagSerializer
-end