|
|
|
@ -10,6 +10,7 @@
|
|
|
|
|
ENCRYPT_MESSAGE: 1,
|
|
|
|
|
INIT_SESSION: 2,
|
|
|
|
|
TRANSMIT_MESSAGE: 3,
|
|
|
|
|
REBUILD_MESSAGE: 4,
|
|
|
|
|
};
|
|
|
|
|
window.textsecure = window.textsecure || {};
|
|
|
|
|
window.textsecure.replay = {
|
|
|
|
@ -88,11 +89,26 @@
|
|
|
|
|
SendMessageNetworkError.prototype = new ReplayableError();
|
|
|
|
|
SendMessageNetworkError.prototype.constructor = SendMessageNetworkError;
|
|
|
|
|
|
|
|
|
|
function MessageError(message, httpError) {
|
|
|
|
|
ReplayableError.call(this, {
|
|
|
|
|
functionCode : Type.REBUILD_MESSAGE,
|
|
|
|
|
args : [message]
|
|
|
|
|
});
|
|
|
|
|
this.name = 'MessageError';
|
|
|
|
|
this.code = httpError.code;
|
|
|
|
|
this.message = httpError.message;
|
|
|
|
|
this.stack = httpError.stack;
|
|
|
|
|
}
|
|
|
|
|
MessageError.prototype = new ReplayableError();
|
|
|
|
|
MessageError.prototype.constructor = MessageError;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
window.textsecure.SendMessageNetworkError = SendMessageNetworkError;
|
|
|
|
|
window.textsecure.IncomingIdentityKeyError = IncomingIdentityKeyError;
|
|
|
|
|
window.textsecure.OutgoingIdentityKeyError = OutgoingIdentityKeyError;
|
|
|
|
|
window.textsecure.ReplayableError = ReplayableError;
|
|
|
|
|
window.textsecure.OutgoingMessageError = OutgoingMessageError;
|
|
|
|
|
window.textsecure.MessageError = MessageError;
|
|
|
|
|
|
|
|
|
|
})();
|
|
|
|
|
|
|
|
|
@ -37432,6 +37448,7 @@ function Message(options) {
|
|
|
|
|
this.timestamp = options.timestamp;
|
|
|
|
|
this.needsSync = options.needsSync;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Message.prototype = {
|
|
|
|
|
constructor: Message,
|
|
|
|
|
toProto: function() {
|
|
|
|
@ -37502,7 +37519,8 @@ MessageSender.prototype = {
|
|
|
|
|
}.bind(this));
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
sendMessage: function(message) {
|
|
|
|
|
sendMessage: function(attrs) {
|
|
|
|
|
var message = new Message(attrs);
|
|
|
|
|
return Promise.all(
|
|
|
|
|
message.attachments.map(this.makeAttachmentPointer.bind(this))
|
|
|
|
|
).then(function(attachmentPointers) {
|
|
|
|
@ -37522,7 +37540,13 @@ MessageSender.prototype = {
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
}.bind(this));
|
|
|
|
|
}.bind(this));
|
|
|
|
|
}.bind(this)).catch(function(error) {
|
|
|
|
|
if (error instanceof Error && error.name === 'HTTPError') {
|
|
|
|
|
throw new textsecure.MessageError(attrs, error);
|
|
|
|
|
} else {
|
|
|
|
|
throw error;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
sendMessageProto: function(timestamp, numbers, message, callback) {
|
|
|
|
|
var outgoing = new OutgoingMessage(this.server, timestamp, numbers, message, callback);
|
|
|
|
@ -37616,15 +37640,13 @@ MessageSender.prototype = {
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
sendMessageToNumber: function(number, messageText, attachments, timestamp) {
|
|
|
|
|
var message = new Message({
|
|
|
|
|
return this.sendMessage({
|
|
|
|
|
recipients : [number],
|
|
|
|
|
body : messageText,
|
|
|
|
|
timestamp : timestamp,
|
|
|
|
|
attachments : attachments,
|
|
|
|
|
needsSync : true
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return this.sendMessage(message);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
closeSession: function(number, timestamp) {
|
|
|
|
@ -37655,7 +37677,7 @@ MessageSender.prototype = {
|
|
|
|
|
return Promise.reject(new Error('No other members in the group'));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var message = new Message({
|
|
|
|
|
return this.sendMessage({
|
|
|
|
|
recipients : numbers,
|
|
|
|
|
body : messageText,
|
|
|
|
|
timestamp : timestamp,
|
|
|
|
@ -37666,7 +37688,6 @@ MessageSender.prototype = {
|
|
|
|
|
type: textsecure.protobuf.GroupContext.Type.DELIVER
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
return this.sendMessage(message);
|
|
|
|
|
}.bind(this));
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
@ -37785,6 +37806,7 @@ textsecure.MessageSender = function(url, username, password, attachment_server_u
|
|
|
|
|
var sender = new MessageSender(url, username, password, attachment_server_url);
|
|
|
|
|
textsecure.replay.registerFunction(sender.tryMessageAgain.bind(sender), textsecure.replay.Type.ENCRYPT_MESSAGE);
|
|
|
|
|
textsecure.replay.registerFunction(sender.retransmitMessage.bind(sender), textsecure.replay.Type.TRANSMIT_MESSAGE);
|
|
|
|
|
textsecure.replay.registerFunction(sender.sendMessage.bind(sender), textsecure.replay.Type.REBUILD_MESSAGE);
|
|
|
|
|
|
|
|
|
|
this.sendRequestGroupSyncMessage = sender.sendRequestGroupSyncMessage .bind(sender);
|
|
|
|
|
this.sendRequestContactSyncMessage = sender.sendRequestContactSyncMessage.bind(sender);
|
|
|
|
|