mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-10-23 04:22:13 +00:00
tests, fix: execute in parallel, send connected events after creating chat items, fix race when merging multiple members to one contact (#7500)
* tests: execute in parallel * remove race in terminal * fix some tests * stop chat controller on exit * fix more tests * fix tests * query plans * update simplexmq * update direct-sqlcipher * fix tests * query plans * ios: update core * fix tests * update simplexmq and direct-sqlcipher, fixes * simplexmq * update simplexmq * parallel channel tests * update tests * fix tests * fix tests * query plans * fix test * more tests in CI * use ram drive in CI * fix tests, fix directory deleting voice file before it is uploaded * fix query * fix query to use index * link contact and channel owner profile when connecting via a signed link * update simplexmq, fix ghc 8.10.7 * fix tests * avoid double stop * query plans * fix more test races * more test fixes * fix queries * fixes * more fixes --------- Co-authored-by: Evgeny @ SimpleX Chat <259188159+evgeny-simplex@users.noreply.github.com>
This commit is contained in:
1 parent
680790695e
commit
df95de8a2c
35 files changed
+1773
-1167
No files matched your search
@@ -12,4 +12,4 @@ main = do
|
||||
opts@DirectoryOpts {runCLI} <- welcomeGetOpts
|
||||
if runCLI
|
||||
then directoryServiceCLI opts
|
||||
else directoryService opts terminalChatConfig
|
||||
else newServiceState opts >>= directoryService opts terminalChatConfig
|
||||
@@ -66,6 +66,7 @@ data DirectoryEvent
|
||||
| DEItemEditIgnored Contact
|
||||
| DEItemDeleteIgnored Contact
|
||||
| DEContactCommand Contact ChatItemId ADirectoryCmd
|
||||
| DEVoiceUploadEnded FilePath
|
||||
| DELogChatResponse Text
|
||||
deriving (Show)
|
||||
|
||||
@@ -110,11 +111,17 @@ crDirectoryEvent_ = \case
|
||||
where
|
||||
ciId = chatItemId' ci
|
||||
err = ADC SDRUser DCUnknownCommand
|
||||
CEvtSndFileCompleteXFTP {chatItem, fileTransferMeta} -> voiceUploadEnded (Just chatItem) fileTransferMeta
|
||||
CEvtSndFileError {chatItem_, fileTransferMeta} -> voiceUploadEnded chatItem_ fileTransferMeta
|
||||
CEvtMessageError {severity, errorMessage} -> Just $ DELogChatResponse $ "message error: " <> severity <> ", " <> errorMessage
|
||||
CEvtChatErrors {chatErrors} -> Just $ DELogChatResponse $ "chat errors: " <> T.intercalate ", " (map tshow chatErrors)
|
||||
_ -> Nothing
|
||||
where
|
||||
pending m = memberStatus m == GSMemPendingApproval
|
||||
voiceUploadEnded :: Maybe AChatItem -> FileTransferMeta -> Maybe DirectoryEvent
|
||||
voiceUploadEnded ci_ FileTransferMeta {filePath} = case ci_ of
|
||||
Just (AChatItem _ SMDSnd _ ChatItem {content = CISndMsgContent MCVoice {}}) -> Just $ DEVoiceUploadEnded filePath
|
||||
_ -> Nothing
|
||||
|
||||
data DirectoryRole = DRUser | DRAdmin | DRSuperUser
|
||||
|
||||
|
||||
@@ -12,7 +12,9 @@
|
||||
{-# OPTIONS_GHC -fno-warn-ambiguous-fields #-}
|
||||
|
||||
module Directory.Service
|
||||
( welcomeGetOpts,
|
||||
( ServiceState (..),
|
||||
welcomeGetOpts,
|
||||
newServiceState,
|
||||
directoryService,
|
||||
directoryServiceCLI,
|
||||
)
|
||||
@@ -245,9 +247,8 @@ directoryCommands =
|
||||
where
|
||||
idParam = Just "<ID>"
|
||||
|
||||
directoryService :: DirectoryOpts -> ChatConfig -> IO ()
|
||||
directoryService opts cfg = do
|
||||
env@ServiceState {eventQ} <- newServiceState opts
|
||||
directoryService :: DirectoryOpts -> ChatConfig -> ServiceState -> IO ()
|
||||
directoryService opts cfg env@ServiceState {eventQ} = do
|
||||
let chatHooks =
|
||||
defaultChatHooks
|
||||
{ preStartHook = Just $ directoryPreStartHook opts,
|
||||
@@ -340,6 +341,7 @@ directoryServiceEvent opts@DirectoryOpts {adminUsers, superUsers, serviceName, o
|
||||
SDRUser -> deUserCommand ct ciId cmd
|
||||
SDRAdmin -> deAdminCommand ct ciId cmd
|
||||
SDRSuperUser -> deSuperUserCommand ct ciId cmd
|
||||
DEVoiceUploadEnded filePath -> void (try $ removeFile filePath :: IO (Either SomeException ()))
|
||||
DELogChatResponse r -> logInfo r
|
||||
where
|
||||
groupLinkText (CCLink cReq sLnk_) = maybe (strEncodeTxt $ simplexChatContact cReq) strEncodeTxt sLnk_
|
||||
@@ -651,9 +653,8 @@ directoryServiceEvent opts@DirectoryOpts {adminUsers, superUsers, serviceName, o
|
||||
case voiceResult of
|
||||
Right r -> case lines r of
|
||||
(filePath : durationStr : _)
|
||||
| not (null filePath), Just duration <- readMaybe durationStr -> do
|
||||
| not (null filePath), Just duration <- readMaybe durationStr ->
|
||||
sendComposedMessageFile cc sendRef Nothing (MCVoice "" duration) (CF.plain filePath)
|
||||
void (try $ removeFile filePath :: IO (Either SomeException ()))
|
||||
_ -> logError "voice captcha generator: unexpected output"
|
||||
Left e -> logError $ "voice captcha generator error: " <> tshow e
|
||||
|
||||
|
||||
Reference in new issue
Block a user