From a3ae62afd2eecb3831e2483f94d2db6a1d6bb748 Mon Sep 17 00:00:00 2001
From: Tor Andersson <tor@ccxvii.net>
Date: Wed, 6 Sep 2023 20:41:52 +0200
Subject: Notification system improvements.

Enable webhook notification support with .env WEBHOOKS=1

Send notifications when invited to a game.

Use notification "too soon" logic for webhooks as well.

Try sending webhooks 3 times before giving up.

Check if player is on the join page instead of the funky "offline" check
when sending "your game is ready" notification.

Only show mail/webhook notification settings if they are enabled.
---
 schema.sql | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

(limited to 'schema.sql')

diff --git a/schema.sql b/schema.sql
index ff99076..e121bda 100644
--- a/schema.sql
+++ b/schema.sql
@@ -422,7 +422,6 @@ create view your_turn_reminder as
 		status = 1
 		and active in ('All', 'Both', role)
 		and is_solo = 0
-		and notify = 1
 		and julianday() > julianday(mtime, '+1 hour')
 	;
 
@@ -439,6 +438,17 @@ create view your_turn as
 		and active in ('All', 'Both', role)
 	;
 
+drop view if exists invite_reminder;
+create view invite_reminder as
+	select
+		game_id, role, user_id, name, mail, notify
+	from
+		players
+		join users using(user_id)
+	where
+		is_invite = 1
+	;
+
 -- Trigger to remove game data when filing a game as archived
 
 drop trigger if exists trigger_archive_game;
-- 
cgit v1.2.3

