From 92828028db28c92d7d36324d445a69d62351df48 Mon Sep 17 00:00:00 2001 From: mei23 Date: Sat, 25 Aug 2018 13:11:54 +0900 Subject: [PATCH] Add Activity id if missing --- src/remote/activitypub/renderer/index.ts | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/remote/activitypub/renderer/index.ts b/src/remote/activitypub/renderer/index.ts index ee7f49616..55b2801ca 100644 --- a/src/remote/activitypub/renderer/index.ts +++ b/src/remote/activitypub/renderer/index.ts @@ -1,7 +1,16 @@ -export default (x: any) => Object.assign({ - '@context': [ - 'https://www.w3.org/ns/activitystreams', - 'https://w3id.org/security/v1', - { Hashtag: 'as:Hashtag' } - ] -}, x); +import config from '../../../config'; +import * as uuid from 'uuid'; + +export default (x: any) => { + if (x !== null && typeof x === 'object' && x.id == null) { + x.id = `${config.url}/${uuid.v4()}`; + } + + return Object.assign({ + '@context': [ + 'https://www.w3.org/ns/activitystreams', + 'https://w3id.org/security/v1', + { Hashtag: 'as:Hashtag' } + ] + }, x); +};