Merge branch 'master' into ep/address-dr

This commit is contained in:
Evgeny Poberezkin committed 2026-07-24 10:56:52 +01:00
commit 8433d70f7c
60 files changed
+1350 -260

No files matched your search

+3
View File
@@ -1760,6 +1760,7 @@ withDirectoryServiceCfgOwnersGroup ps cfg createOwnersGroup webFolder test = do
withNewTestChatCfg ps cfg serviceDbPrefix directoryProfile $ \ds ->
withNewTestChatCfg ps cfg "super_user" aliceProfile $ \superUser -> do
connectUsers ds superUser
enableNamesRole ds
when createOwnersGroup $ do
superUser ##> "/g owners"
superUser <## "group #owners is created"
@@ -2131,6 +2132,7 @@ testDirectoryChannelName ps = withSmpServerAndNames $ \reg ->
withDirectoryServiceCfg ps testCfg $ \superUser dsLink ->
withNewTestChatCfg ps testCfg "bob" bobProfile $ \bob ->
withRelay ps $ \relay -> do
enableNamesRole bob
bob `connectVia` dsLink
(shortLink, _fullLink) <- prepareChannel1Relay "news" bob relay
registerName reg newsName (channelNameRecord "news" (T.pack shortLink))
@@ -2171,6 +2173,7 @@ testDirectoryChannelNameNotVerified ps = withSmpServerAndNames $ \reg ->
withDirectoryServiceCfg ps testCfg $ \superUser dsLink ->
withNewTestChatCfg ps testCfg "bob" bobProfile $ \bob ->
withRelay ps $ \relay -> do
enableNamesRole bob
bob `connectVia` dsLink
(shortLink, _fullLink) <- prepareChannel1Relay "news" bob relay
registerName reg newsName (channelNameRecord "news" (T.pack shortLink))
+24 -24
View File
@@ -1920,14 +1920,14 @@ testMultipleUserAddresses =
cLinkAlisa <- getContactLink alice True
bob ##> ("/c " <> cLinkAlisa)
alice <#? bob
alice #$> ("/_get chats 2 pcc=on", chats, [("@bob", "Audio/video calls: enabled"), ("@Ask SimpleX Team", ""), ("@SimpleX Status", ""), ("*", "")])
alice #$> ("/_get chats 2 pcc=on", chats, [("@bob", "Audio/video calls: enabled"), ("@Ask SimpleX Team", ""), ("*", "")])
alice ##> "/ac bob"
alice <## "bob (Bob): accepting contact request, you can send messages to contact"
concurrently_
(bob <## "alisa: contact is connected")
(alice <## "bob (Bob): contact is connected")
threadDelay 100000
alice #$> ("/_get chats 2 pcc=on", chats, [("@bob", lastChatFeature), ("@Ask SimpleX Team", ""), ("@SimpleX Status", ""), ("*", "")])
alice #$> ("/_get chats 2 pcc=on", chats, [("@bob", lastChatFeature), ("@Ask SimpleX Team", ""), ("*", "")])
alice <##> bob
bob #> "@alice hey alice"
@@ -1958,7 +1958,7 @@ testMultipleUserAddresses =
(cath <## "alisa: contact is connected")
(alice <## "cath (Catherine): contact is connected")
threadDelay 100000
alice #$> ("/_get chats 2 pcc=on", chats, [("@cath", lastChatFeature), ("@bob", "hey"), ("@Ask SimpleX Team", ""), ("@SimpleX Status", ""), ("*", "")])
alice #$> ("/_get chats 2 pcc=on", chats, [("@cath", lastChatFeature), ("@bob", "hey"), ("@Ask SimpleX Team", ""), ("*", "")])
alice <##> cath
-- first user doesn't have cath as contact
@@ -2171,7 +2171,7 @@ testUsersDifferentCIExpirationTTL ps = do
bob #> "@alisa alisa 4"
alice <# "bob> alisa 4"
alice #$> ("/_get chat @6 count=100", chat, chatFeatures <> [(1, "alisa 1"), (0, "alisa 2"), (1, "alisa 3"), (0, "alisa 4")])
alice #$> ("/_get chat @5 count=100", chat, chatFeatures <> [(1, "alisa 1"), (0, "alisa 2"), (1, "alisa 3"), (0, "alisa 4")])
threadDelay 3000000
@@ -2184,11 +2184,11 @@ testUsersDifferentCIExpirationTTL ps = do
-- second user messages
alice ##> "/user alisa"
showActiveUser alice "alisa"
alice #$> ("/_get chat @6 count=100", chat, chatFeatures <> [(1, "alisa 1"), (0, "alisa 2"), (1, "alisa 3"), (0, "alisa 4")])
alice #$> ("/_get chat @5 count=100", chat, chatFeatures <> [(1, "alisa 1"), (0, "alisa 2"), (1, "alisa 3"), (0, "alisa 4")])
threadDelay 2100000
alice #$> ("/_get chat @6 count=100", chat, [(1,"chat banner")])
alice #$> ("/_get chat @5 count=100", chat, [(1,"chat banner")])
where
cfg = testCfg {initialCleanupManagerDelay = 0, cleanupManagerStepDelay = 0, ciExpirationInterval = 500000}
@@ -2254,7 +2254,7 @@ testUsersRestartCIExpiration ps = do
bob #> "@alisa alisa 4"
alice <# "bob> alisa 4"
alice #$> ("/_get chat @6 count=100", chat, chatFeatures <> [(1, "alisa 1"), (0, "alisa 2"), (1, "alisa 3"), (0, "alisa 4")])
alice #$> ("/_get chat @5 count=100", chat, chatFeatures <> [(1, "alisa 1"), (0, "alisa 2"), (1, "alisa 3"), (0, "alisa 4")])
threadDelay 3000000
@@ -2267,11 +2267,11 @@ testUsersRestartCIExpiration ps = do
-- second user messages
alice ##> "/user alisa"
showActiveUser alice "alisa"
alice #$> ("/_get chat @6 count=100", chat, chatFeatures <> [(1, "alisa 1"), (0, "alisa 2"), (1, "alisa 3"), (0, "alisa 4")])
alice #$> ("/_get chat @5 count=100", chat, chatFeatures <> [(1, "alisa 1"), (0, "alisa 2"), (1, "alisa 3"), (0, "alisa 4")])
threadDelay 4000000
alice #$> ("/_get chat @6 count=100", chat, [(1,"chat banner")])
alice #$> ("/_get chat @5 count=100", chat, [(1,"chat banner")])
where
cfg = testCfg {initialCleanupManagerDelay = 0, cleanupManagerStepDelay = 0, ciExpirationInterval = 500000}
@@ -2313,7 +2313,7 @@ testEnableCIExpirationOnlyForOneUser ps = do
bob #> "@alisa alisa 4"
alice <# "bob> alisa 4"
alice #$> ("/_get chat @6 count=100", chat, chatFeatures <> [(1, "alisa 1"), (0, "alisa 2"), (1, "alisa 3"), (0, "alisa 4")])
alice #$> ("/_get chat @5 count=100", chat, chatFeatures <> [(1, "alisa 1"), (0, "alisa 2"), (1, "alisa 3"), (0, "alisa 4")])
threadDelay 2000000
@@ -2325,14 +2325,14 @@ testEnableCIExpirationOnlyForOneUser ps = do
-- messages are not deleted for second user
alice ##> "/user alisa"
showActiveUser alice "alisa"
alice #$> ("/_get chat @6 count=100", chat, chatFeatures <> [(1, "alisa 1"), (0, "alisa 2"), (1, "alisa 3"), (0, "alisa 4")])
alice #$> ("/_get chat @5 count=100", chat, chatFeatures <> [(1, "alisa 1"), (0, "alisa 2"), (1, "alisa 3"), (0, "alisa 4")])
withTestChatCfg ps cfg "alice" $ \alice -> do
alice <## "subscribed 1 connections on server localhost"
alice <## "subscribed 1 connections on server localhost"
-- messages are not deleted for second user after restart
alice #$> ("/_get chat @6 count=100", chat, chatFeatures <> [(1, "alisa 1"), (0, "alisa 2"), (1, "alisa 3"), (0, "alisa 4")])
alice #$> ("/_get chat @5 count=100", chat, chatFeatures <> [(1, "alisa 1"), (0, "alisa 2"), (1, "alisa 3"), (0, "alisa 4")])
alice #> "@bob alisa 5"
bob <# "alisa> alisa 5"
@@ -2342,7 +2342,7 @@ testEnableCIExpirationOnlyForOneUser ps = do
threadDelay 2000000
-- new messages are not deleted for second user
alice #$> ("/_get chat @6 count=100", chat, chatFeatures <> [(1, "alisa 1"), (0, "alisa 2"), (1, "alisa 3"), (0, "alisa 4"), (1, "alisa 5"), (0, "alisa 6")])
alice #$> ("/_get chat @5 count=100", chat, chatFeatures <> [(1, "alisa 1"), (0, "alisa 2"), (1, "alisa 3"), (0, "alisa 4"), (1, "alisa 5"), (0, "alisa 6")])
where
cfg = testCfg {initialCleanupManagerDelay = 0, cleanupManagerStepDelay = 0, ciExpirationInterval = 500000}
@@ -2376,12 +2376,12 @@ testDisableCIExpirationOnlyForOneUser ps = do
bob #> "@alisa alisa 2"
alice <# "bob> alisa 2"
alice #$> ("/_get chat @6 count=100", chat, chatFeatures <> [(1, "alisa 1"), (0, "alisa 2")])
alice #$> ("/_get chat @5 count=100", chat, chatFeatures <> [(1, "alisa 1"), (0, "alisa 2")])
threadDelay 2000000
-- second user messages are deleted
alice #$> ("/_get chat @6 count=100", chat, [(1,"chat banner")])
alice #$> ("/_get chat @5 count=100", chat, [(1,"chat banner")])
withTestChatCfg ps cfg "alice" $ \alice -> do
alice <## "subscribed 1 connections on server localhost"
@@ -2395,12 +2395,12 @@ testDisableCIExpirationOnlyForOneUser ps = do
bob #> "@alisa alisa 4"
alice <# "bob> alisa 4"
alice #$> ("/_get chat @6 count=100", chat, [(1,"chat banner"), (1, "alisa 3"), (0, "alisa 4")])
alice #$> ("/_get chat @5 count=100", chat, [(1,"chat banner"), (1, "alisa 3"), (0, "alisa 4")])
threadDelay 3000000
-- second user messages are deleted
alice #$> ("/_get chat @6 count=100", chat, [(1,"chat banner")])
alice #$> ("/_get chat @5 count=100", chat, [(1,"chat banner")])
where
cfg = testCfg {initialCleanupManagerDelay = 0, cleanupManagerStepDelay = 0, ciExpirationInterval = 500000}
@@ -2415,7 +2415,7 @@ testUsersTimedMessages ps' = do
alice ##> "/create user alisa"
showActiveUser alice "alisa"
connectUsers alice bob
configureTimedMessages alice bob "6" "3"
configureTimedMessages alice bob "5" "3"
-- first user messages
alice ##> "/user alice"
@@ -2444,7 +2444,7 @@ testUsersTimedMessages ps' = do
alice ##> "/user alisa"
showActiveUser alice "alisa"
alice #$> ("/_get chat @6 count=100", chat, [(1,"chat banner"), (1, "alisa 1"), (0, "alisa 2")])
alice #$> ("/_get chat @5 count=100", chat, [(1,"chat banner"), (1, "alisa 1"), (0, "alisa 2")])
threadDelay 1000000
@@ -2457,7 +2457,7 @@ testUsersTimedMessages ps' = do
alice ##> "/user alisa"
showActiveUser alice "alisa"
alice #$> ("/_get chat @6 count=100", chat, [(1,"chat banner"), (1, "alisa 1"), (0, "alisa 2")])
alice #$> ("/_get chat @5 count=100", chat, [(1,"chat banner"), (1, "alisa 1"), (0, "alisa 2")])
threadDelay 1000000
@@ -2466,7 +2466,7 @@ testUsersTimedMessages ps' = do
alice ##> "/user"
showActiveUser alice "alisa"
alice #$> ("/_get chat @6 count=100", chat, [(1,"chat banner")])
alice #$> ("/_get chat @5 count=100", chat, [(1,"chat banner")])
-- first user messages
alice ##> "/user alice"
@@ -2496,7 +2496,7 @@ testUsersTimedMessages ps' = do
alice ##> "/user alisa"
showActiveUser alice "alisa"
alice #$> ("/_get chat @6 count=100", chat, [(1,"chat banner"), (1, "alisa 3"), (0, "alisa 4")])
alice #$> ("/_get chat @5 count=100", chat, [(1,"chat banner"), (1, "alisa 3"), (0, "alisa 4")])
-- messages are deleted after restart
threadDelay 1000000
@@ -2510,7 +2510,7 @@ testUsersTimedMessages ps' = do
alice ##> "/user alisa"
showActiveUser alice "alisa"
alice #$> ("/_get chat @6 count=100", chat, [(1,"chat banner"), (1, "alisa 3"), (0, "alisa 4")])
alice #$> ("/_get chat @5 count=100", chat, [(1,"chat banner"), (1, "alisa 3"), (0, "alisa 4")])
threadDelay 1000000
@@ -2519,7 +2519,7 @@ testUsersTimedMessages ps' = do
alice ##> "/user"
showActiveUser alice "alisa"
alice #$> ("/_get chat @6 count=100", chat, [(1,"chat banner")])
alice #$> ("/_get chat @5 count=100", chat, [(1,"chat banner")])
where
ps = ps' {printOutput = True} :: TestParams
configureTimedMessages :: HasCallStack => TestCC -> TestCC -> String -> String -> IO ()
+38
View File
@@ -240,6 +240,7 @@ chatGroupTests = do
it "should correctly maintain unread stats for support chats on reading chat items" testScopedSupportUnreadStatsOnRead
it "should correctly maintain unread stats for support chats on deleting chat items" testScopedSupportUnreadStatsOnDelete
it "should correct member attention stat for support chat on opening it" testScopedSupportUnreadStatsCorrectOnOpen
it "should not read support chat items when reading group without scope" testScopedSupportUnreadStatsGroupReadNoScope
it "should remove support chat with member when member is removed" testScopedSupportMemberRemoved
it "should remove support chat with member when user removes member" testScopedSupportUserRemovesMember
it "should remove support chat with member when member leaves" testScopedSupportMemberLeaves
@@ -8464,6 +8465,43 @@ testScopedSupportUnreadStatsCorrectOnOpen =
{ markRead = False
}
testScopedSupportUnreadStatsGroupReadNoScope :: HasCallStack => TestParams -> IO ()
testScopedSupportUnreadStatsGroupReadNoScope =
testChatOpts2 opts aliceProfile bobProfile $ \alice bob -> do
createGroup2 "team" alice bob
bob #> "#team (support) 1"
alice <# "#team (support: bob) bob> 1"
-- capture the support item id directly: lastItemId returns the latest item by
-- item_ts, which right after createGroup2 can be a group event ("connected")
-- rather than the support message, making the per-item read below target the
-- wrong item.
bobItemId <-
withCCTransaction alice $ \db -> do
rows <- DB.query_ db "SELECT chat_item_id FROM chat_items WHERE group_scope_tag = 'member_support' ORDER BY chat_item_id DESC LIMIT 1" :: IO [Only Int]
case rows of
Only iId : _ -> pure $ show iId
_ -> error "testScopedSupportUnreadStatsGroupReadNoScope: no member_support item"
alice ##> "/member support chats #team"
alice <## "members require attention: 1"
alice <## "bob (Bob) (id 2): unread: 1, require attention: 1, mentions: 0"
-- reading the group without scope must not mark support scope items read
alice #$> ("/_read chat #1", id, "ok")
-- the support item was left unread, so reading it in scope still decrements the stats
alice #$> ("/_read chat items #1(_support:2) " <> bobItemId, id, "items read for chat")
alice ##> "/member support chats #team"
alice <## "members require attention: 0"
alice <## "bob (Bob) (id 2): unread: 0, require attention: 0, mentions: 0"
where
opts =
testOpts
{ markRead = False
}
testScopedSupportMemberRemoved :: HasCallStack => TestParams -> IO ()
testScopedSupportMemberRemoved =
testChatOpts3 opts aliceProfile bobProfile cathProfile $ \alice bob cath -> do
+14 -14
View File
@@ -3960,14 +3960,14 @@ testShortLinkChangePreparedContactUser = testChat2 aliceProfile bobProfile test
bob ##> ("/_prepare contact 1 " <> fullLink <> " " <> shortLink <> " " <> contactSLinkData)
bob <## "alice: contact is prepared"
-- 2 ids are for "user contacts", 2 ids are for second user contact cards, so alice is id 5
bob ##> "/_set contact user @5 2"
-- 2 ids are for "user contacts", 1 id is for second user contact card, so alice is id 4
bob ##> "/_set contact user @4 2"
bob <## "contact alice changed from user bob to user robert"
bob ##> "/user robert"
showActiveUser bob "robert"
bob ##> "/_connect contact @5 text hello"
bob ##> "/_connect contact @4 text hello"
bob
<### [ "alice: connection started",
WithTime "@alice hello"
@@ -3981,8 +3981,8 @@ testShortLinkChangePreparedContactUser = testChat2 aliceProfile bobProfile test
alice @@@ [("@robert", "hey")]
alice `hasContactProfiles` ["alice", "robert"]
bob #$> ("/_get chats 2 pcc=on", chats, [("@alice", "hey"), ("@Ask SimpleX Team", ""), ("@SimpleX Status", ""), ("*", "")])
bob `hasContactProfiles` ["robert", "alice", "Ask SimpleX Team", "SimpleX Status"]
bob #$> ("/_get chats 2 pcc=on", chats, [("@alice", "hey"), ("@Ask SimpleX Team", ""), ("*", "")])
bob `hasContactProfiles` ["robert", "alice", "Ask SimpleX Team"]
bob ##> "/user bob"
showActiveUser bob "bob (Bob)"
bob @@@ []
@@ -4010,16 +4010,16 @@ testShortLinkChangePreparedContactUserDuplicate = testChat2 aliceProfile bobProf
bob <## "alice: contact is prepared"
-- 2 ids are for "user contacts"
-- 2 ids are for second user contact cards
-- 1 id is for second user contact card
-- 1 for second user's alice
-- so this alice is id 6
bob ##> "/_set contact user @6 2"
-- so this alice is id 5
bob ##> "/_set contact user @5 2"
bob <## "contact alice changed from user bob to user robert, new local name: alice_1"
bob ##> "/user robert"
showActiveUser bob "robert"
bob ##> "/_connect contact @6 text hello"
bob ##> "/_connect contact @5 text hello"
bob
<### [ "alice_1: connection started",
WithTime "@alice_1 hello"
@@ -4038,8 +4038,8 @@ testShortLinkChangePreparedContactUserDuplicate = testChat2 aliceProfile bobProf
alice @@@ [("@robert", "hey"), ("@robert_1", "hey")]
alice `hasContactProfiles` ["alice", "robert", "robert"]
bob #$> ("/_get chats 2 pcc=on", chats, [("@alice", "hey"), ("@alice_1", "hey"), ("@Ask SimpleX Team", ""), ("@SimpleX Status", ""), ("*", "")])
bob `hasContactProfiles` ["robert", "alice", "alice", "Ask SimpleX Team", "SimpleX Status"]
bob #$> ("/_get chats 2 pcc=on", chats, [("@alice", "hey"), ("@alice_1", "hey"), ("@Ask SimpleX Team", ""), ("*", "")])
bob `hasContactProfiles` ["robert", "alice", "alice", "Ask SimpleX Team"]
bob ##> "/user bob"
showActiveUser bob "bob (Bob)"
bob @@@ []
@@ -4132,8 +4132,8 @@ testShortLinkChangePreparedGroupUser = testChat3 aliceProfile bobProfile cathPro
alice @@@ [("#team", "3"), ("@cath","sent invitation to join group team as admin")]
alice `hasContactProfiles` ["alice", "cath", "robert"]
bob #$> ("/_get chats 2 pcc=on", chats, [("#team", "3"), ("@Ask SimpleX Team", ""), ("@SimpleX Status", ""), ("*", "")])
bob `hasContactProfiles` ["robert", "alice", "cath", "Ask SimpleX Team", "SimpleX Status"]
bob #$> ("/_get chats 2 pcc=on", chats, [("#team", "3"), ("@Ask SimpleX Team", ""), ("*", "")])
bob `hasContactProfiles` ["robert", "alice", "cath", "Ask SimpleX Team"]
cath @@@ [("#team", "3"), ("@alice","received invitation to join group team as admin")]
cath `hasContactProfiles` ["cath", "alice", "robert"]
bob ##> "/user bob"
@@ -4246,7 +4246,7 @@ testShortLinkChangePreparedGroupUserDuplicate = testChat3 aliceProfile bobProfil
alice @@@ [("#team", "7"), ("@cath","sent invitation to join group team as admin")]
alice `hasContactProfiles` ["alice", "cath", "robert", "robert"]
bob `hasContactProfiles` ["robert", "robert", "robert", "alice", "alice", "cath", "cath", "Ask SimpleX Team", "SimpleX Status"]
bob `hasContactProfiles` ["robert", "robert", "robert", "alice", "alice", "cath", "cath", "Ask SimpleX Team"]
cath @@@ [("#team", "7"), ("@alice","received invitation to join group team as admin")]
cath `hasContactProfiles` ["cath", "alice", "robert", "robert"]
bob ##> "/user bob"