]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/jabber.php
Fix a couple of notice errors
[quix0rs-gnu-social.git] / lib / jabber.php
index b0dc24bd0dfdab0a5f775dbcdfd2d7dc5ac0cba1..a0f5080d0fb9faeb641010704a3949eee606d02f 100644 (file)
@@ -37,8 +37,11 @@ class Laconica_XMPP extends XMPPHP_XMPP {
        $out .= "<body>$body</body>";
        if($payload) $out .= $payload;
        $out .= "</message>";
-       
+
+               $cnt = strlen($out);
+               common_log(LOG_DEBUG, "Sending $cnt chars to $to");
        $this->send($out);
+               common_log(LOG_DEBUG, 'Done.');
     }
 }
 
@@ -114,6 +117,7 @@ function jabber_send_notice($to, $notice) {
 # Extra stuff defined by Twitter, needed by twitter clients
 
 function jabber_format_entry($profile, $notice) {
+       
        $noticeurl = common_local_url('shownotice',
                                                                  array('notice' => $notice->id));
        $msg = jabber_format_notice($profile, $notice);
@@ -132,6 +136,13 @@ function jabber_format_entry($profile, $notice) {
        $entry .= "<published>".common_date_w3dtf($notice->created)."</published>\n";
        $entry .= "<updated>".common_date_w3dtf($notice->modified)."</updated>\n";
        $entry .= "</entry>\n";
+
+       $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 .= ($notice->rendered) ? $notice->rendered : common_render_content($notice->content, $notice);
+       $html .= "\n</body>\n";
+       $html .= "\n</html>\n";
        
        $event = "<event xmlns='http://jabber.org/protocol/pubsub#event'>\n";
     $event .= "<items xmlns='http://jabber.org/protocol/pubsub' ";
@@ -140,7 +151,7 @@ function jabber_format_entry($profile, $notice) {
        $event .= "</items>\n";
        $event .= "</event>\n";
        # FIXME: include the pubsub event, too.
-       return $entry;
+       return $html . $entry;
 #      return $entry . "\n" . $event;
 }
 
@@ -218,6 +229,9 @@ function jabber_broadcast_notice($notice) {
                                        $sent_to[$user->id] = true;
                                } else {
                                        # XXX: Not sure, but I think that's the right thing to do
+                                       common_log(LOG_WARNING,
+                                                          'Sending reply notice ' . $notice->id . ' to ' . $user->jabber . ' FAILED, cancelling.',
+                                                          __FILE__);
                                        return false;
                                }
                        }
@@ -238,13 +252,32 @@ function jabber_broadcast_notice($notice) {
                                $success = jabber_send_notice($user->jabber, $notice);
                                if ($success) {
                                        $sent_to[$user->id] = true;
+                               } else {
                                        # XXX: Not sure, but I think that's the right thing to do
+                                       common_log(LOG_WARNING,
+                                                          'Sending notice ' . $notice->id . ' to ' . $user->jabber . ' FAILED, cancelling.',
+                                                          __FILE__);
                                        return false;
                                }
                        }
                }
        }
 
+       # Now, users who want everything
+       
+       $public = common_config('xmpp', 'public');
+       
+       # FIXME PRIV don't send out private messages here
+       
+       if ($public) {
+               foreach ($public as $address) {
+                               common_log(LOG_INFO,
+                                                  'Sending notice ' . $notice->id . ' to public listener ' . $address,
+                                                  __FILE__);
+                               jabber_send_notice($address, $notice);
+               }
+       }
+       
        return true;
 }