From: Evan Prodromou Date: Fri, 21 Aug 2009 11:21:29 +0000 (-0400) Subject: correctly check Message length for d-commands X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=eb309f788bc9e52fd7108e024e58594b425de426;p=quix0rs-gnu-social.git correctly check Message length for d-commands --- diff --git a/lib/command.php b/lib/command.php index 4e2280bc80..371386dc58 100644 --- a/lib/command.php +++ b/lib/command.php @@ -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) {