From f1b7be45afb545f942442cd3af003d2eeefce975 Mon Sep 17 00:00:00 2001 From: Danilo Alves Date: Thu, 13 Jan 2022 16:24:36 -0300 Subject: [PATCH] =?UTF-8?q?Corrigido=20erro=20CONTACT=5FNOT=5FFIND=20ao=20?= =?UTF-8?q?renderizar=20um=20VCard=20que=20j=C3=A1=20existia=20antes=20da?= =?UTF-8?q?=20atualiza=C3=A7=C3=A3o=20nova=20dos=20VCards?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Agora caso encontre um VCard de um contato que não exista ele já faz a inclusão deste contato e o renderiza corretamente --- .../services/ContactServices/GetContactService.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/backend/src/services/ContactServices/GetContactService.ts b/backend/src/services/ContactServices/GetContactService.ts index 93b12e3..3865bc5 100644 --- a/backend/src/services/ContactServices/GetContactService.ts +++ b/backend/src/services/ContactServices/GetContactService.ts @@ -1,5 +1,6 @@ import AppError from "../../errors/AppError"; import Contact from "../../models/Contact"; +import CreateContactService from "./CreateContactService"; interface ExtraInfo { name: string; @@ -20,10 +21,18 @@ const GetContactService = async ({ name, number }: Request): Promise => }); if (!numberExists) { - throw new AppError("CONTACT_NOT_FIND"); + const contact = await CreateContactService({ + name, + number, + }) + + if (contact == null) + throw new AppError("CONTACT_NOT_FIND") + else + return contact } - return numberExists; + return numberExists }; export default GetContactService; \ No newline at end of file