feat: Add support for WhatsApp groups

gertec
adriano 2024-06-13 17:50:30 -03:00
parent e1e10d8226
commit 1c93c16f84
5 changed files with 36 additions and 21 deletions

View File

@ -64,6 +64,7 @@ const FindOrCreateTicketService = async (
await ticket.update({
status: "pending",
userId: null,
queueId: null,
unreadMessages
});
}
@ -96,7 +97,12 @@ const FindOrCreateTicketService = async (
if (!ticket) {
let status = "pending";
if (queues.length > 1 && !botInfo.isOnQueue && !queueId) {
if (
queues.length > 1 &&
!botInfo.isOnQueue &&
!queueId &&
!groupContact
) {
status = "queueChoice";
}

View File

@ -372,6 +372,12 @@ const verifyQueue = async (
ticket: Ticket,
contact: Contact
) => {
if(ticket?.isGroup){
return
}
const { queues, greetingMessage } = await ShowWhatsAppService(wbot.id!);
let selectedOption = null;
@ -703,7 +709,7 @@ const handleMessage = async (
try {
let msgContact: any = wbot.msgContact;
// let groupContact: Contact | undefined;
let groupContact: Contact | undefined;
if (msg.fromMe) {
// messages sent automatically by wbot have a special character in front of it
@ -743,7 +749,10 @@ const handleMessage = async (
// console.log('----------> chat: ', JSON.parse(JSON.stringify(chat)))
// if (chat.isGroup) {
console
if (chat.isGroup) {
// let msgGroupContact;
// if (msg.fromMe) {
@ -752,8 +761,8 @@ const handleMessage = async (
// msgGroupContact = await wbot.getContactById(msg.from);
// }
// groupContact = await verifyContact(msgGroupContact);
// }
groupContact = await verifyContact(wbot.getContactById);
}
const whatsapp = await ShowWhatsAppService(wbot.id!);
@ -777,12 +786,12 @@ const handleMessage = async (
const _botInfo = await BotIsOnQueue("botqueue");
if (_botInfo.isOnQueue) {
if (_botInfo.isOnQueue && !chat.isGroup) {
let ticket_obj: any = await FindOrCreateTicketServiceBot(
contact,
wbot.id!,
unreadMessages
// groupContact
unreadMessages,
groupContact
);
ticket = ticket_obj.ticket;
@ -801,8 +810,8 @@ const handleMessage = async (
ticket = await FindOrCreateTicketService(
contact,
wbot.id!,
unreadMessages
// groupContact
unreadMessages,
groupContact
);
}

View File

@ -387,10 +387,10 @@ const NotificationsPopOver = () => {
vertical: "top",
horizontal: "right",
}}
classes={{ paper: classes.popoverPaper }}
classes={{ paper: classes?.popoverPaper }}
onClose={handleClickAway}
>
<List dense className={classes.tabContainer}>
<List dense className={classes?.tabContainer}>
{notifications.length === 0 ? (
<ListItem>
<ListItemText>{i18n.t("notifications.noTickets")}</ListItemText>

View File

@ -229,7 +229,7 @@ const TicketListItem = ({ ticket, remoteTicketsControll, settings }) => {
variant="body2"
color="textPrimary"
>
{ticket.contact.name}
{ticket?.contact?.name}
</Typography>
{ticket.status === "closed" && (
<Badge