Conversejs groupchat subscriptions (ejabberd)

266 views Asked by At

I have been struggling to configure a group chat using conversejs and ejabberd. From the documentation I've stumbled across, it seems like it is possible to have a persistent group chat that users can be subscribed to, which will allow them to receive messages from the group chat while not present in the group chat.

For example: I would like to be able to simply close the group chat on my conversejs client, but still get notifications from that group chat.

This is a fresh ejabberd 21.04 and conversejs 7.0.6 install (using websockets).

What I tried to do was create a room through the conversejs client, and then add a subscription through the ejabberd cli: ejabberdctl subscribe_room [email protected]/muc user [email protected] urn:xmpp:mucsub:nodes:messages

One of the things I'm most confused by is the field in the configuration panel of a group chat that is titled "XMPP URI of Associated Publish-Subscribe Node." I have no clue how to format this, but have found a few clues online... What I have tried is a number of different configurations of something like: xmpp:my.example.com?;node=messages but I'm really just grasping at straws here.

If anyone can help me figure out what I'm doing wrong with this URI, or can show me a working example of this, that would be amazing. If what I'm trying to do simply isn't possible with XMPP, please let me know as well.

Thanks!

1

There are 1 answers

0
Badlop On

it is possible to have a persistent group chat that users can be subscribed to, which will allow them to receive messages from the group chat while not present in the group chat.

Exactly.

ejabberdctl create_room room1 conf.localhost localhost

ejabberdctl change_room_option room1 conf.localhost persistent true

ejabberdctl change_room_option room1 conf.localhost allow_subscription true

ejabberdctl subscribe_room user1@localhost User1 [email protected] urn:xmpp:mucsub:nodes:messages

Now I'll use the send_message API call to send a message to the room. This requires the sender to be online, so for this example register and login to admin@localhost. And of course, login to user1@localhost to receive the notification from the room. Those clients do not need to join the room.

ejabberdctl send_message groupchat admin@localhost [email protected] Sub Body