Skip to content

Commit

Permalink
Merge pull request #3 from ESC-CoM/fix/chat-list
Browse files Browse the repository at this point in the history
[Fix] user의 room 정보가 제대로 안오는 이슈 해결
  • Loading branch information
juyeong-s authored Sep 1, 2024
2 parents 329b169 + 6c50a26 commit 473769c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { AllExceptionsFilter } from './all/all.filter';
import * as https from 'https';

export const CONFIG_URL = `${process.env.SCHEME}://${process.env.ESC_CONFIG}${process.env.ESC_CONFIG_PORT}`;
// NOTE: dev사용 안하고 싶으면 https://api.meething.net로 바꿔서 사용
export const API_URL = `https://${process.env.ESC_API}${process.env.ESC_API_PORT}`;

export async function bootstrap() {
Expand Down
2 changes: 1 addition & 1 deletion src/room/meeting/meeting.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ export class MeetingService {
)
.then((result) => result.json())
.then((res) => res.data);
return result;
return result ?? [];
}
}
1 change: 0 additions & 1 deletion src/room/room.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ export class RoomController {
@Req() request: Request & { user: { id: string } },
) {
const chatRoom = await this.service.findDetail(roomId);
console.log(chatRoom);
return new BaseResponse(new RoomDto(chatRoom, request.user.id));
}

Expand Down
8 changes: 6 additions & 2 deletions src/room/room.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ export class RoomService {
const meetings = await this.meetingService.findByIdIn(
rooms.map((room) => room.meeting.id),
);
rooms.forEach(
(room) =>
user.rooms.forEach(
({ room }) =>
(room.meeting = meetings.find(
(meeting) => meeting.id === room.meeting.id,
)),
Expand All @@ -105,19 +105,23 @@ export class RoomService {
senderId: string;
}) {
const sender = await this.userService.findById(chat.senderId);

const room = await this.repository.findOne({
_id: new Types.ObjectId(chat.roomId),
});

const createdChat = await this.chatService.sendChat({
content: { message: chat.message },
room: room._id,
sender: sender,
});

const users = await this.userService.findByRoomId(room._id);
await this.repository.findOneAndUpdate(
{ _id: room._id },
{ $set: { lastChat: createdChat } },
);

const result = new ChatDto(createdChat);
this.detailGateway.io.server
.of(`/chat-rooms/${chat.roomId}`)
Expand Down

0 comments on commit 473769c

Please sign in to comment.