import ChatHistory from './chatHistory.js' import Feedback from './feedback.js' export interface HistoryMessage { msgId: string, quoteId?: string, botId: string, buttons: any[], content: string, conversionId: string, goods: any[], text: string, timestamp: number, title: string, type: string, position: string, isBot: boolean, like?: boolean, unlike?: boolean, unlikeReason?: string, fileUrl?: string, mediaType?: string, } export interface FeedbackMessage { answer: string | undefined, msgId: string, quoteId?: string, botId: string, buttons: any[], content: string, conversionId: string, goods: any[], text: string, timestamp: number, title: string, type: string, position: string, isBot: boolean, like?: boolean, unlike?: boolean, unlikeReason?: string, question: string, fileUrl?: string, mediaType?: string, } export interface UpdateMessage { like?: boolean, unlike?: boolean, unlikeReason?: string, } export async function saveMessage (info: HistoryMessage) { return await new ChatHistory(info).save() } export async function updateMessage (msgId: string, info: UpdateMessage) { return await ChatHistory.updateOne({ msgId }, info) } export async function getMessage (msgId: string): Promise { return await ChatHistory.findOne({ msgId }) } export async function saveFeedback (info: FeedbackMessage) { return await new Feedback(info).save() }