fix: send telegram confirmation messages during business connect flow

This commit is contained in:
Ruslan Bakiev
2026-02-22 07:51:35 +07:00
parent 89ce62e1ee
commit 6ee12ed254

View File

@@ -1,5 +1,6 @@
import { getHeader, readBody } from "h3"; import { getHeader, readBody } from "h3";
import { prisma } from "../../../../utils/prisma"; import { prisma } from "../../../../utils/prisma";
import { telegramBotApi } from "../../../../utils/telegram";
import { import {
extractLinkTokenFromStartText, extractLinkTokenFromStartText,
getBusinessConnectionFromUpdate, getBusinessConnectionFromUpdate,
@@ -61,6 +62,13 @@ export default defineEventHandler(async (event) => {
}, },
}); });
if (chatId) {
void telegramBotApi("sendMessage", {
chat_id: chatId,
text: "CRM: связка аккаунта получена. Теперь подключите Telegram Business в настройках Telegram, затем вернитесь в CRM и обновите статус.",
}).catch(() => {});
}
return { ok: true, accepted: true, type: "start_link" }; return { ok: true, accepted: true, type: "start_link" };
} }
@@ -123,6 +131,13 @@ export default defineEventHandler(async (event) => {
prisma.telegramBusinessConnection.delete({ where: { id: matchedPending.id } }), prisma.telegramBusinessConnection.delete({ where: { id: matchedPending.id } }),
]); ]);
if (businessConnection.userChatId) {
void telegramBotApi("sendMessage", {
chat_id: businessConnection.userChatId,
text: "CRM: Telegram Business подключен. Теперь входящие сообщения будут появляться в CRM.",
}).catch(() => {});
}
return { ok: true, accepted: true, type: "business_connection" }; return { ok: true, accepted: true, type: "business_connection" };
} }