mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-14 01:41:24 -06:00
Merge pull request #1415 from victoreduardo/victoreduardos/fix-conversation-not-found
fix: Erro na criação de conversation quando já existe uma conversation de outro inbox para o mesmo usuário
This commit is contained in:
commit
bff3bf564b
@ -698,34 +698,33 @@ export class ChatwootService {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (contactConversations.payload.length) {
|
let inboxConversation = contactConversations.payload.find(
|
||||||
let conversation: any;
|
(conversation) => conversation.inbox_id == filterInbox.id,
|
||||||
|
);
|
||||||
|
if (inboxConversation) {
|
||||||
if (this.provider.reopenConversation) {
|
if (this.provider.reopenConversation) {
|
||||||
conversation = contactConversations.payload.find((conversation) => conversation.inbox_id == filterInbox.id);
|
this.logger.verbose(`Found conversation in reopenConversation mode: ${JSON.stringify(inboxConversation)}`);
|
||||||
this.logger.verbose(`Found conversation in reopenConversation mode: ${JSON.stringify(conversation)}`);
|
|
||||||
|
|
||||||
if (this.provider.conversationPending && conversation.status !== 'open') {
|
if (this.provider.conversationPending && inboxConversation.status !== 'open') {
|
||||||
if (conversation) {
|
|
||||||
await client.conversations.toggleStatus({
|
await client.conversations.toggleStatus({
|
||||||
accountId: this.provider.accountId,
|
accountId: this.provider.accountId,
|
||||||
conversationId: conversation.id,
|
conversationId: inboxConversation.id,
|
||||||
data: {
|
data: {
|
||||||
status: 'pending',
|
status: 'pending',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
conversation = contactConversations.payload.find(
|
inboxConversation = contactConversations.payload.find(
|
||||||
(conversation) => conversation.status !== 'resolved' && conversation.inbox_id == filterInbox.id,
|
(conversation) => conversation.status !== 'resolved' && conversation.inbox_id == filterInbox.id,
|
||||||
);
|
);
|
||||||
this.logger.verbose(`Found conversation: ${JSON.stringify(conversation)}`);
|
this.logger.verbose(`Found conversation: ${JSON.stringify(inboxConversation)}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (conversation) {
|
if (inboxConversation) {
|
||||||
this.logger.verbose(`Returning existing conversation ID: ${conversation.id}`);
|
this.logger.verbose(`Returning existing conversation ID: ${inboxConversation.id}`);
|
||||||
this.cache.set(cacheKey, conversation.id);
|
this.cache.set(cacheKey, inboxConversation.id);
|
||||||
return conversation.id;
|
return inboxConversation.id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user