only use one push attribute
When pushing to multiple UUIDs, combine them all into a single push attribute.
This commit is contained in:
parent
91c0c7b9ef
commit
8c9c8e3110
2 changed files with 15 additions and 6 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue