diff --git a/packages/database-interface/user.ts b/packages/database-interface/user.ts index 8fb38f2d..f7d04b8d 100644 --- a/packages/database-interface/user.ts +++ b/packages/database-interface/user.ts @@ -169,7 +169,7 @@ export class User extends BaseInterface { roles: [], sanctions: [], statusCount: 0, - uri: "", + uri: "/users/actor", }); } diff --git a/server/api/users/:uuid/index.ts b/server/api/users/:uuid/index.ts index 0b46a52d..dd2d6d63 100644 --- a/server/api/users/:uuid/index.ts +++ b/server/api/users/:uuid/index.ts @@ -21,7 +21,7 @@ export const meta = applyConfig({ export const schemas = { param: z.object({ - uuid: z.string().uuid(), + uuid: z.string().uuid().or(z.literal("actor")), }), query: z.object({ debug: z @@ -41,7 +41,10 @@ export default (app: Hono) => const { uuid } = context.req.valid("param"); const { debug } = context.req.valid("query"); - const user = await User.fromId(uuid); + const user = + uuid === "actor" + ? User.getServerActor() + : await User.fromId(uuid); if (!user) { return errorResponse("User not found", 404); @@ -61,7 +64,10 @@ export default (app: Hono) => } // Try to detect a web browser and redirect to the user's profile page - if (context.req.header("user-agent")?.includes("Mozilla")) { + if ( + context.req.header("user-agent")?.includes("Mozilla") && + uuid !== "actor" + ) { return redirect(user.toApi().url); }