about summary refs log tree commit diff
path: root/app/models
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2023-02-25 14:00:40 +0100
committerClaire <claire.github-309c@sitedethib.com>2023-02-25 14:00:40 +0100
commit4ed09276d5267181061dff438a0b10770db9f226 (patch)
treecb8f358d58669626332ea01bcf0186d08b5eac90 /app/models
parent45087c1092143e95dfcc85b6c9abc5c6c0a0a5c2 (diff)
parent730bb3e211a84a2f30e3e2bbeae3f77149824a68 (diff)
Merge branch 'main' into glitch-soc/merge-upstream
Conflicts:
- `.prettierignore`:
  Upstream added a line at the end of the file, while glitch-soc had its own
  extra lines.
  Took upstream's change.
- `CONTRIBUTING.md`:
  We have our custom CONTRIBUTING.md quoting upstream. Upstream made changes.
  Ported upstream changes.
- `app/controllers/application_controller.rb`:
  Upstream made code style changes in a method that is entirely replaced
  in glitch-soc.
  Ignored the change.
- `app/models/account.rb`:
  Code style changes textually close to glitch-soc-specific changes.
  Ported upstream changes.
- `lib/sanitize_ext/sanitize_config.rb`:
  Upstream code style changes.
  Ignored them.
Diffstat (limited to 'app/models')
-rw-r--r--app/models/account.rb8
-rw-r--r--app/models/account/field.rb4
-rw-r--r--app/models/account_conversation.rb2
-rw-r--r--app/models/account_domain_block.rb1
-rw-r--r--app/models/account_moderation_note.rb1
-rw-r--r--app/models/account_note.rb1
-rw-r--r--app/models/account_pin.rb1
-rw-r--r--app/models/account_stat.rb1
-rw-r--r--app/models/account_summary.rb1
-rw-r--r--app/models/account_warning.rb13
-rw-r--r--app/models/admin/import.rb1
-rw-r--r--app/models/announcement.rb2
-rw-r--r--app/models/backup.rb1
-rw-r--r--app/models/block.rb1
-rw-r--r--app/models/bookmark.rb1
-rw-r--r--app/models/canonical_email_block.rb1
-rw-r--r--app/models/concerns/account_interactions.rb4
-rw-r--r--app/models/conversation.rb1
-rw-r--r--app/models/conversation_mute.rb1
-rw-r--r--app/models/custom_emoji.rb1
-rw-r--r--app/models/custom_filter.rb9
-rw-r--r--app/models/custom_filter_keyword.rb1
-rw-r--r--app/models/custom_filter_status.rb1
-rw-r--r--app/models/device.rb1
-rw-r--r--app/models/domain_block.rb3
-rw-r--r--app/models/email_domain_block.rb1
-rw-r--r--app/models/encrypted_message.rb1
-rw-r--r--app/models/favourite.rb2
-rw-r--r--app/models/featured_tag.rb1
-rw-r--r--app/models/follow.rb1
-rw-r--r--app/models/follow_recommendation.rb3
-rw-r--r--app/models/follow_recommendation_suppression.rb1
-rw-r--r--app/models/follow_request.rb1
-rw-r--r--app/models/form/admin_settings.rb1
-rw-r--r--app/models/identity.rb1
-rw-r--r--app/models/import.rb3
-rw-r--r--app/models/instance.rb1
-rw-r--r--app/models/invite.rb1
-rw-r--r--app/models/ip_block.rb1
-rw-r--r--app/models/list.rb3
-rw-r--r--app/models/list_account.rb1
-rw-r--r--app/models/login_activity.rb1
-rw-r--r--app/models/media_attachment.rb7
-rw-r--r--app/models/mention.rb1
-rw-r--r--app/models/mute.rb1
-rw-r--r--app/models/notification.rb11
-rw-r--r--app/models/one_time_key.rb1
-rw-r--r--app/models/poll.rb8
-rw-r--r--app/models/poll_vote.rb1
-rw-r--r--app/models/preview_card.rb5
-rw-r--r--app/models/preview_card_provider.rb1
-rw-r--r--app/models/relay.rb3
-rw-r--r--app/models/report.rb3
-rw-r--r--app/models/report_note.rb1
-rw-r--r--app/models/session_activation.rb2
-rw-r--r--app/models/setting.rb4
-rw-r--r--app/models/site_upload.rb1
-rw-r--r--app/models/status.rb7
-rw-r--r--app/models/status_edit.rb2
-rw-r--r--app/models/status_pin.rb1
-rw-r--r--app/models/status_stat.rb1
-rw-r--r--app/models/tag.rb1
-rw-r--r--app/models/unavailable_domain.rb1
-rw-r--r--app/models/user.rb4
-rw-r--r--app/models/user_ip.rb3
-rw-r--r--app/models/user_role.rb2
-rw-r--r--app/models/web/push_subscription.rb1
-rw-r--r--app/models/web/setting.rb1
-rw-r--r--app/models/webauthn_credential.rb1
69 files changed, 121 insertions, 40 deletions
diff --git a/app/models/account.rb b/app/models/account.rb
index bd623cff9..2a5a33ca7 100644
--- a/app/models/account.rb
+++ b/app/models/account.rb
@@ -1,4 +1,5 @@
 # frozen_string_literal: true
+
 # == Schema Information
 #
 # Table name: accounts
@@ -82,8 +83,8 @@ class Account < ApplicationRecord
   MAX_NOTE_LENGTH = (ENV['MAX_BIO_CHARS'] || 500).to_i
   DEFAULT_FIELDS_SIZE = (ENV['MAX_PROFILE_FIELDS'] || 4).to_i
 
-  enum protocol: [:ostatus, :activitypub]
-  enum suspension_origin: [:local, :remote], _prefix: true
+  enum protocol: { ostatus: 0, activitypub: 1 }
+  enum suspension_origin: { local: 0, remote: 1 }, _prefix: true
 
   validates :username, presence: true
   validates_with UniqueUsernameValidator, if: -> { will_save_change_to_username? }
@@ -111,7 +112,7 @@ class Account < ApplicationRecord
   scope :bots, -> { where(actor_type: %w(Application Service)) }
   scope :groups, -> { where(actor_type: 'Group') }
   scope :alphabetic, -> { order(domain: :asc, username: :asc) }
-  scope :matches_username, ->(value) { where(arel_table[:username].matches("#{value}%")) }
+  scope :matches_username, ->(value) { where('lower((username)::text) LIKE lower(?)', "#{value}%") }
   scope :matches_display_name, ->(value) { where(arel_table[:display_name].matches("#{value}%")) }
   scope :matches_domain, ->(value) { where(arel_table[:domain].matches("%#{value}%")) }
   scope :without_unapproved, -> { left_outer_joins(:user).remote.or(left_outer_joins(:user).merge(User.approved.confirmed)) }
@@ -537,6 +538,7 @@ class Account < ApplicationRecord
 
   def ensure_keys!
     return unless local? && private_key.blank? && public_key.blank?
+
     generate_keys
     save!
   end
diff --git a/app/models/account/field.rb b/app/models/account/field.rb
index 98c29726d..2bada6954 100644
--- a/app/models/account/field.rb
+++ b/app/models/account/field.rb
@@ -14,8 +14,8 @@ class Account::Field < ActiveModelSerializers::Model
     @account        = account
 
     super(
-      name:        sanitize(attributes['name']),
-      value:       sanitize(attributes['value']),
+      name: sanitize(attributes['name']),
+      value: sanitize(attributes['value']),
       verified_at: attributes['verified_at']&.to_datetime,
     )
   end
diff --git a/app/models/account_conversation.rb b/app/models/account_conversation.rb
index 45e74bbeb..b3ddc04c1 100644
--- a/app/models/account_conversation.rb
+++ b/app/models/account_conversation.rb
@@ -1,4 +1,5 @@
 # frozen_string_literal: true
+
 # == Schema Information
 #
 # Table name: account_conversations
@@ -107,6 +108,7 @@ class AccountConversation < ApplicationRecord
 
   def push_to_streaming_api
     return if destroyed? || !subscribed_to_timeline?
+
     PushConversationWorker.perform_async(id)
   end
 
diff --git a/app/models/account_domain_block.rb b/app/models/account_domain_block.rb
index 3aaffde9a..af1e6a68d 100644
--- a/app/models/account_domain_block.rb
+++ b/app/models/account_domain_block.rb
@@ -1,4 +1,5 @@
 # frozen_string_literal: true
+
 # == Schema Information
 #
 # Table name: account_domain_blocks
diff --git a/app/models/account_moderation_note.rb b/app/models/account_moderation_note.rb
index 22e312bb2..ff399bab0 100644
--- a/app/models/account_moderation_note.rb
+++ b/app/models/account_moderation_note.rb
@@ -1,4 +1,5 @@
 # frozen_string_literal: true
+
 # == Schema Information
 #
 # Table name: account_moderation_notes
diff --git a/app/models/account_note.rb b/app/models/account_note.rb
index b338bc92f..9bc704d98 100644
--- a/app/models/account_note.rb
+++ b/app/models/account_note.rb
@@ -1,4 +1,5 @@
 # frozen_string_literal: true
+
 # == Schema Information
 #
 # Table name: account_notes
diff --git a/app/models/account_pin.rb b/app/models/account_pin.rb
index b51d3d4cd..6c78e8c44 100644
--- a/app/models/account_pin.rb
+++ b/app/models/account_pin.rb
@@ -1,4 +1,5 @@
 # frozen_string_literal: true
+
 # == Schema Information
 #
 # Table name: account_pins
diff --git a/app/models/account_stat.rb b/app/models/account_stat.rb
index a5d71a5b8..834f8ba4c 100644
--- a/app/models/account_stat.rb
+++ b/app/models/account_stat.rb
@@ -1,4 +1,5 @@
 # frozen_string_literal: true
+
 # == Schema Information
 #
 # Table name: account_stats
diff --git a/app/models/account_summary.rb b/app/models/account_summary.rb
index 3a3cebc55..0d8835b83 100644
--- a/app/models/account_summary.rb
+++ b/app/models/account_summary.rb
@@ -1,4 +1,5 @@
 # frozen_string_literal: true
+
 # == Schema Information
 #
 # Table name: account_summaries
diff --git a/app/models/account_warning.rb b/app/models/account_warning.rb
index a181cd18d..4f8cc5320 100644
--- a/app/models/account_warning.rb
+++ b/app/models/account_warning.rb
@@ -1,4 +1,5 @@
 # frozen_string_literal: true
+
 # == Schema Information
 #
 # Table name: account_warnings
@@ -17,13 +18,13 @@
 
 class AccountWarning < ApplicationRecord
   enum action: {
-    none:                       0,
-    disable:                    1_000,
+    none: 0,
+    disable: 1_000,
     mark_statuses_as_sensitive: 1_250,
-    delete_statuses:            1_500,
-    sensitive:                  2_000,
-    silence:                    3_000,
-    suspend:                    4_000,
+    delete_statuses: 1_500,
+    sensitive: 2_000,
+    silence: 3_000,
+    suspend: 4_000,
   }, _suffix: :action
 
   before_validation :before_validate
diff --git a/app/models/admin/import.rb b/app/models/admin/import.rb
index fecde4878..0fd4bdb82 100644
--- a/app/models/admin/import.rb
+++ b/app/models/admin/import.rb
@@ -56,6 +56,7 @@ class Admin::Import
 
   def validate_data
     return if data.nil?
+
     errors.add(:data, I18n.t('imports.errors.over_rows_processing_limit', count: ROWS_PROCESSING_LIMIT)) if csv_row_count > ROWS_PROCESSING_LIMIT
   rescue CSV::MalformedCSVError => e
     errors.add(:data, I18n.t('imports.errors.invalid_csv_file', error: e.message))
diff --git a/app/models/announcement.rb b/app/models/announcement.rb
index 898bf3efa..339f5ae70 100644
--- a/app/models/announcement.rb
+++ b/app/models/announcement.rb
@@ -20,7 +20,7 @@
 class Announcement < ApplicationRecord
   scope :unpublished, -> { where(published: false) }
   scope :published, -> { where(published: true) }
-  scope :without_muted, ->(account) { joins("LEFT OUTER JOIN announcement_mutes ON announcement_mutes.announcement_id = announcements.id AND announcement_mutes.account_id = #{account.id}").where('announcement_mutes.id IS NULL') }
+  scope :without_muted, ->(account) { joins("LEFT OUTER JOIN announcement_mutes ON announcement_mutes.announcement_id = announcements.id AND announcement_mutes.account_id = #{account.id}").where(announcement_mutes: { id: nil }) }
   scope :chronological, -> { order(Arel.sql('COALESCE(announcements.starts_at, announcements.scheduled_at, announcements.published_at, announcements.created_at) ASC')) }
   scope :reverse_chronological, -> { order(Arel.sql('COALESCE(announcements.starts_at, announcements.scheduled_at, announcements.published_at, announcements.created_at) DESC')) }
 
diff --git a/app/models/backup.rb b/app/models/backup.rb
index 277b9395b..bec3cbfe5 100644
--- a/app/models/backup.rb
+++ b/app/models/backup.rb
@@ -1,4 +1,5 @@
 # frozen_string_literal: true
+
 # == Schema Information
 #
 # Table name: backups
diff --git a/app/models/block.rb b/app/models/block.rb
index bf3e07600..b42c1569b 100644
--- a/app/models/block.rb
+++ b/app/models/block.rb
@@ -1,4 +1,5 @@
 # frozen_string_literal: true
+
 # == Schema Information
 #
 # Table name: blocks
diff --git a/app/models/bookmark.rb b/app/models/bookmark.rb
index 6334ef0df..04b660372 100644
--- a/app/models/bookmark.rb
+++ b/app/models/bookmark.rb
@@ -1,4 +1,5 @@
 # frozen_string_literal: true
+
 # == Schema Information
 #
 # Table name: bookmarks
diff --git a/app/models/canonical_email_block.rb b/app/models/canonical_email_block.rb
index 1eb69ac67..d09df6f5e 100644
--- a/app/models/canonical_email_block.rb
+++ b/app/models/canonical_email_block.rb
@@ -1,4 +1,5 @@
 # frozen_string_literal: true
+
 # == Schema Information
 #
 # Table name: canonical_email_blocks
diff --git a/app/models/concerns/account_interactions.rb b/app/models/concerns/account_interactions.rb
index 325619774..1898516b0 100644
--- a/app/models/concerns/account_interactions.rb
+++ b/app/models/concerns/account_interactions.rb
@@ -278,7 +278,7 @@ module AccountInteractions
       followers.where(Account.arel_table[:uri].matches("#{Account.sanitize_sql_like(url_prefix)}/%", false, true)).or(followers.where(uri: url_prefix)).pluck_each(:uri) do |uri|
         Xorcist.xor!(digest, Digest::SHA256.digest(uri))
       end
-      digest.unpack('H*')[0]
+      digest.unpack1('H*')
     end
   end
 
@@ -288,7 +288,7 @@ module AccountInteractions
       followers.where(domain: nil).pluck_each(:username) do |username|
         Xorcist.xor!(digest, Digest::SHA256.digest(ActivityPub::TagManager.instance.uri_for_username(username)))
       end
-      digest.unpack('H*')[0]
+      digest.unpack1('H*')
     end
   end
 
diff --git a/app/models/conversation.rb b/app/models/conversation.rb
index 4dfaea889..5de259962 100644
--- a/app/models/conversation.rb
+++ b/app/models/conversation.rb
@@ -1,4 +1,5 @@
 # frozen_string_literal: true
+
 # == Schema Information
 #
 # Table name: conversations
diff --git a/app/models/conversation_mute.rb b/app/models/conversation_mute.rb
index 52c1a33e0..31f8e1966 100644
--- a/app/models/conversation_mute.rb
+++ b/app/models/conversation_mute.rb
@@ -1,4 +1,5 @@
 # frozen_string_literal: true
+
 # == Schema Information
 #
 # Table name: conversation_mutes
diff --git a/app/models/custom_emoji.rb b/app/models/custom_emoji.rb
index fc8d3aed3..b5a07a5a0 100644
--- a/app/models/custom_emoji.rb
+++ b/app/models/custom_emoji.rb
@@ -1,4 +1,5 @@
 # frozen_string_literal: true
+
 # == Schema Information
 #
 # Table name: custom_emojis
diff --git a/app/models/custom_filter.rb b/app/models/custom_filter.rb
index 5a4a974be..d85e196e9 100644
--- a/app/models/custom_filter.rb
+++ b/app/models/custom_filter.rb
@@ -1,4 +1,5 @@
 # frozen_string_literal: true
+
 # == Schema Information
 #
 # Table name: custom_filters
@@ -30,11 +31,11 @@ class CustomFilter < ApplicationRecord
   include Expireable
   include Redisable
 
-  enum action: [:warn, :hide], _suffix: :action
+  enum action: { warn: 0, hide: 1 }, _suffix: :action
 
   belongs_to :account
-  has_many :keywords, class_name: 'CustomFilterKeyword', foreign_key: :custom_filter_id, inverse_of: :custom_filter, dependent: :destroy
-  has_many :statuses, class_name: 'CustomFilterStatus', foreign_key: :custom_filter_id, inverse_of: :custom_filter, dependent: :destroy
+  has_many :keywords, class_name: 'CustomFilterKeyword', inverse_of: :custom_filter, dependent: :destroy
+  has_many :statuses, class_name: 'CustomFilterStatus', inverse_of: :custom_filter, dependent: :destroy
   accepts_nested_attributes_for :keywords, reject_if: :all_blank, allow_destroy: true
 
   validates :title, :context, presence: true
@@ -101,6 +102,7 @@ class CustomFilter < ApplicationRecord
       status_matches = [status.id, status.reblog_of_id].compact & rules[:status_ids] if rules[:status_ids].present?
 
       next if keyword_matches.blank? && status_matches.blank?
+
       FilterResultPresenter.new(filter: filter, keyword_matches: keyword_matches, status_matches: status_matches)
     end
   end
@@ -111,6 +113,7 @@ class CustomFilter < ApplicationRecord
 
   def invalidate_cache!
     return unless @should_invalidate_cache
+
     @should_invalidate_cache = false
 
     Rails.cache.delete("filters:v3:#{account_id}")
diff --git a/app/models/custom_filter_keyword.rb b/app/models/custom_filter_keyword.rb
index e0d0289ae..3158b3b79 100644
--- a/app/models/custom_filter_keyword.rb
+++ b/app/models/custom_filter_keyword.rb
@@ -1,4 +1,5 @@
 # frozen_string_literal: true
+
 # == Schema Information
 #
 # Table name: custom_filter_keywords
diff --git a/app/models/custom_filter_status.rb b/app/models/custom_filter_status.rb
index e748d6963..0a5650204 100644
--- a/app/models/custom_filter_status.rb
+++ b/app/models/custom_filter_status.rb
@@ -1,4 +1,5 @@
 # frozen_string_literal: true
+
 # == Schema Information
 #
 # Table name: custom_filter_statuses
diff --git a/app/models/device.rb b/app/models/device.rb
index 97d0d2774..5dc6cf1e6 100644
--- a/app/models/device.rb
+++ b/app/models/device.rb
@@ -1,4 +1,5 @@
 # frozen_string_literal: true
+
 # == Schema Information
 #
 # Table name: devices
diff --git a/app/models/domain_block.rb b/app/models/domain_block.rb
index 8e298ac9d..fbb045416 100644
--- a/app/models/domain_block.rb
+++ b/app/models/domain_block.rb
@@ -1,4 +1,5 @@
 # frozen_string_literal: true
+
 # == Schema Information
 #
 # Table name: domain_blocks
@@ -20,7 +21,7 @@ class DomainBlock < ApplicationRecord
   include DomainNormalizable
   include DomainMaterializable
 
-  enum severity: [:silence, :suspend, :noop]
+  enum severity: { silence: 0, suspend: 1, noop: 2 }
 
   validates :domain, presence: true, uniqueness: true, domain: true
 
diff --git a/app/models/email_domain_block.rb b/app/models/email_domain_block.rb
index 3a56e4f2a..276e7d31a 100644
--- a/app/models/email_domain_block.rb
+++ b/app/models/email_domain_block.rb
@@ -1,4 +1,5 @@
 # frozen_string_literal: true
+
 # == Schema Information
 #
 # Table name: email_domain_blocks
diff --git a/app/models/encrypted_message.rb b/app/models/encrypted_message.rb
index 7b4e32283..3e7e95594 100644
--- a/app/models/encrypted_message.rb
+++ b/app/models/encrypted_message.rb
@@ -1,4 +1,5 @@
 # frozen_string_literal: true
+
 # == Schema Information
 #
 # Table name: encrypted_messages
diff --git a/app/models/favourite.rb b/app/models/favourite.rb
index 2f355739a..042f72bea 100644
--- a/app/models/favourite.rb
+++ b/app/models/favourite.rb
@@ -1,4 +1,5 @@
 # frozen_string_literal: true
+
 # == Schema Information
 #
 # Table name: favourites
@@ -38,6 +39,7 @@ class Favourite < ApplicationRecord
 
   def decrement_cache_counters
     return if association(:status).loaded? && status.marked_for_destruction?
+
     status&.decrement_count!(:favourites_count)
   end
 
diff --git a/app/models/featured_tag.rb b/app/models/featured_tag.rb
index 70f949b6a..587dcf991 100644
--- a/app/models/featured_tag.rb
+++ b/app/models/featured_tag.rb
@@ -1,4 +1,5 @@
 # frozen_string_literal: true
+
 # == Schema Information
 #
 # Table name: featured_tags
diff --git a/app/models/follow.rb b/app/models/follow.rb
index e5cecbbc1..108f5c5d5 100644
--- a/app/models/follow.rb
+++ b/app/models/follow.rb
@@ -1,4 +1,5 @@
 # frozen_string_literal: true
+
 # == Schema Information
 #
 # Table name: follows
diff --git a/app/models/follow_recommendation.rb b/app/models/follow_recommendation.rb
index e552b5a88..602d32985 100644
--- a/app/models/follow_recommendation.rb
+++ b/app/models/follow_recommendation.rb
@@ -1,4 +1,5 @@
 # frozen_string_literal: true
+
 # == Schema Information
 #
 # Table name: follow_recommendations
@@ -12,7 +13,7 @@ class FollowRecommendation < ApplicationRecord
   self.primary_key = :account_id
 
   belongs_to :account_summary, foreign_key: :account_id
-  belongs_to :account, foreign_key: :account_id
+  belongs_to :account
 
   scope :localized, ->(locale) { joins(:account_summary).merge(AccountSummary.localized(locale)) }
 
diff --git a/app/models/follow_recommendation_suppression.rb b/app/models/follow_recommendation_suppression.rb
index 170506b85..a9dbbfc18 100644
--- a/app/models/follow_recommendation_suppression.rb
+++ b/app/models/follow_recommendation_suppression.rb
@@ -1,4 +1,5 @@
 # frozen_string_literal: true
+
 # == Schema Information
 #
 # Table name: follow_recommendation_suppressions
diff --git a/app/models/follow_request.rb b/app/models/follow_request.rb
index 9034250c0..78f79c18f 100644
--- a/app/models/follow_request.rb
+++ b/app/models/follow_request.rb
@@ -1,4 +1,5 @@
 # frozen_string_literal: true
+
 # == Schema Information
 #
 # Table name: follow_requests
diff --git a/app/models/form/admin_settings.rb b/app/models/form/admin_settings.rb
index d692891d8..eaee142fa 100644
--- a/app/models/form/admin_settings.rb
+++ b/app/models/form/admin_settings.rb
@@ -153,6 +153,7 @@ class Form::AdminSettings
   def validate_site_uploads
     UPLOAD_KEYS.each do |key|
       next unless instance_variable_defined?("@#{key}")
+
       upload = instance_variable_get("@#{key}")
       next if upload.valid?
 
diff --git a/app/models/identity.rb b/app/models/identity.rb
index 8cc65aef4..6f10fed4d 100644
--- a/app/models/identity.rb
+++ b/app/models/identity.rb
@@ -1,4 +1,5 @@
 # frozen_string_literal: true
+
 # == Schema Information
 #
 # Table name: identities
diff --git a/app/models/import.rb b/app/models/import.rb
index 00a54892e..21634005e 100644
--- a/app/models/import.rb
+++ b/app/models/import.rb
@@ -1,4 +1,5 @@
 # frozen_string_literal: true
+
 # == Schema Information
 #
 # Table name: imports
@@ -24,7 +25,7 @@ class Import < ApplicationRecord
 
   belongs_to :account
 
-  enum type: [:following, :blocking, :muting, :domain_blocking, :bookmarks]
+  enum type: { following: 0, blocking: 1, muting: 2, domain_blocking: 3, bookmarks: 4 }
 
   validates :type, presence: true
   validates_with ImportValidator, on: :create
diff --git a/app/models/instance.rb b/app/models/instance.rb
index edbf02a6d..1f96d3728 100644
--- a/app/models/instance.rb
+++ b/app/models/instance.rb
@@ -1,4 +1,5 @@
 # frozen_string_literal: true
+
 # == Schema Information
 #
 # Table name: instances
diff --git a/app/models/invite.rb b/app/models/invite.rb
index 7ea4e2f98..8e816cef0 100644
--- a/app/models/invite.rb
+++ b/app/models/invite.rb
@@ -1,4 +1,5 @@
 # frozen_string_literal: true
+
 # == Schema Information
 #
 # Table name: invites
diff --git a/app/models/ip_block.rb b/app/models/ip_block.rb
index 31343f0e1..99783050b 100644
--- a/app/models/ip_block.rb
+++ b/app/models/ip_block.rb
@@ -1,4 +1,5 @@
 # frozen_string_literal: true
+
 # == Schema Information
 #
 # Table name: ip_blocks
diff --git a/app/models/list.rb b/app/models/list.rb
index cdc6ebdb3..bd1bdbd24 100644
--- a/app/models/list.rb
+++ b/app/models/list.rb
@@ -1,4 +1,5 @@
 # frozen_string_literal: true
+
 # == Schema Information
 #
 # Table name: lists
@@ -16,7 +17,7 @@ class List < ApplicationRecord
 
   PER_ACCOUNT_LIMIT = 50
 
-  enum replies_policy: [:list, :followed, :none], _prefix: :show
+  enum replies_policy: { list: 0, followed: 1, none: 2 }, _prefix: :show
 
   belongs_to :account, optional: true
 
diff --git a/app/models/list_account.rb b/app/models/list_account.rb
index 785923c4c..a5767d3d8 100644
--- a/app/models/list_account.rb
+++ b/app/models/list_account.rb
@@ -1,4 +1,5 @@
 # frozen_string_literal: true
+
 # == Schema Information
 #
 # Table name: list_accounts
diff --git a/app/models/login_activity.rb b/app/models/login_activity.rb
index 52a0fd01d..2b7b37f8e 100644
--- a/app/models/login_activity.rb
+++ b/app/models/login_activity.rb
@@ -1,4 +1,5 @@
 # frozen_string_literal: true
+
 # == Schema Information
 #
 # Table name: login_activities
diff --git a/app/models/media_attachment.rb b/app/models/media_attachment.rb
index 4dd3042ab..62c9828c6 100644
--- a/app/models/media_attachment.rb
+++ b/app/models/media_attachment.rb
@@ -1,4 +1,5 @@
 # frozen_string_literal: true
+
 # == Schema Information
 #
 # Table name: media_attachments
@@ -33,8 +34,8 @@ class MediaAttachment < ApplicationRecord
 
   include Attachmentable
 
-  enum type: [:image, :gifv, :video, :unknown, :audio]
-  enum processing: [:queued, :in_progress, :complete, :failed], _prefix: true
+  enum type: { :image => 0, :gifv => 1, :video => 2, :unknown => 3, :audio => 4 }
+  enum processing: { :queued => 0, :in_progress => 1, :complete => 2, :failed => 3 }, _prefix: true
 
   MAX_DESCRIPTION_LENGTH = 1_500
 
@@ -372,7 +373,7 @@ class MediaAttachment < ApplicationRecord
     return {} if width.nil?
 
     {
-      width:  width,
+      width: width,
       height: height,
       size: "#{width}x#{height}",
       aspect: width.to_f / height,
diff --git a/app/models/mention.rb b/app/models/mention.rb
index d01a88e32..2348b2905 100644
--- a/app/models/mention.rb
+++ b/app/models/mention.rb
@@ -1,4 +1,5 @@
 # frozen_string_literal: true
+
 # == Schema Information
 #
 # Table name: mentions
diff --git a/app/models/mute.rb b/app/models/mute.rb
index 578345ef6..8fc542262 100644
--- a/app/models/mute.rb
+++ b/app/models/mute.rb
@@ -1,4 +1,5 @@
 # frozen_string_literal: true
+
 # == Schema Information
 #
 # Table name: mutes
diff --git a/app/models/notification.rb b/app/models/notification.rb
index 01155c363..3eaf557b0 100644
--- a/app/models/notification.rb
+++ b/app/models/notification.rb
@@ -1,4 +1,5 @@
 # frozen_string_literal: true
+
 # == Schema Information
 #
 # Table name: notifications
@@ -19,12 +20,12 @@ class Notification < ApplicationRecord
   include Paginable
 
   LEGACY_TYPE_CLASS_MAP = {
-    'Mention'       => :mention,
-    'Status'        => :reblog,
-    'Follow'        => :follow,
+    'Mention' => :mention,
+    'Status' => :reblog,
+    'Follow' => :follow,
     'FollowRequest' => :follow_request,
-    'Favourite'     => :favourite,
-    'Poll'          => :poll,
+    'Favourite' => :favourite,
+    'Poll' => :poll,
   }.freeze
 
   TYPES = %i(
diff --git a/app/models/one_time_key.rb b/app/models/one_time_key.rb
index 8ada34824..23604e2f7 100644
--- a/app/models/one_time_key.rb
+++ b/app/models/one_time_key.rb
@@ -1,4 +1,5 @@
 # frozen_string_literal: true
+
 # == Schema Information
 #
 # Table name: one_time_keys
diff --git a/app/models/poll.rb b/app/models/poll.rb
index af3b09315..dd35e953b 100644
--- a/app/models/poll.rb
+++ b/app/models/poll.rb
@@ -1,4 +1,5 @@
 # frozen_string_literal: true
+
 # == Schema Information
 #
 # Table name: polls
@@ -74,9 +75,9 @@ class Poll < ApplicationRecord
 
     def initialize(poll, id, title, votes_count)
       super(
-        poll:        poll,
-        id:          id,
-        title:       title,
+        poll: poll,
+        id: id,
+        title: title,
         votes_count: votes_count,
       )
     end
@@ -105,6 +106,7 @@ class Poll < ApplicationRecord
 
   def reset_parent_cache
     return if status_id.nil?
+
     Rails.cache.delete("statuses/#{status_id}")
   end
 
diff --git a/app/models/poll_vote.rb b/app/models/poll_vote.rb
index ad24eb691..00eaedd12 100644
--- a/app/models/poll_vote.rb
+++ b/app/models/poll_vote.rb
@@ -1,4 +1,5 @@
 # frozen_string_literal: true
+
 # == Schema Information
 #
 # Table name: poll_votes
diff --git a/app/models/preview_card.rb b/app/models/preview_card.rb
index 56ca62d5e..6bce16562 100644
--- a/app/models/preview_card.rb
+++ b/app/models/preview_card.rb
@@ -1,4 +1,5 @@
 # frozen_string_literal: true
+
 # == Schema Information
 #
 # Table name: preview_cards
@@ -44,8 +45,8 @@ class PreviewCard < ApplicationRecord
 
   self.inheritance_column = false
 
-  enum type: [:link, :photo, :video, :rich]
-  enum link_type: [:unknown, :article]
+  enum type: { link: 0, photo: 1, video: 2, rich: 3 }
+  enum link_type: { unknown: 0, article: 1 }
 
   has_and_belongs_to_many :statuses
   has_one :trend, class_name: 'PreviewCardTrend', inverse_of: :preview_card, dependent: :destroy
diff --git a/app/models/preview_card_provider.rb b/app/models/preview_card_provider.rb
index d61fe6020..1dd95fc91 100644
--- a/app/models/preview_card_provider.rb
+++ b/app/models/preview_card_provider.rb
@@ -1,4 +1,5 @@
 # frozen_string_literal: true
+
 # == Schema Information
 #
 # Table name: preview_card_providers
diff --git a/app/models/relay.rb b/app/models/relay.rb
index c66bfe4ff..a5fa03a99 100644
--- a/app/models/relay.rb
+++ b/app/models/relay.rb
@@ -1,4 +1,5 @@
 # frozen_string_literal: true
+
 # == Schema Information
 #
 # Table name: relays
@@ -14,7 +15,7 @@
 class Relay < ApplicationRecord
   validates :inbox_url, presence: true, uniqueness: true, url: true, if: :will_save_change_to_inbox_url?
 
-  enum state: [:idle, :pending, :accepted, :rejected]
+  enum state: { idle: 0, pending: 1, accepted: 2, rejected: 3 }
 
   scope :enabled, -> { accepted }
 
diff --git a/app/models/report.rb b/app/models/report.rb
index 525d22ad5..a9940459d 100644
--- a/app/models/report.rb
+++ b/app/models/report.rb
@@ -1,4 +1,5 @@
 # frozen_string_literal: true
+
 # == Schema Information
 #
 # Table name: reports
@@ -32,7 +33,7 @@ class Report < ApplicationRecord
   belongs_to :action_taken_by_account, class_name: 'Account', optional: true
   belongs_to :assigned_account, class_name: 'Account', optional: true
 
-  has_many :notes, class_name: 'ReportNote', foreign_key: :report_id, inverse_of: :report, dependent: :destroy
+  has_many :notes, class_name: 'ReportNote', inverse_of: :report, dependent: :destroy
   has_many :notifications, as: :activity, dependent: :destroy
 
   scope :unresolved, -> { where(action_taken_at: nil) }
diff --git a/app/models/report_note.rb b/app/models/report_note.rb
index 6d7167e0e..74b46027e 100644
--- a/app/models/report_note.rb
+++ b/app/models/report_note.rb
@@ -1,4 +1,5 @@
 # frozen_string_literal: true
+
 # == Schema Information
 #
 # Table name: report_notes
diff --git a/app/models/session_activation.rb b/app/models/session_activation.rb
index 0b7fa6fe4..10c3a6c25 100644
--- a/app/models/session_activation.rb
+++ b/app/models/session_activation.rb
@@ -1,4 +1,5 @@
 # frozen_string_literal: true
+
 # == Schema Information
 #
 # Table name: session_activations
@@ -51,6 +52,7 @@ class SessionActivation < ApplicationRecord
 
     def deactivate(id)
       return unless id
+
       where(session_id: id).destroy_all
     end
 
diff --git a/app/models/setting.rb b/app/models/setting.rb
index c6558d692..3bdc6ffb4 100644
--- a/app/models/setting.rb
+++ b/app/models/setting.rb
@@ -1,4 +1,5 @@
 # frozen_string_literal: true
+
 # == Schema Information
 #
 # Table name: settings
@@ -30,6 +31,7 @@ class Setting < RailsSettings::Base
           default_value = default_settings[key]
 
           return default_value.with_indifferent_access.merge!(db_val.value) if default_value.is_a?(Hash)
+
           db_val.value
         else
           default_settings[key]
@@ -43,6 +45,7 @@ class Setting < RailsSettings::Base
 
       default_settings.each do |key, default_value|
         next if records.key?(key) || default_value.is_a?(Hash)
+
         records[key] = Setting.new(var: key, value: default_value)
       end
 
@@ -51,6 +54,7 @@ class Setting < RailsSettings::Base
 
     def default_settings
       return {} unless RailsSettings::Default.enabled?
+
       RailsSettings::Default.instance
     end
   end
diff --git a/app/models/site_upload.rb b/app/models/site_upload.rb
index 167131fdd..e17668110 100644
--- a/app/models/site_upload.rb
+++ b/app/models/site_upload.rb
@@ -1,4 +1,5 @@
 # frozen_string_literal: true
+
 # == Schema Information
 #
 # Table name: site_uploads
diff --git a/app/models/status.rb b/app/models/status.rb
index c17921333..bf102120e 100644
--- a/app/models/status.rb
+++ b/app/models/status.rb
@@ -1,4 +1,5 @@
 # frozen_string_literal: true
+
 # == Schema Information
 #
 # Table name: statuses
@@ -50,12 +51,12 @@ class Status < ApplicationRecord
 
   update_index('statuses', :proper)
 
-  enum visibility: [:public, :unlisted, :private, :direct, :limited], _suffix: :visibility
+  enum visibility: { public: 0, unlisted: 1, private: 2, direct: 3, limited: 4 }, _suffix: :visibility
 
   belongs_to :application, class_name: 'Doorkeeper::Application', optional: true
 
   belongs_to :account, inverse_of: :statuses
-  belongs_to :in_reply_to_account, foreign_key: 'in_reply_to_account_id', class_name: 'Account', optional: true
+  belongs_to :in_reply_to_account, class_name: 'Account', optional: true
   belongs_to :conversation, optional: true
   belongs_to :preloadable_poll, class_name: 'Poll', foreign_key: 'poll_id', optional: true
 
@@ -97,7 +98,7 @@ class Status < ApplicationRecord
   scope :local,  -> { where(local: true).or(where(uri: nil)) }
   scope :with_accounts, ->(ids) { where(id: ids).includes(:account) }
   scope :without_replies, -> { where('statuses.reply = FALSE OR statuses.in_reply_to_account_id = statuses.account_id') }
-  scope :without_reblogs, -> { where('statuses.reblog_of_id IS NULL') }
+  scope :without_reblogs, -> { where(statuses: { reblog_of_id: nil }) }
   scope :with_public_visibility, -> { where(visibility: :public) }
   scope :tagged_with, ->(tag_ids) { joins(:statuses_tags).where(statuses_tags: { tag_id: tag_ids }) }
   scope :excluding_silenced_accounts, -> { left_outer_joins(:account).where(accounts: { silenced_at: nil }) }
diff --git a/app/models/status_edit.rb b/app/models/status_edit.rb
index 18095b4e6..653a04252 100644
--- a/app/models/status_edit.rb
+++ b/app/models/status_edit.rb
@@ -1,4 +1,5 @@
 # frozen_string_literal: true
+
 # == Schema Information
 #
 # Table name: status_edits
@@ -46,6 +47,7 @@ class StatusEdit < ApplicationRecord
 
   def emojis
     return @emojis if defined?(@emojis)
+
     @emojis = CustomEmoji.from_text([spoiler_text, text].join(' '), status.account.domain)
   end
 
diff --git a/app/models/status_pin.rb b/app/models/status_pin.rb
index 93a0ea1c0..dae4a5b4e 100644
--- a/app/models/status_pin.rb
+++ b/app/models/status_pin.rb
@@ -1,4 +1,5 @@
 # frozen_string_literal: true
+
 # == Schema Information
 #
 # Table name: status_pins
diff --git a/app/models/status_stat.rb b/app/models/status_stat.rb
index 437861d1c..d101cc178 100644
--- a/app/models/status_stat.rb
+++ b/app/models/status_stat.rb
@@ -1,4 +1,5 @@
 # frozen_string_literal: true
+
 # == Schema Information
 #
 # Table name: status_stats
diff --git a/app/models/tag.rb b/app/models/tag.rb
index 98001d60a..554a92d90 100644
--- a/app/models/tag.rb
+++ b/app/models/tag.rb
@@ -1,4 +1,5 @@
 # frozen_string_literal: true
+
 # == Schema Information
 #
 # Table name: tags
diff --git a/app/models/unavailable_domain.rb b/app/models/unavailable_domain.rb
index dfc0ef14e..c3f2f20e9 100644
--- a/app/models/unavailable_domain.rb
+++ b/app/models/unavailable_domain.rb
@@ -1,4 +1,5 @@
 # frozen_string_literal: true
+
 # == Schema Information
 #
 # Table name: unavailable_domains
diff --git a/app/models/user.rb b/app/models/user.rb
index 5ac1f663c..a90f43eda 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -1,4 +1,5 @@
 # frozen_string_literal: true
+
 # == Schema Information
 #
 # Table name: users
@@ -501,12 +502,14 @@ class User < ApplicationRecord
 
   def sanitize_languages
     return if chosen_languages.nil?
+
     chosen_languages.reject!(&:blank?)
     self.chosen_languages = nil if chosen_languages.empty?
   end
 
   def sanitize_role
     return if role.nil?
+
     self.role = nil if role.everyone?
   end
 
@@ -525,6 +528,7 @@ class User < ApplicationRecord
   def notify_staff_about_pending_account!
     User.those_who_can(:manage_users).includes(:account).find_each do |u|
       next unless u.allows_pending_account_emails?
+
       AdminMailer.new_pending_account(u.account, self).deliver_later
     end
   end
diff --git a/app/models/user_ip.rb b/app/models/user_ip.rb
index a8e802e13..38287c2a6 100644
--- a/app/models/user_ip.rb
+++ b/app/models/user_ip.rb
@@ -1,4 +1,5 @@
 # frozen_string_literal: true
+
 # == Schema Information
 #
 # Table name: user_ips
@@ -11,7 +12,7 @@
 class UserIp < ApplicationRecord
   self.primary_key = :user_id
 
-  belongs_to :user, foreign_key: :user_id
+  belongs_to :user
 
   def readonly?
     true
diff --git a/app/models/user_role.rb b/app/models/user_role.rb
index 74dfdc220..a1b91dc0f 100644
--- a/app/models/user_role.rb
+++ b/app/models/user_role.rb
@@ -163,6 +163,7 @@ class UserRole < ApplicationRecord
 
   def in_permissions?(privilege)
     raise ArgumentError, "Unknown privilege: #{privilege}" unless FLAGS.key?(privilege)
+
     computed_permissions & FLAGS[privilege] == FLAGS[privilege]
   end
 
@@ -172,6 +173,7 @@ class UserRole < ApplicationRecord
 
   def validate_own_role_edition
     return unless defined?(@current_account) && @current_account.user_role.id == id
+
     errors.add(:permissions_as_keys, :own_role) if permissions_changed?
     errors.add(:position, :own_role) if position_changed?
   end
diff --git a/app/models/web/push_subscription.rb b/app/models/web/push_subscription.rb
index dfaadf5cc..0ffbe068e 100644
--- a/app/models/web/push_subscription.rb
+++ b/app/models/web/push_subscription.rb
@@ -1,4 +1,5 @@
 # frozen_string_literal: true
+
 # == Schema Information
 #
 # Table name: web_push_subscriptions
diff --git a/app/models/web/setting.rb b/app/models/web/setting.rb
index 99588d26c..3d5efe664 100644
--- a/app/models/web/setting.rb
+++ b/app/models/web/setting.rb
@@ -1,4 +1,5 @@
 # frozen_string_literal: true
+
 # == Schema Information
 #
 # Table name: web_settings
diff --git a/app/models/webauthn_credential.rb b/app/models/webauthn_credential.rb
index 48abfc1d4..4fa31ece5 100644
--- a/app/models/webauthn_credential.rb
+++ b/app/models/webauthn_credential.rb
@@ -1,4 +1,5 @@
 # frozen_string_literal: true
+
 # == Schema Information
 #
 # Table name: webauthn_credentials