{-# LANGUAGE DataKinds #-} {-# LANGUAGE KindSignatures #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE NamedFieldPuns #-} module Simplex.Messaging.Server.QueueStore where import Simplex.Messaging.Protocol data QueueRec = QueueRec { QueueRec -> QueueId recipientId :: QueueId, QueueRec -> QueueId senderId :: QueueId, QueueRec -> RecipientPublicKey recipientKey :: RecipientPublicKey, QueueRec -> Maybe RecipientPublicKey senderKey :: Maybe SenderPublicKey, QueueRec -> QueueStatus status :: QueueStatus } data QueueStatus = QueueActive | QueueOff deriving (QueueStatus -> QueueStatus -> Bool (QueueStatus -> QueueStatus -> Bool) -> (QueueStatus -> QueueStatus -> Bool) -> Eq QueueStatus forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a /= :: QueueStatus -> QueueStatus -> Bool $c/= :: QueueStatus -> QueueStatus -> Bool == :: QueueStatus -> QueueStatus -> Bool $c== :: QueueStatus -> QueueStatus -> Bool Eq) class MonadQueueStore s m where addQueue :: s -> RecipientPublicKey -> (RecipientId, SenderId) -> m (Either ErrorType ()) getQueue :: s -> SParty (a :: Party) -> QueueId -> m (Either ErrorType QueueRec) secureQueue :: s -> RecipientId -> SenderPublicKey -> m (Either ErrorType ()) suspendQueue :: s -> RecipientId -> m (Either ErrorType ()) deleteQueue :: s -> RecipientId -> m (Either ErrorType ()) mkQueueRec :: RecipientPublicKey -> (RecipientId, SenderId) -> QueueRec mkQueueRec :: RecipientPublicKey -> (QueueId, QueueId) -> QueueRec mkQueueRec recipientKey :: RecipientPublicKey recipientKey (recipientId :: QueueId recipientId, senderId :: QueueId senderId) = QueueRec :: QueueId -> QueueId -> RecipientPublicKey -> Maybe RecipientPublicKey -> QueueStatus -> QueueRec QueueRec { QueueId recipientId :: QueueId recipientId :: QueueId recipientId, QueueId senderId :: QueueId senderId :: QueueId senderId, RecipientPublicKey recipientKey :: RecipientPublicKey recipientKey :: RecipientPublicKey recipientKey, senderKey :: Maybe RecipientPublicKey senderKey = Maybe RecipientPublicKey forall a. Maybe a Nothing, status :: QueueStatus status = QueueStatus QueueActive }