File tree Expand file tree Collapse file tree 4 files changed +20
-13
lines changed
src/Simplex/Messaging/Notifications Expand file tree Collapse file tree 4 files changed +20
-13
lines changed Original file line number Diff line number Diff line change @@ -259,6 +259,7 @@ library
259259 Simplex.Messaging.Notifications.Server.Main
260260 Simplex.Messaging.Notifications.Server.Prometheus
261261 Simplex.Messaging.Notifications.Server.Push.APNS
262+ Simplex.Messaging.Notifications.Server.Push
262263 Simplex.Messaging.Notifications.Server.Push.APNS.Internal
263264 Simplex.Messaging.Notifications.Server.Stats
264265 Simplex.Messaging.Notifications.Server.Store
Original file line number Diff line number Diff line change @@ -56,7 +56,7 @@ import Simplex.Messaging.Notifications.Protocol
5656import Simplex.Messaging.Notifications.Server.Control
5757import Simplex.Messaging.Notifications.Server.Env
5858import Simplex.Messaging.Notifications.Server.Prometheus
59- import Simplex.Messaging.Notifications.Server.Push.APNS (PushNotification (.. ), PushProviderError (.. ))
59+ import Simplex.Messaging.Notifications.Server.Push (PushNotification (.. ), PushProviderError (.. ))
6060import Simplex.Messaging.Notifications.Server.Stats
6161import Simplex.Messaging.Notifications.Server.Store (NtfSTMStore , TokenNtfMessageRecord (.. ), stmStoreTokenLastNtf )
6262import Simplex.Messaging.Notifications.Server.Store.Postgres
Original file line number Diff line number Diff line change @@ -30,6 +30,12 @@ import Data.Time.Clock.System
3030import qualified Data.X509 as X
3131import Simplex.Messaging.Notifications.Protocol
3232import Simplex.Messaging.Parsers (defaultJSON )
33+ import Simplex.Messaging.Transport.HTTP2.Client (HTTP2ClientError )
34+ import qualified Simplex.Messaging.Crypto as C
35+ import Network.HTTP.Types (Status )
36+ import Control.Exception (Exception )
37+ import Simplex.Messaging.Notifications.Server.Store.Types (NtfTknRec )
38+ import Control.Monad.Except (ExceptT )
3339
3440data JWTHeader = JWTHeader
3541 { alg :: Text , -- key algorithm, ES256 for APNS
@@ -79,3 +85,15 @@ data PushNotification
7985 | -- | PNAlert Text
8086 PNCheckMessages
8187 deriving (Show )
88+
89+ data PushProviderError
90+ = PPConnection HTTP2ClientError
91+ | PPCryptoError C. CryptoError
92+ | PPResponseError (Maybe Status ) Text
93+ | PPTokenInvalid NTInvalidReason
94+ | PPRetryLater
95+ | PPPermanentError
96+ | PPInvalidPusher
97+ deriving (Show , Exception )
98+
99+ type PushProviderClient = NtfTknRec -> PushNotification -> ExceptT PushProviderError IO ()
Original file line number Diff line number Diff line change 1010
1111module Simplex.Messaging.Notifications.Server.Push.APNS where
1212
13- import Control.Exception (Exception )
1413import Control.Logger.Simple
1514import Control.Monad
1615import Control.Monad.Except
@@ -251,17 +250,6 @@ apnsRequest c tkn ntf@APNSNotification {aps} = do
251250 APNSBackground {} -> " background"
252251 _ -> " alert"
253252
254- data PushProviderError
255- = PPConnection HTTP2ClientError
256- | PPCryptoError C. CryptoError
257- | PPResponseError (Maybe Status ) Text
258- | PPTokenInvalid NTInvalidReason
259- | PPRetryLater
260- | PPPermanentError
261- deriving (Show , Exception )
262-
263- type PushProviderClient = NtfTknRec -> PushNotification -> ExceptT PushProviderError IO ()
264-
265253-- this is not a newtype on purpose to have a correct JSON encoding as a record
266254data APNSErrorResponse = APNSErrorResponse { reason :: Text }
267255
You can’t perform that action at this time.
0 commit comments