From 99d3681d9a471df040efe4cf4939b35476c9b38a Mon Sep 17 00:00:00 2001 From: yubinquitous Date: Mon, 4 Dec 2023 18:26:03 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EC=B1=84=EB=84=90=20=EC=83=9D=EC=84=B1?= =?UTF-8?q?=20=EC=8B=9C=20=EC=B1=84=EB=84=90=20=EC=9E=85=EC=9E=A5=EA=B3=BC?= =?UTF-8?q?=20=EB=8F=99=EC=9D=BC=ED=95=9C=20response=EB=A1=9C=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD=20#16?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/channels/channels.service.ts | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/channels/channels.service.ts b/src/channels/channels.service.ts index 6872b57..2d1aab0 100644 --- a/src/channels/channels.service.ts +++ b/src/channels/channels.service.ts @@ -38,9 +38,17 @@ export class ChannelsService { userId, channelInfo.userId!, ); + // 이미 DM 채널이 존재한다면 해당 채널에 대한 정보를 반환한다. if (channelId) { - // 이미 DM 채널이 존재하는 경우 - return { channelId }; + const channelUserInfoList = + await this.channelUsersRepository.findChannelUserInfoList( + userId, + channelId, + ); + const myChannelUserType = channelUserInfoList.find( + (channelUser) => channelUser.userId === userId, + )?.channelUserType; + return { channelUser: channelUserInfoList, myChannelUserType }; } } @@ -61,6 +69,7 @@ export class ChannelsService { let userCount = 1; + // DM 일 경우 상대방도 channelUsers에 추가 if (channel.channelType === ChannelType.DM) { const targetChannelUser = this.channelUsersRepository.create({ channelId: channel.id, @@ -73,13 +82,23 @@ export class ChannelsService { ++userCount; } + // channelUserList 조회 + const channelUserInfoList = + await this.channelUsersRepository.findChannelUserInfoList( + userId, + channel.id, + ); + // TODO: 채널에 소환된 유저에게 알림 전송. DM의 경우에만 해당 // TODO: cache에 user count 저장 this.logger.log( `channel ${channel.id} is created. user count: ${userCount}`, ); - return { channelId: channel.id }; + return { + channelUser: channelUserInfoList, + myChannelUserType: ChannelUserType.OWNER, + }; } async enterChannel(userId: number, channelId: number) {