@arcaelas/whatsapp 6.1.0 → 6.1.1
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.
|
@@ -52,6 +52,8 @@ const internal_1 = require("../../lib/internal");
|
|
|
52
52
|
const message_1 = require("../../lib/message");
|
|
53
53
|
const status_1 = require("../../lib/status");
|
|
54
54
|
const store_1 = require("../../lib/store");
|
|
55
|
+
/** Rechazo del servidor: estado terminal, el único que puede retroceder el avance. / Server rejection: terminal state, the only one allowed to move the state backwards. */
|
|
56
|
+
const ERROR = 0;
|
|
55
57
|
/** Estados legibles del mensaje que el receipt puede avanzar. / Readable message states a receipt can advance to. */
|
|
56
58
|
const READ = 4;
|
|
57
59
|
const PLAYED = 5;
|
|
@@ -947,6 +949,13 @@ class WhatsApp {
|
|
|
947
949
|
if (existing_doc.reactions) {
|
|
948
950
|
doc.reactions = existing_doc.reactions;
|
|
949
951
|
}
|
|
952
|
+
// El historial reporta el estado que tenía al sincronizarse: si acá se reescribe
|
|
953
|
+
// por otro cambio (edición, destacado), el estado ya conocido se conserva.
|
|
954
|
+
// History reports the state it had when synced: if the doc gets rewritten here
|
|
955
|
+
// for another change (edit, star), the state already known is kept.
|
|
956
|
+
if (existing_doc.status > doc.status) {
|
|
957
|
+
doc.status = existing_doc.status;
|
|
958
|
+
}
|
|
950
959
|
if (existing_doc.status >= doc.status &&
|
|
951
960
|
existing_doc.caption === doc.caption &&
|
|
952
961
|
existing_doc.edited === doc.edited &&
|
|
@@ -1103,8 +1112,14 @@ class WhatsApp {
|
|
|
1103
1112
|
await this.engine.set(path, (0, store_1.serialize)(doc), doc.created_at);
|
|
1104
1113
|
const msg_instance = (0, message_1.message)(this, doc);
|
|
1105
1114
|
this.emit(doc.starred ? 'message:starred' : 'message:unstarred', msg_instance, await msg_instance.chat(), this);
|
|
1115
|
+
// WhatsApp reemite los acks desordenados al reconectar (un `sent` después
|
|
1116
|
+
// de un `delivered`), así que el estado solo avanza; el rechazo (`error`)
|
|
1117
|
+
// es terminal y sí puede pisar lo que hubiera.
|
|
1118
|
+
// WhatsApp re-emits acks out of order on reconnect (a `sent` after a
|
|
1119
|
+
// `delivered`), so the state only moves forward; a rejection (`error`) is
|
|
1120
|
+
// terminal and may override whatever was there.
|
|
1106
1121
|
}
|
|
1107
|
-
else if (status !== undefined) {
|
|
1122
|
+
else if (status !== undefined && (status > doc.status || status === ERROR)) {
|
|
1108
1123
|
raw.status = status;
|
|
1109
1124
|
doc.status = status;
|
|
1110
1125
|
// El rechazo del servidor viaja como stub del update; sin persistirlo el
|
|
@@ -13,6 +13,8 @@ import { bind } from '../../lib/internal.js';
|
|
|
13
13
|
import { Audio, Document, Event, Image, Location, message, Message, Poll, Sticker, Text, VCard, Video, } from '../../lib/message/index.js';
|
|
14
14
|
import { Feed, TTL_MS as FEED_TTL_MS } from '../../lib/status/index.js';
|
|
15
15
|
import { deserialize, serialize } from '../../lib/store/index.js';
|
|
16
|
+
/** Rechazo del servidor: estado terminal, el único que puede retroceder el avance. / Server rejection: terminal state, the only one allowed to move the state backwards. */
|
|
17
|
+
const ERROR = 0;
|
|
16
18
|
/** Estados legibles del mensaje que el receipt puede avanzar. / Readable message states a receipt can advance to. */
|
|
17
19
|
const READ = 4;
|
|
18
20
|
const PLAYED = 5;
|
|
@@ -908,6 +910,13 @@ export class WhatsApp {
|
|
|
908
910
|
if (existing_doc.reactions) {
|
|
909
911
|
doc.reactions = existing_doc.reactions;
|
|
910
912
|
}
|
|
913
|
+
// El historial reporta el estado que tenía al sincronizarse: si acá se reescribe
|
|
914
|
+
// por otro cambio (edición, destacado), el estado ya conocido se conserva.
|
|
915
|
+
// History reports the state it had when synced: if the doc gets rewritten here
|
|
916
|
+
// for another change (edit, star), the state already known is kept.
|
|
917
|
+
if (existing_doc.status > doc.status) {
|
|
918
|
+
doc.status = existing_doc.status;
|
|
919
|
+
}
|
|
911
920
|
if (existing_doc.status >= doc.status &&
|
|
912
921
|
existing_doc.caption === doc.caption &&
|
|
913
922
|
existing_doc.edited === doc.edited &&
|
|
@@ -1064,8 +1073,14 @@ export class WhatsApp {
|
|
|
1064
1073
|
await this.engine.set(path, serialize(doc), doc.created_at);
|
|
1065
1074
|
const msg_instance = message(this, doc);
|
|
1066
1075
|
this.emit(doc.starred ? 'message:starred' : 'message:unstarred', msg_instance, await msg_instance.chat(), this);
|
|
1076
|
+
// WhatsApp reemite los acks desordenados al reconectar (un `sent` después
|
|
1077
|
+
// de un `delivered`), así que el estado solo avanza; el rechazo (`error`)
|
|
1078
|
+
// es terminal y sí puede pisar lo que hubiera.
|
|
1079
|
+
// WhatsApp re-emits acks out of order on reconnect (a `sent` after a
|
|
1080
|
+
// `delivered`), so the state only moves forward; a rejection (`error`) is
|
|
1081
|
+
// terminal and may override whatever was there.
|
|
1067
1082
|
}
|
|
1068
|
-
else if (status !== undefined) {
|
|
1083
|
+
else if (status !== undefined && (status > doc.status || status === ERROR)) {
|
|
1069
1084
|
raw.status = status;
|
|
1070
1085
|
doc.status = status;
|
|
1071
1086
|
// El rechazo del servidor viaja como stub del update; sin persistirlo el
|