Skip to content

Commit

Permalink
refactor: User컬렉션 Community필드에 채널 추가해주는 형식을 만드는 것을 모듈화
Browse files Browse the repository at this point in the history
  • Loading branch information
soomanbaek authored and NaayoungKwon committed Nov 25, 2022
1 parent 969486d commit b2eea18
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions server/apps/api/src/channel/channel.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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('채널 생성 중 오류 발생!');
Expand Down
6 changes: 6 additions & 0 deletions server/utils/addObjectForm.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export function addChannelToUserForm(communityId, channelId) {
const newChannel = {};
newChannel[`communities.${communityId.toString()}.channels.${channelId.toString()}`] = new Date();

return newChannel;
}

1 comment on commit b2eea18

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests Skipped Failures Errors Time
13 0 💤 1 ❌ 0 🔥 1m 2s ⏱️

Please sign in to comment.