From: Matt S Trout Date: Wed, 16 Feb 2011 16:36:03 +0000 (+0000) Subject: final fixes from gmail integration X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=7c5b5a3a81fe80f6d3aaa33a8b627a018dc93b5e;p=scpubgit%2FClifton.git final fixes from gmail integration --- diff --git a/lib/App/Clifton/Tower/Jabber.pm b/lib/App/Clifton/Tower/Jabber.pm index e57e962..ffc852c 100644 --- a/lib/App/Clifton/Tower/Jabber.pm +++ b/lib/App/Clifton/Tower/Jabber.pm @@ -27,6 +27,8 @@ has chain_set => ( default => sub { ChainSet->new } ); +has full_jid => (is => 'rw'); + sub _build_xmpp_client { my ($self) = @_; $self->_login_xmpp_client($self->_new_child(XMPP_Client, { @@ -50,9 +52,15 @@ sub handle_message { my $me = $self->jabber_config->user; + return log_info { + "Received error message" + } if $msg->type eq 'error'; + return log_debug { "Received message for ${\$msg->to} instead of $me - ignoring" - } unless $msg->to eq $me; + } unless $msg->to =~ /^\Q$me/; # may be foo@gmail.com or .../gsklgsh + + $self->full_jid($msg->to); # need foo@gmail.com/skldshgsdg here (my $from = $msg->from) =~ s/\/.*//; @@ -94,6 +102,7 @@ sub handle_message { sub send_xmpp_message { my ($self, $args) = @_; s/&/&/g, s/"/"/g, s//>/g for $args->{body}; + $args->{from} = $self->full_jid; $self->xmpp_client->compose(%$args)->send; }