Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
soyeonkim0227 committed Dec 29, 2023
2 parents 5a1344b + 5900dfb commit 15edd3d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
Binary file added dump.rdb
Binary file not shown.
7 changes: 5 additions & 2 deletions src/chat/chat.gateway.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { UnauthorizedException } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import {
SubscribeMessage,
Expand Down Expand Up @@ -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 });

Expand All @@ -60,9 +63,9 @@ export class ChatGateway implements OnGatewayInit, OnGatewayConnection, OnGatewa
message: string,
room: string
}): Promise<null> {
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
})
Expand Down
3 changes: 3 additions & 0 deletions src/chat/chat.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -340,9 +340,12 @@ export class ChatService {
.orderBy('isManager', 'DESC')
.getRawMany();

const isOrganization: boolean = count.length == 2 ? false: true

return {
thisGroup,
member: count,
isOrganization
};
}

Expand Down
8 changes: 4 additions & 4 deletions src/profile/profile.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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});
}
Expand Down Expand Up @@ -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});
}
Expand Down

0 comments on commit 15edd3d

Please sign in to comment.