From 3d28fb21573ded8a917602397ce0759cf50057a9 Mon Sep 17 00:00:00 2001 From: CSDUMMI Date: Sun, 4 Aug 2024 13:00:02 +0200 Subject: [PATCH] Add follow, mute and block serializer --- .../rest/admin/webhook_event_serializer.rb | 6 ++++++ app/serializers/rest/block_serializer.rb | 9 +++++++++ app/serializers/rest/follow_serializer.rb | 11 +++++++++++ app/serializers/rest/mute_serializer.rb | 10 ++++++++++ 4 files changed, 36 insertions(+) create mode 100644 app/serializers/rest/block_serializer.rb create mode 100644 app/serializers/rest/follow_serializer.rb create mode 100644 app/serializers/rest/mute_serializer.rb diff --git a/app/serializers/rest/admin/webhook_event_serializer.rb b/app/serializers/rest/admin/webhook_event_serializer.rb index b6d2616e530..99da399ab77 100644 --- a/app/serializers/rest/admin/webhook_event_serializer.rb +++ b/app/serializers/rest/admin/webhook_event_serializer.rb @@ -9,6 +9,12 @@ class REST::Admin::WebhookEventSerializer < ActiveModel::Serializer REST::Admin::ReportSerializer when 'Status' REST::StatusSerializer + when 'Follow' + REST::FollowSerializer + when 'Mute' + REST::MuteSerializer + when 'Block' + REST::BlockSerializer else super end diff --git a/app/serializers/rest/block_serializer.rb b/app/serializers/rest/block_serializer.rb new file mode 100644 index 00000000000..887237cd181 --- /dev/null +++ b/app/serializers/rest/block_serializer.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class REST::BlockSerializer < ActiveModel::Serializer + attributes :id, :created_at, :updated_at, :account_id, :target_account_id, :uri + + def id + object.id.to_s + end +end diff --git a/app/serializers/rest/follow_serializer.rb b/app/serializers/rest/follow_serializer.rb new file mode 100644 index 00000000000..f7b9c507042 --- /dev/null +++ b/app/serializers/rest/follow_serializer.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +class REST::FollowSerializer < ActiveModel::Serializer + attributes :id, :created_at, :updated_at, :account_id, + :target_account_id, :show_reblogs, :uri, + :notify, :languages + + def id + object.id.to_s + end +end diff --git a/app/serializers/rest/mute_serializer.rb b/app/serializers/rest/mute_serializer.rb new file mode 100644 index 00000000000..06d3f90af12 --- /dev/null +++ b/app/serializers/rest/mute_serializer.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +class REST::MuteSerializer < ActiveModel::Serializer + attributes :id, :created_at, :updated_at, :hide_notifications, + :account_id, :target_account_id, :expires_at + + def id + object.id.to_s + end +end