0
0
Fork 0

Add notifications of severed relationships (#27511)

This commit is contained in:
Claire 2024-03-20 16:37:21 +01:00 committed by GitHub
parent 8a1423a474
commit 44bf7b8128
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
39 changed files with 781 additions and 54 deletions

View file

@ -58,6 +58,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
@ -72,6 +74,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)
@ -84,6 +87,7 @@ class DeleteAccountService < BaseService
@options[:skip_activitypub] = true if @options[:skip_side_effects]
record_severed_relationships!
distribute_activities!
purge_content!
fulfill_deletion_request!
@ -266,6 +270,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
@ -305,4 +323,8 @@ class DeleteAccountService < BaseService
def skip_activitypub?
@options[:skip_activitypub]
end
def relationship_severance_event
@options[:relationship_severance_event]
end
end