fix sending messages in groups with members before version 18

This commit is contained in:
Evgeny @ SimpleX Chat
2026-08-04 07:12:51 +00:00
parent 9b83ef7e73
commit 01bb8d8e7a
2 changed files with 17 additions and 9 deletions
+4 -4
View File
@@ -2547,11 +2547,11 @@ sendGroupSignedMessages_ gInfo@GroupInfo {groupId} recipientMembers signedEvents
mIds' = S.insert mId mIds
prepareMsgReqs :: MsgFlags -> NonEmpty (Either ChatError SndMessage) -> ([(GroupMember, Connection)], [(GroupMember, Connection)]) -> ([GroupMemberId], [Either ChatError ChatMsgReq])
prepareMsgReqs msgFlags msgs (toSendBin, toSendJson) =
batchReqs BMBinary msgs toSendBin <> batchReqs BMJson msgs toSendJson
batchReqs 1 BMBinary toSendBin <> batchReqs 2 BMJson toSendJson
where
batchReqs _ [] [] = ([], [])
batchReqs mode msgs' toSend' = case L.nonEmpty (batchSndMessagesJSON mode msgs') of
Just batched -> foldMembers (length batched + length msgs') msgBatchMBR batched toSend'
batchReqs _ _ [] = ([], [])
batchReqs n mode toSend' = case L.nonEmpty (batchSndMessagesJSON mode msgs) of
Just batched -> foldMembers (n * (length batched + length msgs)) msgBatchMBR batched toSend'
Nothing -> ([], [])
foldMembers :: forall a. Int -> (Maybe Int -> Int -> a -> (ValueOrRef MsgBody, [MessageId])) -> NonEmpty (Either ChatError a) -> [(GroupMember, Connection)] -> ([GroupMemberId], [Either ChatError ChatMsgReq])
foldMembers lastRef mkMb mbs mems = snd $ foldr' foldMsgBodies (lastMemIdx_, ([], [])) mems
+13 -5
View File
@@ -108,7 +108,7 @@ chatGroupTests = do
it "send multiple messages (many chat batches)" testSendMultiManyBatches
it "shared message body is reused" testSharedMessageBody
it "shared batch body is reused" testSharedBatchBody
xit "shared batch body reference across binary and json members" testGroupSharedBatchBodyMixedModes
it "shared batch body reference across binary and json members" testGroupSharedBatchBodyMixedModes
describe "async group connections" $ do
xit "create and join group when clients go offline" testGroupAsync
describe "group links" $ do
@@ -2414,12 +2414,20 @@ testGroupSharedBatchBodyMixedModes ps =
cath #> "#team hi"
alice <# "#team kate> hi"
bob <# "#team kate> hi"
threadDelay 1000000
errs <- withCCTransaction cath $ \db ->
DB.query_ db "SELECT count(1) FROM group_snd_item_statuses WHERE group_snd_item_status LIKE 'snd_error%'" :: IO [[Int]]
errs `shouldBe` [[0]]
dan <# "#team kate> hi"
eve <# "#team kate> hi"
alice ##> "/_get chat #1 count=100"
ra <- chat <$> getTermLine alice
ra `shouldContain` [(0, "updated profile (signed)")]
bob ##> "/_get chat #1 count=100"
rb <- chat <$> getTermLine bob
rb `shouldContain` [(0, "updated profile (signed)")]
dan ##> "/_get chat #1 count=100"
rd <- chat <$> getTermLine dan
rd `shouldContain` [(0, "updated profile")]
eve ##> "/_get chat #1 count=100"
re <- chat <$> getTermLine eve
re `shouldContain` [(0, "updated profile")]
where
oldCfg = testCfg {chatVRange = mkVersionRange (VersionChat 9) (VersionChat 17)}