From b50f300566143837aba3739d62caf679ec19727e Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Wed, 5 May 2010 14:46:36 -0700 Subject: [PATCH] Implement since_id and max_id param handling for /api/favorites --- actions/apitimelinefavorites.php | 10 ++++++++-- actions/favoritesrss.php | 2 +- actions/showfavorites.php | 8 ++++---- classes/Fave.php | 4 ++-- classes/User.php | 4 ++-- 5 files changed, 17 insertions(+), 11 deletions(-) diff --git a/actions/apitimelinefavorites.php b/actions/apitimelinefavorites.php index 8cb2e808de..79632447ef 100644 --- a/actions/apitimelinefavorites.php +++ b/actions/apitimelinefavorites.php @@ -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 ); } diff --git a/actions/favoritesrss.php b/actions/favoritesrss.php index 62f06e841b..51c92af933 100644 --- a/actions/favoritesrss.php +++ b/actions/favoritesrss.php @@ -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); diff --git a/actions/showfavorites.php b/actions/showfavorites.php index 4d776ef04c..7f3c77ee24 100644 --- a/actions/showfavorites.php +++ b/actions/showfavorites.php @@ -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)) { diff --git a/classes/Fave.php b/classes/Fave.php index 7ca9ade7f0..ed4f56aeef 100644 --- a/classes/Fave.php +++ b/classes/Fave.php @@ -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; } diff --git a/classes/User.php b/classes/User.php index 1928a3c62f..2abb7eeb69 100644 --- a/classes/User.php +++ b/classes/User.php @@ -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); } -- 2.39.5