diff options
author | Tor Andersson <tor@ccxvii.net> | 2025-02-15 23:47:40 +0100 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2025-02-15 23:47:40 +0100 |
commit | c77deb601f3f6bc2b37379c262764365772387ed (patch) | |
tree | a47524581f2ffc13a3017c5f5e37797add75ea16 | |
parent | 94060bfa5f58b3715c38b36b5c110061ca12bea4 (diff) | |
download | server-c77deb601f3f6bc2b37379c262764365772387ed.tar.gz |
Send tournament ended notification.
-rw-r--r-- | server.js | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -2604,6 +2604,10 @@ function message_link(msg_id) { return SITE_URL + "/message/read/" + msg_id } +function tour_pool_link(pool_id) { + return SITE_URL + "/tm/pool/" + pool_id +} + function send_notification(user, link, message) { if (WEBHOOKS) { let webhook = SQL_SELECT_WEBHOOK_SEND.get(user.user_id) @@ -2638,6 +2642,10 @@ function send_play_notification(user, game_id, message) { send_notification(user, game_play_link(game_id, title_id, user), `${title_name} #${game_id} (${user.role}) - ${message}`) } +function send_tour_notification(user, pool_name, message) { + send_notification(user, tour_pool_link(pool_name), `${pool_name} - ${message}`) +} + function send_chat_activity_notification(game_id, p) { send_play_notification(p, game_id, "Chat activity") } @@ -3534,9 +3542,11 @@ function start_tournament_seed(seed_id, level) { function tm_reap_pools() { // reap pools that are finished (and promote winners) + // reap pools that are finished (and notify players) let ended = TM_SELECT_ENDED_POOLS.all() for (let item of ended) { console.log("TM POOL - END", item.pool_name) + SQL_BEGIN.run() try { TM_UPDATE_POOL_FINISHED.run(item.pool_id) @@ -3550,6 +3560,10 @@ function tm_reap_pools() { if (db.inTransaction) SQL_ROLLBACK.run() } + + let players = TM_SELECT_PLAYERS_IN_POOL.all(item.pool_id) + for (let user of players) + send_tour_notification(user, item.pool_name, "Finished") } } |