diff options
author | beatrix <beatrix.bitrot@gmail.com> | 2018-03-03 13:40:00 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-03 13:40:00 -0500 |
commit | 43a9a781a443a6b9296431fbcc4285b3ca6a1a57 (patch) | |
tree | d4bf067aeedcebbdc3d160eca6aa1a7c7d1bfa00 /app/serializers | |
parent | ee00da01d2e4cc455b92f1f4a7c9142c73048433 (diff) | |
parent | 65e2a4645e086110072efed5b3d4d1434c933e04 (diff) |
Merge pull request #377 from glitch-soc/merge-upstream
hhhhhhhhhnnnnnnnnnnnghh!!!!!
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 |