MCPcopy Create free account
hub / github.com/CodeFox-Repo/codefox / saveMessage

Method saveMessage

backend/src/chat/chat.service.ts:207–231  ·  view source on GitHub ↗
(chatId: string, messageContent: string, role: MessageRole)

Source from the content-addressed store, hash-verified

205 where: { id: chatId, isDeleted: false },
206 });
207
208 if (chat) {
209 chat.isDeleted = true;
210 chat.isActive = false;
211 await this.chatRepository.save(chat);
212 return true;
213 }
214 return false;
215 }
216
217 async clearChatHistory(chatId: string): Promise<boolean> {
218 // Queued with the appends: clearing does not read the array first, but an
219 // append that started before the clear would write its stale copy back
220 // afterwards and undo it.
221 return ChatService.serialise(chatId, async () => {
222 const chat = await this.chatRepository.findOne({
223 where: { id: chatId, isDeleted: false },
224 });
225 if (chat) {
226 chat.messages = [];
227 chat.updatedAt = new Date();
228 await this.chatRepository.save(chat);
229 return true;
230 }
231 return false;
232 });
233 }
234

Callers 1

managerAgentFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected