From b2eea183824ff79f96c506fcfafc53b2aef6d17b Mon Sep 17 00:00:00 2001 From: soomanbaek Date: Fri, 25 Nov 2022 01:47:50 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20User=EC=BB=AC=EB=A0=89=EC=85=98=20C?= =?UTF-8?q?ommunity=ED=95=84=EB=93=9C=EC=97=90=20=EC=B1=84=EB=84=90=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=ED=95=B4=EC=A3=BC=EB=8A=94=20=ED=98=95?= =?UTF-8?q?=EC=8B=9D=EC=9D=84=20=EB=A7=8C=EB=93=9C=EB=8A=94=20=EA=B2=83?= =?UTF-8?q?=EC=9D=84=20=EB=AA=A8=EB=93=88=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/apps/api/src/channel/channel.service.ts | 4 ++-- server/utils/addObjectForm.ts | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 server/utils/addObjectForm.ts diff --git a/server/apps/api/src/channel/channel.service.ts b/server/apps/api/src/channel/channel.service.ts index 378728ff..dd1dadc6 100644 --- a/server/apps/api/src/channel/channel.service.ts +++ b/server/apps/api/src/channel/channel.service.ts @@ -3,6 +3,7 @@ import { ChannelRepository } from '@repository/channel.repository'; import { CreateChannelDto } from '@api/src/channel/dto'; import { CommunityRepository } from '@repository/community.repository'; import { UserRepository } from '@repository/user.repository'; +import { addChannelToUserForm } from '@utils/addObjectForm'; @Injectable() export class ChannelService { @@ -29,8 +30,7 @@ export class ChannelService { ]); // 유저 목록에 자신이 속한 채널 업데이트 - const newChannel = {}; - newChannel[`communities.${community._id.toString()}.channels.${channel._id}`] = new Date(); + const newChannel = addChannelToUserForm(community._id, channel._id); await this.userRepository.updateObject({ _id: createChannelDto.managerId }, newChannel); } catch (error) { throw new BadRequestException('채널 생성 중 오류 발생!'); diff --git a/server/utils/addObjectForm.ts b/server/utils/addObjectForm.ts new file mode 100644 index 00000000..1514c0ed --- /dev/null +++ b/server/utils/addObjectForm.ts @@ -0,0 +1,6 @@ +export function addChannelToUserForm(communityId, channelId) { + const newChannel = {}; + newChannel[`communities.${communityId.toString()}.channels.${channelId.toString()}`] = new Date(); + + return newChannel; +}