mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-20 10:16:43 -06:00
fix(chatwoot): fix conversation read on chatwoot version 3.7
if contact has more than one conversation, we could get the wrong conversation.
This commit is contained in:
parent
3e85af9589
commit
28581f88b2
@ -1,4 +1,12 @@
|
|||||||
import ChatwootClient, { ChatwootAPIConfig, contact, conversation, generic_id, inbox } from '@figuro/chatwoot-sdk';
|
import ChatwootClient, {
|
||||||
|
ChatwootAPIConfig,
|
||||||
|
contact,
|
||||||
|
contact_inboxes,
|
||||||
|
conversation,
|
||||||
|
conversation_show,
|
||||||
|
generic_id,
|
||||||
|
inbox,
|
||||||
|
} from '@figuro/chatwoot-sdk';
|
||||||
import { request as chatwootRequest } from '@figuro/chatwoot-sdk/dist/core/request';
|
import { request as chatwootRequest } from '@figuro/chatwoot-sdk/dist/core/request';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import FormData from 'form-data';
|
import FormData from 'form-data';
|
||||||
@ -2130,12 +2138,13 @@ export class ChatwootService {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (!sourceId && inbox) {
|
if (!sourceId && inbox) {
|
||||||
const contact = (await this.findContact(
|
const conversation = (await client.conversations.get({
|
||||||
instance,
|
accountId: this.provider.account_id,
|
||||||
this.getNumberFromRemoteJid(body.key.remoteJid),
|
conversationId: conversationId,
|
||||||
)) as contact;
|
})) as conversation_show & {
|
||||||
const contactInbox = contact?.contact_inboxes?.find((contactInbox) => contactInbox?.inbox?.id === inbox.id);
|
last_non_activity_message: { conversation: { contact_inbox: contact_inboxes } };
|
||||||
sourceId = contactInbox?.source_id;
|
};
|
||||||
|
sourceId = conversation.last_non_activity_message?.conversation?.contact_inbox?.source_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sourceId && inbox?.inbox_identifier) {
|
if (sourceId && inbox?.inbox_identifier) {
|
||||||
|
Loading…
Reference in New Issue
Block a user