forked from FoundKeyGang/FoundKey
ActivityPub visibility on send
This commit is contained in:
parent
ab701bb93e
commit
f079041827
3 changed files with 60 additions and 4 deletions
|
@ -50,9 +50,21 @@ export default async function renderNote(note: INote, dive = true): Promise<any>
|
||||||
? note.mentionedRemoteUsers.map(x => x.uri)
|
? note.mentionedRemoteUsers.map(x => x.uri)
|
||||||
: [];
|
: [];
|
||||||
|
|
||||||
const cc = ['public', 'home', 'followers'].includes(note.visibility)
|
let to: string[] = [];
|
||||||
? [`${attributedTo}/followers`].concat(mentions)
|
let cc: string[] = [];
|
||||||
: [];
|
|
||||||
|
if (note.visibility == 'public') {
|
||||||
|
to = ['https://www.w3.org/ns/activitystreams#Public'];
|
||||||
|
cc = [`${attributedTo}/followers`].concat(mentions);
|
||||||
|
} else if (note.visibility == 'home') {
|
||||||
|
to = [`${attributedTo}/followers`];
|
||||||
|
cc = ['https://www.w3.org/ns/activitystreams#Public'].concat(mentions);
|
||||||
|
} else if (note.visibility == 'followers') {
|
||||||
|
to = [`${attributedTo}/followers`];
|
||||||
|
cc = mentions;
|
||||||
|
} else {
|
||||||
|
to = mentions;
|
||||||
|
}
|
||||||
|
|
||||||
const mentionedUsers = note.mentions ? await User.find({
|
const mentionedUsers = note.mentions ? await User.find({
|
||||||
_id: {
|
_id: {
|
||||||
|
@ -74,7 +86,7 @@ export default async function renderNote(note: INote, dive = true): Promise<any>
|
||||||
summary: note.cw,
|
summary: note.cw,
|
||||||
content: toHtml(note),
|
content: toHtml(note),
|
||||||
published: note.createdAt.toISOString(),
|
published: note.createdAt.toISOString(),
|
||||||
to: 'https://www.w3.org/ns/activitystreams#Public',
|
to,
|
||||||
cc,
|
cc,
|
||||||
inReplyTo,
|
inReplyTo,
|
||||||
attachment: (await promisedFiles).map(renderDocument),
|
attachment: (await promisedFiles).map(renderDocument),
|
||||||
|
|
|
@ -19,6 +19,8 @@ export default async (user: ILocalUser) => {
|
||||||
id,
|
id,
|
||||||
inbox: `${id}/inbox`,
|
inbox: `${id}/inbox`,
|
||||||
outbox: `${id}/outbox`,
|
outbox: `${id}/outbox`,
|
||||||
|
followers: `${id}/followers`,
|
||||||
|
following: `${id}/following`,
|
||||||
sharedInbox: `${config.url}/inbox`,
|
sharedInbox: `${config.url}/inbox`,
|
||||||
url: `${config.url}/@${user.username}`,
|
url: `${config.url}/@${user.username}`,
|
||||||
preferredUsername: user.username,
|
preferredUsername: user.username,
|
||||||
|
|
|
@ -89,6 +89,48 @@ router.get('/users/:user/outbox', async ctx => {
|
||||||
ctx.body = pack(rendered);
|
ctx.body = pack(rendered);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// followers
|
||||||
|
router.get('/users/:user/followers', async ctx => {
|
||||||
|
const userId = new mongo.ObjectID(ctx.params.user);
|
||||||
|
|
||||||
|
const user = await User.findOne({
|
||||||
|
_id: userId,
|
||||||
|
host: null
|
||||||
|
});
|
||||||
|
|
||||||
|
if (user === null) {
|
||||||
|
ctx.status = 404;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Implement fetch and render
|
||||||
|
|
||||||
|
const rendered = renderOrderedCollection(`${config.url}/users/${userId}/followers`, 0, []);
|
||||||
|
|
||||||
|
ctx.body = pack(rendered);
|
||||||
|
});
|
||||||
|
|
||||||
|
// following
|
||||||
|
router.get('/users/:user/following', async ctx => {
|
||||||
|
const userId = new mongo.ObjectID(ctx.params.user);
|
||||||
|
|
||||||
|
const user = await User.findOne({
|
||||||
|
_id: userId,
|
||||||
|
host: null
|
||||||
|
});
|
||||||
|
|
||||||
|
if (user === null) {
|
||||||
|
ctx.status = 404;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Implement fetch and render
|
||||||
|
|
||||||
|
const rendered = renderOrderedCollection(`${config.url}/users/${userId}/following`, 0, []);
|
||||||
|
|
||||||
|
ctx.body = pack(rendered);
|
||||||
|
});
|
||||||
|
|
||||||
// publickey
|
// publickey
|
||||||
router.get('/users/:user/publickey', async ctx => {
|
router.get('/users/:user/publickey', async ctx => {
|
||||||
const userId = new mongo.ObjectID(ctx.params.user);
|
const userId = new mongo.ObjectID(ctx.params.user);
|
||||||
|
|
Loading…
Reference in a new issue