4
openfire 4.0.2
https://github.com/igniterealtime/REST-API-Client

I am using the REST API Client to add a user to a room. Looking at the debug information it seems to return success 201. However, the user is not added to the chat room.

1 > POST http://10.10.20.160:9090/plugins/restapi/v1/chatrooms/coffeeroom/members/steve@localhost.localdomain  
1 > Authorization: Basic YWRtaW46Zm9ydW0xOA==  
1 > Content-Type: application/xml  

Apr 06, 2016 12:31:51 AM org.glassfish.jersey.filter.LoggingFilter log  
INFO: 1 * Client response received on thread http-nio-8080-exec-2  
1 < 201  
1 < Access-Control-Allow-Credentials: true  
1 < Access-Control-Allow-Headers: origin, content-type, accept, authorization  
1 < Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS, HEAD  
1 < Access-Control-Allow-Origin: *  
1 < Content-Length: 0  
1 < Date: Tue, 05 Apr 2016 17:31:51 GMT  
1 < Expires: Thu, 01 Jan 1970 00:00:00 GMT  
1 < Set-Cookie: JSESSIONID=153sgnfp1oi1x16rjo68kvbwz8;Path=/;HttpOnly  
1 < X-Frame-Options: deny  

I have successfully created new group chat rooms using the REST API, but can't add any users into them. Using this code.

mRestXmppClient.getRestApiClient().addMember(roomName, username);

Just wondering for this to work do I need to add any particular setting for the users, rooms, roles to add a user into a chat room?

Under Permissions (Room Affiliations) I have added steve@localhost.localdomain to the members of this room. enter image description here

However, I am still not able to add a member to the group chat room. Am I missing something here? I am wondering if there is any settings that I need to modify for the room to get this to work. These are the properties of the room I am trying to add a member to.

enter image description here

Any extra help would be grateful.

ant2009
  • 27,094
  • 154
  • 411
  • 609
  • Is the problem that the REST API request don't add the "steve@localhost.localdomain" to room members list (which you added manually later?), or that the user "steve@localhost.localdomain" can not join the room later via XMPP? – Roman S. Apr 27 '16 at 12:43
  • Problem cannot join the room. First: I added steve@localhost.localdomain manually using openfire admin console. Then I used the REST API from my java app to try and add steve@localhost.localdomain to the room. The result returns 201, but steve is not been added to the room. Any ideas? – ant2009 Apr 28 '16 at 04:47
  • You can also not join the room, if it's not a "member-only" room? – Roman S. Apr 28 '16 at 08:38
  • In the screen shot for the room properties I have checked the 'Make Room Members-only' So I think I should be able to enter this room. Is there anything else I am missing? – ant2009 Apr 28 '16 at 09:05
  • I mean, if you uncheck the "members only", everyone can join the room. Does this work? – Roman S. Apr 28 '16 at 09:39
  • I have unchecked the 'members-only' This does not work. I hope that you can give more ideas about this. thanks. – ant2009 Apr 29 '16 at 06:35
  • If it even don't work without "members-only", which means the room is public and everyone can join it. It has nothing to do with REST API Plugin or even configuration of room permissions. Probably the problem is that your client can not join the room or connect to the server. – Roman S. May 03 '16 at 11:45
  • The client can connect to the the openfire as I can create room, create users etc. The only thing I can't do is add existing users to the room that I have created. When I try and add a user to the room I always get the response code 201. – ant2009 May 03 '16 at 14:39
  • 201 means, the user was successfully added – Roman S. May 03 '16 at 14:40
  • If 201 means that the user was successfully added to the room. However, when I click on the group chat rooms in openfire the room that I added the user too has zero occupants inside. – ant2009 May 03 '16 at 16:05

1 Answers1

6

I guess you misunderstood the flow/design how it works. By adding a user e.g over REST API to a member/admin/outcast/owner list does NOT mean the user will be placed there as an occupant with this role/affiliation.

It means the user have only follow affiliation (be a normal member or admin etc.). Really good overview about MUC XMPP terms is the XEP: http://xmpp.org/extensions/xep-0045.html#terms-general

If you want to be an occupant, you need to connect to the server and also join the channel. After that you will present as an occupant with probably specific role.

I would recommend you to read more about Multi User Chat here: http://xmpp.org/extensions/xep-0045.html

Roman S.
  • 1,206
  • 15
  • 24
  • I understand what you mean. I thought this function restApiClient.addMember("chatroom1", "username"); would make 'username' join the room as an occupant. Is it possible for the REST API to have this feature to allow someone to join the room as an occupant? – ant2009 May 04 '16 at 09:24
  • There is no way to do that with the REST API plugin. What you need is e.g. https://www.igniterealtime.org/projects/smack/ – Roman S. May 04 '16 at 09:29