mirror of
https://github.com/hempyhemp/hh-auto-reply.git
synced 2026-06-08 18:04:57 +00:00
🌟 feat(file): обновлены запросы к базе данных для обновления/создания пользователя.
All checks were successful
Deploy / deploy (push) Successful in 46s
All checks were successful
Deploy / deploy (push) Successful in 46s
This commit is contained in:
@@ -39,7 +39,11 @@ async function doLogin(chatId: number, email: string): Promise<void> {
|
|||||||
await bot.sendMessage(chatId, '🔄 Логинюсь...')
|
await bot.sendMessage(chatId, '🔄 Логинюсь...')
|
||||||
try {
|
try {
|
||||||
await login(email, chatId)
|
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)
|
const state = getState(chatId)
|
||||||
|
|
||||||
@@ -380,9 +384,10 @@ export function registerHHCommands() {
|
|||||||
if (state.awaitingPrompt) {
|
if (state.awaitingPrompt) {
|
||||||
state.awaitingPrompt = false
|
state.awaitingPrompt = false
|
||||||
await bot.deleteMessage(chatId, msg.message_id).catch(() => {})
|
await bot.deleteMessage(chatId, msg.message_id).catch(() => {})
|
||||||
await prisma.user.update({
|
await prisma.user.upsert({
|
||||||
where: { telegramId: chatId },
|
where: { telegramId: chatId },
|
||||||
data: { prompt: msg.text },
|
update: { prompt: msg.text },
|
||||||
|
create: { telegramId: chatId, prompt: msg.text, Settings: { create: {} } },
|
||||||
})
|
})
|
||||||
await bot.sendMessage(chatId, '✅ Промт сохранён')
|
await bot.sendMessage(chatId, '✅ Промт сохранён')
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -96,9 +96,10 @@ export async function login(email: string, chatId: number): Promise<void> {
|
|||||||
await page.waitForSelector('[data-qa="profileAndResumes-button"]', { timeout: 15000 })
|
await page.waitForSelector('[data-qa="profileAndResumes-button"]', { timeout: 15000 })
|
||||||
|
|
||||||
const cookies = await context.cookies()
|
const cookies = await context.cookies()
|
||||||
await prisma.user.update({
|
await prisma.user.upsert({
|
||||||
where: { telegramId: chatId },
|
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 ? '✅ Авторизация выполнена' : '❌ Произошла ошибка')
|
await bot.sendMessage(chatId, cookies.length > 0 ? '✅ Авторизация выполнена' : '❌ Произошла ошибка')
|
||||||
|
|||||||
Reference in New Issue
Block a user