v3: follows, notifications, invite-only registration, unread markers
This commit is contained in:
@@ -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 });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user