query += modifs + " WHERE id = " + id;
db.run(query);
}
- if (obj.move)
+
+
+//return cb({errmsg: JSON.stringify(obj.move)});
+
+
+ // NOTE: move, chat and delchat are mutually exclusive
+ if (!!obj.move)
{
// Security: only update moves if index is right
query =
"WHERE gid = " + id;
db.get(query, (err,ret) => {
const m = obj.move;
+
+//return cb({errmsg: ret.maxIdx + " " + m.idx + " " + (!ret.maxIdx || ret.maxIdx + 1 == m.idx) + " " + query});
+
+
if (!ret.maxIdx || ret.maxIdx + 1 == m.idx) {
query =
"INSERT INTO Moves (gid, squares, played, idx) VALUES " +
"DELETE " +
"FROM Chats " +
"WHERE gid = " + id;
- db.run(query, cb);
+ db.run(query);
}
});
},