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

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"

Related

Do two clients have to be subscribe to each other's presence in order to exchange messages in XMPP?

I have read the following doc but somewhat confused between message sending, sending presence and subscription.
https://xmpp.org/extensions/xep-0162.html#intro
Specifically, do two users have to subscribe to each other's presence to exchange messages?
Short answer: No
Presence subscription (usually) is just a way to control which entities can see your presence status. The exchange of message stanzas is not affected but the subscription status (if techniques like "Privacy Lists" are not used).

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/

jabber-net and vysper message broadcast facility

I have establish chat communication between two users using jabber-net xmpp client and vysper server by apache.
I am looking for broadcast facility using the same.
There are different mechanisms for "broadcasting", a word which I understand as "sending one message which is distributed by the server to many receivers".
When a user changes his "status" (for example "do not disturb me - I'm coding") a so call "presence" message is sent out which is distributed to all his contacts. This is a broadcast, and presence messages are intended to do that in XMPP.
There is at least another popular possibility: multi-user chat ("MUC"). MUC has the notion of "rooms", where users can "enter" to become part of a "conversation". Every message sent by one of the participants is sent to all others.
There are more similar mechanisms available, depending on what you actually want to do.

Implementing something like Google Groups (the email part)

if I wanted to create an "email list" along the lines of google groups (and eventually integrate with a web site), what services should I look into? I haven't really dealt with email before so I'm not 100% sure how it all works. I do know I need to be careful about being blacklisted, etc. Do I use something like sendgrid/mailman? I imagine all emails go to my server when a user hits "reply all" and on my end I push that email as though it came from the user but really it came from my "mail" server? It seems a user doesn't need to "reply all" to send to the list and there is no quick way to reply to just one user (which is a good thing for this app).
So the way I imagine this working:
1) I use something like sendgrid to "listen" for emails coming to list#mywebsite.com
2) When emails come (i.e from userx) I do some filtering for spam, etc and then push them all out to "all users/subscribers"
3) All users get something that is "from user x" (but it's really from my server, on google groups it says "via googlegroups") and the "reply to" is list#mywebsite.com
I imagine this is how it all works but I'm not 100% sure this is correct or if sendgrid will allow me to do this (and if it will cost too much).
Thanks
It really depends on what your needs and skills are. For simple mailing lists there is some very established software such as ListServ or MajorDomo
If you're not running a Unix variant, or you're not confident setting up this kind of software they might not be suitable though.
You can use SendGrid to handle your incoming email, but you will have to re-assemble the message before sending it out since it will be posted to your incoming parse URL in a, well, parsed way. The good news is that SendGrid can handle the spam check for you.
SendGrid currently doesn't charge for inbound parsing, but of course that may change. So as far as your cost goes, you would only use credits for the mail you send. Keep in mind that SendGrid only provides the Parse API to silver ($80/mo) customers or customers on the free (200 emails/day) plan, but there are plans to add a lower tier package that also has access to all APIs.
You can also use SendGrid to handle unsubscribes, but if you are using another solution for list management that's probably superfluous.
Googling for "mailing list hosting" brings up a wealth of sites, some of them free at least under some conditions. Many of them will use something like Mailman / Majordomo / Listserv; certainly you can run Mailman or Majordomo on your own server if you like, as well, so your question doesn't really make sense from that point of view. Yahoo Groups / Google Groups can also happily host a list for you. Do you need the list to be visible to subscribers only? Google Groups and Yahoo Groups will host private lists, too.
A mailing list basically works like Bcc: mail. You send to the mailing list's submission address; it then replaces some of the headers (often the Sender: and perhaps Reply-To:) and then redistributes the message to all the subscribers. Behind the scenes, it might rewrite some headers to make sure bounce messages come back to the list software for further handling (for example, to automatically unsubscribe addresses which consistently return a bounce), and often, it distributes the message with some delay in order not to saturate the outgoing bandwidth and/or choke a receiving server; though some parts of this are also handled by the regular mail transport agent (MTA -- Postfix or Sendmail or what have you).
You might look at ezmlm
EZmlm-idx is a nice mailing list add-on to Qmail. When we install Qmailadmin later on, you'll see that EZmlm-idx integrates seamlessly into Qmailadmin to provide a very user friendly mailing list management interface. As an added bonus, Vpopmail (which we will install as well) will let you control what users can and cannot use mailing lists!
Quoted from qmailrocks
You do not need to worry about sendgrid. Just get a cheap vps,configure DNS and, install MTA(postfix,qmail,sendmail) imap(courier,dovecot), a modern listserve, and let it do it's magic! On the lists where I am subscribed , I have the option to reply to a post, or the whole group.

How should one handle sending xmpp welcome messages when users subscribe to bot (in general)

As the title says, I would like to send a welcome message when a user subscribes to a bot.
However, as I understand it, presence subscribe stanzas should not contain a from-JID that includes resource (and my testing with Adium indicates that is also the case). That is, welcome message could easily be sent to the bare JID but is that really the right way to do it? It feels like it should be sent to the actual instance where the subscription originated.
Perhaps I'm seeing a problem where there is none? If not, any ideas on how to solve it?
Do not fear sending a message to a bare JID. Almost all the time this is what you want. The user may already have a fantastic system in place using priority to get the answer at the right device, like a blackberry, their home jabber client, the one at work, and so on. Heck, they may have sent the request from their blackberry that has a 0 priority, and they want to get the answer back at their desk.
Just send a message stanza with a type of headline, since you don't want them to reply to the notice.
The things said about messages are all right.
If you care about whom to send presence subscribe stanzas to, I wonder whether you really know resources at that time. IIRC, resources are stripped off before forwarding presence subscribes and I assume that you are responding to them. Furthermore, the bot wants to be informed about all presences, so subscribing to the bare jid is the right thing to do.