Supported 26th layer schema

This commit is contained in:
Igor Zhukov 2015-04-06 14:50:38 +03:00
parent 48b9d94289
commit c5a7401e4a
5 changed files with 74 additions and 125 deletions

View File

@ -1524,7 +1524,7 @@ angular.module('myApp.controllers', ['myApp.i18n'])
$scope.$on('user_update', angular.noop); $scope.$on('user_update', angular.noop);
}) })
.controller('AppImSendController', function ($scope, $timeout, MtpApiManager, Storage, AppChatsManager, AppUsersManager, AppPeersManager, AppDocsManager, AppMessagesManager, ApiUpdatesManager, MtpApiFileManager) { .controller('AppImSendController', function ($scope, $timeout, MtpApiManager, Storage, AppChatsManager, AppUsersManager, AppPeersManager, AppDocsManager, AppMessagesManager, MtpApiFileManager) {
$scope.$watch('curDialog.peer', resetDraft); $scope.$watch('curDialog.peer', resetDraft);
$scope.$on('user_update', angular.noop); $scope.$on('user_update', angular.noop);
@ -1695,7 +1695,10 @@ angular.module('myApp.controllers', ['myApp.i18n'])
access_hash: doc.access_hash access_hash: doc.access_hash
} }
} }
AppMessagesManager.sendOther($scope.curDialog.peerID, inputMedia); var options = {
replyToMsgID: $scope.draftMessage.replyToMessage && $scope.draftMessage.replyToMessage.id
};
AppMessagesManager.sendOther($scope.curDialog.peerID, inputMedia, options);
$scope.$broadcast('ui_message_send'); $scope.$broadcast('ui_message_send');
} }
delete $scope.draftMessage.sticker; delete $scope.draftMessage.sticker;
@ -2162,8 +2165,8 @@ angular.module('myApp.controllers', ['myApp.i18n'])
MtpApiManager.invokeApi('messages.editChatPhoto', { MtpApiManager.invokeApi('messages.editChatPhoto', {
chat_id: $scope.chatID, chat_id: $scope.chatID,
photo: {_: 'inputChatPhotoEmpty'} photo: {_: 'inputChatPhotoEmpty'}
}).then(function (updateResult) { }).then(function (updates) {
AppMessagesManager.onStatedMessage(updateResult); ApiUpdatesManager.processUpdateMessage(updates);
$modalInstance.dismiss(); $modalInstance.dismiss();
$rootScope.$broadcast('history_focus', {peerString: AppChatsManager.getChatString($scope.chatID)}); $rootScope.$broadcast('history_focus', {peerString: AppChatsManager.getChatString($scope.chatID)});
})['finally'](function () { })['finally'](function () {
@ -2398,8 +2401,8 @@ angular.module('myApp.controllers', ['myApp.i18n'])
}); });
function onStatedMessage (statedMessage) { function onChatUpdated (updates) {
AppMessagesManager.onStatedMessage(statedMessage); ApiUpdatesManager.processUpdateMessage(updates);
$rootScope.$broadcast('history_focus', {peerString: $scope.chatFull.peerString}); $rootScope.$broadcast('history_focus', {peerString: $scope.chatFull.peerString});
} }
@ -2408,14 +2411,14 @@ angular.module('myApp.controllers', ['myApp.i18n'])
MtpApiManager.invokeApi('messages.deleteChatUser', { MtpApiManager.invokeApi('messages.deleteChatUser', {
chat_id: $scope.chatID, chat_id: $scope.chatID,
user_id: {_: 'inputUserSelf'} user_id: {_: 'inputUserSelf'}
}).then(onStatedMessage); }).then(onChatUpdated);
}; };
$scope.returnToGroup = function () { $scope.returnToGroup = function () {
MtpApiManager.invokeApi('messages.addChatUser', { MtpApiManager.invokeApi('messages.addChatUser', {
chat_id: $scope.chatID, chat_id: $scope.chatID,
user_id: {_: 'inputUserSelf'} user_id: {_: 'inputUserSelf'}
}).then(onStatedMessage); }).then(onChatUpdated);
}; };
@ -2431,19 +2434,8 @@ angular.module('myApp.controllers', ['myApp.i18n'])
chat_id: $scope.chatID, chat_id: $scope.chatID,
user_id: AppUsersManager.getUserInput(userID), user_id: AppUsersManager.getUserInput(userID),
fwd_limit: 100 fwd_limit: 100
}).then(function (addResult) { }).then(function (updates) {
ApiUpdatesManager.processUpdateMessage({ ApiUpdatesManager.processUpdateMessage(updates);
_: 'updates',
users: addResult.users,
chats: addResult.chats,
seq: 0,
updates: [{
_: 'updateNewMessage',
message: addResult.message,
pts: addResult.pts,
pts_count: addResult.pts_count
}]
});
}); });
}); });
@ -2457,7 +2449,7 @@ angular.module('myApp.controllers', ['myApp.i18n'])
MtpApiManager.invokeApi('messages.deleteChatUser', { MtpApiManager.invokeApi('messages.deleteChatUser', {
chat_id: $scope.chatID, chat_id: $scope.chatID,
user_id: {_: 'inputUserForeign', user_id: userID, access_hash: user.access_hash || '0'} user_id: {_: 'inputUserForeign', user_id: userID, access_hash: user.access_hash || '0'}
}).then(onStatedMessage); }).then(onChatUpdated);
}; };
@ -2488,9 +2480,7 @@ angular.module('myApp.controllers', ['myApp.i18n'])
file: inputFile, file: inputFile,
crop: {_: 'inputPhotoCropAuto'} crop: {_: 'inputPhotoCropAuto'}
} }
}).then(function (updateResult) { }).then(onChatUpdated);
onStatedMessage(updateResult);
});
})['finally'](function () { })['finally'](function () {
$scope.photo.updating = false; $scope.photo.updating = false;
}); });
@ -2501,9 +2491,7 @@ angular.module('myApp.controllers', ['myApp.i18n'])
MtpApiManager.invokeApi('messages.editChatPhoto', { MtpApiManager.invokeApi('messages.editChatPhoto', {
chat_id: $scope.chatID, chat_id: $scope.chatID,
photo: {_: 'inputChatPhotoEmpty'} photo: {_: 'inputChatPhotoEmpty'}
}).then(function (updateResult) { }).then(onChatUpdated)['finally'](function () {
onStatedMessage(updateResult);
})['finally'](function () {
$scope.photo.updating = false; $scope.photo.updating = false;
}); });
}; };
@ -3115,19 +3103,8 @@ angular.module('myApp.controllers', ['myApp.i18n'])
return MtpApiManager.invokeApi('messages.editChatTitle', { return MtpApiManager.invokeApi('messages.editChatTitle', {
chat_id: $scope.chatID, chat_id: $scope.chatID,
title: $scope.group.name title: $scope.group.name
}).then(function (editResult) { }).then(function (updates) {
ApiUpdatesManager.processUpdateMessage({ ApiUpdatesManager.processUpdateMessage(updates);
_: 'updates',
users: editResult.users,
chats: editResult.chats,
seq: 0,
updates: [{
_: 'updateNewMessage',
message: editResult.message,
pts: editResult.pts,
pts_count: editResult.pts_count
}]
});
var peerString = AppChatsManager.getChatString($scope.chatID); var peerString = AppChatsManager.getChatString($scope.chatID);
$rootScope.$broadcast('history_focus', {peerString: peerString}); $rootScope.$broadcast('history_focus', {peerString: peerString});

File diff suppressed because one or more lines are too long

View File

@ -501,8 +501,8 @@ messages.deleteHistory#f4f8fb61 peer:InputPeer offset:int = messages.AffectedHis
messages.deleteMessages#a5f18925 id:Vector<int> = messages.AffectedMessages; messages.deleteMessages#a5f18925 id:Vector<int> = messages.AffectedMessages;
messages.receivedMessages#28abcb68 max_id:int = Vector<int>; messages.receivedMessages#28abcb68 max_id:int = Vector<int>;
messages.setTyping#a3825e50 peer:InputPeer action:SendMessageAction = Bool; messages.setTyping#a3825e50 peer:InputPeer action:SendMessageAction = Bool;
messages.sendMessage#1ca852a1 peer:InputPeer reply_to_msg_id:int message:string random_id:long = messages.SentMessage; messages.sendMessage#9add8f26 flags:# peer:InputPeer reply_to_msg_id:flags.0?int message:string random_id:long = messages.SentMessage;
messages.sendMedia#33f6d58c peer:InputPeer reply_to_msg_id:int media:InputMedia random_id:long = Updates; messages.sendMedia#2d7923b1 flags:# peer:InputPeer reply_to_msg_id:flags.0?int media:InputMedia random_id:long = Updates;
messages.forwardMessages#55e1728d peer:InputPeer id:Vector<int> random_id:Vector<long> = Updates; messages.forwardMessages#55e1728d peer:InputPeer id:Vector<int> random_id:Vector<long> = Updates;
messages.getChats#3c6aa187 id:Vector<int> = messages.Chats; messages.getChats#3c6aa187 id:Vector<int> = messages.Chats;
messages.getFullChat#3b831c66 chat_id:int = messages.ChatFull; messages.getFullChat#3b831c66 chat_id:int = messages.ChatFull;
@ -589,6 +589,9 @@ messages.getStickers#ae22e045 emoticon:string hash:string = messages.Stickers;
messages.getAllStickers#aa3bc868 hash:string = messages.AllStickers; messages.getAllStickers#aa3bc868 hash:string = messages.AllStickers;
account.updateDeviceLocked#38df3532 period:int = Bool; account.updateDeviceLocked#38df3532 period:int = Bool;
messages.getWebPagePreview#25223e24 message:string = MessageMedia;
account.getAuthorizations#e320c158 = account.Authorizations; account.getAuthorizations#e320c158 = account.Authorizations;
account.resetAuthorization#df77f3bc hash:long = Bool; account.resetAuthorization#df77f3bc hash:long = Bool;
account.getPassword#548a30f5 = account.Password; account.getPassword#548a30f5 = account.Password;

View File

@ -222,7 +222,17 @@ TLSerialization.prototype.storeMethod = function (methodName, params) {
var self = this; var self = this;
angular.forEach(methodData.params, function (param) { angular.forEach(methodData.params, function (param) {
self.storeObject(params[param.name], param.type, methodName + '[' + param.name + ']'); var type = param.type;
if (type.indexOf('?') !== -1) {
var condType = type.split('?');
var fieldBit = condType[0].split('.');
if (!(params[fieldBit[0]] & (1 << fieldBit[1]))) {
return;
}
type = condType[1];
}
self.storeObject(params[param.name], type, methodName + '[' + param.name + ']');
}); });
return methodData.type; return methodData.type;
@ -230,6 +240,7 @@ TLSerialization.prototype.storeMethod = function (methodName, params) {
TLSerialization.prototype.storeObject = function (obj, type, field) { TLSerialization.prototype.storeObject = function (obj, type, field) {
switch (type) { switch (type) {
case '#':
case 'int': return this.storeInt(obj, field); case 'int': return this.storeInt(obj, field);
case 'long': return this.storeLong(obj, field); case 'long': return this.storeLong(obj, field);
case 'int128': return this.storeIntBytes(obj, 128, field); case 'int128': return this.storeIntBytes(obj, 128, field);
@ -293,7 +304,17 @@ TLSerialization.prototype.storeObject = function (obj, type, field) {
var self = this; var self = this;
angular.forEach(constructorData.params, function (param) { angular.forEach(constructorData.params, function (param) {
self.storeObject(obj[param.name], param.type, field + '[' + predicate + '][' + param.name + ']'); var type = param.type;
if (type.indexOf('?') !== -1) {
var condType = type.split('?');
var fieldBit = condType[0].split('.');
if (!(obj[fieldBit[0]] & (1 << fieldBit[1]))) {
return;
}
type = condType[1];
}
self.storeObject(obj[param.name], type, field + '[' + predicate + '][' + param.name + ']');
}); });
return constructorData.type; return constructorData.type;

View File

@ -1477,7 +1477,12 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
if (pendingAfterMsgs[peerID]) { if (pendingAfterMsgs[peerID]) {
sentRequestOptions.afterMessageID = pendingAfterMsgs[peerID].messageID; sentRequestOptions.afterMessageID = pendingAfterMsgs[peerID].messageID;
} }
var flags = 0;
if (replyToMsgID) {
flags |= 1;
}
MtpApiManager.invokeApi('messages.sendMessage', { MtpApiManager.invokeApi('messages.sendMessage', {
flags: flags,
peer: inputPeer, peer: inputPeer,
message: text, message: text,
random_id: randomID, random_id: randomID,
@ -1638,32 +1643,18 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
{_: 'documentAttributeFilename', file_name: file.name} {_: 'documentAttributeFilename', file_name: file.name}
]}; ]};
} }
var flags = 0;
if (replyToMsgID) {
flags |= 1;
}
MtpApiManager.invokeApi('messages.sendMedia', { MtpApiManager.invokeApi('messages.sendMedia', {
flags: flags,
peer: inputPeer, peer: inputPeer,
media: inputMedia, media: inputMedia,
random_id: randomID, random_id: randomID,
reply_to_msg_id: replyToMsgID reply_to_msg_id: replyToMsgID
}).then(function (statedMessage) { }).then(function (updates) {
message.date = statedMessage.message.date; ApiUpdatesManager.processUpdateMessage(updates);
message.id = statedMessage.message.id;
message.media = statedMessage.message.media;
ApiUpdatesManager.processUpdateMessage({
_: 'updates',
users: statedMessage.users,
chats: statedMessage.chats,
seq: 0,
updates: [{
_: 'updateMessageID',
random_id: randomIDS,
id: statedMessage.message.id
}, {
_: 'updateNewMessage',
message: message,
pts: statedMessage.pts,
pts_count: statedMessage.pts_count
}]
});
}, function (error) { }, function (error) {
if (attachType == 'photo' && if (attachType == 'photo' &&
error.code == 400 && error.code == 400 &&
@ -1710,12 +1701,15 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
pendingByRandomID[randomIDS] = [peerID, messageID]; pendingByRandomID[randomIDS] = [peerID, messageID];
} }
function sendOther(peerID, inputMedia) { function sendOther(peerID, inputMedia, options) {
options = options || {};
var messageID = tempID--, var messageID = tempID--,
randomID = [nextRandomInt(0xFFFFFFFF), nextRandomInt(0xFFFFFFFF)], randomID = [nextRandomInt(0xFFFFFFFF), nextRandomInt(0xFFFFFFFF)],
randomIDS = bigint(randomID[0]).shiftLeft(32).add(bigint(randomID[1])).toString(), randomIDS = bigint(randomID[0]).shiftLeft(32).add(bigint(randomID[1])).toString(),
historyStorage = historiesStorage[peerID], historyStorage = historiesStorage[peerID],
inputPeer = AppPeersManager.getInputPeerByID(peerID); inputPeer = AppPeersManager.getInputPeerByID(peerID),
replyToMsgID = options.replyToMsgID;
if (historyStorage === undefined) { if (historyStorage === undefined) {
historyStorage = historiesStorage[peerID] = {count: null, history: [], pending: []}; historyStorage = historiesStorage[peerID] = {count: null, history: [], pending: []};
@ -1773,32 +1767,18 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
} }
message.send = function () { message.send = function () {
var flags = 0;
if (replyToMsgID) {
flags |= 1;
}
MtpApiManager.invokeApi('messages.sendMedia', { MtpApiManager.invokeApi('messages.sendMedia', {
flags: flags,
peer: inputPeer, peer: inputPeer,
media: inputMedia, media: inputMedia,
random_id: randomID, random_id: randomID,
reply_to_msg_id: 0 reply_to_msg_id: replyToMsgID
}).then(function (statedMessage) { }).then(function (updates) {
message.date = statedMessage.message.date; ApiUpdatesManager.processUpdateMessage(updates);
message.id = statedMessage.message.id;
message.media = statedMessage.message.media;
ApiUpdatesManager.processUpdateMessage({
_: 'updates',
users: statedMessage.users,
chats: statedMessage.chats,
seq: 0,
updates: [{
_: 'updateMessageID',
random_id: randomIDS,
id: statedMessage.message.id
}, {
_: 'updateNewMessage',
message: message,
pts: statedMessage.pts,
pts_count: statedMessage.pts_count
}]
});
}, function (error) { }, function (error) {
toggleError(true); toggleError(true);
}); });
@ -1828,24 +1808,8 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
peer: AppPeersManager.getInputPeerByID(peerID), peer: AppPeersManager.getInputPeerByID(peerID),
id: msgIDs, id: msgIDs,
random_id: randomIDs random_id: randomIDs
}).then(function (statedMessages) { }).then(function (updates) {
var updates = []; ApiUpdatesManager.processUpdateMessage(updates);
angular.forEach(statedMessages.messages, function(apiMessage) {
updates.push({
_: 'updateNewMessage',
message: apiMessage,
pts: statedMessages.pts,
pts_count: statedMessages.pts_count
});
});
ApiUpdatesManager.processUpdateMessage({
_: 'updates',
users: statedMessages.users,
chats: statedMessages.chats,
seq: 0,
updates: updates
});
}); });
}; };
@ -1924,21 +1888,6 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
return false; return false;
} }
function onStatedMessage (statedMessage) {
ApiUpdatesManager.processUpdateMessage({
_: 'updates',
users: statedMessage.users,
chats: statedMessage.chats,
seq: 0,
updates: [{
_: 'updateNewMessage',
message: statedMessage.message,
pts: statedMessage.pts,
pts_count: statedMessage.pts_count
}]
});
}
function getMessagePeer (message) { function getMessagePeer (message) {
var toID = message.to_id && AppPeersManager.getPeerID(message.to_id) || 0; var toID = message.to_id && AppPeersManager.getPeerID(message.to_id) || 0;
@ -2596,7 +2545,6 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
sendFile: sendFile, sendFile: sendFile,
sendOther: sendOther, sendOther: sendOther,
forwardMessages: forwardMessages, forwardMessages: forwardMessages,
onStatedMessage: onStatedMessage,
getMessagePeer: getMessagePeer, getMessagePeer: getMessagePeer,
wrapForDialog: wrapForDialog, wrapForDialog: wrapForDialog,
wrapForHistory: wrapForHistory, wrapForHistory: wrapForHistory,