]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Merge branch '0.7.x' of git://gitorious.org/laconica/bAvatar-clone without the uninte...
authorAdrian Lang <mail@adrianlang.de>
Mon, 20 Apr 2009 10:15:12 +0000 (12:15 +0200)
committerAdrian Lang <mail@adrianlang.de>
Mon, 20 Apr 2009 10:15:12 +0000 (12:15 +0200)
1  2 
lib/util.php
scripts/xmppdaemon.php

diff --combined lib/util.php
index 5d16e39b56a2214d9d5321c9cad1a88616bad47f,ab5e99593ee75a151562125827993b120b23364b..e0eda0114b7101e046c55df94a3cb95919550bd4
@@@ -519,11 -519,16 +519,16 @@@ function common_shorten_links($text
  
  function common_shorten_link($url, $reverse = false)
  {
      static $url_cache = array();
      if ($reverse) return isset($url_cache[$url]) ? $url_cache[$url] : $url;
  
      $user = common_current_user();
+     if (!isset($user)) {
+       // common current user does not find a user when called from the XMPP daemon
+       // therefore we'll set one here fix, so that XMPP given URLs may be shortened
+       $user->urlshorteningservice = 'ur1.ca';
+     }
      $curlh = curl_init();
      curl_setopt($curlh, CURLOPT_CONNECTTIMEOUT, 20); // # seconds to wait
      curl_setopt($curlh, CURLOPT_USERAGENT, 'Laconica');
@@@ -1321,17 -1326,3 +1326,16 @@@ function common_compatible_license($fro
      // XXX: better compatibility check needed here!
      return ($from == $to);
  }
 +
 +/**
 + * returns a quoted table name, if required according to config
 + */
 +function common_database_tablename($tablename)
 +{
 +  
 +  if(common_config('db','quote_identifiers')) {
 +      $tablename = '"'. $tablename .'"';
 +  }
 +  //table prefixes could be added here later
 +  return $tablename;
 +}
diff --combined scripts/xmppdaemon.php
index 0ce2f2a28008397867de795afd36d1b0cf943cea,5711f715dfeffff4d8b123c80a78dca5b982541c..b79fa1b3ba0145101e167ddafea80fdd67ca3fc8
@@@ -152,11 -152,6 +152,6 @@@ class XMPPDaemon extends Daemo
              $body = preg_replace('/d[\ ]*('. $to .')[\ ]*/', '', $pl['body']);
              $this->add_direct($user, $body, $to, $from);
          } else {
-             $len = mb_strlen($pl['body']);
-             if($len > 140) {
-                 $this->from_site($from, 'Message too long - maximum is 140 characters, you sent ' . $len);
-                 return;
-             }
              $this->add_notice($user, $pl);
          }
  
      function add_notice(&$user, &$pl)
      {
          $body = trim($pl['body']);
-         $content_shortened = common_shorten_link($body);
+         $content_shortened = common_shorten_links($body);
          if (mb_strlen($content_shortened) > 140) {
-             $content = trim(mb_substr($body, 0, 140));
-             $content_shortened = common_shorten_link($content);
-         }
-         else {
-             $content = $body;
+           $from = jabber_normalize_jid($pl['from']);
+           $this->from_site($from, "Message too long - maximum is 140 characters, you sent ".mb_strlen($content_shortened));
+           return;
          }
-         $notice = Notice::saveNew($user->id, $content, 'xmpp');
+         $notice = Notice::saveNew($user->id, $content_shortened, 'xmpp');
          if (is_string($notice)) {
              $this->log(LOG_ERR, $notice);
              return;
      }
  }
  
 +// Abort immediately if xmpp is not enabled, otherwise the daemon chews up
 +// lots of CPU trying to connect to unconfigured servers
 +if (common_config('xmpp','enabled')==false) {
 +    print "Aborting daemon - xmpp is disabled\n";
 +    exit();
 +}
 +
  ini_set("max_execution_time", "0");
  ini_set("max_input_time", "0");
  set_time_limit(0);