Skip to content

Commit

Permalink
merge main into yubin
Browse files Browse the repository at this point in the history
  • Loading branch information
yubinquitous committed Dec 15, 2023
2 parents 63acf79 + 2847484 commit 2094bb5
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 12 deletions.
7 changes: 4 additions & 3 deletions src/channels/channels.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
}
}
22 changes: 18 additions & 4 deletions src/channels/channels.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -591,14 +595,24 @@ export class ChannelsService {
async acceptInvitation(
createChannelUserParamDto: ChannelInvitationParamDto,
): Promise<ChannelInvitationListResponseDto> {
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;
Expand Down
10 changes: 5 additions & 5 deletions src/channels/dto/channel-Invitation-list-response.dto.ts
Original file line number Diff line number Diff line change
@@ -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[];
};
channelId: number;
channelName: string;
channelUsers: ChannelInvitationListDto[];
};

0 comments on commit 2094bb5

Please sign in to comment.