diff options
Diffstat (limited to 'app/serializers')
-rw-r--r-- | app/serializers/activitypub/flag_serializer.rb | 27 | ||||
-rw-r--r-- | app/serializers/initial_state_serializer.rb | 1 | ||||
-rw-r--r-- | app/serializers/rest/instance_serializer.rb | 11 |
3 files changed, 38 insertions, 1 deletions
diff --git a/app/serializers/activitypub/flag_serializer.rb b/app/serializers/activitypub/flag_serializer.rb new file mode 100644 index 000000000..53e8f726d --- /dev/null +++ b/app/serializers/activitypub/flag_serializer.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +class ActivityPub::FlagSerializer < ActiveModel::Serializer + attributes :id, :type, :actor, :content + attribute :virtual_object, key: :object + + def id + # This is nil for now + ActivityPub::TagManager.instance.uri_for(object) + end + + def type + 'Flag' + end + + def actor + ActivityPub::TagManager.instance.uri_for(instance_options[:account] || object.account) + end + + def virtual_object + [ActivityPub::TagManager.instance.uri_for(object.target_account)] + object.statuses.map { |s| ActivityPub::TagManager.instance.uri_for(s) } + end + + def content + object.comment + end +end diff --git a/app/serializers/initial_state_serializer.rb b/app/serializers/initial_state_serializer.rb index 5434f1c56..1d17e2b0a 100644 --- a/app/serializers/initial_state_serializer.rb +++ b/app/serializers/initial_state_serializer.rb @@ -22,6 +22,7 @@ class InitialStateSerializer < ActiveModel::Serializer locale: I18n.locale, domain: Rails.configuration.x.local_domain, admin: object.admin&.id&.to_s, + search_enabled: Chewy.enabled?, } if object.current_account diff --git a/app/serializers/rest/instance_serializer.rb b/app/serializers/rest/instance_serializer.rb index 65907dad2..0168b18ea 100644 --- a/app/serializers/rest/instance_serializer.rb +++ b/app/serializers/rest/instance_serializer.rb @@ -4,7 +4,12 @@ class REST::InstanceSerializer < ActiveModel::Serializer include RoutingHelper attributes :uri, :title, :description, :email, - :version, :urls, :stats, :thumbnail, :max_toot_chars + :version, :urls, :stats, :thumbnail, :max_toot_chars, + :languages + + has_one :contact_account, serializer: REST::AccountSerializer + + delegate :contact_account, to: :instance_presenter def uri Rails.configuration.x.local_domain @@ -46,6 +51,10 @@ class REST::InstanceSerializer < ActiveModel::Serializer { streaming_api: Rails.configuration.x.streaming_api_base_url } end + def languages + [ENV.fetch('DEFAULT_LOCALE', I18n.default_locale)] + end + private def instance_presenter |