fix(pos): actualizar whatsapp.js a nuevos endpoints del bridge Baileys
Reemplaza /instance/status → /status, /instance/create → /connect, etc. Lee QR de data.qr (formato del bridge) ademas de data.base64 (Evolution). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -85,7 +85,7 @@
|
|||||||
// -- Connection management -------------------------------------------------
|
// -- Connection management -------------------------------------------------
|
||||||
|
|
||||||
function checkInstanceStatus() {
|
function checkInstanceStatus() {
|
||||||
api('GET', '/instance/status').then(function (data) {
|
api('GET', '/status').then(function (data) {
|
||||||
var state = (data.instance || data).state || data.state || 'close';
|
var state = (data.instance || data).state || data.state || 'close';
|
||||||
updateConnectionUI(state);
|
updateConnectionUI(state);
|
||||||
}).catch(function () {
|
}).catch(function () {
|
||||||
@@ -129,7 +129,7 @@
|
|||||||
connectBtn.disabled = true;
|
connectBtn.disabled = true;
|
||||||
connectBtn.textContent = 'Creando instancia...';
|
connectBtn.textContent = 'Creando instancia...';
|
||||||
|
|
||||||
api('POST', '/instance/create').then(function (data) {
|
api('POST', '/connect').then(function (data) {
|
||||||
connectBtn.disabled = false;
|
connectBtn.disabled = false;
|
||||||
connectBtn.textContent = 'Conectar WhatsApp';
|
connectBtn.textContent = 'Conectar WhatsApp';
|
||||||
|
|
||||||
@@ -150,8 +150,8 @@
|
|||||||
function fetchQR() {
|
function fetchQR() {
|
||||||
qrPlaceholder.textContent = 'Generando QR...';
|
qrPlaceholder.textContent = 'Generando QR...';
|
||||||
|
|
||||||
api('GET', '/instance/qr').then(function (data) {
|
api('GET', '/qr').then(function (data) {
|
||||||
var base64 = data.base64 || data.qrcode || '';
|
var base64 = data.qr || data.base64 || data.qrcode || '';
|
||||||
if (base64) {
|
if (base64) {
|
||||||
qrImg.src = base64.startsWith('data:') ? base64 : 'data:image/png;base64,' + base64;
|
qrImg.src = base64.startsWith('data:') ? base64 : 'data:image/png;base64,' + base64;
|
||||||
qrImg.style.display = 'block';
|
qrImg.style.display = 'block';
|
||||||
@@ -161,7 +161,7 @@
|
|||||||
|
|
||||||
// Start polling for connection state while QR is shown
|
// Start polling for connection state while QR is shown
|
||||||
startStatusPolling();
|
startStatusPolling();
|
||||||
} else if (data.instance && data.instance.state === 'open') {
|
} else if ((data.instance && data.instance.state === 'open') || data.state === 'open') {
|
||||||
// Already connected
|
// Already connected
|
||||||
updateConnectionUI('open');
|
updateConnectionUI('open');
|
||||||
loadConversations();
|
loadConversations();
|
||||||
@@ -177,7 +177,7 @@
|
|||||||
|
|
||||||
function doDisconnect() {
|
function doDisconnect() {
|
||||||
if (!confirm('Desconectar WhatsApp?')) return;
|
if (!confirm('Desconectar WhatsApp?')) return;
|
||||||
api('POST', '/instance/logout').then(function () {
|
api('POST', '/logout').then(function () {
|
||||||
updateConnectionUI('close');
|
updateConnectionUI('close');
|
||||||
stopStatusPolling();
|
stopStatusPolling();
|
||||||
});
|
});
|
||||||
@@ -186,7 +186,7 @@
|
|||||||
function startStatusPolling() {
|
function startStatusPolling() {
|
||||||
stopStatusPolling();
|
stopStatusPolling();
|
||||||
statusPollTimer = setInterval(function () {
|
statusPollTimer = setInterval(function () {
|
||||||
api('GET', '/instance/status').then(function (data) {
|
api('GET', '/status').then(function (data) {
|
||||||
var state = (data.instance || data).state || data.state || 'close';
|
var state = (data.instance || data).state || data.state || 'close';
|
||||||
if (state === 'open') {
|
if (state === 'open') {
|
||||||
updateConnectionUI('open');
|
updateConnectionUI('open');
|
||||||
|
|||||||
Reference in New Issue
Block a user