diff --git a/dump.rdb b/dump.rdb new file mode 100644 index 0000000..251dbc2 Binary files /dev/null and b/dump.rdb differ diff --git a/src/chat/chat.gateway.ts b/src/chat/chat.gateway.ts index 3a14147..9bfeef9 100644 --- a/src/chat/chat.gateway.ts +++ b/src/chat/chat.gateway.ts @@ -1,3 +1,4 @@ +import { UnauthorizedException } from '@nestjs/common'; import { InjectRepository } from '@nestjs/typeorm'; import { SubscribeMessage, @@ -34,6 +35,8 @@ export class ChatGateway implements OnGatewayInit, OnGatewayConnection, OnGatewa // JWT 유효성 검사 const { userID } = await this.userService.validateAccess(socket.handshake.headers.authorization); + if(!userID) throw new UnauthorizedException() + // 유저가 속한 채팅방 찾기 const groupList = await this.groupMappingEntity.findBy({ userID }); @@ -60,9 +63,9 @@ export class ChatGateway implements OnGatewayInit, OnGatewayConnection, OnGatewa message: string, room: string }): Promise { - const thisUser = (await this.userService.validateAccess(client.client.request.headers.authorization)).userID + const { userID } = (await this.userService.validateAccess(client.client.request.headers.authorization)) this.server.to(data.room).emit('message', { - userID: thisUser, + userID, message: data.message, room: data.room }) diff --git a/src/chat/chat.service.ts b/src/chat/chat.service.ts index c92a49e..1f78715 100644 --- a/src/chat/chat.service.ts +++ b/src/chat/chat.service.ts @@ -340,9 +340,12 @@ export class ChatService { .orderBy('isManager', 'DESC') .getRawMany(); + const isOrganization: boolean = count.length == 2 ? false: true + return { thisGroup, member: count, + isOrganization }; } diff --git a/src/profile/profile.service.ts b/src/profile/profile.service.ts index 34fed47..84ae434 100644 --- a/src/profile/profile.service.ts +++ b/src/profile/profile.service.ts @@ -37,10 +37,10 @@ export class ProfileService { const thisUser = await this.userEntity.findOneBy({ userID }); const thisStudent = await this.studentEntity.findOneBy({ userID }); - let isOnline = 0; + let isOnline = false; if (!thisUser || !thisStudent) throw new NotFoundException('존재하지 않는 유저'); - if(await this.redis.get(`${userID}AccessToken`)) isOnline = 1 + if(await this.redis.get(`${userID}AccessToken`)) isOnline = true return Object.assign(thisUser, thisStudent, {isOnline}); } @@ -173,10 +173,10 @@ export class ProfileService { const thisUser = await this.userEntity.findOneBy({ userID }); const thisTeacher = await this.teacherEntity.findOneBy({ userID }); - let isOnline = 0; + let isOnline = false; if (!thisUser || !thisTeacher) throw new NotFoundException('존재하지 않는 유저'); - if(await this.redis.get(`${userID}AccessToken`)) isOnline = 1 + if(await this.redis.get(`${userID}AccessToken`)) isOnline = true return Object.assign(thisUser, thisTeacher, {isOnline}); }