Add LIMIT of featured tag to instance API response

This commit is contained in:
noellabo 2022-10-14 22:45:00 +09:00
parent 3702afec9f
commit fb64791eda
2 changed files with 7 additions and 1 deletions

View file

@ -26,6 +26,8 @@ class FeaturedTag < ApplicationRecord
attr_writer :name
LIMIT = 10
def name
tag_id.present? ? tag.name : @name
end
@ -50,7 +52,7 @@ class FeaturedTag < ApplicationRecord
end
def validate_featured_tags_limit
errors.add(:base, I18n.t('featured_tags.errors.limit')) if account.featured_tags.count >= 10
errors.add(:base, I18n.t('featured_tags.errors.limit')) if account.featured_tags.count >= LIMIT
end
def validate_tag_name

View file

@ -47,6 +47,10 @@ class REST::InstanceSerializer < ActiveModel::Serializer
streaming: Rails.configuration.x.streaming_api_base_url,
},
accounts: {
max_featured_tags: FeaturedTag::LIMIT,
},
statuses: {
max_characters: StatusLengthValidator::MAX_CHARS,
max_media_attachments: 4,