2024-11-25 16:54:46 +01:00
|
|
|
import { getLogger } from "@logtape/logtape";
|
|
|
|
|
import chalk from "chalk";
|
2025-03-29 03:30:06 +01:00
|
|
|
import { describeRoute } from "hono-openapi";
|
2025-04-10 19:15:31 +02:00
|
|
|
import { apiRoute } from "@/api";
|
2024-11-25 16:54:46 +01:00
|
|
|
|
2025-03-29 03:30:06 +01:00
|
|
|
export default apiRoute((app) =>
|
|
|
|
|
app.post(
|
|
|
|
|
"/messaging",
|
|
|
|
|
describeRoute({
|
|
|
|
|
summary: "Endpoint for the Instance Messaging Versia Extension.",
|
|
|
|
|
description: "https://versia.pub/extensions/instance-messaging.",
|
|
|
|
|
tags: ["Federation"],
|
|
|
|
|
responses: {
|
|
|
|
|
200: {
|
|
|
|
|
description: "Message saved",
|
2024-11-25 16:54:46 +01:00
|
|
|
},
|
|
|
|
|
},
|
2025-03-29 03:30:06 +01:00
|
|
|
}),
|
|
|
|
|
async (context) => {
|
|
|
|
|
const content = await context.req.text();
|
2024-11-25 16:54:46 +01:00
|
|
|
|
2025-03-29 03:30:06 +01:00
|
|
|
getLogger(["federation", "messaging"])
|
|
|
|
|
.info`Received message via ${chalk.bold("Instance Messaging")}:\n${content}`;
|
2024-11-25 16:54:46 +01:00
|
|
|
|
2025-03-29 03:30:06 +01:00
|
|
|
return context.text("", 200);
|
|
|
|
|
},
|
|
|
|
|
),
|
2024-11-25 16:54:46 +01:00
|
|
|
);
|