igniterealtime / openfire-restAPI-plugin

Allows Openfire administration over a RESTful API.
http://www.igniterealtime.org/projects/openfire/plugin-archive.jsp?plugin=restAPI
Apache License 2.0
19 stars 53 forks source link

Not specifying primitives can overwrite room config #174

Open Fishbowler opened 1 year ago

Fishbowler commented 1 year ago

Initial state:

curl -s -k -H "Accept: application/json" -X GET \
  -u "myuser:mypassword" \
  https://myopenfire/plugins/restapi/v1/chatrooms/test1?servicename=mucservice \
  | jq . \
  | grep "canAnyoneDiscoverJID"

"canAnyoneDiscoverJID": true,

Then:

curl -X 'PUT' \
  -u "myuser:mypassword" \
  https://myopenfire/plugins/restapi/v1/chatrooms/test1?servicename=mucservice \
  -H 'accept: */*' \
  -H 'Content-Type: application/json' \
  -d '{"roomName": "test1", "description": "test1 Desc Updated"}'

Alters state so that:

curl -s -k -H "Accept: application/json" -X GET \
  -u "myuser:mypassword" \
  https://myopenfire/plugins/restapi/v1/chatrooms/test1?servicename=mucservice \
  | jq . \
  | grep "canAnyoneDiscoverJID"

"canAnyoneDiscoverJID": false,

Suspected caused by this: https://github.com/igniterealtime/openfire-restAPI-plugin/blob/a990316a9a5506fe9b4407274c2a357adc954e1a/src/java/org/jivesoftware/openfire/plugin/rest/controller/MUCRoomController.java#L385

Which calls this: https://github.com/igniterealtime/openfire-restAPI-plugin/blob/a990316a9a5506fe9b4407274c2a357adc954e1a/src/java/org/jivesoftware/openfire/plugin/rest/entity/MUCRoomEntity.java#L186

Because that is a primitive boolean, the default is false - so if a client does not send a value, the value defaults to false, and overwrites, regardless of the existing value. If so, move to using Boolean?

guusdk commented 1 year ago

If so, move to using Boolean?

Agreed.