diff --git a/server/apps/api/src/channel/channel.controller.ts b/server/apps/api/src/channel/channel.controller.ts index 4dae0957..dbd9417a 100644 --- a/server/apps/api/src/channel/channel.controller.ts +++ b/server/apps/api/src/channel/channel.controller.ts @@ -17,8 +17,11 @@ export class ChannelController { async createChannel(@Body() createChannelDto: CreateChannelDto, @Req() req: any) { const requestUserId = req.user._id; try { - await this.channelService.createChannel({ ...createChannelDto, managerId: requestUserId }); - return responseForm(200, { message: '채널 생성 성공!' }); + const newChannel = await this.channelService.createChannel({ + ...createChannelDto, + managerId: requestUserId, + }); + return responseForm(200, newChannel); } catch (error) { this.logger.error(JSON.stringify(error.response)); throw error; diff --git a/server/apps/api/src/channel/channel.service.ts b/server/apps/api/src/channel/channel.service.ts index ca93f295..85011268 100644 --- a/server/apps/api/src/channel/channel.service.ts +++ b/server/apps/api/src/channel/channel.service.ts @@ -42,6 +42,8 @@ export class ChannelService { // 공개 채널일 경우 : 채널 유저에 커뮤니티 사용자 모두 존재 await this.addUserToChannel(community._id, channel._id, community.users); } + + return getChannelBasicInfo(channel); } async modifyChannel(modifyChannelDto: ModifyChannelDto) { @@ -86,8 +88,15 @@ export class ChannelService { } async getChannelInfo(channel_id) { - const channelInfo = await this.channelRepository.findOne({ _id: channel_id }); - return getChannelBasicInfo(channelInfo); + const channel = await this.channelRepository.findOne({ _id: channel_id }); + const users = await Promise.all( + channel.users.map(async (user_id) => { + const user = await this.userRepository.findById(user_id); + return getUserBasicInfo(user); + }), + ); + channel['users'] = users as any; + return getChannelBasicInfo(channel); } async exitChannel(exitChannelDto: ExitChannelDto) { diff --git a/server/apps/api/src/channel/helper/getChannelBasicInfo.ts b/server/apps/api/src/channel/helper/getChannelBasicInfo.ts index 1b569440..c18ce137 100644 --- a/server/apps/api/src/channel/helper/getChannelBasicInfo.ts +++ b/server/apps/api/src/channel/helper/getChannelBasicInfo.ts @@ -9,7 +9,6 @@ export const getChannelBasicInfo = (channel) => { type: channel.type, isPrivate: channel.isPrivate, users: channel.users, - chatLists: channel.chatLists, deletedAt: channel.deletedAt, }; };