summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--server.js14
1 files changed, 14 insertions, 0 deletions
diff --git a/server.js b/server.js
index 3faa6b0..ddaf0ce 100644
--- a/server.js
+++ b/server.js
@@ -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")
}
}