2015-09-07 23:53:43 +02:00
|
|
|
/*
|
|
|
|
* vim: ts=4:sw=4:expandtab
|
2014-05-04 08:34:13 +02:00
|
|
|
*/
|
|
|
|
|
2014-05-31 19:28:46 +02:00
|
|
|
var getKeysForNumberMap = {};
|
2015-04-30 23:10:04 +02:00
|
|
|
TextSecureServer.getKeysForNumber = function(number, deviceId) {
|
2015-01-06 23:46:23 +01: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 23:10:04 +02:00
|
|
|
};
|
2014-03-14 08:47:13 +01:00
|
|
|
|
2014-05-31 19:28:46 +02:00
|
|
|
var messagesSentMap = {};
|
2015-04-30 23:10:04 +02:00
|
|
|
TextSecureServer.sendMessages = function(destination, messageArray) {
|
2015-01-06 23:46:23 +01: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 08:47:13 +01:00
|
|
|
|
2015-01-06 23:46:23 +01:00
|
|
|
messagesSentMap[destination + "." + messageArray[i].destinationDeviceId] = msg;
|
|
|
|
}
|
2015-04-30 23:10:04 +02:00
|
|
|
};
|