feat: real-time sync, notification & social system overhaul
- Add WS events: dm_channel_created, dm_channel_closed, friend_removed, channel_created/updated/deleted, server_updated - Fix first-ever DM: broadcast dm_channel_created to recipient - Add DELETE /api/dm/:id for closing DMs with re-open support - Wire Close DM button in sidebar - Fix dm_message_created for unknown channels (safety net) - Broadcast friend_removed on friend deletion - Sound system: track realtimeMessageEvents separately from API loads, play notification for messages in all channels, not just current - Optimistic updates: send/edit/delete messages appear instantly with rollback on failure, temp message deduplication on WS echo - Channel CRUD broadcasts to all server members - Server update broadcast on PATCH - Server join registers user in connectionManager immediately - Reconnect: only reload current channel, preserve other channel caches - Activity panel, right panel, member list toggle components
This commit is contained in:
@@ -275,7 +275,15 @@ export async function serverRoutes(app: FastifyInstance): Promise<void> {
|
||||
return reply.code(500).send({ error: 'Failed to update server', statusCode: 500 });
|
||||
}
|
||||
|
||||
return reply.code(200).send(rowToServer(updated));
|
||||
const serverData = rowToServer(updated);
|
||||
|
||||
// Broadcast server_updated to all server members
|
||||
connectionManager.sendToServer(id, {
|
||||
type: 'server_updated',
|
||||
server: serverData,
|
||||
});
|
||||
|
||||
return reply.code(200).send(serverData);
|
||||
});
|
||||
|
||||
// DELETE /api/servers/:id - Delete server (owner only)
|
||||
@@ -363,6 +371,9 @@ export async function serverRoutes(app: FastifyInstance): Promise<void> {
|
||||
joinedAt: now,
|
||||
}).run();
|
||||
|
||||
// Register the user in connectionManager so they receive WS broadcasts for this server
|
||||
connectionManager.addUserServer(request.userId, id);
|
||||
|
||||
return reply.code(200).send(rowToServer(server));
|
||||
});
|
||||
|
||||
@@ -395,6 +406,9 @@ export async function serverRoutes(app: FastifyInstance): Promise<void> {
|
||||
joinedAt: now,
|
||||
}).run();
|
||||
|
||||
// Register the user in connectionManager so they receive WS broadcasts for this server
|
||||
connectionManager.addUserServer(request.userId, server.id);
|
||||
|
||||
return reply.code(200).send(rowToServer(server));
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user