Adição do userProfile para quando abrir um novo chat associar com o perfil do usuario
parent
9c351d1e9a
commit
f00220ff37
|
@ -2,9 +2,9 @@ import Whatsapp from "../models/Whatsapp";
|
||||||
import ShowQueuesByUser from "../services/UserServices/ShowQueuesByUser";
|
import ShowQueuesByUser from "../services/UserServices/ShowQueuesByUser";
|
||||||
import ShowWhatsAppService from "../services/WhatsappService/ShowWhatsAppService";
|
import ShowWhatsAppService from "../services/WhatsappService/ShowWhatsAppService";
|
||||||
|
|
||||||
async function whatsappQueueMatchingUserQueue(userId: number, whatsapp: Whatsapp) {
|
async function whatsappQueueMatchingUserQueue(userId: number, whatsapp: Whatsapp, userProfile: string = 'user') {
|
||||||
|
|
||||||
const userQueues = await ShowQueuesByUser({ profile: 'user', userId: userId });
|
const userQueues = await ShowQueuesByUser({ profile: userProfile, userId: userId });
|
||||||
|
|
||||||
if (!userQueues || userQueues && userQueues.length == 0) return
|
if (!userQueues || userQueues && userQueues.length == 0) return
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@ import ShowQueuesByUser from "../UserServices/ShowQueuesByUser";
|
||||||
import ShowWhatsAppService from "../WhatsappService/ShowWhatsAppService";
|
import ShowWhatsAppService from "../WhatsappService/ShowWhatsAppService";
|
||||||
import Whatsapp from "../../models/Whatsapp";
|
import Whatsapp from "../../models/Whatsapp";
|
||||||
import whatsappQueueMatchingUserQueue from "../../helpers/whatsappQueueMatchingUserQueue";
|
import whatsappQueueMatchingUserQueue from "../../helpers/whatsappQueueMatchingUserQueue";
|
||||||
|
import User from "../../models/User";
|
||||||
let flatten = require('flat')
|
let flatten = require('flat')
|
||||||
|
|
||||||
|
|
||||||
|
@ -40,7 +41,12 @@ const CreateTicketService = async ({
|
||||||
|
|
||||||
const defaultWhatsapp = await GetDefaultWhatsApp(userId);
|
const defaultWhatsapp = await GetDefaultWhatsApp(userId);
|
||||||
|
|
||||||
const matchingQueue = await whatsappQueueMatchingUserQueue(userId, defaultWhatsapp);
|
|
||||||
|
const user = await User.findByPk(userId, { raw: true, })
|
||||||
|
console.log('user.profile: ', user?.profile)
|
||||||
|
|
||||||
|
|
||||||
|
const matchingQueue = await whatsappQueueMatchingUserQueue(userId, defaultWhatsapp, user?.profile);
|
||||||
console.log('matchingQueue: ', matchingQueue)
|
console.log('matchingQueue: ', matchingQueue)
|
||||||
const queueId = matchingQueue ? matchingQueue.queueId : undefined
|
const queueId = matchingQueue ? matchingQueue.queueId : undefined
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue