diff --git a/src/channels/channels.controller.ts b/src/channels/channels.controller.ts index a58c45b..e005a3a 100644 --- a/src/channels/channels.controller.ts +++ b/src/channels/channels.controller.ts @@ -401,14 +401,15 @@ export class ChannelsController { }) async rejectInvitation( @GetUser() user: User, - @Param('channelinvitationId', ParseIntPipe, PositiveIntPipe) + @Param('channelInvitationId', ParseIntPipe, PositiveIntPipe) invitationId: number, ) { const deleteInvitationParamDto: DeleteChannelInvitationParamDto = { cancelingUserId: user.id, invitationId: invitationId, }; - - await this.channelsService.rejectInvitation(deleteInvitationParamDto); + return await this.channelsService.rejectInvitation( + deleteInvitationParamDto, + ); } } diff --git a/src/channels/channels.service.ts b/src/channels/channels.service.ts index 24b6ef1..410e106 100644 --- a/src/channels/channels.service.ts +++ b/src/channels/channels.service.ts @@ -3,7 +3,11 @@ import { BadRequestException, Injectable, Logger } from '@nestjs/common'; import * as bycrypt from 'bcrypt'; import { Redis } from 'ioredis'; import { MUTE_TIME } from 'src/common/constants'; -import { ChannelType, ChannelUserType } from 'src/common/enum'; +import { + ChannelEventType, + ChannelType, + ChannelUserType, +} from 'src/common/enum'; import { GatewayCreateChannelInvitationParamDto } from 'src/game/dto/gateway-create-channelInvitation-param-dto'; import { User } from 'src/users/entities/user.entity'; import { UsersRepository } from 'src/users/users.repository'; @@ -591,14 +595,24 @@ export class ChannelsService { async acceptInvitation( createChannelUserParamDto: ChannelInvitationParamDto, ): Promise { + const channelInvitationInfo = + await this.channelInvitationRepository.findOne({ + where: { + id: createChannelUserParamDto.invitationId, + }, + }); + if (!channelInvitationInfo?.channelId || !channelInvitationInfo.id) + throw new BadRequestException( + `channel ${channelInvitationInfo?.id} does not exist`, + ); const channelInfo = await this.channelsRepository.findOne({ where: { - id: createChannelUserParamDto.invitationId, + id: channelInvitationInfo.channelId, }, }); - if (!channelInfo || !channelInfo.name) + if (!channelInfo?.id || !channelInfo.name) throw new BadRequestException( - `channel ${createChannelUserParamDto.invitationId} does not exist`, + `channel ${channelInfo?.id} does not exist`, ); const channelId = channelInfo.id; diff --git a/src/channels/dto/channel-Invitation-list-response.dto.ts b/src/channels/dto/channel-Invitation-list-response.dto.ts index e9e66a4..e60eca1 100644 --- a/src/channels/dto/channel-Invitation-list-response.dto.ts +++ b/src/channels/dto/channel-Invitation-list-response.dto.ts @@ -1,7 +1,7 @@ -import { ChannelInvitationListDto } from "./channel-Invitation-list-return.dto"; +import { ChannelInvitationListDto } from './channel-Invitation-list-return.dto'; export type ChannelInvitationListResponseDto = { - channelId : number; - channelName : string; - channelUsers: ChannelInvitationListDto[]; -}; \ No newline at end of file + channelId: number; + channelName: string; + channelUsers: ChannelInvitationListDto[]; +};