Re: Email to Jabber
- Zed A. Shaw
- 2009-07-29 @ 06:36
On Tue, Jul 28, 2009 at 09:38:07PM -0400, Luke Baker wrote:
> I want to create a Lamson app that will intelligently forward email to
> a jabber user. For example, I want incoming email to be sent as a
> jabber message if the user is online, available, and not idle.
> Otherwise I want the incoming email to be forwarded to some other
> non-Lamson-controlled email address. So in addition to the typical
> Lamson stuff, there'd be a jabber bot which would monitor the presence
> of jabber users and send messages to them.
> First, would Lamson be a good fit for this?
Yep, assuming you had a good enough Python lib for it, it'd be fairly
easy. You'd basically extrapolate a mailing list out to include XMPP
for your basic design. Lamson wouldn't have much to help with the XMPP
side, but it will help with the conversions.
> Secondly, I'm looking for suggestions for the best way to hook up the
> jabber component to Lamson. Do I pull the jabber bot into the Lamson
> project as a service? Do I keep them separate entities and
> communicate between the two via queues and/or a database?
I'd keep it simple at first. Focus on making it work for one person, a
single handler, and have it just do it all in one process inside your
I'd probably have a model for your XMPP vs. email routing, that way if
you want to break it out into separate components you can without
changing your handler much. It's also easier to test this piece in
isolation then, or mock it out.
> Any other thoughts or suggests are welcome.
Study the examples/librelist source since it does a lot of what you'll
need to do to make this work. Take particular look at the
app/model/archive.py and app/model/mailinglist.py files. In archive you
have a couple of tricks for convertion lamson messages into json (or
plain python, or anything really). In mailinglist.py you have stuff for
routing around based on a django model's contents.
But, even if you just start with a simple handler that takes an email it
gets and sends it to your XMPP address you'd probably get pretty far.
Zed A. Shaw