diff options
author | Claire <claire.github-309c@sitedethib.com> | 2022-05-25 12:27:11 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-25 12:27:11 +0200 |
commit | 3fd2aadb2323728e15fe2d49928b4af09447cf0f (patch) | |
tree | b3570a6471e46e2a69c438a16b421444d110ae6d /app/models | |
parent | 4ab3ad3bef44d245a7c02d05c7cc1788f17b2dd0 (diff) |
Various code cleanup (#1782)
* Remove duplicate in_chosen_languages definition * Use `DEFAULT_FIELDS_SIZE` instead of `MAX_FIELDS` to reduce code differences with upstream * Remove duplicate annotation * Fix incorrect cross-flavor imports * Remove deprecated `hide_network` setting (replaced by account column) * Remove unused KeywordMutesHelper * Remove trailing spaces * Remove commit_hash from InstancePresenter, as it has been unused since mid-2017
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/account.rb | 8 | ||||
-rw-r--r-- | app/models/mute.rb | 1 | ||||
-rw-r--r-- | app/models/status.rb | 4 |
3 files changed, 4 insertions, 9 deletions
diff --git a/app/models/account.rb b/app/models/account.rb index 068ee7ae9..f4fc32153 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -79,7 +79,7 @@ class Account < ApplicationRecord MAX_DISPLAY_NAME_LENGTH = (ENV['MAX_DISPLAY_NAME_CHARS'] || 30).to_i MAX_NOTE_LENGTH = (ENV['MAX_BIO_CHARS'] || 500).to_i - MAX_FIELDS = (ENV['MAX_PROFILE_FIELDS'] || 4).to_i + DEFAULT_FIELDS_SIZE = (ENV['MAX_PROFILE_FIELDS'] || 4).to_i enum protocol: [:ostatus, :activitypub] enum suspension_origin: [:local, :remote], _prefix: true @@ -95,7 +95,7 @@ class Account < ApplicationRecord validates_with UnreservedUsernameValidator, if: -> { local? && will_save_change_to_username? } validates :display_name, length: { maximum: MAX_DISPLAY_NAME_LENGTH }, if: -> { local? && will_save_change_to_display_name? } validates :note, note_length: { maximum: MAX_NOTE_LENGTH }, if: -> { local? && will_save_change_to_note? } - validates :fields, length: { maximum: MAX_FIELDS }, if: -> { local? && will_save_change_to_fields? } + validates :fields, length: { maximum: DEFAULT_FIELDS_SIZE }, if: -> { local? && will_save_change_to_fields? } scope :remote, -> { where.not(domain: nil) } scope :local, -> { where(domain: nil) } @@ -329,12 +329,12 @@ class Account < ApplicationRecord end def build_fields - return if fields.size >= MAX_FIELDS + return if fields.size >= DEFAULT_FIELDS_SIZE tmp = self[:fields] || [] tmp = [] if tmp.is_a?(Hash) - (MAX_FIELDS - tmp.size).times do + (DEFAULT_FIELDS_SIZE - tmp.size).times do tmp << { name: '', value: '' } end diff --git a/app/models/mute.rb b/app/models/mute.rb index fe8b6f42c..578345ef6 100644 --- a/app/models/mute.rb +++ b/app/models/mute.rb @@ -6,7 +6,6 @@ # id :bigint(8) not null, primary key # created_at :datetime not null # updated_at :datetime not null -# hide_notifications :boolean default(TRUE), not null # account_id :bigint(8) not null # target_account_id :bigint(8) not null # hide_notifications :boolean default(TRUE), not null diff --git a/app/models/status.rb b/app/models/status.rb index 75b464a70..21a574a71 100644 --- a/app/models/status.rb +++ b/app/models/status.rb @@ -322,10 +322,6 @@ class Status < ApplicationRecord visibilities.keys - %w(direct limited) end - def in_chosen_languages(account) - where(language: nil).or where(language: account.chosen_languages) - end - def as_direct_timeline(account, limit = 20, max_id = nil, since_id = nil, cache_ids = false) # direct timeline is mix of direct message from_me and to_me. # 2 queries are executed with pagination. |