|
|
@ -201,6 +201,10 @@ angular.module('izhukov.mtproto', ['izhukov.utils']) |
|
|
|
responseType: 'arraybuffer', |
|
|
|
responseType: 'arraybuffer', |
|
|
|
transformRequest: null, |
|
|
|
transformRequest: null, |
|
|
|
transformResponse: function (responseBuffer) { |
|
|
|
transformResponse: function (responseBuffer) { |
|
|
|
|
|
|
|
if (!responseBuffer || !responseBuffer.byteLength) { |
|
|
|
|
|
|
|
return $q.reject({code: 406, type: 'NETWORK_BAD_RESPONSE'}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
|
|
|
|
|
|
|
|
|
var deserializer = new TLDeserialization(responseBuffer, {mtproto: true}); |
|
|
|
var deserializer = new TLDeserialization(responseBuffer, {mtproto: true}); |
|
|
@ -216,20 +220,12 @@ angular.module('izhukov.mtproto', ['izhukov.utils']) |
|
|
|
|
|
|
|
|
|
|
|
return deserializer; |
|
|
|
return deserializer; |
|
|
|
} |
|
|
|
} |
|
|
|
}).then( |
|
|
|
})['catch'](function (error) { |
|
|
|
function (result) { |
|
|
|
|
|
|
|
if (!result.data || !result.data.byteLength) { |
|
|
|
|
|
|
|
return $q.reject({code: 406, type: 'NETWORK_BAD_REQUEST'}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return result; |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
function (error) { |
|
|
|
|
|
|
|
if (!error.message && !error.type) { |
|
|
|
if (!error.message && !error.type) { |
|
|
|
error = {code: 406, type: 'NETWORK_BAD_REQUEST'}; |
|
|
|
error = {code: 406, type: 'NETWORK_BAD_REQUEST'}; |
|
|
|
} |
|
|
|
} |
|
|
|
return $q.reject(error); |
|
|
|
return $q.reject(error); |
|
|
|
} |
|
|
|
}); |
|
|
|
); |
|
|
|
|
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
function mtpSendReqPQ (auth) { |
|
|
|
function mtpSendReqPQ (auth) { |
|
|
@ -1130,7 +1126,7 @@ angular.module('izhukov.mtproto', ['izhukov.utils']) |
|
|
|
}).then( |
|
|
|
}).then( |
|
|
|
function (result) { |
|
|
|
function (result) { |
|
|
|
if (!result.data || !result.data.byteLength) { |
|
|
|
if (!result.data || !result.data.byteLength) { |
|
|
|
return $q.reject({code: 406, type: 'NETWORK_BAD_REQUEST'}); |
|
|
|
return $q.reject({code: 406, type: 'NETWORK_BAD_RESPONSE'}); |
|
|
|
} |
|
|
|
} |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
}, |
|
|
|
}, |
|
|
|