From 522e228aef02c026c3595c2774c6da5fd9203186 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 11 Nov 2012 18:16:11 -0400 Subject: [PATCH] auto-accept pair requests from JIDs already paired with --- Assistant/Threads/XMPPClient.hs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/Assistant/Threads/XMPPClient.hs b/Assistant/Threads/XMPPClient.hs index 641e6da662..f526a9574b 100644 --- a/Assistant/Threads/XMPPClient.hs +++ b/Assistant/Threads/XMPPClient.hs @@ -204,14 +204,24 @@ pull us = do pairMsgReceived :: UrlRenderer -> PairStage -> UUID -> JID -> JID -> Assistant () pairMsgReceived urlrenderer PairReq theiruuid selfjid theirjid - -- PairReq from another client using our JID is automatically accepted. - | baseJID selfjid == baseJID theirjid = do + | baseJID selfjid == baseJID theirjid = autoaccept + | otherwise = do + knownjids <- catMaybes . map (parseJID . getXMPPClientID) + . filter isXMPPRemote . syncRemotes <$> getDaemonStatus + if any (== baseJID theirjid) knownjids + then autoaccept + else showalert + + where + -- PairReq from another client using our JID, or the JID of + -- any repo we're already paired with is automatically accepted. + autoaccept = do selfuuid <- liftAnnex getUUID sendNetMessage $ PairingNotification PairAck (formatJID theirjid) selfuuid finishXMPPPairing theirjid theiruuid -- Show an alert to let the user decide if they want to pair. - | otherwise = do + showalert = do let route = FinishXMPPPairR (PairKey theiruuid $ formatJID theirjid) url <- liftIO $ renderUrl urlrenderer route [] close <- asIO1 removeAlert