Skip to content

Commit

Permalink
Accept multiple tickets from same contact (on different connections)
Browse files Browse the repository at this point in the history
  • Loading branch information
allgood committed Jul 6, 2024
1 parent 65cde63 commit 48fc4ac
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions backend/src/services/TicketServices/FindOrCreateTicketService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const FindOrCreateTicketService = async (
[Op.or]: ["open", "pending"]
},
contactId: groupContact ? groupContact.id : contact.id,
companyId
whatsappId
},
order: [["id", "DESC"]]
});
Expand All @@ -37,7 +37,8 @@ const FindOrCreateTicketService = async (
if (!ticket && groupContact) {
ticket = await Ticket.findOne({
where: {
contactId: groupContact.id
contactId: groupContact.id,
whatsappId
},
order: [["updatedAt", "DESC"]]
});
Expand Down Expand Up @@ -69,7 +70,8 @@ const FindOrCreateTicketService = async (
updatedAt: {
[Op.between]: [+subHours(new Date(), 2), +new Date()]
},
contactId: contact.id
contactId: contact.id,
whatsappId
},
order: [["updatedAt", "DESC"]]
});
Expand Down Expand Up @@ -106,8 +108,6 @@ const FindOrCreateTicketService = async (
whatsappId,
userId: ticket.userId
});
} else {
await ticket.update({ whatsappId });
}

ticket = await ShowTicketService(ticket.id, companyId);
Expand Down

0 comments on commit 48fc4ac

Please sign in to comment.