delete received messages after sending ACK to server (#256)

This commit is contained in:
Efim Poberezkin
2022-01-05 16:52:28 +04:00
committed by GitHub
parent 19edf09ae2
commit e452c6ebff
3 changed files with 1 additions and 14 deletions
+1 -1
View File
@@ -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 ()
-1
View File
@@ -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
@@ -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 ->