mirror of
https://github.com/koel/koel
synced 2025-02-17 13:58:28 +00:00
fix(plus): smart playlist display inaccessible songs
This commit is contained in:
parent
9dc23f319e
commit
69368bfbd8
3 changed files with 7 additions and 0 deletions
|
@ -22,6 +22,7 @@ class SmartPlaylistService
|
|||
|
||||
$query = Song::query()
|
||||
->withMetaFor($user ?? $playlist->user)
|
||||
->when(License::isPlus(), static fn (SongBuilder $query) => $query->accessibleBy($user))
|
||||
->when(
|
||||
$playlist->own_songs_only && License::isPlus(),
|
||||
static fn (SongBuilder $query) => $query->where('songs.owner_id', $playlist->user_id)
|
||||
|
|
|
@ -31,6 +31,7 @@ class PlaylistSongTest extends PlusTestCase
|
|||
|
||||
public function testGetSongsInCollaborativePlaylist(): void
|
||||
{
|
||||
/** @var Playlist $playlist */
|
||||
$playlist = Playlist::factory()->create();
|
||||
$playlist->addSongs(Song::factory()->public()->count(3)->create());
|
||||
|
||||
|
@ -45,6 +46,7 @@ class PlaylistSongTest extends PlusTestCase
|
|||
|
||||
public function testPrivateSongsDoNotShowUpInCollaborativePlaylist(): void
|
||||
{
|
||||
/** @var Playlist $playlist */
|
||||
$playlist = Playlist::factory()->create();
|
||||
$playlist->addSongs(Song::factory()->public()->count(3)->create());
|
||||
|
||||
|
@ -64,6 +66,7 @@ class PlaylistSongTest extends PlusTestCase
|
|||
|
||||
public function testCollaboratorCanAddSongs(): void
|
||||
{
|
||||
/** @var Playlist $playlist */
|
||||
$playlist = Playlist::factory()->create();
|
||||
$collaborator = create_user();
|
||||
$playlist->addCollaborator($collaborator);
|
||||
|
@ -77,6 +80,7 @@ class PlaylistSongTest extends PlusTestCase
|
|||
|
||||
public function testCollaboratorCanRemoveSongs(): void
|
||||
{
|
||||
/** @var Playlist $playlist */
|
||||
$playlist = Playlist::factory()->create();
|
||||
$collaborator = create_user();
|
||||
$playlist->addCollaborator($collaborator);
|
||||
|
|
|
@ -15,6 +15,8 @@ class SongTest extends PlusTestCase
|
|||
$user = create_user();
|
||||
|
||||
Song::factory(2)->public()->create();
|
||||
|
||||
/** @var Collection<Song>|array<array-key, Song> $ownSongs */
|
||||
$ownSongs = Song::factory(3)->for($user, 'owner')->create();
|
||||
|
||||
$this->getAs('api/songs?own_songs_only=true', $user)
|
||||
|
|
Loading…
Add table
Reference in a new issue