]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - scripts/xmppdaemon.php
Merge branch '0.7.x' of git://gitorious.org/laconica/bAvatar-clone without the uninte...
[quix0rs-gnu-social.git] / scripts / xmppdaemon.php
index 0ce2f2a28008397867de795afd36d1b0cf943cea..b79fa1b3ba0145101e167ddafea80fdd67ca3fc8 100755 (executable)
@@ -152,11 +152,6 @@ class XMPPDaemon extends Daemon
             $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);
         }
 
@@ -255,15 +250,13 @@ class XMPPDaemon extends Daemon
     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;