From 7b8d6350b8bbb50c8b379cb05371526a25ec1b5e Mon Sep 17 00:00:00 2001 From: Oscar Date: Fri, 29 May 2026 00:45:31 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=8C=9F=20feat(file):=20=D0=BE=D0=B1=D0=BD?= =?UTF-8?q?=D0=BE=D0=B2=D0=BB=D0=B5=D0=BD=D1=8B=20=D0=B7=D0=B0=D0=BF=D1=80?= =?UTF-8?q?=D0=BE=D1=81=D1=8B=20=D0=BA=20=D0=B1=D0=B0=D0=B7=D0=B5=20=D0=B4?= =?UTF-8?q?=D0=B0=D0=BD=D0=BD=D1=8B=D1=85=20=D0=B4=D0=BB=D1=8F=20=D0=BE?= =?UTF-8?q?=D0=B1=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F/=D1=81?= =?UTF-8?q?=D0=BE=D0=B7=D0=B4=D0=B0=D0=BD=D0=B8=D1=8F=20=D0=BF=D0=BE=D0=BB?= =?UTF-8?q?=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8F.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hh/bot-commands.ts | 11 ++++++++--- src/hh/scraper.ts | 5 +++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/hh/bot-commands.ts b/src/hh/bot-commands.ts index 00328a0..26ebf7b 100644 --- a/src/hh/bot-commands.ts +++ b/src/hh/bot-commands.ts @@ -39,7 +39,11 @@ async function doLogin(chatId: number, email: string): Promise { await bot.sendMessage(chatId, '🔄 Логинюсь...') try { await login(email, chatId) - await prisma.user.update({ where: { telegramId: chatId }, data: { hhEmail: email } }) + await prisma.user.upsert({ + where: { telegramId: chatId }, + update: { hhEmail: email }, + create: { telegramId: chatId, hhEmail: email, Settings: { create: {} } }, + }) const state = getState(chatId) @@ -380,9 +384,10 @@ export function registerHHCommands() { if (state.awaitingPrompt) { state.awaitingPrompt = false await bot.deleteMessage(chatId, msg.message_id).catch(() => {}) - await prisma.user.update({ + await prisma.user.upsert({ where: { telegramId: chatId }, - data: { prompt: msg.text }, + update: { prompt: msg.text }, + create: { telegramId: chatId, prompt: msg.text, Settings: { create: {} } }, }) await bot.sendMessage(chatId, '✅ Промт сохранён') return diff --git a/src/hh/scraper.ts b/src/hh/scraper.ts index a10f839..a0b359e 100644 --- a/src/hh/scraper.ts +++ b/src/hh/scraper.ts @@ -96,9 +96,10 @@ export async function login(email: string, chatId: number): Promise { await page.waitForSelector('[data-qa="profileAndResumes-button"]', { timeout: 15000 }) const cookies = await context.cookies() - await prisma.user.update({ + await prisma.user.upsert({ where: { telegramId: chatId }, - data: { session: JSON.stringify(cookies, null, 2) }, + update: { session: JSON.stringify(cookies, null, 2) }, + create: { telegramId: chatId, session: JSON.stringify(cookies, null, 2), Settings: { create: {} } }, }) await bot.sendMessage(chatId, cookies.length > 0 ? '✅ Авторизация выполнена' : '❌ Произошла ошибка')