diff options
author | 2012-11-11 18:16:11 -0400 | |
---|---|---|
committer | 2012-11-11 18:16:11 -0400 | |
commit | ff567a884af1bb2b7e81a60b3b37f34b4100c042 (patch) | |
tree | 5ddc67be3732ddf57dc3d9fc148dd43fc79b2e0c /Assistant | |
parent | 3a6456a7b786e1cb41605a1ad46004e4de6d27b7 (diff) |
auto-accept pair requests from JIDs already paired with
Diffstat (limited to 'Assistant')
-rw-r--r-- | Assistant/Threads/XMPPClient.hs | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/Assistant/Threads/XMPPClient.hs b/Assistant/Threads/XMPPClient.hs index 641e6da66..f526a9574 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 |