feat: added user association to queues

This commit is contained in:
canove
2021-01-08 20:18:11 -03:00
parent 9f99245dc4
commit 3c6d0660d1
15 changed files with 145 additions and 41 deletions

View File

@@ -18,7 +18,7 @@ interface Response {
const CreateWhatsAppService = async ({
name,
status = "OPENING",
queueIds,
queueIds = [],
isDefault = false
}: Request): Promise<Response> => {
const schema = Yup.object().shape({
@@ -64,14 +64,19 @@ const CreateWhatsAppService = async ({
}
}
const whatsapp = await Whatsapp.create({
name,
status,
isDefault
});
const whatsapp = await Whatsapp.create(
{
name,
status,
isDefault
},
{ include: ["queues"] }
);
await whatsapp.$set("queues", queueIds);
await whatsapp.reload();
return { whatsapp, oldDefaultWhatsapp };
};