From 26dc0ad9300a0fc30197d1d88e91f5e4e0cc128c Mon Sep 17 00:00:00 2001 From: levlam Date: Fri, 26 Mar 2021 18:15:21 +0300 Subject: [PATCH] Update layer to 127. --- td/generate/scheme/telegram_api.tl | 34 ++++++----- td/telegram/ContactsManager.cpp | 2 +- td/telegram/GroupCallManager.cpp | 3 +- td/telegram/MessageContent.cpp | 8 ++- td/telegram/MessagesManager.cpp | 10 ++-- td/telegram/Payments.cpp | 94 ++++++++++++++++++++++-------- td/telegram/Payments.h | 16 +++-- td/telegram/Photo.cpp | 2 +- td/telegram/UpdatesManager.cpp | 1 + td/telegram/Version.h | 2 +- 10 files changed, 118 insertions(+), 54 deletions(-) diff --git a/td/generate/scheme/telegram_api.tl b/td/generate/scheme/telegram_api.tl index 03a50c28f..62919c288 100644 --- a/td/generate/scheme/telegram_api.tl +++ b/td/generate/scheme/telegram_api.tl @@ -55,7 +55,7 @@ inputMediaVenue#c13d1c11 geo_point:InputGeoPoint title:string address:string pro inputMediaPhotoExternal#e5bbfe1a flags:# url:string ttl_seconds:flags.0?int = InputMedia; inputMediaDocumentExternal#fb52dc99 flags:# url:string ttl_seconds:flags.0?int = InputMedia; inputMediaGame#d33f43f3 id:InputGame = InputMedia; -inputMediaInvoice#f4e096c3 flags:# title:string description:string photo:flags.0?InputWebDocument invoice:Invoice payload:bytes provider:string provider_data:DataJSON start_param:string = InputMedia; +inputMediaInvoice#d9799874 flags:# title:string description:string photo:flags.0?InputWebDocument invoice:Invoice payload:bytes provider:string provider_data:DataJSON start_param:flags.1?string = InputMedia; inputMediaGeoLive#971fa843 flags:# stopped:flags.0?true geo_point:InputGeoPoint heading:flags.2?int period:flags.1?int proximity_notification_radius:flags.3?int = InputMedia; inputMediaPoll#f94e5f1 flags:# poll:Poll correct_answers:flags.0?Vector solution:flags.1?string solution_entities:flags.1?Vector = InputMedia; inputMediaDice#e66fbf7b emoticon:string = InputMedia; @@ -100,7 +100,7 @@ userEmpty#200250ba id:int = User; user#938458c1 flags:# self:flags.10?true contact:flags.11?true mutual_contact:flags.12?true deleted:flags.13?true bot:flags.14?true bot_chat_history:flags.15?true bot_nochats:flags.16?true verified:flags.17?true restricted:flags.18?true min:flags.20?true bot_inline_geo:flags.21?true support:flags.23?true scam:flags.24?true apply_min_photo:flags.25?true fake:flags.26?true id:int access_hash:flags.0?long first_name:flags.1?string last_name:flags.2?string username:flags.3?string phone:flags.4?string photo:flags.5?UserProfilePhoto status:flags.6?UserStatus bot_info_version:flags.14?int restriction_reason:flags.18?Vector bot_inline_placeholder:flags.19?string lang_code:flags.22?string = User; userProfilePhotoEmpty#4f11bae1 = UserProfilePhoto; -userProfilePhoto#69d3ab26 flags:# has_video:flags.0?true photo_id:long photo_small:FileLocation photo_big:FileLocation dc_id:int = UserProfilePhoto; +userProfilePhoto#cc656077 flags:# has_video:flags.0?true photo_id:long photo_small:FileLocation photo_big:FileLocation stripped_thumb:flags.1?bytes dc_id:int = UserProfilePhoto; userStatusEmpty#9d05049 = UserStatus; userStatusOnline#edb93949 expires:int = UserStatus; @@ -126,7 +126,7 @@ chatParticipantsForbidden#fc900c2b flags:# chat_id:int self_participant:flags.0? chatParticipants#3f460fed chat_id:int participants:Vector version:int = ChatParticipants; chatPhotoEmpty#37c1011c = ChatPhoto; -chatPhoto#d20b9f3c flags:# has_video:flags.0?true photo_small:FileLocation photo_big:FileLocation dc_id:int = ChatPhoto; +chatPhoto#4790ee05 flags:# has_video:flags.0?true photo_small:FileLocation photo_big:FileLocation stripped_thumb:flags.1?bytes dc_id:int = ChatPhoto; messageEmpty#90a6ca84 flags:# id:int peer_id:flags.0?Peer = Message; message#bce383d2 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?int 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; @@ -173,6 +173,7 @@ messageActionGeoProximityReached#98e0d697 from_id:Peer to_id:Peer distance:int = messageActionGroupCall#7a0d7f42 flags:# call:InputGroupCall duration:flags.0?int = MessageAction; messageActionInviteToGroupCall#76b9f11a call:InputGroupCall users:Vector = MessageAction; messageActionSetMessagesTTL#aa1afbfd period:int = MessageAction; +messageActionGroupCallScheduled#b3a07661 call:InputGroupCall schedule_date:int = MessageAction; dialog#2c171f72 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 notify_settings:PeerNotifySettings pts:flags.0?int draft:flags.1?DraftMessage folder_id:flags.4?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; @@ -541,7 +542,7 @@ inputStickerSetShortName#861cc8a0 short_name:string = InputStickerSet; inputStickerSetAnimatedEmoji#28703c8 = InputStickerSet; inputStickerSetDice#e67f520e emoticon:string = InputStickerSet; -stickerSet#40e237a8 flags:# archived:flags.1?true official:flags.2?true masks:flags.3?true animated:flags.5?true installed_date:flags.0?int id:long access_hash:long title:string short_name:string thumbs:flags.4?Vector thumb_dc_id:flags.4?int count:int hash:int = StickerSet; +stickerSet#d7df217a flags:# archived:flags.1?true official:flags.2?true masks:flags.3?true animated:flags.5?true installed_date:flags.0?int id:long access_hash:long title:string short_name:string thumbs:flags.4?Vector thumb_dc_id:flags.4?int thumb_version:flags.4?int count:int hash:int = StickerSet; messages.stickerSet#b60a24a6 set:StickerSet packs:Vector documents:Vector = messages.StickerSet; @@ -635,6 +636,7 @@ inputBotInlineMessageMediaGeo#96929a85 flags:# geo_point:InputGeoPoint heading:f inputBotInlineMessageMediaVenue#417bbf11 flags:# geo_point:InputGeoPoint title:string address:string provider:string venue_id:string venue_type:string reply_markup:flags.2?ReplyMarkup = InputBotInlineMessage; inputBotInlineMessageMediaContact#a6edbffd flags:# phone_number:string first_name:string last_name:string vcard:string reply_markup:flags.2?ReplyMarkup = InputBotInlineMessage; inputBotInlineMessageGame#4b425864 flags:# reply_markup:flags.2?ReplyMarkup = InputBotInlineMessage; +inputBotInlineMessageMediaInvoice#d7e78225 flags:# title:string description:string photo:flags.0?InputWebDocument invoice:Invoice payload:bytes provider:string provider_data:DataJSON reply_markup:flags.2?ReplyMarkup = InputBotInlineMessage; inputBotInlineResult#88bf9319 flags:# id:string type:string title:flags.1?string description:flags.2?string url:flags.3?string thumb:flags.4?InputWebDocument content:flags.5?InputWebDocument send_message:InputBotInlineMessage = InputBotInlineResult; inputBotInlineResultPhoto#a8d864a7 id:string type:string photo:InputPhoto send_message:InputBotInlineMessage = InputBotInlineResult; @@ -646,6 +648,7 @@ botInlineMessageText#8c7f65e2 flags:# no_webpage:flags.0?true message:string ent botInlineMessageMediaGeo#51846fd flags:# geo:GeoPoint heading:flags.0?int period:flags.1?int proximity_notification_radius:flags.3?int reply_markup:flags.2?ReplyMarkup = BotInlineMessage; botInlineMessageMediaVenue#8a86659c flags:# geo:GeoPoint title:string address:string provider:string venue_id:string venue_type:string reply_markup:flags.2?ReplyMarkup = BotInlineMessage; botInlineMessageMediaContact#18d1cdc2 flags:# phone_number:string first_name:string last_name:string vcard:string reply_markup:flags.2?ReplyMarkup = BotInlineMessage; +botInlineMessageMediaInvoice#354a9b09 flags:# shipping_address_requested:flags.1?true test:flags.3?true title:string description:string photo:flags.0?WebDocument currency:string total_amount:long reply_markup:flags.2?ReplyMarkup = BotInlineMessage; botInlineResult#11965f3a flags:# id:string type:string title:flags.1?string description:flags.2?string url:flags.3?string thumb:flags.4?WebDocument content:flags.5?WebDocument send_message:BotInlineMessage = BotInlineResult; botInlineMediaResult#17db940b flags:# id:string type:string photo:flags.0?Photo document:flags.1?Document title:flags.2?string description:flags.3?string send_message:BotInlineMessage = BotInlineResult; @@ -779,7 +782,7 @@ dataJSON#7d748d04 data:string = DataJSON; labeledPrice#cb296bf8 label:string amount:long = LabeledPrice; -invoice#c30aa358 flags:# test:flags.0?true name_requested:flags.1?true phone_requested:flags.2?true email_requested:flags.3?true shipping_address_requested:flags.4?true flexible:flags.5?true phone_to_provider:flags.6?true email_to_provider:flags.7?true currency:string prices:Vector = Invoice; +invoice#cd886e0 flags:# test:flags.0?true name_requested:flags.1?true phone_requested:flags.2?true email_requested:flags.3?true shipping_address_requested:flags.4?true flexible:flags.5?true phone_to_provider:flags.6?true email_to_provider:flags.7?true currency:string prices:Vector max_tip_amount:flags.8?long suggested_tip_amounts:flags.8?Vector = Invoice; paymentCharge#ea02c27e id:string provider_charge_id:string = PaymentCharge; @@ -799,14 +802,14 @@ inputWebFileGeoPointLocation#9f2221c9 geo_point:InputGeoPoint access_hash:long w upload.webFile#21e753bc size:int mime_type:string file_type:storage.FileType mtime:int bytes:bytes = upload.WebFile; -payments.paymentForm#3f56aea3 flags:# can_save_credentials:flags.2?true password_missing:flags.3?true bot_id:int invoice:Invoice provider_id:int url:string native_provider:flags.4?string native_params:flags.4?DataJSON saved_info:flags.0?PaymentRequestedInfo saved_credentials:flags.1?PaymentSavedCredentials users:Vector = payments.PaymentForm; +payments.paymentForm#8d0b2415 flags:# can_save_credentials:flags.2?true password_missing:flags.3?true form_id:long bot_id:int invoice:Invoice provider_id:int url:string native_provider:flags.4?string native_params:flags.4?DataJSON saved_info:flags.0?PaymentRequestedInfo saved_credentials:flags.1?PaymentSavedCredentials users:Vector = payments.PaymentForm; payments.validatedRequestedInfo#d1451883 flags:# id:flags.0?string shipping_options:flags.1?Vector = payments.ValidatedRequestedInfo; payments.paymentResult#4e5f810d updates:Updates = payments.PaymentResult; payments.paymentVerificationNeeded#d8411139 url:string = payments.PaymentResult; -payments.paymentReceipt#500911e1 flags:# date:int bot_id:int invoice:Invoice provider_id:int info:flags.0?PaymentRequestedInfo shipping:flags.1?ShippingOption currency:string total_amount:long credentials_title:string users:Vector = payments.PaymentReceipt; +payments.paymentReceipt#10b555d0 flags:# date:int bot_id:int provider_id:int title:string description:string photo:flags.2?WebDocument invoice:Invoice info:flags.0?PaymentRequestedInfo shipping:flags.1?ShippingOption tip_amount:flags.3?long currency:string total_amount:long credentials_title:string users:Vector = payments.PaymentReceipt; payments.savedInfo#fb8fe43c flags:# has_saved_credentials:flags.1?true saved_info:flags.0?PaymentRequestedInfo = payments.SavedInfo; @@ -1190,11 +1193,11 @@ peerBlocked#e8fd8014 peer_id:Peer date:int = PeerBlocked; stats.messageStats#8999f295 views_graph:StatsGraph = stats.MessageStats; groupCallDiscarded#7780bcb4 id:long access_hash:long duration:int = GroupCall; -groupCall#c0c2052e flags:# join_muted:flags.1?true can_change_join_muted:flags.2?true join_date_asc:flags.6?true id:long access_hash:long participants_count:int params:flags.0?DataJSON title:flags.3?string stream_dc_id:flags.4?int record_start_date:flags.5?int version:int = GroupCall; +groupCall#c95c6654 flags:# join_muted:flags.1?true can_change_join_muted:flags.2?true join_date_asc:flags.6?true schedule_start_subscribed:flags.8?true id:long access_hash:long participants_count:int params:flags.0?DataJSON title:flags.3?string stream_dc_id:flags.4?int record_start_date:flags.5?int schedule_date:flags.7?int version:int = GroupCall; inputGroupCall#d8aa840f id:long access_hash:long = InputGroupCall; -groupCallParticipant#19adba89 flags:# muted:flags.0?true left:flags.1?true can_self_unmute:flags.2?true just_joined:flags.4?true versioned:flags.5?true min:flags.8?true muted_by_you:flags.9?true volume_by_admin:flags.10?true self:flags.12?true peer:Peer date:int active_date:flags.3?int source:int volume:flags.7?int about:flags.11?string raise_hand_rating:flags.13?long = GroupCallParticipant; +groupCallParticipant#b96b25ee flags:# muted:flags.0?true left:flags.1?true can_self_unmute:flags.2?true just_joined:flags.4?true versioned:flags.5?true min:flags.8?true muted_by_you:flags.9?true volume_by_admin:flags.10?true self:flags.12?true peer:Peer date:int active_date:flags.3?int source:int volume:flags.7?int about:flags.11?string raise_hand_rating:flags.13?long params:flags.6?DataJSON = GroupCallParticipant; phone.groupCall#9e727aad call:GroupCall participants:Vector participants_next_offset:string chats:Vector users:Vector = phone.GroupCall; @@ -1579,10 +1582,10 @@ bots.sendCustomRequest#aa2769ed custom_method:string params:DataJSON = DataJSON; bots.answerWebhookJSONQuery#e6213f4d query_id:long data:DataJSON = Bool; bots.setBotCommands#805d46f6 commands:Vector = Bool; -payments.getPaymentForm#99f09745 msg_id:int = payments.PaymentForm; -payments.getPaymentReceipt#a092a980 msg_id:int = payments.PaymentReceipt; -payments.validateRequestedInfo#770a8e74 flags:# save:flags.0?true msg_id:int info:PaymentRequestedInfo = payments.ValidatedRequestedInfo; -payments.sendPaymentForm#2b8879b3 flags:# msg_id:int requested_info_id:flags.0?string shipping_option_id:flags.1?string credentials:InputPaymentCredentials = payments.PaymentResult; +payments.getPaymentForm#8a333c8d flags:# peer:InputPeer msg_id:int theme_params:flags.0?DataJSON = payments.PaymentForm; +payments.getPaymentReceipt#2478d1cc peer:InputPeer msg_id:int = payments.PaymentReceipt; +payments.validateRequestedInfo#db103170 flags:# save:flags.0?true peer:InputPeer msg_id:int info:PaymentRequestedInfo = payments.ValidatedRequestedInfo; +payments.sendPaymentForm#30c3bc9d flags:# form_id:long peer:InputPeer msg_id:int requested_info_id:flags.0?string shipping_option_id:flags.1?string credentials:InputPaymentCredentials tip_amount:flags.2?long = payments.PaymentResult; payments.getSavedInfo#227d824b = payments.SavedInfo; payments.clearSavedInfo#d83d70c1 flags:# credentials:flags.0?true info:flags.1?true = Bool; payments.getBankCardData#2e79d779 number:string = payments.BankCardData; @@ -1602,7 +1605,7 @@ phone.discardCall#b2cbc1c0 flags:# video:flags.0?true peer:InputPhoneCall durati phone.setCallRating#59ead627 flags:# user_initiative:flags.0?true peer:InputPhoneCall rating:int comment:string = Updates; phone.saveCallDebug#277add7e peer:InputPhoneCall debug:DataJSON = Bool; phone.sendSignalingData#ff7a9383 peer:InputPhoneCall data:bytes = Bool; -phone.createGroupCall#bd3dabe0 peer:InputPeer random_id:int = Updates; +phone.createGroupCall#48cdc6d8 flags:# peer:InputPeer random_id:int title:flags.0?string schedule_date:flags.1?int = Updates; phone.joinGroupCall#b132ff7b flags:# muted:flags.0?true call:InputGroupCall join_as:InputPeer invite_hash:flags.1?string params:DataJSON = Updates; phone.leaveGroupCall#500377f9 call:InputGroupCall source:int = Updates; phone.inviteToGroupCall#7b393160 call:InputGroupCall users:Vector = Updates; @@ -1616,6 +1619,9 @@ phone.editGroupCallParticipant#d975eb80 flags:# muted:flags.0?true call:InputGro phone.editGroupCallTitle#1ca6ac0a call:InputGroupCall title:string = Updates; phone.getGroupCallJoinAs#ef7c213a peer:InputPeer = phone.JoinAsPeers; phone.exportGroupCallInvite#e6aa647f flags:# can_self_unmute:flags.0?true call:InputGroupCall = phone.ExportedGroupCallInvite; +phone.toggleGroupCallStartSubscription#219c34e6 call:InputGroupCall subscribed:Bool = Updates; +phone.startScheduledGroupCall#5680e342 call:InputGroupCall = Updates; +phone.saveDefaultGroupCallJoinAs#575e1f8c peer:InputPeer join_as:InputPeer = Bool; langpack.getLangPack#f2f2330a lang_pack:string lang_code:string = LangPackDifference; langpack.getStrings#efea3803 lang_pack:string lang_code:string keys:Vector = Vector; diff --git a/td/telegram/ContactsManager.cpp b/td/telegram/ContactsManager.cpp index 43caa5323..a1299992d 100644 --- a/td/telegram/ContactsManager.cpp +++ b/td/telegram/ContactsManager.cpp @@ -8459,7 +8459,7 @@ ContactsManager::User *ContactsManager::get_user_force(UserId user_id) { profile_photo_local_id), telegram_api::make_object(profile_photo_volume_id, profile_photo_local_id + 2), - profile_photo_dc_id); + BufferSlice(), profile_photo_dc_id); } auto user = telegram_api::make_object( diff --git a/td/telegram/GroupCallManager.cpp b/td/telegram/GroupCallManager.cpp index 745c7515c..d5f4857dd 100644 --- a/td/telegram/GroupCallManager.cpp +++ b/td/telegram/GroupCallManager.cpp @@ -137,8 +137,9 @@ class CreateGroupCallQuery : public Td::ResultHandler { auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Read); CHECK(input_peer != nullptr); + int32 flags = 0; send_query(G()->net_query_creator().create( - telegram_api::phone_createGroupCall(std::move(input_peer), Random::secure_int32()))); + telegram_api::phone_createGroupCall(flags, std::move(input_peer), Random::secure_int32(), string(), 0))); } void on_result(uint64 id, BufferSlice packet) override { diff --git a/td/telegram/MessageContent.cpp b/td/telegram/MessageContent.cpp index 0cd8f6c87..0321e53e3 100644 --- a/td/telegram/MessageContent.cpp +++ b/td/telegram/MessageContent.cpp @@ -2301,7 +2301,7 @@ static tl_object_ptr get_input_invoice(const Invoice &inv }); return make_tl_object( flags, false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/, - false /*ignored*/, false /*ignored*/, false /*ignored*/, invoice.currency, std::move(prices)); + false /*ignored*/, false /*ignored*/, false /*ignored*/, invoice.currency, std::move(prices), 0, vector()); } static tl_object_ptr get_input_web_document(const FileManager *file_manager, @@ -2332,7 +2332,7 @@ static tl_object_ptr get_input_web_document(cons static tl_object_ptr get_input_media_invoice(const FileManager *file_manager, const MessageInvoice *message_invoice) { CHECK(message_invoice != nullptr); - int32 flags = 0; + int32 flags = telegram_api::inputMediaInvoice::START_PARAM_MASK; auto input_web_document = get_input_web_document(file_manager, message_invoice->photo); if (input_web_document != nullptr) { flags |= telegram_api::inputMediaInvoice::PHOTO_MASK; @@ -4653,6 +4653,10 @@ unique_ptr get_action_message_content(Td *td, tl_object_ptr(set_messages_ttl->period_); } + case telegram_api::messageActionGroupCallScheduled::ID: { + auto scheduled_group_call = move_tl_object_as(action); + break; + } default: UNREACHABLE(); } diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index 9bac60842..64ba102d7 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -37374,7 +37374,7 @@ void MessagesManager::get_payment_form(FullMessageId full_message_id, return promise.set_error(r_message_id.move_as_error()); } - ::td::get_payment_form(r_message_id.ok(), std::move(promise)); + ::td::get_payment_form(full_message_id.get_dialog_id(), r_message_id.ok(), std::move(promise)); } void MessagesManager::validate_order_info(FullMessageId full_message_id, tl_object_ptr order_info, @@ -37385,7 +37385,8 @@ void MessagesManager::validate_order_info(FullMessageId full_message_id, tl_obje return promise.set_error(r_message_id.move_as_error()); } - ::td::validate_order_info(r_message_id.ok(), std::move(order_info), allow_save, std::move(promise)); + ::td::validate_order_info(full_message_id.get_dialog_id(), r_message_id.ok(), std::move(order_info), allow_save, + std::move(promise)); } void MessagesManager::send_payment_form(FullMessageId full_message_id, const string &order_info_id, @@ -37397,7 +37398,8 @@ void MessagesManager::send_payment_form(FullMessageId full_message_id, const str return promise.set_error(r_message_id.move_as_error()); } - ::td::send_payment_form(r_message_id.ok(), order_info_id, shipping_option_id, credentials, std::move(promise)); + ::td::send_payment_form(full_message_id.get_dialog_id(), r_message_id.ok(), order_info_id, shipping_option_id, + credentials, std::move(promise)); } void MessagesManager::get_payment_receipt(FullMessageId full_message_id, @@ -37416,7 +37418,7 @@ void MessagesManager::get_payment_receipt(FullMessageId full_message_id, return promise.set_error(Status::Error(5, "Wrong message identifier")); } - ::td::get_payment_receipt(m->message_id.get_server_message_id(), std::move(promise)); + ::td::get_payment_receipt(full_message_id.get_dialog_id(), m->message_id.get_server_message_id(), std::move(promise)); } void MessagesManager::remove_sponsored_dialog() { diff --git a/td/telegram/Payments.cpp b/td/telegram/Payments.cpp index 22ebb11e3..08142dc44 100644 --- a/td/telegram/Payments.cpp +++ b/td/telegram/Payments.cpp @@ -6,14 +6,14 @@ // #include "td/telegram/Payments.h" -#include "td/telegram/td_api.h" -#include "td/telegram/telegram_api.h" - #include "td/telegram/ContactsManager.h" #include "td/telegram/Global.h" +#include "td/telegram/MessagesManager.h" #include "td/telegram/misc.h" #include "td/telegram/PasswordManager.h" #include "td/telegram/Td.h" +#include "td/telegram/td_api.h" +#include "td/telegram/telegram_api.h" #include "td/telegram/UpdatesManager.h" #include "td/utils/algorithm.h" @@ -255,13 +255,22 @@ static tl_object_ptr convert_saved_credentials( class GetPaymentFormQuery : public Td::ResultHandler { Promise> promise_; + DialogId dialog_id_; public: explicit GetPaymentFormQuery(Promise> &&promise) : promise_(std::move(promise)) { } - void send(ServerMessageId server_message_id) { - send_query(G()->net_query_creator().create(telegram_api::payments_getPaymentForm(server_message_id.get()))); + void send(DialogId dialog_id, ServerMessageId server_message_id) { + dialog_id_ = dialog_id; + auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Read); + if (input_peer == nullptr) { + return on_error(0, Status::Error(400, "Can't access the chat")); + } + + int32 flags = 0; + send_query(G()->net_query_creator().create( + telegram_api::payments_getPaymentForm(flags, std::move(input_peer), server_message_id.get(), nullptr))); } void on_result(uint64 id, BufferSlice packet) override { @@ -286,20 +295,28 @@ class GetPaymentFormQuery : public Td::ResultHandler { } void on_error(uint64 id, Status status) override { + td->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetPaymentFormQuery"); promise_.set_error(std::move(status)); } }; class ValidateRequestedInfoQuery : public Td::ResultHandler { Promise> promise_; + DialogId dialog_id_; public: explicit ValidateRequestedInfoQuery(Promise> &&promise) : promise_(std::move(promise)) { } - void send(ServerMessageId server_message_id, tl_object_ptr requested_info, - bool allow_save) { + void send(DialogId dialog_id, ServerMessageId server_message_id, + tl_object_ptr requested_info, bool allow_save) { + dialog_id_ = dialog_id; + auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Read); + if (input_peer == nullptr) { + return on_error(0, Status::Error(400, "Can't access the chat")); + } + int32 flags = 0; if (allow_save) { flags |= telegram_api::payments_validateRequestedInfo::SAVE_MASK; @@ -309,7 +326,7 @@ class ValidateRequestedInfoQuery : public Td::ResultHandler { requested_info->flags_ = 0; } send_query(G()->net_query_creator().create(telegram_api::payments_validateRequestedInfo( - flags, false /*ignored*/, server_message_id.get(), std::move(requested_info)))); + flags, false /*ignored*/, std::move(input_peer), server_message_id.get(), std::move(requested_info)))); } void on_result(uint64 id, BufferSlice packet) override { @@ -327,21 +344,30 @@ class ValidateRequestedInfoQuery : public Td::ResultHandler { } void on_error(uint64 id, Status status) override { + td->messages_manager_->on_get_dialog_error(dialog_id_, status, "ValidateRequestedInfoQuery"); promise_.set_error(std::move(status)); } }; class SendPaymentFormQuery : public Td::ResultHandler { Promise> promise_; + DialogId dialog_id_; public: explicit SendPaymentFormQuery(Promise> &&promise) : promise_(std::move(promise)) { } - void send(ServerMessageId server_message_id, const string &order_info_id, const string &shipping_option_id, - tl_object_ptr input_credentials) { + void send(DialogId dialog_id, ServerMessageId server_message_id, const string &order_info_id, + const string &shipping_option_id, tl_object_ptr input_credentials) { CHECK(input_credentials != nullptr); + + dialog_id_ = dialog_id; + auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Read); + if (input_peer == nullptr) { + return on_error(0, Status::Error(400, "Can't access the chat")); + } + int32 flags = 0; if (!order_info_id.empty()) { flags |= telegram_api::payments_sendPaymentForm::REQUESTED_INFO_ID_MASK; @@ -349,8 +375,9 @@ class SendPaymentFormQuery : public Td::ResultHandler { if (!shipping_option_id.empty()) { flags |= telegram_api::payments_sendPaymentForm::SHIPPING_OPTION_ID_MASK; } - send_query(G()->net_query_creator().create(telegram_api::payments_sendPaymentForm( - flags, server_message_id.get(), order_info_id, shipping_option_id, std::move(input_credentials)))); + send_query(G()->net_query_creator().create( + telegram_api::payments_sendPaymentForm(flags, 0, std::move(input_peer), server_message_id.get(), order_info_id, + shipping_option_id, std::move(input_credentials), 0))); } void on_result(uint64 id, BufferSlice packet) override { @@ -382,20 +409,29 @@ class SendPaymentFormQuery : public Td::ResultHandler { } void on_error(uint64 id, Status status) override { + td->messages_manager_->on_get_dialog_error(dialog_id_, status, "SendPaymentFormQuery"); promise_.set_error(std::move(status)); } }; class GetPaymentReceiptQuery : public Td::ResultHandler { Promise> promise_; + DialogId dialog_id_; public: explicit GetPaymentReceiptQuery(Promise> &&promise) : promise_(std::move(promise)) { } - void send(ServerMessageId server_message_id) { - send_query(G()->net_query_creator().create(telegram_api::payments_getPaymentReceipt(server_message_id.get()))); + void send(DialogId dialog_id, ServerMessageId server_message_id) { + dialog_id_ = dialog_id; + auto input_peer = td->messages_manager_->get_input_peer(dialog_id, AccessRights::Read); + if (input_peer == nullptr) { + return on_error(0, Status::Error(400, "Can't access the chat")); + } + + send_query(G()->net_query_creator().create( + telegram_api::payments_getPaymentReceipt(std::move(input_peer), server_message_id.get()))); } void on_result(uint64 id, BufferSlice packet) override { @@ -423,6 +459,7 @@ class GetPaymentReceiptQuery : public Td::ResultHandler { } void on_error(uint64 id, Status status) override { + td->messages_manager_->on_get_dialog_error(dialog_id_, status, "GetPaymentReceiptQuery"); promise_.set_error(std::move(status)); } }; @@ -785,12 +822,17 @@ void answer_pre_checkout_query(int64 pre_checkout_query_id, const string &error_ ->send(pre_checkout_query_id, error_message); } -void get_payment_form(ServerMessageId server_message_id, Promise> &&promise) { - G()->td().get_actor_unsafe()->create_handler(std::move(promise))->send(server_message_id); +void get_payment_form(DialogId dialog_id, ServerMessageId server_message_id, + Promise> &&promise) { + G()->td() + .get_actor_unsafe() + ->create_handler(std::move(promise)) + ->send(dialog_id, server_message_id); } -void validate_order_info(ServerMessageId server_message_id, tl_object_ptr order_info, - bool allow_save, Promise> &&promise) { +void validate_order_info(DialogId dialog_id, ServerMessageId server_message_id, + tl_object_ptr order_info, bool allow_save, + Promise> &&promise) { if (order_info != nullptr) { if (!clean_input_string(order_info->name_)) { return promise.set_error(Status::Error(400, "Name must be encoded in UTF-8")); @@ -826,11 +868,11 @@ void validate_order_info(ServerMessageId server_message_id, tl_object_ptrtd() .get_actor_unsafe() ->create_handler(std::move(promise)) - ->send(server_message_id, convert_order_info(std::move(order_info)), allow_save); + ->send(dialog_id, server_message_id, convert_order_info(std::move(order_info)), allow_save); } -void send_payment_form(ServerMessageId server_message_id, const string &order_info_id, const string &shipping_option_id, - const tl_object_ptr &credentials, +void send_payment_form(DialogId dialog_id, ServerMessageId server_message_id, const string &order_info_id, + const string &shipping_option_id, const tl_object_ptr &credentials, Promise> &&promise) { CHECK(credentials != nullptr); @@ -882,11 +924,15 @@ void send_payment_form(ServerMessageId server_message_id, const string &order_in G()->td() .get_actor_unsafe() ->create_handler(std::move(promise)) - ->send(server_message_id, order_info_id, shipping_option_id, std::move(input_credentials)); + ->send(dialog_id, server_message_id, order_info_id, shipping_option_id, std::move(input_credentials)); } -void get_payment_receipt(ServerMessageId server_message_id, Promise> &&promise) { - G()->td().get_actor_unsafe()->create_handler(std::move(promise))->send(server_message_id); +void get_payment_receipt(DialogId dialog_id, ServerMessageId server_message_id, + Promise> &&promise) { + G()->td() + .get_actor_unsafe() + ->create_handler(std::move(promise)) + ->send(dialog_id, server_message_id); } void get_saved_order_info(Promise> &&promise) { diff --git a/td/telegram/Payments.h b/td/telegram/Payments.h index 5287e0e7b..ab30e4d16 100644 --- a/td/telegram/Payments.h +++ b/td/telegram/Payments.h @@ -8,6 +8,7 @@ #include "td/actor/PromiseFuture.h" +#include "td/telegram/DialogId.h" #include "td/telegram/Photo.h" #include "td/telegram/ServerMessageId.h" @@ -137,16 +138,19 @@ void answer_shipping_query(int64 shipping_query_id, vector &&promise); -void get_payment_form(ServerMessageId server_message_id, Promise> &&promise); +void get_payment_form(DialogId dialog_id, ServerMessageId server_message_id, + Promise> &&promise); -void validate_order_info(ServerMessageId server_message_id, tl_object_ptr order_info, - bool allow_save, Promise> &&promise); +void validate_order_info(DialogId dialog_id, ServerMessageId server_message_id, + tl_object_ptr order_info, bool allow_save, + Promise> &&promise); -void send_payment_form(ServerMessageId server_message_id, const string &order_info_id, const string &shipping_option_id, - const tl_object_ptr &credentials, +void send_payment_form(DialogId dialog_id, ServerMessageId server_message_id, const string &order_info_id, + const string &shipping_option_id, const tl_object_ptr &credentials, Promise> &&promise); -void get_payment_receipt(ServerMessageId server_message_id, Promise> &&promise); +void get_payment_receipt(DialogId dialog_id, ServerMessageId server_message_id, + Promise> &&promise); void get_saved_order_info(Promise> &&promise); diff --git a/td/telegram/Photo.cpp b/td/telegram/Photo.cpp index 2fa58f8bf..6e8114441 100644 --- a/td/telegram/Photo.cpp +++ b/td/telegram/Photo.cpp @@ -992,7 +992,7 @@ tl_object_ptr convert_photo_to_profile_photo( flags |= telegram_api::userProfilePhoto::HAS_VIDEO_MASK; } return make_tl_object(flags, false /*ignored*/, photo->id_, std::move(photo_small), - std::move(photo_big), photo->dc_id_); + std::move(photo_big), BufferSlice(), photo->dc_id_); } } // namespace td diff --git a/td/telegram/UpdatesManager.cpp b/td/telegram/UpdatesManager.cpp index 3ca0835ed..e28158047 100644 --- a/td/telegram/UpdatesManager.cpp +++ b/td/telegram/UpdatesManager.cpp @@ -623,6 +623,7 @@ bool UpdatesManager::is_acceptable_message(const telegram_api::Message *message_ case telegram_api::messageActionSecureValuesSentMe::ID: case telegram_api::messageActionContactSignUp::ID: case telegram_api::messageActionGroupCall::ID: + case telegram_api::messageActionGroupCallScheduled::ID: case telegram_api::messageActionSetMessagesTTL::ID: break; case telegram_api::messageActionChatCreate::ID: { diff --git a/td/telegram/Version.h b/td/telegram/Version.h index d9f28e617..a523cd6cc 100644 --- a/td/telegram/Version.h +++ b/td/telegram/Version.h @@ -8,7 +8,7 @@ namespace td { -constexpr int32 MTPROTO_LAYER = 126; +constexpr int32 MTPROTO_LAYER = 127; enum class Version : int32 { Initial, // 0