diff options
| author | MeiMei <30769358+mei23@users.noreply.github.com> | 2018-11-17 03:25:48 +0900 |
|---|---|---|
| committer | syuilo <Syuilotan@yahoo.co.jp> | 2018-11-17 03:25:48 +0900 |
| commit | 0bf54b3ff6899f4eb5e2bb42c6466094c8f0b8c4 (patch) | |
| tree | 4f19682385b6371dee4eaa1c9d733877f72ed56c /src/remote/activitypub/renderer | |
| parent | Hide unused login method (#3285) (diff) | |
| download | sharkey-0bf54b3ff6899f4eb5e2bb42c6466094c8f0b8c4.tar.gz sharkey-0bf54b3ff6899f4eb5e2bb42c6466094c8f0b8c4.tar.bz2 sharkey-0bf54b3ff6899f4eb5e2bb42c6466094c8f0b8c4.zip | |
Renote visibility (#3290)
Diffstat (limited to 'src/remote/activitypub/renderer')
| -rw-r--r-- | src/remote/activitypub/renderer/announce.ts | 17 | ||||
| -rw-r--r-- | src/remote/activitypub/renderer/index.ts | 2 |
2 files changed, 17 insertions, 2 deletions
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()}`; } |