File tree 1 file changed +13
-2
lines changed
1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -23,16 +23,27 @@ export class ChatRoomService {
23
23
userId,
24
24
} )
25
25
. andWhere ( 'chatRoom.status = :status' , { status : 'activated' } )
26
+ . andWhere ( 'chatRoom.requestStatus = :requestStatus' , {
27
+ requestStatus : 'accepted' ,
28
+ } )
26
29
. orderBy ( 'chatMessages.createdAt' , 'DESC' )
27
30
. getMany ( ) ;
28
31
29
32
// 각 채팅방에서 최신 메시지를 선택
30
33
const chatRoomsWithLatestMessages = chatRooms . map ( ( room ) => {
34
+ const otherUser =
35
+ room . fromUser . id === userId ? room . toUser : room . fromUser ;
31
36
const latestMessage =
32
37
room . chatMessages . length > 0 ? room . chatMessages [ 0 ] : null ; // 가장 최근 메시지 선택
38
+
33
39
return {
34
- ...room ,
35
- latestMessage, // 최신 메시지 포함
40
+ chatRoomId : room . id ,
41
+ otherUser : {
42
+ id : otherUser . id ,
43
+ nickname : otherUser . nickname ,
44
+ profileUrl : otherUser . profilePictureUrl ,
45
+ } ,
46
+ latestMessage : latestMessage ,
36
47
} ;
37
48
} ) ;
38
49
return chatRoomsWithLatestMessages ;
You can’t perform that action at this time.
0 commit comments