v3: added opengraph support to the app, wrote README instructions incl. a Docker image
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user