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
@ -46,15 +46,23 @@ class apActorLikedCollectionAction extends ManagedAction
|
|||||||
throw new \Exception('Invalid username');
|
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 = [];
|
$faves = [];
|
||||||
while ($fave->fetch()) {
|
while ($fave->fetch()) {
|
||||||
$faves[] = $this->pretty_fave (clone($fave));
|
$faves[] = $this->pretty_fave (clone($fave));
|
||||||
|
++$total_faves;
|
||||||
}
|
}
|
||||||
|
|
||||||
$res = [
|
$res = [
|
||||||
@ -83,4 +91,24 @@ class apActorLikedCollectionAction extends ManagedAction
|
|||||||
|
|
||||||
return $res;
|
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 (),
|
'id' => $attachment->getID (),
|
||||||
'mimetype' => $attachment->mimetype,
|
'mimetype' => $attachment->mimetype,
|
||||||
'url' => $attachment->getUrl (),
|
'url' => $attachment->getUrl (),
|
||||||
'size' => $attachment->getSize (),
|
'size' => intval($attachment->size),
|
||||||
'title' => $attachment->getTitle (),
|
'title' => $attachment->getTitle (),
|
||||||
'meta' => null
|
'meta' => null
|
||||||
];
|
];
|
||||||
|
@ -66,7 +66,7 @@ class Activitypub_notice extends Managed_DataObject
|
|||||||
'url' => $notice->getUrl(),
|
'url' => $notice->getUrl(),
|
||||||
'reply_to' => empty($notice->reply_to) ? null : Notice::getById($notice->reply_to)->getUrl(),
|
'reply_to' => empty($notice->reply_to) ? null : Notice::getById($notice->reply_to)->getUrl(),
|
||||||
'is_local' => $notice->isLocal(),
|
'is_local' => $notice->isLocal(),
|
||||||
'conversation' => $notice->conversation,
|
'conversation' => intval($notice->conversation),
|
||||||
'attachment' => $attachments,
|
'attachment' => $attachments,
|
||||||
'tag' => $tags
|
'tag' => $tags
|
||||||
];
|
];
|
||||||
|
Reference in New Issue
Block a user