Skip to content

Commit 79ba60e

Browse files
authored
agent: update contact request server hosts to match server in short link (#1597)
1 parent fb477b2 commit 79ba60e

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/Simplex/Messaging/Agent.hs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -912,12 +912,19 @@ getConnShortLink' c nm userId = \case
912912
where
913913
decryptData :: ConnectionModeI c => SMPServer -> LinkKey -> C.SbKey -> (SMP.SenderId, QueueLinkData) -> AM (ConnectionRequestUri c, ConnLinkData c)
914914
decryptData srv linkKey k (sndId, d) = do
915-
r@(cReq, _) <- liftEither $ SL.decryptLinkData @c linkKey k d
915+
r@(cReq, clData) <- liftEither $ SL.decryptLinkData @c linkKey k d
916916
let (srv', sndId') = qAddress (connReqQueue cReq)
917917
unless (srv `sameSrvHost` srv' && sndId == sndId') $
918918
throwE $ AGENT $ A_LINK "different address"
919-
pure r
919+
pure $ if srv' == srv then r else (updateConnReqServer srv cReq, clData)
920920
sameSrvHost ProtocolServer {host = h :| _} ProtocolServer {host = hs} = h `elem` hs
921+
updateConnReqServer :: SMPServer -> ConnectionRequestUri c -> ConnectionRequestUri c
922+
updateConnReqServer srv = \case
923+
CRInvitationUri crData e2eParams -> CRInvitationUri (updateQueues crData) e2eParams
924+
CRContactUri crData -> CRContactUri $ updateQueues crData
925+
where
926+
updateQueues crData@(ConnReqUriData {crSmpQueues = SMPQueueUri vr addr :| qs}) =
927+
crData {crSmpQueues = SMPQueueUri vr addr {smpServer = srv} :| qs}
921928

922929
deleteLocalInvShortLink' :: AgentClient -> ConnShortLink 'CMInvitation -> AM ()
923930
deleteLocalInvShortLink' c (CSLInvitation _ srv linkId _) = withStore' c $ \db -> deleteInvShortLink db srv linkId

0 commit comments

Comments
 (0)