mirror of
https://github.com/openvk/openvk
synced 2025-04-23 16:43:02 +03:00
Disallow having more than 65k audios in playlist
This commit is contained in:
parent
4171a51e28
commit
7aef23b3cd
2 changed files with 12 additions and 3 deletions
|
@ -462,7 +462,11 @@ final class Audio extends VKAPIRequestHandler
|
|||
else if(!$audio->canBeViewedBy($this->getUser()))
|
||||
$this->fail(201, "Access denied to audio(owner=$owner_id, vid=$audio_id)");
|
||||
|
||||
$audio->add($to);
|
||||
try {
|
||||
$audio->add($to);
|
||||
} catch(\OverflowException $ex) {
|
||||
$this->fail(300, "Album is full");
|
||||
}
|
||||
|
||||
return $audio->getPrettyId();
|
||||
}
|
||||
|
|
|
@ -266,8 +266,13 @@ class Audio extends Media
|
|||
if($this->isInLibraryOf($entity))
|
||||
return false;
|
||||
|
||||
DatabaseConnection::i()->getContext()->table("audio_relations")->insert([
|
||||
"entity" => $entity->getId() * ($entity instanceof Club ? -1 : 1),
|
||||
$entityId = $entity->getId() * ($entity instanceof Club ? -1 : 1);
|
||||
$audioRels = DatabaseConnection::i()->getContext()->table("audio_relations");
|
||||
if(sizeof($audioRels->where("entity", $entityId)) > 65536)
|
||||
throw new \OverflowException("Can't have more than 65536 audios in a playlist");
|
||||
|
||||
$audioRels->insert([
|
||||
"entity" => $entityId,
|
||||
"audio" => $this->getId(),
|
||||
]);
|
||||
|
||||
|
|
Loading…
Reference in a new issue