mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-14 01:41:24 -06:00
Added connection functionality via pairing code
This commit is contained in:
parent
b681e33944
commit
16ed5821e2
@ -103,7 +103,7 @@ export class InstanceController {
|
|||||||
|
|
||||||
if (!chatwoot_account_id || !chatwoot_token || !chatwoot_url) {
|
if (!chatwoot_account_id || !chatwoot_token || !chatwoot_url) {
|
||||||
let getQrcode: wa.QrCode;
|
let getQrcode: wa.QrCode;
|
||||||
let getParingCode: string;
|
let getPairingCode: string;
|
||||||
|
|
||||||
if (qrcode) {
|
if (qrcode) {
|
||||||
this.logger.verbose('creating qrcode');
|
this.logger.verbose('creating qrcode');
|
||||||
@ -111,14 +111,13 @@ export class InstanceController {
|
|||||||
if (number) {
|
if (number) {
|
||||||
this.logger.verbose('creating number');
|
this.logger.verbose('creating number');
|
||||||
await delay(5000);
|
await delay(5000);
|
||||||
getParingCode = await instance.client.requestPairingCode(number);
|
getPairingCode = await instance.client.requestPairingCode(number);
|
||||||
}
|
}
|
||||||
await delay(2000);
|
await delay(2000);
|
||||||
getQrcode = instance.qrCode;
|
getQrcode = instance.qrCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.logger.verbose('instance created');
|
const result = {
|
||||||
this.logger.verbose({
|
|
||||||
instance: {
|
instance: {
|
||||||
instanceName: instance.instanceName,
|
instanceName: instance.instanceName,
|
||||||
status: 'created',
|
status: 'created',
|
||||||
@ -127,22 +126,18 @@ export class InstanceController {
|
|||||||
webhook,
|
webhook,
|
||||||
webhook_by_events,
|
webhook_by_events,
|
||||||
events: getEvents,
|
events: getEvents,
|
||||||
pairingCode: getParingCode,
|
|
||||||
qrcode: getQrcode,
|
|
||||||
});
|
|
||||||
|
|
||||||
return {
|
|
||||||
instance: {
|
|
||||||
instanceName: instance.instanceName,
|
|
||||||
status: 'created',
|
|
||||||
},
|
|
||||||
hash,
|
|
||||||
webhook,
|
|
||||||
webhook_by_events,
|
|
||||||
events: getEvents,
|
|
||||||
pairingCode: getParingCode,
|
|
||||||
qrcode: getQrcode,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (getPairingCode) {
|
||||||
|
result['pairingCode'] = getPairingCode;
|
||||||
|
} else {
|
||||||
|
result['qrcode'] = getQrcode;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.logger.verbose('instance created');
|
||||||
|
this.logger.verbose(result);
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!chatwoot_account_id) {
|
if (!chatwoot_account_id) {
|
||||||
@ -225,11 +220,15 @@ export class InstanceController {
|
|||||||
await delay(5000);
|
await delay(5000);
|
||||||
pairingCode = await instance.client.requestPairingCode(number);
|
pairingCode = await instance.client.requestPairingCode(number);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pairingCode) {
|
||||||
|
return {
|
||||||
|
pairingCode,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
await delay(2000);
|
await delay(2000);
|
||||||
return {
|
return instance.qrCode;
|
||||||
pairingCode,
|
|
||||||
...instance.qrCode,
|
|
||||||
};
|
|
||||||
case 'connecting':
|
case 'connecting':
|
||||||
return instance.qrCode;
|
return instance.qrCode;
|
||||||
default:
|
default:
|
||||||
|
Loading…
Reference in New Issue
Block a user