Wrong boolean value in MUC config Form

Smack version: 4.3.0
Openfire version: 4.2.1
Class: org.jivesoftware.smackx.xdata.Form
method: public void setAnswer(String variable, boolean value)
xep-0045: https://xmpp.org/extensions/attic/xep-0045-1.21.html

After some research I found there is an inconsistent in the Form send by Smack when you are configuring the values of the new room.
The default stanza values send by my OF said (1), for example, that muc#roomconfig_publicroom or muc#roomconfig_persistentroom are boolean and default value is 1 (1 = true).
If you see the stanza smack send when I tried to modify muc#roomconfig_publicroom (2) or muc#roomconfig_persistentroom (3), you will see the boolean value is sent with true instead 1 and as you can see in the screenshoot of chat group settings (4).
As far as I saw, OF didn’t said anything about this, just generating a TimeOut exception (some times, not always), but as you can see in room settings (5) it’s not a publicroom anymore.

After digging in the code I found the method setAnswer in Form class is transforming the boolean value with setAnswer(field, Boolean.toString(value)); that is going to give you the strings “true” or “false”.

My work around at this moment was just set the default values in server side and don’t touch them in app.

@Flow I can create a PR with this if my thought are true :smiley:


(1) Default OF room config values

<iq type="result" id="obJH2-63" from="80409a0aa503eb7a9d69fcfa56bd8e39@testconference.XXXXXXX" to="789518@XXXXXXX/YYYYYY">
			<query
				xmlns="http://jabber.org/protocol/muc#owner">
				<x
					xmlns="jabber:x:data" type="form">
					<title>Room configuration</title>
					<instructions>The room "80409a0aa503eb7a9d69fcfa56bd8e39" has been created. To accept the default configuration, click the "OK" button. Or, modify the settings by completing the following form:</instructions>
					<field var="FORM_TYPE" type="hidden">
						<value>http://jabber.org/protocol/muc#roomconfig</value>
					</field>
					<field var="muc#roomconfig_roomname" type="text-single" label="Room Name">
						<value>80409a0aa503eb7a9d69fcfa56bd8e39</value>
					</field>
					<field var="muc#roomconfig_roomdesc" type="text-single" label="Description">
						<value>80409a0aa503eb7a9d69fcfa56bd8e39</value>
					</field>
					<field var="muc#roomconfig_changesubject" type="boolean" label="Allow Occupants to Change Subject">
						<value>0</value>
					</field>
					<field var="muc#roomconfig_maxusers" type="list-single" label="Maximum Room Occupants">
						<option label="10">
							<value>10</value>
						</option>
						<option label="20">
							<value>20</value>
						</option>
						<option label="30">
							<value>30</value>
						</option>
						<option label="40">
							<value>40</value>
						</option>
						<option label="50">
							<value>50</value>
						</option>
						<option label="None">
							<value>0</value>
						</option>
						<value>0</value>
					</field>
					<field var="muc#roomconfig_presencebroadcast" type="list-multi" label="Roles for Which Presence is Broadcast">
						<option label="Moderator">
							<value>moderator</value>
						</option>
						<option label="Participant">
							<value>participant</value>
						</option>
						<option label="Visitor">
							<value>visitor</value>
						</option>
						<value>moderator</value>
						<value>participant</value>
						<value>visitor</value>
					</field>
					<field var="muc#roomconfig_publicroom" type="boolean" label="List Room in Directory">
						<value>1</value>
					</field>
					<field var="muc#roomconfig_persistentroom" type="boolean" label="Room is Persistent">
						<value>1</value>
					</field>
					<field var="muc#roomconfig_moderatedroom" type="boolean" label="Room is Moderated">
						<value>0</value>
					</field>
					<field var="muc#roomconfig_membersonly" type="boolean" label="Room is Members-only">
						<value>0</value>
					</field>
					<field type="fixed">
						<value>Note: by default, only admins can send invitations in an members-only room.</value>
					</field>
					<field var="muc#roomconfig_allowinvites" type="boolean" label="Allow Occupants to Invite Others">
						<value>0</value>
					</field>
					<field var="muc#roomconfig_passwordprotectedroom" type="boolean" label="Password Required to Enter Room">
						<value>0</value>
					</field>
					<field type="fixed">
						<value>If a password is required to enter this room, you must specify the password below.</value>
					</field>
					<field var="muc#roomconfig_roomsecret" type="text-private" label="Password"/>
					<field var="muc#roomconfig_whois" type="list-single" label="Role that May Discover Real JIDs of Occupants">
						<option label="Moderator">
							<value>moderators</value>
						</option>
						<option label="Anyone">
							<value>anyone</value>
						</option>
						<value>anyone</value>
					</field>
					<field var="muc#roomconfig_allowpm" type="list-single" label="Allowed to Send Private Messages">
						<option label="Anyone">
							<value>anyone</value>
						</option>
						<option label="Moderator">
							<value>moderators</value>
						</option>
						<option label="Participant">
							<value>participants</value>
						</option>
						<option label="None">
							<value>none</value>
						</option>
						<value>anyone</value>
					</field>
					<field var="muc#roomconfig_enablelogging" type="boolean" label="Log Room Conversations">
						<value>1</value>
					</field>
					<field var="x-muc#roomconfig_reservednick" type="boolean" label="Only login with registered nickname">
						<value>0</value>
					</field>
					<field var="x-muc#roomconfig_canchangenick" type="boolean" label="Allow Occupants to change nicknames">
						<value>1</value>
					</field>
					<field type="fixed">
						<value>Allow Users to register with the room</value>
					</field>
					<field var="x-muc#roomconfig_registration" type="boolean" label="Allow Users to register with the room">
						<value>1</value>
					</field>
					<field type="fixed">
						<value>You may specify administrators of this room. Please provide one JID per line.</value>
					</field>
					<field var="muc#roomconfig_roomadmins" type="jid-multi..."></field>
				</x>
			</query>
		</iq>

(2) stanza
Trying to make members-only

<iq to='80409a0aa503eb7a9d69fcfa56bd8e39@XXXXXXX' id='obJH2-65' type='set'>
		<query
			xmlns='http://jabber.org/protocol/muc#owner'>
			<x
				xmlns='jabber:x:data' type='submit'>
				<field var='FORM_TYPE' type='hidden'>
					<value>http://jabber.org/protocol/muc#roomconfig</value>
				</field>
				<field var='muc#roomconfig_membersonly' type='boolean'>
					<value>true</value>
				</field>
			</x>
		</query>
	</iq>

(3) stanza
trying to modify default public room option

<iq to='80409a0aa503eb7a9d69fcfa56bd8e39@XXXXXXX' id='oCF1p-67' type='set'>
		<query
			xmlns='http://jabber.org/protocol/muc#owner'>
			<x
				xmlns='jabber:x:data' type='submit'>
				<field var='FORM_TYPE' type='hidden'>
					<value>http://jabber.org/protocol/muc#roomconfig</value>
				</field>
				<field var='muc#roomconfig_publicroom' type='boolean'>
					<value>true</value>
				</field>
			</x>
		</query>
	</iq>

(4) screenshoot of chat group settings

(5) values of room after smack send roomconfig_publicroom

That is an Openfire bug.

Flow - Is there/should there be a JIRA for it?

Greg

Don’t know. I would simply create one. We can later close it as duplicate if necessary.

@gdt : There is an old issue with it

which refers to OF-785 - status resolved

Btw. we also bumped into this issue, when trying to create a room or search users. I did a quick research on the code, but the code looked ok. Both for OF and for Tinder

One of the sides (smack) or OF should add a cast condition for boolean values right? I mean, is just about to check if a “true” is coming, cast it to boolean or “1”… or in smack do not send “true” … am I wrong?

This issue should be fixed in Openfire 4.3.0. The corresponding issue is https://issues.igniterealtime.org/browse/OF-1513

1 Like