diff --git a/src/Simplex/Messaging/Agent.hs b/src/Simplex/Messaging/Agent.hs index e4b0d4013..799fed250 100644 --- a/src/Simplex/Messaging/Agent.hs +++ b/src/Simplex/Messaging/Agent.hs @@ -2268,10 +2268,8 @@ verifyNtfToken' c deviceToken nonce code = _ -> throwE $ CMD PROHIBITED "verifyNtfToken: no token" setCronInterval :: AgentClient -> NtfTokenId -> NtfToken -> AM' () -setCronInterval c tknId tkn@NtfToken {ntfMode} = do - cron <- case ntfMode of - NMPeriodic -> asks $ ntfCron . config - _ -> pure 0 +setCronInterval c tknId tkn = do + cron <- asks $ ntfCron . config void $ forkIO $ void $ runExceptT $ agentNtfSetCronInterval c tknId tkn cron checkNtfToken' :: AgentClient -> DeviceToken -> AM NtfTknStatus diff --git a/src/Simplex/Messaging/Notifications/Protocol.hs b/src/Simplex/Messaging/Notifications/Protocol.hs index b23bd4e91..cc2d63bca 100644 --- a/src/Simplex/Messaging/Notifications/Protocol.hs +++ b/src/Simplex/Messaging/Notifications/Protocol.hs @@ -521,7 +521,6 @@ instance StrEncoding NtfSubStatus where strP = smpP {-# INLINE strP #-} --- TODO [ntfdb] check what happens in agent when token in not yet registered data NtfTknStatus = -- | Token created in DB NTNew @@ -541,7 +540,7 @@ allowNtfSubCommands :: NtfTknStatus -> Bool allowNtfSubCommands = \case NTNew -> False NTRegistered -> False - -- TODO [ntfdb] we could have separate statuses to show whether it became invalid + -- TODO we could have separate statuses to show whether it became invalid -- after verification (allow commands) or before (do not allow) NTInvalid _ -> True NTConfirmed -> False diff --git a/src/Simplex/Messaging/Notifications/Server.hs b/src/Simplex/Messaging/Notifications/Server.hs index 677f14758..b132c0ac9 100644 --- a/src/Simplex/Messaging/Notifications/Server.hs +++ b/src/Simplex/Messaging/Notifications/Server.hs @@ -491,7 +491,6 @@ ntfSubscriber NtfSubscriber {smpSubscribers, newSubQ, smpAgent = ca@SMPClientAge let newNtf = PNMessageData {smpQueue, ntfTs, nmsgNonce, encNMsgMeta} ntfs_ <- liftIO $ addTokenLastNtf st newNtf forM_ ntfs_ $ \(tkn, lastNtfs) -> atomically $ writeTBQueue pushQ (tkn, PNMessage lastNtfs) - -- TODO [ntfdb] count queued notifications separately? incNtfStat ntfReceived Right SMP.END -> do whenM (atomically $ activeClientSession' ca sessionId srv) $ do @@ -604,8 +603,6 @@ ntfPush s@NtfPushServer {pushQ} = forever $ do _ -> err e err e = logError ("Push provider error (" <> tshow pp <> ", " <> tshow ntfTknId <> "): " <> tshow e) $> Left e --- TODO [ntfdb] this could be further improved by sending periodic notifications directly from this thread, --- without any queue periodicNtfsThread :: NtfPushServer -> M () periodicNtfsThread NtfPushServer {pushQ} = do st <- asks store