2015-09-07 21:53:43 +00:00
|
|
|
/*
|
|
|
|
* vim: ts=4:sw=4:expandtab
|
2014-05-04 06:34:13 +00:00
|
|
|
*/
|
|
|
|
|
2014-05-31 17:28:46 +00:00
|
|
|
var getKeysForNumberMap = {};
|
2015-04-30 21:10:04 +00:00
|
|
|
TextSecureServer.getKeysForNumber = function(number, deviceId) {
|
2015-01-06 22:46:23 +00:00
|
|
|
var res = getKeysForNumberMap[number];
|
|
|
|
if (res !== undefined) {
|
|
|
|
delete getKeysForNumberMap[number];
|
|
|
|
return Promise.resolve(res);
|
|
|
|
} else
|
|
|
|
throw new Error("getKeysForNumber of unknown/used number");
|
2015-04-30 21:10:04 +00:00
|
|
|
};
|
2014-03-14 07:47:13 +00:00
|
|
|
|
2014-05-31 17:28:46 +00:00
|
|
|
var messagesSentMap = {};
|
2015-04-30 21:10:04 +00:00
|
|
|
TextSecureServer.sendMessages = function(destination, messageArray) {
|
2015-01-06 22:46:23 +00:00
|
|
|
for (i in messageArray) {
|
|
|
|
var msg = messageArray[i];
|
|
|
|
if ((msg.type != 1 && msg.type != 3) ||
|
|
|
|
msg.destinationDeviceId === undefined ||
|
|
|
|
msg.destinationRegistrationId === undefined ||
|
|
|
|
msg.body === undefined ||
|
|
|
|
msg.timestamp == undefined ||
|
|
|
|
msg.relay !== undefined ||
|
|
|
|
msg.destination !== undefined)
|
|
|
|
throw new Error("Invalid message");
|
2014-03-14 07:47:13 +00:00
|
|
|
|
2015-01-06 22:46:23 +00:00
|
|
|
messagesSentMap[destination + "." + messageArray[i].destinationDeviceId] = msg;
|
|
|
|
}
|
2015-04-30 21:10:04 +00:00
|
|
|
};
|