~singpolyma/cheogram

56b9985fa39cacedd9692ace5a63d72d0f042de9 — Stephen Paul Weber 7 years ago bdf0f43
Do not tell me I joined when I'm already in

Especially when I'm changing my nickname.

Closes #20
1 files changed, 8 insertions(+), 4 deletions(-)

M Main.hs
M Main.hs => Main.hs +8 -4
@@ 200,10 200,14 @@ handleJoinPartRoom db toVitelity toComponent existingRoom from to tel payloads j
			else
				code "201" status

		when (null code201) $ do
			writeStanzaChan toVitelity $ mkSMS tel (mconcat [fromString "* You have joined ", bareMUC, fromString " as ", resourceFrom])
			presence <- fmap (fromMaybe [] . (readZ =<<)) (TC.runTCM $ TC.get db (T.unpack bareMUC <> "\0presence"))
			writeStanzaChan toVitelity $ mkSMS tel $ fromString $ "Group participants: " <> intercalate ", " presence
		presence <- fmap (fromMaybe [] . (readZ =<<)) (TC.runTCM $ TC.get db (T.unpack bareMUC <> "\0presence"))
		when (null code201 && not (resourceFrom `elem` presence)) $
			writeStanzaChan toVitelity $ mkSMS tel (mconcat [
				fromString "* You have joined ", bareMUC,
				fromString " as ", resourceFrom,
				fromString " along with\n",
				intercalate ", " (filter (/= resourceFrom) presence)
			])

		queryDisco toComponent room to
	| not join,