diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 18c90205..18638804 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -78,6 +78,7 @@ module.exports = { '@typescript-eslint/no-empty-function': 'off', '@typescript-eslint/no-floating-promises': 'off', '@typescript-eslint/no-non-null-assertion': 'off', + '@typescript-eslint/no-unsafe-argument': 'off', 'import/order': [ 'warn', { diff --git a/src/modules/users/users-playback.controller.ts b/src/modules/users/users-playback.controller.ts index 2dc4749c..246f9eb8 100644 --- a/src/modules/users/users-playback.controller.ts +++ b/src/modules/users/users-playback.controller.ts @@ -3,6 +3,7 @@ import { Get, NotFoundException, Param, + ParseUUIDPipe, Put, UnauthorizedException, } from '@nestjs/common' @@ -53,7 +54,10 @@ export class UsersPlaybackController { @ApiBadRequestResponse({ description: ONE_IS_INVALID('uuid'), }) - async getPlaybackState(@Param('id') id: string, @Token() _token?: string) { + async getPlaybackState( + @Param('id', ParseUUIDPipe) id: string, + @Token() _token?: string + ) { const foundUser = await this.usersRepository.findOneBy({ id }) if (!foundUser) throw new NotFoundException(NOT_BEEN_FOUND(USER)) @@ -80,7 +84,7 @@ export class UsersPlaybackController { description: ONE_IS_INVALID('uuid'), }) async pausePlayback( - @Param('id') id: string, + @Param('id', ParseUUIDPipe) id: string, @Token() accessToken: string ): Promise { const foundUser = await this.usersRepository.findOneBy({ id }) @@ -118,7 +122,7 @@ export class UsersPlaybackController { description: ONE_IS_INVALID('uuid'), }) async resumePlayback( - @Param('id') id: string, + @Param('id', ParseUUIDPipe) id: string, @Token() accessToken: string ): Promise { const foundUser = await this.usersRepository.findOneBy({ id }) @@ -128,9 +132,7 @@ export class UsersPlaybackController { const meProfile = await this.spotifyAuthService.getMeProfile(accessToken) if (foundUser.profile.id !== meProfile.id) - throw new UnauthorizedException( - 'You are not allowed to resume playback.' - ) + throw new UnauthorizedException('You are not allowed to resume playback.') const token = await this.spotifyAuthService.token({ refreshToken: foundUser.refreshToken, diff --git a/src/modules/users/users-profile.controller.ts b/src/modules/users/users-profile.controller.ts index cd7bf7ac..517e9597 100644 --- a/src/modules/users/users-profile.controller.ts +++ b/src/modules/users/users-profile.controller.ts @@ -243,33 +243,4 @@ export class UsersProfileController { return this.spotifyUsersService.getAnalysis(token) } - - // @Get('state') - // @ApiOperation({ - // summary: "Getting user's playback state.", - // }) - // @ApiParam({ name: 'id' }) - // @ApiOkResponse({ - // description: ONE_SUCCESFULLY_FOUND(USER), - // }) - // @ApiNotFoundResponse({ - // description: NOT_BEEN_FOUND(USER), - // }) - // @ApiBadRequestResponse({ - // description: ONE_IS_INVALID('uuid'), - // }) - // async getState( - // @Param('id', ParseUUIDPipe) id: string, - // @Token() _token?: string - // ) { - // const foundUser = await this.usersRepository.findOneBy({ id }) - - // if (!foundUser) throw new NotFoundException(NOT_BEEN_FOUND(USER)) - - // const token = await this.spotifyAuthService.token({ - // refreshToken: foundUser.refreshToken, - // }) - - // return this.spotifyPlayerService.getPlaybackState(token) - // } }