mirror of
https://github.com/koel/koel
synced 2024-11-14 00:17:13 +00:00
fix: get playables not returnig episodes
This commit is contained in:
parent
5c07b893f3
commit
7ee8c7ba45
4 changed files with 17 additions and 4 deletions
|
@ -15,10 +15,10 @@ class SongStorageCast implements CastsAttributes
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @param SongStorageType|string|null $value */
|
/** @param SongStorageType|string|null $value */
|
||||||
public function set(Model $model, string $key, mixed $value, array $attributes): string
|
public function set(Model $model, string $key, mixed $value, array $attributes): ?string
|
||||||
{
|
{
|
||||||
$type = $value instanceof SongStorageType ? $value : SongStorageType::tryFrom($value);
|
$type = $value instanceof SongStorageType ? $value : SongStorageType::tryFrom($value);
|
||||||
|
|
||||||
return $type->value;
|
return $type?->value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -204,7 +204,7 @@ class SongRepository extends Repository
|
||||||
*/
|
*/
|
||||||
public function getManyInCollaborativeContext(array $ids, ?User $scopedUser = null): Collection
|
public function getManyInCollaborativeContext(array $ids, ?User $scopedUser = null): Collection
|
||||||
{
|
{
|
||||||
return Song::query(type: PlayableType::SONG, user: $scopedUser ?? $this->auth->user())
|
return Song::query(user: $scopedUser ?? $this->auth->user())
|
||||||
->accessible()
|
->accessible()
|
||||||
->withMeta()
|
->withMeta()
|
||||||
->when(License::isPlus(), static function (SongBuilder $query): SongBuilder {
|
->when(License::isPlus(), static function (SongBuilder $query): SongBuilder {
|
||||||
|
|
|
@ -47,6 +47,14 @@ class SongFactory extends Factory
|
||||||
return $this->state(fn () => [ // @phpcs:ignore
|
return $this->state(fn () => [ // @phpcs:ignore
|
||||||
'podcast_id' => Podcast::factory(),
|
'podcast_id' => Podcast::factory(),
|
||||||
'is_public' => true,
|
'is_public' => true,
|
||||||
|
'artist_id' => null,
|
||||||
|
'owner_id' => null,
|
||||||
|
'album_id' => null,
|
||||||
|
'storage' => null,
|
||||||
|
'path' => $this->faker->url(),
|
||||||
|
'lyrics' => '',
|
||||||
|
'track' => null,
|
||||||
|
'disc' => 0,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ namespace Tests\Integration\Services;
|
||||||
|
|
||||||
use App\Models\Playlist;
|
use App\Models\Playlist;
|
||||||
use App\Models\PlaylistFolder;
|
use App\Models\PlaylistFolder;
|
||||||
|
use App\Models\Podcast;
|
||||||
use App\Models\Song;
|
use App\Models\Song;
|
||||||
use App\Services\PlaylistService;
|
use App\Services\PlaylistService;
|
||||||
use App\Values\SmartPlaylistRuleGroupCollection;
|
use App\Values\SmartPlaylistRuleGroupCollection;
|
||||||
|
@ -210,7 +211,11 @@ class PlaylistServiceTest extends TestCase
|
||||||
/** @var Playlist $playlist */
|
/** @var Playlist $playlist */
|
||||||
$playlist = Playlist::factory()->create();
|
$playlist = Playlist::factory()->create();
|
||||||
$playlist->addPlayables(Song::factory(3)->create());
|
$playlist->addPlayables(Song::factory(3)->create());
|
||||||
$episodes = Song::factory(2)->asEpisode()->create();
|
|
||||||
|
$podcast = Podcast::factory()->create();
|
||||||
|
$episodes = Song::factory(2)->asEpisode()->for($podcast)->create();
|
||||||
|
|
||||||
|
$playlist->user->subscribeToPodcast($podcast);
|
||||||
|
|
||||||
$addedEpisodes = $this->service->addPlayablesToPlaylist($playlist, $episodes, $playlist->user);
|
$addedEpisodes = $this->service->addPlayablesToPlaylist($playlist, $episodes, $playlist->user);
|
||||||
$playlist->refresh();
|
$playlist->refresh();
|
||||||
|
|
Loading…
Reference in a new issue