mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-12-26 07:07:45 -06:00
fix: Option conversation_pending in chatwoot endpoint
This commit is contained in:
@@ -231,12 +231,19 @@ export class ChatwootService {
|
||||
|
||||
if (qrcode) {
|
||||
this.logger.verbose('create conversation in chatwoot');
|
||||
const data = {
|
||||
contact_id: contactId.toString(),
|
||||
inbox_id: inboxId.toString(),
|
||||
};
|
||||
|
||||
if (this.provider.conversation_pending) {
|
||||
data['status'] = 'pending';
|
||||
}
|
||||
|
||||
console.log('this.provider', this.provider);
|
||||
const conversation = await client.conversations.create({
|
||||
accountId: this.provider.account_id,
|
||||
data: {
|
||||
contact_id: contactId.toString(),
|
||||
inbox_id: inboxId.toString(),
|
||||
},
|
||||
data,
|
||||
});
|
||||
|
||||
if (!conversation) {
|
||||
@@ -521,11 +528,20 @@ export class ChatwootService {
|
||||
})) as any;
|
||||
|
||||
if (contactConversations) {
|
||||
let conversation: any;
|
||||
if (this.provider.reopen_conversation) {
|
||||
conversation = contactConversations.payload.find(
|
||||
(conversation) => conversation.inbox_id == filterInbox.id,
|
||||
);
|
||||
} else {
|
||||
conversation = contactConversations.payload.find(
|
||||
(conversation) =>
|
||||
conversation.status !== 'resolved' &&
|
||||
conversation.inbox_id == filterInbox.id,
|
||||
);
|
||||
}
|
||||
this.logger.verbose('return conversation if exists');
|
||||
const conversation = contactConversations.payload.find(
|
||||
(conversation) =>
|
||||
conversation.status !== 'resolved' && conversation.inbox_id == filterInbox.id,
|
||||
);
|
||||
|
||||
if (conversation) {
|
||||
this.logger.verbose('conversation found');
|
||||
return conversation.id;
|
||||
@@ -533,12 +549,18 @@ export class ChatwootService {
|
||||
}
|
||||
|
||||
this.logger.verbose('create conversation in chatwoot');
|
||||
const data = {
|
||||
contact_id: contactId.toString(),
|
||||
inbox_id: filterInbox.id.toString(),
|
||||
};
|
||||
|
||||
if (this.provider.conversation_pending) {
|
||||
data['status'] = 'pending';
|
||||
}
|
||||
|
||||
const conversation = await client.conversations.create({
|
||||
accountId: this.provider.account_id,
|
||||
data: {
|
||||
contact_id: `${contactId}`,
|
||||
inbox_id: `${filterInbox.id}`,
|
||||
},
|
||||
data,
|
||||
});
|
||||
|
||||
if (!conversation) {
|
||||
|
||||
@@ -312,6 +312,19 @@ export class WAStartupService {
|
||||
this.localChatwoot.sign_msg = data?.sign_msg;
|
||||
this.logger.verbose(`Chatwoot sign msg: ${this.localChatwoot.sign_msg}`);
|
||||
|
||||
this.localChatwoot.number = data?.number;
|
||||
this.logger.verbose(`Chatwoot number: ${this.localChatwoot.number}`);
|
||||
|
||||
this.localChatwoot.reopen_conversation = data?.reopen_conversation;
|
||||
this.logger.verbose(
|
||||
`Chatwoot reopen conversation: ${this.localChatwoot.reopen_conversation}`,
|
||||
);
|
||||
|
||||
this.localChatwoot.conversation_pending = data?.conversation_pending;
|
||||
this.logger.verbose(
|
||||
`Chatwoot conversation pending: ${this.localChatwoot.conversation_pending}`,
|
||||
);
|
||||
|
||||
this.logger.verbose('Chatwoot loaded');
|
||||
}
|
||||
|
||||
@@ -323,6 +336,8 @@ export class WAStartupService {
|
||||
this.logger.verbose(`Chatwoot url: ${data.url}`);
|
||||
this.logger.verbose(`Chatwoot inbox name: ${data.name_inbox}`);
|
||||
this.logger.verbose(`Chatwoot sign msg: ${data.sign_msg}`);
|
||||
this.logger.verbose(`Chatwoot reopen conversation: ${data.reopen_conversation}`);
|
||||
this.logger.verbose(`Chatwoot conversation pending: ${data.conversation_pending}`);
|
||||
|
||||
Object.assign(this.localChatwoot, data);
|
||||
this.logger.verbose('Chatwoot set');
|
||||
@@ -342,6 +357,8 @@ export class WAStartupService {
|
||||
this.logger.verbose(`Chatwoot url: ${data.url}`);
|
||||
this.logger.verbose(`Chatwoot inbox name: ${data.name_inbox}`);
|
||||
this.logger.verbose(`Chatwoot sign msg: ${data.sign_msg}`);
|
||||
this.logger.verbose(`Chatwoot reopen conversation: ${data.reopen_conversation}`);
|
||||
this.logger.verbose(`Chatwoot conversation pending: ${data.conversation_pending}`);
|
||||
|
||||
return data;
|
||||
}
|
||||
@@ -618,7 +635,6 @@ export class WAStartupService {
|
||||
color: { light: '#ffffff', dark: '#198754' },
|
||||
};
|
||||
|
||||
console.log(this.phoneNumber);
|
||||
if (this.phoneNumber) {
|
||||
await delay(2000);
|
||||
this.instance.qrcode.pairingCode = await this.client.requestPairingCode(
|
||||
|
||||
Reference in New Issue
Block a user