Project

General

Profile

Send message stanza on behalf of a user

Matthew M
Added over 5 years ago

We would like to implement a module and API which enables the user to send message via email to a JID, especially to a MUC room. The module can properly parse the incoming email and handle the user identification.

Is there a recommended way to programmatically send a message stanza to a jid via Tigase? I wonder if there is already some similar API or plugins, is RestMessageReceiver something I should look into? Or if we need to write our own plugin, do you have any recommendation?

Best of all, not sure if there is any XMPP spec or approach to deal with this send-message-on-my-behalf case...

Many thanks!


Replies (10)

Avatar?id=6023&size=32x32

Added by Artur Hefczyc TigaseTeam over 5 years ago

There are no spec for this. But there are a few ways to do this in Tigase. The main question is how much traffic you want to handle this way. Because there are quite simple ways to do it but do not offer a high performance.

For example you can inject a packet to the Tigase on behalf of any user using administrator ad-hoc command. So basically a simple working solution could consist of a comment line mail filter script which could analyze email and then forward it to XMPP using, for example our Tigase comment line management tool. The tool can connect as an admin to Tigase and submit a message for a final delivery.

This would work without any problems but I do not think it could handle a high volume of emails to XMPP that way.

Added by Matthew M over 5 years ago

This is nice, we only have low volume for now so this could be perfect... would you give us a bit of example command line usage or examples so that I can look into it?

Two examples

  1. send a regular message

  2. add a buddy

Another question is how reliable it is, or will we get a confirmation at the end that "message is delivered", for example, a shell return value that we can evaluate?

Many thanks!

Avatar?id=6023&size=32x32

Added by Artur Hefczyc TigaseTeam over 5 years ago

The admin ad-hoc command are based on scripting. There are scripts for many tasks already. Updating user's roster is also implemented. There is no script for sending a message, however, based on existing code it should be not very difficult to implement a new script for this task.

Here is a link to the command line tool: https://projects.tigase.org/projects/tclmt

The wiki page contains examples and documentation.

Added by Matthew M over 5 years ago

Thank you!

Added by Matthew M over 5 years ago

I am trying to run the command line connecting to Tigase 5.2 beta 3, but unable to do any operation yet. The following is the sample error from the command line tool, I am trying to "get-user-roster"

bin/tclmt.sh -u bigname@company.com -p 123 -ip localhost -i
INFO: Create empty DB.
Tigase XMPP Server Command Line Management Tool - ver. 1.0.0-SNAPSHOT
$: get-user-roster
Users jid:bigname@company.com
awaiting response...
Error executing script get-user-roster
    java.lang.NullPointerException: Cannot invoke method getChildrenNS() on null object

I don't see any useful logs on the server side. Is there anyway to test the command line tool against official tigase.im server?

Thanks!

Added by Wojciech Kapcia TigaseTeam over 5 years ago

Which version of TCLMT are you using? (distribution package? self compiled from repository?).

You can try enabling debug with -debug flag, ie.:

bin/tclmt.sh -debug -u bigname@company.com -p 123 -ip localhost -i

Added by Matthew M almost 5 years ago

Just in case if there is relatively high volume, what's the best way to solve this problem?

This would work without any problems but I do not think it could handle a high volume of emails to XMPP that way.

Let's assume the "email parsing part" is efficient, do you mean the admin ad-hoc script command is not efficient, because it has to "login as an admin"? What would be an alternative solution?

I am not familiar with XMPP Gateway, and not sure if the gateway is applicable in this situation, such as a email-to-xmpp gateway?

Or should we write a customized plugin let Tigase post message to a buddy on behalf of a user?

Thanks!

Avatar?id=6023&size=32x32

Added by Artur Hefczyc TigaseTeam almost 5 years ago

The inefficient part is "executing ad-hoc command through a command line tool". More specifically, I mean, if you would have to run the tool from a command line each time for each single message. Much more efficient way would be to have your "email parsing part" to run as a process with is in memory and working all the time (not started for each message) and if this part is connected to the Tigase all the time. Then sending an ad-hoc command to forward email as XMPP message is very fast.

So in other words, the whole overhead for starting a command line tool and/or connecting to XMPP server, authenticating is relatively long process, not suitable for a high number of messages.

Permanent XMPP connection between the email parsing part and Tigase would be very efficient, even much better that REST calls which is also supported by Tigase.

Added by Matthew M almost 5 years ago

Permanent XMPP connection between the email parsing part and Tigase would be very efficient

This is great. I am a little curious about the logics behind the scene... Let's say the email-parser is process always running, and establishes ONE permanent XMPP connection as a special user, e.g, "admin". Is this true that the "admin" user can send messages on behalf of many "different" users? Is this logic done in tigase server code, or is it somewhere in the script? Which java class should l look into?

Our use case is very simple: we allow any users to reply to a some email address to "send" a message to a (room) chat. So will one persisted xmpp connection meet this requirement of "many" different users?

By the way, I did not find any update-roster script, only get-roster from here:

https://projects.tigase.org/projects/tclmt/repository/revisions/master/show/src/main/groovy/tigase

Avatar?id=6023&size=32x32

Added by Artur Hefczyc TigaseTeam almost 5 years ago

Matthew M wrote:

[...]

This is great. I am a little curious about the logics behind the scene... Let's say the email-parser is process always running, and establishes ONE permanent XMPP connection as a special user, e.g, "admin". Is this true that the "admin" user can send messages on behalf of many "different" users?

Yes, this is true. Admin can do anything.

Is this logic done in tigase server code, or is it somewhere in the script? Which java class should l look into?

Ad-hoc commands are implemented as Groovy scripts. There is quite a few already implemented in Tigase XMPP Server source code: https://projects.tigase.org/projects/tigase-server/repository/revisions/master/show/src/main/groovy/tigase/admin

Use them as an example. There is a command which sends a message to all online users. I think it might be a good starting point for your own ad-hoc script.

Our use case is very simple: we allow any users to reply to a some email address to "send" a message to a (room) chat. So will one persisted xmpp connection meet this requirement of "many" different users?

Yes.

By the way, I did not find any update-roster script, only get-roster from here:

https://projects.tigase.org/projects/tclmt/repository/revisions/master/show/src/main/groovy/tigase

Yes, because you are looking in a wrong location. The link above is for the command line tool sources. Please check the Tigase XMPP Server sources at the link given above.

    (1-10/10)