v3: follows, notifications, invite-only registration, unread markers

This commit is contained in:
khannurien
2026-03-21 18:42:47 +00:00
parent 7c098e7c4c
commit 608c6bc6a8
55 changed files with 4743 additions and 884 deletions

View File

@@ -1,4 +1,9 @@
import type { Comment, Dump, OnlineUser, Playlist } from "../model/interfaces.ts";
import type {
Comment,
Dump,
OnlineUser,
Playlist,
} from "../model/interfaces.ts";
export interface WsClient {
socket: WebSocket;
@@ -46,6 +51,14 @@ function send(socket: WebSocket, data: unknown): void {
}
}
export function sendToUser(userId: string, data: unknown): void {
for (const client of clients) {
if (client.userId === userId) {
send(client.socket, data);
}
}
}
export function broadcastPresence(): void {
const users = getOnlineUsers();
for (const client of clients) {
@@ -136,7 +149,10 @@ export function broadcastCommentCreated(comment: Comment): void {
}
}
export function broadcastCommentDeleted(commentId: string, dumpId: string): void {
export function broadcastCommentDeleted(
commentId: string,
dumpId: string,
): void {
for (const client of clients) {
send(client.socket, { type: "comment_deleted", commentId, dumpId });
}