From d615739f5b94280a9dbf96826b620ca8796783c3 Mon Sep 17 00:00:00 2001 From: josc146 Date: Fri, 21 Apr 2023 21:18:26 +0800 Subject: [PATCH] chore: add `createdAt` and `updatedAt` to session --- src/config/localSession.mjs | 1 + src/utils/init-session.mjs | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/src/config/localSession.mjs b/src/config/localSession.mjs index 35076eb..f31ccf4 100644 --- a/src/config/localSession.mjs +++ b/src/config/localSession.mjs @@ -51,6 +51,7 @@ export const getSession = async (sessionId) => { } export const updateSession = async (newSession) => { + newSession.updatedAt = new Date().toISOString() const currentSessions = await getSessions() currentSessions[ currentSessions.findIndex((session) => session.sessionId === newSession.sessionId) diff --git a/src/utils/init-session.mjs b/src/utils/init-session.mjs index 29b2b0d..d571013 100644 --- a/src/utils/init-session.mjs +++ b/src/utils/init-session.mjs @@ -7,6 +7,8 @@ import { v4 as uuidv4 } from 'uuid' * @property {Object[]|null} conversationRecords * @property {string|null} sessionName * @property {string|null} sessionId + * @property {string|null} createdAt + * @property {string|null} updatedAt * @property {string|null} aiName * @property {string|null} modelName * @property {boolean|null} autoClean @@ -45,6 +47,8 @@ export function initSession({ sessionName, sessionId: uuidv4(), + createdAt: new Date().toISOString(), + updatedAt: new Date().toISOString(), aiName: modelName ? Models[modelName].desc : null, modelName,