X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=lib%2Fjabber.php;h=e15076160fc82c1bccb128e5709ded5db65af777;hb=db4ffca5350a11835c2c990f8d77d7cabb365a43;hp=3fbb3e1ab9ee0c04c9ad263cc3ba43654b97a39b;hpb=02184df7c8fd40ee9d1b134fd318e0c6f444ae01;p=quix0rs-gnu-social.git diff --git a/lib/jabber.php b/lib/jabber.php index 3fbb3e1ab9..e15076160f 100644 --- a/lib/jabber.php +++ b/lib/jabber.php @@ -77,6 +77,14 @@ function jabber_daemon_address() return common_config('xmpp', 'user') . '@' . common_config('xmpp', 'server'); } +class Sharing_XMPP extends XMPPHP_XMPP +{ + function getSocket() + { + return $this->socket; + } +} + /** * connect the configured Jabber account to the configured server * @@ -89,7 +97,7 @@ function jabber_connect($resource=null) { static $conn = null; if (!$conn) { - $conn = new XMPPHP_XMPP(common_config('xmpp', 'host') ? + $conn = new Sharing_XMPP(common_config('xmpp', 'host') ? common_config('xmpp', 'host') : common_config('xmpp', 'server'), common_config('xmpp', 'port'), @@ -163,50 +171,25 @@ function jabber_send_notice($to, $notice) function jabber_format_entry($profile, $notice) { - // FIXME: notice url might be remote - - $noticeurl = common_local_url('shownotice', - array('notice' => $notice->id)); - - $msg = jabber_format_notice($profile, $notice); - - $self_url = common_local_url('userrss', array('nickname' => $profile->nickname)); - - $entry = "\n\n"; - $entry .= "\n"; - $entry .= "" . $profile->nickname . " - " . common_config('site', 'name') . "\n"; - $entry .= "\n"; - $entry .= "\n"; - $entry .= "" . $profile->nickname . "\n"; - $entry .= "" . $profile->avatarUrl(AVATAR_PROFILE_SIZE) . "\n"; - $entry .= "\n"; - $entry .= "" . htmlspecialchars($msg) . "\n"; - $entry .= "" . htmlspecialchars($msg) . "\n"; - $entry .= "\n"; - $entry .= "". $notice->uri . "\n"; - $entry .= "".common_date_w3dtf($notice->created)."\n"; - $entry .= "".common_date_w3dtf($notice->modified)."\n"; - if ($notice->reply_to) { - $replyurl = common_local_url('shownotice', - array('notice' => $notice->reply_to)); - $entry .= "\n"; + $entry = $notice->asAtomEntry(true, true); + + $xs = new XMLStringer(); + $xs->elementStart('html', array('xmlns' => 'http://jabber.org/protocol/xhtml-im')); + $xs->elementStart('body', array('xmlns' => 'http://www.w3.org/1999/xhtml')); + $xs->element('a', array('href' => $profile->profileurl), + $profile->nickname); + $xs->text(": "); + if (!empty($notice->rendered)) { + $xs->raw($notice->rendered); + } else { + $xs->raw(common_render_content($notice->content, $notice)); } - $entry .= "\n"; - - $html = "\n\n"; - $html .= "\n"; - $html .= "".$profile->nickname.": "; - $html .= ($notice->rendered) ? $notice->rendered : common_render_content($notice->content, $notice); - $html .= "\n\n"; - $html .= "\n\n"; + $xs->elementEnd('body'); + $xs->elementEnd('html'); - $address = "\n"; - $address .= "
\n"; - $address .= "\n"; + $html = $xs->getString(); - // FIXME: include a pubsub event, too. - - return $html . $entry . $address; + return $html . ' ' . $entry; } /** @@ -410,8 +393,8 @@ function jabber_broadcast_notice($notice) "ON $UT.id = notice_inbox.user_id " . 'WHERE notice_inbox.notice_id = ' . $notice->id . ' ' . 'AND notice_inbox.source = 2 ' . - 'AND user.jabber is not null ' . - 'AND user.jabbernotify = 1 '); + "AND $UT.jabber is not null " . + "AND $UT.jabbernotify = 1 "); while ($user->fetch()) { if (!array_key_exists($user->id, $sent_to)) {