ready for PR/review

This commit is contained in:
Keith Campbell
2022-01-02 18:00:16 -05:00
parent ab73d05471
commit 2aedb6e938
+21 -21
View File
@@ -46,11 +46,8 @@ const chat = io => {
socket.join(socket.user.room);
//broadcast to this room
socket.broadcast.to(socket.user.room).emit('message', {timestamp: log.createdAt, emphasis: true, text: `${socket.user.username} entered chat` });
//log
chatlog.create({
const log = await chatlog.create({
notification: true,
username: socket.user.username,
text: `${socket.user.username} entered chat`,
@@ -58,6 +55,9 @@ const chat = io => {
emphasis: true
});
//broadcast to this room
socket.broadcast.to(socket.user.room).emit('message', {timestamp: log.createdAt, emphasis: true, text: `${socket.user.username} entered chat` });
//send backlog to the user
chatlog.findAll({
where: {
@@ -129,7 +129,7 @@ const chat = io => {
socket.broadcast.to(socket.user.room || '.error').emit('message', { emphasis: true, text: `${socket.user.username} left chat` });
//log
chatlog.create({
const log = await chatlog.create({
notification: true,
username: socket.user.username,
text: `${socket.user.username} left chat`,
@@ -164,11 +164,8 @@ const executeCommand = (io, socket, command) => {
break;
}
//broadcast to the old room
socket.broadcast.to(socket.user.room).emit('message', { emphasis: true, text: `${socket.user.username} left the room (going to ${room})` });
//log
chatlog.create({
const log = await chatlog.create({
notification: true,
username: socket.user.username,
text: `${socket.user.username} left the room`,
@@ -176,16 +173,16 @@ const executeCommand = (io, socket, command) => {
emphasis: true
});
//broadcast to the old room
socket.broadcast.to(socket.user.room).emit('message', { timestamp: log.createdAt, emphasis: true, text: `${socket.user.username} left the room (going to ${room})` });
//move
socket.leave(socket.user.room);
socket.user.room = room;
socket.join(socket.user.room);
//broadcast to the new room
socket.broadcast.to(socket.user.room).emit('message', { emphasis: true, text: `${socket.user.username} entered the room` });
//log
chatlog.create({
const log = await chatlog.create({
notification: true,
username: socket.user.username,
text: `${socket.user.username} entered the room`,
@@ -193,6 +190,9 @@ const executeCommand = (io, socket, command) => {
emphasis: true
});
//broadcast to the new room
socket.broadcast.to(socket.user.room).emit('message', {timestamp: log.createdAt, emphasis: true, text: `${socket.user.username} entered the room` });
//update the user
socket.emit('message', {timestamp: log.createdAt, emphasis: true, text: `Entered room ${socket.user.room}` });
break;
@@ -225,11 +225,8 @@ const executeCommand = (io, socket, command) => {
reason: reason
});
//broadcast
io.to(socket.user.room).emit('message', { strong: true, emphasis: true, text: `${username} has been muted for ${minutes} minute${minutes != 1 ? 's' : ''}${reason ? ': ' : ''}${reason}` });
//log
chatlog.create({
const log = await chatlog.create({
notification: true,
username: socket.user.username,
text: `${username} has been muted for ${minutes} minute${minutes != 1 ? 's' : ''}: ${reason}`,
@@ -238,6 +235,9 @@ const executeCommand = (io, socket, command) => {
emphasis: true
});
//broadcast
io.to(socket.user.room).emit('message', { timestamp: log.createdAt, strong: true, emphasis: true, text: `${username} has been muted for ${minutes} minute${minutes != 1 ? 's' : ''}${reason ? ': ' : ''}${reason}` });
break;
}
@@ -267,11 +267,8 @@ const executeCommand = (io, socket, command) => {
break;
}
//broadcast
io.to(socket.user.room).emit('message', { emphasis: true, text: `${username} has been unmuted` });
//log
chatlog.create({
const log = await chatlog.create({
notification: true,
username: socket.user.username,
text: `${username} has been unmuted`,
@@ -279,6 +276,9 @@ const executeCommand = (io, socket, command) => {
emphasis: true
});
//broadcast
io.to(socket.user.room).emit('message', {timestamp: log.createdAt, emphasis: true, text: `${username} has been unmuted` });
break;
}