From f017b824790eae98199cbf75e13486b3596bdb65 Mon Sep 17 00:00:00 2001 From: Phan An Date: Thu, 24 Oct 2024 18:05:07 +0700 Subject: [PATCH] fix: broken route:list command (#1859) --- app/Services/PlaylistCollaborationService.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/Services/PlaylistCollaborationService.php b/app/Services/PlaylistCollaborationService.php index c489b765..7fb7a09b 100644 --- a/app/Services/PlaylistCollaborationService.php +++ b/app/Services/PlaylistCollaborationService.php @@ -17,13 +17,9 @@ use Illuminate\Support\Facades\DB; class PlaylistCollaborationService { - public function __construct() - { - License::requirePlus(); - } - public function createToken(Playlist $playlist): PlaylistCollaborationToken { + License::requirePlus(); throw_if($playlist->is_smart, OperationNotApplicableForSmartPlaylistException::class); return $playlist->collaborationTokens()->create(); @@ -31,6 +27,7 @@ class PlaylistCollaborationService public function acceptUsingToken(string $token, User $user): Playlist { + License::requirePlus(); $collaborationToken = PlaylistCollaborationToken::query()->where('token', $token)->firstOrFail(); throw_if($collaborationToken->expired, PlaylistCollaborationTokenExpiredException::class); @@ -51,6 +48,8 @@ class PlaylistCollaborationService /** @return Collection */ public function getCollaborators(Playlist $playlist): Collection { + License::requirePlus(); + return $playlist->collaborators->unless( $playlist->collaborators->contains($playlist->user), // The owner is always a collaborator static fn (Collection $collaborators) => $collaborators->push($playlist->user) @@ -60,6 +59,7 @@ class PlaylistCollaborationService public function removeCollaborator(Playlist $playlist, User $user): void { + License::requirePlus(); throw_if($user->is($playlist->user), CannotRemoveOwnerFromPlaylistException::class); throw_if(!$playlist->hasCollaborator($user), NotAPlaylistCollaboratorException::class);