diff options
author | Joe Crayne <joe@jerkface.net> | 2018-11-05 23:23:20 -0500 |
---|---|---|
committer | Joe Crayne <joe@jerkface.net> | 2018-11-06 04:34:03 -0500 |
commit | fb4ad2167102046125c822841dabf3edba32ed85 (patch) | |
tree | 410ca61c160b3cb2398f7482752b6994c17ca23a | |
parent | 239f4fa10828f2cc4e71cffa1d3aed31a0ce8625 (diff) |
Comments documenting home-grown <presence> whitelist attribute.
-rw-r--r-- | Presence/Stanza/Types.hs | 13 | ||||
-rw-r--r-- | Presence/XMPPServer.hs | 10 |
2 files changed, 22 insertions, 1 deletions
diff --git a/Presence/Stanza/Types.hs b/Presence/Stanza/Types.hs index cbb156a0..3e039a34 100644 --- a/Presence/Stanza/Types.hs +++ b/Presence/Stanza/Types.hs | |||
@@ -50,7 +50,20 @@ data StanzaType | |||
50 | , presencePriority :: Maybe Int8 | 50 | , presencePriority :: Maybe Int8 |
51 | , presenceStatus :: [(Lang,Text)] | 51 | , presenceStatus :: [(Lang,Text)] |
52 | , presenceWhiteList :: [Text] | 52 | , presenceWhiteList :: [Text] |
53 | -- ^ A custom extension extension we are using. When a | ||
54 | -- peer answers a presence probe, it also communicates | ||
55 | -- to the remote peer which remote users it believes | ||
56 | -- are subscribed to that presence. | ||
57 | -- | ||
58 | -- This is communicated via a space-delimited list in | ||
59 | -- the nonstandard "whitelist" attribute for a | ||
60 | -- <{jabber:server}presence> tag. | ||
61 | -- | ||
62 | -- TODO: Use this to update the buddies file so that a | ||
63 | -- client is made aware when a subscription was | ||
64 | -- canceled. | ||
53 | } | 65 | } |
66 | |||
54 | | PresenceInformError | 67 | | PresenceInformError |
55 | | PresenceInformSubscription Bool | 68 | | PresenceInformSubscription Bool |
56 | | PresenceRequestStatus | 69 | | PresenceRequestStatus |
diff --git a/Presence/XMPPServer.hs b/Presence/XMPPServer.hs index 218e60e0..a0d5a69b 100644 --- a/Presence/XMPPServer.hs +++ b/Presence/XMPPServer.hs | |||
@@ -305,6 +305,12 @@ swapit old new (EventEndElement n) | nameNamespace n==Just old = | |||
305 | EventEndElement (n { nameNamespace = Just new }) | 305 | EventEndElement (n { nameNamespace = Just new }) |
306 | swapit old new x = x | 306 | swapit old new x = x |
307 | 307 | ||
308 | -- | This is invoked by sendModifiedStanzaTo* before swapping the namespace. | ||
309 | -- | ||
310 | -- Optionally, when the namespace is jabber:server, this will set a "whitelist" | ||
311 | -- attribute on a presence tag that indicates a list of users deliminated by | ||
312 | -- spaces. This is so that a server can communicate to another server which | ||
313 | -- users are believed to be subscribed. | ||
308 | fixHeaders :: Monad m => Stanza -> ConduitM Event Event m () | 314 | fixHeaders :: Monad m => Stanza -> ConduitM Event Event m () |
309 | fixHeaders Stanza { stanzaType=typ, stanzaTo=mto, stanzaFrom=mfrom } = do | 315 | fixHeaders Stanza { stanzaType=typ, stanzaTo=mto, stanzaFrom=mfrom } = do |
310 | x <- await | 316 | x <- await |
@@ -319,8 +325,10 @@ fixHeaders Stanza { stanzaType=typ, stanzaTo=mto, stanzaFrom=mfrom } = do | |||
319 | as'' = maybe as' (setAttrib "from" as') mfrom | 325 | as'' = maybe as' (setAttrib "from" as') mfrom |
320 | as3 = case typ of | 326 | as3 = case typ of |
321 | PresenceStatus {} | nameNamespace n == Just "jabber:client" | 327 | PresenceStatus {} | nameNamespace n == Just "jabber:client" |
322 | -> delAttrib "whitelist" as'' | 328 | -> delAttrib "whitelist" as'' -- client-to-peer "whitelist" is filtered. |
323 | PresenceStatus {} | otherwise | 329 | PresenceStatus {} | otherwise |
330 | -- peer-to-client, we may have set a list of subscribed users | ||
331 | -- to be communicated to the remote end. | ||
324 | -> case presenceWhiteList typ of | 332 | -> case presenceWhiteList typ of |
325 | [] -> delAttrib "whitelist" as'' | 333 | [] -> delAttrib "whitelist" as'' |
326 | ws -> setAttrib "whitelist" as'' (Text.intercalate " " ws) | 334 | ws -> setAttrib "whitelist" as'' (Text.intercalate " " ws) |