feat: Add support for WhatsApp groups
parent
e1e10d8226
commit
1c93c16f84
|
@ -64,6 +64,7 @@ const FindOrCreateTicketService = async (
|
||||||
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,17 +749,20 @@ 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!);
|
||||||
|
|
||||||
|
@ -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