diff options
author | Thibaut Girka <thib@sitedethib.com> | 2019-03-06 13:36:09 +0100 |
---|---|---|
committer | ThibG <thib@sitedethib.com> | 2019-03-06 23:56:53 +0100 |
commit | 3b1390dc789b52cf570a179daf50d4cb8afbfbcd (patch) | |
tree | afb84c3449f4322f4971263b36aad33fc1b7568e /app/serializers | |
parent | 8fe86cebaa30e77e50c8223a1ff83759dbd7ca62 (diff) |
Serialize poll limits in instance serializer and initial state
Diffstat (limited to 'app/serializers')
-rw-r--r-- | app/serializers/initial_state_serializer.rb | 11 | ||||
-rw-r--r-- | app/serializers/rest/instance_serializer.rb | 11 |
2 files changed, 20 insertions, 2 deletions
diff --git a/app/serializers/initial_state_serializer.rb b/app/serializers/initial_state_serializer.rb index 19817e89e..3b07093bf 100644 --- a/app/serializers/initial_state_serializer.rb +++ b/app/serializers/initial_state_serializer.rb @@ -3,7 +3,7 @@ class InitialStateSerializer < ActiveModel::Serializer attributes :meta, :compose, :accounts, :media_attachments, :settings, - :max_toot_chars + :max_toot_chars, :poll_limits has_one :push_subscription, serializer: REST::WebPushSubscriptionSerializer @@ -11,6 +11,15 @@ class InitialStateSerializer < ActiveModel::Serializer StatusLengthValidator::MAX_CHARS end + def poll_limits + { + max_options: PollValidator::MAX_OPTIONS, + max_option_chars: PollValidator::MAX_OPTION_CHARS, + min_expiration: PollValidator::MAX_EXPIRATION, + max_expiration: PollValidator::MIN_EXPIRATION, + } + end + def meta store = { streaming_api_base_url: Rails.configuration.x.streaming_api_base_url, diff --git a/app/serializers/rest/instance_serializer.rb b/app/serializers/rest/instance_serializer.rb index 41ed1995d..9547ba735 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, :description, :email, - :version, :urls, :stats, :thumbnail, :max_toot_chars, + :version, :urls, :stats, :thumbnail, :max_toot_chars, :poll_limits, :languages, :registrations has_one :contact_account, serializer: REST::AccountSerializer @@ -39,6 +39,15 @@ class REST::InstanceSerializer < ActiveModel::Serializer StatusLengthValidator::MAX_CHARS end + def poll_limits + { + max_options: PollValidator::MAX_OPTIONS, + max_option_chars: PollValidator::MAX_OPTION_CHARS, + min_expiration: PollValidator::MAX_EXPIRATION, + max_expiration: PollValidator::MIN_EXPIRATION, + } + end + def stats { user_count: instance_presenter.user_count, |