From 8a12e78e0bff680eb913ec2140da909da74040a0 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 25 Oct 2012 13:29:18 -0400 Subject: only use one push attribute When pushing to multiple UUIDs, combine them all into a single push attribute. --- Assistant/Threads/PushNotifier.hs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'Assistant/Threads/PushNotifier.hs') 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 -- cgit v1.2.3