From 0bf54b3ff6899f4eb5e2bb42c6466094c8f0b8c4 Mon Sep 17 00:00:00 2001 From: MeiMei <30769358+mei23@users.noreply.github.com> Date: Sat, 17 Nov 2018 03:25:48 +0900 Subject: Renote visibility (#3290) --- src/remote/activitypub/renderer/announce.ts | 17 +++++++++++++++-- src/remote/activitypub/renderer/index.ts | 2 ++ 2 files changed, 17 insertions(+), 2 deletions(-) (limited to 'src/remote/activitypub/renderer') diff --git a/src/remote/activitypub/renderer/announce.ts b/src/remote/activitypub/renderer/announce.ts index 18e23cc336..f6f2f9bdcd 100644 --- a/src/remote/activitypub/renderer/announce.ts +++ b/src/remote/activitypub/renderer/announce.ts @@ -4,13 +4,26 @@ import { INote } from '../../../models/note'; export default (object: any, note: INote) => { const attributedTo = `${config.url}/users/${note.userId}`; + let to: string[] = []; + let cc: string[] = []; + + if (note.visibility == 'public') { + to = ['https://www.w3.org/ns/activitystreams#Public']; + cc = [`${attributedTo}/followers`]; + } else if (note.visibility == 'home') { + to = [`${attributedTo}/followers`]; + cc = ['https://www.w3.org/ns/activitystreams#Public']; + } else { + return null; + } + return { id: `${config.url}/notes/${note._id}/activity`, actor: `${config.url}/users/${note.userId}`, type: 'Announce', published: note.createdAt.toISOString(), - to: ['https://www.w3.org/ns/activitystreams#Public'], - cc: [attributedTo, `${attributedTo}/followers`], + to, + cc, object }; }; diff --git a/src/remote/activitypub/renderer/index.ts b/src/remote/activitypub/renderer/index.ts index 55b2801cad..30f5f1cff5 100644 --- a/src/remote/activitypub/renderer/index.ts +++ b/src/remote/activitypub/renderer/index.ts @@ -2,6 +2,8 @@ import config from '../../../config'; import * as uuid from 'uuid'; export default (x: any) => { + if (x == null) return null; + if (x !== null && typeof x === 'object' && x.id == null) { x.id = `${config.url}/${uuid.v4()}`; } -- cgit v1.2.3-freya