[core] NOWEB - fix timestamp
This commit is contained in:
1 parent
d87cdef311
commit
be888f195d
2 files changed
+13
-5
No files matched your search
@@ -158,7 +158,7 @@ import { NowebAuthFactoryCore } from './NowebAuthFactoryCore';
|
||||
import { INowebStore } from './store/INowebStore';
|
||||
import { NowebPersistentStore } from './store/NowebPersistentStore';
|
||||
import { NowebStorageFactoryCore } from './store/NowebStorageFactoryCore';
|
||||
import { extractMediaContent } from './utils';
|
||||
import { ensureNumber, extractMediaContent } from './utils';
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const QRCode = require('qrcode');
|
||||
@@ -1507,7 +1507,7 @@ export class WhatsappSessionNoWebCore extends WhatsappSession {
|
||||
const messageId = buildMessageId(reactionMessage.key);
|
||||
const reaction: WAMessageReaction = {
|
||||
id: id,
|
||||
timestamp: message.messageTimestamp,
|
||||
timestamp: ensureNumber(message.messageTimestamp),
|
||||
from: toCusFormat(fromToParticipant.from),
|
||||
fromMe: message.key.fromMe,
|
||||
to: toCusFormat(fromToParticipant.to),
|
||||
@@ -1556,7 +1556,7 @@ export class WhatsappSessionNoWebCore extends WhatsappSession {
|
||||
const ack = message.ack || message.status - 1;
|
||||
return Promise.resolve({
|
||||
id: id,
|
||||
timestamp: message.messageTimestamp,
|
||||
timestamp: ensureNumber(message.messageTimestamp),
|
||||
from: toCusFormat(fromToParticipant.from),
|
||||
fromMe: message.key.fromMe,
|
||||
body: body,
|
||||
@@ -1700,7 +1700,7 @@ export class WhatsappSessionNoWebCore extends WhatsappSession {
|
||||
const pollVote: PollVote = {
|
||||
...voteDestination,
|
||||
selectedOptions: selectedOptions,
|
||||
timestamp: pollUpdate.senderTimestampMs,
|
||||
timestamp: ensureNumber(pollUpdate.senderTimestampMs),
|
||||
};
|
||||
const payload: PollVotePayload = {
|
||||
vote: pollVote,
|
||||
@@ -1732,7 +1732,7 @@ export class WhatsappSessionNoWebCore extends WhatsappSession {
|
||||
// https://github.com/WhiskeySockets/Baileys/pull/348
|
||||
// Or without toNumber() - it depends on the PR above
|
||||
// timestamp: pollUpdateMessage.senderTimestampMs.toNumber()
|
||||
timestamp: message.messageTimestamp,
|
||||
timestamp: ensureNumber(message.messageTimestamp),
|
||||
};
|
||||
const payload: PollVotePayload = {
|
||||
vote: pollVote,
|
||||
|
||||
@@ -78,6 +78,14 @@ const isObjectALong = (value: any): value is Long => {
|
||||
);
|
||||
};
|
||||
|
||||
export function ensureNumber(value: number | Long): number {
|
||||
if (!value) {
|
||||
// @ts-ignore
|
||||
return value;
|
||||
}
|
||||
return typeof value === 'number' ? value : toNumber(value);
|
||||
}
|
||||
|
||||
const toNumber = (longValue: Long): number => {
|
||||
const { low, high, unsigned } = longValue;
|
||||
const result = unsigned ? low >>> 0 : low + high * 0x100000000;
|
||||
|
||||
Reference in new issue
Block a user