summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvan Prodromou <evan@status.net>2009-12-15 10:31:25 -0500
committerEvan Prodromou <evan@status.net>2009-12-15 10:31:25 -0500
commit797a0d79fbf4e105ee4ccdce093c1595c1f08a4a (patch)
treed144137e9607e6ee1144dae4e993b4f22335fa0b
parent19bb9a04d171fe2a8d87a51c0267c5670cb0f5bf (diff)
create a method for notification for new messages, and use it
-rw-r--r--actions/apidirectmessagenew.php2
-rw-r--r--actions/newmessage.php8
-rw-r--r--classes/Message.php8
-rw-r--r--lib/command.php2
4 files changed, 11 insertions, 9 deletions
diff --git a/actions/apidirectmessagenew.php b/actions/apidirectmessagenew.php
index e6c39ce4a..b9ac92d77 100644
--- a/actions/apidirectmessagenew.php
+++ b/actions/apidirectmessagenew.php
@@ -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);
diff --git a/actions/newmessage.php b/actions/newmessage.php
index 0db2e7181..350452091 100644
--- a/actions/newmessage.php
+++ b/actions/newmessage.php
@@ -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()
diff --git a/classes/Message.php b/classes/Message.php
index 718a9d922..16d0c60b3 100644
--- a/classes/Message.php
+++ b/classes/Message.php
@@ -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);
+ }
}
diff --git a/lib/command.php b/lib/command.php
index b30780bfb..67140c348 100644
--- a/lib/command.php
+++ b/lib/command.php
@@ -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.'));