ntf server: resume push notifications after APNS errors (#2020)

* ntf server: resume push notifications after APNS errors

* ntf server: fix push delivery test assertion
This commit is contained in:
Evgeny @ SimpleX Chat authored and GitHub committed 2026-11-06 18:56:17 +00:00
1 parent 9af1341498
commit db1cf85e2a
3 files changed
+41 -2

No files matched your search

@@ -677,7 +677,7 @@ runPushWorker s srvHost_ isOwn q = forever $ do
(tkn@NtfTknRec {ntfTknId, token = t@(DeviceToken pp _), tknStatus}, ntf) <- atomically (readTBQueue q)
liftIO $ logDebug $ "sending push notification to " <> T.pack (show pp)
st <- asks store
case ntf of
r <- tryAny $ case ntf of
PNVerification _ ->
liftIO (deliverNotification st pp tkn ntf) >>= \case
Right _ -> do
@@ -700,6 +700,9 @@ runPushWorker s srvHost_ isOwn q = forever $ do
Right () -> do
incNtfStatT t ntfDelivered
when isOwn $ liftIO $ mapM_ (`incServerStat` ntfDeliveredOwn stats) srvHost_
case r of
Right () -> pure ()
Left e -> logError $ "push notification error (" <> tshow pp <> ", " <> tshow ntfTknId <> "): " <> tshow e
where
checkActiveTkn :: NtfTknStatus -> M () -> M ()
checkActiveTkn status action
@@ -232,9 +232,9 @@ data APNSPushClient = APNSPushClient
createAPNSPushClient :: HostName -> APNSPushClientConfig -> IO APNSPushClient
createAPNSPushClient apnsHost apnsCfg@APNSPushClientConfig {authKeyFileEnv, authKeyAlg, authKeyIdEnv, appTeamId} = do
https2Client <- newTVarIO Nothing
connectHTTPS2 apnsHost apnsCfg https2Client >>= either (throwIO . userError . show) (\_ -> pure ())
privateKey <- readECPrivateKey =<< getEnv authKeyFileEnv
authKeyId <- T.pack <$> getEnv authKeyIdEnv
connectHTTPS2 apnsHost apnsCfg https2Client >>= either (throwIO . userError . show) (\_ -> pure ())
let jwtHeader = JWTHeader {alg = authKeyAlg, kid = authKeyId}
jwtToken <- newTVarIO =<< mkApnsJWTToken appTeamId jwtHeader privateKey
nonceDrg <- C.newRandom