return (
(
!obj.move || (
- obj.move.played.toString().match(/^[0-9]+$/) &&
- obj.move.idx.toString().match(/^[0-9]+$/)
+ !!(obj.move.played.toString().match(/^[0-9]+$/)) &&
+ !!(obj.move.idx.toString().match(/^[0-9]+$/))
)
) && (
- !obj.drawOffer || obj.drawOffer.match(/^[wbtn]$/)
+ !obj.drawOffer || !!(obj.drawOffer.match(/^[wbtn]$/))
) && (
- !obj.fen || obj.fen.match(/^[a-zA-Z0-9, /-]*$/)
+ !obj.fen || !!(obj.fen.match(/^[a-zA-Z0-9, /-]*$/))
) && (
- !obj.score || obj.score.match(/^[012?*\/-]+$/)
+ !obj.score || !!(obj.score.match(/^[012?*\/-]+$/))
) && (
- !obj.scoreMsg || obj.scoreMsg.match(/^[a-zA-Z ]+$/)
+ !obj.scoreMsg || !!(obj.scoreMsg.match(/^[a-zA-Z ]+$/))
) && (
!obj.chat || UserModel.checkNameEmail({name: obj.chat.name})
)
query += modifs + " WHERE id = " + id;
db.run(query);
}
- if (obj.move)
+ // NOTE: move, chat and delchat are mutually exclusive
+ if (!!obj.move)
{
// Security: only update moves if index is right
query =
"DELETE " +
"FROM Chats " +
"WHERE gid = " + id;
- db.run(query, cb);
+ db.run(query);
}
});
},