abhaypradhan (abhaypradhan) wrote in lj_dev,

LiveJournal comments through Jabber?


I've deployed LiveJournal in our company and one of the "issues" we've faced is that our IT division is not too keen on LiveJournal sending emails to employees everytime they receive a comment in their blog. So, for the time being, I've disabled that (sending email).

I was wondering if people would be interested in sending an IM to a jabber ID (we have jabber deployed internally). There is a Net::Jabber module available at CPAN, and I looked at this (http://www.pipetree.com/jabber/mail_notify.html) to see if it would work.

use strict;
use Net::Jabber;

#the person who is sending the note. ideally, this should be lj@jabberserver
use constant RECIPIENT => 'abhay_pradhan@jabberserver';
use constant SERVER => 'jabberserver';
use constant PORT => 5222;
use constant USER => 'abhay_pradhan';
use constant PASSWORD => '******';

#Jabber recognizes a handle as username/resource .. so you could be signed in as username/PDA or username/mobile etc etc.
use constant RESOURCE => 'LJscript';

my $connection = Net::Jabber::Client->new();
$connection->Connect( "hostname" => SERVER,
"port" => PORT )
or die "Cannot connect ($!)\n";

my @result = $connection->AuthSend( "username" => USER,
"password" => PASSWORD,
"resource" => RESOURCE );
if ($result[0] ne "ok") {
die "Ident/Auth with server failed: $result[0] - $result[1]\n";

my $message = Net::Jabber::Message->new();
$message->SetMessage( "to" => RECIPIENT,
"subject" => "LJ Message",
"body" => "Somebody commented on your blog. Please visit ");

$connection->Send($message) or die "cannot send message ($!)\n";



Of course, there are various things which can be done better here.

a) a connection pool to the jabber server (so we don't setup lj@jabberserver everytime)
b) a producer/consumer thread. basically LiveJournal would just write IM's to be sent to a file (or anything) and consumer threads would use the pool of jabber connections to send messages to various employee accounts.

Basically, the question I"m trying to ask here is, design wise, is IM a better way to go than email? Or is there no difference and one can do it one way or the other?

Feel free to scream if its a stupid idea.

Btw, our company's official IM service is MSN. So i'm wondering if I can send IM's from blog to the MSN ID of an employee.


  • Post a new comment


    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded