FoundKey/packages/backend/src/remote/activitypub/kernel/undo/announce.ts
Johann150 1516ddfc9b
refactor: remove CacheableUser & co
The CacheableUser, CacheableLocalUser and CacheableRemoteUser are
identical types to User, ILocalUser and IRemoteUser so it seems
nonsensical to have different types for them.
2023-05-18 13:25:57 +02:00

19 lines
534 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], actor);
return 'ok: deleted';
};