Corrigido erro CONTACT_NOT_FIND ao renderizar um VCard que já existia antes da atualização nova dos VCards

Agora caso encontre um VCard de um contato que não exista ele já faz a inclusão deste contato e o renderiza corretamente
This commit is contained in:
Danilo Alves
2022-01-13 16:24:36 -03:00
parent 2c0621278b
commit f1b7be45af

View File

@@ -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<Contact> =>
});
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;