From 421b42d07da18ad6fdc50434596801a7d2157a93 Mon Sep 17 00:00:00 2001 From: Johann150 Date: Tue, 11 Oct 2022 00:30:32 +0200 Subject: [PATCH] backend: send delete activity to all known instances closes https://akkoma.dev/FoundKeyGang/FoundKey/issues/190 Changelog: Added --- packages/backend/src/services/note/delete.ts | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/packages/backend/src/services/note/delete.ts b/packages/backend/src/services/note/delete.ts index 61b75c963..f23ec2616 100644 --- a/packages/backend/src/services/note/delete.ts +++ b/packages/backend/src/services/note/delete.ts @@ -10,7 +10,7 @@ import { User, ILocalUser, IRemoteUser } from '@/models/entities/user.js'; import { Note } from '@/models/entities/note.js'; import { Notes, Users, Instances } from '@/models/index.js'; import { notesChart, perUserNotesChart, instanceChart } from '@/services/chart/index.js'; -import { deliverToFollowers, deliverToUser } from '@/remote/activitypub/deliver-manager.js'; +import DeliverManager from '@/remote/activitypub/deliver-manager.js'; import { countSameRenotes } from '@/misc/count-same-renotes.js'; import { isPureRenote } from '@/misc/renote.js'; import { registerOrFetchInstanceDoc } from '../register-or-fetch-instance-doc.js'; @@ -132,10 +132,22 @@ async function getMentionedRemoteUsers(note: Note): Promise { } async function deliverToConcerned(user: { id: ILocalUser['id']; host: null; }, note: Note, content: any) { - deliverToFollowers(user, content); - deliverToRelays(user, content); + const manager = new DeliverManager(user, content); + const remoteUsers = await getMentionedRemoteUsers(note); for (const remoteUser of remoteUsers) { - deliverToUser(user, content, remoteUser); + manager.addDirectRecipe(remoteUser); } + + if (['public', 'home', 'followers'].contains(note.visibility)) { + manager.addFollowersRecipe(); + } + + if (['public', 'home'].contains(note.visibility)) { + manager.addEveryone(); + } + + await manager.execute(); + + deliverToRelays(user, content); }