From 89caf5572980b776bd750caa3c918ae4488612d8 Mon Sep 17 00:00:00 2001 From: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com> Date: Sat, 27 May 2023 19:28:14 +0200 Subject: [PATCH] agent: ack message in case of decryption error (#759) --- src/Simplex/Messaging/Agent.hs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Simplex/Messaging/Agent.hs b/src/Simplex/Messaging/Agent.hs index 326a6af0a..f6181bb92 100644 --- a/src/Simplex/Messaging/Agent.hs +++ b/src/Simplex/Messaging/Agent.hs @@ -1656,6 +1656,8 @@ cleanupManager c@AgentClient {subQ} = do notify :: forall e. AEntityI e => EntityId -> ACommand 'Agent e -> ExceptT AgentErrorType m () notify entId cmd = atomically $ writeTBQueue subQ ("", entId, APC (sAEntity @e) cmd) +-- | make sure to ACK or throw in each message processing branch +-- it cannot be finally, unfortunately, as sometimes it needs to be ACK+DEL processSMPTransmission :: forall m. AgentMonad m => AgentClient -> ServerTransmission BrokerMsg -> m () processSMPTransmission c@AgentClient {smpClients, subQ} (tSess@(_, srv, _), v, sessId, rId, cmd) = do (rq, SomeConn _ conn) <- withStore c (\db -> getRcvConn db srv rId) @@ -1733,8 +1735,8 @@ processSMPTransmission c@AgentClient {smpClients, subQ} (tSess@(_, srv, _), v, s logServer "<--" c srv rId "MSG " notify $ MSG msgMeta msgFlags body _ -> pure () - _ -> checkDuplicateHash e encryptedMsgHash - Left e -> checkDuplicateHash e encryptedMsgHash + _ -> checkDuplicateHash e encryptedMsgHash >> ack + Left e -> checkDuplicateHash e encryptedMsgHash >> ack where checkDuplicateHash :: AgentErrorType -> ByteString -> m () checkDuplicateHash e encryptedMsgHash =