]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
create a method for notification for new messages, and use it
authorEvan Prodromou <evan@status.net>
Tue, 15 Dec 2009 15:31:25 +0000 (10:31 -0500)
committerEvan Prodromou <evan@status.net>
Tue, 15 Dec 2009 15:31:25 +0000 (10:31 -0500)
actions/apidirectmessagenew.php
actions/newmessage.php
classes/Message.php
lib/command.php

index e6c39ce4ac6e6950e34d45abd00abbf2884fb44d..b9ac92d77bfc01bb91f87ec67ddde184b48f8347 100644 (file)
@@ -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);
index 0db2e7181ca7d327b37023e7143ae70cbb932b56..350452091378203c7967b87c38cd48248f1cee9f 100644 (file)
@@ -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()
index 718a9d922a525eccbb5218d9b412c11e4c24a76a..16d0c60b304704bf69dd63e002f1162d11657786 100644 (file)
@@ -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);
+    }
 }
index b30780bfb146e5546f2c341f769b19ff0b02bda9..67140c3485f7cd56770d0feea56932865dfda03e 100644 (file)
@@ -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.'));