From be5a0b4794b1455094953f42f119b2233ea16bdc Mon Sep 17 00:00:00 2001 From: mei23 Date: Sun, 19 Aug 2018 18:08:29 +0900 Subject: [PATCH] =?UTF-8?q?Fix=20=E3=83=AA=E3=83=A2=E3=83=BC=E3=83=88?= =?UTF-8?q?=E3=81=ABNSFW=E3=81=8C=E5=8A=B9=E3=81=8B=E3=81=AA=E3=81=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/remote/activitypub/models/note.ts | 2 ++ src/remote/activitypub/renderer/note.ts | 5 ++++- src/remote/activitypub/type.ts | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/remote/activitypub/models/note.ts b/src/remote/activitypub/models/note.ts index dbad63ea4..02bce6fec 100644 --- a/src/remote/activitypub/models/note.ts +++ b/src/remote/activitypub/models/note.ts @@ -81,7 +81,9 @@ export async function createNote(value: any, resolver?: Resolver, silent = false // 添付メディア // TODO: attachmentは必ずしもImageではない // TODO: attachmentは必ずしも配列ではない + // Noteがsensitiveなら添付もsensitiveにする const media = note.attachment + .map(attach => attach.sensitive = note.sensitive) ? await Promise.all(note.attachment.map(x => resolveImage(actor, x))) : []; diff --git a/src/remote/activitypub/renderer/note.ts b/src/remote/activitypub/renderer/note.ts index 209e74392..1d169d308 100644 --- a/src/remote/activitypub/renderer/note.ts +++ b/src/remote/activitypub/renderer/note.ts @@ -79,6 +79,8 @@ export default async function renderNote(note: INote, dive = true): Promise ...mentionTags, ]; + const files = await promisedFiles; + return { id: `${config.url}/notes/${note._id}`, type: 'Note', @@ -89,7 +91,8 @@ export default async function renderNote(note: INote, dive = true): Promise to, cc, inReplyTo, - attachment: (await promisedFiles).map(renderDocument), + attachment: files.map(renderDocument), + sensitive: files.some(file => file.metadata.isSensitive), tag }; } diff --git a/src/remote/activitypub/type.ts b/src/remote/activitypub/type.ts index 9761b66dc..3d40ad48c 100644 --- a/src/remote/activitypub/type.ts +++ b/src/remote/activitypub/type.ts @@ -16,6 +16,7 @@ export interface IObject { image?: any; url?: string; tag?: any[]; + sensitive?: boolean; } export interface IActivity extends IObject {