diff --git a/packages/backend/src/remote/activitypub/kernel/undo/announce.ts b/packages/backend/src/remote/activitypub/kernel/undo/announce.ts index a6e9c88c61..32c66cfb7b 100644 --- a/packages/backend/src/remote/activitypub/kernel/undo/announce.ts +++ b/packages/backend/src/remote/activitypub/kernel/undo/announce.ts @@ -3,6 +3,13 @@ import type { CacheableRemoteUser } from "@/models/entities/user.js"; import type { IAnnounce } from "../../type.js"; import { getApId } from "../../type.js"; import deleteNote from "@/services/note/delete.js"; +import { + type ScyllaNote, + scyllaClient, + prepared, + parseScyllaNote, +} from "@/db/scylla.js"; +import type { Note } from "@/models/entities/note.js"; export const undoAnnounce = async ( actor: CacheableRemoteUser, @@ -10,10 +17,26 @@ export const undoAnnounce = async ( ): Promise => { const uri = getApId(activity); - const note = await Notes.findOneBy({ - uri, - userId: actor.id, - }); + let note: Note | ScyllaNote | null = null; + + if (scyllaClient) { + const result = await scyllaClient.execute( + prepared.note.select.byUri, + [uri], + { prepare: true }, + ); + if (result.rowLength > 0) { + const candidate = parseScyllaNote(result.first()); + if (candidate.userId === actor.id) { + note = candidate; + } + } + } else { + note = await Notes.findOneBy({ + uri, + userId: actor.id, + }); + } if (!note) return "skip: no such Announce";