mirror of
https://github.com/mastodon/mastodon.git
synced 2024-11-25 07:05:20 +00:00
Add Account.without_internal
scope (#29559)
Co-authored-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
parent
acf3f410ae
commit
c09b8a7164
|
@ -129,7 +129,7 @@ class ApplicationController < ActionController::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def single_user_mode?
|
def single_user_mode?
|
||||||
@single_user_mode ||= Rails.configuration.x.single_user_mode && Account.where('id > 0').exists?
|
@single_user_mode ||= Rails.configuration.x.single_user_mode && Account.without_internal.exists?
|
||||||
end
|
end
|
||||||
|
|
||||||
def use_seamless_external_login?
|
def use_seamless_external_login?
|
||||||
|
|
|
@ -213,7 +213,7 @@ module ApplicationHelper
|
||||||
state_params[:moved_to_account] = current_account.moved_to_account
|
state_params[:moved_to_account] = current_account.moved_to_account
|
||||||
end
|
end
|
||||||
|
|
||||||
state_params[:owner] = Account.local.without_suspended.where('id > 0').first if single_user_mode?
|
state_params[:owner] = Account.local.without_suspended.without_internal.first if single_user_mode?
|
||||||
|
|
||||||
json = ActiveModelSerializers::SerializableResource.new(InitialStatePresenter.new(state_params), serializer: InitialStateSerializer).to_json
|
json = ActiveModelSerializers::SerializableResource.new(InitialStatePresenter.new(state_params), serializer: InitialStateSerializer).to_json
|
||||||
# rubocop:disable Rails/OutputSafety
|
# rubocop:disable Rails/OutputSafety
|
||||||
|
|
|
@ -111,6 +111,7 @@ class Account < ApplicationRecord
|
||||||
|
|
||||||
normalizes :username, with: ->(username) { username.squish }
|
normalizes :username, with: ->(username) { username.squish }
|
||||||
|
|
||||||
|
scope :without_internal, -> { where(id: 1...) }
|
||||||
scope :remote, -> { where.not(domain: nil) }
|
scope :remote, -> { where.not(domain: nil) }
|
||||||
scope :local, -> { where(domain: nil) }
|
scope :local, -> { where(domain: nil) }
|
||||||
scope :partitioned, -> { order(Arel.sql('row_number() over (partition by domain)')) }
|
scope :partitioned, -> { order(Arel.sql('row_number() over (partition by domain)')) }
|
||||||
|
|
|
@ -888,7 +888,7 @@ RSpec.describe Account do
|
||||||
{ username: 'b', domain: 'b' },
|
{ username: 'b', domain: 'b' },
|
||||||
].map(&method(:Fabricate).curry(2).call(:account))
|
].map(&method(:Fabricate).curry(2).call(:account))
|
||||||
|
|
||||||
expect(described_class.where('id > 0').alphabetic).to eq matches
|
expect(described_class.without_internal.alphabetic).to eq matches
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -939,7 +939,7 @@ RSpec.describe Account do
|
||||||
it 'returns an array of accounts who do not have a domain' do
|
it 'returns an array of accounts who do not have a domain' do
|
||||||
local_account = Fabricate(:account, domain: nil)
|
local_account = Fabricate(:account, domain: nil)
|
||||||
_account_with_domain = Fabricate(:account, domain: 'example.com')
|
_account_with_domain = Fabricate(:account, domain: 'example.com')
|
||||||
expect(described_class.where('id > 0').local).to contain_exactly(local_account)
|
expect(described_class.without_internal.local).to contain_exactly(local_account)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -950,14 +950,14 @@ RSpec.describe Account do
|
||||||
matches[index] = Fabricate(:account, domain: matches[index])
|
matches[index] = Fabricate(:account, domain: matches[index])
|
||||||
end
|
end
|
||||||
|
|
||||||
expect(described_class.where('id > 0').partitioned).to match_array(matches)
|
expect(described_class.without_internal.partitioned).to match_array(matches)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'recent' do
|
describe 'recent' do
|
||||||
it 'returns a relation of accounts sorted by recent creation' do
|
it 'returns a relation of accounts sorted by recent creation' do
|
||||||
matches = Array.new(2) { Fabricate(:account) }
|
matches = Array.new(2) { Fabricate(:account) }
|
||||||
expect(described_class.where('id > 0').recent).to match_array(matches)
|
expect(described_class.without_internal.recent).to match_array(matches)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue