Implement since_id and max_id param handling for /api/favorites
This commit is contained in:
parent
c2bda7726c
commit
b50f300566
@ -185,17 +185,23 @@ class ApiTimelineFavoritesAction extends ApiBareAuthAction
|
|||||||
{
|
{
|
||||||
$notices = array();
|
$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) {
|
if (!empty($this->auth_user) && $this->auth_user->id == $this->user->id) {
|
||||||
$notice = $this->user->favoriteNotices(
|
$notice = $this->user->favoriteNotices(
|
||||||
|
true,
|
||||||
($this->page-1) * $this->count,
|
($this->page-1) * $this->count,
|
||||||
$this->count,
|
$this->count,
|
||||||
true
|
$this->since_id,
|
||||||
|
$this->max_id
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
$notice = $this->user->favoriteNotices(
|
$notice = $this->user->favoriteNotices(
|
||||||
|
false,
|
||||||
($this->page-1) * $this->count,
|
($this->page-1) * $this->count,
|
||||||
$this->count,
|
$this->count,
|
||||||
false
|
$this->since_id,
|
||||||
|
$this->max_id
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ class FavoritesrssAction extends Rss10Action
|
|||||||
function getNotices($limit=0)
|
function getNotices($limit=0)
|
||||||
{
|
{
|
||||||
$user = $this->user;
|
$user = $this->user;
|
||||||
$notice = $user->favoriteNotices(0, $limit);
|
$notice = $user->favoriteNotices(false, 0, $limit);
|
||||||
$notices = array();
|
$notices = array();
|
||||||
while ($notice->fetch()) {
|
while ($notice->fetch()) {
|
||||||
$notices[] = clone($notice);
|
$notices[] = clone($notice);
|
||||||
|
@ -121,11 +121,11 @@ class ShowfavoritesAction extends OwnerDesignAction
|
|||||||
// Show imported/gateway notices as well as local if
|
// Show imported/gateway notices as well as local if
|
||||||
// the user is looking at his own favorites
|
// the user is looking at his own favorites
|
||||||
|
|
||||||
$this->notice = $this->user->favoriteNotices(($this->page-1)*NOTICES_PER_PAGE,
|
$this->notice = $this->user->favoriteNotices(true, ($this->page-1)*NOTICES_PER_PAGE,
|
||||||
NOTICES_PER_PAGE + 1, true);
|
NOTICES_PER_PAGE + 1);
|
||||||
} else {
|
} else {
|
||||||
$this->notice = $this->user->favoriteNotices(($this->page-1)*NOTICES_PER_PAGE,
|
$this->notice = $this->user->favoriteNotices(false, ($this->page-1)*NOTICES_PER_PAGE,
|
||||||
NOTICES_PER_PAGE + 1, false);
|
NOTICES_PER_PAGE + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($this->notice)) {
|
if (empty($this->notice)) {
|
||||||
|
@ -75,13 +75,13 @@ class Fave extends Memcached_DataObject
|
|||||||
return Memcached_DataObject::pkeyGet('Fave', $kv);
|
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'),
|
$ids = Notice::stream(array('Fave', '_streamDirect'),
|
||||||
array($user_id, $own),
|
array($user_id, $own),
|
||||||
($own) ? 'fave:ids_by_user_own:'.$user_id :
|
($own) ? 'fave:ids_by_user_own:'.$user_id :
|
||||||
'fave:ids_by_user:'.$user_id,
|
'fave:ids_by_user:'.$user_id,
|
||||||
$offset, $limit);
|
$offset, $limit, $since_id, $max_id);
|
||||||
return $ids;
|
return $ids;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -464,9 +464,9 @@ class User extends Memcached_DataObject
|
|||||||
return $profile->getNotices($offset, $limit, $since_id, $before_id);
|
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);
|
return Notice::getStreamByIds($ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user