summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2024-03-14 23:04:06 +0100
committerTor Andersson <tor@ccxvii.net>2024-03-14 23:04:11 +0100
commita3e6bb6dd0ebf7f2a368403f406c2f3d82654ed1 (patch)
tree46f33cb7972ada08cbeb62f799627e4df529695a
parent0db8085b833c038d5c5766b870b7f1ad98ccbd66 (diff)
downloadserver-a3e6bb6dd0ebf7f2a368403f406c2f3d82654ed1.tar.gz
Add chat message when joining active game via invitation too.
-rw-r--r--server.js5
1 files changed, 5 insertions, 0 deletions
diff --git a/server.js b/server.js
index b2f70f4..183148a 100644
--- a/server.js
+++ b/server.js
@@ -1995,11 +1995,16 @@ app.post("/invite/:game_id/:role/:user", must_be_logged_in, function (req, res)
app.post("/accept/:game_id/:role", must_be_logged_in, function (req, res) {
// TODO: check join game limit if inviting self...
let game_id = req.params.game_id | 0
+ let game = SQL_SELECT_GAME.get(game_id)
let role = req.params.role
let info = SQL_UPDATE_PLAYER_ACCEPT.run(game_id, role, req.user.user_id)
if (info.changes === 1) {
update_join_clients_players(game_id)
res.send("SUCCESS")
+
+ // send chat message about player joining a game in progress
+ if (game.status > 0)
+ send_chat_message(game_id, null, null, `${req.user.name} joined as ${role}.`)
} else {
res.send("Could not accept invite.")
}