M Session.hs => Session.hs +2 -1
@@ 80,7 80,8 @@ sendPresenceToMUC config presence@XMPP.Presence {
let typ'
| ghost = XMPP.PresenceUnavailable
| otherwise = typ
- mkSession config typ' (Just from) target
+ when (typ' == XMPP.PresenceAvailable) $
+ mkSession config typ' (Just from) target
XMPP.putStanza $ presence {
XMPP.presenceType = typ',
M gateway.hs => gateway.hs +8 -2
@@ 41,9 41,11 @@ targets = map (Config.jid . fst) .: fullTargets
handlePresence :: Config.Config -> XMPP.Presence -> XMPP.XMPP ()
handlePresence config presence@XMPP.Presence {
XMPP.presenceFrom = Just from,
- XMPP.presenceTo = Just to
+ XMPP.presenceTo = Just to,
+ XMPP.presenceType = typ
}
- | hasMucCode 110 presence, -- done joining room
+ | typ == XMPP.PresenceAvailable,
+ hasMucCode 110 presence, -- done joining room
Just source <- (XMPP.parseJID . unescapeJid . XMPP.strNode) =<< XMPP.jidNode to = do
when (bareTxt to == bareTxt (Config.bridgeJid config)) $ Session.cleanOld config from
liftIO $ DB.execute (Config.db config)
@@ 54,6 56,10 @@ handlePresence config presence@XMPP.Presence {
XMPP.strResource <$> XMPP.jidResource source,
bareTxt from
)
+ | typ == XMPP.PresenceUnavailable,
+ hasMucCode 110 presence, -- done leaving room
+ Just source <- (XMPP.parseJID . unescapeJid . XMPP.strNode) =<< XMPP.jidNode to = do
+ Session.mkSession config typ (Just source) from
| bareTxt to /= bareTxt (Config.bridgeJid config) =
-- This is to one of our ghosts, so just ignore it
return ()