feat: application actor + public key for uid 0 signs, moved homepage route to after core routes are generated

This commit is contained in:
Julian Lam
2024-01-22 16:18:49 -05:00
parent 403bf3e1a8
commit 9885f94a2b
6 changed files with 150 additions and 43 deletions

View File

@@ -9,43 +9,10 @@ const helpers = require('../helpers');
const Controller = module.exports;
Controller.actors = require('./actors');
Controller.profiles = require('./profiles');
Controller.topics = require('./topics');
Controller.getActor = async (req, res) => {
// todo: view:users priv gate
const { userslug } = req.params;
const { uid } = res.locals;
const { username, displayname: name, aboutme, picture, 'cover:url': cover } = await user.getUserData(uid);
const publicKey = await activitypub.getPublicKey(uid);
res.status(200).json({
'@context': [
'https://www.w3.org/ns/activitystreams',
'https://w3id.org/security/v1',
],
id: `${nconf.get('url')}/user/${userslug}`,
url: `${nconf.get('url')}/user/${userslug}`,
followers: `${nconf.get('url')}/user/${userslug}/followers`,
following: `${nconf.get('url')}/user/${userslug}/following`,
inbox: `${nconf.get('url')}/user/${userslug}/inbox`,
outbox: `${nconf.get('url')}/user/${userslug}/outbox`,
type: 'Person',
name,
preferredUsername: username,
summary: aboutme,
icon: picture ? `${nconf.get('url')}${picture}` : null,
image: cover ? `${nconf.get('url')}${cover}` : null,
publicKey: {
id: `${nconf.get('url')}/user/${userslug}#key`,
owner: `${nconf.get('url')}/user/${userslug}`,
publicKeyPem: publicKey,
},
});
};
Controller.getFollowing = async (req, res) => {
const { followingCount: totalItems } = await user.getUserFields(res.locals.uid, ['followingCount']);