Added public key to selfUrl

This commit is contained in:
Nathan Byrd 2023-01-06 13:42:15 -06:00
parent 344d4716ce
commit e478665456
1 changed files with 16 additions and 4 deletions

View File

@ -79,12 +79,15 @@ exports.getModule = class ActivityPubWebHandler extends WebHandlerModule {
} }
_selfAsActorHandler(user, req, resp) { _selfAsActorHandler(user, req, resp) {
const body = JSON.stringify({
const sUrl = selfUrl(this.webServer, user);
const bodyJson = {
'@context': [ '@context': [
'https://www.w3.org/ns/activitystreams', 'https://www.w3.org/ns/activitystreams',
'https://w3id.org/security/v1', 'https://w3id.org/security/v1',
], ],
id: selfUrl(this.webServer, user), id: sUrl,
type: 'Person', type: 'Person',
preferredUsername: user.username, preferredUsername: user.username,
name: user.getSanitizedName('real'), name: user.getSanitizedName('real'),
@ -97,10 +100,19 @@ exports.getModule = class ActivityPubWebHandler extends WebHandlerModule {
following: makeUserUrl(this.webServer, user, '/ap/users') + '/following', following: makeUserUrl(this.webServer, user, '/ap/users') + '/following',
summary: user.getProperty(UserProps.AutoSignature) || '', summary: user.getProperty(UserProps.AutoSignature) || '',
url: webFingerProfileUrl(this.webServer, user), url: webFingerProfileUrl(this.webServer, user),
publicKey: {},
// :TODO: we can start to define BBS related stuff with the community perhaps // :TODO: we can start to define BBS related stuff with the community perhaps
}); };
const publicKeyPem = user.getProperty(UserProps.PublicKeyMain);
if (!(_.isEmpty(publicKeyPem))) {
bodyJson['publicKey'] = { id: sUrl + '#main-key', owner: sUrl, publicKeyPem: user.getProperty(UserProps.PublicKeyMain) };
}
else {
Log.debug({ User: user.username }, 'User does not have a publickey.');
}
const body = JSON.stringify(bodyJson);
const headers = { const headers = {
'Content-Type': 'application/activity+json', 'Content-Type': 'application/activity+json',