about summary refs log tree commit diff
path: root/app/serializers
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2022-06-27 09:30:15 +0200
committerGitHub <noreply@github.com>2022-06-27 09:30:15 +0200
commit2936f42a14cfdca70d4a9653dab29382315945e7 (patch)
tree182a6660f1d8304ad893582732fb85db00e250aa /app/serializers
parent602f291da9f4fa157233b29dc6ac96e784203c98 (diff)
Add notifications for new reports (#18697)
Diffstat (limited to 'app/serializers')
-rw-r--r--app/serializers/rest/admin/report_serializer.rb2
-rw-r--r--app/serializers/rest/notification_serializer.rb5
-rw-r--r--app/serializers/rest/report_serializer.rb5
3 files changed, 10 insertions, 2 deletions
diff --git a/app/serializers/rest/admin/report_serializer.rb b/app/serializers/rest/admin/report_serializer.rb
index 237f41d8e..44b4726e4 100644
--- a/app/serializers/rest/admin/report_serializer.rb
+++ b/app/serializers/rest/admin/report_serializer.rb
@@ -2,7 +2,7 @@
 
 class REST::Admin::ReportSerializer < ActiveModel::Serializer
   attributes :id, :action_taken, :action_taken_at, :category, :comment,
-             :created_at, :updated_at
+             :forwarded, :created_at, :updated_at
 
   has_one :account, serializer: REST::Admin::AccountSerializer
   has_one :target_account, serializer: REST::Admin::AccountSerializer
diff --git a/app/serializers/rest/notification_serializer.rb b/app/serializers/rest/notification_serializer.rb
index 69b81f6de..137fc53dd 100644
--- a/app/serializers/rest/notification_serializer.rb
+++ b/app/serializers/rest/notification_serializer.rb
@@ -5,6 +5,7 @@ class REST::NotificationSerializer < ActiveModel::Serializer
 
   belongs_to :from_account, key: :account, serializer: REST::AccountSerializer
   belongs_to :target_status, key: :status, if: :status_type?, serializer: REST::StatusSerializer
+  belongs_to :report, if: :report_type?, serializer: REST::ReportSerializer
 
   def id
     object.id.to_s
@@ -13,4 +14,8 @@ class REST::NotificationSerializer < ActiveModel::Serializer
   def status_type?
     [:favourite, :reblog, :status, :mention, :poll, :update].include?(object.type)
   end
+
+  def report_type?
+    object.type == :'admin.report'
+  end
 end
diff --git a/app/serializers/rest/report_serializer.rb b/app/serializers/rest/report_serializer.rb
index ecb88d653..de68dfc6d 100644
--- a/app/serializers/rest/report_serializer.rb
+++ b/app/serializers/rest/report_serializer.rb
@@ -1,7 +1,10 @@
 # frozen_string_literal: true
 
 class REST::ReportSerializer < ActiveModel::Serializer
-  attributes :id, :action_taken
+  attributes :id, :action_taken, :action_taken_at, :category, :comment,
+             :forwarded, :created_at, :status_ids, :rule_ids
+
+  has_one :target_account, serializer: REST::AccountSerializer
 
   def id
     object.id.to_s