ntf: refactor NtfSubAction (#445)

This commit is contained in:
JRoberts
2022-06-30 15:34:16 +04:00
committed by GitHub
parent 9695786aa5
commit c82fae72f2
3 changed files with 35 additions and 65 deletions
+3 -34
View File
@@ -4,22 +4,7 @@
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
module Simplex.Messaging.Notifications.Types
( NtfServer,
NtfTknAction (..),
NtfToken (..),
newNtfToken,
NtfSubAction (..),
NtfSubActionData (..),
NtfSubNTFActionData (..),
NtfSubNTFAction (..),
NtfSubSMPActionData (..),
NtfSubSMPAction (..),
NtfAgentSubStatus (..),
NtfSubscription (..),
newNtfSubscription,
)
where
module Simplex.Messaging.Notifications.Types where
import qualified Data.Attoparsec.ByteString.Char8 as A
import Data.Text.Encoding (decodeLatin1, encodeUtf8)
@@ -97,17 +82,7 @@ newNtfToken deviceToken ntfServer (ntfPubKey, ntfPrivKey) ntfDhKeys ntfMode =
data NtfSubAction = NtfSubNTFAction NtfSubNTFAction | NtfSubSMPAction NtfSubSMPAction
data NtfSubActionData = NtfSubActionData
{ action :: NtfSubAction,
actionTs :: UTCTime,
ntfSubscription :: NtfSubscription
}
data NtfSubNTFActionData = NtfSubNTFActionData
{ ntfAction :: NtfSubNTFAction,
actionTs :: UTCTime,
ntfSubscription :: NtfSubscription
}
type NtfActionTs = UTCTime
data NtfSubNTFAction
= NSACreate
@@ -131,12 +106,6 @@ instance FromField NtfSubNTFAction where fromField = blobFieldDecoder smpDecode
instance ToField NtfSubNTFAction where toField = toField . smpEncode
data NtfSubSMPActionData = NtfSubSMPActionData
{ smpAction :: NtfSubSMPAction,
actionTs :: UTCTime,
ntfSubscription :: NtfSubscription
}
data NtfSubSMPAction
= NSASmpKey
| NSASmpDelete
@@ -212,4 +181,4 @@ newNtfSubscription connId smpServer ntfQueueId ntfServer ntfSubStatus =
ntfServer,
ntfSubId = Nothing,
ntfSubStatus
}
}