v1 review pass: fixed some minor bugs

This commit is contained in:
khannurien
2026-03-16 11:08:39 +00:00
parent e88fed4e98
commit 867e64cb5b
37 changed files with 1228 additions and 400 deletions

View File

@@ -5,10 +5,14 @@ import {
broadcastVoteUpdate,
getOnlineUsers,
register,
type WsClient,
unregister,
type WsClient,
} from "../services/ws-service.ts";
import { castVote, getUserVotes, removeVote } from "../services/vote-service.ts";
import {
castVote,
getUserVotes,
removeVote,
} from "../services/vote-service.ts";
import { getUserById } from "../services/user-service.ts";
import { APIException } from "../model/interfaces.ts";
@@ -38,7 +42,9 @@ router.get("/ws", async (ctx) => {
let avatarMime: string | undefined;
if (authPayload) {
try { avatarMime = getUserById(authPayload.userId).avatarMime; } catch { /* user not found */ }
try {
avatarMime = getUserById(authPayload.userId).avatarMime;
} catch { /* user not found */ }
}
const client: WsClient = {
@@ -100,7 +106,9 @@ function handleVote(
const { socket } = client;
if (!client.userId) {
socket.send(JSON.stringify({ type: "error", message: "Authentication required" }));
socket.send(
JSON.stringify({ type: "error", message: "Authentication required" }),
);
return;
}
@@ -122,7 +130,7 @@ function handleVote(
voteCount: newCount,
}));
broadcastVoteUpdate(dumpId, newCount);
broadcastVoteUpdate(dumpId, newCount, client.userId, action);
} catch (err) {
const message = err instanceof APIException ? err.message : "Vote failed";
socket.send(JSON.stringify({ type: "error", message }));