diff options
-rw-r--r-- | Assistant/Threads/PushNotifier.hs | 14 | ||||
-rw-r--r-- | doc/design/assistant/xmpp.mdwn | 7 |
2 files changed, 15 insertions, 6 deletions
diff --git a/Assistant/Threads/PushNotifier.hs b/Assistant/Threads/PushNotifier.hs index 872b18994..84fe4952a 100644 --- a/Assistant/Threads/PushNotifier.hs +++ b/Assistant/Threads/PushNotifier.hs @@ -57,8 +57,9 @@ pushNotifierThread st dstatus pushnotifier = NamedThread thisThread $ do sendnotifications = forever $ do us <- liftIO $ waitPush pushnotifier let payload = [extendedAway, encodePushNotification us] - putStanza $ (emptyPresence PresenceAvailable) + let notification = (emptyPresence PresenceAvailable) { presencePayloads = payload } + putStanza notification receivenotifications = forever $ do s <- getStanza @@ -117,17 +118,24 @@ gitAnnexTagName = Name (T.pack "git-annex") (Just $ T.pack "git-annex") Nothing pushAttr :: Name pushAttr = Name (T.pack "push") Nothing Nothing +uuidSep :: T.Text +uuidSep = T.pack "," + {- git-annex tag with one push attribute per UUID pushed to. -} encodePushNotification :: [UUID] -> Element encodePushNotification us = Element gitAnnexTagName - [(pushAttr, map (ContentText . T.pack . fromUUID) us)] [] + [(pushAttr, [ContentText pushvalue])] [] + where + pushvalue = T.intercalate uuidSep $ + map (T.pack . fromUUID) us decodePushNotification :: Element -> Maybe [UUID] decodePushNotification (Element name attrs _nodes) | name == gitAnnexTagName && not (null us) = Just us | otherwise = Nothing where - us = concatMap (map (toUUID . T.unpack . fromContent) . snd) $ + us = map (toUUID . T.unpack) $ + concatMap (T.splitOn uuidSep . T.concat . map fromContent . snd) $ filter ispush attrs ispush (k, _) = k == pushAttr fromContent (ContentText t) = t diff --git a/doc/design/assistant/xmpp.mdwn b/doc/design/assistant/xmpp.mdwn index 6d5384e43..d008d3fdc 100644 --- a/doc/design/assistant/xmpp.mdwn +++ b/doc/design/assistant/xmpp.mdwn @@ -42,11 +42,12 @@ using presence messages. These always mark it as extended away. To this, it adds its own tag as [extended content](http://xmpp.org/rfcs/rfc6121.html#presence-extended). The xml namespace is "git-annex" (not an URL because I hate wasting bandwidth). -To indicate it's pushed changes to a git repo, a client uses: +To indicate it's pushed changes to a git repo with a given UUID, a client uses: - <git-annex xmlns='git-annex' push="uuid" /> + <git-annex xmlns='git-annex' push="uuid[,uuid...]" /> -The push attribute can be repeated when the push was sent to multiple repos. +Multiple UUIDs can be listed when multiple clients were pushed. If the +git repo does not have a git-annex UUID, an empty string is used. ### security |