newmessage (and Message class) fixed for FormAction

Also added a needLogin function to the Action class, which will do
redirect to login page with proper returnto setting.
This commit is contained in:
Mikael Nordfeldth
2013-09-02 10:59:02 +02:00
parent 89b10666bb
commit e5e3aeb4e6
5 changed files with 31 additions and 69 deletions

View File

@@ -632,15 +632,15 @@ class MessageCommand extends Command
$channel->error($this->user, _('Do not send a message to yourself; just say it to yourself quietly instead.'));
return;
}
$message = Message::saveNew($this->user->id, $other->id, $this->text, $channel->source());
if ($message) {
try {
$message = Message::saveNew($this->user->id, $other->id, $this->text, $channel->source());
$message->notify();
// TRANS: Message given have sent a direct message to another user.
// TRANS: %s is the name of the other user.
$channel->output($this->user, sprintf(_('Direct message to %s sent.'), $this->other));
} else {
} catch (Exception $e) {
// TRANS: Error text shown sending a direct message fails with an unknown reason.
$channel->error($this->user, _('Error sending direct message.'));
$channel->error($this->user, $e->getMessage());
}
}
}