ios: contacts UI improvements

This commit is contained in:
spaced4ndy
2024-05-20 10:22:03 +04:00
parent 8f8601eaa4
commit 995863d78b
95 changed files with 1716 additions and 626 deletions
+6 -1
View File
@@ -37,6 +37,7 @@ import Simplex.Chat.Types
import Simplex.FileTransfer.Description (kb, mb)
import Simplex.FileTransfer.Server (runXFTPServerBlocking)
import Simplex.FileTransfer.Server.Env (XFTPServerConfig (..), defaultFileExpiration)
import Simplex.FileTransfer.Transport (supportedFileServerVRange)
import Simplex.Messaging.Agent (disposeAgentClient)
import Simplex.Messaging.Agent.Env.SQLite
import Simplex.Messaging.Agent.Protocol (currentSMPAgentVersion, duplexHandshakeSMPAgentVersion, pqdrSMPAgentVersion, supportedSMPAgentVRange)
@@ -44,6 +45,7 @@ import Simplex.Messaging.Agent.RetryInterval
import Simplex.Messaging.Agent.Store.SQLite (MigrationConfirmation (..), closeSQLiteStore)
import qualified Simplex.Messaging.Agent.Store.SQLite.DB as DB
import Simplex.Messaging.Client (ProtocolClientConfig (..), defaultNetworkConfig)
import Simplex.Messaging.Client.Agent (defaultSMPClientAgentConfig)
import Simplex.Messaging.Crypto.Ratchet (supportedE2EEncryptVRange)
import qualified Simplex.Messaging.Crypto.Ratchet as CR
import Simplex.Messaging.Server (runSMPServerBlocking)
@@ -427,7 +429,9 @@ serverCfg =
smpServerVRange = supportedServerSMPRelayVRange,
transportConfig = defaultTransportServerConfig,
smpHandshakeTimeout = 1000000,
controlPort = Nothing
controlPort = Nothing,
smpAgentCfg = defaultSMPClientAgentConfig,
allowSMPProxy = False
}
withSmpServer :: IO () -> IO ()
@@ -458,6 +462,7 @@ xftpServerConfig =
caCertificateFile = "tests/fixtures/tls/ca.crt",
privateKeyFile = "tests/fixtures/tls/server.key",
certificateFile = "tests/fixtures/tls/server.crt",
xftpServerVRange = supportedFileServerVRange,
logStatsInterval = Nothing,
logStatsStartTime = 0,
serverStatsLogFile = "tests/tmp/xftp-server-stats.daily.log",
+15 -3
View File
@@ -298,6 +298,7 @@ testPlanInvitationLinkOwn tmp =
alice ##> ("/_connect plan 1 " <> inv)
alice <## "invitation link: ok to connect" -- conn_req_inv is forgotten after connection
threadDelay 100000
alice @@@ [("@alice_1", lastChatFeature), ("@alice_2", lastChatFeature)]
alice `send` "@alice_2 hi"
alice
@@ -346,7 +347,7 @@ testDeleteContactDeletesProfile =
connectUsers alice bob
alice <##> bob
-- alice deletes contact, profile is deleted
alice ##> "/_delete @2 {\"type\": \"full\", \"notify\": true}"
alice ##> "/_delete @2 full notify=on"
alice <## "bob: contact is deleted"
bob <## "alice (Alice) deleted contact with you"
alice ##> "/_contacts 1"
@@ -366,7 +367,7 @@ testDeleteContactKeepConversation =
connectUsers alice bob
alice <##> bob
alice ##> "/_delete @2 {\"type\": \"entity\", \"notify\": true}"
alice ##> "/_delete @2 entity notify=on"
alice <## "bob: contact is deleted"
bob <## "alice (Alice) deleted contact with you"
@@ -386,7 +387,7 @@ testDeleteConversationKeepContact =
alice @@@ [("@bob", "hey")]
alice ##> "/_delete @2 {\"type\": \"messages\", \"notify\": true}"
alice ##> "/_delete @2 messages"
alice <## "bob: contact is deleted"
alice @@@ [("@bob", "")] -- UI would filter
@@ -1068,20 +1069,25 @@ testNegotiateCall =
-- alice confirms call by sending WebRTC answer
alice ##> ("/_call answer @2 " <> serialize testWebRTCSession)
alice <## "ok"
threadDelay 100000
alice #$> ("/_get chat @2 count=100", chat, chatFeatures <> [(1, "outgoing call: connecting...")])
bob <## "alice continued the WebRTC call"
repeatM_ 3 $ getTermLine bob
threadDelay 100000
bob #$> ("/_get chat @2 count=100", chat, chatFeatures <> [(0, "incoming call: connecting...")])
-- participants can update calls as connected
alice ##> "/_call status @2 connected"
alice <## "ok"
threadDelay 100000
alice #$> ("/_get chat @2 count=100", chat, chatFeatures <> [(1, "outgoing call: in progress (00:00)")])
bob ##> "/_call status @2 connected"
bob <## "ok"
threadDelay 100000
bob #$> ("/_get chat @2 count=100", chat, chatFeatures <> [(0, "incoming call: in progress (00:00)")])
-- either party can end the call
bob ##> "/_call end @2"
bob <## "ok"
threadDelay 100000
bob #$> ("/_get chat @2 count=100", chat, chatFeatures <> [(0, "incoming call: ended (00:00)")])
alice <## "call with bob ended"
alice #$> ("/_get chat @2 count=100", chat, chatFeatures <> [(1, "outgoing call: ended (00:00)")])
@@ -2290,6 +2296,7 @@ testSwitchContact =
alice <## "bob: you started changing address"
bob <## "alice changed address for you"
alice <## "bob: you changed address"
threadDelay 100000
alice #$> ("/_get chat @2 count=100", chat, chatFeatures <> [(1, "started changing address..."), (1, "you changed address")])
bob #$> ("/_get chat @2 count=100", chat, chatFeatures <> [(0, "started changing address for you..."), (0, "changed address for you")])
alice <##> bob
@@ -2317,6 +2324,7 @@ testAbortSwitchContact tmp = do
bob <## "alice started changing address for you"
bob <## "alice changed address for you"
alice <## "bob: you changed address"
threadDelay 100000
alice #$> ("/_get chat @2 count=100", chat, chatFeatures <> [(1, "started changing address..."), (1, "started changing address..."), (1, "you changed address")])
bob #$> ("/_get chat @2 count=100", chat, chatFeatures <> [(0, "started changing address for you..."), (0, "started changing address for you..."), (0, "changed address for you")])
alice <##> bob
@@ -2331,6 +2339,7 @@ testSwitchGroupMember =
alice <## "#team: you started changing address for bob"
bob <## "#team: alice changed address for you"
alice <## "#team: you changed address for bob"
threadDelay 100000
alice #$> ("/_get chat #1 count=100", chat, [(1, e2eeInfoNoPQStr), (0, "connected"), (1, "started changing address for bob..."), (1, "you changed address for bob")])
bob #$> ("/_get chat #1 count=100", chat, groupFeatures <> [(0, "connected"), (0, "started changing address for you..."), (0, "changed address for you")])
alice #> "#team hey"
@@ -2362,6 +2371,7 @@ testAbortSwitchGroupMember tmp = do
bob <## "#team: alice started changing address for you"
bob <## "#team: alice changed address for you"
alice <## "#team: you changed address for bob"
threadDelay 100000
alice #$> ("/_get chat #1 count=100", chat, [(1, e2eeInfoNoPQStr), (0, "connected"), (1, "started changing address for bob..."), (1, "started changing address for bob..."), (1, "you changed address for bob")])
bob #$> ("/_get chat #1 count=100", chat, groupFeatures <> [(0, "connected"), (0, "started changing address for you..."), (0, "started changing address for you..."), (0, "changed address for you")])
alice #> "#team hey"
@@ -2511,6 +2521,7 @@ testSyncRatchet tmp =
alice <## "bob: connection synchronized"
bob <## "alice: connection synchronized"
threadDelay 100000
bob #$> ("/_get chat @2 count=3", chat, [(1, "connection synchronization started"), (0, "connection synchronization agreed"), (0, "connection synchronized")])
alice #$> ("/_get chat @2 count=2", chat, [(0, "connection synchronization agreed"), (0, "connection synchronized")])
@@ -2550,6 +2561,7 @@ testSyncRatchetCodeReset tmp =
alice <## "bob: connection synchronized"
bob <## "alice: connection synchronized"
threadDelay 100000
bob #$> ("/_get chat @2 count=4", chat, [(1, "connection synchronization started"), (0, "connection synchronization agreed"), (0, "security code changed"), (0, "connection synchronized")])
alice #$> ("/_get chat @2 count=2", chat, [(0, "connection synchronization agreed"), (0, "connection synchronized")])
+19 -8
View File
@@ -69,7 +69,7 @@ chatGroupTests = do
it "group is known if host contact was deleted" testPlanHostContactDeletedGroupLinkKnown
it "own group link" testPlanGroupLinkOwn
it "connecting via group link" testPlanGroupLinkConnecting
xit "re-join existing group after leaving" testPlanGroupLinkLeaveRejoin
it "re-join existing group after leaving" testPlanGroupLinkLeaveRejoin
describe "group links without contact" $ do
it "join via group link without creating contact" testGroupLinkNoContact
it "invitees were previously connected as contacts" testGroupLinkNoContactInviteesWereConnected
@@ -2578,13 +2578,15 @@ testPlanGroupLinkOwn tmp =
testPlanGroupLinkConnecting :: HasCallStack => FilePath -> IO ()
testPlanGroupLinkConnecting tmp = do
gLink <- withNewTestChatCfg tmp cfg "alice" aliceProfile $ \alice -> do
-- gLink <- withNewTestChatCfg tmp cfg "alice" aliceProfile $ \alice -> do
gLink <- withNewTestChatCfg tmp cfg "alice" aliceProfile $ \a -> withTestOutput a $ \alice -> do
alice ##> "/g team"
alice <## "group #team is created"
alice <## "to add members use /a team <name> or /create link #team"
alice ##> "/create link #team"
getGroupLink alice "team" GRMember True
withNewTestChatCfg tmp cfg "bob" bobProfile $ \bob -> do
-- withNewTestChatCfg tmp cfg "bob" bobProfile $ \bob -> do
withNewTestChatCfg tmp cfg "bob" bobProfile $ \b -> withTestOutput b $ \bob -> do
threadDelay 100000
bob ##> ("/c " <> gLink)
@@ -2598,13 +2600,15 @@ testPlanGroupLinkConnecting tmp = do
bob <## "group link: connecting, allowed to reconnect"
threadDelay 100000
withTestChatCfg tmp cfg "alice" $ \alice -> do
-- withTestChatCfg tmp cfg "alice" $ \alice -> do
withTestChatCfg tmp cfg "alice" $ \a -> withTestOutput a $ \alice -> do
alice
<### [ "1 group links active",
"#team: group is empty",
"bob (Bob): accepting request to join group #team..."
]
withTestChatCfg tmp cfg "bob" $ \bob -> do
-- withTestChatCfg tmp cfg "bob" $ \bob -> do
withTestChatCfg tmp cfg "bob" $ \b -> withTestOutput b $ \bob -> do
threadDelay 500000
bob ##> ("/_connect plan 1 " <> gLink)
bob <## "group link: connecting"
@@ -2621,9 +2625,8 @@ testPlanGroupLinkConnecting tmp = do
testPlanGroupLinkLeaveRejoin :: HasCallStack => FilePath -> IO ()
testPlanGroupLinkLeaveRejoin =
testChatCfg2 testCfgGroupLinkViaContact aliceProfile bobProfile $
\a b -> do
let alice = a {printOutput = True}
bob = b {printOutput = True}
-- \alice bob -> do
\a b -> withTestOutput a $ \alice -> withTestOutput b $ \bob -> do
alice ##> "/g team"
alice <## "group #team is created"
alice <## "to add members use /a team <name> or /create link #team"
@@ -2643,6 +2646,8 @@ testPlanGroupLinkLeaveRejoin =
bob <## "#team: you joined the group"
]
threadDelay 100000
bob ##> ("/_connect plan 1 " <> gLink)
bob <## "group link: known group #team"
bob <## "use #team <message> to send messages"
@@ -2651,6 +2656,8 @@ testPlanGroupLinkLeaveRejoin =
bob <## "group link: known group #team"
bob <## "use #team <message> to send messages"
threadDelay 100000
bob ##> "/leave #team"
concurrentlyN_
[ do
@@ -2659,6 +2666,8 @@ testPlanGroupLinkLeaveRejoin =
alice <## "#team: bob left the group"
]
threadDelay 100000
bob ##> ("/_connect plan 1 " <> gLink)
bob <## "group link: ok to connect"
@@ -3296,6 +3305,7 @@ testGroupSyncRatchet tmp =
alice <## "#team bob: connection synchronized"
bob <## "#team alice: connection synchronized"
threadDelay 100000
bob #$> ("/_get chat #1 count=3", chat, [(1, "connection synchronization started for alice"), (0, "connection synchronization agreed"), (0, "connection synchronized")])
alice #$> ("/_get chat #1 count=2", chat, [(0, "connection synchronization agreed"), (0, "connection synchronized")])
@@ -3336,6 +3346,7 @@ testGroupSyncRatchetCodeReset tmp =
alice <## "#team bob: connection synchronized"
bob <## "#team alice: connection synchronized"
threadDelay 100000
bob #$> ("/_get chat #1 count=4", chat, [(1, "connection synchronization started for alice"), (0, "connection synchronization agreed"), (0, "security code changed"), (0, "connection synchronized")])
alice #$> ("/_get chat #1 count=2", chat, [(0, "connection synchronization agreed"), (0, "connection synchronized")])
+23 -11
View File
@@ -397,6 +397,7 @@ testDeduplicateContactRequests = testChat3 aliceProfile bobProfile cathProfile $
bob ##> ("/c " <> cLink)
bob <## "contact address: known contact alice"
bob <## "use @alice <message> to send messages"
threadDelay 100000
alice @@@ [("@bob", lastChatFeature)]
bob @@@ [("@alice", lastChatFeature), (":2", ""), (":1", "")]
bob ##> "/_delete :1"
@@ -470,6 +471,7 @@ testDeduplicateContactRequestsProfileChange = testChat3 aliceProfile bobProfile
bob ##> ("/c " <> cLink)
bob <## "contact address: known contact alice"
bob <## "use @alice <message> to send messages"
threadDelay 100000
alice @@@ [("@robert", lastChatFeature)]
bob @@@ [("@alice", lastChatFeature), (":3", ""), (":2", ""), (":1", "")]
bob ##> "/_delete :1"
@@ -488,6 +490,7 @@ testDeduplicateContactRequestsProfileChange = testChat3 aliceProfile bobProfile
bob <## "use @alice <message> to send messages"
alice <##> bob
threadDelay 100000
alice #$> ("/_get chat @2 count=100", chat, chatFeatures <> [(1, "hi"), (0, "hey"), (1, "hi"), (0, "hey")])
bob #$> ("/_get chat @2 count=100", chat, chatFeatures <> [(0, "hi"), (1, "hey"), (0, "hi"), (1, "hey")])
@@ -655,6 +658,7 @@ testPlanAddressOwn tmp =
"alice_2 (Alice): contact is connected"
]
threadDelay 100000
alice @@@ [("@alice_1", lastChatFeature), ("@alice_2", lastChatFeature)]
alice `send` "@alice_2 hi"
alice
@@ -1948,21 +1952,29 @@ testGroupPrefsDirectForRole = testChat4 aliceProfile bobProfile cathProfile danP
bob <## "#team: cath added dan (Daniel) to the group (connecting...)"
bob <## "#team: new member dan is connected"
]
-- dan cannot send direct messages to alice (owner)
-- dan cannot send direct messages to alice
dan ##> "@alice hello alice"
dan <## "bad chat command: direct messages not allowed"
(alice </)
-- but alice can
-- alice (owner) can send direct messages to dan
alice `send` "@dan hello dan"
alice <## "member #team dan does not have direct connection, creating"
alice <## "contact for member #team dan is created"
alice <## "sent invitation to connect directly to member #team dan"
alice <# "@dan hello dan"
alice <## "dan (Daniel): contact is connected"
dan <## "#team alice is creating direct contact alice with you"
dan <# "alice> hello dan"
dan <## "alice (Alice): contact is connected"
-- and now dan can too
alice
<### [ "member #team dan does not have direct connection, creating",
"contact for member #team dan is created",
"sent invitation to connect directly to member #team dan",
WithTime "@dan hello dan"
]
dan
<### [ "#team alice is creating direct contact alice with you",
WithTime "alice> hello dan"
]
concurrently_
(alice <## "dan (Daniel): contact is connected")
(dan <## "alice (Alice): contact is connected")
-- now dan can send messages to alice
dan #> "@alice hi alice"
alice <# "dan> hi alice"
where
+1 -1
View File
@@ -298,7 +298,7 @@ itemId i = show $ length chatFeatures + i
(@@@) :: HasCallStack => TestCC -> [(String, String)] -> Expectation
(@@@) cc res = do
threadDelay 10000
threadDelay 100000
getChats mapChats cc res
mapChats :: [(String, String, Maybe ConnStatus)] -> [(String, String)]