VKAPI: Add owner_id support to video.get (not sure if this works cuz it's hot outside and i'm tired)

This commit is contained in:
veselcraft 2023-04-29 16:05:37 +03:00
parent 27fb0f1d90
commit 725e68d0e5
No known key found for this signature in database
GPG key ID: AED66BC1AC628A4E

View file

@ -11,10 +11,11 @@ use openvk\Web\Models\Repositories\Comments as CommentsRepo;
final class Video extends VKAPIRequestHandler final class Video extends VKAPIRequestHandler
{ {
function get(string $videos, int $offset = 0, int $count = 30, int $extended = 0): object function get(int $owner_id, string $videos, int $offset = 0, int $count = 30, int $extended = 0): object
{ {
$this->requireUser(); $this->requireUser();
if ($videos) {
$vids = explode(',', $videos); $vids = explode(',', $videos);
foreach($vids as $vid) foreach($vids as $vid)
@ -33,5 +34,24 @@ final class Video extends VKAPIRequestHandler
"count" => count($items), "count" => count($items),
"items" => $items "items" => $items
]; ];
} else {
if ($owner_id > 0)
$user = (new UsersRepo)->get($owner_id);
else
$this->fail(1, "Not implemented");
$videos = (new VideosRepo)->getByUser($user, $offset + 1, $count);
$videosCount = (new VideosRepo)->getUserVideosCount($user);
$items = [];
foreach ($videos as $video) {
$items[] = $video->getApiStructure();
}
return (object) [
"count" => $videosCount,
"items" => $items
];
}
} }
} }