Change account fields max 4 to 6

This commit is contained in:
KMY 2023-05-15 14:21:50 +09:00
parent a85fbcd471
commit 9015002334

View file

@ -99,7 +99,7 @@ class Account < ApplicationRecord
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 :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: 6 }, if: -> { local? && will_save_change_to_fields? }
scope :remote, -> { where.not(domain: nil) }
scope :local, -> { where(domain: nil) }
@ -301,6 +301,40 @@ class Account < ApplicationRecord
user&.setting_noai || (settings.present? && settings['noai']) || false
end
def hide_statuses_count?
return user&.setting_hide_statuses_count unless user&.setting_hide_statuses_count.nil?
return settings['hide_statuses_count'] if settings.present?
false
end
def hide_following_count?
return user&.setting_hide_following_count unless user&.setting_hide_following_count.nil?
return settings['hide_following_count'] if settings.present?
false
end
def hide_followers_count?
return user&.setting_hide_followers_count unless user&.setting_hide_followers_count.nil?
return settings['hide_followers_count'] if settings.present?
false
end
def public_settings
config = {
'noindex' => noindex?,
'noai' => noai?,
'hide_network' => hide_collections,
'hide_statuses_count' => hide_statuses_count?,
'hide_following_count' => hide_following_count?,
'hide_followers_count' => hide_followers_count?,
}
config = config.merge(settings) if settings.present?
config
end
def previous_strikes_count
strikes.where(overruled_at: nil).count
end
@ -359,7 +393,7 @@ class Account < ApplicationRecord
self[:fields] = fields
end
DEFAULT_FIELDS_SIZE = 4
DEFAULT_FIELDS_SIZE = 6
def build_fields
return if fields.size >= DEFAULT_FIELDS_SIZE