summaryrefslogtreecommitdiff
path: root/src/remote/activitypub/kernel/undo/like.ts
blob: 2678828a9a69286f65d6e741e875a9b723b65c40 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import { IRemoteUser } from '../../../../models/entities/user';
import { ILike } from '../../type';
import deleteReaction from '../../../../services/note/reaction/delete';
import { Notes } from '../../../../models';

/**
 * Process Undo.Like activity
 */
export default async (actor: IRemoteUser, activity: ILike): Promise<void> => {
	const id = typeof activity.object == 'string' ? activity.object : activity.object.id;
	if (id == null) throw new Error('missing id');

	const noteId = id.split('/').pop();

	const note = await Notes.findOne(noteId);
	if (note == null) {
		throw new Error('note not found');
	}

	await deleteReaction(actor, note);
};