From fb007082841f1a23da5427063e00ceb7c93f3ac2 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Sun, 13 Jul 2008 23:45:03 -0400 Subject: [PATCH] add extra Twitter cruft to jabber messages darcs-hash:20080714034503-84dde-c06198f9d7b8b1c11f6c57e518dcf49b863ee6f3.gz --- lib/jabber.php | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) 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) { -- 2.39.5