Discovering members of MUC room as occupant
Asked Answered
B

1

8

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.

Baking answered 10/12, 2014 at 4:50 Comment(0)
M
1

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>
Mckinley answered 20/6, 2017 at 8:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.