From 8331fdf7e0ea85ecc6d7dbff00b784bb6aa1f7d4 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Sun, 21 Feb 2021 19:50:12 +0100 Subject: Add server rules (#15769) --- app/serializers/rest/instance_serializer.rb | 4 +++- app/serializers/rest/rule_serializer.rb | 9 +++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 app/serializers/rest/rule_serializer.rb (limited to 'app/serializers/rest') diff --git a/app/serializers/rest/instance_serializer.rb b/app/serializers/rest/instance_serializer.rb index b388e448e..d39092b56 100644 --- a/app/serializers/rest/instance_serializer.rb +++ b/app/serializers/rest/instance_serializer.rb @@ -9,7 +9,9 @@ class REST::InstanceSerializer < ActiveModel::Serializer has_one :contact_account, serializer: REST::AccountSerializer - delegate :contact_account, to: :instance_presenter + has_many :rules, serializer: REST::RuleSerializer + + delegate :contact_account, :rules, to: :instance_presenter def uri Rails.configuration.x.local_domain diff --git a/app/serializers/rest/rule_serializer.rb b/app/serializers/rest/rule_serializer.rb new file mode 100644 index 000000000..fc925925a --- /dev/null +++ b/app/serializers/rest/rule_serializer.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class REST::RuleSerializer < ActiveModel::Serializer + attributes :id, :text + + def id + object.id.to_s + end +end -- cgit