diff options
author | Joe Crayne <joe@jerkface.net> | 2018-11-13 17:07:22 -0500 |
---|---|---|
committer | Joe Crayne <joe@jerkface.net> | 2018-11-14 01:29:41 -0500 |
commit | 2a0902701e7c806c2cfd2561d8af1f56539e8811 (patch) | |
tree | fee53bd9c23a6644bf2fda7b7120491015f35b65 /Presence/XMPPServer.hs | |
parent | 971b23b40e2b519107923dcb6976145e2b83b9cf (diff) |
MUC: Notify members on chatroom joins.
Diffstat (limited to 'Presence/XMPPServer.hs')
-rw-r--r-- | Presence/XMPPServer.hs | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/Presence/XMPPServer.hs b/Presence/XMPPServer.hs index 912bbf0b..e44ae37b 100644 --- a/Presence/XMPPServer.hs +++ b/Presence/XMPPServer.hs | |||
@@ -1358,6 +1358,12 @@ monitor sv params xmpp = do | |||
1358 | dput XJabber $ "CHAT " ++ Text.unpack rkey ++ ": <" ++ Text.unpack cnick ++ "> " ++ show es | 1358 | dput XJabber $ "CHAT " ++ Text.unpack rkey ++ ": <" ++ Text.unpack cnick ++ "> " ++ show es |
1359 | forM_ es $ \case | 1359 | forM_ es $ \case |
1360 | Join | mine -> sendRoomOccupants muckey me cnick rkey r replyto | 1360 | Join | mine -> sendRoomOccupants muckey me cnick rkey r replyto |
1361 | Join -> do | ||
1362 | stanza <- makePresenceStanzaEx "jabber:client" (Just $ roomjid muckey me rkey cnick) Available | ||
1363 | [ EventBeginElement "{http://jabber.org/protocol/muc#user}x" [] | ||
1364 | , EventEndElement "{http://jabber.org/protocol/muc#user}x" | ||
1365 | ] | ||
1366 | ioWriteChan replyto stanza | ||
1361 | _ -> return () | 1367 | _ -> return () |
1362 | ] | 1368 | ] |
1363 | action | 1369 | action |
@@ -1367,12 +1373,14 @@ monitor sv params xmpp = do | |||
1367 | where | 1373 | where |
1368 | _ = str :: String | 1374 | _ = str :: String |
1369 | 1375 | ||
1376 | roomjid :: Text {- ^ service -} -> Text {- ^ hostname -} -> Text {- ^ room -} -> Text {- ^ nick -} -> Text | ||
1377 | roomjid a me room n = room <> "@" <> a <> "." <> me <> "/" <> n | ||
1378 | |||
1370 | sendRoomOccupants :: Text -> Text -> Text -> Text -> JoinedRoom k -> TChan Stanza -> IO () | 1379 | sendRoomOccupants :: Text -> Text -> Text -> Text -> JoinedRoom k -> TChan Stanza -> IO () |
1371 | sendRoomOccupants a me them room r replyto = do | 1380 | sendRoomOccupants a me them room r replyto = do |
1372 | let roomjid n = room <> "@" <> a <> "." <> me <> "/" <> n | 1381 | xs <- map (\(n,m) -> (roomjid a me room n, m)) |
1373 | xs <- map (\(n,m) -> (roomjid n, m)) | ||
1374 | <$> atomically (roomOccupants $ joinedRoom r) | 1382 | <$> atomically (roomOccupants $ joinedRoom r) |
1375 | let (ys,xs') = partition (\(jid,_) -> jid == roomjid them) xs | 1383 | let (ys,xs') = partition (\(jid,_) -> jid == roomjid a me room them) xs |
1376 | forM_ xs $ \(jid,_) -> do | 1384 | forM_ xs $ \(jid,_) -> do |
1377 | stanza <- makePresenceStanzaEx "jabber:client" (Just jid) Available | 1385 | stanza <- makePresenceStanzaEx "jabber:client" (Just jid) Available |
1378 | [ EventBeginElement "{http://jabber.org/protocol/muc#user}x" [] | 1386 | [ EventBeginElement "{http://jabber.org/protocol/muc#user}x" [] |