Archived
1
0
Fork 0
This repository has been archived on 2024-02-17. You can view files and clone it, but cannot push or open issues or pull requests.
kfet/sockets/clearCommand.js

24 lines
692 B
JavaScript
Raw Normal View History

const models = require("../models");
module.exports = socket => {
return async (data) => {
try {
2020-05-30 17:09:44 +02:00
let c = await models.Command.findOne({where: {number: {[models.Sequelize.Op.eq]: data}, date: {[models.Sequelize.Op.eq]: new Date()}}});
if (!c)
throw new Error("Command not found");
c.done = null;
c.give = null;
c.error = false;
c.WIP = false;
await c.save();
socket.emit("clear command", data);
socket.broadcast.emit("clear command", data);
} catch (e) {
socket.emit("internal error");
console.error(e);
}
}
}