Skip to content

Commit

Permalink
Merge pull request #72 from tscenping/jangcho
Browse files Browse the repository at this point in the history
fix(channel): recover joinChannelRoom logic also add notice dto
  • Loading branch information
tomatozil authored Dec 13, 2023
2 parents 544f7b7 + a633ffa commit d1b9756
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
14 changes: 14 additions & 0 deletions src/channels/channels.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@ export class ChannelsController {
const createChannelResponseDto =
await this.channelsService.createChannel(user.id, channelInfo);

if (user.channelSocketId) {
this.channelsGateway.joinChannelRoom(
createChannelResponseDto.channelId.toString(),
user.channelSocketId,
);
}

return createChannelResponseDto;
}

Expand Down Expand Up @@ -132,6 +139,13 @@ export class ChannelsController {

const channelUsersResponseDto =
await this.channelsService.createChannelUser(channelUserParamDto);

if (user.channelSocketId) {
this.channelsGateway.joinChannelRoom(
channelId.toString(),
user.channelSocketId,
);
}

return channelUsersResponseDto ;
}
Expand Down
7 changes: 5 additions & 2 deletions src/channels/channels.gateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,11 +258,14 @@ export class ChannelsGateway
const invitedUser = await this.usersRepository.findOne({
where: { id: data.invitedUserId },
});
const invitationId = data.invitationId;

const invitationEmitDto = {
invitationId: data.invitationId,
};

if (!invitedUser || invitedUser.status === UserStatus.OFFLINE || !invitedUser.channelSocketId) {
throw WSBadRequestException('유저가 유효하지 않습니다.');
}
this.server.to(invitedUser.channelSocketId).emit('privateAlert', invitationId);
this.server.to(invitedUser.channelSocketId).emit('privateAlert', invitationEmitDto);
}
}
5 changes: 5 additions & 0 deletions src/channels/dto/event-message-on.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,9 @@ export class EventMessageOnDto {
@IsPositive()
@IsNotEmpty()
channelId: number;

@IsString()
@IsNotEmpty()
// 따로 리터럴이 지정되지 않으면 디폴트로 'MESSAGE'가 들어간다.
notice: 'ADMIN' | 'BAN' | 'KICK' | 'MUTE'| 'JOIN' | 'EXIT' | 'MESSAGE' = 'MESSAGE';
}

0 comments on commit d1b9756

Please sign in to comment.