|
|
@ -39582,17 +39582,14 @@ textsecure.MessageReceiver.prototype = {
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* vim: ts=4:sw=4:expandtab
|
|
|
|
* vim: ts=4:sw=4:expandtab
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
// sendMessage(numbers = [], message = PushMessageContentProto, callback(success/failure map))
|
|
|
|
function MessageSender(url, username, password) {
|
|
|
|
window.textsecure.MessageSender = function(url, username, password) {
|
|
|
|
this.server = new TextSecureServer(url, username, password);
|
|
|
|
'use strict';
|
|
|
|
}
|
|
|
|
var server = new TextSecureServer(url, username, password);
|
|
|
|
|
|
|
|
return (function(TextSecureServer) {
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var self = {};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MessageSender.prototype = {
|
|
|
|
|
|
|
|
constructor: MessageSender,
|
|
|
|
// message == DataMessage or ContentMessage proto
|
|
|
|
// message == DataMessage or ContentMessage proto
|
|
|
|
function sendMessageToDevices(timestamp, number, deviceObjectList, message) {
|
|
|
|
sendMessageToDevices: function(timestamp, number, deviceObjectList, message) {
|
|
|
|
var relay = deviceObjectList[0].relay;
|
|
|
|
var relay = deviceObjectList[0].relay;
|
|
|
|
for (var i=1; i < deviceObjectList.length; ++i) {
|
|
|
|
for (var i=1; i < deviceObjectList.length; ++i) {
|
|
|
|
if (deviceObjectList[i].relay !== relay) {
|
|
|
|
if (deviceObjectList[i].relay !== relay) {
|
|
|
@ -39621,11 +39618,11 @@ window.textsecure.MessageSender = function(url, username, password) {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
})).then(function(jsonData) {
|
|
|
|
})).then(function(jsonData) {
|
|
|
|
var legacy = (message instanceof textsecure.protobuf.DataMessage);
|
|
|
|
var legacy = (message instanceof textsecure.protobuf.DataMessage);
|
|
|
|
return TextSecureServer.sendMessages(number, jsonData, legacy);
|
|
|
|
return this.server.sendMessages(number, jsonData, legacy);
|
|
|
|
});
|
|
|
|
}.bind(this));
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
function makeAttachmentPointer(attachment) {
|
|
|
|
makeAttachmentPointer: function(attachment) {
|
|
|
|
if (typeof attachment !== 'object' || attachment == null) {
|
|
|
|
if (typeof attachment !== 'object' || attachment == null) {
|
|
|
|
return Promise.resolve(undefined);
|
|
|
|
return Promise.resolve(undefined);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -39634,28 +39631,27 @@ window.textsecure.MessageSender = function(url, username, password) {
|
|
|
|
|
|
|
|
|
|
|
|
var iv = textsecure.crypto.getRandomBytes(16);
|
|
|
|
var iv = textsecure.crypto.getRandomBytes(16);
|
|
|
|
return textsecure.crypto.encryptAttachment(attachment.data, proto.key, iv).then(function(encryptedBin) {
|
|
|
|
return textsecure.crypto.encryptAttachment(attachment.data, proto.key, iv).then(function(encryptedBin) {
|
|
|
|
return TextSecureServer.putAttachment(encryptedBin).then(function(id) {
|
|
|
|
return this.server.putAttachment(encryptedBin).then(function(id) {
|
|
|
|
proto.id = id;
|
|
|
|
proto.id = id;
|
|
|
|
proto.contentType = attachment.contentType;
|
|
|
|
proto.contentType = attachment.contentType;
|
|
|
|
return proto;
|
|
|
|
return proto;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}.bind(this));
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
var tryMessageAgain = function(number, encodedMessage, timestamp) {
|
|
|
|
tryMessageAgain: function(number, encodedMessage, timestamp) {
|
|
|
|
var proto = textsecure.protobuf.DataMessage.decode(encodedMessage);
|
|
|
|
var proto = textsecure.protobuf.DataMessage.decode(encodedMessage);
|
|
|
|
return new Promise(function(resolve, reject) {
|
|
|
|
return new Promise(function(resolve, reject) {
|
|
|
|
sendMessageProto(timestamp, [number], proto, function(res) {
|
|
|
|
this.sendMessageProto(timestamp, [number], proto, function(res) {
|
|
|
|
if (res.failure.length > 0)
|
|
|
|
if (res.failure.length > 0)
|
|
|
|
reject(res.failure);
|
|
|
|
reject(res.failure);
|
|
|
|
else
|
|
|
|
else
|
|
|
|
resolve();
|
|
|
|
resolve();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}.bind(this));
|
|
|
|
};
|
|
|
|
},
|
|
|
|
textsecure.replay.registerFunction(tryMessageAgain, textsecure.replay.Type.SEND_MESSAGE);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var sendMessageProto = function(timestamp, numbers, message, callback) {
|
|
|
|
sendMessageProto: function(timestamp, numbers, message, callback) {
|
|
|
|
var numbersCompleted = 0;
|
|
|
|
var numbersCompleted = 0;
|
|
|
|
var errors = [];
|
|
|
|
var errors = [];
|
|
|
|
var successfulNumbers = [];
|
|
|
|
var successfulNumbers = [];
|
|
|
@ -39710,18 +39706,18 @@ window.textsecure.MessageSender = function(url, username, password) {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
if (updateDevices === undefined) {
|
|
|
|
if (updateDevices === undefined) {
|
|
|
|
return TextSecureServer.getKeysForNumber(number).then(handleResult);
|
|
|
|
return this.server.getKeysForNumber(number).then(handleResult);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
var promises = updateDevices.map(function(device) {
|
|
|
|
var promises = updateDevices.map(function(device) {
|
|
|
|
return TextSecureServer.getKeysForNumber(number, device).then(handleResult);
|
|
|
|
return this.server.getKeysForNumber(number, device).then(handleResult);
|
|
|
|
});
|
|
|
|
}.bind(this));
|
|
|
|
|
|
|
|
|
|
|
|
return Promise.all(promises);
|
|
|
|
return Promise.all(promises);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var doSendMessage = function(number, devicesForNumber, recurse) {
|
|
|
|
var doSendMessage = function(number, devicesForNumber, recurse) {
|
|
|
|
return sendMessageToDevices(timestamp, number, devicesForNumber, message).then(function(result) {
|
|
|
|
return this.sendMessageToDevices(timestamp, number, devicesForNumber, message).then(function(result) {
|
|
|
|
successfulNumbers[successfulNumbers.length] = number;
|
|
|
|
successfulNumbers[successfulNumbers.length] = number;
|
|
|
|
numberCompleted();
|
|
|
|
numberCompleted();
|
|
|
|
}).catch(function(error) {
|
|
|
|
}).catch(function(error) {
|
|
|
@ -39750,7 +39746,7 @@ window.textsecure.MessageSender = function(url, username, password) {
|
|
|
|
registerError(number, "Failed to create or send message", error);
|
|
|
|
registerError(number, "Failed to create or send message", error);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
}.bind(this);
|
|
|
|
|
|
|
|
|
|
|
|
numbers.forEach(function(number) {
|
|
|
|
numbers.forEach(function(number) {
|
|
|
|
textsecure.storage.devices.getDeviceObjectsForNumber(number).then(function(devicesForNumber) {
|
|
|
|
textsecure.storage.devices.getDeviceObjectsForNumber(number).then(function(devicesForNumber) {
|
|
|
@ -39773,20 +39769,20 @@ window.textsecure.MessageSender = function(url, username, password) {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
var sendIndividualProto = function(number, proto, timestamp) {
|
|
|
|
sendIndividualProto: function(number, proto, timestamp) {
|
|
|
|
return new Promise(function(resolve, reject) {
|
|
|
|
return new Promise(function(resolve, reject) {
|
|
|
|
sendMessageProto(timestamp, [number], proto, function(res) {
|
|
|
|
this.sendMessageProto(timestamp, [number], proto, function(res) {
|
|
|
|
if (res.failure.length > 0)
|
|
|
|
if (res.failure.length > 0)
|
|
|
|
reject(res.failure);
|
|
|
|
reject(res.failure);
|
|
|
|
else
|
|
|
|
else
|
|
|
|
resolve();
|
|
|
|
resolve();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}.bind(this));
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
var sendSyncMessage = function(message, timestamp, destination) {
|
|
|
|
sendSyncMessage: function(message, timestamp, destination) {
|
|
|
|
var myNumber = textsecure.storage.user.getNumber();
|
|
|
|
var myNumber = textsecure.storage.user.getNumber();
|
|
|
|
var myDevice = textsecure.storage.user.getDeviceId();
|
|
|
|
var myDevice = textsecure.storage.user.getDeviceId();
|
|
|
|
if (myDevice != 1) {
|
|
|
|
if (myDevice != 1) {
|
|
|
@ -39801,11 +39797,11 @@ window.textsecure.MessageSender = function(url, username, password) {
|
|
|
|
var contentMessage = new textsecure.protobuf.Content();
|
|
|
|
var contentMessage = new textsecure.protobuf.Content();
|
|
|
|
contentMessage.syncMessage = syncMessage;
|
|
|
|
contentMessage.syncMessage = syncMessage;
|
|
|
|
|
|
|
|
|
|
|
|
return sendIndividualProto(myNumber, contentMessage, Date.now());
|
|
|
|
return this.sendIndividualProto(myNumber, contentMessage, Date.now());
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
self.sendRequestGroupSyncMessage = function() {
|
|
|
|
sendRequestGroupSyncMessage: function() {
|
|
|
|
var myNumber = textsecure.storage.user.getNumber();
|
|
|
|
var myNumber = textsecure.storage.user.getNumber();
|
|
|
|
var myDevice = textsecure.storage.user.getDeviceId();
|
|
|
|
var myDevice = textsecure.storage.user.getDeviceId();
|
|
|
|
if (myDevice != 1) {
|
|
|
|
if (myDevice != 1) {
|
|
|
@ -39816,10 +39812,11 @@ window.textsecure.MessageSender = function(url, username, password) {
|
|
|
|
var contentMessage = new textsecure.protobuf.Content();
|
|
|
|
var contentMessage = new textsecure.protobuf.Content();
|
|
|
|
contentMessage.syncMessage = syncMessage;
|
|
|
|
contentMessage.syncMessage = syncMessage;
|
|
|
|
|
|
|
|
|
|
|
|
return sendIndividualProto(myNumber, contentMessage, Date.now());
|
|
|
|
return this.sendIndividualProto(myNumber, contentMessage, Date.now());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
},
|
|
|
|
self.sendRequestContactSyncMessage = function() {
|
|
|
|
|
|
|
|
|
|
|
|
sendRequestContactSyncMessage: function() {
|
|
|
|
var myNumber = textsecure.storage.user.getNumber();
|
|
|
|
var myNumber = textsecure.storage.user.getNumber();
|
|
|
|
var myDevice = textsecure.storage.user.getDeviceId();
|
|
|
|
var myDevice = textsecure.storage.user.getDeviceId();
|
|
|
|
if (myDevice != 1) {
|
|
|
|
if (myDevice != 1) {
|
|
|
@ -39830,44 +39827,42 @@ window.textsecure.MessageSender = function(url, username, password) {
|
|
|
|
var contentMessage = new textsecure.protobuf.Content();
|
|
|
|
var contentMessage = new textsecure.protobuf.Content();
|
|
|
|
contentMessage.syncMessage = syncMessage;
|
|
|
|
contentMessage.syncMessage = syncMessage;
|
|
|
|
|
|
|
|
|
|
|
|
return sendIndividualProto(myNumber, contentMessage, Date.now());
|
|
|
|
return this.sendIndividualProto(myNumber, contentMessage, Date.now());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
var sendGroupProto = function(numbers, proto, timestamp) {
|
|
|
|
sendGroupProto: function(numbers, proto, timestamp) {
|
|
|
|
timestamp = timestamp || Date.now();
|
|
|
|
timestamp = timestamp || Date.now();
|
|
|
|
var me = textsecure.storage.user.getNumber();
|
|
|
|
var me = textsecure.storage.user.getNumber();
|
|
|
|
numbers = numbers.filter(function(number) { return number != me; });
|
|
|
|
numbers = numbers.filter(function(number) { return number != me; });
|
|
|
|
|
|
|
|
|
|
|
|
return new Promise(function(resolve, reject) {
|
|
|
|
return new Promise(function(resolve, reject) {
|
|
|
|
sendMessageProto(timestamp, numbers, proto, function(res) {
|
|
|
|
this.sendMessageProto(timestamp, numbers, proto, function(res) {
|
|
|
|
if (res.failure.length > 0)
|
|
|
|
if (res.failure.length > 0)
|
|
|
|
reject(res.failure);
|
|
|
|
reject(res.failure);
|
|
|
|
else
|
|
|
|
else
|
|
|
|
resolve();
|
|
|
|
resolve();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}).then(function() {
|
|
|
|
}.bind(this)).then(this.sendSyncMessage.bind(this, proto, timestamp));
|
|
|
|
return sendSyncMessage(proto, timestamp);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.sendMessageToNumber = function(number, messageText, attachments, timestamp) {
|
|
|
|
sendMessageToNumber: function(number, messageText, attachments, timestamp) {
|
|
|
|
var proto = new textsecure.protobuf.DataMessage();
|
|
|
|
var proto = new textsecure.protobuf.DataMessage();
|
|
|
|
proto.body = messageText;
|
|
|
|
proto.body = messageText;
|
|
|
|
|
|
|
|
|
|
|
|
return Promise.all(attachments.map(makeAttachmentPointer)).then(function(attachmentsArray) {
|
|
|
|
return Promise.all(attachments.map(this.makeAttachmentPointer.bind(this))).then(function(attachmentsArray) {
|
|
|
|
proto.attachments = attachmentsArray;
|
|
|
|
proto.attachments = attachmentsArray;
|
|
|
|
return sendIndividualProto(number, proto, timestamp).then(function() {
|
|
|
|
return this.sendIndividualProto(number, proto, timestamp).then(function() {
|
|
|
|
return sendSyncMessage(proto, timestamp, number);
|
|
|
|
return this.sendSyncMessage(proto, timestamp, number);
|
|
|
|
});
|
|
|
|
}.bind(this));
|
|
|
|
});
|
|
|
|
}.bind(this));
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
self.closeSession = function(number) {
|
|
|
|
closeSession: function(number) {
|
|
|
|
var proto = new textsecure.protobuf.DataMessage();
|
|
|
|
var proto = new textsecure.protobuf.DataMessage();
|
|
|
|
proto.body = "TERMINATE";
|
|
|
|
proto.body = "TERMINATE";
|
|
|
|
proto.flags = textsecure.protobuf.DataMessage.Flags.END_SESSION;
|
|
|
|
proto.flags = textsecure.protobuf.DataMessage.Flags.END_SESSION;
|
|
|
|
return sendIndividualProto(number, proto, Date.now()).then(function(res) {
|
|
|
|
return this.sendIndividualProto(number, proto, Date.now()).then(function(res) {
|
|
|
|
return textsecure.storage.devices.getDeviceObjectsForNumber(number).then(function(devices) {
|
|
|
|
return textsecure.storage.devices.getDeviceObjectsForNumber(number).then(function(devices) {
|
|
|
|
return Promise.all(devices.map(function(device) {
|
|
|
|
return Promise.all(devices.map(function(device) {
|
|
|
|
return textsecure.protocol_wrapper.closeOpenSessionForDevice(device.encodedNumber);
|
|
|
|
return textsecure.protocol_wrapper.closeOpenSessionForDevice(device.encodedNumber);
|
|
|
@ -39876,9 +39871,9 @@ window.textsecure.MessageSender = function(url, username, password) {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
self.sendMessageToGroup = function(groupId, messageText, attachments, timestamp) {
|
|
|
|
sendMessageToGroup: function(groupId, messageText, attachments, timestamp) {
|
|
|
|
var proto = new textsecure.protobuf.DataMessage();
|
|
|
|
var proto = new textsecure.protobuf.DataMessage();
|
|
|
|
proto.body = messageText;
|
|
|
|
proto.body = messageText;
|
|
|
|
proto.group = new textsecure.protobuf.GroupContext();
|
|
|
|
proto.group = new textsecure.protobuf.GroupContext();
|
|
|
@ -39889,14 +39884,14 @@ window.textsecure.MessageSender = function(url, username, password) {
|
|
|
|
if (numbers === undefined)
|
|
|
|
if (numbers === undefined)
|
|
|
|
return Promise.reject(new Error("Unknown Group"));
|
|
|
|
return Promise.reject(new Error("Unknown Group"));
|
|
|
|
|
|
|
|
|
|
|
|
return Promise.all(attachments.map(makeAttachmentPointer)).then(function(attachmentsArray) {
|
|
|
|
return Promise.all(attachments.map(this.makeAttachmentPointer.bind(this))).then(function(attachmentsArray) {
|
|
|
|
proto.attachments = attachmentsArray;
|
|
|
|
proto.attachments = attachmentsArray;
|
|
|
|
return sendGroupProto(numbers, proto, timestamp);
|
|
|
|
return this.sendGroupProto(numbers, proto, timestamp);
|
|
|
|
});
|
|
|
|
}.bind(this));
|
|
|
|
});
|
|
|
|
}.bind(this));
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
self.createGroup = function(numbers, name, avatar) {
|
|
|
|
createGroup: function(numbers, name, avatar) {
|
|
|
|
var proto = new textsecure.protobuf.DataMessage();
|
|
|
|
var proto = new textsecure.protobuf.DataMessage();
|
|
|
|
proto.group = new textsecure.protobuf.GroupContext();
|
|
|
|
proto.group = new textsecure.protobuf.GroupContext();
|
|
|
|
|
|
|
|
|
|
|
@ -39908,16 +39903,16 @@ window.textsecure.MessageSender = function(url, username, password) {
|
|
|
|
proto.group.members = numbers;
|
|
|
|
proto.group.members = numbers;
|
|
|
|
proto.group.name = name;
|
|
|
|
proto.group.name = name;
|
|
|
|
|
|
|
|
|
|
|
|
return makeAttachmentPointer(avatar).then(function(attachment) {
|
|
|
|
return this.makeAttachmentPointer(avatar).then(function(attachment) {
|
|
|
|
proto.group.avatar = attachment;
|
|
|
|
proto.group.avatar = attachment;
|
|
|
|
return sendGroupProto(numbers, proto).then(function() {
|
|
|
|
return this.sendGroupProto(numbers, proto).then(function() {
|
|
|
|
return proto.group.id;
|
|
|
|
return proto.group.id;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}.bind(this));
|
|
|
|
});
|
|
|
|
}.bind(this));
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
self.updateGroup = function(groupId, name, avatar, numbers) {
|
|
|
|
updateGroup: function(groupId, name, avatar, numbers) {
|
|
|
|
var proto = new textsecure.protobuf.DataMessage();
|
|
|
|
var proto = new textsecure.protobuf.DataMessage();
|
|
|
|
proto.group = new textsecure.protobuf.GroupContext();
|
|
|
|
proto.group = new textsecure.protobuf.GroupContext();
|
|
|
|
|
|
|
|
|
|
|
@ -39931,16 +39926,16 @@ window.textsecure.MessageSender = function(url, username, password) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
proto.group.members = numbers;
|
|
|
|
proto.group.members = numbers;
|
|
|
|
|
|
|
|
|
|
|
|
return makeAttachmentPointer(avatar).then(function(attachment) {
|
|
|
|
return this.makeAttachmentPointer(avatar).then(function(attachment) {
|
|
|
|
proto.group.avatar = attachment;
|
|
|
|
proto.group.avatar = attachment;
|
|
|
|
return sendGroupProto(numbers, proto).then(function() {
|
|
|
|
return this.sendGroupProto(numbers, proto).then(function() {
|
|
|
|
return proto.group.id;
|
|
|
|
return proto.group.id;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}.bind(this));
|
|
|
|
});
|
|
|
|
}.bind(this));
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
self.addNumberToGroup = function(groupId, number) {
|
|
|
|
addNumberToGroup: function(groupId, number) {
|
|
|
|
var proto = new textsecure.protobuf.DataMessage();
|
|
|
|
var proto = new textsecure.protobuf.DataMessage();
|
|
|
|
proto.group = new textsecure.protobuf.GroupContext();
|
|
|
|
proto.group = new textsecure.protobuf.GroupContext();
|
|
|
|
proto.group.id = toArrayBuffer(groupId);
|
|
|
|
proto.group.id = toArrayBuffer(groupId);
|
|
|
@ -39951,11 +39946,11 @@ window.textsecure.MessageSender = function(url, username, password) {
|
|
|
|
return Promise.reject(new Error("Unknown Group"));
|
|
|
|
return Promise.reject(new Error("Unknown Group"));
|
|
|
|
proto.group.members = numbers;
|
|
|
|
proto.group.members = numbers;
|
|
|
|
|
|
|
|
|
|
|
|
return sendGroupProto(numbers, proto);
|
|
|
|
return this.sendGroupProto(numbers, proto);
|
|
|
|
});
|
|
|
|
}.bind(this));
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
self.setGroupName = function(groupId, name) {
|
|
|
|
setGroupName: function(groupId, name) {
|
|
|
|
var proto = new textsecure.protobuf.DataMessage();
|
|
|
|
var proto = new textsecure.protobuf.DataMessage();
|
|
|
|
proto.group = new textsecure.protobuf.GroupContext();
|
|
|
|
proto.group = new textsecure.protobuf.GroupContext();
|
|
|
|
proto.group.id = toArrayBuffer(groupId);
|
|
|
|
proto.group.id = toArrayBuffer(groupId);
|
|
|
@ -39967,11 +39962,11 @@ window.textsecure.MessageSender = function(url, username, password) {
|
|
|
|
return Promise.reject(new Error("Unknown Group"));
|
|
|
|
return Promise.reject(new Error("Unknown Group"));
|
|
|
|
proto.group.members = numbers;
|
|
|
|
proto.group.members = numbers;
|
|
|
|
|
|
|
|
|
|
|
|
return sendGroupProto(numbers, proto);
|
|
|
|
return this.sendGroupProto(numbers, proto);
|
|
|
|
});
|
|
|
|
}.bind(this));
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
self.setGroupAvatar = function(groupId, avatar) {
|
|
|
|
setGroupAvatar: function(groupId, avatar) {
|
|
|
|
var proto = new textsecure.protobuf.DataMessage();
|
|
|
|
var proto = new textsecure.protobuf.DataMessage();
|
|
|
|
proto.group = new textsecure.protobuf.GroupContext();
|
|
|
|
proto.group = new textsecure.protobuf.GroupContext();
|
|
|
|
proto.group.id = toArrayBuffer(groupId);
|
|
|
|
proto.group.id = toArrayBuffer(groupId);
|
|
|
@ -39982,14 +39977,14 @@ window.textsecure.MessageSender = function(url, username, password) {
|
|
|
|
return Promise.reject(new Error("Unknown Group"));
|
|
|
|
return Promise.reject(new Error("Unknown Group"));
|
|
|
|
proto.group.members = numbers;
|
|
|
|
proto.group.members = numbers;
|
|
|
|
|
|
|
|
|
|
|
|
return makeAttachmentPointer(avatar).then(function(attachment) {
|
|
|
|
return this.makeAttachmentPointer(avatar).then(function(attachment) {
|
|
|
|
proto.group.avatar = attachment;
|
|
|
|
proto.group.avatar = attachment;
|
|
|
|
return sendGroupProto(numbers, proto);
|
|
|
|
return this.sendGroupProto(numbers, proto);
|
|
|
|
});
|
|
|
|
}.bind(this));
|
|
|
|
});
|
|
|
|
}.bind(this));
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
self.leaveGroup = function(groupId) {
|
|
|
|
leaveGroup: function(groupId) {
|
|
|
|
var proto = new textsecure.protobuf.DataMessage();
|
|
|
|
var proto = new textsecure.protobuf.DataMessage();
|
|
|
|
proto.group = new textsecure.protobuf.GroupContext();
|
|
|
|
proto.group = new textsecure.protobuf.GroupContext();
|
|
|
|
proto.group.id = toArrayBuffer(groupId);
|
|
|
|
proto.group.id = toArrayBuffer(groupId);
|
|
|
@ -39999,13 +39994,33 @@ window.textsecure.MessageSender = function(url, username, password) {
|
|
|
|
if (numbers === undefined)
|
|
|
|
if (numbers === undefined)
|
|
|
|
return Promise.reject(new Error("Unknown Group"));
|
|
|
|
return Promise.reject(new Error("Unknown Group"));
|
|
|
|
return textsecure.storage.groups.deleteGroup(groupId).then(function() {
|
|
|
|
return textsecure.storage.groups.deleteGroup(groupId).then(function() {
|
|
|
|
return sendGroupProto(numbers, proto);
|
|
|
|
return this.sendGroupProto(numbers, proto);
|
|
|
|
});
|
|
|
|
}.bind(this));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
return self;
|
|
|
|
window.textsecure = window.textsecure || {};
|
|
|
|
})(server);
|
|
|
|
|
|
|
|
|
|
|
|
textsecure.MessageSender = function(url, username, password) {
|
|
|
|
|
|
|
|
var sender = new MessageSender(url, username, password);
|
|
|
|
|
|
|
|
textsecure.replay.registerFunction(sender.tryMessageAgain.bind(sender), textsecure.replay.Type.SEND_MESSAGE);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.sendRequestGroupSyncMessage = sender.sendRequestGroupSyncMessage .bind(sender);
|
|
|
|
|
|
|
|
this.sendRequestContactSyncMessage = sender.sendRequestContactSyncMessage.bind(sender);
|
|
|
|
|
|
|
|
this.sendMessageToNumber = sender.sendMessageToNumber .bind(sender);
|
|
|
|
|
|
|
|
this.closeSession = sender.closeSession .bind(sender);
|
|
|
|
|
|
|
|
this.sendMessageToGroup = sender.sendMessageToGroup .bind(sender);
|
|
|
|
|
|
|
|
this.createGroup = sender.createGroup .bind(sender);
|
|
|
|
|
|
|
|
this.updateGroup = sender.updateGroup .bind(sender);
|
|
|
|
|
|
|
|
this.addNumberToGroup = sender.addNumberToGroup .bind(sender);
|
|
|
|
|
|
|
|
this.setGroupName = sender.setGroupName .bind(sender);
|
|
|
|
|
|
|
|
this.setGroupAvatar = sender.setGroupAvatar .bind(sender);
|
|
|
|
|
|
|
|
this.leaveGroup = sender.leaveGroup .bind(sender);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
textsecure.MessageReceiver.prototype = {
|
|
|
|
|
|
|
|
constructor: textsecure.MessageReceiver
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|