Information messages in XMPP MUC - xmpp

I'm looking for system that let me to put aditional system messages in MUC. For example 'chat room has been created', 'user1 has added user2' or 'user1 has left the room' etc. What is the best solution for that kind of messages?
Thanks

Related

strophe js MUC room

I have created room from desktop client. And want to send message and receive messages on this room using strophejs. I have already set muc plugin, but I don't see any documentation of it.
1) how to subscribe on messages in room
2) how to send messages to room
First, read http://xmpp.org/extensions/xep-0045.html if you haven't already.
By joining a room, you should get the messages, when sending messages, you send the message to the room jid instead of an individual.
To join a room (after attaching/connecting to jabber server):
connection.muc.join(room, nick, msg_handler_cb, pres_handler_cb,
roster_cb, password, history_attrs);
room is the jid of the room and nick is your nickname.
You will need to write callback functions for handling the messages, rosters and presences (msg_handler_cb, pres_handler_cb,roster_cb). Password can be null if one is not required. Your history attributes define things line maxstanzas, which define how far back to get messages when loading.

How to get mucroom offline messages

How to retrieve mucroom offline messages from openfire and any plugin available for this one?
Thank you,
You cannot. Multi User Chat in XMPP is presence based. When you are online you get the message. When you get offline, you leave the room and will not get anymore message until you join the room again by sending a presence message.
Update: With ejabberd 16.09, you can now use MUC/Sub protocol to subscribe to chat rooms. When subscribed, you do not have to join the room again to receive the messages. Protocol is documented here: https://docs.ejabberd.im/developer/xmpp-clients-bots/proposed-extensions/muc-sub/

Delivering messages to offline users in a multi-user chat (ejabberd)

Actually we are using ejabberd server for one of our client's Chat application. Everything is working well except for Group chat.
We are using MUC for Group chat but it is not sending Messages to the member whenever uses is offline. Is there any alternative plugin or something where we can make that working?
Or any one can suggest about how to receive offline messages for that user from Group chat history.
Thanks in advance
That's because there's no such concept for multi-user chat rooms. In fact, if you'll think about this a bit more you'll understand why:
Potentially unbound number of participants might be present in a room at any given time.
So exactly for which users not currently present in the MUC room should the server store the messages in the offline storage? I mean, in the generic case, the server does not know all the users who could ever possibly chat in a given room it hosts.
(Well, if this would be the only problem, it could possibly work for members-only rooms, I must admit.)
MUC rooms are not "local server only": a potentially unbound number of users from any number of other servers might join the room, and messages to those users will be delivered by routing them via their respective servers.
Obviously, this is another reason why such an idea of "MUC room offline storage" has no sense.
MUC rooms are by definition transient: when a user is offline, they're not in any room— (re-)joninig a room is an explicit action.
This is in fact the most important reason for not supporting offline storage.
As you can see, XMPP MUC rooms are much like IRC chats on steroids.
So what you really want is "room history"—a part of the XMPP-0045 extension which allows the client to explicitly ask the room for the message history they missed. In a sense, instead of storing offline message for each user, the room might be configured to store just a certain number of the most recent messages sent to it (or all such messages for a given period of time). Then the room supports querying these messages by the joined users.
There's another possibility which you might explore: "multicast addressing" of XEP-0033 ("Extended stanza addressing"). Basically it allows a client to use a special multicast service to send their message to multiple recipients at once. The upside is that offline storage is there again. The downside is that I doubt such a multicast service is supported out of the box in ejabberd, and it seems like that extension leaves much details about how it could be implemented unspecified.
I faced your issue as I sought to implement groupchats for my chatting app. I faced the same problem of MUC not storing offline messages for each recipient. And I did not want to retrieve MUC history which requires the user to rejoin every MUC to update his messages database. What I wanted is for the server to save offline messages by recipient, and for the recipient to get all MUC messages when he gets online (without having to join each MUC).
The way I did it is through pubsub. Using pubsub will force the server to store offline message per recipient. When the user reconnects, he gets all the offline messages including the pubsub messages which are sent as normal messages - that is it. One issue I had with pubsub over MUC though is that it is hard to get the list of subscribers. So when my app creates a groupchat, it creates a pubsub node for messages, invite all participants to subscribe (including self) to the pubsub and my app also creates a MUC and makes every participant an owner of that MUC. This way the list of the groupchat participants can be retrieved by checking the list of owners of the MUC. The only purposes of the MUC are to hold the list of participants as well as the name of the groupchat. Everything else is handled by the pubsub node.
Anything unclear please let me know.
ADDITIONAL DETAILS:
Essentially when the user wants to create a groupchat, our app creates a pubsub node as well as a MUC. You need to be familiar with both concepts. For the pubsub node, you need to set an option to allow any subscriber to post. When a user sends a message, he actually publishes on the node, and ejabberd will send the message to all subscribers as if it were a regular message (except it comes from pubsub.yourdomain.com). Therefore if a recipient is offline, ejabberd will store this message as any other regular message.
This is not how ejabberd handles MUC messages. Those are only sent to people CURRENTLY in the chatroom. History of messages can be stored by ejabberd however, but for a recipient to get the history he will need to join the MUC. Which means that everytime the app reconnects, it would have to join all the user's existing MUCs. We found this was not practical.
We also use a MUC for the same groupchat, but this is only to store participants so that a user can get the list at any time (no way to do it with pubsub).
An additional benefit of using pubsub over MUC is that the way ejabberd stores pubsub data is way more efficient. I have not studied this in depth, but I expect much better performance from pubsub.
New ejabberd server at 16.09 version have improvements for multi-user chat - MUC Sub:
The goal of MUC Sub is to try to rely as much as possible on existing MUC specification, while making the smallest possible change that make mobile group conversation client easy.
The feature is enabled by default. To use it, just make sure you set the new parameter “Allow subscription” in the room on which you want to use it.
Here is link to documentation: https://docs.ejabberd.im/developer/proposed-extensions/muc-sub/
More info here: https://blog.process-one.net/xmpp-mobile-groupchat-introducing-muc-subscription/

XMPP receive history without rejoining the MUC

Suppose A has already joined into the MUC. At the time of join A will receive complete history. But after that is there any way for A to receive the complete history any number of times by doing some query to MUC.
Leaving and Rejoining the MUC is not acceptable. :(
I have seen How to re-request room roster and history from a muc in ejabberd
But the last comment with is not working for me.
Please help me, if this is even possible or not. If yes can you give me the stanza that needs to be sent to muc. BTW I am using smack API and openfire
Thanks,
Nitiraj

How can I stop my XMPP MUC messages from echoing back to me?

I'm writing a bot to log a MUC XMPP channel. This bot sends messages sometimes, and MUC echoes these messages back to it. How can I disable this behavior to prevent it from messing with the logs?
There's no way in the spec (http://xmpp.org/extensions/xep-0045.html) to send a message to everyone BUT yourself. I would recommend modifying your bot to check the sender JID for all inbound messages and discard any messages coming from your bot's occupant JID.
XEP-0016
http://xmpp.org/extensions/xep-0016.html
privacy lists: learn it, love it, live it
Create list_home for use at home to exclude employee chitter, apply list_work to prevent your children from pestering you, apply list_weekendall to constrain interaction to close personal friends.
XMPP texting is more powerful than legacy sms texting plus xmpp = $0 texting. It's not-smart to pay to sms text on a smart phone. It's equally foolish to tolerate malware of the adware variety posing as freeware offering "Free" texting.
privacy lists control which flavor of subscribed information roster members may view. It's far simpler than unsubscribe/resubscribe the privacy list naive attempt.
Your specific use case avails (http://xmpp.org/extensions/xep-0016.html#protocol)
"blocking messages based on JID, group, or subscription type"