projects
/
vchess.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Experimental game upload added
[vchess.git]
/
server
/
models
/
Game.js
diff --git
a/server/models/Game.js
b/server/models/Game.js
index
aec80a0
..
ee381d4
100644
(file)
--- a/
server/models/Game.js
+++ b/
server/models/Game.js
@@
-18,6
+18,8
@@
const UserModel = require("./User");
* randomness: integer
* deletedByWhite: boolean
* deletedByBlack: boolean
* randomness: integer
* deletedByWhite: boolean
* deletedByBlack: boolean
+ * chatReadWhite: datetime
+ * chatReadBlack: datetime
*
* Structure table Moves:
* gid: ref game id
*
* Structure table Moves:
* gid: ref game id
@@
-74,6
+76,7
@@
const GameModel =
"SELECT " +
"g.id, g.fen, g.fenStart, g.cadence, g.created, " +
"g.white, g.black, g.score, g.scoreMsg, " +
"SELECT " +
"g.id, g.fen, g.fenStart, g.cadence, g.created, " +
"g.white, g.black, g.score, g.scoreMsg, " +
+ "g.chatReadWhite, g.chatReadBlack, " +
"g.drawOffer, g.rematchOffer, v.name AS vname " +
"FROM Games g " +
"JOIN Variants v " +
"g.drawOffer, g.rematchOffer, v.name AS vname " +
"FROM Games g " +
"JOIN Variants v " +
@@
-309,6
+312,8
@@
const GameModel =
!obj.fen || !!(obj.fen.match(/^[a-zA-Z0-9, /-]*$/))
) && (
!obj.score || !!(obj.score.match(/^[012?*\/-]+$/))
!obj.fen || !!(obj.fen.match(/^[a-zA-Z0-9, /-]*$/))
) && (
!obj.score || !!(obj.score.match(/^[012?*\/-]+$/))
+ ) && (
+ !obj.chatRead || !(['w','b'].includes(obj.chatRead))
) && (
!obj.scoreMsg || !!(obj.scoreMsg.match(/^[a-zA-Z ]+$/))
) && (
) && (
!obj.scoreMsg || !!(obj.scoreMsg.match(/^[a-zA-Z ]+$/))
) && (
@@
-343,6
+348,10
@@
const GameModel =
const myColor = obj.deletedBy == 'w' ? "White" : "Black";
modifs += "deletedBy" + myColor + " = true,";
}
const myColor = obj.deletedBy == 'w' ? "White" : "Black";
modifs += "deletedBy" + myColor + " = true,";
}
+ if (!!obj.chatRead) {
+ const myColor = obj.chatRead == 'w' ? "White" : "Black";
+ modifs += "chatRead" + myColor + " = " + Date.now() + ",";
+ }
if (!!obj.score) {
modifs += "score = '" + obj.score + "'," +
"scoreMsg = '" + obj.scoreMsg + "',";
if (!!obj.score) {
modifs += "score = '" + obj.score + "'," +
"scoreMsg = '" + obj.scoreMsg + "',";