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

export default async (actor: IRemoteUser, activity: ILike) => {
	const id = typeof activity.object == 'string' ? activity.object : activity.object.id;

	// Transform:
	// https://misskey.ex/notes/xxxx to
	// xxxx
	const noteId = id.split('/').pop();

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

	await create(actor, note, activity._misskey_reaction);
};