Merge remote-tracking branch 'parent/main' into upstream-20240218

This commit is contained in:
KMY 2024-02-18 14:39:40 +09:00
commit a1f88f6001
27 changed files with 131 additions and 169 deletions

View file

@ -92,9 +92,9 @@ class Account < ApplicationRecord
include DomainNormalizable
include Paginable
enum protocol: { ostatus: 0, activitypub: 1 }
enum suspension_origin: { local: 0, remote: 1 }, _prefix: true
enum searchability: { public: 0, private: 1, direct: 2, limited: 3, unsupported: 4, public_unlisted: 10 }, _suffix: :searchability
enum :protocol, { ostatus: 0, activitypub: 1 }
enum :suspension_origin, { local: 0, remote: 1 }, prefix: true
enum :searchability, { public: 0, private: 1, direct: 2, limited: 3, unsupported: 4, public_unlisted: 10 }, suffix: :searchability
validates :username, presence: true
validates_with UniqueUsernameValidator, if: -> { will_save_change_to_username? }

View file

@ -17,7 +17,7 @@
#
class AccountWarning < ApplicationRecord
enum action: {
enum :action, {
none: 0,
disable: 1_000,
force_cw: 1_200,
@ -26,7 +26,7 @@ class AccountWarning < ApplicationRecord
sensitive: 2_000,
silence: 3_000,
suspend: 4_000,
}, _suffix: :action
}, suffix: :action
normalizes :text, with: ->(text) { text.to_s }, apply_to_nil: true

View file

@ -24,7 +24,7 @@ class BulkImport < ApplicationRecord
belongs_to :account
has_many :rows, class_name: 'BulkImportRow', inverse_of: :bulk_import, dependent: :delete_all
enum type: {
enum :type, {
following: 0,
blocking: 1,
muting: 2,
@ -33,7 +33,7 @@ class BulkImport < ApplicationRecord
lists: 5,
}
enum state: {
enum :state, {
unconfirmed: 0,
scheduled: 1,
in_progress: 2,

View file

@ -35,7 +35,7 @@ class CustomFilter < ApplicationRecord
include Expireable
include Redisable
enum action: { warn: 0, hide: 1, half_warn: 2 }, _suffix: :action
enum :action, { warn: 0, hide: 1, half_warn: 2 }, suffix: :action
belongs_to :account
has_many :keywords, class_name: 'CustomFilterKeyword', inverse_of: :custom_filter, dependent: :destroy

View file

@ -32,7 +32,7 @@ class DomainBlock < ApplicationRecord
include DomainNormalizable
include DomainMaterializable
enum severity: { silence: 0, suspend: 1, noop: 2 }
enum :severity, { silence: 0, suspend: 1, noop: 2 }
validates :domain, presence: true, uniqueness: true, domain: true

View file

@ -23,8 +23,8 @@ class FriendDomain < ApplicationRecord
validates :domain, presence: true, uniqueness: true, if: :will_save_change_to_domain?
validates :inbox_url, presence: true, uniqueness: true, if: :will_save_change_to_inbox_url?
enum active_state: { idle: 0, pending: 1, accepted: 2, rejected: 3 }, _prefix: :i_am
enum passive_state: { idle: 0, pending: 1, accepted: 2, rejected: 3 }, _prefix: :they_are
enum :active_state, { idle: 0, pending: 1, accepted: 2, rejected: 3 }, prefix: :i_am
enum :passive_state, { idle: 0, pending: 1, accepted: 2, rejected: 3 }, prefix: :they_are
scope :by_domain_and_subdomains, ->(domain) { where(domain: Instance.by_domain_and_subdomains(domain).select(:domain)) }
scope :enabled, -> { where(active_state: :accepted).or(FriendDomain.where(passive_state: :accepted)).where(available: true) }

View file

@ -28,7 +28,7 @@ class Import < ApplicationRecord
belongs_to :account
enum type: { following: 0, blocking: 1, muting: 2, domain_blocking: 3, bookmarks: 4 }
enum :type, { following: 0, blocking: 1, muting: 2, domain_blocking: 3, bookmarks: 4 }
validates :type, presence: true

View file

@ -19,7 +19,7 @@ class IpBlock < ApplicationRecord
include Expireable
include Paginable
enum severity: {
enum :severity, {
sign_up_requires_approval: 5000,
sign_up_block: 5500,
no_access: 9999,

View file

@ -19,7 +19,7 @@ class List < ApplicationRecord
PER_ACCOUNT_LIMIT = 50
enum replies_policy: { list: 0, followed: 1, none: 2 }, _prefix: :show
enum :replies_policy, { list: 0, followed: 1, none: 2 }, prefix: :show
belongs_to :account, optional: true

View file

@ -16,7 +16,7 @@
#
class LoginActivity < ApplicationRecord
enum authentication_method: { password: 'password', otp: 'otp', webauthn: 'webauthn', sign_in_token: 'sign_in_token', omniauth: 'omniauth' }
enum :authentication_method, { password: 'password', otp: 'otp', webauthn: 'webauthn', sign_in_token: 'sign_in_token', omniauth: 'omniauth' }
belongs_to :user

View file

@ -39,8 +39,8 @@ class MediaAttachment < ApplicationRecord
LOCAL_STATUS_ATTACHMENT_MAX_WITH_POLL = 4
ACTIVITYPUB_STATUS_ATTACHMENT_MAX = 16
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
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

View file

@ -17,6 +17,6 @@
class NgwordHistory < ApplicationRecord
include Paginable
enum target_type: { status: 0, account_note: 1, account_name: 2 }, _suffix: :blocked
enum reason: { ng_words: 0, ng_words_for_stranger_mention: 1, hashtag_count: 2, mention_count: 3, stranger_mention_count: 4 }, _prefix: :within
enum :target_type, { status: 0, account_note: 1, account_name: 2 }, suffix: :blocked
enum :reason, { ng_words: 0, ng_words_for_stranger_mention: 1, hashtag_count: 2, mention_count: 3, stranger_mention_count: 4 }, prefix: :within
end

View file

@ -47,8 +47,8 @@ class PreviewCard < ApplicationRecord
self.inheritance_column = false
enum type: { link: 0, photo: 1, video: 2, rich: 3 }
enum link_type: { unknown: 0, article: 1 }
enum :type, { link: 0, photo: 1, video: 2, rich: 3 }
enum :link_type, { unknown: 0, article: 1 }
has_many :preview_cards_statuses, dependent: :delete_all, inverse_of: :preview_card
has_many :statuses, through: :preview_cards_statuses

View file

@ -15,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: 0, pending: 1, accepted: 2, rejected: 3 }
enum :state, { idle: 0, pending: 1, accepted: 2, rejected: 3 }
scope :enabled, -> { accepted }

View file

@ -55,7 +55,7 @@ class Report < ApplicationRecord
# - app/javascript/mastodon/features/notifications/components/report.jsx
# - app/javascript/mastodon/features/report/category.jsx
# - app/javascript/mastodon/components/admin/ReportReasonSelector.jsx
enum category: {
enum :category, {
other: 0,
spam: 1_000,
legal: 1_500,

View file

@ -16,7 +16,7 @@
class SoftwareUpdate < ApplicationRecord
self.inheritance_column = nil
enum type: { patch: 0, minor: 1, major: 2 }, _suffix: :type
enum :type, { patch: 0, minor: 1, major: 2 }, suffix: :type
def gem_version
Gem::Version.new(version)

View file

@ -58,9 +58,9 @@ class Status < ApplicationRecord
update_index('statuses', :proper)
update_index('public_statuses', :proper)
enum visibility: { public: 0, unlisted: 1, private: 2, direct: 3, limited: 4, public_unlisted: 10, login: 11 }, _suffix: :visibility
enum searchability: { public: 0, private: 1, direct: 2, limited: 3, unsupported: 4, public_unlisted: 10 }, _suffix: :searchability
enum limited_scope: { none: 0, mutual: 1, circle: 2, personal: 3, reply: 4 }, _suffix: :limited
enum :visibility, { public: 0, unlisted: 1, private: 2, direct: 3, limited: 4, public_unlisted: 10, login: 11 }, suffix: :visibility
enum :searchability, { public: 0, private: 1, direct: 2, limited: 3, unsupported: 4, public_unlisted: 10 }, suffix: :searchability
enum :limited_scope, { none: 0, mutual: 1, circle: 2, personal: 3, reply: 4 }, suffix: :limited
belongs_to :application, class_name: 'Doorkeeper::Application', optional: true