Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Discovering members of MUC room as occupant

As an occupant/member, I need to know all the "members" in the room with ejabberd-14.x

I followed http://xmpp.org/extensions/xep-0045.html#getmemberlist

I got forbidden (401) for following stanze - Admin privilege required

<iq from='[email protected]/desktop'
    id='member3'
    to='[email protected]'
    type='get'>
  <query xmlns='http://jabber.org/protocol/muc#admin'>
    <item affiliation='member'/>
  </query>
</iq>

If I change

<query xmlns='http://jabber.org/protocol/muc#admin'> 

from admin to user namespace, then I get status code 501 - Feature not implemented

Would you know how can I get members of a room as an occupant or member?

I am not an admin/moderator in this use case.

XEP-0045 does say:

Note: A service SHOULD also return the member list to any occupant in a members-only room; i.e., it SHOULD NOT generate a error when a member in the room requests the member list. This functionality can assist clients in showing all the existing members even if some of them are not in the room, e.g. to help a member determine if another user should be invited. A service SHOULD also allow any member to retrieve the member list even if not yet an occupant.

like image 557
GJain Avatar asked Dec 10 '14 04:12

GJain


1 Answers

You need to be at least a member yourself to access the affiliation list. It doesn't matter whether or not you are currently an occupant (ie. in the room).

Note that an affiliation (such as "member") is a persistent setting that needs to be explicitly given to people, who default to "none" otherwise. In a normal unrestricted room, this setting doesn't have any other effect than allowing you to retrieve the member list. The member list is unrelated to the occupant list.

(If you merely want to know who is currently in the room, you should send a query with the namespace http://jabber.org/protocol/disco#items instead of muc#admin.)

Example (just tried on my ejabberd server). Attempting to query the list with an unaffiliated account:

<iq from='[email protected]/desktop'
    id='member3'
    to='[email protected]'
    type='get'>
  <query xmlns='http://jabber.org/protocol/muc#admin'>
    <item affiliation='member'/>
  </query>
</iq>
<iq from='[email protected]'
    to='[email protected]/desktop'
    type='error'
    id='member3'>
  <query xmlns='http://jabber.org/protocol/muc#admin'>
    <item affiliation='member'/>
  </query>
  <error code='403' type='auth'>
    <forbidden/>
    <text>Administrator privileges required</text>
  </error>
</iq>

Using a privileged (room owner) account to grant that first account member privileges:

<iq from='[email protected]/desktop'
    type='set'
    to='[email protected]'
    id='member4'>
  <query xmlns='http://jabber.org/protocol/muc#admin'>
    <item jid='[email protected]' affiliation='member'/>
  </query>
</iq>

<iq to='[email protected]/desktop'
    from='[email protected]'
    type='result' id='member4'/>

Trying again:

<iq from='[email protected]/desktop' 
    type='get'
    to='[email protected]'
    id='member5'>
  <query xmlns='http://jabber.org/protocol/muc#admin'>
    <item affiliation='member'/>
  </query>
</iq>

<iq to='[email protected]/desktop'
    from='[email protected]'
    type='result'
    id='member5'>
  <query xmlns='http://jabber.org/protocol/muc#admin'>
    <item jid='[email protected]' affiliation='member'/>
  </query>
</iq>
like image 129
Christoph Burschka Avatar answered Oct 20 '22 08:10

Christoph Burschka