← All repositories

crossmate

A collaborative crossword app for iPhone and iPad

git clone https://code.inqk.net/crossmate.git


commit 1376ed86a7e44d41247e3ad6913b51c3e04be22f
parent a4cdea5829da56abf4e09727a901f1711ccb33a4
Author: Michael Camilleri <[email protected]>
Date:   Wed, 17 Jun 2026 11:02:09 +0900

Retain account-seen pushes briefly

This commit gives 'accountSeen' background pushes a 15-minute APNs
expiry so a briefly unreachable sibling device can still withdraw
already-read notifications. Other background pushes and 'play' presence
events remain deliver-now-or-discard, while visible puzzle alerts keep
their existing four-hour window.

Co-Authored-By: Codex GPT 5.5 <[email protected]>

Diffstat

MWorkers/push-worker.js | 20++++++++++++--------

1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/Workers/push-worker.js b/Workers/push-worker.js

@@ -559,15 +559,19 @@ export class PushRegistry {
     // app builds, which the extension handles by falling back to `kind`.
     if (message.payload) apnsPayload.payload = message.payload;
 
-    // "play" presence is ephemeral: deliver now or discard. Other alert kinds
-    // (win/resign/pause) are one-time meaningful events — give APNs a
-    // store-and-forward window so a recipient who is offline at send time
-    // still gets the banner. Background pushes stay at 0; the state they
-    // nudge converges through CloudKit anyway.
-    const ephemeral = message.background || message.kind === "play";
-    const expiration = ephemeral
+    // "play" presence is ephemeral: deliver now or discard. `accountSeen` is
+    // also background-only, but it withdraws already-read notifications from
+    // sibling devices; give APNs a short store-and-forward window so a
+    // briefly-unreachable device can still converge. Other alert kinds
+    // (win/resign/pause) are one-time meaningful events and keep the longer
+    // window so a recipient who is offline at send time still gets the banner.
+    const expirationSeconds =
+      message.kind === "accountSeen" ? 15 * 60 :
+      message.background || message.kind === "play" ? 0 :
+      4 * 60 * 60;
+    const expiration = expirationSeconds === 0
       ? "0"
-      : String(Math.floor(Date.now() / 1000) + 4 * 60 * 60);
+      : String(Math.floor(Date.now() / 1000) + expirationSeconds);
 
     const response = await fetch(`https://${host}/3/device/${target.token}`, {
       method: "POST",