da487d20b4087993f9b6cd745235d528266f22f2 — Stephen Paul Weber 7 months ago 31c95ca
Only store muc_membersonly if True

The default is False anyway if not present.

This handler is overbroad and catches any disco#info that isn't caught
elsewhere, but assumes this must be a result from a MUC.  That was probably true
when this was written, but it's certainly not safe and we can see in the DB that
there are muc_membersonly keys set to False for non-MUC JIDs.  This change is
safe and not invasive but will cut down on DB contents at least.
1 files changed, 4 insertions(+), 2 deletions(-)

M Main.hs
M Main.hs => Main.hs +4 -2
@@ 1142,8 1142,10 @@ componentStanza (ComponentContext { db, componentJid, sendIQ }) (ReceivedIQ (IQ 
	| [query] <- isNamed (fromString "{http://jabber.org/protocol/disco#info}query") p = do
		let vars = mapMaybe (attributeText (fromString "var")) $
			isNamed (fromString "{http://jabber.org/protocol/disco#info}feature") =<< elementChildren query
		let muc_membersonly = s"muc_membersonly" `elem` vars
		DB.setEnum db (DB.byJid from ["muc_membersonly"]) muc_membersonly
		if s"muc_membersonly" `elem` vars then
			DB.setEnum db (DB.byJid from ["muc_membersonly"]) True
			DB.del db (DB.byJid from ["muc_membersonly"])
		return []
componentStanza _ (ReceivedIQ (iq@IQ { iqType = IQGet, iqFrom = Just from, iqTo = Just to, iqPayload = Just p }))
	| not $ null $ isNamed (fromString "{urn:xmpp:ping}ping") p = do