mirror of
https://github.com/mastodon/mastodon.git
synced 2024-12-24 09:57:27 +00:00
Add LIMIT of featured tag to instance API response
This commit is contained in:
parent
3702afec9f
commit
fb64791eda
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue