Add `Account#unavailable?` and `Account#permanently_unavailable?` aliases (#28053)
parent
35deaaf90b
commit
963354978a
|
@ -105,7 +105,7 @@ class Api::BaseController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def require_not_suspended!
|
def require_not_suspended!
|
||||||
render json: { error: 'Your login is currently disabled' }, status: 403 if current_user&.account&.suspended?
|
render json: { error: 'Your login is currently disabled' }, status: 403 if current_user&.account&.unavailable?
|
||||||
end
|
end
|
||||||
|
|
||||||
def require_user!
|
def require_user!
|
||||||
|
|
|
@ -26,7 +26,7 @@ class Api::V1::Accounts::FollowerAccountsController < Api::BaseController
|
||||||
end
|
end
|
||||||
|
|
||||||
def hide_results?
|
def hide_results?
|
||||||
@account.suspended? || (@account.hides_followers? && current_account&.id != @account.id) || (current_account && @account.blocking?(current_account))
|
@account.unavailable? || (@account.hides_followers? && current_account&.id != @account.id) || (current_account && @account.blocking?(current_account))
|
||||||
end
|
end
|
||||||
|
|
||||||
def default_accounts
|
def default_accounts
|
||||||
|
|
|
@ -26,7 +26,7 @@ class Api::V1::Accounts::FollowingAccountsController < Api::BaseController
|
||||||
end
|
end
|
||||||
|
|
||||||
def hide_results?
|
def hide_results?
|
||||||
@account.suspended? || (@account.hides_following? && current_account&.id != @account.id) || (current_account && @account.blocking?(current_account))
|
@account.unavailable? || (@account.hides_following? && current_account&.id != @account.id) || (current_account && @account.blocking?(current_account))
|
||||||
end
|
end
|
||||||
|
|
||||||
def default_accounts
|
def default_accounts
|
||||||
|
|
|
@ -19,7 +19,7 @@ class Api::V1::Accounts::StatusesController < Api::BaseController
|
||||||
end
|
end
|
||||||
|
|
||||||
def load_statuses
|
def load_statuses
|
||||||
@account.suspended? ? [] : cached_account_statuses
|
@account.unavailable? ? [] : cached_account_statuses
|
||||||
end
|
end
|
||||||
|
|
||||||
def cached_account_statuses
|
def cached_account_statuses
|
||||||
|
|
|
@ -120,7 +120,7 @@ class Auth::RegistrationsController < Devise::RegistrationsController
|
||||||
end
|
end
|
||||||
|
|
||||||
def require_not_suspended!
|
def require_not_suspended!
|
||||||
forbidden if current_account.suspended?
|
forbidden if current_account.unavailable?
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_rules
|
def set_rules
|
||||||
|
|
|
@ -34,8 +34,8 @@ module AccountOwnedConcern
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_account_suspension
|
def check_account_suspension
|
||||||
if @account.suspended_permanently?
|
if @account.permanently_unavailable?
|
||||||
permanent_suspension_response
|
permanent_unavailability_response
|
||||||
elsif @account.suspended? && !skip_temporary_suspension_response?
|
elsif @account.suspended? && !skip_temporary_suspension_response?
|
||||||
temporary_suspension_response
|
temporary_suspension_response
|
||||||
end
|
end
|
||||||
|
@ -45,7 +45,7 @@ module AccountOwnedConcern
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
def permanent_suspension_response
|
def permanent_unavailability_response
|
||||||
expires_in(3.minutes, public: true)
|
expires_in(3.minutes, public: true)
|
||||||
gone
|
gone
|
||||||
end
|
end
|
||||||
|
|
|
@ -31,7 +31,7 @@ class Oauth::AuthorizedApplicationsController < Doorkeeper::AuthorizedApplicatio
|
||||||
end
|
end
|
||||||
|
|
||||||
def require_not_suspended!
|
def require_not_suspended!
|
||||||
forbidden if current_account.suspended?
|
forbidden if current_account.unavailable?
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_cache_headers
|
def set_cache_headers
|
||||||
|
|
|
@ -18,6 +18,6 @@ class Settings::BaseController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def require_not_suspended!
|
def require_not_suspended!
|
||||||
forbidden if current_account.suspended?
|
forbidden if current_account.unavailable?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -25,7 +25,7 @@ class Settings::DeletesController < Settings::BaseController
|
||||||
end
|
end
|
||||||
|
|
||||||
def require_not_suspended!
|
def require_not_suspended!
|
||||||
forbidden if current_account.suspended?
|
forbidden if current_account.unavailable?
|
||||||
end
|
end
|
||||||
|
|
||||||
def challenge_passed?
|
def challenge_passed?
|
||||||
|
|
|
@ -42,7 +42,7 @@ module WellKnown
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_account_suspension
|
def check_account_suspension
|
||||||
gone if @account.suspended_permanently?
|
gone if @account.permanently_unavailable?
|
||||||
end
|
end
|
||||||
|
|
||||||
def gone
|
def gone
|
||||||
|
|
|
@ -32,7 +32,7 @@ class AccountStatusesFilter
|
||||||
private
|
private
|
||||||
|
|
||||||
def initial_scope
|
def initial_scope
|
||||||
return Status.none if suspended?
|
return Status.none if account.unavailable?
|
||||||
|
|
||||||
if anonymous?
|
if anonymous?
|
||||||
account.statuses.where(visibility: %i(public unlisted))
|
account.statuses.where(visibility: %i(public unlisted))
|
||||||
|
@ -95,10 +95,6 @@ class AccountStatusesFilter
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def suspended?
|
|
||||||
account.suspended?
|
|
||||||
end
|
|
||||||
|
|
||||||
def anonymous?
|
def anonymous?
|
||||||
current_account.nil?
|
current_account.nil?
|
||||||
end
|
end
|
||||||
|
|
|
@ -9,7 +9,7 @@ class ActivityPub::Activity::Move < ActivityPub::Activity
|
||||||
|
|
||||||
target_account = ActivityPub::FetchRemoteAccountService.new.call(target_uri)
|
target_account = ActivityPub::FetchRemoteAccountService.new.call(target_uri)
|
||||||
|
|
||||||
if target_account.nil? || target_account.suspended? || !target_account.also_known_as.include?(origin_account.uri)
|
if target_account.nil? || target_account.unavailable? || !target_account.also_known_as.include?(origin_account.uri)
|
||||||
unmark_as_processing!
|
unmark_as_processing!
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
|
@ -246,6 +246,9 @@ class Account < ApplicationRecord
|
||||||
suspended? && deletion_request.present?
|
suspended? && deletion_request.present?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
alias unavailable? suspended?
|
||||||
|
alias permanently_unavailable? suspended_permanently?
|
||||||
|
|
||||||
def suspend!(date: Time.now.utc, origin: :local, block_email: true)
|
def suspend!(date: Time.now.utc, origin: :local, block_email: true)
|
||||||
transaction do
|
transaction do
|
||||||
create_deletion_request!
|
create_deletion_request!
|
||||||
|
|
|
@ -250,7 +250,7 @@ class User < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def functional_or_moved?
|
def functional_or_moved?
|
||||||
confirmed? && approved? && !disabled? && !account.suspended? && !account.memorial?
|
confirmed? && approved? && !disabled? && !account.unavailable? && !account.memorial?
|
||||||
end
|
end
|
||||||
|
|
||||||
def unconfirmed?
|
def unconfirmed?
|
||||||
|
|
|
@ -8,7 +8,7 @@ class StatusPolicy < ApplicationPolicy
|
||||||
end
|
end
|
||||||
|
|
||||||
def show?
|
def show?
|
||||||
return false if author.suspended?
|
return false if author.unavailable?
|
||||||
|
|
||||||
if requires_mention?
|
if requires_mention?
|
||||||
owned? || mention_exists?
|
owned? || mention_exists?
|
||||||
|
|
|
@ -96,19 +96,19 @@ class ActivityPub::ActorSerializer < ActivityPub::Serializer
|
||||||
end
|
end
|
||||||
|
|
||||||
def discoverable
|
def discoverable
|
||||||
object.suspended? ? false : (object.discoverable || false)
|
object.unavailable? ? false : (object.discoverable || false)
|
||||||
end
|
end
|
||||||
|
|
||||||
def indexable
|
def indexable
|
||||||
object.suspended? ? false : (object.indexable || false)
|
object.unavailable? ? false : (object.indexable || false)
|
||||||
end
|
end
|
||||||
|
|
||||||
def name
|
def name
|
||||||
object.suspended? ? object.username : (object.display_name.presence || object.username)
|
object.unavailable? ? object.username : (object.display_name.presence || object.username)
|
||||||
end
|
end
|
||||||
|
|
||||||
def summary
|
def summary
|
||||||
object.suspended? ? '' : account_bio_format(object)
|
object.unavailable? ? '' : account_bio_format(object)
|
||||||
end
|
end
|
||||||
|
|
||||||
def icon
|
def icon
|
||||||
|
@ -132,23 +132,23 @@ class ActivityPub::ActorSerializer < ActivityPub::Serializer
|
||||||
end
|
end
|
||||||
|
|
||||||
def avatar_exists?
|
def avatar_exists?
|
||||||
!object.suspended? && object.avatar?
|
!object.unavailable? && object.avatar?
|
||||||
end
|
end
|
||||||
|
|
||||||
def header_exists?
|
def header_exists?
|
||||||
!object.suspended? && object.header?
|
!object.unavailable? && object.header?
|
||||||
end
|
end
|
||||||
|
|
||||||
def manually_approves_followers
|
def manually_approves_followers
|
||||||
object.suspended? ? false : object.locked
|
object.unavailable? ? false : object.locked
|
||||||
end
|
end
|
||||||
|
|
||||||
def virtual_tags
|
def virtual_tags
|
||||||
object.suspended? ? [] : (object.emojis + object.tags)
|
object.unavailable? ? [] : (object.emojis + object.tags)
|
||||||
end
|
end
|
||||||
|
|
||||||
def virtual_attachments
|
def virtual_attachments
|
||||||
object.suspended? ? [] : object.fields
|
object.unavailable? ? [] : object.fields
|
||||||
end
|
end
|
||||||
|
|
||||||
def moved_to
|
def moved_to
|
||||||
|
@ -156,11 +156,11 @@ class ActivityPub::ActorSerializer < ActivityPub::Serializer
|
||||||
end
|
end
|
||||||
|
|
||||||
def moved?
|
def moved?
|
||||||
!object.suspended? && object.moved?
|
!object.unavailable? && object.moved?
|
||||||
end
|
end
|
||||||
|
|
||||||
def also_known_as?
|
def also_known_as?
|
||||||
!object.suspended? && !object.also_known_as.empty?
|
!object.unavailable? && !object.also_known_as.empty?
|
||||||
end
|
end
|
||||||
|
|
||||||
def published
|
def published
|
||||||
|
|
|
@ -61,7 +61,7 @@ class REST::AccountSerializer < ActiveModel::Serializer
|
||||||
end
|
end
|
||||||
|
|
||||||
def note
|
def note
|
||||||
object.suspended? ? '' : account_bio_format(object)
|
object.unavailable? ? '' : account_bio_format(object)
|
||||||
end
|
end
|
||||||
|
|
||||||
def url
|
def url
|
||||||
|
@ -73,19 +73,19 @@ class REST::AccountSerializer < ActiveModel::Serializer
|
||||||
end
|
end
|
||||||
|
|
||||||
def avatar
|
def avatar
|
||||||
full_asset_url(object.suspended? ? object.avatar.default_url : object.avatar_original_url)
|
full_asset_url(object.unavailable? ? object.avatar.default_url : object.avatar_original_url)
|
||||||
end
|
end
|
||||||
|
|
||||||
def avatar_static
|
def avatar_static
|
||||||
full_asset_url(object.suspended? ? object.avatar.default_url : object.avatar_static_url)
|
full_asset_url(object.unavailable? ? object.avatar.default_url : object.avatar_static_url)
|
||||||
end
|
end
|
||||||
|
|
||||||
def header
|
def header
|
||||||
full_asset_url(object.suspended? ? object.header.default_url : object.header_original_url)
|
full_asset_url(object.unavailable? ? object.header.default_url : object.header_original_url)
|
||||||
end
|
end
|
||||||
|
|
||||||
def header_static
|
def header_static
|
||||||
full_asset_url(object.suspended? ? object.header.default_url : object.header_static_url)
|
full_asset_url(object.unavailable? ? object.header.default_url : object.header_static_url)
|
||||||
end
|
end
|
||||||
|
|
||||||
def created_at
|
def created_at
|
||||||
|
@ -97,39 +97,39 @@ class REST::AccountSerializer < ActiveModel::Serializer
|
||||||
end
|
end
|
||||||
|
|
||||||
def display_name
|
def display_name
|
||||||
object.suspended? ? '' : object.display_name
|
object.unavailable? ? '' : object.display_name
|
||||||
end
|
end
|
||||||
|
|
||||||
def locked
|
def locked
|
||||||
object.suspended? ? false : object.locked
|
object.unavailable? ? false : object.locked
|
||||||
end
|
end
|
||||||
|
|
||||||
def bot
|
def bot
|
||||||
object.suspended? ? false : object.bot
|
object.unavailable? ? false : object.bot
|
||||||
end
|
end
|
||||||
|
|
||||||
def discoverable
|
def discoverable
|
||||||
object.suspended? ? false : object.discoverable
|
object.unavailable? ? false : object.discoverable
|
||||||
end
|
end
|
||||||
|
|
||||||
def indexable
|
def indexable
|
||||||
object.suspended? ? false : object.indexable
|
object.unavailable? ? false : object.indexable
|
||||||
end
|
end
|
||||||
|
|
||||||
def moved_to_account
|
def moved_to_account
|
||||||
object.suspended? ? nil : AccountDecorator.new(object.moved_to_account)
|
object.unavailable? ? nil : AccountDecorator.new(object.moved_to_account)
|
||||||
end
|
end
|
||||||
|
|
||||||
def emojis
|
def emojis
|
||||||
object.suspended? ? [] : object.emojis
|
object.unavailable? ? [] : object.emojis
|
||||||
end
|
end
|
||||||
|
|
||||||
def fields
|
def fields
|
||||||
object.suspended? ? [] : object.fields
|
object.unavailable? ? [] : object.fields
|
||||||
end
|
end
|
||||||
|
|
||||||
def suspended
|
def suspended
|
||||||
object.suspended?
|
object.unavailable?
|
||||||
end
|
end
|
||||||
|
|
||||||
def silenced
|
def silenced
|
||||||
|
@ -141,7 +141,7 @@ class REST::AccountSerializer < ActiveModel::Serializer
|
||||||
end
|
end
|
||||||
|
|
||||||
def roles
|
def roles
|
||||||
if object.suspended? || object.user.nil?
|
if object.unavailable? || object.user.nil?
|
||||||
[]
|
[]
|
||||||
else
|
else
|
||||||
[object.user.role].compact.filter(&:highlighted?)
|
[object.user.role].compact.filter(&:highlighted?)
|
||||||
|
|
|
@ -50,7 +50,7 @@ class FollowService < BaseService
|
||||||
end
|
end
|
||||||
|
|
||||||
def following_not_possible?
|
def following_not_possible?
|
||||||
@target_account.nil? || @target_account.id == @source_account.id || @target_account.suspended?
|
@target_account.nil? || @target_account.id == @source_account.id || @target_account.unavailable?
|
||||||
end
|
end
|
||||||
|
|
||||||
def following_not_allowed?
|
def following_not_allowed?
|
||||||
|
|
|
@ -108,7 +108,7 @@ class NotifyService < BaseService
|
||||||
end
|
end
|
||||||
|
|
||||||
def blocked?
|
def blocked?
|
||||||
blocked = @recipient.suspended?
|
blocked = @recipient.unavailable?
|
||||||
blocked ||= from_self? && @notification.type != :poll
|
blocked ||= from_self? && @notification.type != :poll
|
||||||
|
|
||||||
return blocked if message? && from_staff?
|
return blocked if message? && from_staff?
|
||||||
|
|
|
@ -51,7 +51,7 @@ class ProcessMentionsService < BaseService
|
||||||
|
|
||||||
# If after resolving it still isn't found or isn't the right
|
# If after resolving it still isn't found or isn't the right
|
||||||
# protocol, then give up
|
# protocol, then give up
|
||||||
next match if mention_undeliverable?(mentioned_account) || mentioned_account&.suspended?
|
next match if mention_undeliverable?(mentioned_account) || mentioned_account&.unavailable?
|
||||||
|
|
||||||
mention = @previous_mentions.find { |x| x.account_id == mentioned_account.id }
|
mention = @previous_mentions.find { |x| x.account_id == mentioned_account.id }
|
||||||
mention ||= @current_mentions.find { |x| x.account_id == mentioned_account.id }
|
mention ||= @current_mentions.find { |x| x.account_id == mentioned_account.id }
|
||||||
|
|
|
@ -12,7 +12,7 @@ class ReportService < BaseService
|
||||||
@rule_ids = options.delete(:rule_ids).presence
|
@rule_ids = options.delete(:rule_ids).presence
|
||||||
@options = options
|
@options = options
|
||||||
|
|
||||||
raise ActiveRecord::RecordNotFound if @target_account.suspended?
|
raise ActiveRecord::RecordNotFound if @target_account.unavailable?
|
||||||
|
|
||||||
create_report!
|
create_report!
|
||||||
notify_staff!
|
notify_staff!
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
.batch-table__row{ class: [!account.suspended? && account.user_pending? && 'batch-table__row--attention', (account.suspended? || account.user_unconfirmed?) && 'batch-table__row--muted'] }
|
.batch-table__row{ class: [!account.unavailable? && account.user_pending? && 'batch-table__row--attention', (account.unavailable? || account.user_unconfirmed?) && 'batch-table__row--muted'] }
|
||||||
%label.batch-table__row__select.batch-table__row__select--aligned.batch-checkbox
|
%label.batch-table__row__select.batch-table__row__select--aligned.batch-checkbox
|
||||||
= f.check_box :account_ids, { multiple: true, include_hidden: false }, account.id
|
= f.check_box :account_ids, { multiple: true, include_hidden: false }, account.id
|
||||||
.batch-table__row__content.batch-table__row__content--unpadded
|
.batch-table__row__content.batch-table__row__content--unpadded
|
||||||
|
@ -8,13 +8,13 @@
|
||||||
%td
|
%td
|
||||||
= account_link_to account, path: admin_account_path(account.id)
|
= account_link_to account, path: admin_account_path(account.id)
|
||||||
%td.accounts-table__count.optional
|
%td.accounts-table__count.optional
|
||||||
- if account.suspended? || account.user_pending?
|
- if account.unavailable? || account.user_pending?
|
||||||
\-
|
\-
|
||||||
- else
|
- else
|
||||||
= friendly_number_to_human account.statuses_count
|
= friendly_number_to_human account.statuses_count
|
||||||
%small= t('accounts.posts', count: account.statuses_count).downcase
|
%small= t('accounts.posts', count: account.statuses_count).downcase
|
||||||
%td.accounts-table__count.optional
|
%td.accounts-table__count.optional
|
||||||
- if account.suspended? || account.user_pending?
|
- if account.unavailable? || account.user_pending?
|
||||||
\-
|
\-
|
||||||
- else
|
- else
|
||||||
= friendly_number_to_human account.followers_count
|
= friendly_number_to_human account.followers_count
|
||||||
|
@ -30,6 +30,6 @@
|
||||||
\-
|
\-
|
||||||
%br/
|
%br/
|
||||||
%samp.ellipsized-ip= relevant_account_ip(account, params[:ip])
|
%samp.ellipsized-ip= relevant_account_ip(account, params[:ip])
|
||||||
- if !account.suspended? && account.user_pending? && account.user&.invite_request&.text.present?
|
- if !account.unavailable? && account.user_pending? && account.user&.invite_request&.text.present?
|
||||||
.batch-table__row__content__quote
|
.batch-table__row__content__quote
|
||||||
%p= account.user&.invite_request&.text
|
%p= account.user&.invite_request&.text
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
|
|
||||||
= t('doorkeeper.authorized_applications.index.authorized_at', date: l(application.created_at.to_date))
|
= t('doorkeeper.authorized_applications.index.authorized_at', date: l(application.created_at.to_date))
|
||||||
|
|
||||||
- unless application.superapp? || current_account.suspended?
|
- unless application.superapp? || current_account.unavailable?
|
||||||
%div
|
%div
|
||||||
= table_link_to 'times', t('doorkeeper.authorized_applications.buttons.revoke'), oauth_authorized_application_path(application), method: :delete, data: { confirm: t('doorkeeper.authorized_applications.confirmations.revoke') }
|
= table_link_to 'times', t('doorkeeper.authorized_applications.buttons.revoke'), oauth_authorized_application_path(application), method: :delete, data: { confirm: t('doorkeeper.authorized_applications.confirmations.revoke') }
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ class AccountDeletionWorker
|
||||||
|
|
||||||
def perform(account_id, options = {})
|
def perform(account_id, options = {})
|
||||||
account = Account.find(account_id)
|
account = Account.find(account_id)
|
||||||
return unless account.suspended?
|
return unless account.unavailable?
|
||||||
|
|
||||||
reserve_username = options.with_indifferent_access.fetch(:reserve_username, true)
|
reserve_username = options.with_indifferent_access.fetch(:reserve_username, true)
|
||||||
skip_activitypub = options.with_indifferent_access.fetch(:skip_activitypub, false)
|
skip_activitypub = options.with_indifferent_access.fetch(:skip_activitypub, false)
|
||||||
|
|
|
@ -21,12 +21,12 @@ class Scheduler::SuspendedUserCleanupScheduler
|
||||||
def perform
|
def perform
|
||||||
return if Sidekiq::Queue.new('pull').size > MAX_PULL_SIZE
|
return if Sidekiq::Queue.new('pull').size > MAX_PULL_SIZE
|
||||||
|
|
||||||
clean_suspended_accounts!
|
process_deletion_requests!
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def clean_suspended_accounts!
|
def process_deletion_requests!
|
||||||
# This should be fine because we only process a small amount of deletion requests at once and
|
# This should be fine because we only process a small amount of deletion requests at once and
|
||||||
# `id` and `created_at` should follow the same order.
|
# `id` and `created_at` should follow the same order.
|
||||||
AccountDeletionRequest.reorder(id: :asc).take(MAX_DELETIONS_PER_JOB).each do |deletion_request|
|
AccountDeletionRequest.reorder(id: :asc).take(MAX_DELETIONS_PER_JOB).each do |deletion_request|
|
||||||
|
|
Loading…
Reference in New Issue