mirror of
https://github.com/mastodon/mastodon
synced 2024-11-23 22:56:20 +09:00
Use existing DEFAULT_FIELDS_SIZE
constant to limit Account#fields
(#29911)
This commit is contained in:
parent
5992df0762
commit
13bbde2246
@ -64,6 +64,7 @@ class Account < ApplicationRecord
|
|||||||
)
|
)
|
||||||
|
|
||||||
BACKGROUND_REFRESH_INTERVAL = 1.week.freeze
|
BACKGROUND_REFRESH_INTERVAL = 1.week.freeze
|
||||||
|
DEFAULT_FIELDS_SIZE = 4
|
||||||
INSTANCE_ACTOR_ID = -99
|
INSTANCE_ACTOR_ID = -99
|
||||||
|
|
||||||
USERNAME_RE = /[a-z0-9_]+([a-z0-9_.-]+[a-z0-9_]+)?/i
|
USERNAME_RE = /[a-z0-9_]+([a-z0-9_.-]+[a-z0-9_]+)?/i
|
||||||
@ -103,7 +104,7 @@ class Account < ApplicationRecord
|
|||||||
validates_with UnreservedUsernameValidator, if: -> { local? && will_save_change_to_username? && actor_type != 'Application' }
|
validates_with UnreservedUsernameValidator, if: -> { local? && will_save_change_to_username? && actor_type != 'Application' }
|
||||||
validates :display_name, length: { maximum: 30 }, if: -> { local? && will_save_change_to_display_name? }
|
validates :display_name, length: { maximum: 30 }, if: -> { local? && will_save_change_to_display_name? }
|
||||||
validates :note, note_length: { maximum: 500 }, if: -> { local? && will_save_change_to_note? }
|
validates :note, note_length: { maximum: 500 }, if: -> { local? && will_save_change_to_note? }
|
||||||
validates :fields, length: { maximum: 4 }, if: -> { local? && will_save_change_to_fields? }
|
validates :fields, length: { maximum: DEFAULT_FIELDS_SIZE }, if: -> { local? && will_save_change_to_fields? }
|
||||||
validates :uri, absence: true, if: :local?, on: :create
|
validates :uri, absence: true, if: :local?, on: :create
|
||||||
validates :inbox_url, absence: true, if: :local?, on: :create
|
validates :inbox_url, absence: true, if: :local?, on: :create
|
||||||
validates :shared_inbox_url, absence: true, if: :local?, on: :create
|
validates :shared_inbox_url, absence: true, if: :local?, on: :create
|
||||||
@ -353,8 +354,6 @@ class Account < ApplicationRecord
|
|||||||
self[:fields] = fields
|
self[:fields] = fields
|
||||||
end
|
end
|
||||||
|
|
||||||
DEFAULT_FIELDS_SIZE = 4
|
|
||||||
|
|
||||||
def build_fields
|
def build_fields
|
||||||
return if fields.size >= DEFAULT_FIELDS_SIZE
|
return if fields.size >= DEFAULT_FIELDS_SIZE
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user