~singpolyma/cheogram

d43e6e8956b9f93254aaf2177782125bfb27cb23 — Stephen Paul Weber 6 years ago 5e5882f
Rejoin on status 332

Closes #36
1 files changed, 5 insertions(+), 0 deletions(-)

M Main.hs
M Main.hs => Main.hs +5 -0
@@ 261,6 261,11 @@ handleJoinPartRoom db toVitelity toRoomPresences toRejoinManager toJoinPartDebou
				]
			) $ attributeText (fromString "nick")
				=<< listToMaybe (isNamed (fromString "{http://jabber.org/protocol/muc#user}item") =<< elementChildren x)
	| not join,
	  [x] <- isNamed (fromString "{http://jabber.org/protocol/muc#user}x") =<< payloads,
	  (_:_) <- code "332" =<< isNamed (fromString "{http://jabber.org/protocol/muc#user}status") =<< elementChildren x = do
		log "SERVER RESTART, rejoin in 5s" (tel, from)
		void $ forkIO $ threadDelay 5000000 >> atomically (writeTChan toRejoinManager $ ForceRejoin from tel)
	| not join && existingRoom == Just from = do
		log "YOU HAVE LEFT" (tel, existingRoom)
		True <- TC.runTCM $ TC.out db $ tcKey tel "joined"