From e452c6ebff074d114780d887ec0e67072b825c84 Mon Sep 17 00:00:00 2001 From: Efim Poberezkin <8711996+efim-poberezkin@users.noreply.github.com> Date: Wed, 5 Jan 2022 16:52:28 +0400 Subject: [PATCH] delete received messages after sending ACK to server (#256) --- src/Simplex/Messaging/Agent.hs | 2 +- src/Simplex/Messaging/Agent/Store.hs | 1 - src/Simplex/Messaging/Agent/Store/SQLite.hs | 12 ------------ 3 files changed, 1 insertion(+), 14 deletions(-) diff --git a/src/Simplex/Messaging/Agent.hs b/src/Simplex/Messaging/Agent.hs index e38c4c3ee..a75c14353 100644 --- a/src/Simplex/Messaging/Agent.hs +++ b/src/Simplex/Messaging/Agent.hs @@ -467,7 +467,7 @@ ackMessage' c connId msgId = do let mId = InternalId msgId withStore $ \st -> checkRcvMsg st connId mId sendAck c rq - withStore $ \st -> updateRcvMsgAck st connId mId + withStore $ \st -> deleteMsg st connId mId -- | Suspend SMP agent connection (OFF command) in Reader monad suspendConnection' :: AgentMonad m => AgentClient -> ConnId -> m () diff --git a/src/Simplex/Messaging/Agent/Store.hs b/src/Simplex/Messaging/Agent/Store.hs index d891c1e2e..ee99611d6 100644 --- a/src/Simplex/Messaging/Agent/Store.hs +++ b/src/Simplex/Messaging/Agent/Store.hs @@ -69,7 +69,6 @@ class Monad m => MonadAgentStore s m where getPendingMsgs :: s -> ConnId -> m [InternalId] getMsg :: s -> ConnId -> InternalId -> m Msg checkRcvMsg :: s -> ConnId -> InternalId -> m () - updateRcvMsgAck :: s -> ConnId -> InternalId -> m () deleteMsg :: s -> ConnId -> InternalId -> m () -- * Queue types diff --git a/src/Simplex/Messaging/Agent/Store/SQLite.hs b/src/Simplex/Messaging/Agent/Store/SQLite.hs index de978d8ea..537e1efe7 100644 --- a/src/Simplex/Messaging/Agent/Store/SQLite.hs +++ b/src/Simplex/Messaging/Agent/Store/SQLite.hs @@ -502,18 +502,6 @@ instance (MonadUnliftIO m, MonadError StoreError m) => MonadAgentStore SQLiteSto hasMsg :: [(ConnId, InternalId)] -> Either StoreError () hasMsg r = if null r then Left SEMsgNotFound else Right () - updateRcvMsgAck :: SQLiteStore -> ConnId -> InternalId -> m () - updateRcvMsgAck st connId msgId = - liftIO . withTransaction st $ \db -> do - DB.execute - db - [sql| - UPDATE rcv_messages - SET rcv_status = ?, ack_brocker_ts = datetime('now') - WHERE conn_alias = ? AND internal_id = ? - |] - (RcvMsgAcknowledged, connId, msgId) - deleteMsg :: SQLiteStore -> ConnId -> InternalId -> m () deleteMsg st connId msgId = liftIO . withTransaction st $ \db ->