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);