save autoStartupChatRecordId, chatStartupFrom in ChatStartupLog

This commit is contained in:
geekgeekrun
2024-10-19 00:50:10 +08:00
parent deb4ad580c
commit d2022ea6dc
10 changed files with 100 additions and 14 deletions

View File

@@ -79,18 +79,20 @@ const runAutoChat = async () => {
}
const hooks = {
daemonInitialized: new AsyncSeriesHook(),
puppeteerLaunched: new SyncHook(),
pageLoaded: new SyncHook(),
cookieWillSet: new SyncHook(['cookies']),
userInfoResponse: new AsyncSeriesHook(['userInfo']),
jobDetailIsGetFromRecommendList: new AsyncSeriesHook(['userInfo']),
newChatWillStartup: new AsyncSeriesHook(['positionInfoDetail']),
newChatStartup: new AsyncSeriesHook(['positionInfoDetail']),
newChatStartup: new AsyncSeriesHook(['positionInfoDetail', 'chatRunningContext']),
noPositionFoundForCurrentJob: new SyncHook(),
noPositionFoundAfterTraverseAllJob: new SyncHook(),
errorEncounter: new SyncHook(['errorInfo'])
}
initPlugins(hooks)
await hooks.daemonInitialized.promise()
pipeWriteRegardlessError(
pipe,
JSON.stringify({

View File

@@ -18,6 +18,7 @@ import packageJson from '@geekgeekrun/launch-bosszhipin-login-page-with-preload-
import { Target } from 'puppeteer'
import { pipeWriteRegardlessError } from '../utils/pipe'
import * as JSONStream from 'JSONStream'
import { ChatStartupFrom } from '@geekgeekrun/sqlite-plugin/dist/entity/ChatStartupLog'
const __dirname = url.fileURLToPath(new URL('.', import.meta.url))
const isRunFromUi = Boolean(process.env.MAIN_BOSSGEEKGO_UI_RUN_MODE)
@@ -89,9 +90,16 @@ const attachRequestsListener = async (target: Target) => {
const currentUserInfo = await page.evaluate(
'document.querySelector(".job-detail-box").__vue__.$store.state.userInfo'
)
await saveChatStartupRecord(await dbInitPromise, currentJobData, {
encryptUserId: currentUserInfo.encryptUserId
})
await saveChatStartupRecord(
await dbInitPromise,
currentJobData,
{
encryptUserId: currentUserInfo.encryptUserId
},
{
chatStartupFrom: ChatStartupFrom.ManuallyFromRecommendList
}
)
}
})