Merge upstream
This commit is contained in:
commit
8839cdd4d0
160 changed files with 1705 additions and 1555 deletions
|
@ -89,6 +89,7 @@ class Account < ApplicationRecord
|
|||
include Account::Merging
|
||||
include Account::Search
|
||||
include Account::StatusesSearch
|
||||
include Account::Suspensions
|
||||
include Account::AttributionDomains
|
||||
include DomainMaterializable
|
||||
include DomainNormalizable
|
||||
|
@ -127,9 +128,7 @@ class Account < ApplicationRecord
|
|||
scope :local, -> { where(domain: nil) }
|
||||
scope :partitioned, -> { order(Arel.sql('row_number() over (partition by domain)')) }
|
||||
scope :silenced, -> { where.not(silenced_at: nil) }
|
||||
scope :suspended, -> { where.not(suspended_at: nil) }
|
||||
scope :sensitized, -> { where.not(sensitized_at: nil) }
|
||||
scope :without_suspended, -> { where(suspended_at: nil) }
|
||||
scope :without_silenced, -> { where(silenced_at: nil) }
|
||||
scope :without_instance_actor, -> { where.not(id: INSTANCE_ACTOR_ID) }
|
||||
scope :recent, -> { reorder(id: :desc) }
|
||||
|
@ -255,41 +254,6 @@ class Account < ApplicationRecord
|
|||
update!(silenced_at: nil)
|
||||
end
|
||||
|
||||
def suspended?
|
||||
suspended_at.present? && !instance_actor?
|
||||
end
|
||||
|
||||
def suspended_locally?
|
||||
suspended? && suspension_origin_local?
|
||||
end
|
||||
|
||||
def suspended_permanently?
|
||||
suspended? && deletion_request.nil?
|
||||
end
|
||||
|
||||
def suspended_temporarily?
|
||||
suspended? && deletion_request.present?
|
||||
end
|
||||
|
||||
alias unavailable? suspended?
|
||||
alias permanently_unavailable? suspended_permanently?
|
||||
|
||||
def suspend!(date: Time.now.utc, origin: :local, block_email: true)
|
||||
transaction do
|
||||
create_deletion_request!
|
||||
update!(suspended_at: date, suspension_origin: origin)
|
||||
create_canonical_email_block! if block_email
|
||||
end
|
||||
end
|
||||
|
||||
def unsuspend!
|
||||
transaction do
|
||||
deletion_request&.destroy!
|
||||
update!(suspended_at: nil, suspension_origin: nil)
|
||||
destroy_canonical_email_block!
|
||||
end
|
||||
end
|
||||
|
||||
def sensitized?
|
||||
sensitized_at.present?
|
||||
end
|
||||
|
|
|
@ -35,7 +35,7 @@ class AccountAlias < ApplicationRecord
|
|||
def set_uri
|
||||
target_account = ResolveAccountService.new.call(acct)
|
||||
self.uri = ActivityPub::TagManager.instance.uri_for(target_account) unless target_account.nil?
|
||||
rescue Webfinger::Error, HTTP::Error, OpenSSL::SSL::SSLError, Mastodon::Error
|
||||
rescue Webfinger::Error, *Mastodon::HTTP_CONNECTION_ERRORS, Mastodon::Error
|
||||
# Validation will take care of it
|
||||
end
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ class AccountMigration < ApplicationRecord
|
|||
|
||||
def set_target_account
|
||||
self.target_account = ResolveAccountService.new.call(acct, skip_cache: true)
|
||||
rescue Webfinger::Error, HTTP::Error, OpenSSL::SSL::SSLError, Mastodon::Error, Addressable::URI::InvalidURIError
|
||||
rescue Webfinger::Error, *Mastodon::HTTP_CONNECTION_ERRORS, Mastodon::Error, Addressable::URI::InvalidURIError
|
||||
# Validation will take care of it
|
||||
end
|
||||
|
||||
|
|
44
app/models/concerns/account/suspensions.rb
Normal file
44
app/models/concerns/account/suspensions.rb
Normal file
|
@ -0,0 +1,44 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Account::Suspensions
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
scope :suspended, -> { where.not(suspended_at: nil) }
|
||||
scope :without_suspended, -> { where(suspended_at: nil) }
|
||||
end
|
||||
|
||||
def suspended?
|
||||
suspended_at.present? && !instance_actor?
|
||||
end
|
||||
alias unavailable? suspended?
|
||||
|
||||
def suspended_locally?
|
||||
suspended? && suspension_origin_local?
|
||||
end
|
||||
|
||||
def suspended_permanently?
|
||||
suspended? && deletion_request.nil?
|
||||
end
|
||||
alias permanently_unavailable? suspended_permanently?
|
||||
|
||||
def suspended_temporarily?
|
||||
suspended? && deletion_request.present?
|
||||
end
|
||||
|
||||
def suspend!(date: Time.now.utc, origin: :local, block_email: true)
|
||||
transaction do
|
||||
create_deletion_request!
|
||||
update!(suspended_at: date, suspension_origin: origin)
|
||||
create_canonical_email_block! if block_email
|
||||
end
|
||||
end
|
||||
|
||||
def unsuspend!
|
||||
transaction do
|
||||
deletion_request&.destroy!
|
||||
update!(suspended_at: nil, suspension_origin: nil)
|
||||
destroy_canonical_email_block!
|
||||
end
|
||||
end
|
||||
end
|
|
@ -26,7 +26,7 @@ module Remotable
|
|||
|
||||
public_send(:"#{attachment_name}=", ResponseWithLimit.new(response, limit))
|
||||
end
|
||||
rescue Mastodon::UnexpectedResponseError, HTTP::TimeoutError, HTTP::ConnectionError, OpenSSL::SSL::SSLError => e
|
||||
rescue Mastodon::UnexpectedResponseError, *Mastodon::HTTP_CONNECTION_ERRORS => e
|
||||
Rails.logger.debug { "Error fetching remote #{attachment_name}: #{e}" }
|
||||
public_send(:"#{attachment_name}=", nil) if public_send(:"#{attachment_name}_file_name").present?
|
||||
raise e unless suppress_errors
|
||||
|
|
|
@ -32,7 +32,7 @@ class Form::Redirect
|
|||
|
||||
def set_target_account
|
||||
@target_account = ResolveAccountService.new.call(acct, skip_cache: true)
|
||||
rescue Webfinger::Error, HTTP::Error, OpenSSL::SSL::SSLError, Mastodon::Error, Addressable::URI::InvalidURIError
|
||||
rescue Webfinger::Error, *Mastodon::HTTP_CONNECTION_ERRORS, Mastodon::Error, Addressable::URI::InvalidURIError
|
||||
# Validation will take care of it
|
||||
end
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ class RemoteFollow
|
|||
|
||||
def acct_resource
|
||||
@acct_resource ||= Webfinger.new("acct:#{acct}").perform
|
||||
rescue Webfinger::Error, HTTP::ConnectionError
|
||||
rescue Webfinger::Error, *Mastodon::HTTP_CONNECTION_ERRORS
|
||||
nil
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue