v3: added opengraph support to the app, wrote README instructions incl. a Docker image

This commit is contained in:
khannurien
2026-03-26 19:55:48 +00:00
parent 0cb5a798c7
commit ca70bdc14b
26 changed files with 551 additions and 120 deletions

View File

@@ -1,4 +1,5 @@
import { Router } from "@oak/oak";
import { ALLOWED_ORIGINS } from "../config.ts";
import { verifyJWT } from "../lib/jwt.ts";
import {
broadcastPresence,
@@ -24,8 +25,7 @@ import {
const router = new Router();
function isAllowedOrigin(origin: string): boolean {
if (!origin) return false;
return /^https?:\/\/(localhost|127\.0\.0\.1)(:\d+)?$/.test(origin);
return ALLOWED_ORIGINS.includes(origin);
}
router.get("/ws", async (ctx) => {
@@ -45,12 +45,9 @@ router.get("/ws", async (ctx) => {
const socket = ctx.upgrade();
let avatarMime: string | undefined;
if (authPayload) {
try {
avatarMime = getUserById(authPayload.userId).avatarMime;
} catch { /* user not found */ }
}
const avatarMime = authPayload
? getUserById(authPayload.userId).avatarMime
: undefined;
const client: WsClient = {
socket,