make webfinger server stuff more readable
Some checks failed
ci/woodpecker/push/lint-backend Pipeline failed
ci/woodpecker/push/build Pipeline was successful
ci/woodpecker/push/lint-sw Pipeline failed
ci/woodpecker/push/lint-foundkey-js Pipeline was successful
ci/woodpecker/push/lint-client Pipeline failed
ci/woodpecker/push/test Pipeline failed
Some checks failed
ci/woodpecker/push/lint-backend Pipeline failed
ci/woodpecker/push/build Pipeline was successful
ci/woodpecker/push/lint-sw Pipeline failed
ci/woodpecker/push/lint-foundkey-js Pipeline was successful
ci/woodpecker/push/lint-client Pipeline failed
ci/woodpecker/push/test Pipeline failed
This commit is contained in:
parent
bed6a1e2d8
commit
c67ff44207
1 changed files with 26 additions and 19 deletions
|
@ -80,26 +80,33 @@ router.get('/.well-known/oauth-authorization-server', oauth);
|
||||||
router.get('/.well-known/openid-configuration', oauth);
|
router.get('/.well-known/openid-configuration', oauth);
|
||||||
|
|
||||||
router.get(webFingerPath, async ctx => {
|
router.get(webFingerPath, async ctx => {
|
||||||
const fromId = (id: User['id']): FindOptionsWhere<User> => ({
|
const fromAcct = (acct_str: string): FindOptionsWhere<User> | number => {
|
||||||
id,
|
const acct = Acct.parse(acct_str);
|
||||||
host: IsNull(),
|
if (!acct.host || acct.host === config.host.toLowerCase()) {
|
||||||
isSuspended: false,
|
return {
|
||||||
});
|
|
||||||
|
|
||||||
const generateQuery = (resource: string): FindOptionsWhere<User> | number =>
|
|
||||||
resource.startsWith(`${config.url.toLowerCase()}/users/`) ?
|
|
||||||
fromId(resource.split('/').pop()!) :
|
|
||||||
fromAcct(Acct.parse(
|
|
||||||
resource.startsWith(`${config.url.toLowerCase()}/@`) ? resource.split('/').pop()! :
|
|
||||||
resource.startsWith('acct:') ? resource.slice('acct:'.length) :
|
|
||||||
resource));
|
|
||||||
|
|
||||||
const fromAcct = (acct: Acct.Acct): FindOptionsWhere<User> | number =>
|
|
||||||
!acct.host || acct.host === config.host.toLowerCase() ? {
|
|
||||||
usernameLower: acct.username,
|
usernameLower: acct.username,
|
||||||
host: IsNull(),
|
host: IsNull(),
|
||||||
isSuspended: false,
|
isSuspended: false,
|
||||||
} : 422;
|
};
|
||||||
|
} else {
|
||||||
|
return 422;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const generateQuery = (resource: string): FindOptionsWhere<User> | number => {
|
||||||
|
if (resource.startsWith(`${config.url.toLowerCase()}/users/`)) {
|
||||||
|
return {
|
||||||
|
id: resource.split('/').pop()!,
|
||||||
|
host: IsNull(),
|
||||||
|
isSuspended: false,
|
||||||
|
};
|
||||||
|
} else if (resource.startsWith(`${config.url.toLowerCase()}/@`)) {
|
||||||
|
return fromAcct(resource.split('/').pop()!);
|
||||||
|
} else if (resource.startsWith("acct:")) {
|
||||||
|
return fromAcct(resource.slice('acct:'.length));
|
||||||
|
}
|
||||||
|
return fromAcct(resource);
|
||||||
|
};
|
||||||
|
|
||||||
let resource = ctx.query.resource;
|
let resource = ctx.query.resource;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue