fix: only send activitypub+json links via webfinger if activitypub is global enabled

This commit is contained in:
Julian Lam
2024-03-22 12:29:41 -04:00
parent 9c03e6e93c
commit 65bb866654

View File

@@ -2,6 +2,7 @@
const nconf = require('nconf'); const nconf = require('nconf');
const meta = require('../meta');
const user = require('../user'); const user = require('../user');
const categories = require('../categories'); const categories = require('../categories');
const privileges = require('../privileges'); const privileges = require('../privileges');
@@ -42,13 +43,15 @@ Controller.webfinger = async (req, res) => {
function application(response) { function application(response) {
response.aliases = [nconf.get('url')]; response.aliases = [nconf.get('url')];
response.links = [ response.links = [];
{
if (meta.config.activitypubEnabled) {
response.links.push({
rel: 'self', rel: 'self',
type: 'application/activity+json', type: 'application/activity+json',
href: `${nconf.get('url')}/actor`, // actor href: `${nconf.get('url')}/actor`, // actor
}, });
]; }
return response; return response;
} }
@@ -66,11 +69,6 @@ async function profile(callerUid, uid, response) {
]; ];
response.links = [ response.links = [
{
rel: 'self',
type: 'application/activity+json',
href: `${nconf.get('url')}/uid/${uid}`, // actor
},
{ {
rel: 'http://webfinger.net/rel/profile-page', rel: 'http://webfinger.net/rel/profile-page',
type: 'text/html', type: 'text/html',
@@ -78,6 +76,14 @@ async function profile(callerUid, uid, response) {
}, },
]; ];
if (meta.config.activitypubEnabled) {
response.links.push({
rel: 'self',
type: 'application/activity+json',
href: `${nconf.get('url')}/uid/${uid}`, // actor
});
}
return response; return response;
} }
@@ -89,13 +95,15 @@ async function category(callerUid, cid, response) {
const slug = await categories.getCategoryField(cid, 'slug'); const slug = await categories.getCategoryField(cid, 'slug');
response.aliases = [`${nconf.get('url')}/category/${slug}`]; response.aliases = [`${nconf.get('url')}/category/${slug}`];
response.links = [ response.links = [];
{
if (meta.config.activitypubEnabled) {
response.links.push({
rel: 'self', rel: 'self',
type: 'application/activity+json', type: 'application/activity+json',
href: `${nconf.get('url')}/category/${cid}`, // actor href: `${nconf.get('url')}/category/${cid}`, // actor
}, });
]; }
return response; return response;
} }