Is there a way to determine which Mulit User Conferences (MUC) a user has joined?

≡放荡痞女 提交于 2019-11-30 14:37:50

As mentioned by Joe Hildebrand, there is no such a standard feature as it is a privacy violation to allow that over XMPP, so you cannot expect to do that from Smack. Maybe with admin privilege you could have a custom protocol extension that does that but that seems risky.

However, at the server level, you should be able to write a custom module for ejabberd that will query or index all rooms users are in. This is not standard and there is plugin development involved.

There are two (maybe three) XMPP entities that have that information:

  • the XMPP MUC component which provides the MUC room
  • the users XMPP client (or better the XMPP library used by the user)
  • maybe the XMPP server(s) (but let's ignore that)

At the time of writing this, there is no standardized way (in terms of XMPP XEPs) to query that information. As Joe Hildebrand pointed out, this would result in a information leak which is not what we want in most cases.

But you can either extend the MUC component to provide that information (remember XMPP is easily extendable) or the XMPP client library. The usual approach would be via an iq get query. For example:

<iq type='get' from='juliet@capulet.lit/balcony' to='capulet.lit' id='q1'>
  <query xmlns='http://jabber.org/protocol/muc#joinedrooms'/>
</iq>

The entities which support that query would then report back the joined rooms of the requested entity. Also they would may announce the http://jabber.org/protocol/muc#joinedrooms feature in their service discovery information.

Note that this is a fictional protocol extension meant as example. I have never seen it in real use

If the MUC component provides this feature then it's not controllable by the client if this information is exposed. But if the client provides this feature then of course he can control who can retrieve this information. You may decide what's the better approach in your case.

Carsten

Getting all chat rooms is no problem, just use this query.

There seems to be already a question on how to retrieve rooms with smack. Look here.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!