Skip to content

Commit 2ebfb01

Browse files
authored
Merge pull request #392 from PromptPlace/develop
Develop -> Main
2 parents 1d583fb + ef7bdf2 commit 2ebfb01

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

src/chat/repositories/chat.repository.ts

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@ export class ChatRepository {
1818
user_id1: userId1,
1919
user_id2: userId2,
2020
last_message_id: null,
21+
// 참여자 생성
22+
participants: {
23+
create: [
24+
{ user_id: userId1},
25+
{ user_id: userId2},
26+
],
27+
}
2128
},
2229
});
2330
}
@@ -111,6 +118,8 @@ export class ChatRepository {
111118
const where: Prisma.ChatParticipantWhereInput = {
112119
user_id: userId,
113120
left_at: null, // 나가지 않은 방
121+
chatRoom: {
122+
is: { last_message_id: { not: null } } }, // 메시지가 있는 방
114123
};
115124

116125
if (filter === "pinned") {
@@ -123,16 +132,17 @@ export class ChatRepository {
123132

124133
if (search && search.trim().length > 0) {
125134
where.chatRoom = {
126-
participants: {
127-
some: {
128-
user_id: { not: userId },
129-
user: {
130-
nickname: {
131-
contains: search.trim(),
135+
is: {
136+
...(where.chatRoom as any)?.is,
137+
participants: {
138+
some: {
139+
user_id: { not: userId },
140+
user: {
141+
nickname: {contains: search.trim()},
132142
},
133143
},
134144
},
135-
},
145+
}
136146
};
137147
}
138148

src/chat/routes/chat.route.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ router.post("/rooms", authenticateJwt, createOrGetChatRoom);
6868
* get:
6969
* summary: 채팅방 상세 조회
7070
* description: >
71-
* 채팅방 상세 정보(상대 정보/차단 상태/메시지 목록/페이지 정보)를 조회합니다.
71+
* 채팅방 상세 정보(상대 정보/차단 상태/메시지 목록/페이지 정보)를 조회합니다.<br/>
7272
* 메시지는 오래된 순(ASC)으로 반환되며, cursor 기반으로 과거 메시지를 추가로 불러올 수 있습니다.
7373
* tags: [Chat]
7474
* security:
@@ -227,7 +227,8 @@ router.get("/rooms/:roomId", authenticateJwt, getChatRoomDetail);
227227
* get:
228228
* summary: 채팅방 목록 조회
229229
* description: >
230-
* 내 채팅방 목록을 조회합니다.
230+
* 내 채팅방 목록을 조회합니다.<br/>
231+
* 메세지가 존재하지 않으면 해당 채팅방은 목록에서 제외됩니다.<br/>
231232
* filter(전체/안읽음/고정), search(상대 닉네임 검색), cursor 기반 페이징을 지원합니다.
232233
* tags: [Chat]
233234
* security:

0 commit comments

Comments
 (0)