]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
correctly check Message length for d-commands
authorEvan Prodromou <evan@controlyourself.ca>
Fri, 21 Aug 2009 11:21:29 +0000 (07:21 -0400)
committerEvan Prodromou <evan@controlyourself.ca>
Fri, 21 Aug 2009 11:21:29 +0000 (07:21 -0400)
lib/command.php

index 4e2280bc8070d58bc5edefc5edd09230f5a7c95b..371386dc58ea516155649ff895ed9eb37e7836eb 100644 (file)
@@ -211,16 +211,20 @@ class MessageCommand extends Command
     function execute($channel)
     {
         $other = User::staticGet('nickname', common_canonical_nickname($this->other));
+
         $len = mb_strlen($this->text);
+
         if ($len == 0) {
             $channel->error($this->user, _('No content!'));
             return;
-        } else if ($len > 140) {
-            $content = common_shorten_links($content);
-            if (mb_strlen($content) > 140) {
-                $channel->error($this->user, sprintf(_('Message too long - maximum is 140 characters, you sent %d'), $len));
-                return;
-            }
+        }
+
+        $this->text = common_shorten_links($this->text);
+
+        if (Message::contentTooLong($this->text)) {
+            $channel->error($this->user, sprintf(_('Message too long - maximum is %d characters, you sent %d'),
+                                                 Message::maxContent(), mb_strlen($this->text)));
+            return;
         }
 
         if (!$other) {