@arcaelas/whatsapp 7.4.1 → 7.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/lib/chat/index.js +16 -1
- package/build/cjs/lib/whatsapp/index.d.ts +9 -0
- package/build/cjs/lib/whatsapp/index.js +2 -2
- package/build/esm/lib/chat/index.js +16 -1
- package/build/esm/lib/whatsapp/index.d.ts +9 -0
- package/build/esm/lib/whatsapp/index.js +2 -2
- package/package.json +1 -1
|
@@ -215,7 +215,22 @@ function chat(init) {
|
|
|
215
215
|
*/
|
|
216
216
|
async seen() {
|
|
217
217
|
const last = await tail(this._raw.id);
|
|
218
|
-
|
|
218
|
+
// Marcar leído se acusa con recibos, no con una mutación del estado de la app.
|
|
219
|
+
// `chatModify({ markRead })` emite un app patch, y cuando el estado local va por
|
|
220
|
+
// detrás del servidor —lo normal en un dispositivo recién vinculado, que arranca en
|
|
221
|
+
// v0— WhatsApp responde al patch expulsando el dispositivo: `conflict
|
|
222
|
+
// (device_removed)`. Abrir un chat basta para provocarlo, así que la línea se caía
|
|
223
|
+
// sola al primer chat que se mirara. Los recibos no tocan el estado de la app.
|
|
224
|
+
// Marking read is acknowledged with receipts, not with an app-state mutation.
|
|
225
|
+
// `chatModify({ markRead })` emits an app patch, and when the local state trails the
|
|
226
|
+
// server —the norm on a freshly linked device, which starts at v0— WhatsApp answers
|
|
227
|
+
// that patch by dropping the device: `conflict (device_removed)`. Opening a chat was
|
|
228
|
+
// enough to trigger it, so the line died on the first chat anyone looked at.
|
|
229
|
+
// Receipts leave the app state alone.
|
|
230
|
+
const keys = last.messages.map(({ key }) => ({ remoteJid: key.remoteJid, id: key.id, participant: undefined }));
|
|
231
|
+
if (keys.length) {
|
|
232
|
+
await init.socket.readMessages(keys);
|
|
233
|
+
}
|
|
219
234
|
this._raw.unread_count = 0;
|
|
220
235
|
await init.engine.set(`/chat/${this._raw.id}`, (0, store_1.serialize)(this._raw), this._raw.activity ?? last.at);
|
|
221
236
|
return true;
|
|
@@ -32,6 +32,15 @@ interface Options {
|
|
|
32
32
|
* more than one should name them.
|
|
33
33
|
*/
|
|
34
34
|
device?: string;
|
|
35
|
+
/**
|
|
36
|
+
* Nivel del log interno de baileys; `silent` por defecto. En silencio un cierre remoto no
|
|
37
|
+
* deja rastro de por qué ocurrió: `Farewell` da el código, pero el intercambio que llevó
|
|
38
|
+
* hasta él —el nodo que WhatsApp rechazó— sólo aparece subiendo esto a `debug` o `trace`.
|
|
39
|
+
* Level of baileys' internal log; `silent` by default. Kept silent, a remote close leaves no
|
|
40
|
+
* trace of why it happened: `Farewell` gives the code, but the exchange leading to it —the
|
|
41
|
+
* node WhatsApp rejected— only shows up by raising this to `debug` or `trace`.
|
|
42
|
+
*/
|
|
43
|
+
debug?: 'silent' | 'fatal' | 'error' | 'warn' | 'info' | 'debug' | 'trace';
|
|
35
44
|
}
|
|
36
45
|
/**
|
|
37
46
|
* Por qué se cerró la sesión. Sin esto un cierre remoto es indistinguible de otro: el evento
|
|
@@ -105,7 +105,7 @@ class WhatsApp {
|
|
|
105
105
|
}
|
|
106
106
|
async connect(callback) {
|
|
107
107
|
const { engine } = this;
|
|
108
|
-
const { phone, method, autoclean = true, sync = true, reconnect = true, device } = this.#options;
|
|
108
|
+
const { phone, method, autoclean = true, sync = true, reconnect = true, device, debug } = this.#options;
|
|
109
109
|
const digits = phone !== undefined ? String(phone).replace(/\D+/g, '') : '';
|
|
110
110
|
const budget = reconnect === false ? 0 : reconnect === true ? null : typeof reconnect === 'number' ? reconnect : reconnect.max ?? null;
|
|
111
111
|
const wait = typeof reconnect === 'object' ? (reconnect.interval ?? 60) * 1_000 : 60_000;
|
|
@@ -148,7 +148,7 @@ class WhatsApp {
|
|
|
148
148
|
},
|
|
149
149
|
},
|
|
150
150
|
browser: baileys_1.Browsers.windows(device ?? 'Chrome'),
|
|
151
|
-
logger: (0, pino_1.default)({ level: 'silent' }),
|
|
151
|
+
logger: (0, pino_1.default)({ level: debug ?? 'silent' }),
|
|
152
152
|
syncFullHistory: sync,
|
|
153
153
|
shouldSyncHistoryMessage: ({ syncType }) => sync || syncType !== baileys_1.proto.HistorySync.HistorySyncType.FULL,
|
|
154
154
|
// Cuando el receptor no puede descifrar pide un retry; el cache interno de
|
|
@@ -211,7 +211,22 @@ export function chat(init) {
|
|
|
211
211
|
*/
|
|
212
212
|
async seen() {
|
|
213
213
|
const last = await tail(this._raw.id);
|
|
214
|
-
|
|
214
|
+
// Marcar leído se acusa con recibos, no con una mutación del estado de la app.
|
|
215
|
+
// `chatModify({ markRead })` emite un app patch, y cuando el estado local va por
|
|
216
|
+
// detrás del servidor —lo normal en un dispositivo recién vinculado, que arranca en
|
|
217
|
+
// v0— WhatsApp responde al patch expulsando el dispositivo: `conflict
|
|
218
|
+
// (device_removed)`. Abrir un chat basta para provocarlo, así que la línea se caía
|
|
219
|
+
// sola al primer chat que se mirara. Los recibos no tocan el estado de la app.
|
|
220
|
+
// Marking read is acknowledged with receipts, not with an app-state mutation.
|
|
221
|
+
// `chatModify({ markRead })` emits an app patch, and when the local state trails the
|
|
222
|
+
// server —the norm on a freshly linked device, which starts at v0— WhatsApp answers
|
|
223
|
+
// that patch by dropping the device: `conflict (device_removed)`. Opening a chat was
|
|
224
|
+
// enough to trigger it, so the line died on the first chat anyone looked at.
|
|
225
|
+
// Receipts leave the app state alone.
|
|
226
|
+
const keys = last.messages.map(({ key }) => ({ remoteJid: key.remoteJid, id: key.id, participant: undefined }));
|
|
227
|
+
if (keys.length) {
|
|
228
|
+
await init.socket.readMessages(keys);
|
|
229
|
+
}
|
|
215
230
|
this._raw.unread_count = 0;
|
|
216
231
|
await init.engine.set(`/chat/${this._raw.id}`, serialize(this._raw), this._raw.activity ?? last.at);
|
|
217
232
|
return true;
|
|
@@ -32,6 +32,15 @@ interface Options {
|
|
|
32
32
|
* more than one should name them.
|
|
33
33
|
*/
|
|
34
34
|
device?: string;
|
|
35
|
+
/**
|
|
36
|
+
* Nivel del log interno de baileys; `silent` por defecto. En silencio un cierre remoto no
|
|
37
|
+
* deja rastro de por qué ocurrió: `Farewell` da el código, pero el intercambio que llevó
|
|
38
|
+
* hasta él —el nodo que WhatsApp rechazó— sólo aparece subiendo esto a `debug` o `trace`.
|
|
39
|
+
* Level of baileys' internal log; `silent` by default. Kept silent, a remote close leaves no
|
|
40
|
+
* trace of why it happened: `Farewell` gives the code, but the exchange leading to it —the
|
|
41
|
+
* node WhatsApp rejected— only shows up by raising this to `debug` or `trace`.
|
|
42
|
+
*/
|
|
43
|
+
debug?: 'silent' | 'fatal' | 'error' | 'warn' | 'info' | 'debug' | 'trace';
|
|
35
44
|
}
|
|
36
45
|
/**
|
|
37
46
|
* Por qué se cerró la sesión. Sin esto un cierre remoto es indistinguible de otro: el evento
|
|
@@ -67,7 +67,7 @@ export default class WhatsApp {
|
|
|
67
67
|
}
|
|
68
68
|
async connect(callback) {
|
|
69
69
|
const { engine } = this;
|
|
70
|
-
const { phone, method, autoclean = true, sync = true, reconnect = true, device } = this.#options;
|
|
70
|
+
const { phone, method, autoclean = true, sync = true, reconnect = true, device, debug } = this.#options;
|
|
71
71
|
const digits = phone !== undefined ? String(phone).replace(/\D+/g, '') : '';
|
|
72
72
|
const budget = reconnect === false ? 0 : reconnect === true ? null : typeof reconnect === 'number' ? reconnect : reconnect.max ?? null;
|
|
73
73
|
const wait = typeof reconnect === 'object' ? (reconnect.interval ?? 60) * 1_000 : 60_000;
|
|
@@ -110,7 +110,7 @@ export default class WhatsApp {
|
|
|
110
110
|
},
|
|
111
111
|
},
|
|
112
112
|
browser: Browsers.windows(device ?? 'Chrome'),
|
|
113
|
-
logger: pino({ level: 'silent' }),
|
|
113
|
+
logger: pino({ level: debug ?? 'silent' }),
|
|
114
114
|
syncFullHistory: sync,
|
|
115
115
|
shouldSyncHistoryMessage: ({ syncType }) => sync || syncType !== proto.HistorySync.HistorySyncType.FULL,
|
|
116
116
|
// Cuando el receptor no puede descifrar pide un retry; el cache interno de
|