We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

Commit 797a0d79 authored by Evan Prodromou's avatar Evan Prodromou

create a method for notification for new messages, and use it

parent 19bb9a04
......@@ -175,7 +175,7 @@ class ApiDirectMessageNewAction extends ApiAuthAction
return;
}
mail_notify_message($message, $this->user, $this->other);
$message->notify();
if ($this->format == 'xml') {
$this->showSingleXmlDirectMessage($message);
......
......@@ -173,7 +173,7 @@ class NewmessageAction extends Action
return;
}
$this->notify($user, $this->other, $message);
$message->notify();
if ($this->boolean('ajax')) {
$this->startHTML('text/xml;charset=utf-8');
......@@ -247,12 +247,6 @@ class NewmessageAction extends Action
}
}
function notify($from, $to, $message)
{
mail_notify_message($message, $from, $to);
// XXX: Jabber, SMS notifications... probably queued
}
// Do nothing (override)
function showNoticeForm()
......
......@@ -89,4 +89,12 @@ class Message extends Memcached_DataObject
$contentlimit = self::maxContent();
return ($contentlimit > 0 && !empty($content) && (mb_strlen($content) > $contentlimit));
}
function notify()
{
$from = User::staticGet('id', $this->from_profile);
$to = User::staticGet('id', $this->to_profile);
mail_notify_message($this, $from, $to);
}
}
......@@ -372,7 +372,7 @@ class MessageCommand extends Command
}
$message = Message::saveNew($this->user->id, $other->id, $this->text, $channel->source());
if ($message) {
mail_notify_message($message, $this->user, $other);
$message->notify();
$channel->output($this->user, sprintf(_('Direct message to %s sent'), $this->other));
} else {
$channel->error($this->user, _('Error sending direct message.'));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment