mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-16 12:12:55 -06:00
Merge pull request #582 from deivisonrpg/hotfix-getOpenConversationByContact
fix(chatwoot): getOpenConversationByContact and init queries error
This commit is contained in:
commit
60a20f61af
@ -49,7 +49,7 @@
|
||||
"amqplib": "^0.10.3",
|
||||
"aws-sdk": "^2.1499.0",
|
||||
"axios": "^1.6.5",
|
||||
"baileys": "^6.7.1",
|
||||
"baileys": "^6.7.2",
|
||||
"class-validator": "^0.14.1",
|
||||
"compression": "^1.7.4",
|
||||
"cors": "^2.8.5",
|
||||
|
@ -789,26 +789,15 @@ export class ChatwootService {
|
||||
return null;
|
||||
}
|
||||
|
||||
const payload = [
|
||||
['inbox_id', inbox.id.toString()],
|
||||
['contact_id', contact.id.toString()],
|
||||
['status', 'open'],
|
||||
];
|
||||
const conversations = (await client.contacts.listConversations({
|
||||
accountId: this.provider.account_id,
|
||||
id: contact.id,
|
||||
})) as any;
|
||||
|
||||
return (
|
||||
(
|
||||
(await client.conversations.filter({
|
||||
accountId: this.provider.account_id,
|
||||
payload: payload.map((item, i, payload) => {
|
||||
return {
|
||||
attribute_key: item[0],
|
||||
filter_operator: 'equal_to',
|
||||
values: [item[1]],
|
||||
query_operator: i < payload.length - 1 ? 'AND' : null,
|
||||
};
|
||||
}),
|
||||
})) as { payload: conversation[] }
|
||||
).payload[0] || undefined
|
||||
conversations.payload.find(
|
||||
(conversation) => conversation.inbox_id === inbox.id && conversation.status === 'open',
|
||||
) || undefined
|
||||
);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user