fix: Prevent users from sending blank messages

This commit is contained in:
April Hall 2025-01-09 12:36:43 -05:00
parent 3dc59bf4f1
commit 92cf5a8af2
No known key found for this signature in database
GPG Key ID: A49AC35CB186266C

View File

@ -15,15 +15,18 @@ export function startupSocketIOServer(httpServer: HttpServer | null) {
console.log(`[ws:kit] client connected (${socket.id})`); console.log(`[ws:kit] client connected (${socket.id})`);
// Runs on message receive // Runs on message receive
socket.on('message', async (msg) => { socket.on('message', async (msg) => {
console.log(`[ws:kit] message from ${socket.id}: ${msg}`); // If message not empty
// Store the message in the database if (msg.content !== "") {
await createChannel(client, '000'); console.log(`[ws:kit] message from ${socket.id}: ${msg.content}`);
await storeMessage(client, '000', msg.content, msg.id, uuidv4()); // Store the message in the database
io!.emit('message', { await createChannel(client, '000');
user: msg.id, await storeMessage(client, '000', msg.content, msg.id, uuidv4());
message: msg.content, io!.emit('message', {
imageSrc: 'https://www.arithefirst.com/images/pfp.png', user: msg.id,
}); message: msg.content,
imageSrc: 'https://www.arithefirst.com/images/pfp.png',
});
}
}); });
// Runs on client disconnect // Runs on client disconnect