delete message API
This commit is contained in:
parent
c8f624de9c
commit
79e988be09
|
|
@ -522,7 +522,7 @@ export class App {
|
||||||
res.status(404).send(`Chatflow ${chatflowid} not found`)
|
res.status(404).send(`Chatflow ${chatflowid} not found`)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const chatId = (req.query?.chatId as string) ?? (await getChatId(chatflowid))
|
const chatId = req.query?.chatId as string
|
||||||
const memoryType = req.query?.memoryType as string | undefined
|
const memoryType = req.query?.memoryType as string | undefined
|
||||||
const sessionId = req.query?.sessionId as string | undefined
|
const sessionId = req.query?.sessionId as string | undefined
|
||||||
const chatType = req.query?.chatType as string | undefined
|
const chatType = req.query?.chatType as string | undefined
|
||||||
|
|
@ -546,7 +546,8 @@ export class App {
|
||||||
return res.status(500).send('Error clearing chat messages')
|
return res.status(500).send('Error clearing chat messages')
|
||||||
}
|
}
|
||||||
|
|
||||||
const deleteOptions: FindOptionsWhere<ChatMessage> = { chatflowid, chatId }
|
const deleteOptions: FindOptionsWhere<ChatMessage> = { chatflowid }
|
||||||
|
if (chatId) deleteOptions.chatId = chatId
|
||||||
if (memoryType) deleteOptions.memoryType = memoryType
|
if (memoryType) deleteOptions.memoryType = memoryType
|
||||||
if (sessionId) deleteOptions.sessionId = sessionId
|
if (sessionId) deleteOptions.sessionId = sessionId
|
||||||
if (chatType) deleteOptions.chatType = chatType
|
if (chatType) deleteOptions.chatType = chatType
|
||||||
|
|
@ -634,7 +635,7 @@ export class App {
|
||||||
return res.json(result)
|
return res.json(result)
|
||||||
})
|
})
|
||||||
|
|
||||||
// Delete all chatmessages from chatflowid
|
// Delete all credentials from chatflowid
|
||||||
this.app.delete('/api/v1/credentials/:id', async (req: Request, res: Response) => {
|
this.app.delete('/api/v1/credentials/:id', async (req: Request, res: Response) => {
|
||||||
const results = await this.AppDataSource.getRepository(Credential).delete({ id: req.params.id })
|
const results = await this.AppDataSource.getRepository(Credential).delete({ id: req.params.id })
|
||||||
return res.json(results)
|
return res.json(results)
|
||||||
|
|
@ -1791,23 +1792,6 @@ export class App {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get first chat message id
|
|
||||||
* @param {string} chatflowid
|
|
||||||
* @returns {string}
|
|
||||||
*/
|
|
||||||
export async function getChatId(chatflowid: string): Promise<string> {
|
|
||||||
// first chatmessage id as the unique chat id
|
|
||||||
const firstChatMessage = await getDataSource()
|
|
||||||
.getRepository(ChatMessage)
|
|
||||||
.createQueryBuilder('cm')
|
|
||||||
.select('cm.id')
|
|
||||||
.where('chatflowid = :chatflowid', { chatflowid })
|
|
||||||
.orderBy('cm.createdDate', 'ASC')
|
|
||||||
.getOne()
|
|
||||||
return firstChatMessage ? firstChatMessage.id : ''
|
|
||||||
}
|
|
||||||
|
|
||||||
let serverApp: App | undefined
|
let serverApp: App | undefined
|
||||||
|
|
||||||
export async function getAllChatFlow(): Promise<IChatFlow[]> {
|
export async function getAllChatFlow(): Promise<IChatFlow[]> {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue