Cable-Desktop/libtextsecure/test/fake_api.js

31 lines
1,020 B
JavaScript
Raw Normal View History

/*
* vim: ts=4:sw=4:expandtab
*/
var getKeysForNumberMap = {};
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");
};
var messagesSentMap = {};
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");
2015-01-06 23:46:23 +01:00
messagesSentMap[destination + "." + messageArray[i].destinationDeviceId] = msg;
}
};