Skip to content

Commit 0ccc770

Browse files
authored
Merge pull request #197 from jeankassio/main
Bugfix timestamp from syncMessage
2 parents ce25c91 + 553bac4 commit 0ccc770

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/whatsapp/services/whatsapp.service.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -807,8 +807,14 @@ export class WAStartupService {
807807
continue;
808808
}
809809

810-
if (Long.isLong(m?.messageTimestamp)) {
811-
m.messageTimestamp = m.messageTimestamp?.toNumber();
810+
let timestamp = m?.messageTimestamp;
811+
812+
if (timestamp && typeof timestamp === 'object' && typeof timestamp.toNumber === 'function') {
813+
timestamp = timestamp.toNumber();
814+
}else if (timestamp && typeof timestamp === 'object' && 'low' in timestamp && 'high' in timestamp) {
815+
timestamp = Number(timestamp.low) || 0;
816+
}else if (typeof timestamp !== 'number') {
817+
timestamp = 0;
812818
}
813819

814820
const messageType = getContentType(m.message);
@@ -825,7 +831,7 @@ export class WAStartupService {
825831
keyParticipant: m?.participant || m.key?.participant,
826832
messageType,
827833
content: m.message[messageType] as PrismType.Prisma.JsonValue,
828-
messageTimestamp: m.messageTimestamp,
834+
messageTimestamp: timestamp,
829835
instanceId: this.instance.id,
830836
device: getDevice(m.key.id),
831837
} as PrismType.Message);

0 commit comments

Comments
 (0)