From 1e9fd66e27702af1d2388e506ead343fd78ecb7b Mon Sep 17 00:00:00 2001 From: vchikalkin Date: Thu, 9 Oct 2025 09:44:43 +0300 Subject: [PATCH] Refactor customer retrieval in addContact function to use RegistrationService - Replaced the use of CustomersService.getCustomer with RegistrationService.checkCustomerExists for improved consistency in customer existence checks. - Introduced a new instance of CustomersService for adding invited users, maintaining functionality while enhancing code clarity. --- apps/bot/src/bot/conversations/add-contact.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/bot/src/bot/conversations/add-contact.ts b/apps/bot/src/bot/conversations/add-contact.ts index f788286..8b9c5ce 100644 --- a/apps/bot/src/bot/conversations/add-contact.ts +++ b/apps/bot/src/bot/conversations/add-contact.ts @@ -17,8 +17,8 @@ export async function addContact(conversation: Conversation, c return ctx.reply(await conversation.external(({ t }) => t('err-generic'))); } - const customerService = new CustomersService({ telegramId }); - const { customer } = await customerService.getCustomer({ telegramId }); + const registrationService = new RegistrationService(); + const { customer } = await registrationService.checkCustomerExists({ telegramId }); if (!customer) { return ctx.reply( @@ -108,7 +108,6 @@ export async function addContact(conversation: Conversation, c try { // Проверяем, есть ли клиент с таким номером - const registrationService = new RegistrationService(); const { customer: existingCustomer } = await registrationService.checkCustomerExists({ phone }); let documentId = existingCustomer?.documentId; @@ -124,6 +123,7 @@ export async function addContact(conversation: Conversation, c // Добавляем текущего пользователя к приглашенному const invitedBy = [customer.documentId]; + const customerService = new CustomersService({ telegramId }); await customerService.addInvitedBy({ data: { invitedBy }, documentId }); // Отправляем подтверждения и инструкции