FoundKey/packages/backend/src/remote/activitypub/kernel/like.ts
Johann150 68bc2e314b
activitypub: remove _misskey_reaction property
This property is duplicated by the `content` property so seems unnecessary.

Changelog: Removed
2023-02-11 17:43:44 +01:00

22 lines
773 B
TypeScript

import { CacheableRemoteUser } from '@/models/entities/user.js';
import { createReaction } from '@/services/note/reaction/create.js';
import { ILike, getApId } from '../type.js';
import { fetchNote, extractEmojis } from '../models/note.js';
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 extractEmojis(activity.tag || [], actor.host).catch(() => null);
return await createReaction(actor, note, activity.content || activity.name).catch(e => {
if (e.id === '51c42bb4-931a-456b-bff7-e5a8a70dd298') {
return 'skip: already reacted';
} else {
throw e;
}
}).then(() => 'ok');
};