mirror of
https://github.com/versia-pub/server.git
synced 2025-12-06 08:28:19 +01:00
feat(federation): ✨ Make server actor available on /users/actor
This commit is contained in:
parent
420a0d05dc
commit
6ae13265fa
|
|
@ -169,7 +169,7 @@ export class User extends BaseInterface<typeof Users, UserWithRelations> {
|
|||
roles: [],
|
||||
sanctions: [],
|
||||
statusCount: 0,
|
||||
uri: "",
|
||||
uri: "/users/actor",
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue