diff --git a/server/internal/clients/handler.ts b/server/internal/clients/handler.ts index 130c8d6..68a507a 100644 --- a/server/internal/clients/handler.ts +++ b/server/internal/clients/handler.ts @@ -63,7 +63,9 @@ export class ClientHandler { } async fetchClientMetadataByToken(token: string) { - return Object.entries(this.temporaryClientTable) + return this.temporaryClientTable + .entries() + .toArray() .map((e) => Object.assign(e[1], { id: e[0] })) .find((e) => e.authToken === token); } diff --git a/server/internal/notifications/index.ts b/server/internal/notifications/index.ts index c158dd0..69c9509 100644 --- a/server/internal/notifications/index.ts +++ b/server/internal/notifications/index.ts @@ -57,8 +57,15 @@ class NotificationSystem { } async push(userId: string, notificationCreateArgs: NotificationCreateArgs) { - const notification = await prisma.notification.create({ - data: { + const notification = await prisma.notification.upsert({ + where: { + nonce: notificationCreateArgs.nonce!! + }, + update: { + userId: userId, + ...notificationCreateArgs, + }, + create: { userId: userId, ...notificationCreateArgs, }, diff --git a/server/internal/objects/fsBackend.ts b/server/internal/objects/fsBackend.ts index 47cb23c..4f3aaae 100644 --- a/server/internal/objects/fsBackend.ts +++ b/server/internal/objects/fsBackend.ts @@ -25,7 +25,6 @@ export class FsObjectBackend extends ObjectBackend { } async fetch(id: ObjectReference) { - console.log("ID: " + id); const objectPath = path.join(this.baseObjectPath, id); if (!fs.existsSync(objectPath)) return undefined; return fs.createReadStream(objectPath); diff --git a/server/internal/tasks/index.ts b/server/internal/tasks/index.ts index bae56a8..7bba7d0 100644 --- a/server/internal/tasks/index.ts +++ b/server/internal/tasks/index.ts @@ -51,7 +51,7 @@ class TaskHandler { }; logOffset = taskEntry.log.length; - for (const clientId of Object.keys(taskEntry.clients)) { + for (const clientId of taskEntry.clients.keys()) { const client = this.clientRegistry.get(clientId); if (!client) continue; client.send(JSON.stringify(taskMessage)); @@ -108,7 +108,7 @@ class TaskHandler { } await updateAllClients(); - for (const clientId of Object.keys(taskEntry.clients)) { + for (const clientId of taskEntry.clients.keys()) { if (!this.clientRegistry.get(clientId)) continue; this.disconnect(clientId, task.id); } @@ -160,7 +160,7 @@ class TaskHandler { } disconnectAll(id: string) { - for (const taskId of Object.keys(this.taskRegistry)) { + for (const taskId of this.taskRegistry.keys()) { this.taskRegistry.get(taskId)?.clients.delete(id); this.sendDisconnectEvent(id, taskId); } @@ -175,8 +175,10 @@ class TaskHandler { task.clients.delete(id); this.sendDisconnectEvent(id, taskId); - const allClientIds = Object.values(this.taskRegistry) - .map((_) => Object.keys(_.clients)) + const allClientIds = this.taskRegistry + .values() + .toArray() + .map((e) => e.clients.keys().toArray()) .flat(); if (!allClientIds.includes(id)) {