Browse Source

Upgrade to API layer 16

Supported Telegram verification code transport
master
Igor Zhukov 10 years ago
parent
commit
292cf3cba9
  1. 19
      app/js/controllers.js
  2. 2
      app/js/lib/config.js
  3. 2
      app/js/lib/mtproto.js
  4. 31
      app/js/lib/schema.tl.txt
  5. 12
      app/partials/login.html

19
app/js/controllers.js

@ -159,6 +159,9 @@ angular.module('myApp.controllers', []) @@ -159,6 +159,9 @@ angular.module('myApp.controllers', [])
function callCheck () {
$timeout.cancel(callTimeout);
if ($scope.credentials.viaApp) {
return;
}
if (!(--$scope.callPending.remaining)) {
$scope.callPending.success = false;
MtpApiManager.invokeApi('auth.sendCall', {
@ -183,7 +186,7 @@ angular.module('myApp.controllers', []) @@ -183,7 +186,7 @@ angular.module('myApp.controllers', [])
$scope.progress.enabled = true;
MtpApiManager.invokeApi('auth.sendCode', {
phone_number: $scope.credentials.phone_full,
sms_type: 0,
sms_type: 5,
api_id: Config.App.id,
api_hash: Config.App.hash
}, options).then(function (sentCode) {
@ -191,9 +194,10 @@ angular.module('myApp.controllers', []) @@ -191,9 +194,10 @@ angular.module('myApp.controllers', [])
$scope.credentials.phone_code_hash = sentCode.phone_code_hash;
$scope.credentials.phone_occupied = sentCode.phone_registered;
$scope.credentials.viaApp = sentCode._ == 'auth.sentAppCode';
$scope.callPending.remaining = sentCode.send_call_timeout || 60;
$scope.error = {};
$scope.callPending.remaining = sentCode.send_call_timeout || 60;
callCheck();
}, function (error) {
@ -218,6 +222,16 @@ angular.module('myApp.controllers', []) @@ -218,6 +222,16 @@ angular.module('myApp.controllers', [])
});
}
$scope.sendSms = function () {
if (!$scope.credentials.viaApp) {
return;
}
delete $scope.credentials.viaApp;
MtpApiManager.invokeApi('auth.sendSms', {
phone_number: $scope.credentials.phone_full,
phone_code_hash: $scope.credentials.phone_code_hash
}, options).then(callCheck);
}
$scope.editPhone = function () {
$timeout.cancel(callTimeout);
@ -225,6 +239,7 @@ angular.module('myApp.controllers', []) @@ -225,6 +239,7 @@ angular.module('myApp.controllers', [])
delete $scope.credentials.phone_code_hash;
delete $scope.credentials.phone_unoccupied;
delete $scope.credentials.phone_code_valid;
delete $scope.credentials.viaApp;
delete $scope.callPending.remaining;
delete $scope.callPending.success;
}

2
app/js/lib/config.js

File diff suppressed because one or more lines are too long

2
app/js/lib/mtproto.js

@ -711,7 +711,7 @@ angular.module('izhukov.mtproto', ['izhukov.utils']) @@ -711,7 +711,7 @@ angular.module('izhukov.mtproto', ['izhukov.utils'])
var serializer = new TLSerialization(options);
if (!this.connectionInited) {
serializer.storeInt(0xb4418b64, 'invokeWithLayer15');
serializer.storeInt(0xcf5f0987, 'invokeWithLayer16');
serializer.storeInt(0x69796de9, 'initConnection');
serializer.storeInt(Config.App.id, 'api_id');
serializer.storeString(navigator.userAgent || 'Unknown UserAgent', 'device_model');

31
app/js/lib/schema.tl.txt

@ -328,19 +328,6 @@ inputEncryptedFileLocation#f5235d55 id:long access_hash:long = InputFileLocation @@ -328,19 +328,6 @@ inputEncryptedFileLocation#f5235d55 id:long access_hash:long = InputFileLocation
encryptedMessage#ed18c118 random_id:long chat_id:int date:int bytes:bytes file:EncryptedFile = EncryptedMessage;
encryptedMessageService#23734b06 random_id:long chat_id:int date:int bytes:bytes = EncryptedMessage;
decryptedMessageLayer#99a438cf layer:int message:DecryptedMessage = DecryptedMessageLayer;
decryptedMessage#1f814f1f random_id:long random_bytes:bytes message:string media:DecryptedMessageMedia = DecryptedMessage;
decryptedMessageService#aa48327d random_id:long random_bytes:bytes action:DecryptedMessageAction = DecryptedMessage;
decryptedMessageMediaEmpty#89f5c4a = DecryptedMessageMedia;
decryptedMessageMediaPhoto#32798a8c thumb:bytes thumb_w:int thumb_h:int w:int h:int size:int key:bytes iv:bytes = DecryptedMessageMedia;
decryptedMessageMediaVideo#524a415d thumb:bytes thumb_w:int thumb_h:int duration:int mime_type:string w:int h:int size:int key:bytes iv:bytes = DecryptedMessageMedia;
decryptedMessageMediaGeoPoint#35480a59 lat:double long:double = DecryptedMessageMedia;
decryptedMessageMediaContact#588a0a97 phone_number:string first_name:string last_name:string user_id:int = DecryptedMessageMedia;
decryptedMessageActionSetMessageTTL#a1733aec ttl_seconds:int = DecryptedMessageAction;
messages.dhConfigNotModified#c0e24635 random:bytes = messages.DhConfig;
messages.dhConfig#2c221edd g:int p:bytes version:int random:bytes = messages.DhConfig;
@ -373,9 +360,6 @@ inputDocument#18798952 id:long access_hash:long = InputDocument; @@ -373,9 +360,6 @@ inputDocument#18798952 id:long access_hash:long = InputDocument;
inputAudioFileLocation#74dc404d id:long access_hash:long = InputFileLocation;
inputDocumentFileLocation#4e45abe9 id:long access_hash:long = InputFileLocation;
decryptedMessageMediaDocument#b095434b thumb:bytes thumb_w:int thumb_h:int file_name:string mime_type:string size:int key:bytes iv:bytes = DecryptedMessageMedia;
decryptedMessageMediaAudio#57e0a9cb duration:int mime_type:string size:int key:bytes iv:bytes = DecryptedMessageMedia;
audioEmpty#586988d8 id:long = Audio;
audio#c7ac6496 id:long access_hash:long user_id:int date:int duration:int mime_type:string size:int dc_id:int = Audio;
@ -384,12 +368,6 @@ document#9efc6326 id:long access_hash:long user_id:int date:int file_name:string @@ -384,12 +368,6 @@ document#9efc6326 id:long access_hash:long user_id:int date:int file_name:string
help.support#17c6b5f6 phone_number:string user:User = help.Support;
decryptedMessageActionReadMessages#c4f40be random_ids:Vector<long> = DecryptedMessageAction;
decryptedMessageActionDeleteMessages#65614304 random_ids:Vector<long> = DecryptedMessageAction;
decryptedMessageActionScreenshotMessages#8ac1f475 random_ids:Vector<long> = DecryptedMessageAction;
decryptedMessageActionFlushHistory#6719e45c = DecryptedMessageAction;
decryptedMessageActionNotifyLayer#f3048883 layer:int = DecryptedMessageAction;
notifyPeer#9fd40bd8 peer:Peer = NotifyPeer;
notifyUsers#b4c83b4c = NotifyPeer;
notifyChats#c007cec3 = NotifyPeer;
@ -398,6 +376,8 @@ notifyAll#74d07c60 = NotifyPeer; @@ -398,6 +376,8 @@ notifyAll#74d07c60 = NotifyPeer;
updateUserBlocked#80ece81a user_id:int blocked:Bool = Update;
updateNotifySettings#bec268ef peer:NotifyPeer notify_settings:PeerNotifySettings = Update;
auth.sentAppCode#e325edcf phone_registered:Bool phone_code_hash:string send_call_timeout:int is_password:Bool = auth.SentCode;
---functions---
invokeAfterMsg#cb9f372d msg_id:long query:!X = X;
@ -414,6 +394,7 @@ auth.resetAuthorizations#9fab0d1a = Bool; @@ -414,6 +394,7 @@ auth.resetAuthorizations#9fab0d1a = Bool;
auth.sendInvites#771c1d97 phone_numbers:Vector<string> message:string = Bool;
auth.exportAuthorization#e5bfffcd dc_id:int = auth.ExportedAuthorization;
auth.importAuthorization#e3ef9613 id:int bytes:bytes = auth.Authorization;
auth.bindTempAuthKey#cdd42a05 perm_auth_key_id:long nonce:long expires_at:int encrypted_message:bytes = Bool;
account.registerDevice#446c712c token_type:int token:string device_model:string system_version:string app_version:string app_sandbox:Bool lang_code:string = Bool;
account.unregisterDevice#65c55b40 token_type:int token:string = Bool;
@ -437,6 +418,8 @@ contacts.deleteContacts#59ab389e id:Vector<InputUser> = Bool; @@ -437,6 +418,8 @@ contacts.deleteContacts#59ab389e id:Vector<InputUser> = Bool;
contacts.block#332b49fc id:InputUser = Bool;
contacts.unblock#e54100bd id:InputUser = Bool;
contacts.getBlocked#f57c350f offset:int limit:int = contacts.Blocked;
contacts.exportCard#84e53737 = Vector<int>;
contacts.importCard#4fe196fe export_card:Vector<int> = User;
messages.getMessages#4222fa74 id:Vector<int> = messages.Messages;
messages.getDialogs#eccf1df6 offset:int max_id:int limit:int = messages.Dialogs;
@ -509,4 +492,6 @@ initConnection#69796de9 api_id:int device_model:string system_version:string app @@ -509,4 +492,6 @@ initConnection#69796de9 api_id:int device_model:string system_version:string app
help.getSupport#9cdf08cd = help.Support;
invokeWithLayer14#2b9b08fa query:!X = X;
auth.sendSms#da9f3e8 phone_number:string phone_code_hash:string = Bool;
invokeWithLayer16#cf5f0987 query:!X = X;

12
app/partials/login.html

@ -30,6 +30,16 @@ @@ -30,6 +30,16 @@
<form name="myLoginForm" ng-if="credentials.phone_code_hash &amp;&amp; !credentials.phone_code_valid" ng-submit="logIn()">
<h3 class="login_form_head"><span ng-bind="credentials.phone_country"></span> <span ng-bind="credentials.phone_number"></span></h3>
<div class="login_edit_phone"><a ng-click="editPhone()">Edit phone number</a></div>
<div ng-switch="credentials.viaApp">
<div ng-switch-when="true">
<p class="login_form_lead">
Please enter the code you've just received in your other <strong>Telegram</strong> app
</p>
<p class="login_form_lead">
<a ng-click="sendSms()">Haven't received the code?</a>
</p>
</div>
<div ng-switch-default>
<p class="login_form_lead">We have sent you a code via SMS.<br/>Please enter it below.</p>
<p class="login_form_lead">
@ -37,6 +47,8 @@ @@ -37,6 +47,8 @@
<span ng-show="!callPending.remaining &amp;&amp; !callPending.success">Telegram is calling you</span>
<span ng-show="!callPending.remaining &amp;&amp; callPending.success">Telegram dialed your number</span>
</p>
</div>
</div>
<div class="form-group" ng-class="{'has-error': error.field == 'phone_code'}">
<label class="control-label" for="phone_code" ng-if="error.field == 'phone_code'">Incorrect SMS code</label>

Loading…
Cancel
Save