parent
48b630d479
commit
b7cf8f36ba
@ -155,6 +155,15 @@ angular.module('myApp.controllers', [])
|
||||
}, function (error) {
|
||||
$scope.progress.enabled = false;
|
||||
switch (error.type) {
|
||||
case 'NETWORK_BAD_REQUEST':
|
||||
if (location.protocol == 'https:') {
|
||||
ErrorService.confirm({type: 'HTTPS_MIXED_FAIL'}).then(function () {
|
||||
location = location.toString().replace('/^https:/', 'http:');
|
||||
});
|
||||
error.handled = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'PHONE_NUMBER_INVALID':
|
||||
$scope.error = {field: 'phone'};
|
||||
error.handled = true;
|
||||
@ -282,7 +291,7 @@ angular.module('myApp.controllers', [])
|
||||
}
|
||||
})
|
||||
|
||||
.controller('AppImDialogsController', function ($scope, $location, MtpApiManager, AppUsersManager, AppChatsManager, AppMessagesManager, AppPeersManager) {
|
||||
.controller('AppImDialogsController', function ($scope, $location, MtpApiManager, AppUsersManager, AppChatsManager, AppMessagesManager, AppPeersManager, ErrorService) {
|
||||
|
||||
// console.log('init controller');
|
||||
|
||||
@ -374,6 +383,15 @@ angular.module('myApp.controllers', [])
|
||||
}
|
||||
|
||||
}, function (error) {
|
||||
if (error.type == 'NETWORK_BAD_REQUEST') {
|
||||
if (location.protocol == 'https:') {
|
||||
ErrorService.confirm({type: 'HTTPS_MIXED_FAIL'}).then(function () {
|
||||
location = location.toString().replace('/^https:/', 'http:');
|
||||
});
|
||||
error.handled = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (error.code == 401) {
|
||||
MtpApiManager.logOut()['finally'](function () {
|
||||
$location.url('/login');
|
||||
|
@ -1196,14 +1196,25 @@ factory('MtpAuthorizer', function (MtpDcConfigurator, MtpRsaKeysManager, MtpSecu
|
||||
transformResponse: function (responseBuffer) {
|
||||
var deserializer = new TLDeserialization(responseBuffer, {mtproto: true});
|
||||
|
||||
var auth_key_id = deserializer.fetchLong('auth_key_id');
|
||||
var msg_id = deserializer.fetchLong('msg_id');
|
||||
var msg_len = deserializer.fetchInt('msg_len');
|
||||
try {
|
||||
|
||||
var auth_key_id = deserializer.fetchLong('auth_key_id');
|
||||
var msg_id = deserializer.fetchLong('msg_id');
|
||||
var msg_len = deserializer.fetchInt('msg_len');
|
||||
|
||||
} catch (e) {
|
||||
return $q.reject({code: 406, type: 'NETWORK_BAD_RESPONSE', problem: e.message, stack: e.stack});
|
||||
}
|
||||
|
||||
rng_seed_time();
|
||||
|
||||
return deserializer;
|
||||
}
|
||||
})['catch'](function (error) {
|
||||
if (!error.message && !error.type) {
|
||||
error = {code: 406, type: 'NETWORK_BAD_REQUEST'};
|
||||
}
|
||||
return $q.reject(error);
|
||||
});
|
||||
};
|
||||
|
||||
@ -2189,6 +2200,11 @@ factory('MtpNetworkerFactory', function (MtpDcConfigurator, MtpMessageIdGenerato
|
||||
return $http.post('http://' + MtpDcConfigurator.chooseServer(self.dcID) + '/apiw1', resultArray, {
|
||||
responseType: 'arraybuffer',
|
||||
transformRequest: null
|
||||
})['catch'](function (error) {
|
||||
if (!error.message && !error.type) {
|
||||
error = {code: 406, type: 'NETWORK_BAD_REQUEST'};
|
||||
}
|
||||
return $q.reject(error);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
@ -9,6 +9,11 @@
|
||||
<span ng-switch-when="WEBOGRAM_UPDATED_RELOAD">A new version of Webogram is available. Load it?</span>
|
||||
<span ng-switch-when="HISTORY_FLUSH">Are you sure? This can not be undone!</span>
|
||||
<span ng-switch-when="TERMINATE_SESSIONS">Are you sure you want to log out all devices except for the current one?</span>
|
||||
<span ng-switch-when="HTTPS_MIXED_FAIL">
|
||||
Your browser does not support mixed content which is neccessary for MTProto support on https. <a href="https://github.com/zhukov/webogram/issues/237" target="_blank">Learn more →</a><br/>
|
||||
Would you like use http-version instead?
|
||||
</span>
|
||||
|
||||
<span ng-switch-when="FILES_CLIPBOARD_PASTE">
|
||||
<ng-pluralize count="files.length"
|
||||
when="{'one': 'Are you sure to send file from clipboard?', 'other': 'Are you sure to send {} files from clipboard?'}">
|
||||
|
@ -10,6 +10,7 @@
|
||||
<span ng-switch-when="401">Unauthorized</span>
|
||||
<span ng-switch-when="403">Access denied</span>
|
||||
<span ng-switch-when="404">Not found</span>
|
||||
<span ng-switch-when="406">Network error</span>
|
||||
<span ng-switch-when="420">Too fast</span>
|
||||
<span ng-switch-default>Server error</span>
|
||||
</span>
|
||||
@ -20,6 +21,12 @@
|
||||
<div class="modal-body">
|
||||
|
||||
<div ng-if="error" class="error_modal_description" ng-switch="error.type">
|
||||
<span ng-switch-when="NETWORK_BAD_REQUEST">
|
||||
Please check your internet connection.
|
||||
</span>
|
||||
<span ng-switch-when="NETWORK_BAD_RESPONSE">
|
||||
Please check your internet connection.
|
||||
</span>
|
||||
<span ng-switch-when="FIRSTNAME_INVALID">
|
||||
The first name you entered is invalid.
|
||||
</span>
|
||||
|
Loading…
x
Reference in New Issue
Block a user