From a3e6bb6dd0ebf7f2a368403f406c2f3d82654ed1 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Thu, 14 Mar 2024 23:04:06 +0100 Subject: Add chat message when joining active game via invitation too. --- server.js | 5 +++++ 1 file changed, 5 insertions(+) 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.") } -- cgit v1.2.3