summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2014-03-08 21:16:18 -0500
committerjoe <joe@jerkface.net>2014-03-08 21:16:18 -0500
commita3382732fb80714113920c699c290c1565d6919b (patch)
tree9b2257f36505ac437d2f7c07498c27acf47c9518
parent6ae814b019a2b14848ee376d1f9ea521310ae0cd (diff)
broadcast roster change to other clients on approve/reject
-rw-r--r--Presence/XMPPServer.hs15
-rw-r--r--xmppServer.hs16
2 files changed, 31 insertions, 0 deletions
diff --git a/Presence/XMPPServer.hs b/Presence/XMPPServer.hs
index 02dd5134..d9cacb4c 100644
--- a/Presence/XMPPServer.hs
+++ b/Presence/XMPPServer.hs
@@ -24,6 +24,7 @@ module XMPPServer
24 , presenceSolicitation 24 , presenceSolicitation
25 , makePresenceStanza 25 , makePresenceStanza
26 , makeInformSubscription 26 , makeInformSubscription
27 , makeRosterUpdate
27 , JabberShow(..) 28 , JabberShow(..)
28 ) where 29 ) where
29 30
@@ -794,6 +795,20 @@ makePresenceStanza namespace mjid pstat = do
794 , EventContent (ContentText stat) 795 , EventContent (ContentText stat)
795 , EventEndElement "{jabber:client}show" ] 796 , EventEndElement "{jabber:client}show" ]
796 797
798makeRosterUpdate tojid contact relationship = do
799 let attrs = [attr "subscription" relationship]
800 stanzaFromList Unrecognized
801 [ EventBeginElement "{jabber:client}iq"
802 [ attr "to" tojid
803 , attr "id" "someid"
804 , attr "type" "set"
805 ]
806 , EventBeginElement "{jabber:iq:roster}query" []
807 , EventBeginElement "{jabber:iq:roster}item" (attr "jid" contact : attrs)
808 , EventEndElement "{jabber:iq:roster}item"
809 , EventEndElement "{jabber:iq:roster}query"
810 , EventEndElement "{jabber:client}iq"
811 ]
797 812
798makePong :: Text -> Maybe Text -> Text -> Text -> [XML.Event] 813makePong :: Text -> Maybe Text -> Text -> Text -> [XML.Event]
799makePong namespace mid to from = 814makePong namespace mid to from =
diff --git a/xmppServer.hs b/xmppServer.hs
index 13883c75..d10fe4c2 100644
--- a/xmppServer.hs
+++ b/xmppServer.hs
@@ -764,6 +764,22 @@ clientInformSubscription state fail k stanza = do
764 -- send roster update to clients 764 -- send roster update to clients
765 -- approve: both ( ∈ buddies) else from 765 -- approve: both ( ∈ buddies) else from
766 -- reject: to ( ∈ buddies ) else none 766 -- reject: to ( ∈ buddies ) else none
767 (clients,ktc) <- atomically $ do
768 cbu <- readTVar (clientsByUser state)
769 let mlp = mu >>= flip Map.lookup cbu
770 let cs = maybe [] (Map.toList . networkClients) mlp
771 ktc <- readTVar (keyToChan state)
772 return (cs,ktc)
773
774 forM_ clients $ \(ck, client) -> do
775 when (clientIsInterested client) $ do
776 flip (maybe $ return ()) (Map.lookup ck ktc) $ \con -> do
777 hostname <- textHostName
778 -- TODO: Should cjid include the resource?
779 let cjid = unsplitJID (mu, hostname, Nothing)
780 update <- makeRosterUpdate cjid to relationship
781 sendModifiedStanzaToClient update (connChan con)
782
767 783
768 -- notify peer 784 -- notify peer
769 return () 785 return ()