From cb85d7cb14b818d5fa198fb98f800cc31e56ad2a Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 10 Apr 2018 04:38:02 +0900 Subject: [PATCH] =?UTF-8?q?=E5=86=8D=E5=B8=B0=E7=9A=84=E3=81=ABNote?= =?UTF-8?q?=E3=82=92=E3=83=AC=E3=83=B3=E3=83=80=E3=83=AA=E3=83=B3=E3=82=B0?= =?UTF-8?q?=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/remote/activitypub/renderer/note.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/remote/activitypub/renderer/note.ts b/src/remote/activitypub/renderer/note.ts index 7cc388dc33..c364b13249 100644 --- a/src/remote/activitypub/renderer/note.ts +++ b/src/remote/activitypub/renderer/note.ts @@ -5,7 +5,7 @@ import DriveFile from '../../../models/drive-file'; import Note, { INote } from '../../../models/note'; import User from '../../../models/user'; -export default async (note: INote) => { +export default async function renderNote(note: INote, dive = true) { const promisedFiles = note.mediaIds ? DriveFile.find({ _id: { $in: note.mediaIds } }) : Promise.resolve([]); @@ -23,7 +23,15 @@ export default async (note: INote) => { }); if (inReplyToUser !== null) { - inReplyTo = inReplyToNote.uri || `${config.url}/notes/${inReplyToNote._id}`; + if (inReplyToNote.uri) { + inReplyTo = inReplyToNote.uri; + } else { + if (dive) { + inReplyTo = await renderNote(inReplyToNote, false); + } else { + inReplyTo = `${config.url}/notes/${inReplyToNote._id}`; + } + } } } } else { @@ -48,4 +56,4 @@ export default async (note: INote) => { attachment: (await promisedFiles).map(renderDocument), tag: (note.tags || []).map(renderHashtag) }; -}; +}