]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Implement since_id and max_id param handling for /api/favorites
authorZach Copley <zach@status.net>
Wed, 5 May 2010 21:46:36 +0000 (14:46 -0700)
committerZach Copley <zach@status.net>
Wed, 5 May 2010 21:46:36 +0000 (14:46 -0700)
actions/apitimelinefavorites.php
actions/favoritesrss.php
actions/showfavorites.php
classes/Fave.php
classes/User.php

index 8cb2e808de0c350ceb74ebb70f57e70afdfe106d..79632447ef0782b1e9887a703e505efd0d60f054 100644 (file)
@@ -185,17 +185,23 @@ class ApiTimelineFavoritesAction extends ApiBareAuthAction
     {
         $notices = array();
 
+        common_debug("since id = " . $this->since_id . " max id = " . $this->max_id);
+
         if (!empty($this->auth_user) && $this->auth_user->id == $this->user->id) {
             $notice = $this->user->favoriteNotices(
+                true,
                 ($this->page-1) * $this->count,
                 $this->count,
-                true
+                $this->since_id,
+                $this->max_id
             );
         } else {
             $notice = $this->user->favoriteNotices(
+                false,
                 ($this->page-1) * $this->count,
                 $this->count,
-                false
+                $this->since_id,
+                $this->max_id
             );
         }
 
index 62f06e841b193ddd2cb4f94fbb47a3c6c151050e..51c92af9339af61c55ab9479b64b7613f288f3b0 100644 (file)
@@ -89,7 +89,7 @@ class FavoritesrssAction extends Rss10Action
     function getNotices($limit=0)
     {
         $user    = $this->user;
-        $notice  = $user->favoriteNotices(0, $limit);
+        $notice  = $user->favoriteNotices(false, 0, $limit);
         $notices = array();
         while ($notice->fetch()) {
             $notices[] = clone($notice);
index 4d776ef04cec23fce077c9e58b6c849a34757a89..7f3c77ee246dfa8f76f7255532cb86a133cac9fa 100644 (file)
@@ -121,11 +121,11 @@ class ShowfavoritesAction extends OwnerDesignAction
             // Show imported/gateway notices as well as local if
             // the user is looking at his own favorites
 
-            $this->notice = $this->user->favoriteNotices(($this->page-1)*NOTICES_PER_PAGE,
-                                                   NOTICES_PER_PAGE + 1, true);
+            $this->notice = $this->user->favoriteNotices(true, ($this->page-1)*NOTICES_PER_PAGE,
+                                                   NOTICES_PER_PAGE + 1);
         } else {
-            $this->notice = $this->user->favoriteNotices(($this->page-1)*NOTICES_PER_PAGE,
-                                                   NOTICES_PER_PAGE + 1, false);
+            $this->notice = $this->user->favoriteNotices(false, ($this->page-1)*NOTICES_PER_PAGE,
+                                                   NOTICES_PER_PAGE + 1);
         }
 
         if (empty($this->notice)) {
index 7ca9ade7f04b846c53982c8507fce5293436d793..ed4f56aeef0405b957534495aea326875bca4d9f 100644 (file)
@@ -75,13 +75,13 @@ class Fave extends Memcached_DataObject
         return Memcached_DataObject::pkeyGet('Fave', $kv);
     }
 
-    function stream($user_id, $offset=0, $limit=NOTICES_PER_PAGE, $own=false)
+    function stream($user_id, $offset=0, $limit=NOTICES_PER_PAGE, $own=false, $since_id=0, $max_id=0)
     {
         $ids = Notice::stream(array('Fave', '_streamDirect'),
                               array($user_id, $own),
                               ($own) ? 'fave:ids_by_user_own:'.$user_id :
                               'fave:ids_by_user:'.$user_id,
-                              $offset, $limit);
+                              $offset, $limit, $since_id, $max_id);
         return $ids;
     }
 
index 1928a3c62fb1735b1c9ecab9a01595f6064ca191..2abb7eeb69319ae8956e2dc64882f32c9b39a2fb 100644 (file)
@@ -464,9 +464,9 @@ class User extends Memcached_DataObject
         return $profile->getNotices($offset, $limit, $since_id, $before_id);
     }
 
-    function favoriteNotices($offset=0, $limit=NOTICES_PER_PAGE, $own=false)
+    function favoriteNotices($own=false, $offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $max_id=0)
     {
-        $ids = Fave::stream($this->id, $offset, $limit, $own);
+        $ids = Fave::stream($this->id, $offset, $limit, $own, $since_id, $max_id);
         return Notice::getStreamByIds($ids);
     }