correctly check Message length for d-commands

This commit is contained in:
Evan Prodromou 2009-08-21 07:21:29 -04:00
parent d88839d167
commit eb309f788b
1 changed files with 10 additions and 6 deletions

View 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) {