sendMessage refactor, initial group stuff (breaks message storage)

This commit is contained in:
Matt Corallo 2014-06-03 12:39:29 -04:00
parent fb2aa6144c
commit d0fd3e94d8
13 changed files with 335 additions and 219 deletions

View file

@ -226,6 +226,40 @@ window.textsecure.api = function() {
});
};
self.putAttachment = function(encryptedBin) {
return doAjax({
call : 'attachment',
httpType : 'GET',
do_auth : true,
}).then(function(response) {
return new Promise(function(resolve, reject) {
$.ajax(response.location, {
type : "PUT",
headers: {
"Content-Type": "application/octet-stream"
},
data: encryptedBin,
success : function() {
resolve(response.id);
},
error : function(jqXHR, textStatus, errorThrown) {
var code = jqXHR.status;
if (code > 999 || code < 100)
code = -1;
var e = new Error(code);
e.name = "HTTPError";
if (jqXHR.responseJSON)
e.response = jqXHR.responseJSON;
reject(e);
}
});
});
});
};
self.getWebsocket = function() {
var user = textsecure.storage.getUnencrypted("number_id");
var password = textsecure.storage.getEncrypted("password");