mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-23 04:22:02 -06:00
fix: optimize ChatwootService method for retrieving open conversations
This commit is contained in:
parent
d9d8707123
commit
ea3b0b3712
@ -789,26 +789,15 @@ export class ChatwootService {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const payload = [
|
const conversations = (await client.contacts.listConversations({
|
||||||
['inbox_id', inbox.id.toString()],
|
accountId: this.provider.account_id,
|
||||||
['contact_id', contact.id.toString()],
|
id: contact.id,
|
||||||
['status', 'open'],
|
})) as any;
|
||||||
];
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
(
|
conversations.payload.find(
|
||||||
(await client.conversations.filter({
|
(conversation) => conversation.inbox_id === inbox.id && conversation.status === 'open',
|
||||||
accountId: this.provider.account_id,
|
) || undefined
|
||||||
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
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user