diff --git a/lib/jabber.php b/lib/jabber.php index a36e19044e..d8cc38dd5e 100644 --- a/lib/jabber.php +++ b/lib/jabber.php @@ -67,6 +67,53 @@ function jabber_connect($resource=NULL) { return $conn; } +function jabber_send_notice($to, $notice) { + $conn = jabber_connect(); + if (!$conn) { + return false; + } + $profile = Profile::staticGet($notice->profile_id); + if (!$profile) { + common_log(LOG_WARNING, 'Refusing to send notice with ' . + 'unknown profile ' . common_log_objstring($notice), + __FILE__); + return false; + } + $msg = jabber_format_notice($profile, $notice); + $entry = jabber_format_entry($profile, $notice); + $conn->message($to, $msg, 'chat', $entry); + return true; +} + +# Extra stuff defined by Twitter, needed by twitter clients + +function jabber_format_entry($profile, $notice) { + $noticeurl = common_local_url('shownotice', + array('notice' => $notice->id)); + $entry = "\n"; + $entry .= "\n"; + $entry .= "" . $profile->nickname . " - " . common_config('site', 'name') . "\n"; + $entry .= "\n"; + $entry .= " $profile->nickname)) . "'/>\n"; + $entry .= "" . $profile->nickname . "\n"; + $entry .= "" . common_profile_avatar_url($profile, AVATAR_STREAM_SIZE) . "\n"; + $entry .= "\n"; + $entry .= "" . $msg . "\n"; + $entry .= "" . $msg . "\n"; + $entry .= "\n"; + $entry .= "". $notice->uri . "\n"; + $entry .= "".common_date_w3dtf($notice->created)."\n"; + $entry .= "".common_date_w3dtf($notice->modified)."\n"; + $entry .= "\n"; + $entry .= "\n"; + $entry .= "\n"; + $entry .= "\n"; + $entry .= "\n"; + $entry .= "\n"; + return $entry; +} + function jabber_send_message($to, $body, $type='chat', $subject=NULL) { $conn = jabber_connect(); if (!$conn) {