FoundKey/packages/backend/src/remote/activitypub/kernel/undo/announce.ts
Johann150 b7dc3cca22
activitypub: send all cascade deletes
The `deleteNotes` function would not correctly handle cases where cascade
deleted notes were from a different user than the initially deleted note.

Changelog: Fixed
2023-12-03 14:18:34 +01:00

19 lines
527 B
TypeScript

import { Notes } from '@/models/index.js';
import { IRemoteUser } from '@/models/entities/user.js';
import { deleteNotes } from '@/services/note/delete.js';
import { IAnnounce, getApId } from '@/remote/activitypub/type.js';
export const undoAnnounce = async (actor: IRemoteUser, activity: IAnnounce): Promise<string> => {
const uri = getApId(activity);
const note = await Notes.findOneBy({
uri,
userId: actor.id,
});
if (!note) return 'skip: no such Announce';
await deleteNotes([note]);
return 'ok: deleted';
};