mirror of
https://github.com/simplex-chat/simplexmq.git
synced 2026-05-31 07:04:17 +00:00
remove/fix compiler warnings
This commit is contained in:
@@ -20,6 +20,7 @@ import Network.Socket
|
||||
import Simplex.Messaging.Agent.Env.SQLite
|
||||
import Simplex.Messaging.Agent.ServerClient (ServerClient (..), newServerClient)
|
||||
import Simplex.Messaging.Agent.Store
|
||||
import Simplex.Messaging.Agent.Store.SQLite
|
||||
import Simplex.Messaging.Agent.Store.Types
|
||||
import Simplex.Messaging.Agent.Transmission
|
||||
import Simplex.Messaging.Server (randomBytes)
|
||||
@@ -68,11 +69,12 @@ client c@AgentClient {rcvQ, sndQ} = forever $ do
|
||||
Right _ -> return ()
|
||||
|
||||
withStore ::
|
||||
(MonadUnliftIO m, MonadError ErrorType m) =>
|
||||
(forall n. (MonadUnliftIO n, MonadError StoreError n) => n a) ->
|
||||
(MonadUnliftIO m, MonadReader Env m, MonadError ErrorType m) =>
|
||||
(forall m'. (MonadUnliftIO m', MonadError StoreError m') => SQLiteStore -> m' a) ->
|
||||
m a
|
||||
withStore action =
|
||||
runExceptT (action `E.catch` handleInternal) >>= \case
|
||||
withStore action = do
|
||||
store <- asks db
|
||||
runExceptT (action store `E.catch` handleInternal) >>= \case
|
||||
Right c -> return c
|
||||
Left e -> throwError $ STORE e
|
||||
where
|
||||
@@ -163,10 +165,9 @@ processResponse
|
||||
(NEW _ _, NEWRequestState {connAlias, smpServer, rcvPrivateKey}) -> do
|
||||
-- TODO all good - process response
|
||||
g <- asks idsDrg
|
||||
st <- asks db
|
||||
encryptKey <- atomically $ randomBytes 16 g -- TODO replace with cryptographic key pair
|
||||
let decryptKey = encryptKey
|
||||
withStore $
|
||||
withStore $ \st ->
|
||||
createRcvConn st connAlias $
|
||||
ReceiveQueue
|
||||
{ server = smpServer,
|
||||
|
||||
@@ -9,14 +9,12 @@ import Control.Monad.IO.Unlift
|
||||
import Crypto.Random
|
||||
import Data.Map.Strict (Map)
|
||||
import qualified Data.Map.Strict as M
|
||||
import qualified Database.SQLite.Simple as DB
|
||||
import Network.Socket (HostName, ServiceName)
|
||||
import Numeric.Natural
|
||||
import Simplex.Messaging.Agent.ServerClient
|
||||
import Simplex.Messaging.Agent.Store
|
||||
import Simplex.Messaging.Agent.Store.SQLite
|
||||
import Simplex.Messaging.Agent.Transmission
|
||||
import Simplex.Messaging.Server.Transmission (PublicKey)
|
||||
import qualified Simplex.Messaging.Server.Transmission as SMP
|
||||
import UnliftIO.STM
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
{-# LANGUAGE ScopedTypeVariables #-}
|
||||
{-# LANGUAGE TypeApplications #-}
|
||||
{-# LANGUAGE UndecidableInstances #-}
|
||||
{-# OPTIONS_GHC -fno-warn-orphans #-}
|
||||
|
||||
module Simplex.Messaging.Agent.Store.SQLite where
|
||||
|
||||
@@ -81,10 +82,10 @@ type ConnectionRowId = Int64
|
||||
fromFieldToReadable :: forall a. (Read a, E.Typeable a) => Field -> Ok a
|
||||
fromFieldToReadable = \case
|
||||
f@(Field (SQLText t) _) ->
|
||||
let s = T.unpack t
|
||||
in case readMaybe s of
|
||||
let str = T.unpack t
|
||||
in case readMaybe str of
|
||||
Just x -> Ok x
|
||||
_ -> returnError ConversionFailed f ("invalid string: " ++ s)
|
||||
_ -> returnError ConversionFailed f ("invalid string: " <> str)
|
||||
f -> returnError ConversionFailed f "expecting SQLText column type"
|
||||
|
||||
withLock :: MonadUnliftIO m => SQLiteStore -> (SQLiteStore -> TMVar ()) -> (DB.Connection -> m a) -> m a
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{-# LANGUAGE InstanceSigs #-}
|
||||
{-# LANGUAGE RankNTypes #-}
|
||||
{-# OPTIONS_GHC -fno-warn-orphans #-}
|
||||
|
||||
module Simplex.Messaging.Util where
|
||||
|
||||
|
||||
Reference in New Issue
Block a user