diff options
author | Joey Hess <joey@kitenet.net> | 2012-11-03 17:34:19 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2012-11-03 17:46:22 -0400 |
commit | bc94dde8f6c5d7ca213fa81a6c03a4c9e22e16d5 (patch) | |
tree | 9a5384d53b222577004ce2cbe8b1540a5e3f2e90 /Assistant/XMPP.hs | |
parent | efa88a0f1589a82a91a06ed3a3cbd5f4106aabb4 (diff) |
XMPP pair requests are now received, and an alert displayed
Diffstat (limited to 'Assistant/XMPP.hs')
-rw-r--r-- | Assistant/XMPP.hs | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/Assistant/XMPP.hs b/Assistant/XMPP.hs index 04eea50f6..3aef76b1a 100644 --- a/Assistant/XMPP.hs +++ b/Assistant/XMPP.hs @@ -86,24 +86,28 @@ isPresenceQuery p = case filter isGitAnnexTag (presencePayloads p) of ((Element _name attrs _nodes):_) -> any (isAttr queryAttr) attrs {- A notification about a stage of pairing. Sent as an XMPP ping. - - The pairing info is sent using its id attribute. -} + - The pairing info is sent using its id attribute; it also has a git-annex + - tag to identify it as from us. -} pairingNotification :: PairStage -> UUID -> JID -> JID -> IQ pairingNotification pairstage u tojid fromjid = (emptyIQ IQGet) { iqTo = Just tojid , iqFrom = Just fromjid , iqID = Just $ T.unwords $ map T.pack - [ "git-annex" - , show pairstage + [ show pairstage , fromUUID u ] + , iqPayload = Just gitAnnexSignature } decodePairingNotification :: IQ -> Maybe NetMessage -decodePairingNotification iq = parseid =<< words . T.unpack <$> iqID iq +decodePairingNotification iq@(IQ { iqPayload = Just elt }) + | isGitAnnexTag elt = parseid =<< words . T.unpack <$> iqID iq + | otherwise = Nothing where - parseid ["git-annex", stage, u] = + parseid [stage, u] = PairingNotification <$> readish stage <*> (formatJID <$> iqFrom iq) <*> pure (toUUID u) parseid _ = Nothing +decodePairingNotification _ = Nothing |