0
votes

What command helps to do that via ejabberd rest-api? From xmpp-client log such command sending:

<iq id="60fe7dd6-82c3-49de-a5a1-f1f71bce6e92" to="[email protected]" type="set">
    <query xmlns="http://jabber.org/protocol/muc#admin">
        <item nick="[email protected]" role="visitor"/>
    </query>
</iq>

Ejabberd version is 20.xx. And i want to say this opportunity works great at swift client connected to our ejabberd service. Just click 'revoke voice' and that user becomes 'visitor' and can't send messages. But I can't do that even via xmpp client smack sdk:

XMPPTCPConnectionConfiguration config = XMPPTCPConnectionConfiguration.builder()
.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled)
.setXmppAddressAndPassword(JidCreate.entityBareFrom("[email protected]"), "123")
.setHost("example.com")
.setPort(5222)
.build();
AbstractXMPPConnection connection = new XMPPTCPConnection(config);
connection.connect();
connection.login();
MultiUserChatManager mucManager = MultiUserChatManager.getInstanceFor(connection);
MultiUserChat muc = mucManager.getMultiUserChat(JidCreate.entityBareFrom("[email protected]"));
muc.revokeVoice(Resourcepart.from("User2"));

an Exception after trying:

org.jivesoftware.smack.XMPPException$XMPPErrorException: XMPP error reply received from [email protected]: XMPPError: not-allowed - cancel [Changing role/affiliation is not allowed]

But '[email protected]' has admin permission and room '[email protected]' has 'moderated' option in true.

Does anyone know how to do that via api for example via send_stanza?

1
Update your question explaining this: What ejabberd version did you install? What mod_muc configuration do you have? What chapter of xmpp.org/extensions/xep-0045.html do you want to perform?Badlop
The question was updated. I want to perform 'revokevoice' option of xep-0045 xmpp.org/extensions/xep-0045.html#revokevoice.kasim

1 Answers

0
votes

<item nick="[email protected]" role="visitor"/>

Are you sure this works? This tells ejabberd that the nick to revoke voice is "[email protected]", but that is not a nick, it's the user JID. How can that work?

The example in https://xmpp.org/extensions/xep-0045.html#revokevoice shows that te nick is... a nick:

<item nick='thirdwitch' role='visitor'/>


I tried with my desktop Jabber client, Tkabber, and it sends the occupant's nick in the nick field.

When I send the occupant JID in the nick field, then I get the same error message that you mentioned.

I don't know about the library and language that your are using, but this smells wrong:

muc.revokeVoice(Resourcepart.from("User2"));

I imagine here you must provide the occupant's nick, and that may not be the resource part of the occupant JID.


For example, when my client joins the room, it sends this stanza:

<presence id='71:576798'
    from='[email protected]/tka1'
    to='[email protected]/troller'>
  <show>xa</show>
  <status>Busysss</status>
</presence>

Occupant full JID: "[email protected]/tka1", which has as resource: "tka1", and joins the room with the nick "troller".

In this example, when a room admin wants to revoke voice to that occupant, the admin client must send this:

<iq id='50:565577'
    type='set'
    to='[email protected]'>
  <query xmlns='http://jabber.org/protocol/muc#admin'>
    <item nick='troller'
    role='visitor'/>
  </query>
</iq>