run xmpp push actions in separate thread from xmpp client
Took me a while to figure out why the xmpp client was not receiving git xmpp push messages after a push started.
This commit is contained in:
parent
232b61e946
commit
47c032a748
2 changed files with 15 additions and 18 deletions
|
@ -96,17 +96,18 @@ xmppClient urlrenderer d = do
|
|||
handle _ (GotNetMessage (NotifyPush us)) = void $ inAssistant $ pull us
|
||||
handle selfjid (GotNetMessage (PairingNotification stage c u)) =
|
||||
maybe noop (inAssistant . pairMsgReceived urlrenderer stage u selfjid) (parseJID c)
|
||||
handle _ (GotNetMessage m@(CanPush _)) = inAssistant $
|
||||
unlessM (queueNetPushMessage m) $ void $ handlePushMessage m
|
||||
handle _ (GotNetMessage m@(PushRequest _)) = inAssistant $
|
||||
unlessM (queueNetPushMessage m) $ void $ handlePushMessage m
|
||||
handle _ (GotNetMessage m@(StartingPush _)) = inAssistant $
|
||||
unlessM (queueNetPushMessage m) $ void $ handlePushMessage m
|
||||
handle _ (GotNetMessage m@(CanPush _)) = handlepushmsg m
|
||||
handle _ (GotNetMessage m@(PushRequest _)) = handlepushmsg m
|
||||
handle _ (GotNetMessage m@(StartingPush _)) = handlepushmsg m
|
||||
handle _ (GotNetMessage m) = void $ inAssistant $ queueNetPushMessage m
|
||||
handle _ (Ignorable _) = noop
|
||||
handle _ (Unknown _) = noop
|
||||
handle _ (ProtocolError _) = noop
|
||||
|
||||
handlepushmsg m = inAssistant $
|
||||
unlessM (queueNetPushMessage m) $
|
||||
void $ forkIO <~> handlePushMessage m
|
||||
|
||||
data XMPPEvent
|
||||
= GotNetMessage NetMessage
|
||||
| PresenceMessage Presence
|
||||
|
|
|
@ -224,24 +224,20 @@ xmppRemotes cid = case baseJID <$> parseJID cid of
|
|||
return $ repoIsUrl r && repoLocation r == "xmpp::" ++ want
|
||||
|
||||
handleDeferred :: NetMessage -> Assistant ()
|
||||
handleDeferred = void . handlePushMessage
|
||||
handleDeferred = handlePushMessage
|
||||
|
||||
handlePushMessage :: NetMessage -> Assistant Bool
|
||||
handlePushMessage :: NetMessage -> Assistant ()
|
||||
handlePushMessage (CanPush cid) = do
|
||||
rs <- xmppRemotes cid
|
||||
if null rs
|
||||
then return False
|
||||
else do
|
||||
unless (null rs) $
|
||||
sendNetMessage $ PushRequest cid
|
||||
return True
|
||||
handlePushMessage (PushRequest cid) = do
|
||||
rs <- xmppRemotes cid
|
||||
current <- liftAnnex $ inRepo Git.Branch.current
|
||||
let refs = catMaybes [current, Just Annex.Branch.fullname]
|
||||
any id <$> (forM rs $ \r -> xmppPush cid r refs)
|
||||
forM_ rs $ \r -> xmppPush cid r refs
|
||||
handlePushMessage (StartingPush cid) = do
|
||||
rs <- xmppRemotes cid
|
||||
if null rs
|
||||
then return False
|
||||
else xmppReceivePack cid
|
||||
handlePushMessage _ = return False
|
||||
unless (null rs) $
|
||||
void $ xmppReceivePack cid
|
||||
handlePushMessage _ = noop
|
||||
|
|
Loading…
Reference in a new issue