Merge pull request #461 from cognitivegears/459-activitypub-integration

Added additional fields from Masto
This commit is contained in:
Bryan Ashby 2022-12-31 13:02:53 -07:00 committed by GitHub
commit 3db35bc5b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 28 additions and 4 deletions

View File

@ -6,7 +6,6 @@ const WebServerPackageName = require('../web').moduleInfo.packageName;
const _ = require('lodash'); const _ = require('lodash');
const User = require('../../../user'); const User = require('../../../user');
const { result } = require('lodash');
const Log = require('../../../logger').log; const Log = require('../../../logger').log;
exports.moduleInfo = { exports.moduleInfo = {
@ -64,7 +63,8 @@ exports.getModule = class WebFingerServerModule extends ServerModule {
const body = JSON.stringify({ const body = JSON.stringify({
subject: `acct:${accountName}`, subject: `acct:${accountName}`,
links: [this._profilePageLink(user)], aliases: [this._profileUrl(user), this._selfUrl(user)],
links: [this._profilePageLink(user), this._selfLink(user), this._subscribeLink()],
}); });
const headers = { const headers = {
@ -77,8 +77,12 @@ exports.getModule = class WebFingerServerModule extends ServerModule {
}); });
} }
_profileUrl(user) {
return this.webServer.instance.buildUrl(`/wf/@${user.username}`);
}
_profilePageLink(user) { _profilePageLink(user) {
const href = this.webServer.instance.buildUrl(`/wf/@${user.username}`); const href = this._profileUrl(user);
return { return {
rel: 'http://webfinger.net/rel/profile-page', rel: 'http://webfinger.net/rel/profile-page',
type: 'text/plain', type: 'text/plain',
@ -86,6 +90,26 @@ exports.getModule = class WebFingerServerModule extends ServerModule {
}; };
} }
_selfUrl(user) {
return this.webServer.instance.buildUrl(`/users/${user.username}`);
}
_selfLink(user) {
const href = this._selfUrl(user);
return {
rel: 'self',
type: 'application/activity+json',
href,
};
}
_subscribeLink() {
return {
rel: 'http://ostatus.org/schema/1.0/subscribe',
template: this.webServer.instance.buildUrl('/authorize_interaction?uri={uri}'),
};
}
_getUser(resource, resp, cb) { _getUser(resource, resp, cb) {
// we only handle "acct:NAME" URIs // we only handle "acct:NAME" URIs