core: include ConnectionStats into switch api response (#2594)
This commit is contained in:
parent
ec7bff9205
commit
d929c34e71
@ -7,7 +7,7 @@ constraints: zip +disable-bzip2 +disable-zstd
|
|||||||
source-repository-package
|
source-repository-package
|
||||||
type: git
|
type: git
|
||||||
location: https://github.com/simplex-chat/simplexmq.git
|
location: https://github.com/simplex-chat/simplexmq.git
|
||||||
tag: 2efe1496d2622a56656a6a00a2cc19005e754468
|
tag: c31668ce286380ed6cf6829f1fa0b246cd52d828
|
||||||
|
|
||||||
source-repository-package
|
source-repository-package
|
||||||
type: git
|
type: git
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"https://github.com/simplex-chat/simplexmq.git"."2efe1496d2622a56656a6a00a2cc19005e754468" = "0syy10zn3ci1nbs00r0l5vhvqkwlqcgmmd5c196pch0xvrk5qbfi";
|
"https://github.com/simplex-chat/simplexmq.git"."c31668ce286380ed6cf6829f1fa0b246cd52d828" = "16bka5rda82wz20n9ldb5wydkf4f9knj3n743832dc93mz60mibw";
|
||||||
"https://github.com/simplex-chat/hs-socks.git"."a30cc7a79a08d8108316094f8f2f82a0c5e1ac51" = "0yasvnr7g91k76mjkamvzab2kvlb1g5pspjyjn2fr6v83swjhj38";
|
"https://github.com/simplex-chat/hs-socks.git"."a30cc7a79a08d8108316094f8f2f82a0c5e1ac51" = "0yasvnr7g91k76mjkamvzab2kvlb1g5pspjyjn2fr6v83swjhj38";
|
||||||
"https://github.com/kazu-yamamoto/http2.git"."b5a1b7200cf5bc7044af34ba325284271f6dff25" = "0dqb50j57an64nf4qcf5vcz4xkd1vzvghvf8bk529c1k30r9nfzb";
|
"https://github.com/kazu-yamamoto/http2.git"."b5a1b7200cf5bc7044af34ba325284271f6dff25" = "0dqb50j57an64nf4qcf5vcz4xkd1vzvghvf8bk529c1k30r9nfzb";
|
||||||
"https://github.com/simplex-chat/direct-sqlcipher.git"."34309410eb2069b029b8fc1872deb1e0db123294" = "0kwkmhyfsn2lixdlgl15smgr1h5gjk7fky6abzh8rng2h5ymnffd";
|
"https://github.com/simplex-chat/direct-sqlcipher.git"."34309410eb2069b029b8fc1872deb1e0db123294" = "0kwkmhyfsn2lixdlgl15smgr1h5gjk7fky6abzh8rng2h5ymnffd";
|
||||||
|
@ -1110,12 +1110,14 @@ processChatCommand = \case
|
|||||||
pure $ CRGroupMemberInfo user g m connectionStats
|
pure $ CRGroupMemberInfo user g m connectionStats
|
||||||
APISwitchContact contactId -> withUser $ \user -> do
|
APISwitchContact contactId -> withUser $ \user -> do
|
||||||
ct <- withStore $ \db -> getContact db user contactId
|
ct <- withStore $ \db -> getContact db user contactId
|
||||||
withAgent $ \a -> switchConnectionAsync a "" $ contactConnId ct
|
connectionStats <- withAgent $ \a -> switchConnectionAsync a "" $ contactConnId ct
|
||||||
ok user
|
pure $ CRContactSwitchStarted user ct connectionStats
|
||||||
APISwitchGroupMember gId gMemberId -> withUser $ \user -> do
|
APISwitchGroupMember gId gMemberId -> withUser $ \user -> do
|
||||||
m <- withStore $ \db -> getGroupMember db user gId gMemberId
|
(g, m) <- withStore $ \db -> (,) <$> getGroupInfo db user gId <*> getGroupMember db user gId gMemberId
|
||||||
case memberConnId m of
|
case memberConnId m of
|
||||||
Just connId -> withAgent (\a -> switchConnectionAsync a "" connId) >> ok user
|
Just connId -> do
|
||||||
|
connectionStats <- withAgent (\a -> switchConnectionAsync a "" connId)
|
||||||
|
pure $ CRGroupMemberSwitchStarted user g m connectionStats
|
||||||
_ -> throwChatError CEGroupMemberNotActive
|
_ -> throwChatError CEGroupMemberNotActive
|
||||||
APIAbortSwitchContact contactId -> withUser $ \user -> do
|
APIAbortSwitchContact contactId -> withUser $ \user -> do
|
||||||
ct <- withStore $ \db -> getContact db user contactId
|
ct <- withStore $ \db -> getContact db user contactId
|
||||||
|
@ -408,6 +408,8 @@ data ChatResponse
|
|||||||
| CRNetworkConfig {networkConfig :: NetworkConfig}
|
| CRNetworkConfig {networkConfig :: NetworkConfig}
|
||||||
| CRContactInfo {user :: User, contact :: Contact, connectionStats :: ConnectionStats, customUserProfile :: Maybe Profile}
|
| CRContactInfo {user :: User, contact :: Contact, connectionStats :: ConnectionStats, customUserProfile :: Maybe Profile}
|
||||||
| CRGroupMemberInfo {user :: User, groupInfo :: GroupInfo, member :: GroupMember, connectionStats_ :: Maybe ConnectionStats}
|
| CRGroupMemberInfo {user :: User, groupInfo :: GroupInfo, member :: GroupMember, connectionStats_ :: Maybe ConnectionStats}
|
||||||
|
| CRContactSwitchStarted {user :: User, contact :: Contact, connectionStats :: ConnectionStats}
|
||||||
|
| CRGroupMemberSwitchStarted {user :: User, groupInfo :: GroupInfo, member :: GroupMember, connectionStats :: ConnectionStats}
|
||||||
| CRContactSwitchAborted {user :: User, contact :: Contact, connectionStats :: ConnectionStats}
|
| CRContactSwitchAborted {user :: User, contact :: Contact, connectionStats :: ConnectionStats}
|
||||||
| CRGroupMemberSwitchAborted {user :: User, groupInfo :: GroupInfo, member :: GroupMember, connectionStats :: ConnectionStats}
|
| CRGroupMemberSwitchAborted {user :: User, groupInfo :: GroupInfo, member :: GroupMember, connectionStats :: ConnectionStats}
|
||||||
| CRContactSwitch {user :: User, contact :: Contact, switchProgress :: SwitchProgress}
|
| CRContactSwitch {user :: User, contact :: Contact, switchProgress :: SwitchProgress}
|
||||||
|
@ -80,6 +80,8 @@ responseToView user_ ChatConfig {logLevel, showReactions, testView} liveItems ts
|
|||||||
CRNetworkConfig cfg -> viewNetworkConfig cfg
|
CRNetworkConfig cfg -> viewNetworkConfig cfg
|
||||||
CRContactInfo u ct cStats customUserProfile -> ttyUser u $ viewContactInfo ct cStats customUserProfile
|
CRContactInfo u ct cStats customUserProfile -> ttyUser u $ viewContactInfo ct cStats customUserProfile
|
||||||
CRGroupMemberInfo u g m cStats -> ttyUser u $ viewGroupMemberInfo g m cStats
|
CRGroupMemberInfo u g m cStats -> ttyUser u $ viewGroupMemberInfo g m cStats
|
||||||
|
CRContactSwitchStarted {} -> ["switch started"]
|
||||||
|
CRGroupMemberSwitchStarted {} -> ["switch started"]
|
||||||
CRContactSwitchAborted {} -> ["switch aborted"]
|
CRContactSwitchAborted {} -> ["switch aborted"]
|
||||||
CRGroupMemberSwitchAborted {} -> ["switch aborted"]
|
CRGroupMemberSwitchAborted {} -> ["switch aborted"]
|
||||||
CRContactSwitch u ct progress -> ttyUser u $ viewContactSwitch ct progress
|
CRContactSwitch u ct progress -> ttyUser u $ viewContactSwitch ct progress
|
||||||
|
@ -49,7 +49,7 @@ extra-deps:
|
|||||||
# - simplexmq-1.0.0@sha256:34b2004728ae396e3ae449cd090ba7410781e2b3cefc59259915f4ca5daa9ea8,8561
|
# - simplexmq-1.0.0@sha256:34b2004728ae396e3ae449cd090ba7410781e2b3cefc59259915f4ca5daa9ea8,8561
|
||||||
# - ../simplexmq
|
# - ../simplexmq
|
||||||
- github: simplex-chat/simplexmq
|
- github: simplex-chat/simplexmq
|
||||||
commit: 2efe1496d2622a56656a6a00a2cc19005e754468
|
commit: c31668ce286380ed6cf6829f1fa0b246cd52d828
|
||||||
- github: kazu-yamamoto/http2
|
- github: kazu-yamamoto/http2
|
||||||
commit: b5a1b7200cf5bc7044af34ba325284271f6dff25
|
commit: b5a1b7200cf5bc7044af34ba325284271f6dff25
|
||||||
# - ../direct-sqlcipher
|
# - ../direct-sqlcipher
|
||||||
|
@ -1838,7 +1838,7 @@ testSwitchContact =
|
|||||||
testChat2 aliceProfile bobProfile $
|
testChat2 aliceProfile bobProfile $
|
||||||
\alice bob -> do
|
\alice bob -> do
|
||||||
connectUsers alice bob
|
connectUsers alice bob
|
||||||
alice #$> ("/switch bob", id, "ok")
|
alice #$> ("/switch bob", id, "switch started")
|
||||||
bob <## "alice started changing address for you"
|
bob <## "alice started changing address for you"
|
||||||
alice <## "bob: you started changing address"
|
alice <## "bob: you started changing address"
|
||||||
bob <## "alice changed address for you"
|
bob <## "alice changed address for you"
|
||||||
@ -1852,7 +1852,7 @@ testAbortSwitchContact tmp = do
|
|||||||
withNewTestChat tmp "alice" aliceProfile $ \alice -> do
|
withNewTestChat tmp "alice" aliceProfile $ \alice -> do
|
||||||
withNewTestChat tmp "bob" bobProfile $ \bob -> do
|
withNewTestChat tmp "bob" bobProfile $ \bob -> do
|
||||||
connectUsers alice bob
|
connectUsers alice bob
|
||||||
alice #$> ("/switch bob", id, "ok")
|
alice #$> ("/switch bob", id, "switch started")
|
||||||
alice <## "bob: you started changing address"
|
alice <## "bob: you started changing address"
|
||||||
-- repeat switch is prohibited
|
-- repeat switch is prohibited
|
||||||
alice ##> "/switch bob"
|
alice ##> "/switch bob"
|
||||||
@ -1865,7 +1865,7 @@ testAbortSwitchContact tmp = do
|
|||||||
withTestChatContactConnected tmp "bob" $ \bob -> do
|
withTestChatContactConnected tmp "bob" $ \bob -> do
|
||||||
bob <## "alice started changing address for you"
|
bob <## "alice started changing address for you"
|
||||||
-- alice changes address again
|
-- alice changes address again
|
||||||
alice #$> ("/switch bob", id, "ok")
|
alice #$> ("/switch bob", id, "switch started")
|
||||||
alice <## "bob: you started changing address"
|
alice <## "bob: you started changing address"
|
||||||
bob <## "alice started changing address for you"
|
bob <## "alice started changing address for you"
|
||||||
bob <## "alice changed address for you"
|
bob <## "alice changed address for you"
|
||||||
@ -1879,7 +1879,7 @@ testSwitchGroupMember =
|
|||||||
testChat2 aliceProfile bobProfile $
|
testChat2 aliceProfile bobProfile $
|
||||||
\alice bob -> do
|
\alice bob -> do
|
||||||
createGroup2 "team" alice bob
|
createGroup2 "team" alice bob
|
||||||
alice #$> ("/switch #team bob", id, "ok")
|
alice #$> ("/switch #team bob", id, "switch started")
|
||||||
bob <## "#team: alice started changing address for you"
|
bob <## "#team: alice started changing address for you"
|
||||||
alice <## "#team: you started changing address for bob"
|
alice <## "#team: you started changing address for bob"
|
||||||
bob <## "#team: alice changed address for you"
|
bob <## "#team: alice changed address for you"
|
||||||
@ -1896,7 +1896,7 @@ testAbortSwitchGroupMember tmp = do
|
|||||||
withNewTestChat tmp "alice" aliceProfile $ \alice -> do
|
withNewTestChat tmp "alice" aliceProfile $ \alice -> do
|
||||||
withNewTestChat tmp "bob" bobProfile $ \bob -> do
|
withNewTestChat tmp "bob" bobProfile $ \bob -> do
|
||||||
createGroup2 "team" alice bob
|
createGroup2 "team" alice bob
|
||||||
alice #$> ("/switch #team bob", id, "ok")
|
alice #$> ("/switch #team bob", id, "switch started")
|
||||||
alice <## "#team: you started changing address for bob"
|
alice <## "#team: you started changing address for bob"
|
||||||
-- repeat switch is prohibited
|
-- repeat switch is prohibited
|
||||||
alice ##> "/switch #team bob"
|
alice ##> "/switch #team bob"
|
||||||
@ -1910,7 +1910,7 @@ testAbortSwitchGroupMember tmp = do
|
|||||||
bob <## "#team: connected to server(s)"
|
bob <## "#team: connected to server(s)"
|
||||||
bob <## "#team: alice started changing address for you"
|
bob <## "#team: alice started changing address for you"
|
||||||
-- alice changes address again
|
-- alice changes address again
|
||||||
alice #$> ("/switch #team bob", id, "ok")
|
alice #$> ("/switch #team bob", id, "switch started")
|
||||||
alice <## "#team: you started changing address for bob"
|
alice <## "#team: you started changing address for bob"
|
||||||
bob <## "#team: alice started changing address for you"
|
bob <## "#team: alice started changing address for you"
|
||||||
bob <## "#team: alice changed address for you"
|
bob <## "#team: alice changed address for you"
|
||||||
|
Loading…
Reference in New Issue
Block a user