]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
UserActivityStream export of DMs moved to plugin
authorMikael Nordfeldth <mmn@hethane.se>
Fri, 7 Nov 2014 15:08:16 +0000 (16:08 +0100)
committerMikael Nordfeldth <mmn@hethane.se>
Fri, 7 Nov 2014 15:08:16 +0000 (16:08 +0100)
lib/useractivitystream.php
plugins/DirectMessage/DirectMessagePlugin.php

index 21dfff1db5be88ec3635143c63832c316b979570..a94fee21393e6414228e52abdd1528909a5f181e 100644 (file)
@@ -75,10 +75,8 @@ class UserActivityStream extends AtomUserNoticeFeed
         $subscriptions = $this->getSubscriptions();
         $subscribers   = $this->getSubscribers();
         $groups        = $this->getGroups();
-        $messagesFrom  = $this->getMessagesFrom();
-        $messagesTo    = $this->getMessagesTo();
 
-        $objs = array_merge($subscriptions, $subscribers, $groups, $notices, $messagesFrom, $messagesTo);
+        $objs = array_merge($subscriptions, $subscribers, $groups, $notices);
 
         Event::handle('AppendUserActivityStreamObjects', array($this, &$objs));
 
@@ -353,32 +351,6 @@ class UserActivityStream extends AtomUserNoticeFeed
         return $groups;
     }
 
-    function getMessagesTo()
-    {
-        $msgMap = Message::listGet('to_profile', array($this->user->id));
-
-        $messages = $msgMap[$this->user->id];
-
-        if (!empty($this->after)) {
-            $messages = array_filter($messages, array($this, 'createdAfter'));
-        }
-
-        return $messages;
-    }
-
-    function getMessagesFrom()
-    {
-        $msgMap = Message::listGet('from_profile', array($this->user->id));
-
-        $messages = $msgMap[$this->user->id];
-
-        if (!empty($this->after)) {
-            $messages = array_filter($messages, array($this, 'createdAfter'));
-        }
-
-        return $messages;
-    }
-
     function createdAfter($item) {
         $created = strtotime((empty($item->created)) ? $item->modified : $item->created);
         return ($created >= $this->after);
index 1e717833adb53856fb77ccfe6e07fb83881278c3..190246de3df325a28130a70b6a8f073b39484139 100644 (file)
@@ -55,6 +55,27 @@ class DirectMessagePlugin extends Plugin
         return true;
     }
 
+    public function onAppendUserActivityStreamObjects(UserActivityStream $uas, array &$objs)
+    {
+        // Messages _from_ the user
+        $msgMap = Message::listGet('from_profile', array($this->user->id));
+        $messages = $msgMap[$uas->user->id];
+        if (!empty($uas->after)) {
+            $messages = array_filter($messages, array($uas, 'createdAfter'));
+        }
+        $objs[] = $messages;
+
+        // Messages _to_ the user
+        $msgMap = Message::listGet('to_profile', array($this->user->id));
+        $messages = $msgMap[$uas->user->id];
+        if (!empty($uas->after)) {
+            $messages = array_filter($messages, array($uas, 'createdAfter'));
+        }
+        $objs[] = $messages;
+
+        return true;
+    }
+
     public function onEndPersonalGroupNav(Menu $menu, Profile $target, Profile $scoped=null)
     {
         if ($scoped instanceof Profile && $scoped->id == $target->id