core: api to differentiate contacts and conversations (#4111)

This commit is contained in:
spaced4ndy
2024-05-13 16:51:54 +04:00
committed by GitHub
parent 06d61ea73e
commit f40ba6f04d
15 changed files with 164 additions and 46 deletions
+40 -1
View File
@@ -37,6 +37,8 @@ chatDirectTests = do
describe "add contact and send/receive messages" testAddContact
it "clear chat with contact" testContactClear
it "deleting contact deletes profile" testDeleteContactDeletesProfile
it "delete contact keeping conversation" testDeleteContactKeepConversation
it "delete conversation keeping contact" testDeleteConversationKeepContact
it "unused contact is deleted silently" testDeleteUnusedContactSilent
it "direct message quoted replies" testDirectMessageQuotedReply
it "direct message update" testDirectMessageUpdate
@@ -344,7 +346,7 @@ testDeleteContactDeletesProfile =
connectUsers alice bob
alice <##> bob
-- alice deletes contact, profile is deleted
alice ##> "/d bob"
alice ##> "/_delete @2 {\"type\": \"full\", \"notify\": true}"
alice <## "bob: contact is deleted"
bob <## "alice (Alice) deleted contact with you"
alice ##> "/_contacts 1"
@@ -357,6 +359,43 @@ testDeleteContactDeletesProfile =
(bob </)
bob `hasContactProfiles` ["bob"]
testDeleteContactKeepConversation :: HasCallStack => FilePath -> IO ()
testDeleteContactKeepConversation =
testChat2 aliceProfile bobProfile $
\alice bob -> do
connectUsers alice bob
alice <##> bob
alice ##> "/_delete @2 {\"type\": \"entity\", \"notify\": true}"
alice <## "bob: contact is deleted"
bob <## "alice (Alice) deleted contact with you"
alice @@@ [("@bob", "hey")]
alice ##> "@bob hi"
alice <## "bob: not ready"
bob @@@ [("@alice", "contact deleted")]
bob ##> "@alice hey"
bob <## "alice: not ready"
testDeleteConversationKeepContact :: HasCallStack => FilePath -> IO ()
testDeleteConversationKeepContact =
testChat2 aliceProfile bobProfile $
\alice bob -> do
connectUsers alice bob
alice <##> bob
alice @@@ [("@bob", "hey")]
alice ##> "/_delete @2 {\"type\": \"messages\", \"notify\": true}"
alice <## "bob: contact is deleted"
alice @@@ [("@bob", "")] -- UI would filter
bob @@@ [("@alice", "hey")]
bob #> "@alice hi"
alice <# "bob> hi"
alice @@@ [("@bob", "hi")]
alice <##> bob
testDeleteUnusedContactSilent :: HasCallStack => FilePath -> IO ()
testDeleteUnusedContactSilent =
testChatCfg3 testCfgCreateGroupDirect aliceProfile bobProfile cathProfile $