diff --git a/Telegram/Resources/tl/api.tl b/Telegram/Resources/tl/api.tl index 21aed824a..4f63ffd6f 100644 --- a/Telegram/Resources/tl/api.tl +++ b/Telegram/Resources/tl/api.tl @@ -142,7 +142,7 @@ chatPhotoEmpty#37c1011c = ChatPhoto; chatPhoto#1c6e1c11 flags:# has_video:flags.0?true photo_id:long stripped_thumb:flags.1?bytes dc_id:int = ChatPhoto; messageEmpty#90a6ca84 flags:# id:int peer_id:flags.0?Peer = Message; -message#85d6cbe2 flags:# out:flags.1?true mentioned:flags.4?true media_unread:flags.5?true silent:flags.13?true post:flags.14?true from_scheduled:flags.18?true legacy:flags.19?true edit_hide:flags.21?true pinned:flags.24?true id:int from_id:flags.8?Peer peer_id:Peer fwd_from:flags.2?MessageFwdHeader via_bot_id:flags.11?long reply_to:flags.3?MessageReplyHeader date:int message:string media:flags.9?MessageMedia reply_markup:flags.6?ReplyMarkup entities:flags.7?Vector views:flags.10?int forwards:flags.10?int replies:flags.23?MessageReplies edit_date:flags.15?int post_author:flags.16?string grouped_id:flags.17?long restriction_reason:flags.22?Vector ttl_period:flags.25?int = Message; +message#85d6cbe2 flags:# out:flags.1?true mentioned:flags.4?true media_unread:flags.5?true silent:flags.13?true post:flags.14?true from_scheduled:flags.18?true legacy:flags.19?true edit_hide:flags.21?true pinned:flags.24?true noforwards:flags.26?true id:int from_id:flags.8?Peer peer_id:Peer fwd_from:flags.2?MessageFwdHeader via_bot_id:flags.11?long reply_to:flags.3?MessageReplyHeader date:int message:string media:flags.9?MessageMedia reply_markup:flags.6?ReplyMarkup entities:flags.7?Vector views:flags.10?int forwards:flags.10?int replies:flags.23?MessageReplies edit_date:flags.15?int post_author:flags.16?string grouped_id:flags.17?long restriction_reason:flags.22?Vector ttl_period:flags.25?int = Message; messageService#2b085862 flags:# out:flags.1?true mentioned:flags.4?true media_unread:flags.5?true silent:flags.13?true post:flags.14?true legacy:flags.19?true id:int from_id:flags.8?Peer peer_id:Peer reply_to:flags.3?MessageReplyHeader date:int action:MessageAction ttl_period:flags.25?int = Message; messageMediaEmpty#3ded6320 = MessageMedia; @@ -208,7 +208,7 @@ geoPoint#b2a2f663 flags:# long:double lat:double access_hash:long accuracy_radiu auth.sentCode#5e002502 flags:# type:auth.SentCodeType phone_code_hash:string next_type:flags.1?auth.CodeType timeout:flags.2?int = auth.SentCode; -auth.authorization#cd050916 flags:# tmp_sessions:flags.0?int user:User = auth.Authorization; +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.authorizationSignUpRequired#44747e9a flags:# terms_of_service:flags.0?help.TermsOfService = auth.Authorization; auth.exportedAuthorization#b434e2b8 id:long bytes:bytes = auth.ExportedAuthorization; @@ -631,7 +631,7 @@ channelMessagesFilterEmpty#94d42ee7 = ChannelMessagesFilter; channelMessagesFilter#cd77d957 flags:# exclude_new_messages:flags.1?true ranges:Vector = ChannelMessagesFilter; channelParticipant#c00c07c0 user_id:long date:int = ChannelParticipant; -channelParticipantSelf#35a8bfa7 flags:# via_invite:flags.0?true user_id:long inviter_id:long date:int = ChannelParticipant; +channelParticipantSelf#35a8bfa7 flags:# via_request:flags.0?true user_id:long inviter_id:long date:int = ChannelParticipant; channelParticipantCreator#2fe601d3 flags:# user_id:long admin_rights:ChatAdminRights rank:flags.0?string = ChannelParticipant; channelParticipantAdmin#34c3bb53 flags:# can_edit:flags.0?true self:flags.1?true user_id:long inviter_id:flags.1?long promoted_by:long date:int admin_rights:ChatAdminRights rank:flags.2?string = ChannelParticipant; channelParticipantBanned#6df8014e flags:# left:flags.0?true peer:Peer kicked_by:long date:int banned_rights:ChatBannedRights = ChannelParticipant; @@ -688,11 +688,13 @@ messageFwdHeader#5f777dce flags:# imported:flags.7?true from_id:flags.0?Peer fro auth.codeTypeSms#72a3158c = auth.CodeType; auth.codeTypeCall#741cd3e3 = auth.CodeType; auth.codeTypeFlashCall#226ccefb = auth.CodeType; +auth.codeTypeMissedCall#d61ad6ee = auth.CodeType; auth.sentCodeTypeApp#3dbb5986 length:int = auth.SentCodeType; auth.sentCodeTypeSms#c000bba2 length:int = auth.SentCodeType; auth.sentCodeTypeCall#5353e5a7 length:int = auth.SentCodeType; auth.sentCodeTypeFlashCall#ab03c6d9 pattern:string = auth.SentCodeType; +auth.sentCodeTypeMissedCall#82006484 prefix:string 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; @@ -1091,7 +1093,7 @@ inputWallPaperNoFile#967a462e id:long = InputWallPaper; account.wallPapersNotModified#1c199183 = account.WallPapers; account.wallPapers#cdc3858c hash:long wallpapers:Vector = account.WallPapers; -codeSettings#debebe83 flags:# allow_flashcall:flags.0?true current_number:flags.1?true allow_app_hash:flags.4?true = CodeSettings; +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 = 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; @@ -1298,6 +1300,8 @@ users.userFull#3b6d152e full_user:UserFull chats:Vector users:Vector messages.peerSettings#6880b94d settings:PeerSettings chats:Vector users:Vector = messages.PeerSettings; +auth.loggedOut#8b591226 flags:# future_auth_token:flags.0?bytes future_auth_expires:flags.0?int = auth.LoggedOut; + ---functions--- invokeAfterMsg#cb9f372d {X:Type} msg_id:long query:!X = X; @@ -1311,7 +1315,7 @@ invokeWithTakeout#aca9fd2e {X:Type} takeout_id:long query:!X = X; auth.sendCode#a677244f phone_number:string api_id:int api_hash:string settings:CodeSettings = auth.SentCode; auth.signUp#80eee427 phone_number:string phone_code_hash:string first_name:string last_name:string = auth.Authorization; auth.signIn#bcd51581 phone_number:string phone_code_hash:string phone_code:string = auth.Authorization; -auth.logOut#5717da40 = Bool; +auth.logOut#3e72ba19 = auth.LoggedOut; auth.resetAuthorizations#9fab0d1a = Bool; auth.exportAuthorization#e5bfffcd dc_id:int = auth.ExportedAuthorization; auth.importAuthorization#a57a7dad id:long bytes:bytes = auth.Authorization; diff --git a/Telegram/SourceFiles/api/api_confirm_phone.cpp b/Telegram/SourceFiles/api/api_confirm_phone.cpp index cfe13eb07..559f16136 100644 --- a/Telegram/SourceFiles/api/api_confirm_phone.cpp +++ b/Telegram/SourceFiles/api/api_confirm_phone.cpp @@ -30,7 +30,7 @@ void ConfirmPhone::resolve( } _sendRequestId = _api.request(MTPaccount_SendConfirmPhoneCode( MTP_string(hash), - MTP_codeSettings(MTP_flags(0)) + MTP_codeSettings(MTP_flags(0), MTP_vector()) )).done([=](const MTPauth_SentCode &result) { _sendRequestId = 0; @@ -46,6 +46,9 @@ void ConfirmPhone::resolve( }, [&](const MTPDauth_sentCodeTypeFlashCall &data) { LOG(("Error: should not be flashcall!")); return 0; + }, [&](const MTPDauth_sentCodeTypeMissedCall &data) { + LOG(("Error: should not be missedcall!")); + return 0; }); const auto phoneHash = qs(data.vphone_code_hash()); const auto timeout = [&]() -> std::optional { diff --git a/Telegram/SourceFiles/apiwrap.cpp b/Telegram/SourceFiles/apiwrap.cpp index 6c7cd9cab..0f2af9379 100644 --- a/Telegram/SourceFiles/apiwrap.cpp +++ b/Telegram/SourceFiles/apiwrap.cpp @@ -1657,7 +1657,7 @@ void ApiWrap::requestSelfParticipant(not_null channel) { finalize( data.vinviter_id().v, data.vdate().v, - data.is_via_invite()); + data.is_via_request()); }, [&](const MTPDchannelParticipantCreator &) { if (channel->mgInfo) { channel->mgInfo->creator = _session->user(); diff --git a/Telegram/SourceFiles/boxes/change_phone_box.cpp b/Telegram/SourceFiles/boxes/change_phone_box.cpp index e35331ecb..dc8194cbe 100644 --- a/Telegram/SourceFiles/boxes/change_phone_box.cpp +++ b/Telegram/SourceFiles/boxes/change_phone_box.cpp @@ -191,7 +191,7 @@ void ChangePhoneBox::EnterPhone::submit() { const auto phoneNumber = _phone->getLastText().trimmed(); _requestId = _api.request(MTPaccount_SendChangePhoneCode( MTP_string(phoneNumber), - MTP_codeSettings(MTP_flags(0)) + MTP_codeSettings(MTP_flags(0), MTP_vector()) )).done([=](const MTPauth_SentCode &result) { _requestId = 0; sendPhoneDone(result, phoneNumber); @@ -225,6 +225,10 @@ void ChangePhoneBox::EnterPhone::sendPhoneDone( LOG(("Error: should not be flashcall!")); showError(Lang::Hard::ServerError()); return false; + }, [&](const MTPDauth_sentCodeTypeMissedCall &data) { + LOG(("Error: should not be missedcall!")); + showError(Lang::Hard::ServerError()); + return false; }); if (!hasLength) { return; diff --git a/Telegram/SourceFiles/intro/intro_phone.cpp b/Telegram/SourceFiles/intro/intro_phone.cpp index b85b6d592..8237f2e9b 100644 --- a/Telegram/SourceFiles/intro/intro_phone.cpp +++ b/Telegram/SourceFiles/intro/intro_phone.cpp @@ -175,7 +175,7 @@ void PhoneWidget::submit() { MTP_string(_sentPhone), MTP_int(ApiId), MTP_string(ApiHash), - MTP_codeSettings(MTP_flags(0)) + MTP_codeSettings(MTP_flags(0), MTP_vector()) )).done([=](const MTPauth_SentCode &result) { phoneSubmitDone(result); }).fail([=](const MTP::Error &error) { diff --git a/Telegram/SourceFiles/intro/intro_step.cpp b/Telegram/SourceFiles/intro/intro_step.cpp index c1b559b6c..6634ec32f 100644 --- a/Telegram/SourceFiles/intro/intro_step.cpp +++ b/Telegram/SourceFiles/intro/intro_step.cpp @@ -309,22 +309,20 @@ bool Step::paintAnimated(Painter &p, QRect clip) { } void Step::fillSentCodeData(const MTPDauth_sentCode &data) { - const auto &type = data.vtype(); - switch (type.type()) { - case mtpc_auth_sentCodeTypeApp: { + data.vtype().match([&](const MTPDauth_sentCodeTypeApp &data) { getData()->codeByTelegram = true; - getData()->codeLength = type.c_auth_sentCodeTypeApp().vlength().v; - } break; - case mtpc_auth_sentCodeTypeSms: { + getData()->codeLength = data.vlength().v; + }, [&](const MTPDauth_sentCodeTypeSms &data) { getData()->codeByTelegram = false; - getData()->codeLength = type.c_auth_sentCodeTypeSms().vlength().v; - } break; - case mtpc_auth_sentCodeTypeCall: { + getData()->codeLength = data.vlength().v; + }, [&](const MTPDauth_sentCodeTypeCall &data) { getData()->codeByTelegram = false; - getData()->codeLength = type.c_auth_sentCodeTypeCall().vlength().v; - } break; - case mtpc_auth_sentCodeTypeFlashCall: LOG(("Error: should not be flashcall!")); break; - } + getData()->codeLength = data.vlength().v; + }, [&](const MTPDauth_sentCodeTypeFlashCall &) { + LOG(("Error: should not be flashcall!")); + }, [&](const MTPDauth_sentCodeTypeMissedCall &data) { + LOG(("Error: should not be missedcall!")); + }); } void Step::showDescription() { diff --git a/Telegram/SourceFiles/passport/passport_form_controller.cpp b/Telegram/SourceFiles/passport/passport_form_controller.cpp index 7680cd0ec..f2bc757f5 100644 --- a/Telegram/SourceFiles/passport/passport_form_controller.cpp +++ b/Telegram/SourceFiles/passport/passport_form_controller.cpp @@ -2161,54 +2161,50 @@ QString FormController::getPlainTextFromValue( void FormController::startPhoneVerification(not_null value) { value->verification.requestId = _api.request(MTPaccount_SendVerifyPhoneCode( MTP_string(getPhoneFromValue(value)), - MTP_codeSettings(MTP_flags(0)) + MTP_codeSettings(MTP_flags(0), MTP_vector()) )).done([=](const MTPauth_SentCode &result) { - Expects(result.type() == mtpc_auth_sentCode); - - value->verification.requestId = 0; - - const auto &data = result.c_auth_sentCode(); - value->verification.phoneCodeHash = qs(data.vphone_code_hash()); - switch (data.vtype().type()) { - case mtpc_auth_sentCodeTypeApp: - LOG(("API Error: sentCodeTypeApp not expected " - "in FormController::startPhoneVerification.")); - return; - case mtpc_auth_sentCodeTypeFlashCall: - LOG(("API Error: sentCodeTypeFlashCall not expected " - "in FormController::startPhoneVerification.")); - return; - case mtpc_auth_sentCodeTypeCall: { - const auto &type = data.vtype().c_auth_sentCodeTypeCall(); - value->verification.codeLength = (type.vlength().v > 0) - ? type.vlength().v - : -1; - value->verification.call = std::make_unique( - [=] { requestPhoneCall(value); }, - [=] { _verificationUpdate.fire_copy(value); }); - value->verification.call->setStatus( - { Ui::SentCodeCall::State::Called, 0 }); - if (data.vnext_type()) { - LOG(("API Error: next_type is not supported for calls.")); - } - } break; - case mtpc_auth_sentCodeTypeSms: { - const auto &type = data.vtype().c_auth_sentCodeTypeSms(); - value->verification.codeLength = (type.vlength().v > 0) - ? type.vlength().v - : -1; + result.match([&](const MTPDauth_sentCode &data) { const auto next = data.vnext_type(); - if (next && next->type() == mtpc_auth_codeTypeCall) { + const auto timeout = data.vtimeout(); + value->verification.requestId = 0; + value->verification.phoneCodeHash = qs(data.vphone_code_hash()); + data.vtype().match([&](const MTPDauth_sentCodeTypeApp &) { + LOG(("API Error: sentCodeTypeApp not expected " + "in FormController::startPhoneVerification.")); + }, [&](const MTPDauth_sentCodeTypeFlashCall &) { + LOG(("API Error: sentCodeTypeFlashCall not expected " + "in FormController::startPhoneVerification.")); + }, [&](const MTPDauth_sentCodeTypeMissedCall &data) { + LOG(("API Error: sentCodeTypeMissedCall not expected " + "in FormController::startPhoneVerification.")); + }, [&](const MTPDauth_sentCodeTypeCall &data) { + value->verification.codeLength = (data.vlength().v > 0) + ? data.vlength().v + : -1; value->verification.call = std::make_unique( [=] { requestPhoneCall(value); }, [=] { _verificationUpdate.fire_copy(value); }); - value->verification.call->setStatus({ - Ui::SentCodeCall::State::Waiting, - data.vtimeout().value_or(60) }); - } - } break; - } - _verificationNeeded.fire_copy(value); + value->verification.call->setStatus( + { Ui::SentCodeCall::State::Called, 0 }); + if (next) { + LOG(("API Error: next_type is not supported for calls.")); + } + }, [&](const MTPDauth_sentCodeTypeSms &data) { + value->verification.codeLength = (data.vlength().v > 0) + ? data.vlength().v + : -1; + if (next && next->type() == mtpc_auth_codeTypeCall) { + value->verification.call = std::make_unique( + [=] { requestPhoneCall(value); }, + [=] { _verificationUpdate.fire_copy(value); }); + value->verification.call->setStatus({ + Ui::SentCodeCall::State::Waiting, + timeout.value_or(60), + }); + } + }); + _verificationNeeded.fire_copy(value); + }); }).fail([=](const MTP::Error &error) { value->verification.requestId = 0; valueSaveShowError(value, error);