From b6a4f5f51865381b5485c9e75ff301f8da1716c4 Mon Sep 17 00:00:00 2001 From: spaced4ndy <8711996+spaced4ndy@users.noreply.github.com> Date: Wed, 17 May 2023 16:13:35 +0400 Subject: [PATCH] core: enable creation of decryption errors chat items (#2450) --- cabal.project | 2 +- scripts/nix/sha256map.nix | 2 +- src/Simplex/Chat.hs | 24 ++++++++++-------------- stack.yaml | 2 +- tests/ChatTests/Direct.hs | 2 +- tests/ChatTests/Groups.hs | 2 +- 6 files changed, 15 insertions(+), 19 deletions(-) diff --git a/cabal.project b/cabal.project index f587eb6b7..c31558d2c 100644 --- a/cabal.project +++ b/cabal.project @@ -7,7 +7,7 @@ constraints: zip +disable-bzip2 +disable-zstd source-repository-package type: git location: https://github.com/simplex-chat/simplexmq.git - tag: d693868bc0ce0926f5b890dfced56960c8bcf2ab + tag: 6c6f22051d693e00aaa4c4e6c5b6bff7e9a40b36 source-repository-package type: git diff --git a/scripts/nix/sha256map.nix b/scripts/nix/sha256map.nix index 54821c669..c516be2b0 100644 --- a/scripts/nix/sha256map.nix +++ b/scripts/nix/sha256map.nix @@ -1,5 +1,5 @@ { - "https://github.com/simplex-chat/simplexmq.git"."d693868bc0ce0926f5b890dfced56960c8bcf2ab" = "1g9p7b7da90ac3zrr0hwk6bjn3x3zrl0yq314f5w4a54zlg785zx"; + "https://github.com/simplex-chat/simplexmq.git"."6c6f22051d693e00aaa4c4e6c5b6bff7e9a40b36" = "0mi4p2s5klm2w6za8xljl3yaiva814phhm5n5q36f04a016i6llm"; "https://github.com/simplex-chat/hs-socks.git"."a30cc7a79a08d8108316094f8f2f82a0c5e1ac51" = "0yasvnr7g91k76mjkamvzab2kvlb1g5pspjyjn2fr6v83swjhj38"; "https://github.com/kazu-yamamoto/http2.git"."b5a1b7200cf5bc7044af34ba325284271f6dff25" = "0dqb50j57an64nf4qcf5vcz4xkd1vzvghvf8bk529c1k30r9nfzb"; "https://github.com/simplex-chat/direct-sqlcipher.git"."34309410eb2069b029b8fc1872deb1e0db123294" = "0kwkmhyfsn2lixdlgl15smgr1h5gjk7fky6abzh8rng2h5ymnffd"; diff --git a/src/Simplex/Chat.hs b/src/Simplex/Chat.hs index db2dcbf04..817236bbf 100644 --- a/src/Simplex/Chat.hs +++ b/src/Simplex/Chat.hs @@ -2993,21 +2993,17 @@ processAgentMessageConn user@User {userId} corrId agentConnId agentMessage = do -- TODO add debugging output _ -> pure () - -- TODO revert to commented function to enable creation of decryption errors chat items agentMsgDecryptError :: AgentErrorType -> Maybe (MsgDecryptError, Word32) - agentMsgDecryptError _ = Nothing - - -- agentMsgDecryptError :: AgentErrorType -> Maybe (MsgDecryptError, Word32) - -- agentMsgDecryptError = \case - -- AGENT (A_CRYPTO RATCHET_HEADER) -> Just (MDERatchetHeader, 1) - -- AGENT (A_CRYPTO (RATCHET_SKIPPED n)) -> Just (MDETooManySkipped, n) - -- -- we are not treating this as decryption error, as in many cases it happens as the result of duplicate or redundant delivery, - -- -- and we don't have a way to differentiate. - -- -- we could store the hashes of past messages in the agent, or delaying message deletion after ACK - -- -- A_DUPLICATE -> Nothing - -- -- earlier messages may be received in case of redundant delivery, and do not necessarily indicate an error - -- -- AGENT (A_CRYPTO (RATCHET_EARLIER n)) -> Nothing - -- _ -> Nothing + agentMsgDecryptError = \case + AGENT (A_CRYPTO RATCHET_HEADER) -> Just (MDERatchetHeader, 1) + AGENT (A_CRYPTO (RATCHET_SKIPPED n)) -> Just (MDETooManySkipped, n) + -- we are not treating this as decryption error, as in many cases it happens as the result of duplicate or redundant delivery, + -- and we don't have a way to differentiate. + -- we could store the hashes of past messages in the agent, or delaying message deletion after ACK + -- A_DUPLICATE -> Nothing + -- earlier messages may be received in case of redundant delivery, and do not necessarily indicate an error + -- AGENT (A_CRYPTO (RATCHET_EARLIER n)) -> Nothing + _ -> Nothing mdeUpdatedCI :: (MsgDecryptError, Word32) -> CChatItem c -> Maybe (ChatItem c 'MDRcv, CIContent 'MDRcv) mdeUpdatedCI (mde', n') (CChatItem _ ci@ChatItem {content = CIRcvDecryptionError mde n}) diff --git a/stack.yaml b/stack.yaml index 4e3b3c81e..16b4b7ca6 100644 --- a/stack.yaml +++ b/stack.yaml @@ -49,7 +49,7 @@ extra-deps: # - simplexmq-1.0.0@sha256:34b2004728ae396e3ae449cd090ba7410781e2b3cefc59259915f4ca5daa9ea8,8561 # - ../simplexmq - github: simplex-chat/simplexmq - commit: d693868bc0ce0926f5b890dfced56960c8bcf2ab + commit: 6c6f22051d693e00aaa4c4e6c5b6bff7e9a40b36 - github: kazu-yamamoto/http2 commit: b5a1b7200cf5bc7044af34ba325284271f6dff25 # - ../direct-sqlcipher diff --git a/tests/ChatTests/Direct.hs b/tests/ChatTests/Direct.hs index 199001281..72ef1ad07 100644 --- a/tests/ChatTests/Direct.hs +++ b/tests/ChatTests/Direct.hs @@ -84,7 +84,7 @@ chatDirectTests = do it "mark contact verified" testMarkContactVerified it "mark group member verified" testMarkGroupMemberVerified describe "message errors" $ do - xit "show message decryption error and update count" testMsgDecryptError + it "show message decryption error and update count" testMsgDecryptError describe "message reactions" $ do it "set message reactions" testSetMessageReactions diff --git a/tests/ChatTests/Groups.hs b/tests/ChatTests/Groups.hs index 3319ef848..978a7d9fc 100644 --- a/tests/ChatTests/Groups.hs +++ b/tests/ChatTests/Groups.hs @@ -53,7 +53,7 @@ chatGroupTests = do it "group link member role" testGroupLinkMemberRole it "leaving and deleting the group joined via link should NOT delete previously existing direct contacts" testGroupLinkLeaveDelete describe "group message errors" $ do - xit "show message decryption error and update count" testGroupMsgDecryptError + it "show message decryption error and update count" testGroupMsgDecryptError describe "message reactions" $ do it "set group message reactions" testSetGroupMessageReactions