Skip to content

Commit

Permalink
Merge pull request #59 from tscenping/yubin
Browse files Browse the repository at this point in the history
feat: createChannel response에 channelId 추가 #16
  • Loading branch information
tomatozil authored Dec 5, 2023
2 parents 600235a + 9da24b7 commit cb5a0c2
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
2 changes: 1 addition & 1 deletion BE-config
22 changes: 17 additions & 5 deletions src/channels/channels.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { ChannelListResponseDto } from './dto/channel-list-response.dto';
import { ChannelListReturnDto } from './dto/channel-list-return.dto';
import { ChannelUsersResponseDto } from './dto/channel-users-response.dto';
import { CreateChannelRequestDto } from './dto/creat-channel-request.dto';
import { CreateChannelResponseDto } from './dto/create-channel-response.dto';
import { CreateChannelUserParamDto } from './dto/create-channel-user-param.dto';
import { CreateInvitationParamDto } from './dto/create-invitation-param.dto';
import { DmChannelListResponseDto } from './dto/dmchannel-list-response.dto';
Expand All @@ -31,7 +32,10 @@ export class ChannelsService {

private readonly logger = new Logger(ChannelsService.name);

async createChannel(userId: number, channelInfo: CreateChannelRequestDto) {
async createChannel(
userId: number,
channelInfo: CreateChannelRequestDto,
): Promise<CreateChannelResponseDto> {
// DM 채널인 경우 예외 처리
if (channelInfo.channelType === ChannelType.DM) {
const channelId = await this.validateDmChannel(
Expand All @@ -47,8 +51,14 @@ export class ChannelsService {
);
const myChannelUserType = channelUserInfoList.find(
(channelUser) => channelUser.userId === userId,
)?.channelUserType;
return { channelUser: channelUserInfoList, myChannelUserType };
)!.channelUserType;

const createChannelResponseDto = {
channelId,
channelUsers: channelUserInfoList,
myChannelUserType,
};
return createChannelResponseDto;
}
}

Expand Down Expand Up @@ -95,10 +105,12 @@ export class ChannelsService {
`channel ${channel.id} is created. user count: ${userCount}`,
);

return {
channelUser: channelUserInfoList,
const createChannelResponseDto = {
channelId: channel.id,
channelUsers: channelUserInfoList,
myChannelUserType: ChannelUserType.OWNER,
};
return createChannelResponseDto;
}

async enterChannel(userId: number, channelId: number) {
Expand Down
8 changes: 8 additions & 0 deletions src/channels/dto/create-channel-response.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { ChannelUserType } from 'src/common/enum';
import { ChannelUserInfoReturnDto } from './channel-user-info-return.dto';

export type CreateChannelResponseDto = {
channelId: number;
channelUsers: ChannelUserInfoReturnDto[];
myChannelUserType: ChannelUserType;
};

0 comments on commit cb5a0c2

Please sign in to comment.