add CRContactConnecting api response (#281)
This commit is contained in:
parent
82d02e923a
commit
855881094b
@ -964,8 +964,9 @@ processAgentMessage (Just user@User {userId, profile}) agentConnId agentMessage
|
||||
saveConnInfo activeConn connInfo = do
|
||||
ChatMessage {chatMsgEvent} <- liftEither $ parseChatMessage connInfo
|
||||
case chatMsgEvent of
|
||||
XInfo p ->
|
||||
withStore $ \st -> createDirectContact st userId activeConn p
|
||||
XInfo p -> do
|
||||
ct <- withStore $ \st -> createDirectContact st userId activeConn p
|
||||
toView $ CRContactConnecting ct
|
||||
-- TODO show/log error, other events in SMP confirmation
|
||||
_ -> pure ()
|
||||
|
||||
|
@ -173,6 +173,7 @@ data ChatResponse
|
||||
| CRSndFileRcvCancelled {sndFileTransfer :: SndFileTransfer}
|
||||
| CRSndGroupFileCancelled {sndFileTransfers :: [SndFileTransfer]}
|
||||
| CRUserProfileUpdated {fromProfile :: Profile, toProfile :: Profile}
|
||||
| CRContactConnecting {contact :: Contact}
|
||||
| CRContactConnected {contact :: Contact}
|
||||
| CRContactAnotherClient {contact :: Contact}
|
||||
| CRContactDisconnected {contact :: Contact}
|
||||
|
@ -272,12 +272,12 @@ createConnection_ db userId connType entityId acId viaContact connLevel currentT
|
||||
where
|
||||
ent ct = if connType == ct then entityId else Nothing
|
||||
|
||||
createDirectContact :: StoreMonad m => SQLiteStore -> UserId -> Connection -> Profile -> m ()
|
||||
createDirectContact st userId Connection {connId} profile =
|
||||
void $
|
||||
liftIOEither . withTransaction st $ \db -> do
|
||||
currentTs <- getCurrentTime
|
||||
createContact_ db userId connId profile Nothing currentTs
|
||||
createDirectContact :: StoreMonad m => SQLiteStore -> UserId -> Connection -> Profile -> m Contact
|
||||
createDirectContact st userId activeConn@Connection {connId} profile =
|
||||
liftIOEither . withTransaction st $ \db -> runExceptT $ do
|
||||
createdAt <- liftIO getCurrentTime
|
||||
(localDisplayName, contactId, _) <- ExceptT $ createContact_ db userId connId profile Nothing createdAt
|
||||
pure $ Contact {contactId, localDisplayName, profile, activeConn, viaGroup = Nothing, createdAt}
|
||||
|
||||
createContact_ :: DB.Connection -> UserId -> Int64 -> Profile -> Maybe Int64 -> UTCTime -> IO (Either StoreError (Text, Int64, Int64))
|
||||
createContact_ db userId connId Profile {displayName, fullName} viaGroup currentTs =
|
||||
|
@ -89,6 +89,7 @@ responseToView cmd = \case
|
||||
CRSndFileCancelled ft -> sendingFile_ "cancelled" ft
|
||||
CRSndFileRcvCancelled ft@SndFileTransfer {recipientDisplayName = c} ->
|
||||
[ttyContact c <> " cancelled receiving " <> sndFile ft]
|
||||
CRContactConnecting _ -> []
|
||||
CRContactConnected ct -> [ttyFullContact ct <> ": contact is connected"]
|
||||
CRContactAnotherClient c -> [ttyContact' c <> ": contact is connected to another client"]
|
||||
CRContactDisconnected c -> [ttyContact' c <> ": disconnected from server (messages will be queued)"]
|
||||
|
Loading…
Reference in New Issue
Block a user