diff options
author | Lain Iwakura <lain@soykaf.club> | 2017-11-14 16:23:12 +0100 |
---|---|---|
committer | Lain Iwakura <lain@soykaf.club> | 2017-11-14 16:23:12 +0100 |
commit | a4dcabc11beac5e1226157baf4242ce66a831d55 (patch) | |
tree | 6b01738808452d76166d868ccd713f1a733664a8 /app/serializers | |
parent | 6cd192b9fb3dcb40a87cfb8b1bd0c5416b686a41 (diff) |
Return character limit in API and initial state.
Diffstat (limited to 'app/serializers')
-rw-r--r-- | app/serializers/initial_state_serializer.rb | 7 | ||||
-rw-r--r-- | app/serializers/rest/instance_serializer.rb | 6 |
2 files changed, 11 insertions, 2 deletions
diff --git a/app/serializers/initial_state_serializer.rb b/app/serializers/initial_state_serializer.rb index 4fa1981ed..4550b344e 100644 --- a/app/serializers/initial_state_serializer.rb +++ b/app/serializers/initial_state_serializer.rb @@ -2,10 +2,15 @@ class InitialStateSerializer < ActiveModel::Serializer attributes :meta, :compose, :accounts, - :media_attachments, :settings, :push_subscription + :media_attachments, :settings, :push_subscription, + :max_chars has_many :custom_emojis, serializer: REST::CustomEmojiSerializer + def max_chars + StatusLengthValidator::MAX_CHARS + end + def custom_emojis CustomEmoji.local.where(disabled: false) end diff --git a/app/serializers/rest/instance_serializer.rb b/app/serializers/rest/instance_serializer.rb index 2898011fd..52c161cb4 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 + :version, :urls, :stats, :thumbnail, :max_chars def uri Rails.configuration.x.local_domain @@ -30,6 +30,10 @@ class REST::InstanceSerializer < ActiveModel::Serializer full_asset_url(instance_presenter.thumbnail.file.url) if instance_presenter.thumbnail end + def max_chars + StatusLengthValidator::MAX_CHARS + end + def stats { user_count: instance_presenter.user_count, |