core: remember new origin for received forwarded messages (#4032)

This commit is contained in:
spaced4ndy
2024-04-15 17:19:37 +04:00
committed by GitHub
parent d7f8bff957
commit 7ff4b05c90
2 changed files with 34 additions and 3 deletions
+5 -3
View File
@@ -930,10 +930,12 @@ processChatCommand' vr = \case
forwardMC ChatItem {content = CIRcvMsgContent fmc} = pure (fmc, MDRcv)
forwardMC _ = throwChatError CEInvalidForward
forwardCIFF :: ChatItem c d -> Maybe CIForwardedFrom -> Maybe CIForwardedFrom
forwardCIFF ChatItem {meta = CIMeta {itemForwarded = Just ciff}} _ = Just ciff
forwardCIFF _ ciff = ciff
forwardCIFF ChatItem {meta = CIMeta {itemForwarded}} ciff = case itemForwarded of
Nothing -> ciff
Just CIFFUnknown -> ciff
Just prevCIFF -> Just prevCIFF
forwardCryptoFile :: ChatItem c d -> CM (Maybe CryptoFile)
forwardCryptoFile ChatItem {file = Just CIFile {fileName, fileStatus, fileSource = Just fromCF@CryptoFile {filePath, cryptoArgs = fromArgs}}}
forwardCryptoFile ChatItem {file = Just CIFile {fileName, fileStatus, fileSource = Just fromCF@CryptoFile {filePath}}}
| ciFileLoaded fileStatus =
chatReadVar filesFolder >>= \case
Nothing ->
+29
View File
@@ -24,6 +24,7 @@ chatForwardTests = do
it "from notes to notes" testForwardNotesToNotes -- TODO forward between different folders when supported
describe "interactions with forwarded messages" $ do
it "preserve original forward info" testForwardPreserveInfo
it "received forwarded message is saved with new forward info" testForwardRcvMsgNewInfo
it "quoted message is not included" testForwardQuotedMsg
it "editing is prohibited" testForwardEditProhibited
it "delete for other" testForwardDeleteForOther
@@ -276,6 +277,34 @@ testForwardPreserveInfo =
dan <# "#team alice> -> forwarded"
dan <## " hey"
testForwardRcvMsgNewInfo :: HasCallStack => FilePath -> IO ()
testForwardRcvMsgNewInfo =
testChat4 aliceProfile bobProfile cathProfile danProfile $
\alice bob cath dan -> do
connectUsers bob dan
createCCNoteFolder alice
connectUsers alice bob
connectUsers alice cath
dan #> "@bob hey"
bob <# "dan> hey"
bob `send` "@alice <- @dan hey"
bob <# "@alice <- @dan"
bob <## " hey"
alice <# "bob> -> forwarded"
alice <## " hey"
alice `send` "* <- @bob hey"
alice <# "* <- @bob"
alice <## " hey"
alice `send` "@cath <- * hey"
alice <# "@cath <- @bob"
alice <## " hey"
cath <# "alice> -> forwarded"
cath <## " hey"
testForwardQuotedMsg :: HasCallStack => FilePath -> IO ()
testForwardQuotedMsg =
testChat3 aliceProfile bobProfile cathProfile $