Merge commit 'aa98c8fbeb
' into kb_migration
This commit is contained in:
commit
370f25f3cd
46 changed files with 714 additions and 288 deletions
|
@ -17,13 +17,13 @@ class AccountFilter
|
|||
attr_reader :params
|
||||
|
||||
def initialize(params)
|
||||
@params = params
|
||||
@params = params.to_h.symbolize_keys
|
||||
end
|
||||
|
||||
def results
|
||||
scope = Account.includes(:account_stat, user: [:ips, :invite_request]).without_instance_actor.reorder(nil)
|
||||
|
||||
params.each do |key, value|
|
||||
relevant_params.each do |key, value|
|
||||
next if key.to_s == 'page'
|
||||
|
||||
scope.merge!(scope_for(key, value)) if value.present?
|
||||
|
@ -34,6 +34,16 @@ class AccountFilter
|
|||
|
||||
private
|
||||
|
||||
def relevant_params
|
||||
params.tap do |args|
|
||||
args.delete(:origin) if origin_is_remote_and_domain_present?
|
||||
end
|
||||
end
|
||||
|
||||
def origin_is_remote_and_domain_present?
|
||||
params[:origin] == 'remote' && params[:by_domain].present?
|
||||
end
|
||||
|
||||
def scope_for(key, value)
|
||||
case key.to_s
|
||||
when 'origin'
|
||||
|
@ -94,7 +104,15 @@ class AccountFilter
|
|||
def order_scope(value)
|
||||
case value.to_s
|
||||
when 'active'
|
||||
accounts_with_users.left_joins(:account_stat).order(Arel.sql('coalesce(users.current_sign_in_at, account_stats.last_status_at, to_timestamp(0)) desc, accounts.id desc'))
|
||||
accounts_with_users
|
||||
.left_joins(:account_stat)
|
||||
.order(
|
||||
Arel.sql(
|
||||
<<~SQL.squish
|
||||
COALESCE(users.current_sign_in_at, account_stats.last_status_at, to_timestamp(0)) DESC, accounts.id DESC
|
||||
SQL
|
||||
)
|
||||
)
|
||||
when 'recent'
|
||||
Account.recent
|
||||
else
|
||||
|
|
|
@ -61,7 +61,7 @@ module Omniauthable
|
|||
user.account.avatar_remote_url = nil
|
||||
end
|
||||
|
||||
user.skip_confirmation! if email_is_verified
|
||||
user.confirm! if email_is_verified
|
||||
user.save!
|
||||
user
|
||||
end
|
||||
|
|
|
@ -17,8 +17,8 @@ class Form::AccountBatch
|
|||
unfollow!
|
||||
when 'remove_from_followers'
|
||||
remove_from_followers!
|
||||
when 'block_domains'
|
||||
block_domains!
|
||||
when 'remove_domains_from_followers'
|
||||
remove_domains_from_followers!
|
||||
when 'approve'
|
||||
approve!
|
||||
when 'reject'
|
||||
|
@ -35,9 +35,15 @@ class Form::AccountBatch
|
|||
private
|
||||
|
||||
def follow!
|
||||
error = nil
|
||||
|
||||
accounts.each do |target_account|
|
||||
FollowService.new.call(current_account, target_account)
|
||||
rescue Mastodon::NotPermittedError, ActiveRecord::RecordNotFound => e
|
||||
error ||= e
|
||||
end
|
||||
|
||||
raise error if error.present?
|
||||
end
|
||||
|
||||
def unfollow!
|
||||
|
@ -50,10 +56,8 @@ class Form::AccountBatch
|
|||
RemoveFromFollowersService.new.call(current_account, account_ids)
|
||||
end
|
||||
|
||||
def block_domains!
|
||||
AfterAccountDomainBlockWorker.push_bulk(account_domains) do |domain|
|
||||
[current_account.id, domain]
|
||||
end
|
||||
def remove_domains_from_followers!
|
||||
RemoveDomainsFromFollowersService.new.call(current_account, account_domains)
|
||||
end
|
||||
|
||||
def account_domains
|
||||
|
|
|
@ -235,6 +235,16 @@ class Status < ApplicationRecord
|
|||
public_visibility? || unlisted_visibility?
|
||||
end
|
||||
|
||||
def translatable?
|
||||
translate_target_locale = I18n.locale.to_s.split(/[_-]/).first
|
||||
|
||||
distributable? &&
|
||||
content.present? &&
|
||||
language != translate_target_locale &&
|
||||
TranslationService.configured? &&
|
||||
TranslationService.configured.supported?(language, translate_target_locale)
|
||||
end
|
||||
|
||||
alias sign? distributable?
|
||||
|
||||
def with_media?
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue