diff options
Diffstat (limited to 'app/serializers/rest')
-rw-r--r-- | app/serializers/rest/account_serializer.rb | 4 | ||||
-rw-r--r-- | app/serializers/rest/instance_serializer.rb | 15 | ||||
-rw-r--r-- | app/serializers/rest/mute_serializer.rb | 15 | ||||
-rw-r--r-- | app/serializers/rest/status_serializer.rb | 2 |
4 files changed, 35 insertions, 1 deletions
diff --git a/app/serializers/rest/account_serializer.rb b/app/serializers/rest/account_serializer.rb index a78ec4507..36886181f 100644 --- a/app/serializers/rest/account_serializer.rb +++ b/app/serializers/rest/account_serializer.rb @@ -63,6 +63,10 @@ class REST::AccountSerializer < ActiveModel::Serializer object.last_status_at&.to_date&.iso8601 end + def followers_count + (Setting.hide_followers_count || object.user&.setting_hide_followers_count) ? -1 : object.followers_count + end + def display_name object.suspended? ? '' : object.display_name end diff --git a/app/serializers/rest/instance_serializer.rb b/app/serializers/rest/instance_serializer.rb index d39092b56..ae8b80fb7 100644 --- a/app/serializers/rest/instance_serializer.rb +++ b/app/serializers/rest/instance_serializer.rb @@ -4,7 +4,7 @@ class REST::InstanceSerializer < ActiveModel::Serializer include RoutingHelper attributes :uri, :title, :short_description, :description, :email, - :version, :urls, :stats, :thumbnail, + :version, :urls, :stats, :thumbnail, :max_toot_chars, :poll_limits, :languages, :registrations, :approval_required, :invites_enabled has_one :contact_account, serializer: REST::AccountSerializer @@ -41,6 +41,19 @@ class REST::InstanceSerializer < ActiveModel::Serializer instance_presenter.thumbnail ? full_asset_url(instance_presenter.thumbnail.file.url) : full_pack_url('media/images/preview.jpg') end + def max_toot_chars + StatusLengthValidator::MAX_CHARS + end + + def poll_limits + { + max_options: PollValidator::MAX_OPTIONS, + max_option_chars: PollValidator::MAX_OPTION_CHARS, + min_expiration: PollValidator::MIN_EXPIRATION, + max_expiration: PollValidator::MAX_EXPIRATION, + } + end + def stats { user_count: instance_presenter.user_count, diff --git a/app/serializers/rest/mute_serializer.rb b/app/serializers/rest/mute_serializer.rb new file mode 100644 index 000000000..043a2f059 --- /dev/null +++ b/app/serializers/rest/mute_serializer.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class REST::MuteSerializer < ActiveModel::Serializer + include RoutingHelper + + attributes :id, :account, :target_account, :created_at, :hide_notifications + + def account + REST::AccountSerializer.new(object.account) + end + + def target_account + REST::AccountSerializer.new(object.target_account) + end +end \ No newline at end of file diff --git a/app/serializers/rest/status_serializer.rb b/app/serializers/rest/status_serializer.rb index bb6df90b7..b5dcf6208 100644 --- a/app/serializers/rest/status_serializer.rb +++ b/app/serializers/rest/status_serializer.rb @@ -11,9 +11,11 @@ class REST::StatusSerializer < ActiveModel::Serializer attribute :muted, if: :current_user? attribute :bookmarked, if: :current_user? attribute :pinned, if: :pinnable? + attribute :local_only if :local? attribute :content, unless: :source_requested? attribute :text, if: :source_requested? + attribute :content_type, if: :source_requested? belongs_to :reblog, serializer: REST::StatusSerializer belongs_to :application, if: :show_application? |