Merge remote-tracking branch 'parent/main' into upstream-20240326

This commit is contained in:
KMY 2024-03-26 09:08:20 +09:00
commit 6c9b221cb2
263 changed files with 4628 additions and 1518 deletions

View file

@ -72,6 +72,8 @@ class DeleteAccountService < BaseService
reports
targeted_moderation_notes
targeted_reports
severed_relationships
remote_severed_relationships
).freeze
# Suspend or remove an account and remove as much of its data
@ -86,6 +88,7 @@ class DeleteAccountService < BaseService
# @option [Boolean] :skip_side_effects Side effects are ActivityPub and streaming API payloads
# @option [Boolean] :skip_activitypub Skip sending ActivityPub payloads. Implied by :skip_side_effects
# @option [Time] :suspended_at Only applicable when :reserve_username is true
# @option [RelationshipSeveranceEvent] :relationship_severance_event Event used to record severed relationships not initiated by the user
def call(account, **options)
@account = account
@options = { reserve_username: true, reserve_email: true }.merge(options)
@ -98,6 +101,7 @@ class DeleteAccountService < BaseService
@options[:skip_activitypub] = true if @options[:skip_side_effects]
record_severed_relationships!
distribute_activities!
purge_content!
fulfill_deletion_request!
@ -198,6 +202,7 @@ class DeleteAccountService < BaseService
# polymorphically associated notifications generated by this account
Notification.where(from_account: @account).in_batches.delete_all
NotificationRequest.where(from_account: @account).in_batches.delete_all
end
def purge_favourites!
@ -294,6 +299,20 @@ class DeleteAccountService < BaseService
end
end
def record_severed_relationships!
return if relationship_severance_event.nil?
@account.active_relationships.in_batches do |follows|
# NOTE: these follows are passive with regards to the local accounts
relationship_severance_event.import_from_passive_follows!(follows)
end
@account.passive_relationships.in_batches do |follows|
# NOTE: these follows are active with regards to the local accounts
relationship_severance_event.import_from_active_follows!(follows)
end
end
def delete_actor_json
@delete_actor_json ||= Oj.dump(serialize_payload(@account, ActivityPub::DeleteActorSerializer, signer: @account, always_sign: true))
end
@ -333,4 +352,8 @@ class DeleteAccountService < BaseService
def skip_activitypub?
@options[:skip_activitypub]
end
def relationship_severance_event
@options[:relationship_severance_event]
end
end