mirror of
https://github.com/versia-pub/server.git
synced 2025-12-06 16:38:19 +01:00
fix(api): 🐛 Fix lookup endpoints thinking local user is remote
This commit is contained in:
parent
ace6921447
commit
da369e604c
|
|
@ -1,4 +1,4 @@
|
||||||
import { apiRoute, applyConfig, auth, userAddressValidator } from "@/api";
|
import { apiRoute, applyConfig, auth, userAddressValidatorRemote } from "@/api";
|
||||||
import { createRoute } from "@hono/zod-openapi";
|
import { createRoute } from "@hono/zod-openapi";
|
||||||
import { User } from "@versia/kit/db";
|
import { User } from "@versia/kit/db";
|
||||||
import { RolePermissions, Users } from "@versia/kit/tables";
|
import { RolePermissions, Users } from "@versia/kit/tables";
|
||||||
|
|
@ -62,7 +62,7 @@ export default apiRoute((app) =>
|
||||||
const { user } = context.get("auth");
|
const { user } = context.get("auth");
|
||||||
|
|
||||||
// Check if acct is matching format username@domain.com or @username@domain.com
|
// Check if acct is matching format username@domain.com or @username@domain.com
|
||||||
const accountMatches = acct?.trim().match(userAddressValidator);
|
const accountMatches = acct?.trim().match(userAddressValidatorRemote);
|
||||||
|
|
||||||
if (accountMatches) {
|
if (accountMatches) {
|
||||||
// Remove leading @ if it exists
|
// Remove leading @ if it exists
|
||||||
|
|
|
||||||
10
utils/api.ts
10
utils/api.ts
|
|
@ -106,6 +106,16 @@ export const userAddressValidator = createRegExp(
|
||||||
[global],
|
[global],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export const userAddressValidatorRemote = createRegExp(
|
||||||
|
maybe("@"),
|
||||||
|
oneOrMore(anyOf(letter.lowercase, digit, charIn("-_"))).groupedAs(
|
||||||
|
"username",
|
||||||
|
),
|
||||||
|
exactly("@"),
|
||||||
|
oneOrMore(anyOf(letter, digit, charIn("_-.:"))).groupedAs("domain"),
|
||||||
|
[global],
|
||||||
|
);
|
||||||
|
|
||||||
export const webfingerMention = createRegExp(
|
export const webfingerMention = createRegExp(
|
||||||
exactly("acct:"),
|
exactly("acct:"),
|
||||||
oneOrMore(anyOf(letter, digit, charIn("-_"))).groupedAs("username"),
|
oneOrMore(anyOf(letter, digit, charIn("-_"))).groupedAs("username"),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue