common_config('xmpp', 'debug') ?
XMPPHP_Log::LEVEL_VERBOSE : NULL
);
- $conn->autoSubscribe();
- $conn->useEncryption(common_config('xmpp', 'encryption'));
if (!$conn) {
return false;
}
- $conn->connect(true); # true = persistent connection
- if ($conn->isDisconnected()) {
+
+ $conn->autoSubscribe();
+ $conn->useEncryption(common_config('xmpp', 'encryption'));
+
+ try {
+ $conn->connect(true); # true = persistent connection
+ } catch (XMPPHP_Exception $e) {
+ common_log(LOG_ERROR, $e->getMessage());
return false;
}
+
$conn->processUntil('session_start');
}
return $conn;
$msg = jabber_format_notice($profile, $notice);
$entry = jabber_format_entry($profile, $notice);
$conn->message($to, $msg, 'chat', NULL, $entry);
+ $profile->free();
return true;
}
$html = "\n<html xmlns='http://jabber.org/protocol/xhtml-im'>\n";
$html .= "<body xmlns='http://www.w3.org/1999/xhtml'>\n";
- $html .= "<a href='".common_profile_url($profile->nickname)."'>".$profile->nickname."</a>: ";
+ $html .= "<a href='".htmlspecialchars($profile->profileurl)."'>".$profile->nickname."</a>: ";
$html .= ($notice->rendered) ? $notice->rendered : common_render_content($notice->content, $notice);
$html .= "\n</body>\n";
$html .= "\n</html>\n";
$address .= "<address type='replyto' jid='" . jabber_daemon_address() . "' />\n";
$address .= "</addresses>\n";
- $event = "<event xmlns='http://jabber.org/protocol/pubsub#event'>\n";
- $event .= "<items xmlns='http://jabber.org/protocol/pubsub' ";
- $event .= "node='" . common_local_url('public') . "'>\n";
- $event .= "<item id='" . $notice->uri ."' />\n";
- $event .= "</items>\n";
- $event .= "</event>\n";
- # FIXME: include the pubsub event, too.
-# return $html . $entry . $address;
- return $entry . $address;
-# return $entry . "\n" . $event;
+ # FIXME: include a pubsub event, too.
+
+ return $html . $entry . $address;
}
function jabber_send_message($to, $body, $type='chat', $subject=NULL) {
$msg = jabber_format_notice($profile, $notice);
$entry = jabber_format_entry($profile, $notice);
+ $profile->free();
+ unset($profile);
+
$sent_to = array();
$conn = jabber_connect();
'Sending reply notice ' . $notice->id . ' to ' . $user->jabber,
__FILE__);
$conn->message($user->jabber, $msg, 'chat', NULL, $entry);
+ $conn->processTime(0);
$sent_to[$user->id] = 1;
}
+ $user->free();
+
# Now, get users subscribed to this profile
$user = new User();
'Sending notice ' . $notice->id . ' to ' . $user->jabber,
__FILE__);
$conn->message($user->jabber, $msg, 'chat', NULL, $entry);
+ # To keep the incoming queue from filling up, we service it after each send.
+ $conn->processTime(0);
}
}
+ $user->free();
+
return true;
}
'Sending notice ' . $notice->id . ' to public listener ' . $address,
__FILE__);
$conn->message($address, $msg, 'chat', NULL, $entry);
+ $conn->processTime(0);
}
+ $profile->free();
}
return true;