Add LIMIT of featured tag to instance API response
This commit is contained in:
parent
3702afec9f
commit
fb64791eda
2 changed files with 7 additions and 1 deletions
|
@ -26,6 +26,8 @@ class FeaturedTag < ApplicationRecord
|
||||||
|
|
||||||
attr_writer :name
|
attr_writer :name
|
||||||
|
|
||||||
|
LIMIT = 10
|
||||||
|
|
||||||
def name
|
def name
|
||||||
tag_id.present? ? tag.name : @name
|
tag_id.present? ? tag.name : @name
|
||||||
end
|
end
|
||||||
|
@ -50,7 +52,7 @@ class FeaturedTag < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def validate_featured_tags_limit
|
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
|
end
|
||||||
|
|
||||||
def validate_tag_name
|
def validate_tag_name
|
||||||
|
|
|
@ -47,6 +47,10 @@ class REST::InstanceSerializer < ActiveModel::Serializer
|
||||||
streaming: Rails.configuration.x.streaming_api_base_url,
|
streaming: Rails.configuration.x.streaming_api_base_url,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
accounts: {
|
||||||
|
max_featured_tags: FeaturedTag::LIMIT,
|
||||||
|
},
|
||||||
|
|
||||||
statuses: {
|
statuses: {
|
||||||
max_characters: StatusLengthValidator::MAX_CHARS,
|
max_characters: StatusLengthValidator::MAX_CHARS,
|
||||||
max_media_attachments: 4,
|
max_media_attachments: 4,
|
||||||
|
|
Loading…
Add table
Reference in a new issue