Renote visibility (#3290)

This commit is contained in:
MeiMei
2018-11-17 03:25:48 +09:00
committed by syuilo
parent db657c2a62
commit 0bf54b3ff6
5 changed files with 52 additions and 16 deletions

View File

@@ -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
};
};

View File

@@ -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()}`;
}