fix: broken route:list command (#1859)

This commit is contained in:
Phan An 2024-10-24 18:05:07 +07:00 committed by GitHub
parent 793b59e9cf
commit f017b82479
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -17,13 +17,9 @@ use Illuminate\Support\Facades\DB;
class PlaylistCollaborationService class PlaylistCollaborationService
{ {
public function __construct()
{
License::requirePlus();
}
public function createToken(Playlist $playlist): PlaylistCollaborationToken public function createToken(Playlist $playlist): PlaylistCollaborationToken
{ {
License::requirePlus();
throw_if($playlist->is_smart, OperationNotApplicableForSmartPlaylistException::class); throw_if($playlist->is_smart, OperationNotApplicableForSmartPlaylistException::class);
return $playlist->collaborationTokens()->create(); return $playlist->collaborationTokens()->create();
@ -31,6 +27,7 @@ class PlaylistCollaborationService
public function acceptUsingToken(string $token, User $user): Playlist public function acceptUsingToken(string $token, User $user): Playlist
{ {
License::requirePlus();
$collaborationToken = PlaylistCollaborationToken::query()->where('token', $token)->firstOrFail(); $collaborationToken = PlaylistCollaborationToken::query()->where('token', $token)->firstOrFail();
throw_if($collaborationToken->expired, PlaylistCollaborationTokenExpiredException::class); throw_if($collaborationToken->expired, PlaylistCollaborationTokenExpiredException::class);
@ -51,6 +48,8 @@ class PlaylistCollaborationService
/** @return Collection<array-key, PlaylistCollaborator> */ /** @return Collection<array-key, PlaylistCollaborator> */
public function getCollaborators(Playlist $playlist): Collection public function getCollaborators(Playlist $playlist): Collection
{ {
License::requirePlus();
return $playlist->collaborators->unless( return $playlist->collaborators->unless(
$playlist->collaborators->contains($playlist->user), // The owner is always a collaborator $playlist->collaborators->contains($playlist->user), // The owner is always a collaborator
static fn (Collection $collaborators) => $collaborators->push($playlist->user) static fn (Collection $collaborators) => $collaborators->push($playlist->user)
@ -60,6 +59,7 @@ class PlaylistCollaborationService
public function removeCollaborator(Playlist $playlist, User $user): void public function removeCollaborator(Playlist $playlist, User $user): void
{ {
License::requirePlus();
throw_if($user->is($playlist->user), CannotRemoveOwnerFromPlaylistException::class); throw_if($user->is($playlist->user), CannotRemoveOwnerFromPlaylistException::class);
throw_if(!$playlist->hasCollaborator($user), NotAPlaylistCollaboratorException::class); throw_if(!$playlist->hasCollaborator($user), NotAPlaylistCollaboratorException::class);