From 638fd3756a8fe2fef699a936bcf016b75f2febdf Mon Sep 17 00:00:00 2001 From: spaced4ndy <8711996+spaced4ndy@users.noreply.github.com> Date: Sat, 13 Apr 2024 14:52:39 +0400 Subject: [PATCH] core: correctly populate data for items forwarded from groups (#4025) --- src/Simplex/Chat/Store/Messages.hs | 6 +++--- tests/ChatTests/Forward.hs | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/Simplex/Chat/Store/Messages.hs b/src/Simplex/Chat/Store/Messages.hs index 2e4ee6e48f..2b31a215da 100644 --- a/src/Simplex/Chat/Store/Messages.hs +++ b/src/Simplex/Chat/Store/Messages.hs @@ -411,7 +411,7 @@ createNewChatItem_ db User {userId} chatDirection msgId_ sharedMsgId ciContent q Just CIFFContact {chatName, msgDir, contactId, chatItemId} -> (Just CIFFContact_, Just chatName, Just msgDir, contactId, Nothing, chatItemId) Just CIFFGroup {chatName, msgDir, groupId, chatItemId} -> - (Just CIFFContact_, Just chatName, Just msgDir, Nothing, groupId, chatItemId) + (Just CIFFGroup_, Just chatName, Just msgDir, Nothing, groupId, chatItemId) ciTimedRow :: Maybe CITimed -> (Maybe Int, Maybe UTCTime) ciTimedRow (Just CITimed {ttl, deleteAt}) = (Just ttl, deleteAt) @@ -1468,8 +1468,8 @@ toCIForwardedFrom :: ChatItemForwardedFromRow -> Maybe CIForwardedFrom toCIForwardedFrom (fwdFromTag, fwdFromChatName, fwdFromMsgDir, fwdFromContactId, fwdFromGroupId, fwdFromChatItemId) = case (fwdFromTag, fwdFromChatName, fwdFromMsgDir, fwdFromContactId, fwdFromGroupId, fwdFromChatItemId) of (Just CIFFUnknown_, Nothing, Nothing, Nothing, Nothing, Nothing) -> Just CIFFUnknown - (Just CIFFContact_, Just chatName, Just msgDir, contactId, Nothing, chatId) -> Just $ CIFFContact chatName msgDir contactId chatId - (Just CIFFGroup_, Just chatName, Just msgDir, Nothing, groupId, chatId) -> Just $ CIFFGroup chatName msgDir groupId chatId + (Just CIFFContact_, Just chatName, Just msgDir, contactId, Nothing, ciId) -> Just $ CIFFContact chatName msgDir contactId ciId + (Just CIFFGroup_, Just chatName, Just msgDir, Nothing, groupId, ciId) -> Just $ CIFFGroup chatName msgDir groupId ciId _ -> Nothing type GroupQuoteRow = QuoteRow :. MaybeGroupMemberRow diff --git a/tests/ChatTests/Forward.hs b/tests/ChatTests/Forward.hs index 4bd75d0e5b..8638076ab2 100644 --- a/tests/ChatTests/Forward.hs +++ b/tests/ChatTests/Forward.hs @@ -5,6 +5,7 @@ module ChatTests.Forward where import ChatClient import ChatTests.Utils +import Control.Concurrent (threadDelay) import qualified Data.ByteString.Char8 as B import System.Directory (copyFile, doesFileExist) import Test.Hspec hiding (it) @@ -158,18 +159,35 @@ testForwardGroupToGroup = bob #> "#team hey" alice <# "#team bob> hey" + threadDelay 1000000 + alice `send` "#club <- #team hi" alice <# "#club <- you #team" alice <## " hi" cath <# "#club alice> -> forwarded" cath <## " hi" + threadDelay 1000000 + alice `send` "#club <- #team hey" alice <# "#club <- #team" alice <## " hey" cath <# "#club alice> -> forwarded" cath <## " hey" + -- read chat + alice ##> "/tail #club 2" + alice <# "#club <- you #team" + alice <## " hi" + alice <# "#club <- #team" + alice <## " hey" + + cath ##> "/tail #club 2" + cath <# "#club alice> -> forwarded" + cath <## " hi" + cath <# "#club alice> -> forwarded" + cath <## " hey" + testForwardGroupToNotes :: HasCallStack => FilePath -> IO () testForwardGroupToNotes = testChat2 aliceProfile bobProfile $