Update API scheme to layer 152.

This commit is contained in:
John Preston 2023-01-10 17:10:34 +04:00
parent 37cf12f06e
commit 90cb61676a
20 changed files with 187 additions and 112 deletions

View File

@ -196,6 +196,7 @@ messageActionTopicCreate#d999256 flags:# title:string icon_color:int icon_emoji_
messageActionTopicEdit#c0944820 flags:# title:flags.0?string icon_emoji_id:flags.1?long closed:flags.2?Bool hidden:flags.3?Bool = MessageAction; messageActionTopicEdit#c0944820 flags:# title:flags.0?string icon_emoji_id:flags.1?long closed:flags.2?Bool hidden:flags.3?Bool = MessageAction;
messageActionSuggestProfilePhoto#57de635e photo:Photo = MessageAction; messageActionSuggestProfilePhoto#57de635e photo:Photo = MessageAction;
messageActionAttachMenuBotAllowed#e7e75f97 = MessageAction; messageActionAttachMenuBotAllowed#e7e75f97 = MessageAction;
messageActionRequestedPeer#fe77345d button_id:int peer:Peer = MessageAction;
dialog#d58a08c6 flags:# pinned:flags.2?true unread_mark:flags.3?true peer:Peer top_message:int read_inbox_max_id:int read_outbox_max_id:int unread_count:int unread_mentions_count:int unread_reactions_count:int notify_settings:PeerNotifySettings pts:flags.0?int draft:flags.1?DraftMessage folder_id:flags.4?int ttl_period:flags.5?int = Dialog; dialog#d58a08c6 flags:# pinned:flags.2?true unread_mark:flags.3?true peer:Peer top_message:int read_inbox_max_id:int read_outbox_max_id:int unread_count:int unread_mentions_count:int unread_reactions_count:int notify_settings:PeerNotifySettings pts:flags.0?int draft:flags.1?DraftMessage folder_id:flags.4?int ttl_period:flags.5?int = Dialog;
dialogFolder#71bd134c flags:# pinned:flags.2?true folder:Folder peer:Peer top_message:int unread_muted_peers_count:int unread_unmuted_peers_count:int unread_muted_messages_count:int unread_unmuted_messages_count:int = Dialog; dialogFolder#71bd134c flags:# pinned:flags.2?true folder:Folder peer:Peer top_message:int unread_muted_peers_count:int unread_unmuted_peers_count:int unread_muted_messages_count:int unread_unmuted_messages_count:int = Dialog;
@ -214,8 +215,9 @@ geoPointEmpty#1117dd5f = GeoPoint;
geoPoint#b2a2f663 flags:# long:double lat:double access_hash:long accuracy_radius:flags.0?int = GeoPoint; geoPoint#b2a2f663 flags:# long:double lat:double access_hash:long accuracy_radius:flags.0?int = GeoPoint;
auth.sentCode#5e002502 flags:# type:auth.SentCodeType phone_code_hash:string next_type:flags.1?auth.CodeType timeout:flags.2?int = auth.SentCode; auth.sentCode#5e002502 flags:# type:auth.SentCodeType phone_code_hash:string next_type:flags.1?auth.CodeType timeout:flags.2?int = auth.SentCode;
auth.sentCodeSuccess#2390fe44 authorization:auth.Authorization = auth.SentCode;
auth.authorization#33fb7bb8 flags:# setup_password_required:flags.1?true otherwise_relogin_days:flags.1?int tmp_sessions:flags.0?int user:User = auth.Authorization; auth.authorization#2ea2c0d4 flags:# setup_password_required:flags.1?true otherwise_relogin_days:flags.1?int tmp_sessions:flags.0?int future_auth_token:flags.2?bytes user:User = auth.Authorization;
auth.authorizationSignUpRequired#44747e9a flags:# terms_of_service:flags.0?help.TermsOfService = auth.Authorization; auth.authorizationSignUpRequired#44747e9a flags:# terms_of_service:flags.0?help.TermsOfService = auth.Authorization;
auth.exportedAuthorization#b434e2b8 id:long bytes:bytes = auth.ExportedAuthorization; auth.exportedAuthorization#b434e2b8 id:long bytes:bytes = auth.ExportedAuthorization;
@ -622,6 +624,7 @@ inputKeyboardButtonUserProfile#e988037b text:string user_id:InputUser = Keyboard
keyboardButtonUserProfile#308660c1 text:string user_id:long = KeyboardButton; keyboardButtonUserProfile#308660c1 text:string user_id:long = KeyboardButton;
keyboardButtonWebView#13767230 text:string url:string = KeyboardButton; keyboardButtonWebView#13767230 text:string url:string = KeyboardButton;
keyboardButtonSimpleWebView#a0c0505c text:string url:string = KeyboardButton; keyboardButtonSimpleWebView#a0c0505c text:string url:string = KeyboardButton;
keyboardButtonRequestPeer#d0b468c text:string button_id:int peer_type:RequestPeerType = KeyboardButton;
keyboardButtonRow#77608b83 buttons:Vector<KeyboardButton> = KeyboardButtonRow; keyboardButtonRow#77608b83 buttons:Vector<KeyboardButton> = KeyboardButtonRow;
@ -736,6 +739,7 @@ auth.sentCodeTypeMissedCall#82006484 prefix:string length:int = auth.SentCodeTyp
auth.sentCodeTypeEmailCode#5a159841 flags:# apple_signin_allowed:flags.0?true google_signin_allowed:flags.1?true email_pattern:string length:int next_phone_login_date:flags.2?int = auth.SentCodeType; auth.sentCodeTypeEmailCode#5a159841 flags:# apple_signin_allowed:flags.0?true google_signin_allowed:flags.1?true email_pattern:string length:int next_phone_login_date:flags.2?int = auth.SentCodeType;
auth.sentCodeTypeSetUpEmailRequired#a5491dea flags:# apple_signin_allowed:flags.0?true google_signin_allowed:flags.1?true = auth.SentCodeType; auth.sentCodeTypeSetUpEmailRequired#a5491dea flags:# apple_signin_allowed:flags.0?true google_signin_allowed:flags.1?true = auth.SentCodeType;
auth.sentCodeTypeFragmentSms#d9565c39 url:string length:int = auth.SentCodeType; auth.sentCodeTypeFragmentSms#d9565c39 url:string length:int = auth.SentCodeType;
auth.sentCodeTypeFirebaseSms#e57b1432 flags:# nonce:flags.0?bytes receipt:flags.1?string push_timeout:flags.1?int length:int = auth.SentCodeType;
messages.botCallbackAnswer#36585ea4 flags:# alert:flags.1?true has_url:flags.3?true native_ui:flags.4?true message:flags.0?string url:flags.2?string cache_time:int = messages.BotCallbackAnswer; messages.botCallbackAnswer#36585ea4 flags:# alert:flags.1?true has_url:flags.3?true native_ui:flags.4?true message:flags.0?string url:flags.2?string cache_time:int = messages.BotCallbackAnswer;
@ -1136,7 +1140,7 @@ statsURL#47a971e0 url:string = StatsURL;
chatAdminRights#5fb224d5 flags:# change_info:flags.0?true post_messages:flags.1?true edit_messages:flags.2?true delete_messages:flags.3?true ban_users:flags.4?true invite_users:flags.5?true pin_messages:flags.7?true add_admins:flags.9?true anonymous:flags.10?true manage_call:flags.11?true other:flags.12?true manage_topics:flags.13?true = ChatAdminRights; chatAdminRights#5fb224d5 flags:# change_info:flags.0?true post_messages:flags.1?true edit_messages:flags.2?true delete_messages:flags.3?true ban_users:flags.4?true invite_users:flags.5?true pin_messages:flags.7?true add_admins:flags.9?true anonymous:flags.10?true manage_call:flags.11?true other:flags.12?true manage_topics:flags.13?true = ChatAdminRights;
chatBannedRights#9f120418 flags:# view_messages:flags.0?true send_messages:flags.1?true send_media:flags.2?true send_stickers:flags.3?true send_gifs:flags.4?true send_games:flags.5?true send_inline:flags.6?true embed_links:flags.7?true send_polls:flags.8?true change_info:flags.10?true invite_users:flags.15?true pin_messages:flags.17?true manage_topics:flags.18?true until_date:int = ChatBannedRights; chatBannedRights#9f120418 flags:# view_messages:flags.0?true send_messages:flags.1?true send_media:flags.2?true send_stickers:flags.3?true send_gifs:flags.4?true send_games:flags.5?true send_inline:flags.6?true embed_links:flags.7?true send_polls:flags.8?true change_info:flags.10?true invite_users:flags.15?true pin_messages:flags.17?true manage_topics:flags.18?true send_photos:flags.19?true send_videos:flags.20?true send_roundvideos:flags.21?true send_audios:flags.22?true send_voices:flags.23?true send_docs:flags.24?true send_plain:flags.25?true until_date:int = ChatBannedRights;
inputWallPaper#e630b979 id:long access_hash:long = InputWallPaper; inputWallPaper#e630b979 id:long access_hash:long = InputWallPaper;
inputWallPaperSlug#72091c80 slug:string = InputWallPaper; inputWallPaperSlug#72091c80 slug:string = InputWallPaper;
@ -1145,7 +1149,7 @@ inputWallPaperNoFile#967a462e id:long = InputWallPaper;
account.wallPapersNotModified#1c199183 = account.WallPapers; account.wallPapersNotModified#1c199183 = account.WallPapers;
account.wallPapers#cdc3858c hash:long wallpapers:Vector<WallPaper> = account.WallPapers; account.wallPapers#cdc3858c hash:long wallpapers:Vector<WallPaper> = account.WallPapers;
codeSettings#8a6469c2 flags:# allow_flashcall:flags.0?true current_number:flags.1?true allow_app_hash:flags.4?true allow_missed_call:flags.5?true logout_tokens:flags.6?Vector<bytes> = CodeSettings; codeSettings#ad253d78 flags:# allow_flashcall:flags.0?true current_number:flags.1?true allow_app_hash:flags.4?true allow_missed_call:flags.5?true allow_firebase:flags.7?true logout_tokens:flags.6?Vector<bytes> token:flags.8?string app_sandbox:flags.8?Bool = CodeSettings;
wallPaperSettings#1dc1bca4 flags:# blur:flags.1?true motion:flags.2?true background_color:flags.0?int second_background_color:flags.4?int third_background_color:flags.5?int fourth_background_color:flags.6?int intensity:flags.3?int rotation:flags.4?int = WallPaperSettings; wallPaperSettings#1dc1bca4 flags:# blur:flags.1?true motion:flags.2?true background_color:flags.0?int second_background_color:flags.4?int third_background_color:flags.5?int fourth_background_color:flags.6?int intensity:flags.3?int rotation:flags.4?int = WallPaperSettings;
@ -1481,6 +1485,13 @@ defaultHistoryTTL#43b46b20 period:int = DefaultHistoryTTL;
exportedContactToken#41bf109b url:string expires:int = ExportedContactToken; exportedContactToken#41bf109b url:string expires:int = ExportedContactToken;
requestPeerTypeUser#5f3b8a00 flags:# bot:flags.0?Bool premium:flags.1?Bool = RequestPeerType;
requestPeerTypeChat#c9f06e1b flags:# creator:flags.0?true bot_participant:flags.5?true has_username:flags.3?Bool forum:flags.4?Bool user_admin_rights:flags.1?ChatAdminRights bot_admin_rights:flags.2?ChatAdminRights = RequestPeerType;
requestPeerTypeBroadcast#339bef6c flags:# creator:flags.0?true has_username:flags.3?Bool user_admin_rights:flags.1?ChatAdminRights bot_admin_rights:flags.2?ChatAdminRights = RequestPeerType;
emojiListNotModified#481eadfa = EmojiList;
emojiList#7a1e11d1 hash:long document_id:Vector<long> = EmojiList;
---functions--- ---functions---
invokeAfterMsg#cb9f372d {X:Type} msg_id:long query:!X = X; invokeAfterMsg#cb9f372d {X:Type} msg_id:long query:!X = X;
@ -1511,6 +1522,7 @@ auth.importLoginToken#95ac5ce4 token:bytes = auth.LoginToken;
auth.acceptLoginToken#e894ad4d token:bytes = Authorization; auth.acceptLoginToken#e894ad4d token:bytes = Authorization;
auth.checkRecoveryPassword#d36bf79 code:string = Bool; auth.checkRecoveryPassword#d36bf79 code:string = Bool;
auth.importWebTokenAuthorization#2db873a9 api_id:int api_hash:string web_auth_token:string = auth.Authorization; auth.importWebTokenAuthorization#2db873a9 api_id:int api_hash:string web_auth_token:string = auth.Authorization;
auth.requestFirebaseSms#89464b50 flags:# phone_number:string phone_code_hash:string safety_net_token:flags.0?string ios_push_secret:flags.1?string = Bool;
account.registerDevice#ec86017a flags:# no_muted:flags.0?true token_type:int token:string app_sandbox:Bool secret:bytes other_uids:Vector<long> = Bool; account.registerDevice#ec86017a flags:# no_muted:flags.0?true token_type:int token:string app_sandbox:Bool secret:bytes other_uids:Vector<long> = Bool;
account.unregisterDevice#6a0d3206 token_type:int token:string other_uids:Vector<long> = Bool; account.unregisterDevice#6a0d3206 token_type:int token:string other_uids:Vector<long> = Bool;
@ -1594,6 +1606,8 @@ account.getRecentEmojiStatuses#f578105 hash:long = account.EmojiStatuses;
account.clearRecentEmojiStatuses#18201aae = Bool; account.clearRecentEmojiStatuses#18201aae = Bool;
account.reorderUsernames#ef500eab order:Vector<string> = Bool; account.reorderUsernames#ef500eab order:Vector<string> = Bool;
account.toggleUsername#58d6b376 username:string active:Bool = Bool; account.toggleUsername#58d6b376 username:string active:Bool = Bool;
account.getDefaultProfilePhotoEmojis#e2750328 hash:long = EmojiList;
account.getDefaultGroupPhotoEmojis#915860ae hash:long = EmojiList;
users.getUsers#d91a548 id:Vector<InputUser> = Vector<User>; users.getUsers#d91a548 id:Vector<InputUser> = Vector<User>;
users.getFullUser#b60f5918 id:InputUser = users.UserFull; users.getFullUser#b60f5918 id:InputUser = users.UserFull;
@ -1802,6 +1816,7 @@ messages.clearRecentReactions#9dfeefb4 = Bool;
messages.getExtendedMedia#84f80814 peer:InputPeer id:Vector<int> = Updates; messages.getExtendedMedia#84f80814 peer:InputPeer id:Vector<int> = Updates;
messages.setDefaultHistoryTTL#9eb51445 period:int = Bool; messages.setDefaultHistoryTTL#9eb51445 period:int = Bool;
messages.getDefaultHistoryTTL#658b7188 = DefaultHistoryTTL; messages.getDefaultHistoryTTL#658b7188 = DefaultHistoryTTL;
messages.sendBotRequestedPeer#fe38d01b peer:InputPeer msg_id:int button_id:int requested_peer:InputPeer = Updates;
updates.getState#edd4882a = updates.State; updates.getState#edd4882a = updates.State;
updates.getDifference#25939651 flags:# pts:int pts_total_limit:flags.0?int date:int qts:int = updates.Difference; updates.getDifference#25939651 flags:# pts:int pts_total_limit:flags.0?int date:int qts:int = updates.Difference;
@ -1854,7 +1869,7 @@ channels.getParticipants#77ced9d0 channel:InputChannel filter:ChannelParticipant
channels.getParticipant#a0ab6cc6 channel:InputChannel participant:InputPeer = channels.ChannelParticipant; channels.getParticipant#a0ab6cc6 channel:InputChannel participant:InputPeer = channels.ChannelParticipant;
channels.getChannels#a7f6bbb id:Vector<InputChannel> = messages.Chats; channels.getChannels#a7f6bbb id:Vector<InputChannel> = messages.Chats;
channels.getFullChannel#8736a09 channel:InputChannel = messages.ChatFull; channels.getFullChannel#8736a09 channel:InputChannel = messages.ChatFull;
channels.createChannel#91006707 flags:# broadcast:flags.0?true megagroup:flags.1?true for_import:flags.3?true title:string about:string geo_point:flags.2?InputGeoPoint address:flags.2?string ttl_period:flags.4?int = Updates; channels.createChannel#91006707 flags:# broadcast:flags.0?true megagroup:flags.1?true for_import:flags.3?true forum:flags.5?true title:string about:string geo_point:flags.2?InputGeoPoint address:flags.2?string ttl_period:flags.4?int = Updates;
channels.editAdmin#d33c8902 channel:InputChannel user_id:InputUser admin_rights:ChatAdminRights rank:string = Updates; channels.editAdmin#d33c8902 channel:InputChannel user_id:InputUser admin_rights:ChatAdminRights rank:string = Updates;
channels.editTitle#566decd0 channel:InputChannel title:string = Updates; channels.editTitle#566decd0 channel:InputChannel title:string = Updates;
channels.editPhoto#f12e57c9 channel:InputChannel photo:InputChatPhoto = Updates; channels.editPhoto#f12e57c9 channel:InputChannel photo:InputChatPhoto = Updates;
@ -1979,4 +1994,4 @@ stats.getMegagroupStats#dcdf8607 flags:# dark:flags.0?true channel:InputChannel
stats.getMessagePublicForwards#5630281b channel:InputChannel msg_id:int offset_rate:int offset_peer:InputPeer offset_id:int limit:int = messages.Messages; stats.getMessagePublicForwards#5630281b channel:InputChannel msg_id:int offset_rate:int offset_peer:InputPeer offset_id:int limit:int = messages.Messages;
stats.getMessageStats#b6e0a3f5 flags:# dark:flags.0?true channel:InputChannel msg_id:int = stats.MessageStats; stats.getMessageStats#b6e0a3f5 flags:# dark:flags.0?true channel:InputChannel msg_id:int = stats.MessageStats;
// LAYER 151 // LAYER 152

View File

@ -404,6 +404,10 @@ void ActivateBotCommand(ClickHandlerContext context, int row, int column) {
disabled); disabled);
} break; } break;
case ButtonType::RequestPeer: { // #TODO request_peer
HideSingleUseKeyboard(controller, item);
} break;
case ButtonType::SwitchInlineSame: case ButtonType::SwitchInlineSame:
case ButtonType::SwitchInline: { case ButtonType::SwitchInline: {
if (const auto bot = item->getMessageBot()) { if (const auto bot = item->getMessageBot()) {

View File

@ -31,7 +31,11 @@ void ConfirmPhone::resolve(
} }
_sendRequestId = _api.request(MTPaccount_SendConfirmPhoneCode( _sendRequestId = _api.request(MTPaccount_SendConfirmPhoneCode(
MTP_string(hash), MTP_string(hash),
MTP_codeSettings(MTP_flags(0), MTP_vector<MTPbytes>()) MTP_codeSettings(
MTP_flags(0),
MTPVector<MTPbytes>(),
MTPstring(),
MTPBool())
)).done([=](const MTPauth_SentCode &result) { )).done([=](const MTPauth_SentCode &result) {
_sendRequestId = 0; _sendRequestId = 0;
@ -54,6 +58,8 @@ void ConfirmPhone::resolve(
return bad("FlashCall"); return bad("FlashCall");
}, [&](const MTPDauth_sentCodeTypeMissedCall &) { }, [&](const MTPDauth_sentCodeTypeMissedCall &) {
return bad("MissedCall"); return bad("MissedCall");
}, [&](const MTPDauth_sentCodeTypeFirebaseSms &) {
return bad("FirebaseSms");
}, [&](const MTPDauth_sentCodeTypeEmailCode &) { }, [&](const MTPDauth_sentCodeTypeEmailCode &) {
return bad("EmailCode"); return bad("EmailCode");
}, [&](const MTPDauth_sentCodeTypeSetUpEmailRequired &) { }, [&](const MTPDauth_sentCodeTypeSetUpEmailRequired &) {
@ -89,7 +95,7 @@ void ConfirmPhone::resolve(
_api.request(MTPauth_ResendCode( _api.request(MTPauth_ResendCode(
MTP_string(phone), MTP_string(phone),
MTP_string(phoneHash) MTP_string(phoneHash)
)).done([=](const MTPauth_SentCode &result) { )).done([=] {
if (boxWeak) { if (boxWeak) {
boxWeak->callDone(); boxWeak->callDone();
} }
@ -135,6 +141,9 @@ void ConfirmPhone::resolve(
}, box->lifetime()); }, box->lifetime());
controller->show(std::move(box), Ui::LayerOption::CloseOther); controller->show(std::move(box), Ui::LayerOption::CloseOther);
}, [](const MTPDauth_sentCodeSuccess &) {
LOG(("API Error: Unexpected auth.sentCodeSuccess "
"(Api::ConfirmPhone)."));
}); });
}).fail([=](const MTP::Error &error) { }).fail([=](const MTP::Error &error) {
_sendRequestId = 0; _sendRequestId = 0;

View File

@ -204,7 +204,11 @@ void ChangePhone::EnterPhone::submit() {
const auto phoneNumber = _phone->getLastText().trimmed(); const auto phoneNumber = _phone->getLastText().trimmed();
_requestId = _api.request(MTPaccount_SendChangePhoneCode( _requestId = _api.request(MTPaccount_SendChangePhoneCode(
MTP_string(phoneNumber), MTP_string(phoneNumber),
MTP_codeSettings(MTP_flags(0), MTP_vector<MTPbytes>()) MTP_codeSettings(
MTP_flags(0),
MTPVector<MTPbytes>(),
MTPstring(),
MTPBool())
)).done([=](const MTPauth_SentCode &result) { )).done([=](const MTPauth_SentCode &result) {
_requestId = 0; _requestId = 0;
sendPhoneDone(result, phoneNumber); sendPhoneDone(result, phoneNumber);
@ -217,10 +221,17 @@ void ChangePhone::EnterPhone::submit() {
void ChangePhone::EnterPhone::sendPhoneDone( void ChangePhone::EnterPhone::sendPhoneDone(
const MTPauth_SentCode &result, const MTPauth_SentCode &result,
const QString &phoneNumber) { const QString &phoneNumber) {
using CodeData = const MTPDauth_sentCode&; const auto data = result.match([](const MTPDauth_sentCode &data) {
const auto &data = result.match([](const auto &data) -> CodeData { return &data;
return data; }, [](const MTPDauth_sentCodeSuccess &) -> const MTPDauth_sentCode* {
LOG(("API Error: Unexpected auth.sentCodeSuccess "
"(ChangePhone::EnterPhone)."));
return nullptr;
}); });
if (!data) {
showError(Lang::Hard::ServerError());
return;
}
const auto bad = [&](const char *type) { const auto bad = [&](const char *type) {
LOG(("API Error: Should not be '%1'.").arg(type)); LOG(("API Error: Should not be '%1'.").arg(type));
@ -229,7 +240,7 @@ void ChangePhone::EnterPhone::sendPhoneDone(
}; };
auto codeLength = 0; auto codeLength = 0;
auto codeByFragmentUrl = QString(); auto codeByFragmentUrl = QString();
const auto hasLength = data.vtype().match([&]( const auto hasLength = data->vtype().match([&](
const MTPDauth_sentCodeTypeApp &typeData) { const MTPDauth_sentCodeTypeApp &typeData) {
LOG(("Error: should not be in-app code!")); LOG(("Error: should not be in-app code!"));
showError(Lang::Hard::ServerError()); showError(Lang::Hard::ServerError());
@ -248,6 +259,8 @@ void ChangePhone::EnterPhone::sendPhoneDone(
return bad("FlashCall"); return bad("FlashCall");
}, [&](const MTPDauth_sentCodeTypeMissedCall &) { }, [&](const MTPDauth_sentCodeTypeMissedCall &) {
return bad("MissedCall"); return bad("MissedCall");
}, [&](const MTPDauth_sentCodeTypeFirebaseSms &) {
return bad("FirebaseSms");
}, [&](const MTPDauth_sentCodeTypeEmailCode &) { }, [&](const MTPDauth_sentCodeTypeEmailCode &) {
return bad("EmailCode"); return bad("EmailCode");
}, [&](const MTPDauth_sentCodeTypeSetUpEmailRequired &) { }, [&](const MTPDauth_sentCodeTypeSetUpEmailRequired &) {
@ -256,11 +269,11 @@ void ChangePhone::EnterPhone::sendPhoneDone(
if (!hasLength) { if (!hasLength) {
return; return;
} }
const auto phoneCodeHash = qs(data.vphone_code_hash()); const auto phoneCodeHash = qs(data->vphone_code_hash());
const auto callTimeout = [&] { const auto callTimeout = [&] {
if (const auto nextType = data.vnext_type()) { if (const auto nextType = data->vnext_type()) {
return nextType->match([&](const MTPDauth_sentCodeTypeCall &) { return nextType->match([&](const MTPDauth_sentCodeTypeCall &) {
return data.vtimeout().value_or(60); return data->vtimeout().value_or(60);
}, [](const auto &) { }, [](const auto &) {
return 0; return 0;
}); });
@ -434,7 +447,7 @@ void ChangePhone::EnterCode::sendCall() {
_api.request(MTPauth_ResendCode( _api.request(MTPauth_ResendCode(
MTP_string(_phone), MTP_string(_phone),
MTP_string(_hash) MTP_string(_hash)
)).done([=](const MTPauth_SentCode &result) { )).done([=] {
_call.callDone(); _call.callDone();
}).send(); }).send();
} }

View File

@ -1175,6 +1175,11 @@ ServiceAction ParseServiceAction(
result.content = content; result.content = content;
}, [&](const MTPDmessageActionAttachMenuBotAllowed &data) { }, [&](const MTPDmessageActionAttachMenuBotAllowed &data) {
result.content = ActionAttachMenuBotAllowed(); result.content = ActionAttachMenuBotAllowed();
}, [&](const MTPDmessageActionRequestedPeer &data) {
auto content = ActionRequestedPeer();
content.peerId = ParsePeerId(data.vpeer());
content.buttonId = data.vbutton_id().v;
result.content = content;
}, [](const MTPDmessageActionEmpty &data) {}); }, [](const MTPDmessageActionEmpty &data) {});
return result; return result;
} }

View File

@ -515,6 +515,11 @@ struct ActionSuggestProfilePhoto {
struct ActionAttachMenuBotAllowed { struct ActionAttachMenuBotAllowed {
}; };
struct ActionRequestedPeer {
PeerId peerId = 0;
int buttonId = 0;
};
struct ServiceAction { struct ServiceAction {
std::variant< std::variant<
v::null_t, v::null_t,
@ -551,7 +556,8 @@ struct ServiceAction {
ActionTopicCreate, ActionTopicCreate,
ActionTopicEdit, ActionTopicEdit,
ActionSuggestProfilePhoto, ActionSuggestProfilePhoto,
ActionAttachMenuBotAllowed> content; ActionAttachMenuBotAllowed,
ActionRequestedPeer> content;
}; };
ServiceAction ParseServiceAction( ServiceAction ParseServiceAction(

View File

@ -1168,6 +1168,8 @@ auto HtmlWriter::Wrap::pushMessage(
}, [&](const ActionAttachMenuBotAllowed &data) { }, [&](const ActionAttachMenuBotAllowed &data) {
return "You allowed this bot to message you " return "You allowed this bot to message you "
"when you added it in the attachment menu."_q; "when you added it in the attachment menu."_q;
}, [&](const ActionRequestedPeer &data) {
return "requested: "_q/* + data.peerId*/;
}, [](v::null_t) { return QByteArray(); }); }, [](v::null_t) { return QByteArray(); });
if (!serviceText.isEmpty()) { if (!serviceText.isEmpty()) {

View File

@ -580,6 +580,11 @@ QByteArray SerializeMessage(
}, [&](const ActionAttachMenuBotAllowed &data) { }, [&](const ActionAttachMenuBotAllowed &data) {
pushActor(); pushActor();
pushAction("attach_menu_bot_allowed"); pushAction("attach_menu_bot_allowed");
}, [&](const ActionRequestedPeer &data) {
pushActor();
pushAction("requested_peer");
push("button_id", data.buttonId);
push("peer_id", data.peerId.value);
}, [](v::null_t) {}); }, [](v::null_t) {});
if (v::is_null(message.action.content)) { if (v::is_null(message.action.content)) {

View File

@ -3947,6 +3947,11 @@ void HistoryItem::setServiceMessageByAction(const MTPmessageAction &action) {
} }; } };
}; };
auto prepareRequestedPeer = [](
const MTPDmessageActionRequestedPeer &action) {
return PreparedServiceText{ { } };
};
setServiceText(action.match([&]( setServiceText(action.match([&](
const MTPDmessageActionChatAddUser &data) { const MTPDmessageActionChatAddUser &data) {
return prepareChatAddUserText(data); return prepareChatAddUserText(data);
@ -4023,6 +4028,8 @@ void HistoryItem::setServiceMessageByAction(const MTPmessageAction &action) {
return prepareSuggestProfilePhoto(data); return prepareSuggestProfilePhoto(data);
}, [&](const MTPDmessageActionAttachMenuBotAllowed &data) { }, [&](const MTPDmessageActionAttachMenuBotAllowed &data) {
return prepareAttachMenuBotAllowed(data); return prepareAttachMenuBotAllowed(data);
}, [&](const MTPDmessageActionRequestedPeer &data) {
return prepareRequestedPeer(data);
}, [](const MTPDmessageActionEmpty &) { }, [](const MTPDmessageActionEmpty &) {
return PreparedServiceText{ { tr::lng_message_empty(tr::now) } }; return PreparedServiceText{ { tr::lng_message_empty(tr::now) } };
})); }));

View File

@ -69,6 +69,13 @@ void HistoryMessageMarkupData::fillRows(
row.emplace_back(Type::RequestLocation, qs(data.vtext())); row.emplace_back(Type::RequestLocation, qs(data.vtext()));
}, [&](const MTPDkeyboardButtonRequestPhone &data) { }, [&](const MTPDkeyboardButtonRequestPhone &data) {
row.emplace_back(Type::RequestPhone, qs(data.vtext())); row.emplace_back(Type::RequestPhone, qs(data.vtext()));
}, [&](const MTPDkeyboardButtonRequestPeer &data) {
row.emplace_back(
Type::RequestPeer,
qs(data.vtext()),
QByteArray(), // #TODO request_peer
QString(),
int64(data.vbutton_id().v));
}, [&](const MTPDkeyboardButtonUrl &data) { }, [&](const MTPDkeyboardButtonUrl &data) {
row.emplace_back( row.emplace_back(
Type::Url, Type::Url,

View File

@ -37,6 +37,7 @@ struct HistoryMessageMarkupButton {
RequestPhone, RequestPhone,
RequestLocation, RequestLocation,
RequestPoll, RequestPoll,
RequestPeer,
SwitchInline, SwitchInline,
SwitchInlineSame, SwitchInlineSame,
Game, Game,

View File

@ -266,25 +266,7 @@ void CodeWidget::checkRequest() {
void CodeWidget::codeSubmitDone(const MTPauth_Authorization &result) { void CodeWidget::codeSubmitDone(const MTPauth_Authorization &result) {
stopCheck(); stopCheck();
_sentRequest = 0; _sentRequest = 0;
result.match([&](const MTPDauth_authorization &data) { finish(result);
if (data.vuser().type() != mtpc_user
|| !data.vuser().c_user().is_self()) {
showError(rpl::single(Lang::Hard::ServerError()));
return;
}
finish(data.vuser());
}, [&](const MTPDauth_authorizationSignUpRequired &data) {
if (const auto terms = data.vterms_of_service()) {
terms->match([&](const MTPDhelp_termsOfService &data) {
getData()->termsLock = Window::TermsLock::FromMTP(
nullptr,
data);
});
} else {
getData()->termsLock = Window::TermsLock();
}
goReplace<SignupWidget>(Animate::Forward);
});
} }
void CodeWidget::codeSubmitFail(const MTP::Error &error) { void CodeWidget::codeSubmitFail(const MTP::Error &error) {
@ -343,17 +325,19 @@ void CodeWidget::sendCall() {
} }
} }
void CodeWidget::callDone(const MTPauth_SentCode &v) { void CodeWidget::callDone(const MTPauth_SentCode &result) {
if (v.type() == mtpc_auth_sentCode) { result.match([&](const MTPDauth_sentCode &data) {
fillSentCodeData(v.c_auth_sentCode()); fillSentCodeData(data);
_code->setDigitsCountMax(getData()->codeLength); _code->setDigitsCountMax(getData()->codeLength);
}
if (_callStatus == CallStatus::Calling) { if (_callStatus == CallStatus::Calling) {
_callStatus = CallStatus::Called; _callStatus = CallStatus::Called;
getData()->callStatus = _callStatus; getData()->callStatus = _callStatus;
getData()->callTimeout = _callTimeout; getData()->callTimeout = _callTimeout;
updateCallText(); updateCallText();
} }
}, [&](const MTPDauth_sentCodeSuccess &data) {
finish(data.vauthorization());
});
} }
void CodeWidget::gotPassword(const MTPaccount_Password &result) { void CodeWidget::gotPassword(const MTPaccount_Password &result) {
@ -455,15 +439,11 @@ void CodeWidget::noTelegramCode() {
void CodeWidget::noTelegramCodeDone(const MTPauth_SentCode &result) { void CodeWidget::noTelegramCodeDone(const MTPauth_SentCode &result) {
_noTelegramCodeRequestId = 0; _noTelegramCodeRequestId = 0;
if (result.type() != mtpc_auth_sentCode) { result.match([&](const MTPDauth_sentCode &data) {
showCodeError(rpl::single(Lang::Hard::ServerError()));
return;
}
const auto &d = result.c_auth_sentCode(); const auto &d = result.c_auth_sentCode();
fillSentCodeData(d); fillSentCodeData(data);
_code->setDigitsCountMax(getData()->codeLength); _code->setDigitsCountMax(getData()->codeLength);
const auto next = d.vnext_type(); const auto next = data.vnext_type();
if (next && next->type() == mtpc_auth_codeTypeCall) { if (next && next->type() == mtpc_auth_codeTypeCall) {
getData()->callStatus = CallStatus::Waiting; getData()->callStatus = CallStatus::Waiting;
getData()->callTimeout = d.vtimeout().value_or(60); getData()->callTimeout = d.vtimeout().value_or(60);
@ -473,6 +453,9 @@ void CodeWidget::noTelegramCodeDone(const MTPauth_SentCode &result) {
} }
getData()->codeByTelegram = false; getData()->codeByTelegram = false;
updateDescText(); updateDescText();
}, [&](const MTPDauth_sentCodeSuccess &data) {
finish(data.vauthorization());
});
} }
void CodeWidget::noTelegramCodeFail(const MTP::Error &error) { void CodeWidget::noTelegramCodeFail(const MTP::Error &error) {

View File

@ -79,7 +79,7 @@ private:
void codeSubmitFail(const MTP::Error &error); void codeSubmitFail(const MTP::Error &error);
void showCodeError(rpl::producer<QString> text); void showCodeError(rpl::producer<QString> text);
void callDone(const MTPauth_SentCode &v); void callDone(const MTPauth_SentCode &result);
void gotPassword(const MTPaccount_Password &result); void gotPassword(const MTPaccount_Password &result);
void noTelegramCodeDone(const MTPauth_SentCode &result); void noTelegramCodeDone(const MTPauth_SentCode &result);

View File

@ -122,17 +122,14 @@ void PasswordCheckWidget::cancelled() {
api().request(base::take(_sentRequest)).cancel(); api().request(base::take(_sentRequest)).cancel();
} }
void PasswordCheckWidget::pwdSubmitDone(bool recover, const MTPauth_Authorization &result) { void PasswordCheckWidget::pwdSubmitDone(
bool recover,
const MTPauth_Authorization &result) {
_sentRequest = 0; _sentRequest = 0;
if (recover) { if (recover) {
cSetPasswordRecovered(true); cSetPasswordRecovered(true);
} }
auto &d = result.c_auth_authorization(); finish(result);
if (d.vuser().type() != mtpc_user || !d.vuser().c_user().is_self()) { // wtf?
showError(rpl::single(Lang::Hard::ServerError()));
return;
}
finish(d.vuser());
} }
void PasswordCheckWidget::pwdSubmitFail(const MTP::Error &error) { void PasswordCheckWidget::pwdSubmitFail(const MTP::Error &error) {

View File

@ -183,7 +183,11 @@ void PhoneWidget::submit() {
MTP_string(_sentPhone), MTP_string(_sentPhone),
MTP_int(ApiId), MTP_int(ApiId),
MTP_string(ApiHash), MTP_string(ApiHash),
MTP_codeSettings(MTP_flags(0), MTP_vector<MTPbytes>()) MTP_codeSettings(
MTP_flags(0),
MTPVector<MTPbytes>(),
MTPstring(),
MTPBool())
)).done([=](const MTPauth_SentCode &result) { )).done([=](const MTPauth_SentCode &result) {
phoneSubmitDone(result); phoneSubmitDone(result);
}).fail([=](const MTP::Error &error) { }).fail([=](const MTP::Error &error) {
@ -212,24 +216,22 @@ void PhoneWidget::phoneSubmitDone(const MTPauth_SentCode &result) {
stopCheck(); stopCheck();
_sentRequest = 0; _sentRequest = 0;
if (result.type() != mtpc_auth_sentCode) { result.match([&](const MTPDauth_sentCode &data) {
showPhoneError(rpl::single(Lang::Hard::ServerError())); fillSentCodeData(data);
return;
}
const auto &d = result.c_auth_sentCode();
fillSentCodeData(d);
getData()->phone = _sentPhone; getData()->phone = _sentPhone;
getData()->phoneHash = qba(d.vphone_code_hash()); getData()->phoneHash = qba(data.vphone_code_hash());
const auto next = d.vnext_type(); const auto next = data.vnext_type();
if (next && next->type() == mtpc_auth_codeTypeCall) { if (next && next->type() == mtpc_auth_codeTypeCall) {
getData()->callStatus = CallStatus::Waiting; getData()->callStatus = CallStatus::Waiting;
getData()->callTimeout = d.vtimeout().value_or(60); getData()->callTimeout = data.vtimeout().value_or(60);
} else { } else {
getData()->callStatus = CallStatus::Disabled; getData()->callStatus = CallStatus::Disabled;
getData()->callTimeout = 0; getData()->callTimeout = 0;
} }
goNext<CodeWidget>(); goNext<CodeWidget>();
}, [&](const MTPDauth_sentCodeSuccess &data) {
finish(data.vauthorization());
});
} }
void PhoneWidget::phoneSubmitFail(const MTP::Error &error) { void PhoneWidget::phoneSubmitFail(const MTP::Error &error) {

View File

@ -375,18 +375,7 @@ void QrWidget::importTo(MTP::DcId dcId, const QByteArray &token) {
} }
void QrWidget::done(const MTPauth_Authorization &authorization) { void QrWidget::done(const MTPauth_Authorization &authorization) {
authorization.match([&](const MTPDauth_authorization &data) { finish(authorization);
if (data.vuser().type() != mtpc_user
|| !data.vuser().c_user().is_self()) {
showError(rpl::single(Lang::Hard::ServerError()));
return;
}
finish(data.vuser());
}, [&](const MTPDauth_authorizationSignUpRequired &data) {
_requestId = 0;
LOG(("API Error: Unexpected auth.authorizationSignUpRequired."));
showError(rpl::single(Lang::Hard::ServerError()));
});
} }
void QrWidget::sendCheckPasswordRequest() { void QrWidget::sendCheckPasswordRequest() {

View File

@ -110,12 +110,7 @@ void SignupWidget::cancelled() {
} }
void SignupWidget::nameSubmitDone(const MTPauth_Authorization &result) { void SignupWidget::nameSubmitDone(const MTPauth_Authorization &result) {
auto &d = result.c_auth_authorization(); finish(result);
if (d.vuser().type() != mtpc_user || !d.vuser().c_user().is_self()) { // wtf?
showError(rpl::single(Lang::Hard::ServerError()));
return;
}
finish(d.vuser(), _photo->takeResultImage());
} }
void SignupWidget::nameSubmitFail(const MTP::Error &error) { void SignupWidget::nameSubmitFail(const MTP::Error &error) {

View File

@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "intro/intro_step.h" #include "intro/intro_step.h"
#include "intro/intro_widget.h" #include "intro/intro_widget.h"
#include "intro/intro_signup.h"
#include "storage/localstorage.h" #include "storage/localstorage.h"
#include "storage/storage_account.h" #include "storage/storage_account.h"
#include "lang/lang_keys.h" #include "lang/lang_keys.h"
@ -141,6 +142,28 @@ void Step::goReplace(Step *step, Animate animate) {
} }
} }
void Step::finish(const MTPauth_Authorization &auth, QImage &&photo) {
auth.match([&](const MTPDauth_authorization &data) {
if (data.vuser().type() != mtpc_user
|| !data.vuser().c_user().is_self()) {
showError(rpl::single(Lang::Hard::ServerError())); // wtf?
return;
}
finish(data.vuser(), std::move(photo));
}, [&](const MTPDauth_authorizationSignUpRequired &data) {
if (const auto terms = data.vterms_of_service()) {
terms->match([&](const MTPDhelp_termsOfService &data) {
getData()->termsLock = Window::TermsLock::FromMTP(
nullptr,
data);
});
} else {
getData()->termsLock = Window::TermsLock();
}
goReplace<SignupWidget>(Animate::Forward);
});
}
void Step::finish(const MTPUser &user, QImage &&photo) { void Step::finish(const MTPUser &user, QImage &&photo) {
if (user.type() != mtpc_user if (user.type() != mtpc_user
|| !user.c_user().is_self() || !user.c_user().is_self()
@ -334,6 +357,8 @@ void Step::fillSentCodeData(const MTPDauth_sentCode &data) {
bad("FlashCall"); bad("FlashCall");
}, [&](const MTPDauth_sentCodeTypeMissedCall &) { }, [&](const MTPDauth_sentCodeTypeMissedCall &) {
bad("MissedCall"); bad("MissedCall");
}, [&](const MTPDauth_sentCodeTypeFirebaseSms &) {
bad("FirebaseSms");
}, [&](const MTPDauth_sentCodeTypeEmailCode &) { }, [&](const MTPDauth_sentCodeTypeEmailCode &) {
bad("EmailCode"); bad("EmailCode");
}, [&](const MTPDauth_sentCodeTypeSetUpEmailRequired &) { }, [&](const MTPDauth_sentCodeTypeSetUpEmailRequired &) {

View File

@ -111,7 +111,8 @@ protected:
[[nodiscard]] not_null<Data*> getData() const { [[nodiscard]] not_null<Data*> getData() const {
return _data; return _data;
} }
void finish(const MTPUser &user, QImage &&photo = QImage()); void finish(const MTPauth_Authorization &auth, QImage &&photo = {});
void finish(const MTPUser &user, QImage &&photo = {});
void createSession( void createSession(
const MTPUser &user, const MTPUser &user,
QImage photo, QImage photo,

View File

@ -2167,7 +2167,11 @@ QString FormController::getPlainTextFromValue(
void FormController::startPhoneVerification(not_null<Value*> value) { void FormController::startPhoneVerification(not_null<Value*> value) {
value->verification.requestId = _api.request(MTPaccount_SendVerifyPhoneCode( value->verification.requestId = _api.request(MTPaccount_SendVerifyPhoneCode(
MTP_string(getPhoneFromValue(value)), MTP_string(getPhoneFromValue(value)),
MTP_codeSettings(MTP_flags(0), MTP_vector<MTPbytes>()) MTP_codeSettings(
MTP_flags(0),
MTPVector<MTPbytes>(),
MTPstring(),
MTPBool())
)).done([=](const MTPauth_SentCode &result) { )).done([=](const MTPauth_SentCode &result) {
result.match([&](const MTPDauth_sentCode &data) { result.match([&](const MTPDauth_sentCode &data) {
const auto next = data.vnext_type(); const auto next = data.vnext_type();
@ -2215,12 +2219,17 @@ void FormController::startPhoneVerification(not_null<Value*> value) {
bad("FlashCall"); bad("FlashCall");
}, [&](const MTPDauth_sentCodeTypeMissedCall &) { }, [&](const MTPDauth_sentCodeTypeMissedCall &) {
bad("MissedCall"); bad("MissedCall");
}, [&](const MTPDauth_sentCodeTypeFirebaseSms &) {
bad("FirebaseSms");
}, [&](const MTPDauth_sentCodeTypeEmailCode &) { }, [&](const MTPDauth_sentCodeTypeEmailCode &) {
bad("EmailCode"); bad("EmailCode");
}, [&](const MTPDauth_sentCodeTypeSetUpEmailRequired &) { }, [&](const MTPDauth_sentCodeTypeSetUpEmailRequired &) {
bad("SetUpEmailRequired"); bad("SetUpEmailRequired");
}); });
_verificationNeeded.fire_copy(value); _verificationNeeded.fire_copy(value);
}, [](const MTPDauth_sentCodeSuccess &) {
LOG(("API Error: Unexpected auth.sentCodeSuccess "
"(FormController::startPhoneVerification)."));
}); });
}).fail([=](const MTP::Error &error) { }).fail([=](const MTP::Error &error) {
value->verification.requestId = 0; value->verification.requestId = 0;
@ -2256,7 +2265,7 @@ void FormController::requestPhoneCall(not_null<Value*> value) {
_api.request(MTPauth_ResendCode( _api.request(MTPauth_ResendCode(
MTP_string(getPhoneFromValue(value)), MTP_string(getPhoneFromValue(value)),
MTP_string(value->verification.phoneCodeHash) MTP_string(value->verification.phoneCodeHash)
)).done([=](const MTPauth_SentCode &code) { )).done([=] {
value->verification.call->callDone(); value->verification.call->callDone();
}).send(); }).send();
} }