Model concerns organization into module namespaces (#28149)
This commit is contained in:
parent
b751078fcd
commit
440b80b2e7
31 changed files with 62 additions and 62 deletions
|
@ -70,19 +70,20 @@ class Account < ApplicationRecord
|
|||
URL_PREFIX_RE = %r{\Ahttp(s?)://[^/]+}
|
||||
USERNAME_ONLY_RE = /\A#{USERNAME_RE}\z/i
|
||||
|
||||
include Attachmentable
|
||||
include AccountAssociations
|
||||
include AccountAvatar
|
||||
include AccountFinderConcern
|
||||
include AccountHeader
|
||||
include AccountInteractions
|
||||
include Paginable
|
||||
include AccountCounters
|
||||
include DomainNormalizable
|
||||
include Attachmentable # Load prior to Avatar & Header concerns
|
||||
|
||||
include Account::Associations
|
||||
include Account::Avatar
|
||||
include Account::Counters
|
||||
include Account::FinderConcern
|
||||
include Account::Header
|
||||
include Account::Interactions
|
||||
include Account::Merging
|
||||
include Account::Search
|
||||
include Account::StatusesSearch
|
||||
include DomainMaterializable
|
||||
include AccountMerging
|
||||
include AccountSearch
|
||||
include AccountStatusesSearch
|
||||
include DomainNormalizable
|
||||
include Paginable
|
||||
|
||||
enum protocol: { ostatus: 0, activitypub: 1 }
|
||||
enum suspension_origin: { local: 0, remote: 1 }, _prefix: true
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module AccountAssociations
|
||||
module Account::Associations
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
|
@ -1,6 +1,6 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module AccountAvatar
|
||||
module Account::Avatar
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
IMAGE_MIME_TYPES = ['image/jpeg', 'image/png', 'image/gif', 'image/webp'].freeze
|
|
@ -1,6 +1,6 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module AccountCounters
|
||||
module Account::Counters
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
ALLOWED_COUNTER_KEYS = %i(statuses_count following_count followers_count).freeze
|
|
@ -1,6 +1,6 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module AccountFinderConcern
|
||||
module Account::FinderConcern
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
class_methods do
|
|
@ -1,6 +1,6 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module AccountHeader
|
||||
module Account::Header
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
IMAGE_MIME_TYPES = ['image/jpeg', 'image/png', 'image/gif', 'image/webp'].freeze
|
|
@ -1,6 +1,6 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module AccountInteractions
|
||||
module Account::Interactions
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
class_methods do
|
|
@ -1,6 +1,6 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module AccountMerging
|
||||
module Account::Merging
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
def merge_with!(other_account)
|
|
@ -1,6 +1,6 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module AccountSearch
|
||||
module Account::Search
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
DISALLOWED_TSQUERY_CHARACTERS = /['?\\:‘’]/
|
|
@ -1,6 +1,6 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module AccountStatusesSearch
|
||||
module Account::StatusesSearch
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
|
@ -1,6 +1,6 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module StatusSafeReblogInsert
|
||||
module Status::SafeReblogInsert
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
class_methods do
|
|
@ -1,6 +1,6 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module StatusSearchConcern
|
||||
module Status::SearchConcern
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
|
@ -1,6 +1,6 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module StatusSnapshotConcern
|
||||
module Status::SnapshotConcern
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
|
@ -1,6 +1,6 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module StatusThreadingConcern
|
||||
module Status::ThreadingConcern
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
def ancestors(limit, account = nil)
|
|
@ -1,6 +1,6 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module HasUserSettings
|
||||
module User::HasSettings
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
|
@ -1,6 +1,6 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module LdapAuthenticable
|
||||
module User::LdapAuthenticable
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
class_methods do
|
|
@ -1,6 +1,6 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Omniauthable
|
||||
module User::Omniauthable
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
TEMP_EMAIL_PREFIX = 'change@me'
|
|
@ -1,6 +1,6 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module PamAuthenticable
|
||||
module User::PamAuthenticable
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
|
@ -30,14 +30,14 @@
|
|||
#
|
||||
|
||||
class Status < ApplicationRecord
|
||||
include Cacheable
|
||||
include Discard::Model
|
||||
include Paginable
|
||||
include Cacheable
|
||||
include StatusThreadingConcern
|
||||
include StatusSnapshotConcern
|
||||
include RateLimitable
|
||||
include StatusSafeReblogInsert
|
||||
include StatusSearchConcern
|
||||
include Status::SafeReblogInsert
|
||||
include Status::SearchConcern
|
||||
include Status::SnapshotConcern
|
||||
include Status::ThreadingConcern
|
||||
|
||||
rate_limit by: :account, family: :statuses
|
||||
|
||||
|
|
|
@ -53,9 +53,12 @@ class User < ApplicationRecord
|
|||
filtered_languages
|
||||
)
|
||||
|
||||
include Redisable
|
||||
include LanguagesHelper
|
||||
include HasUserSettings
|
||||
include Redisable
|
||||
include User::HasSettings
|
||||
include User::LdapAuthenticable
|
||||
include User::Omniauthable
|
||||
include User::PamAuthenticable
|
||||
|
||||
# The home and list feeds will be stored in Redis for this amount
|
||||
# of time, and status fan-out to followers will include only people
|
||||
|
@ -75,10 +78,6 @@ class User < ApplicationRecord
|
|||
devise :registerable, :recoverable, :validatable,
|
||||
:confirmable
|
||||
|
||||
include Omniauthable
|
||||
include PamAuthenticable
|
||||
include LdapAuthenticable
|
||||
|
||||
belongs_to :account, inverse_of: :user
|
||||
belongs_to :invite, counter_cache: :uses, optional: true
|
||||
belongs_to :created_by_application, class_name: 'Doorkeeper::Application', optional: true
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
.fields-row
|
||||
.fields-row__column.fields-row__column-6
|
||||
.fields-group
|
||||
= f.input :avatar, wrapper: :with_block_label, input_html: { accept: AccountAvatar::IMAGE_MIME_TYPES.join(',') }, hint: t('simple_form.hints.defaults.avatar', dimensions: '400x400', size: number_to_human_size(AccountAvatar::LIMIT))
|
||||
= f.input :avatar, wrapper: :with_block_label, input_html: { accept: Account::Avatar::IMAGE_MIME_TYPES.join(',') }, hint: t('simple_form.hints.defaults.avatar', dimensions: '400x400', size: number_to_human_size(Account::Avatar::LIMIT))
|
||||
|
||||
.fields-row__column.fields-row__column-6
|
||||
.fields-group
|
||||
|
@ -46,7 +46,7 @@
|
|||
.fields-row
|
||||
.fields-row__column.fields-row__column-6
|
||||
.fields-group
|
||||
= f.input :header, wrapper: :with_block_label, input_html: { accept: AccountHeader::IMAGE_MIME_TYPES.join(',') }, hint: t('simple_form.hints.defaults.header', dimensions: '1500x500', size: number_to_human_size(AccountHeader::LIMIT))
|
||||
= f.input :header, wrapper: :with_block_label, input_html: { accept: Account::Header::IMAGE_MIME_TYPES.join(',') }, hint: t('simple_form.hints.defaults.header', dimensions: '1500x500', size: number_to_human_size(Account::Header::LIMIT))
|
||||
|
||||
.fields-row__column.fields-row__column-6
|
||||
.fields-group
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue