Changes to work with Mastodon. Also fixed variable rename issue
This commit is contained in:
parent
d278307a81
commit
b252f69f05
|
@ -45,6 +45,10 @@ function selfUrl(webServer, user) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function userFromAccount(accountName, cb) {
|
function userFromAccount(accountName, cb) {
|
||||||
|
if (accountName.startsWith('@')) {
|
||||||
|
accountName = accountName.slice(1);
|
||||||
|
}
|
||||||
|
|
||||||
User.getUserIdAndName(accountName, (err, userId) => {
|
User.getUserIdAndName(accountName, (err, userId) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
return cb(err);
|
return cb(err);
|
||||||
|
@ -58,7 +62,7 @@ function userFromAccount(accountName, cb) {
|
||||||
const accountStatus = user.getPropertyAsNumber(UserProps.AccountStatus);
|
const accountStatus = user.getPropertyAsNumber(UserProps.AccountStatus);
|
||||||
if (
|
if (
|
||||||
User.AccountStatus.disabled == accountStatus ||
|
User.AccountStatus.disabled == accountStatus ||
|
||||||
User.AccountStatus.inactive == accountStatus
|
User.AccountStatus.inactive == accountStatus
|
||||||
) {
|
) {
|
||||||
return cb(Errors.AccessDenied('Account disabled', ErrorReasons.Disabled));
|
return cb(Errors.AccessDenied('Account disabled', ErrorReasons.Disabled));
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,8 @@ exports.getModule = class ActivityPubWebHandler extends WebHandlerModule {
|
||||||
}
|
}
|
||||||
|
|
||||||
const accept = req.headers['accept'] || '*/*';
|
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;
|
sendActor = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,14 +82,14 @@ exports.getModule = class ActivityPubWebHandler extends WebHandlerModule {
|
||||||
}
|
}
|
||||||
|
|
||||||
_selfAsActorHandler(user, req, resp) {
|
_selfAsActorHandler(user, req, resp) {
|
||||||
const selfUrl = selfUrl(this.webServer, user);
|
const sUrl = selfUrl(this.webServer, user);
|
||||||
|
|
||||||
const bodyJson = {
|
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,
|
id: sUrl,
|
||||||
type: 'Person',
|
type: 'Person',
|
||||||
preferredUsername: user.username,
|
preferredUsername: user.username,
|
||||||
name: user.getSanitizedName('real'),
|
name: user.getSanitizedName('real'),
|
||||||
|
@ -108,7 +109,7 @@ exports.getModule = class ActivityPubWebHandler extends WebHandlerModule {
|
||||||
const publicKeyPem = user.getProperty(UserProps.PublicKeyMain);
|
const publicKeyPem = user.getProperty(UserProps.PublicKeyMain);
|
||||||
if (!_.isEmpty(publicKeyPem)) {
|
if (!_.isEmpty(publicKeyPem)) {
|
||||||
bodyJson['publicKey'] = {
|
bodyJson['publicKey'] = {
|
||||||
id: selfUrl + '#main-key',
|
id: sUrl + '#main-key',
|
||||||
owner: sUrl,
|
owner: sUrl,
|
||||||
publicKeyPem: user.getProperty(UserProps.PublicKeyMain),
|
publicKeyPem: user.getProperty(UserProps.PublicKeyMain),
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue