mirror of
https://github.com/versia-pub/server.git
synced 2026-04-27 20:59:15 +02:00
feat(federation): ✨ Port to Versia 0.6
This commit is contained in:
parent
de69f27877
commit
fca30b4dad
62 changed files with 1614 additions and 2008 deletions
59
packages/api/routes/versia/v0.6/inbox.ts
vendored
Normal file
59
packages/api/routes/versia/v0.6/inbox.ts
vendored
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
import { apiRoute, handleZodError } from "@versia-server/kit/api";
|
||||
import { describeRoute, validator } from "hono-openapi";
|
||||
import z from "zod";
|
||||
import { InboxJobType, inboxQueue } from "~/packages/kit/queues/inbox/queue";
|
||||
|
||||
export default apiRoute((app) =>
|
||||
app.get(
|
||||
"/.versia/v0.6/inbox",
|
||||
describeRoute({
|
||||
summary: "Instance inbox endpoint",
|
||||
tags: ["Federation"],
|
||||
responses: {
|
||||
200: {
|
||||
description: "Request processing initiated",
|
||||
},
|
||||
},
|
||||
}),
|
||||
validator(
|
||||
"header",
|
||||
z.object({
|
||||
"versia-signature": z.string(),
|
||||
"versia-signed-at": z.coerce.number(),
|
||||
"versia-signed-by": z.string(),
|
||||
authorization: z.string().optional(),
|
||||
}),
|
||||
handleZodError,
|
||||
),
|
||||
async (context) => {
|
||||
const body = await context.req.json();
|
||||
const {
|
||||
"versia-signature": signature,
|
||||
"versia-signed-at": signedAt,
|
||||
"versia-signed-by": signedBy,
|
||||
authorization,
|
||||
} = context.req.valid("header");
|
||||
|
||||
await inboxQueue.add(InboxJobType.ProcessEntity, {
|
||||
data: body,
|
||||
headers: {
|
||||
"versia-signature": signature,
|
||||
"versia-signed-at": signedAt,
|
||||
"versia-signed-by": signedBy,
|
||||
authorization,
|
||||
},
|
||||
request: {
|
||||
body: await context.req.text(),
|
||||
method: context.req.method,
|
||||
url: context.req.url,
|
||||
},
|
||||
ip: context.env?.ip ?? null,
|
||||
});
|
||||
|
||||
return context.body(
|
||||
"Request processing initiated.\nImplement the Instance Messaging Extension to receive any eventual feedback (errors, etc.)",
|
||||
200,
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
Loading…
Add table
Add a link
Reference in a new issue