]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/jabber.php
Profile block base style
[quix0rs-gnu-social.git] / lib / jabber.php
index ef99f8f467165df8e7b280737499185c132e0a97..ab0fd6af8663a6490e3df5dbc9c088e0894c1380 100644 (file)
@@ -92,6 +92,7 @@ function jabber_send_notice($to, $notice) {
        $msg = jabber_format_notice($profile, $notice);
        $entry = jabber_format_entry($profile, $notice);
        $conn->message($to, $msg, 'chat', NULL, $entry);
+       $profile->free();
        return true;
 }
 
@@ -122,7 +123,7 @@ function jabber_format_entry($profile, $notice) {
 
        $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";
@@ -204,6 +205,9 @@ function jabber_broadcast_notice($notice) {
        $msg = jabber_format_notice($profile, $notice);
        $entry = jabber_format_entry($profile, $notice);
 
+       $profile->free();
+       unset($profile);
+
        $sent_to = array();
        $conn = jabber_connect();
 
@@ -221,9 +225,12 @@ function jabber_broadcast_notice($notice) {
                                   '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();
@@ -231,7 +238,8 @@ function jabber_broadcast_notice($notice) {
                                 'FROM user JOIN subscription ON user.id = subscription.subscriber ' .
                                 'WHERE subscription.subscribed = ' . $notice->profile_id . ' ' .
                                 'AND user.jabber is not null ' .
-                                'AND user.jabbernotify = 1 ');
+                                'AND user.jabbernotify = 1 ' .
+                 'AND subscription.jabber = 1 ');
 
        while ($user->fetch()) {
                if (!array_key_exists($user->id, $sent_to)) {
@@ -239,9 +247,13 @@ function jabber_broadcast_notice($notice) {
                                           '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;
 }
 
@@ -275,7 +287,9 @@ function jabber_public_notice($notice) {
                                           'Sending notice ' . $notice->id . ' to public listener ' . $address,
                                           __FILE__);
                        $conn->message($address, $msg, 'chat', NULL, $entry);
+                       $conn->processTime(0);
                }
+               $profile->free();
        }
 
        return true;