Query parameters implemented as per the doc
Kept Attachment entity compatible with GS Master Fixed conversation id data type on Notice entity
This commit is contained in:
parent
3161b62b5d
commit
81b9f17cb1
@ -39,22 +39,30 @@ class apActorLikedCollectionAction extends ManagedAction
|
||||
{
|
||||
$nickname = $this->trimmed('nickname');
|
||||
try {
|
||||
$user = User::getByNickname($nickname);
|
||||
$user = User::getByNickname($nickname);
|
||||
$profile = $user->getProfile();
|
||||
$url = $profile->profileurl;
|
||||
$url = $profile->profileurl;
|
||||
} catch (Exception $e) {
|
||||
throw new \Exception('Invalid username');
|
||||
}
|
||||
|
||||
// TODO: Implement query parameters as per the doc
|
||||
$limit = intval($this->trimmed('limit'));
|
||||
$since_id = intval($this->trimmed('since_id'));
|
||||
$max_id = intval($this->trimmed('max_id'));
|
||||
|
||||
$total_faves = Fave::countByProfile ($profile);
|
||||
$limit = empty ($limit) ? 40 : $limit; // Default is 40
|
||||
$since_id = empty ($since_id) ? null : $since_id;
|
||||
$max_id = empty ($max_id) ? null : $max_id;
|
||||
|
||||
$fave = Fave::byProfile ($user->getID(), 0, $total_faves);
|
||||
if ($limit > 80) $limit = 80; // Max is 80
|
||||
|
||||
$fave = $this->fetch_faves ($user->getID(), $limit, $since_id, $max_id);
|
||||
|
||||
$total_faves = 0;
|
||||
$faves = [];
|
||||
while ($fave->fetch()) {
|
||||
$faves[] = $this->pretty_fave (clone($fave));
|
||||
++$total_faves;
|
||||
}
|
||||
|
||||
$res = [
|
||||
@ -83,4 +91,24 @@ class apActorLikedCollectionAction extends ManagedAction
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
private static function fetch_faves ($user_id, $limit = 40, $since_id = null, $max_id = null)
|
||||
{
|
||||
$fav = new Fave();
|
||||
|
||||
$fav->user_id = $user_id;
|
||||
|
||||
$fav->orderBy('modified DESC');
|
||||
|
||||
if ($since_id != null)
|
||||
$fav->whereAdd("notice_id > {$since_id}");
|
||||
if ($max_id != null)
|
||||
$fav->whereAdd("notice_id < {$max_id}");
|
||||
|
||||
$fav->limit($limit);
|
||||
|
||||
$fav->find();
|
||||
|
||||
return $fav;
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ class Activitypub_attachment extends Managed_DataObject
|
||||
'id' => $attachment->getID (),
|
||||
'mimetype' => $attachment->mimetype,
|
||||
'url' => $attachment->getUrl (),
|
||||
'size' => $attachment->getSize (),
|
||||
'size' => intval($attachment->size),
|
||||
'title' => $attachment->getTitle (),
|
||||
'meta' => null
|
||||
];
|
||||
|
@ -66,7 +66,7 @@ class Activitypub_notice extends Managed_DataObject
|
||||
'url' => $notice->getUrl(),
|
||||
'reply_to' => empty($notice->reply_to) ? null : Notice::getById($notice->reply_to)->getUrl(),
|
||||
'is_local' => $notice->isLocal(),
|
||||
'conversation' => $notice->conversation,
|
||||
'conversation' => intval($notice->conversation),
|
||||
'attachment' => $attachments,
|
||||
'tag' => $tags
|
||||
];
|
||||
|
Reference in New Issue
Block a user