Changes to work with Mastodon. Also fixed variable rename issue

This commit is contained in:
Nathan Byrd 2023-01-06 16:09:08 -06:00
parent d278307a81
commit b252f69f05
2 changed files with 10 additions and 5 deletions

View File

@ -45,6 +45,10 @@ function selfUrl(webServer, user) {
}
function userFromAccount(accountName, cb) {
if (accountName.startsWith('@')) {
accountName = accountName.slice(1);
}
User.getUserIdAndName(accountName, (err, userId) => {
if (err) {
return cb(err);
@ -58,7 +62,7 @@ function userFromAccount(accountName, cb) {
const accountStatus = user.getPropertyAsNumber(UserProps.AccountStatus);
if (
User.AccountStatus.disabled == accountStatus ||
User.AccountStatus.inactive == accountStatus
User.AccountStatus.inactive == accountStatus
) {
return cb(Errors.AccessDenied('Account disabled', ErrorReasons.Disabled));
}

View File

@ -66,7 +66,8 @@ exports.getModule = class ActivityPubWebHandler extends WebHandlerModule {
}
const accept = req.headers['accept'] || '*/*';
if (accept === 'application/activity+json') {
const headerValues = ['application/activity+json', 'application/ld+json', 'application/json'];
if (headerValues.some(mime => accept.includes(mime))) {
sendActor = true;
}
@ -81,14 +82,14 @@ exports.getModule = class ActivityPubWebHandler extends WebHandlerModule {
}
_selfAsActorHandler(user, req, resp) {
const selfUrl = selfUrl(this.webServer, user);
const sUrl = selfUrl(this.webServer, user);
const bodyJson = {
'@context': [
'https://www.w3.org/ns/activitystreams',
'https://w3id.org/security/v1',
],
id: selfUrl,
id: sUrl,
type: 'Person',
preferredUsername: user.username,
name: user.getSanitizedName('real'),
@ -108,7 +109,7 @@ exports.getModule = class ActivityPubWebHandler extends WebHandlerModule {
const publicKeyPem = user.getProperty(UserProps.PublicKeyMain);
if (!_.isEmpty(publicKeyPem)) {
bodyJson['publicKey'] = {
id: selfUrl + '#main-key',
id: sUrl + '#main-key',
owner: sUrl,
publicKeyPem: user.getProperty(UserProps.PublicKeyMain),
};