mirror of
https://github.com/versia-pub/server.git
synced 2025-12-06 08:28:19 +01:00
feat(federation): ✨ Implement Instance Messaging Extension
This commit is contained in:
parent
4594c69808
commit
756f67c0f3
|
|
@ -9,6 +9,7 @@ Versia Server `0.8.0` is fully backwards compatible with `0.7.0`.
|
|||
- Outbound federation and inbox processing are now handled by a queue system (like most federated software).
|
||||
- Added an administration UI for managing the queue.
|
||||
- Upgraded Bun to `1.1.36`.
|
||||
- Implemented support for the [Instance Messaging Extension](https://versia.pub/extensions/instance-messaging)
|
||||
- Allowed `<div>` and `<span>` tags in Markdown.
|
||||
- Added `--password` flag to the user creation CLI.
|
||||
|
||||
|
|
|
|||
|
|
@ -70,6 +70,7 @@ Contributions are welcome! Please see the [CONTRIBUTING.md](CONTRIBUTING.md) fil
|
|||
|
||||
The following extensions are currently supported or being worked on:
|
||||
- `pub.versia:custom_emojis`: Custom emojis
|
||||
- `pub.versia:instance_messaging`: Instance Messaging
|
||||
- `pub.versia:polls`: Polls
|
||||
- `pub.versia:share`: Share
|
||||
|
||||
|
|
|
|||
48
api/messaging/index.ts
Normal file
48
api/messaging/index.ts
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
import { apiRoute, applyConfig } from "@/api";
|
||||
import { createRoute } from "@hono/zod-openapi";
|
||||
import { getLogger } from "@logtape/logtape";
|
||||
import chalk from "chalk";
|
||||
import { z } from "zod";
|
||||
|
||||
export const meta = applyConfig({
|
||||
auth: {
|
||||
required: false,
|
||||
},
|
||||
ratelimits: {
|
||||
duration: 60,
|
||||
max: 500,
|
||||
},
|
||||
route: "/messaging",
|
||||
});
|
||||
|
||||
const route = createRoute({
|
||||
method: "post",
|
||||
path: "/messaging",
|
||||
summary: "Endpoint for the Instance Messaging Versia Extension.",
|
||||
description: "https://versia.pub/extensions/instance-messaging.",
|
||||
request: {
|
||||
body: {
|
||||
content: {
|
||||
"text/plain": {
|
||||
schema: z.string(),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
responses: {
|
||||
200: {
|
||||
description: "Message saved",
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export default apiRoute((app) =>
|
||||
app.openapi(route, async (context) => {
|
||||
const content = await context.req.text();
|
||||
|
||||
getLogger(["federation", "messaging"])
|
||||
.info`Received message via ${chalk.bold("Instance Messaging")}:\n${content}`;
|
||||
|
||||
return context.newResponse(null, 200);
|
||||
}),
|
||||
);
|
||||
|
|
@ -44,7 +44,10 @@ export default apiRoute((app) =>
|
|||
{
|
||||
type: "InstanceMetadata" as const,
|
||||
compatibility: {
|
||||
extensions: ["pub.versia:custom_emojis"],
|
||||
extensions: [
|
||||
"pub.versia:custom_emojis",
|
||||
"pub.versia:instance_messaging",
|
||||
],
|
||||
versions: ["0.4.0"],
|
||||
},
|
||||
host: new URL(config.http.base_url).host,
|
||||
|
|
@ -63,6 +66,14 @@ export default apiRoute((app) =>
|
|||
created_at: new Date(
|
||||
firstUser?.data.createdAt ?? 0,
|
||||
).toISOString(),
|
||||
extensions: {
|
||||
"pub.versia:instance_messaging": {
|
||||
endpoint: new URL(
|
||||
"/messaging",
|
||||
config.http.base_url,
|
||||
).toString(),
|
||||
},
|
||||
},
|
||||
},
|
||||
200,
|
||||
);
|
||||
|
|
|
|||
|
|
@ -194,6 +194,11 @@ export const configureLoggers = (silent = false): Promise<void> =>
|
|||
sinks: ["console", "file"],
|
||||
filters: ["configFilter"],
|
||||
},
|
||||
{
|
||||
category: ["federation", "messaging"],
|
||||
sinks: ["console", "file"],
|
||||
filters: ["configFilter"],
|
||||
},
|
||||
{
|
||||
category: "database",
|
||||
sinks: ["console", "file"],
|
||||
|
|
|
|||
Loading…
Reference in a new issue