]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/inboxnoticestream.php
New mechanism for "all" feed (InboxNoticeStream)
[quix0rs-gnu-social.git] / lib / inboxnoticestream.php
index 913e9fff2e85e685feb95b1e9709810d523ee9ae..0eb791d70a45823a140629e235b20b75d4ccf26f 100644 (file)
@@ -102,19 +102,22 @@ class RawInboxNoticeStream extends NoticeStream
     {
         $notice = new Notice();
         $notice->selectAdd();
-        $notice->selectAdd('notice_id');
-        // Reply is a class for mentions
-        $notice->joinAdd(array('id', 'reply:notice_id'));
-
-        $notice->profile_id = $this->target->id;
+        $notice->selectAdd('id');
+        $notice->whereAdd(sprintf('notice.created > "%s"', $notice->escape($this->target->created)));
+        // Reply:: is a table of mentions
+        // Subscription:: is a table of subscriptions (every user is subscribed to themselves)
+        $notice->whereAdd(
+                sprintf('notice.id IN (SELECT notice_id FROM reply WHERE profile_id=%1$d) ' .
+                    'OR notice.profile_id IN (SELECT subscribed FROM subscription WHERE subscriber=%d)', $this->target->id)
+            );
         $notice->limit($offset, $limit);
-        $notice->orderBy('created DESC');
+        $notice->orderBy('notice.created DESC');
 
         if (!$notice->find()) {
             return array();
         }
 
-        $ids = $notice->fetchAll('notice_id');
+        $ids = $notice->fetchAll('id');
 
         return $ids;
     }