import { Notification, OllamaResponse } from "../types.js"; import { trimInputData } from "./util.js"; import { prisma } from "./main.js"; const storePromptData = async ( notification: Notification, ollamaResponseBody: OllamaResponse ) => { try { await prisma.response.updateMany({ where: { pleromaNotificationId: notification.id }, data: { response: ollamaResponseBody.response, request: trimInputData(notification.status.content), to: notification.account.fqn, isProcessing: false, isComplete: true, }, }); } catch (error: any) { throw new Error(error.message); } }; const storeUserData = async (notification: Notification): Promise => { try { await prisma.user.upsert({ where: { userFqn: notification.status.account.fqn }, update: { lastRespondedTo: new Date(Date.now()), }, create: { userFqn: notification.status.account.fqn, lastRespondedTo: new Date(Date.now()), }, }); } catch (error: any) { throw new Error(error.message); } }; export { storeUserData, storePromptData };