core: notify about xftp errors (#2105)

This commit is contained in:
spaced4ndy
2023-03-30 18:36:39 +04:00
committed by GitHub
parent 39330fdce3
commit b20824e16c
8 changed files with 24 additions and 7 deletions

View File

@@ -7,7 +7,7 @@ constraints: zip +disable-bzip2 +disable-zstd
source-repository-package
type: git
location: https://github.com/simplex-chat/simplexmq.git
tag: 6a665a083387fe7145d161957f0fcab223a48838
tag: 0f23b4ab5c4c8bf5b937344c865fb195040f3c33
source-repository-package
type: git

View File

@@ -1,5 +1,5 @@
{
"https://github.com/simplex-chat/simplexmq.git"."6a665a083387fe7145d161957f0fcab223a48838" = "06nmqbnvalwx8zc8dndzcp31asm65clx519aplzpkipjcbyz93y4";
"https://github.com/simplex-chat/simplexmq.git"."0f23b4ab5c4c8bf5b937344c865fb195040f3c33" = "15dmz8qkz2jpc0ak71waiqn7x4lmlhiifymk31qxfdpywh96l55f";
"https://github.com/simplex-chat/hs-socks.git"."a30cc7a79a08d8108316094f8f2f82a0c5e1ac51" = "0yasvnr7g91k76mjkamvzab2kvlb1g5pspjyjn2fr6v83swjhj38";
"https://github.com/kazu-yamamoto/http2.git"."78e18f52295a7f89e828539a03fbcb24931461a3" = "05q165anvv0qrcxqbvq1dlvw0l8gmsa9kl6sazk1mfhz2g0yimdk";
"https://github.com/simplex-chat/direct-sqlcipher.git"."34309410eb2069b029b8fc1872deb1e0db123294" = "0kwkmhyfsn2lixdlgl15smgr1h5gjk7fky6abzh8rng2h5ymnffd";

View File

@@ -2328,6 +2328,12 @@ processAgentMsgSndFile _corrId aFileId msg =
void $ sendFileDescription sft rfd sharedMsgId $ \msg' -> sendDirectMessage conn msg' $ GroupId groupId
_ -> pure ()
_ -> pure () -- TODO error?
SFERR e -> do
throwChatError $ CEXFTPSndFile fileId (AgentSndFileId aFileId) e
-- update chat item status
-- send status to view
-- agentXFTPDeleteSndFile
pure ()
where
sendFileDescription :: SndFileTransfer -> ValidFileDescription 'FRecipient -> SharedMsgId -> (ChatMsgEvent 'Json -> m (SndMessage, Int64)) -> m Int64
sendFileDescription sft rfd msgId sendMsg = do
@@ -2378,11 +2384,11 @@ processAgentMsgRcvFile _corrId aFileId msg =
getChatItemByFileId db user fileId
agentXFTPDeleteRcvFile user aFileId fileId
toView $ CRRcvFileComplete user ci
RFERR _e -> do
RFERR e -> do
throwChatError $ CEXFTPRcvFile fileId (AgentRcvFileId aFileId) e
-- update chat item status
-- send status to view
agentXFTPDeleteRcvFile user aFileId fileId
pure ()
processAgentMessageConn :: forall m. ChatMonad m => User -> ACorrId -> ConnId -> ACommand 'Agent 'AEConn -> m ()
processAgentMessageConn user _ agentConnId END =

View File

@@ -780,6 +780,8 @@ data ChatErrorType
| CEFileImageType {filePath :: FilePath}
| CEFileImageSize {filePath :: FilePath}
| CEFileNotReceived {fileId :: FileTransferId}
| CEXFTPRcvFile {fileId :: FileTransferId, agentRcvFileId :: AgentRcvFileId, agentError :: AgentErrorType}
| CEXFTPSndFile {fileId :: FileTransferId, agentSndFileId :: AgentSndFileId, agentError :: AgentErrorType}
| CEInlineFileProhibited {fileId :: FileTransferId}
| CEInvalidQuote
| CEInvalidChatItemUpdate

View File

@@ -134,7 +134,10 @@ mobileChatOpts dbFilePrefix dbKey =
defaultMobileConfig :: ChatConfig
defaultMobileConfig =
defaultChatConfig {confirmMigrations = MCYesUp}
defaultChatConfig
{ confirmMigrations = MCYesUp,
logLevel = CLLError
}
type CJSONString = CString

View File

@@ -1284,6 +1284,8 @@ viewChatError logLevel = \case
CEFileImageType _ -> ["image type must be jpg, send as a file using " <> highlight' "/f"]
CEFileImageSize _ -> ["max image size: " <> sShow maxImageSize <> " bytes, resize it or send as a file using " <> highlight' "/f"]
CEFileNotReceived fileId -> ["file " <> sShow fileId <> " not received"]
CEXFTPRcvFile fileId aFileId e -> ["error receiving XFTP file " <> sShow fileId <> ", agent file id " <> sShow aFileId <> ": " <> sShow e | logLevel == CLLError]
CEXFTPSndFile fileId aFileId e -> ["error sending XFTP file " <> sShow fileId <> ", agent file id " <> sShow aFileId <> ": " <> sShow e | logLevel == CLLError]
CEInlineFileProhibited _ -> ["A small file sent without acceptance - you can enable receiving such files with -f option."]
CEInvalidQuote -> ["cannot reply to this message"]
CEInvalidChatItemUpdate -> ["cannot update this item"]

View File

@@ -49,7 +49,7 @@ extra-deps:
# - simplexmq-1.0.0@sha256:34b2004728ae396e3ae449cd090ba7410781e2b3cefc59259915f4ca5daa9ea8,8561
# - ../simplexmq
- github: simplex-chat/simplexmq
commit: 6a665a083387fe7145d161957f0fcab223a48838
commit: 0f23b4ab5c4c8bf5b937344c865fb195040f3c33
- github: kazu-yamamoto/http2
commit: 78e18f52295a7f89e828539a03fbcb24931461a3
# - ../direct-sqlcipher

View File

@@ -100,7 +100,11 @@ aCfg :: AgentConfig
aCfg = (agentConfig defaultChatConfig) {tbqSize = 16}
testAgentCfg :: AgentConfig
testAgentCfg = aCfg {reconnectInterval = (reconnectInterval aCfg) {initialInterval = 50000}}
testAgentCfg =
aCfg
{ reconnectInterval = (reconnectInterval aCfg) {initialInterval = 50000},
xftpNotifyErrsOnRetry = False
}
testCfg :: ChatConfig
testCfg =