about summary refs log tree commit diff
path: root/app/serializers/rest
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2022-06-10 11:51:43 +0200
committerClaire <claire.github-309c@sitedethib.com>2022-06-10 11:51:43 +0200
commitedaaf6a5e9ac1d7ffa51488e122d1dbbf267ab33 (patch)
treee7b389ba7f0fbd64554ef5859fcaa464922c4e05 /app/serializers/rest
parent3d841eba69b340aac4f012fb388f9e9761ec2ba5 (diff)
parenta2871cd74719a7a5a104daaa3dcc0e2670b7c2df (diff)
Merge branch 'main' into glitch-soc/merge-upstream
Diffstat (limited to 'app/serializers/rest')
-rw-r--r--app/serializers/rest/admin/report_serializer.rb3
-rw-r--r--app/serializers/rest/admin/webhook_event_serializer.rb26
2 files changed, 28 insertions, 1 deletions
diff --git a/app/serializers/rest/admin/report_serializer.rb b/app/serializers/rest/admin/report_serializer.rb
index 74bc0c520..237f41d8e 100644
--- a/app/serializers/rest/admin/report_serializer.rb
+++ b/app/serializers/rest/admin/report_serializer.rb
@@ -1,7 +1,8 @@
 # frozen_string_literal: true
 
 class REST::Admin::ReportSerializer < ActiveModel::Serializer
-  attributes :id, :action_taken, :category, :comment, :created_at, :updated_at
+  attributes :id, :action_taken, :action_taken_at, :category, :comment,
+             :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/admin/webhook_event_serializer.rb b/app/serializers/rest/admin/webhook_event_serializer.rb
new file mode 100644
index 000000000..fe0ac23f9
--- /dev/null
+++ b/app/serializers/rest/admin/webhook_event_serializer.rb
@@ -0,0 +1,26 @@
+# frozen_string_literal: true
+
+class REST::Admin::WebhookEventSerializer < ActiveModel::Serializer
+  def self.serializer_for(model, options)
+    case model.class.name
+    when 'Account'
+      REST::Admin::AccountSerializer
+    when 'Report'
+      REST::Admin::ReportSerializer
+    else
+      super
+    end
+  end
+
+  attributes :event, :created_at
+
+  has_one :virtual_object, key: :object
+
+  def virtual_object
+    object.object
+  end
+
+  def event
+    object.type
+  end
+end