about summary refs log tree commit diff
path: root/app/serializers/rest/notification_serializer.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/serializers/rest/notification_serializer.rb')
-rw-r--r--app/serializers/rest/notification_serializer.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/app/serializers/rest/notification_serializer.rb b/app/serializers/rest/notification_serializer.rb
new file mode 100644
index 000000000..97fadf32e
--- /dev/null
+++ b/app/serializers/rest/notification_serializer.rb
@@ -0,0 +1,12 @@
+# frozen_string_literal: true
+
+class REST::NotificationSerializer < ActiveModel::Serializer
+  attributes :id, :type, :created_at
+
+  belongs_to :from_account, key: :account, serializer: REST::AccountSerializer
+  belongs_to :status, if: :status_type?,   serializer: REST::StatusSerializer
+
+  def status_type?
+    [:favourite, :reblog, :mention].include?(object.type)
+  end
+end