Get members nickname of MUC Room

2019-04-10 05:20发布

问题:

Is there a way to get all nicknames of a MUC Room with an ejabberd server?

I'm trying with:

<iq from='crone1@shakespeare.lit/desktop'
  id='member3'
  to='coven@chat.shakespeare.lit'
  type='get'>
  <query xmlns='http://jabber.org/protocol/muc#admin'>
   <item affiliation='member'/>
  </query>
</iq>

but I obtain only jid without nicknames:

<iq from='coven@chat.shakespeare.lit'
  id='member3'
  to='crone1@shakespeare.lit/desktop'
  type='result'>
  <query xmlns='http://jabber.org/protocol/muc#admin'>
    <item affiliation='member'
      jid='hag66@shakespeare.lit'
      role='participant'/>
  </query>
</iq>

回答1:

On 6.5 Querying for Room Items from XEP 0045 when you send

<iq from='$user-name@$user-server/$user-resorce'
    id='someid'
    to='$chat-room-to-query@$chatserver'
    type='get'>
  <query xmlns='http://jabber.org/protocol/disco#items'/>
</iq> 

You have the following description

An implementation MAY return a list of existing occupants if that information is publicly available, or return no list at all if this information is kept private.(emphasis mine)

if the room is public them you get

<iq from='$chat-room-to-query@$chatserver'
    id='someid'
    to='$user-name@$user-server/$user-resorce'
    type='result'>
  <query xmlns='http://jabber.org/protocol/disco#items'>
    <item jid='$chat-room-to-query@$chatserver/$firstnick'/>
    <item jid='$chat-room-to-query@$chatserver/$secondnick'/>
    <...>
  </query>
</iq>

From my knowledge ejabberd implements this correctly.