diff --git a/src/game/dto/create-game-param.dto.ts b/src/game/dto/create-game-param.dto.ts index d4e204d..fe42f63 100644 --- a/src/game/dto/create-game-param.dto.ts +++ b/src/game/dto/create-game-param.dto.ts @@ -1,4 +1,4 @@ export class CreateGameParamDto { - gameInvitationId: number; + invitationId: number; invitedUserId: number; } diff --git a/src/game/dto/delete-invitation-param.dto.ts b/src/game/dto/delete-invitation-param.dto.ts index bf0cb84..6b84fce 100644 --- a/src/game/dto/delete-invitation-param.dto.ts +++ b/src/game/dto/delete-invitation-param.dto.ts @@ -1,4 +1,4 @@ export class DeleteGameInvitationParamDto { cancelingUserId: number; - gameInvitationId: number; + invitationId: number; } diff --git a/src/game/game.controller.ts b/src/game/game.controller.ts index 7113190..5fd32c0 100644 --- a/src/game/game.controller.ts +++ b/src/game/game.controller.ts @@ -42,18 +42,18 @@ export class GameController { /** * 초대 수락 * @param user - * @param gameInvitationId 초대 테이블의 id + * @param invitationId 초대 테이블의 id * (초대시 프론트가 이벤트를 수신하며 받은 data 입니다) */ @Post('/accept') async createGame( @GetUser() user: User, @Body('gameInvitationId', ParseIntPipe, PositiveIntPipe) - gameInvitationId: number, + invitationId: number, ) { const createGameParamDto: CreateGameParamDto = { invitedUserId: user.id, - gameInvitationId: gameInvitationId, + invitationId: invitationId, }; await this.gameService.createGame(createGameParamDto); } @@ -62,11 +62,11 @@ export class GameController { async deleteInvitation( @GetUser() user: User, @Param('gameInvitationId', ParseIntPipe, PositiveIntPipe) - gameInvitationId: number, + invitationId: number, ) { const deleteInvitationParamDto: DeleteGameInvitationParamDto = { cancelingUserId: user.id, - gameInvitationId: gameInvitationId, + invitationId: invitationId, }; await this.gameService.deleteInvitationByInvitingUserId( deleteInvitationParamDto, @@ -77,11 +77,11 @@ export class GameController { async refuseInvitation( @GetUser() user: User, @Param('gameInvitationId', ParseIntPipe, PositiveIntPipe) - gameInvitationId: number, + invitationId: number, ) { const deleteInvitationParamDto: DeleteGameInvitationParamDto = { cancelingUserId: user.id, - gameInvitationId: gameInvitationId, + invitationId: invitationId, }; await this.gameService.deleteInvitationByInvitedUserId( deleteInvitationParamDto, diff --git a/src/game/game.module.ts b/src/game/game.module.ts index ebd83c9..9e802b4 100644 --- a/src/game/game.module.ts +++ b/src/game/game.module.ts @@ -16,6 +16,8 @@ import { FriendsRepository } from '../users/friends.repository'; import { ChannelUser } from '../channels/entities/channel-user.entity'; import { Friend } from '../users/entities/friend.entity'; import { ChannelsModule } from '../channels/channels.module'; +import { Block } from '../users/entities/block.entity'; +import { BlocksRepository } from '../users/blocks.repository'; @Module({ imports: [ @@ -25,6 +27,7 @@ import { ChannelsModule } from '../channels/channels.module'; User, ChannelUser, Friend, + Block, ]), ChannelsModule, ], @@ -36,6 +39,7 @@ import { ChannelsModule } from '../channels/channels.module'; JwtService, ChannelUsersRepository, FriendsRepository, + BlocksRepository, GameRepository, GameInvitationRepository, UsersRepository, diff --git a/src/game/game.service.ts b/src/game/game.service.ts index 8695dfe..733a21e 100644 --- a/src/game/game.service.ts +++ b/src/game/game.service.ts @@ -17,6 +17,7 @@ import { CreateGameParamDto } from './dto/create-game-param.dto'; import { GatewaySendInvitationReplyDto } from './dto/gateway-send-invitation-reaponse.dto'; import { User } from '../users/entities/user.entity'; import * as moment from 'moment'; +import { BlocksRepository } from '../users/blocks.repository'; @Injectable() export class GameService { @@ -25,6 +26,7 @@ export class GameService { private readonly gameInvitationRepository: GameInvitationRepository, private readonly gameGateway: GameGateway, private readonly usersRepository: UsersRepository, + private readonly blocksRepository: BlocksRepository, ) {} async createInvitation(invitationParamDto: CreateGameInvitationParamDto) { @@ -47,6 +49,10 @@ export class GameService { throw new ImATeapotException( `초대된 유저 ${invitedUserId} 는 OFFLINE 상태입니다`, ); + const isblocked = await this.blocksRepository.findOne({ + where: { fromUserId: invitedUserId, toUserId: invitingUser.id }, + }); + if (isblocked) return; // game invitation DB 저장 const gameInvitation = @@ -65,7 +71,7 @@ export class GameService { } async createGame(createGameParamDto: CreateGameParamDto) { - const invitationId = createGameParamDto.gameInvitationId; + const invitationId = createGameParamDto.invitationId; const invitedUserId = createGameParamDto.invitedUserId; const invitation = await this.gameInvitationRepository.findOne({ @@ -161,7 +167,7 @@ export class GameService { async deleteInvitationByInvitingUserId( deleteInvitationParamDto: DeleteGameInvitationParamDto, ) { - const invitationId = deleteInvitationParamDto.gameInvitationId; + const invitationId = deleteInvitationParamDto.invitationId; const invitingUserId = deleteInvitationParamDto.cancelingUserId; const invitation = await this.gameInvitationRepository.findOne({ @@ -189,7 +195,7 @@ export class GameService { async deleteInvitationByInvitedUserId( deleteInvitationParamDto: DeleteGameInvitationParamDto, ) { - const invitationId = deleteInvitationParamDto.gameInvitationId; + const invitationId = deleteInvitationParamDto.invitationId; const invitedUserId = deleteInvitationParamDto.cancelingUserId; const invitation = await this.gameInvitationRepository.findOne({