From ea4e2da58d09a664d79f51fa1b6b9d0592839dbf Mon Sep 17 00:00:00 2001 From: MeiMei <30769358+mei23@users.noreply.github.com> Date: Sun, 9 Sep 2018 02:59:14 +0900 Subject: [PATCH] Fix AP Announce detection (#2672) --- src/remote/activitypub/misc/get-note-html.ts | 3 +-- src/server/activitypub/outbox.ts | 2 +- src/services/note/create.ts | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/remote/activitypub/misc/get-note-html.ts b/src/remote/activitypub/misc/get-note-html.ts index 8df440930..f92e91c34 100644 --- a/src/remote/activitypub/misc/get-note-html.ts +++ b/src/remote/activitypub/misc/get-note-html.ts @@ -4,9 +4,8 @@ import parse from '../../../mfm/parse'; import config from '../../../config'; export default function(note: INote) { - if (note.text == null) return null; - let html = toHtml(parse(note.text), note.mentionedRemoteUsers); + if (html == null) html = ''; if (note.poll != null) { const url = `${config.url}/notes/${note._id}`; diff --git a/src/server/activitypub/outbox.ts b/src/server/activitypub/outbox.ts index 9a4c88177..1d062f61a 100644 --- a/src/server/activitypub/outbox.ts +++ b/src/server/activitypub/outbox.ts @@ -105,7 +105,7 @@ export default async (ctx: Router.IRouterContext) => { * @param note Note */ export async function packActivity(note: INote): Promise { - if (note.renoteId && note.text == null) { + if (note.renoteId && note.text == null && note.poll == null && (note.fileIds == null || note.fileIds.length == 0)) { const renote = await Note.findOne(note.renoteId); return renderAnnounce(renote.uri ? renote.uri : `${config.url}/notes/${renote._id}`, note); } diff --git a/src/services/note/create.ts b/src/services/note/create.ts index c08836c94..ceb2ab2e2 100644 --- a/src/services/note/create.ts +++ b/src/services/note/create.ts @@ -239,7 +239,7 @@ export default async (user: IUser, data: Option, silent = false) => new Promise< }); async function renderActivity(data: Option, note: INote) { - const content = data.renote && data.text == null + const content = data.renote && data.text == null && data.poll == null && (data.files == null || data.files.length == 0) ? renderAnnounce(data.renote.uri ? data.renote.uri : `${config.url}/notes/${data.renote._id}`, note) : renderCreate(await renderNote(note, false), note);