(userId: string, newChatInput: NewChatInput)
| 109 | }) |
| 110 | .sort((a, b) => { |
| 111 | return a.createdAt.getTime() - b.createdAt.getTime(); |
| 112 | }); |
| 113 | } |
| 114 | |
| 115 | return chat ? chat.messages : []; |
| 116 | } |
| 117 | |
| 118 | async getChatDetails(chatId: string): Promise<Chat> { |
| 119 | const chat = await this.chatRepository.findOne({ |
| 120 | where: { id: chatId, isDeleted: false }, |
| 121 | relations: ['project'], |
| 122 | }); |
| 123 | |
| 124 | if (!chat) { |
| 125 | throw new NotFoundException('Chat not found'); |
| 126 | } |
| 127 | |
| 128 | try { |
| 129 | const messages = chat.messages || []; |