2014-05-14 18:58:12 +00:00
|
|
|
/* vim: ts=4:sw=4
|
|
|
|
*
|
2014-05-04 06:34:13 +00:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2014-05-31 17:28:46 +00:00
|
|
|
var getKeysForNumberMap = {};
|
2014-07-25 00:15:27 +00:00
|
|
|
textsecure.api.getKeysForNumber = function(number, deviceId) {
|
2014-05-31 17:28:46 +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");
|
|
|
|
}
|
2014-03-14 07:47:13 +00:00
|
|
|
|
2014-05-31 17:28:46 +00:00
|
|
|
var messagesSentMap = {};
|
|
|
|
textsecure.api.sendMessages = function(destination, messageArray) {
|
|
|
|
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 ||
|
2014-06-03 16:39:29 +00:00
|
|
|
msg.relay !== undefined ||
|
|
|
|
msg.destination !== undefined)
|
2014-05-31 17:28:46 +00:00
|
|
|
throw new Error("Invalid message");
|
2014-03-14 07:47:13 +00:00
|
|
|
|
2014-05-31 17:28:46 +00:00
|
|
|
messagesSentMap[destination + "." + messageArray[i].destinationDeviceId] = msg;
|
2014-03-22 22:45:01 +00:00
|
|
|
}
|
2014-05-31 17:28:46 +00:00
|
|
|
}
|