Use --force-long with pbjs

This commit is contained in:
Fedor Indutny 2022-03-23 13:49:27 -07:00 committed by GitHub
parent bb066d4a84
commit 2eaacac151
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 99 additions and 131 deletions

View file

@ -342,7 +342,7 @@ class Message {
}
const proto = new Proto.DataMessage();
proto.timestamp = this.timestamp;
proto.timestamp = Long.fromNumber(this.timestamp);
proto.attachments = this.attachmentPointers;
if (this.body) {
@ -384,7 +384,10 @@ class Message {
proto.reaction.emoji = this.reaction.emoji || null;
proto.reaction.remove = this.reaction.remove || false;
proto.reaction.targetAuthorUuid = this.reaction.targetAuthorUuid || null;
proto.reaction.targetTimestamp = this.reaction.targetTimestamp || null;
proto.reaction.targetTimestamp =
this.reaction.targetTimestamp === undefined
? null
: Long.fromNumber(this.reaction.targetTimestamp);
}
if (Array.isArray(this.preview)) {
@ -407,7 +410,8 @@ class Message {
proto.quote = new Quote();
const { quote } = proto;
quote.id = this.quote.id || null;
quote.id =
this.quote.id === undefined ? null : Long.fromNumber(this.quote.id);
quote.authorUuid = this.quote.authorUuid || null;
quote.text = this.quote.text || null;
quote.attachments = (this.quote.attachments || []).map(
@ -453,7 +457,7 @@ class Message {
}
if (this.deletedForEveryoneTimestamp) {
proto.delete = {
targetSentTimestamp: this.deletedForEveryoneTimestamp,
targetSentTimestamp: Long.fromNumber(this.deletedForEveryoneTimestamp),
};
}
if (this.mentions) {
@ -484,7 +488,7 @@ class Message {
if (this.storyContext.authorUuid) {
storyContext.authorUuid = this.storyContext.authorUuid;
}
storyContext.sentTimestamp = this.storyContext.timestamp;
storyContext.sentTimestamp = Long.fromNumber(this.storyContext.timestamp);
proto.storyContext = storyContext;
}
@ -772,7 +776,7 @@ export default class MessageSender {
typingMessage.groupId = groupId;
}
typingMessage.action = action;
typingMessage.timestamp = finalTimestamp;
typingMessage.timestamp = Long.fromNumber(finalTimestamp);
const contentMessage = new Proto.Content();
contentMessage.typingMessage = typingMessage;
@ -1111,7 +1115,7 @@ export default class MessageSender {
const dataMessage = Proto.DataMessage.decode(encodedDataMessage);
const sentMessage = new Proto.SyncMessage.Sent();
sentMessage.timestamp = timestamp;
sentMessage.timestamp = Long.fromNumber(timestamp);
sentMessage.message = dataMessage;
if (destination) {
sentMessage.destination = destination;
@ -1120,7 +1124,9 @@ export default class MessageSender {
sentMessage.destinationUuid = destinationUuid;
}
if (expirationStartTimestamp) {
sentMessage.expirationStartTimestamp = expirationStartTimestamp;
sentMessage.expirationStartTimestamp = Long.fromNumber(
expirationStartTimestamp
);
}
if (isUpdate) {
@ -1345,7 +1351,10 @@ export default class MessageSender {
const syncMessage = this.createSyncMessage();
syncMessage.read = [];
for (let i = 0; i < reads.length; i += 1) {
const proto = new Proto.SyncMessage.Read(reads[i]);
const proto = new Proto.SyncMessage.Read({
...reads[i],
timestamp: Long.fromNumber(reads[i].timestamp),
});
syncMessage.read.push(proto);
}
@ -1374,7 +1383,13 @@ export default class MessageSender {
const myUuid = window.textsecure.storage.user.getCheckedUuid();
const syncMessage = this.createSyncMessage();
syncMessage.viewed = views.map(view => new Proto.SyncMessage.Viewed(view));
syncMessage.viewed = views.map(
view =>
new Proto.SyncMessage.Viewed({
...view,
timestamp: Long.fromNumber(view.timestamp),
})
);
const contentMessage = new Proto.Content();
contentMessage.syncMessage = syncMessage;
@ -1417,7 +1432,7 @@ export default class MessageSender {
viewOnceOpen.sender = senderE164;
}
viewOnceOpen.senderUuid = senderUuid;
viewOnceOpen.timestamp = timestamp;
viewOnceOpen.timestamp = Long.fromNumber(timestamp);
syncMessage.viewOnceOpen = viewOnceOpen;
const contentMessage = new Proto.Content();
@ -1647,7 +1662,9 @@ export default class MessageSender {
const receiptMessage = new Proto.ReceiptMessage();
receiptMessage.type = type;
receiptMessage.timestamp = timestamps;
receiptMessage.timestamp = timestamps.map(timestamp =>
Long.fromNumber(timestamp)
);
const contentMessage = new Proto.Content();
contentMessage.receiptMessage = receiptMessage;