Fix undefined URL_BASE in background.js
Sieze an opportunity to move code out of the helpers.js. Only 616 more lines to go.
This commit is contained in:
parent
4efb8a2616
commit
ed3aa9667d
2 changed files with 12 additions and 4 deletions
11
js/api.js
11
js/api.js
|
@ -222,5 +222,16 @@ window.textsecure.api = function() {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
self.getWebsocket = function() {
|
||||||
|
var user = storage.getUnencrypted("number_id");
|
||||||
|
var password = storage.getEncrypted("password");
|
||||||
|
var URL = URL_BASE.replace(/^http/g, 'ws') + URL_CALLS['push'] + '/?';
|
||||||
|
var params = $.param({
|
||||||
|
user: '+' + getString(user).substring(1),
|
||||||
|
password: getString(password)
|
||||||
|
});
|
||||||
|
return new WebSocket(URL+params);
|
||||||
|
}
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}();
|
}();
|
||||||
|
|
|
@ -440,10 +440,7 @@ window.textsecure.subscribeToPush = function() {
|
||||||
if (subscribeToPushMessageSemaphore <= 0)
|
if (subscribeToPushMessageSemaphore <= 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var user = storage.getUnencrypted("number_id");
|
var socket = textsecure.api.getWebsocket();
|
||||||
var password = storage.getEncrypted("password");
|
|
||||||
var URL = URL_BASE.replace(/^http:/g, "ws:").replace(/^https:/g, "wss:") + URL_CALLS['push'] + "/?user=%2B" + getString(user).substring(1) + "&password=" + getString(password);
|
|
||||||
var socket = new WebSocket(URL);
|
|
||||||
|
|
||||||
var pingInterval;
|
var pingInterval;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue