From b7a4f286b02c8ebb376779569e5564f52496913e Mon Sep 17 00:00:00 2001 From: MeiMei <30769358+mei23@users.noreply.github.com> Date: Tue, 4 Feb 2020 08:26:00 +0900 Subject: リモート投稿にリモートでされたリアクションが表示されるように (#5817) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 第3インスタンスへのLikeも受け入れるように * リアクション済みだったらエラーにせずに置き換えるように * Likeを第3インスタンスにdeliverするように * fix * fix * 同じリアクションがすでにされていたら何もしない * リモートから自身の投稿へリアクションした場合にエラーにならないように --- src/remote/activitypub/kernel/undo/like.ts | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'src/remote/activitypub/kernel/undo/like.ts') diff --git a/src/remote/activitypub/kernel/undo/like.ts b/src/remote/activitypub/kernel/undo/like.ts index 2678828a9a..bd6930c66b 100644 --- a/src/remote/activitypub/kernel/undo/like.ts +++ b/src/remote/activitypub/kernel/undo/like.ts @@ -1,21 +1,17 @@ import { IRemoteUser } from '../../../../models/entities/user'; -import { ILike } from '../../type'; +import { ILike, getApId } from '../../type'; import deleteReaction from '../../../../services/note/reaction/delete'; -import { Notes } from '../../../../models'; +import { fetchNote } from '../../models/note'; /** * Process Undo.Like activity */ -export default async (actor: IRemoteUser, activity: ILike): Promise => { - const id = typeof activity.object == 'string' ? activity.object : activity.object.id; - if (id == null) throw new Error('missing id'); +export default async (actor: IRemoteUser, activity: ILike) => { + const targetUri = getApId(activity.object); - const noteId = id.split('/').pop(); - - const note = await Notes.findOne(noteId); - if (note == null) { - throw new Error('note not found'); - } + const note = await fetchNote(targetUri); + if (!note) return `skip: target note not found ${targetUri}`; await deleteReaction(actor, note); + return `ok`; }; -- cgit v1.2.3-freya