redirect webfinger of domain to instance actor

(Johann150 yells at cloud)
This commit is contained in:
Johann150 2023-12-16 09:59:17 +01:00
parent 5f9fb28fc2
commit bed6a1e2d8
Signed by: Johann150
GPG Key ID: 9EE6577A2A06F8F1
1 changed files with 12 additions and 2 deletions

View File

@ -101,12 +101,22 @@ router.get(webFingerPath, async ctx => {
isSuspended: false,
} : 422;
if (typeof ctx.query.resource !== 'string') {
let resource = ctx.query.resource;
if (typeof resource !== 'string') {
ctx.status = 400;
return;
}
const query = generateQuery(ctx.query.resource.toLowerCase());
resource = resource.toLowerCase();
// Mastodon sometimes only checks for the domain name,
// which should be rewritten to the instance actor.
if (`https://${config.host}`.toLowerCase() === resource) {
resource = `acct:instance.actor@${config.host}`;
}
const query = generateQuery(resource);
if (typeof query === 'number') {
ctx.status = query;