add the feature when startup chat in LAUNCH_BOSS_SITE recommend, save the startup record

This commit is contained in:
geekgeekrun
2024-09-29 09:00:39 +08:00
parent e12cfe73ac
commit 16779b54e5
3 changed files with 52 additions and 19 deletions

View File

@@ -15,7 +15,7 @@ import { VChatStartupLog } from "./entity/VChatStartupLog";
import sqlite3 from 'sqlite3';
import * as cliHighlight from 'cli-highlight';
import { saveJobInfoFromRecommendPage } from "./handlers";
import { saveChatStartupRecord, saveJobInfoFromRecommendPage } from "./handlers";
Boolean(cliHighlight);
export function initDb(dbFilePath) {
@@ -76,26 +76,12 @@ export default class SqlitePlugin {
hooks.jobDetailIsGetFromRecommendList.tapPromise("SqlitePlugin", async (_jobInfo) => {
const ds = await this.initPromise;
saveJobInfoFromRecommendPage(ds, _jobInfo);
await saveJobInfoFromRecommendPage(ds, _jobInfo);
});
hooks.newChatStartup.tapPromise("SqlitePlugin", async (_jobInfo) => {
const { jobInfo } = _jobInfo;
//#region chat-startup-log
const chatStartupLog = new ChatStartupLog()
const chatStartupLogPayload: Partial<ChatStartupLog> = {
date: new Date(),
encryptCurrentUserId: this.userInfo.encryptUserId,
encryptJobId: jobInfo.encryptId,
}
Object.assign(chatStartupLog, chatStartupLogPayload)
const ds = await this.initPromise;
const chatStartupLogRepository = ds.getRepository(ChatStartupLog);
await chatStartupLogRepository.save(chatStartupLog);
//#endregion
return
return await saveChatStartupRecord(ds, _jobInfo, this.userInfo);
});
}
}