open more than one ticket per user as long as it is using another whatsapp

This commit is contained in:
Ricardo Paes
2022-02-23 11:21:11 -03:00
parent afb5d68602
commit acd628028e
4 changed files with 13 additions and 7 deletions

View File

@@ -2,9 +2,12 @@ import { Op } from "sequelize";
import AppError from "../errors/AppError";
import Ticket from "../models/Ticket";
const CheckContactOpenTickets = async (contactId: number): Promise<void> => {
const CheckContactOpenTickets = async (
contactId: number,
whatsappId: number
): Promise<void> => {
const ticket = await Ticket.findOne({
where: { contactId, status: { [Op.or]: ["open", "pending"] } }
where: { contactId, whatsappId, status: { [Op.or]: ["open", "pending"] } }
});
if (ticket) {