forked from asonix/mastodon
4 profile fields max, store only 255 characters per name/value (#7348)
Fix #7303
This commit is contained in:
parent
80b23a6a85
commit
8da4bf0f90
1 changed files with 8 additions and 5 deletions
|
@ -74,6 +74,7 @@ class Account < ApplicationRecord
|
||||||
validates_with UnreservedUsernameValidator, if: -> { local? && will_save_change_to_username? }
|
validates_with UnreservedUsernameValidator, if: -> { local? && will_save_change_to_username? }
|
||||||
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, length: { maximum: 160 }, if: -> { local? && will_save_change_to_note? }
|
validates :note, length: { maximum: 160 }, if: -> { local? && will_save_change_to_note? }
|
||||||
|
validates :fields, length: { maximum: 4 }, if: -> { local? && will_save_change_to_fields? }
|
||||||
|
|
||||||
# Timelines
|
# Timelines
|
||||||
has_many :stream_entries, inverse_of: :account, dependent: :destroy
|
has_many :stream_entries, inverse_of: :account, dependent: :destroy
|
||||||
|
@ -198,10 +199,12 @@ class Account < ApplicationRecord
|
||||||
def fields_attributes=(attributes)
|
def fields_attributes=(attributes)
|
||||||
fields = []
|
fields = []
|
||||||
|
|
||||||
|
if attributes.is_a?(Hash)
|
||||||
attributes.each_value do |attr|
|
attributes.each_value do |attr|
|
||||||
next if attr[:name].blank?
|
next if attr[:name].blank?
|
||||||
fields << attr
|
fields << attr
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
self[:fields] = fields
|
self[:fields] = fields
|
||||||
end
|
end
|
||||||
|
@ -269,8 +272,8 @@ class Account < ApplicationRecord
|
||||||
|
|
||||||
def initialize(account, attr)
|
def initialize(account, attr)
|
||||||
@account = account
|
@account = account
|
||||||
@name = attr['name']
|
@name = attr['name'].strip[0, 255]
|
||||||
@value = attr['value']
|
@value = attr['value'].strip[0, 255]
|
||||||
@errors = {}
|
@errors = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue