Skip to content

Commit 64e345d

Browse files
committed
fix: display qrcode
1 parent 296fa8d commit 64e345d

File tree

2 files changed

+226
-142
lines changed

2 files changed

+226
-142
lines changed

src/whatsapp/services/whatsapp.service.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ import { getObjectUrl } from '../../integrations/minio/minio.utils';
160160

161161
type InstanceQrCode = {
162162
count: number;
163+
paringCode?: string;
163164
code?: string;
164165
base64?: string;
165166
};
@@ -416,11 +417,10 @@ export class WAStartupService {
416417
color: { light: qrCodeOptions.LIGHT_COLOR, dark: qrCodeOptions.DARK_COLOR },
417418
};
418419

419-
let code: string;
420-
421420
if (this.phoneNumber && !this.client?.authState?.creds?.registered) {
422-
code = await this.client.requestPairingCode(this.phoneNumber);
423-
this.eventEmitter.emit('code.connection', { code });
421+
this.instanceQr.paringCode = await this.client.requestPairingCode(
422+
this.phoneNumber,
423+
);
424424
}
425425

426426
qrcode.toDataURL(qr, optsQrcode, (error, base64) => {
@@ -430,12 +430,12 @@ export class WAStartupService {
430430
}
431431

432432
this.instanceQr.base64 = base64;
433-
this.instanceQr.code = code ?? qr;
433+
this.instanceQr.code = qr;
434434

435-
this.ws.send(this.instance.name, 'qrcode.updated', { code: qr, base64 });
435+
this.ws.send(this.instance.name, 'qrcode.updated', this.instanceQr);
436436

437437
this.sendDataWebhook('qrcodeUpdated', {
438-
qrcode: { instance: this.instance.name, code: qr, base64 },
438+
qrcode: { instance: this.instance.name, ...this.instanceQr },
439439
});
440440
});
441441

@@ -444,8 +444,7 @@ export class WAStartupService {
444444
`\n${JSON.stringify(
445445
{
446446
instanceName: this.instance.name,
447-
qrCount: this.instanceQr.count,
448-
code: this.instanceQr.code ?? code,
447+
...this.instanceQr,
449448
},
450449
null,
451450
2,

0 commit comments

Comments
 (0)