FoundKey-0x7f/packages/backend/src/remote/activitypub/kernel/undo/like.ts
Johann150 36a0e48e49
bacakend: prefer absolute over relative imports
There are still many places where import paths with `..` are used and
maybe should use absolute paths also.
2022-10-01 14:40:30 +02:00

22 lines
666 B
TypeScript

import { CacheableRemoteUser } from '@/models/entities/user.js';
import deleteReaction from '@/services/note/reaction/delete.js';
import { ILike, getApId } from '@/remote/activitypub/type.js';
import { fetchNote } from '@/remote/activitypub/models/note.js';
/**
* Process Undo.Like activity
*/
export default async (actor: CacheableRemoteUser, activity: ILike) => {
const targetUri = getApId(activity.object);
const note = await fetchNote(targetUri);
if (!note) return `skip: target note not found ${targetUri}`;
await deleteReaction(actor, note).catch(e => {
if (e.id === '60527ec9-b4cb-4a88-a6bd-32d3ad26817d') return;
throw e;
});
return 'ok';
};