mirror of
https://github.com/Discreetly/server.git
synced 2026-01-09 12:37:58 -05:00
system message broadcasts need to be reworked.
This commit is contained in:
@@ -46,19 +46,20 @@ export function websocketSetup(io: SocketIOServer) {
|
||||
io.to(roomID).emit('Members', userCount[roomID] ? userCount[roomID] : 0);
|
||||
});
|
||||
|
||||
socket.on('systemMessage', (msg: string, roomID: bigint) => {
|
||||
const id = roomID.toString();
|
||||
createSystemMessages(msg, id)
|
||||
.then(() => {
|
||||
if (roomID) {
|
||||
io.to(id).emit('systemMessage', msg);
|
||||
} else {
|
||||
io.emit('systemMessage', msg);
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
pp(err, 'error');
|
||||
});
|
||||
});
|
||||
// TODO We need to rewrite this so it doesn't use `socket.on`, because this allows anyone to be able to broadcast a system message to any room.
|
||||
// socket.on('systemMessage', (msg: string, roomID: bigint) => {
|
||||
// const id = roomID.toString();
|
||||
// createSystemMessages(msg, id)
|
||||
// .then(() => {
|
||||
// if (roomID) {
|
||||
// io.to(id).emit('systemMessage', msg);
|
||||
// } else {
|
||||
// io.emit('systemMessage', msg);
|
||||
// }
|
||||
// })
|
||||
// .catch((err) => {
|
||||
// pp(err, 'error');
|
||||
// });
|
||||
// });
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user