Compare commits
2 Commits
e1e10d8226
...
b9f8bfc8d5
Author | SHA1 | Date |
---|---|---|
adriano | b9f8bfc8d5 | |
adriano | 1c93c16f84 |
|
@ -885,11 +885,15 @@ async function handleMessage(msg) {
|
||||||
|
|
||||||
if (msg.fromMe) {
|
if (msg.fromMe) {
|
||||||
|
|
||||||
|
console.log('MSG FROM ME')
|
||||||
|
|
||||||
msgContact = await client.getContactById(msg.to)
|
msgContact = await client.getContactById(msg.to)
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
|
console.log('MSG FROM CLIENT')
|
||||||
|
|
||||||
console.log('################# RECEIVING MESSAGE FROM: ', msg.from, ' to ', msg.to)
|
console.log('################# RECEIVING MESSAGE FROM: ', msg.from, ' to ', msg.to)
|
||||||
|
|
||||||
msgContact = await msg.getContact()
|
msgContact = await msg.getContact()
|
||||||
|
@ -912,10 +916,10 @@ async function handleMessage(msg) {
|
||||||
msgContact: msgContact,
|
msgContact: msgContact,
|
||||||
chat: chat,
|
chat: chat,
|
||||||
quotedMsg: quotedMsg ? quotedMsg.id.id : null,
|
quotedMsg: quotedMsg ? quotedMsg.id.id : null,
|
||||||
media: media
|
media: media,
|
||||||
|
getContactById: msg.fromMe ? await client.getContactById(msg.to) : await client.getContactById(msg.from)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
socketIo.emit("message_create", data)
|
socketIo.emit("message_create", data)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,7 +114,7 @@ export const index = async (req: Request, res: Response): Promise<Response> => {
|
||||||
withUnreadMessages,
|
withUnreadMessages,
|
||||||
unlimited,
|
unlimited,
|
||||||
searchParamContent
|
searchParamContent
|
||||||
});
|
});
|
||||||
|
|
||||||
return res
|
return res
|
||||||
.status(200)
|
.status(200)
|
||||||
|
|
|
@ -60,10 +60,11 @@ const FindOrCreateTicketService = async (
|
||||||
order: [["updatedAt", "DESC"]]
|
order: [["updatedAt", "DESC"]]
|
||||||
});
|
});
|
||||||
|
|
||||||
if (ticket) {
|
if (ticket) {
|
||||||
await ticket.update({
|
await ticket.update({
|
||||||
status: "pending",
|
status: "pending",
|
||||||
userId: null,
|
userId: null,
|
||||||
|
queueId: null,
|
||||||
unreadMessages
|
unreadMessages
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -96,7 +97,12 @@ const FindOrCreateTicketService = async (
|
||||||
if (!ticket) {
|
if (!ticket) {
|
||||||
let status = "pending";
|
let status = "pending";
|
||||||
|
|
||||||
if (queues.length > 1 && !botInfo.isOnQueue && !queueId) {
|
if (
|
||||||
|
queues.length > 1 &&
|
||||||
|
!botInfo.isOnQueue &&
|
||||||
|
!queueId &&
|
||||||
|
!groupContact
|
||||||
|
) {
|
||||||
status = "queueChoice";
|
status = "queueChoice";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -372,6 +372,12 @@ const verifyQueue = async (
|
||||||
ticket: Ticket,
|
ticket: Ticket,
|
||||||
contact: Contact
|
contact: Contact
|
||||||
) => {
|
) => {
|
||||||
|
|
||||||
|
if(ticket?.isGroup){
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
const { queues, greetingMessage } = await ShowWhatsAppService(wbot.id!);
|
const { queues, greetingMessage } = await ShowWhatsAppService(wbot.id!);
|
||||||
|
|
||||||
let selectedOption = null;
|
let selectedOption = null;
|
||||||
|
@ -703,7 +709,7 @@ const handleMessage = async (
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let msgContact: any = wbot.msgContact;
|
let msgContact: any = wbot.msgContact;
|
||||||
// let groupContact: Contact | undefined;
|
let groupContact: Contact | undefined;
|
||||||
|
|
||||||
if (msg.fromMe) {
|
if (msg.fromMe) {
|
||||||
// messages sent automatically by wbot have a special character in front of it
|
// messages sent automatically by wbot have a special character in front of it
|
||||||
|
@ -743,18 +749,21 @@ const handleMessage = async (
|
||||||
|
|
||||||
// console.log('----------> chat: ', JSON.parse(JSON.stringify(chat)))
|
// console.log('----------> chat: ', JSON.parse(JSON.stringify(chat)))
|
||||||
|
|
||||||
// if (chat.isGroup) {
|
|
||||||
// let msgGroupContact;
|
|
||||||
|
|
||||||
// if (msg.fromMe) {
|
console
|
||||||
// msgGroupContact = await wbot.getContactById(msg.to);
|
|
||||||
// } else {
|
|
||||||
// msgGroupContact = await wbot.getContactById(msg.from);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// groupContact = await verifyContact(msgGroupContact);
|
if (chat.isGroup) {
|
||||||
// }
|
// let msgGroupContact;
|
||||||
|
|
||||||
|
// if (msg.fromMe) {
|
||||||
|
// msgGroupContact = await wbot.getContactById(msg.to);
|
||||||
|
// } else {
|
||||||
|
// msgGroupContact = await wbot.getContactById(msg.from);
|
||||||
|
// }
|
||||||
|
|
||||||
|
groupContact = await verifyContact(wbot.getContactById);
|
||||||
|
}
|
||||||
|
|
||||||
const whatsapp = await ShowWhatsAppService(wbot.id!);
|
const whatsapp = await ShowWhatsAppService(wbot.id!);
|
||||||
|
|
||||||
const unreadMessages = msg.fromMe ? 0 : chat.unreadCount;
|
const unreadMessages = msg.fromMe ? 0 : chat.unreadCount;
|
||||||
|
@ -777,12 +786,12 @@ const handleMessage = async (
|
||||||
|
|
||||||
const _botInfo = await BotIsOnQueue("botqueue");
|
const _botInfo = await BotIsOnQueue("botqueue");
|
||||||
|
|
||||||
if (_botInfo.isOnQueue) {
|
if (_botInfo.isOnQueue && !chat.isGroup) {
|
||||||
let ticket_obj: any = await FindOrCreateTicketServiceBot(
|
let ticket_obj: any = await FindOrCreateTicketServiceBot(
|
||||||
contact,
|
contact,
|
||||||
wbot.id!,
|
wbot.id!,
|
||||||
unreadMessages
|
unreadMessages,
|
||||||
// groupContact
|
groupContact
|
||||||
);
|
);
|
||||||
|
|
||||||
ticket = ticket_obj.ticket;
|
ticket = ticket_obj.ticket;
|
||||||
|
@ -801,8 +810,8 @@ const handleMessage = async (
|
||||||
ticket = await FindOrCreateTicketService(
|
ticket = await FindOrCreateTicketService(
|
||||||
contact,
|
contact,
|
||||||
wbot.id!,
|
wbot.id!,
|
||||||
unreadMessages
|
unreadMessages,
|
||||||
// groupContact
|
groupContact
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -387,10 +387,10 @@ const NotificationsPopOver = () => {
|
||||||
vertical: "top",
|
vertical: "top",
|
||||||
horizontal: "right",
|
horizontal: "right",
|
||||||
}}
|
}}
|
||||||
classes={{ paper: classes.popoverPaper }}
|
classes={{ paper: classes?.popoverPaper }}
|
||||||
onClose={handleClickAway}
|
onClose={handleClickAway}
|
||||||
>
|
>
|
||||||
<List dense className={classes.tabContainer}>
|
<List dense className={classes?.tabContainer}>
|
||||||
{notifications.length === 0 ? (
|
{notifications.length === 0 ? (
|
||||||
<ListItem>
|
<ListItem>
|
||||||
<ListItemText>{i18n.t("notifications.noTickets")}</ListItemText>
|
<ListItemText>{i18n.t("notifications.noTickets")}</ListItemText>
|
||||||
|
|
|
@ -229,7 +229,7 @@ const TicketListItem = ({ ticket, remoteTicketsControll, settings }) => {
|
||||||
variant="body2"
|
variant="body2"
|
||||||
color="textPrimary"
|
color="textPrimary"
|
||||||
>
|
>
|
||||||
{ticket.contact.name}
|
{ticket?.contact?.name}
|
||||||
</Typography>
|
</Typography>
|
||||||
{ticket.status === "closed" && (
|
{ticket.status === "closed" && (
|
||||||
<Badge
|
<Badge
|
||||||
|
|
Loading…
Reference in New Issue