Update json formatting for legacy message requests
Legacy DataMessages are sent using the `body` field, new Content messages are sent using the `content` field. // FREEBIE
This commit is contained in:
parent
a833d62a71
commit
228ffe901d
3 changed files with 22 additions and 10 deletions
|
@ -39168,10 +39168,15 @@ TextSecureServer = function () {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
self.sendMessages = function(destination, messageArray) {
|
self.sendMessages = function(destination, messageArray, legacy) {
|
||||||
//TODO: Do this conversion somewhere else?
|
//TODO: Do this conversion somewhere else?
|
||||||
for (var i = 0; i < messageArray.length; i++)
|
for (var i = 0; i < messageArray.length; i++) {
|
||||||
messageArray[i].body = btoa(messageArray[i].body);
|
messageArray[i].content = btoa(messageArray[i].content);
|
||||||
|
if (legacy) {
|
||||||
|
messageArray[i].body = messageArray[i].content;
|
||||||
|
delete messageArray[i].content;
|
||||||
|
}
|
||||||
|
}
|
||||||
var jsonData = { messages: messageArray };
|
var jsonData = { messages: messageArray };
|
||||||
if (messageArray[0].relay !== undefined)
|
if (messageArray[0].relay !== undefined)
|
||||||
jsonData.relay = messageArray[0].relay;
|
jsonData.relay = messageArray[0].relay;
|
||||||
|
@ -39700,7 +39705,7 @@ window.textsecure.messaging = function() {
|
||||||
type: encryptedMsg.type,
|
type: encryptedMsg.type,
|
||||||
destinationDeviceId: textsecure.utils.unencodeNumber(deviceObjectList[i].encodedNumber)[1],
|
destinationDeviceId: textsecure.utils.unencodeNumber(deviceObjectList[i].encodedNumber)[1],
|
||||||
destinationRegistrationId: registrationId,
|
destinationRegistrationId: registrationId,
|
||||||
body: encryptedMsg.body,
|
content: encryptedMsg.body,
|
||||||
timestamp: timestamp
|
timestamp: timestamp
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -39714,7 +39719,8 @@ window.textsecure.messaging = function() {
|
||||||
for (var i = 0; i < deviceObjectList.length; i++)
|
for (var i = 0; i < deviceObjectList.length; i++)
|
||||||
promises[i] = addEncryptionFor(i);
|
promises[i] = addEncryptionFor(i);
|
||||||
return Promise.all(promises).then(function() {
|
return Promise.all(promises).then(function() {
|
||||||
return TextSecureServer.sendMessages(number, jsonData);
|
var legacy = (message instanceof textsecure.protobuf.DataMessage);
|
||||||
|
return TextSecureServer.sendMessages(number, jsonData, legacy);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -248,10 +248,15 @@ TextSecureServer = function () {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
self.sendMessages = function(destination, messageArray) {
|
self.sendMessages = function(destination, messageArray, legacy) {
|
||||||
//TODO: Do this conversion somewhere else?
|
//TODO: Do this conversion somewhere else?
|
||||||
for (var i = 0; i < messageArray.length; i++)
|
for (var i = 0; i < messageArray.length; i++) {
|
||||||
messageArray[i].body = btoa(messageArray[i].body);
|
messageArray[i].content = btoa(messageArray[i].content);
|
||||||
|
if (legacy) {
|
||||||
|
messageArray[i].body = messageArray[i].content;
|
||||||
|
delete messageArray[i].content;
|
||||||
|
}
|
||||||
|
}
|
||||||
var jsonData = { messages: messageArray };
|
var jsonData = { messages: messageArray };
|
||||||
if (messageArray[0].relay !== undefined)
|
if (messageArray[0].relay !== undefined)
|
||||||
jsonData.relay = messageArray[0].relay;
|
jsonData.relay = messageArray[0].relay;
|
||||||
|
|
|
@ -74,7 +74,7 @@ window.textsecure.messaging = function() {
|
||||||
type: encryptedMsg.type,
|
type: encryptedMsg.type,
|
||||||
destinationDeviceId: textsecure.utils.unencodeNumber(deviceObjectList[i].encodedNumber)[1],
|
destinationDeviceId: textsecure.utils.unencodeNumber(deviceObjectList[i].encodedNumber)[1],
|
||||||
destinationRegistrationId: registrationId,
|
destinationRegistrationId: registrationId,
|
||||||
body: encryptedMsg.body,
|
content: encryptedMsg.body,
|
||||||
timestamp: timestamp
|
timestamp: timestamp
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -88,7 +88,8 @@ window.textsecure.messaging = function() {
|
||||||
for (var i = 0; i < deviceObjectList.length; i++)
|
for (var i = 0; i < deviceObjectList.length; i++)
|
||||||
promises[i] = addEncryptionFor(i);
|
promises[i] = addEncryptionFor(i);
|
||||||
return Promise.all(promises).then(function() {
|
return Promise.all(promises).then(function() {
|
||||||
return TextSecureServer.sendMessages(number, jsonData);
|
var legacy = (message instanceof textsecure.protobuf.DataMessage);
|
||||||
|
return TextSecureServer.sendMessages(number, jsonData, legacy);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue