diff --git a/td/generate/scheme/telegram_api.tl b/td/generate/scheme/telegram_api.tl index 7336b2a63..63c1c8172 100644 --- a/td/generate/scheme/telegram_api.tl +++ b/td/generate/scheme/telegram_api.tl @@ -169,7 +169,7 @@ messageActionPaymentSent#96163f56 flags:# recurring_init:flags.2?true recurring_ messageActionPhoneCall#80e11a7f flags:# video:flags.2?true call_id:long reason:flags.0?PhoneCallDiscardReason duration:flags.1?int = MessageAction; messageActionScreenshotTaken#4792929b = MessageAction; messageActionCustomAction#fae69f56 message:string = MessageAction; -messageActionBotAllowed#abe9affe domain:string = MessageAction; +messageActionBotAllowed#c516d679 flags:# attach_menu:flags.1?true domain:flags.0?string app:flags.2?BotApp = MessageAction; messageActionSecureValuesSentMe#1b287353 values:Vector credentials:SecureCredentialsEncrypted = MessageAction; messageActionSecureValuesSent#d95c6154 types:Vector = MessageAction; messageActionContactSignUp#f3f25f76 = MessageAction; @@ -186,7 +186,6 @@ messageActionGiftPremium#aba0f5c6 currency:string amount:long months:int = Messa messageActionTopicCreate#d999256 flags:# title:string icon_color:int icon_emoji_id:flags.0?long = 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; -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; @@ -399,6 +398,7 @@ updateChannelPinnedTopic#192efbe3 flags:# pinned:flags.0?true channel_id:long to updateChannelPinnedTopics#fe198602 flags:# channel_id:long order:flags.0?Vector = Update; updateUser#20529438 user_id:long = Update; updateAutoSaveSettings#ec05b097 = Update; +updateGroupInvitePrivacyForbidden#ccf08ad6 user_id:long = Update; updates.state#a56c2a3e pts:int qts:int date:int seq:int unread_count:int = updates.State; @@ -425,7 +425,7 @@ upload.fileCdnRedirect#f18cda44 dc_id:int file_token:bytes encryption_key:bytes dcOption#18b7a10d flags:# ipv6:flags.0?true media_only:flags.1?true tcpo_only:flags.2?true cdn:flags.3?true static:flags.4?true this_port_only:flags.5?true id:int ip_address:string port:int secret:flags.10?bytes = DcOption; -config#232566ac flags:# phonecalls_enabled:flags.1?true default_p2p_contacts:flags.3?true preload_featured_stickers:flags.4?true ignore_phone_entities:flags.5?true revoke_pm_inbox:flags.6?true blocked_mode:flags.8?true pfs_enabled:flags.13?true force_try_ipv6:flags.14?true date:int expires:int test_mode:Bool this_dc:int dc_options:Vector dc_txt_domain_name:string chat_size_max:int megagroup_size_max:int forwarded_count_max:int online_update_period_ms:int offline_blur_timeout_ms:int offline_idle_timeout_ms:int online_cloud_timeout_ms:int notify_cloud_delay_ms:int notify_default_delay_ms:int push_chat_period_ms:int push_chat_limit:int saved_gifs_limit:int edit_time_limit:int revoke_time_limit:int revoke_pm_time_limit:int rating_e_decay:int stickers_recent_limit:int stickers_faved_limit:int channels_read_media_period:int tmp_sessions:flags.0?int pinned_dialogs_count_max:int pinned_infolder_count_max:int call_receive_timeout_ms:int call_ring_timeout_ms:int call_connect_timeout_ms:int call_packet_timeout_ms:int me_url_prefix:string autoupdate_url_prefix:flags.7?string gif_search_username:flags.9?string venue_search_username:flags.10?string img_search_username:flags.11?string static_maps_provider:flags.12?string caption_length_max:int message_length_max:int webfile_dc_id:int suggested_lang_code:flags.2?string lang_pack_version:flags.2?int base_lang_pack_version:flags.2?int reactions_default:flags.15?Reaction = Config; +config#cc1a241e flags:# default_p2p_contacts:flags.3?true preload_featured_stickers:flags.4?true revoke_pm_inbox:flags.6?true blocked_mode:flags.8?true force_try_ipv6:flags.14?true date:int expires:int test_mode:Bool this_dc:int dc_options:Vector dc_txt_domain_name:string chat_size_max:int megagroup_size_max:int forwarded_count_max:int online_update_period_ms:int offline_blur_timeout_ms:int offline_idle_timeout_ms:int online_cloud_timeout_ms:int notify_cloud_delay_ms:int notify_default_delay_ms:int push_chat_period_ms:int push_chat_limit:int edit_time_limit:int revoke_time_limit:int revoke_pm_time_limit:int rating_e_decay:int stickers_recent_limit:int channels_read_media_period:int tmp_sessions:flags.0?int call_receive_timeout_ms:int call_ring_timeout_ms:int call_connect_timeout_ms:int call_packet_timeout_ms:int me_url_prefix:string autoupdate_url_prefix:flags.7?string gif_search_username:flags.9?string venue_search_username:flags.10?string img_search_username:flags.11?string static_maps_provider:flags.12?string caption_length_max:int message_length_max:int webfile_dc_id:int suggested_lang_code:flags.2?string lang_pack_version:flags.2?int base_lang_pack_version:flags.2?int reactions_default:flags.15?Reaction autologin_token:flags.16?string = Config; nearestDc#8e1a1775 country:string this_dc:int nearest_dc:int = NearestDc; @@ -711,7 +711,7 @@ botInlineMessageMediaInvoice#354a9b09 flags:# shipping_address_requested:flags.1 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; -messages.botResults#947ca848 flags:# gallery:flags.0?true query_id:long next_offset:flags.1?string switch_pm:flags.2?InlineBotSwitchPM results:Vector cache_time:int users:Vector = messages.BotResults; +messages.botResults#e021f2f6 flags:# gallery:flags.0?true query_id:long next_offset:flags.1?string switch_pm:flags.2?InlineBotSwitchPM switch_webview:flags.3?InlineBotWebView results:Vector cache_time:int users:Vector = messages.BotResults; exportedMessageLink#5dab1af4 link:string html:string = ExportedMessageLink; @@ -891,7 +891,7 @@ account.tmpPassword#db64fd34 tmp_password:bytes valid_until:int = account.TmpPas shippingOption#b6213cdf id:string title:string prices:Vector = ShippingOption; -inputStickerSetItem#ffa0a496 flags:# document:InputDocument emoji:string mask_coords:flags.0?MaskCoords = InputStickerSetItem; +inputStickerSetItem#32da9e9c flags:# document:InputDocument emoji:string mask_coords:flags.0?MaskCoords keywords:flags.1?string = InputStickerSetItem; inputPhoneCall#1e36fded id:long access_hash:long = InputPhoneCall; @@ -1333,7 +1333,7 @@ account.resetPasswordFailedWait#e3779861 retry_date:int = account.ResetPasswordR account.resetPasswordRequestedWait#e9effc7d until_date:int = account.ResetPasswordResult; account.resetPasswordOk#e926d63e = account.ResetPasswordResult; -sponsoredMessage#3a836df8 flags:# recommended:flags.5?true show_peer_photo:flags.6?true random_id:bytes from_id:flags.3?Peer chat_invite:flags.4?ChatInvite chat_invite_hash:flags.4?string channel_post:flags.2?int start_param:flags.0?string message:string entities:flags.1?Vector = SponsoredMessage; +sponsoredMessage#fc25b828 flags:# recommended:flags.5?true show_peer_photo:flags.6?true random_id:bytes from_id:flags.3?Peer chat_invite:flags.4?ChatInvite chat_invite_hash:flags.4?string channel_post:flags.2?int start_param:flags.0?string message:string entities:flags.1?Vector sponsor_info:flags.7?string additional_info:flags.8?string = SponsoredMessage; messages.sponsoredMessages#c9ee1d87 flags:# posts_between:flags.0?int messages:Vector chats:Vector users:Vector = messages.SponsoredMessages; messages.sponsoredMessagesEmpty#1839490f = messages.SponsoredMessages; @@ -1498,6 +1498,23 @@ autoSaveException#81602d47 peer:Peer settings:AutoSaveSettings = AutoSaveExcepti account.autoSaveSettings#4c3e069d users_settings:AutoSaveSettings chats_settings:AutoSaveSettings broadcasts_settings:AutoSaveSettings exceptions:Vector chats:Vector users:Vector = account.AutoSaveSettings; +help.appConfigNotModified#7cde641d = help.AppConfig; +help.appConfig#dd18782e hash:int config:JSONValue = help.AppConfig; + +inputBotAppID#a920bd7a id:long access_hash:long = InputBotApp; +inputBotAppShortName#908c0407 bot_id:InputUser short_name:string = InputBotApp; + +botAppNotModified#5da674b7 = BotApp; +botApp#95fcd1d6 flags:# id:long access_hash:long short_name:string title:string description:string photo:Photo document:flags.0?Document hash:long = BotApp; + +messages.botApp#eb50adf5 flags:# inactive:flags.0?true request_write_access:flags.1?true app:BotApp = messages.BotApp; + +appWebViewResultUrl#3c1b4f0d url:string = AppWebViewResult; + +inlineBotWebView#b57295d5 text:string url:string = InlineBotWebView; + +readParticipantDate#4a4ff172 user_id:long date:int = ReadParticipantDate; + ---functions--- invokeAfterMsg#cb9f372d {X:Type} msg_id:long query:!X = X; @@ -1699,7 +1716,7 @@ messages.getDocumentByHash#b1f2061f sha256:bytes size:long mime_type:string = Do messages.getSavedGifs#5cf09635 hash:long = messages.SavedGifs; messages.saveGif#327a30cb id:InputDocument unsave:Bool = Bool; messages.getInlineBotResults#514e999d flags:# bot:InputUser peer:InputPeer geo_point:flags.0?InputGeoPoint query:string offset:string = messages.BotResults; -messages.setInlineBotResults#eb5ea206 flags:# gallery:flags.0?true private:flags.1?true query_id:long results:Vector cache_time:int next_offset:flags.2?string switch_pm:flags.3?InlineBotSwitchPM = Bool; +messages.setInlineBotResults#bb12a419 flags:# gallery:flags.0?true private:flags.1?true query_id:long results:Vector cache_time:int next_offset:flags.2?string switch_pm:flags.3?InlineBotSwitchPM switch_webview:flags.4?InlineBotWebView = Bool; messages.sendInlineBotResult#d3fbdccb flags:# silent:flags.5?true background:flags.6?true clear_draft:flags.7?true hide_via:flags.11?true peer:InputPeer reply_to_msg_id:flags.0?int top_msg_id:flags.9?int random_id:long query_id:long id:string schedule_date:flags.10?int send_as:flags.13?InputPeer = Updates; messages.getMessageEditData#fda68d36 peer:InputPeer id:int = messages.MessageEditData; messages.editMessage#48f71778 flags:# no_webpage:flags.1?true peer:InputPeer id:int message:flags.11?string media:flags.14?InputMedia reply_markup:flags.2?ReplyMarkup entities:flags.3?Vector schedule_date:flags.15?int = Updates; @@ -1788,7 +1805,7 @@ messages.getChatInviteImporters#df04dd4e flags:# requested:flags.0?true peer:Inp messages.setHistoryTTL#b80e5fe4 peer:InputPeer period:int = Updates; messages.checkHistoryImportPeer#5dc60f03 peer:InputPeer = messages.CheckedHistoryImportPeer; messages.setChatTheme#e63be13f peer:InputPeer emoticon:string = Updates; -messages.getMessageReadParticipants#2c6f97b7 peer:InputPeer msg_id:int = Vector; +messages.getMessageReadParticipants#31c1c44f peer:InputPeer msg_id:int = Vector; messages.getSearchResultsCalendar#49f0bde9 peer:InputPeer filter:MessagesFilter offset_id:int offset_date:int = messages.SearchResultsCalendar; messages.getSearchResultsPositions#6e9583a3 peer:InputPeer filter:MessagesFilter offset_id:int limit:int = messages.SearchResultsPositions; messages.hideChatJoinRequest#7fe7e815 flags:# approved:flags.0?true peer:InputPeer user_id:InputUser = Updates; @@ -1810,7 +1827,7 @@ messages.getAttachMenuBot#77216192 bot:InputUser = AttachMenuBotsBot; messages.toggleBotInAttachMenu#69f59d69 flags:# write_allowed:flags.0?true bot:InputUser enabled:Bool = Bool; messages.requestWebView#178b480b flags:# from_bot_menu:flags.4?true silent:flags.5?true peer:InputPeer bot:InputUser url:flags.1?string start_param:flags.3?string theme_params:flags.2?DataJSON platform:string reply_to_msg_id:flags.0?int top_msg_id:flags.9?int send_as:flags.13?InputPeer = WebViewResult; messages.prolongWebView#7ff34309 flags:# silent:flags.5?true peer:InputPeer bot:InputUser query_id:long reply_to_msg_id:flags.0?int top_msg_id:flags.9?int send_as:flags.13?InputPeer = Bool; -messages.requestSimpleWebView#299bec8e flags:# bot:InputUser url:string theme_params:flags.0?DataJSON platform:string = SimpleWebViewResult; +messages.requestSimpleWebView#299bec8e flags:# from_switch_webview:flags.1?true bot:InputUser url:string theme_params:flags.0?DataJSON platform:string = SimpleWebViewResult; messages.sendWebViewResultMessage#a4314f5 bot_query_id:string result:InputBotInlineResult = WebViewMessageSent; messages.sendWebViewData#dc0242c8 bot:InputUser random_id:long button_text:string data:string = Updates; messages.transcribeAudio#269e9a49 peer:InputPeer msg_id:int = messages.TranscribedAudio; @@ -1831,6 +1848,8 @@ messages.getEmojiStatusGroups#2ecd56cd hash:int = messages.EmojiGroups; messages.getEmojiProfilePhotoGroups#21a548f3 hash:int = messages.EmojiGroups; messages.searchCustomEmoji#2c11c0d7 emoticon:string hash:long = EmojiList; messages.togglePeerTranslations#e47cb579 flags:# disabled:flags.0?true peer:InputPeer = Bool; +messages.getBotApp#34fdc5c3 app:InputBotApp hash:long = messages.BotApp; +messages.requestAppWebView#8c5a3b3c flags:# write_allowed:flags.0?true peer:InputPeer app:InputBotApp start_param:flags.1?string theme_params:flags.2?DataJSON platform:string = AppWebViewResult; updates.getState#edd4882a = updates.State; updates.getDifference#25939651 flags:# pts:int pts_total_limit:flags.0?int date:int qts:int = updates.Difference; @@ -1863,7 +1882,7 @@ help.getRecentMeUrls#3dc0f114 referer:string = help.RecentMeUrls; help.getTermsOfServiceUpdate#2ca51fd1 = help.TermsOfServiceUpdate; help.acceptTermsOfService#ee72f79a id:DataJSON = Bool; help.getDeepLinkInfo#3fedc75f path:string = help.DeepLinkInfo; -help.getAppConfig#98914110 = JSONValue; +help.getAppConfig#61e3f854 hash:int = help.AppConfig; help.saveAppLog#6f02f748 events:Vector = Bool; help.getPassportConfig#c661ad08 hash:int = help.PassportConfig; help.getSupportName#d360e72c = help.SupportName; @@ -1940,6 +1959,8 @@ bots.setBotMenuButton#4504d54f user_id:InputUser button:BotMenuButton = Bool; bots.getBotMenuButton#9c60eb28 user_id:InputUser = BotMenuButton; bots.setBotBroadcastDefaultAdminRights#788464e1 admin_rights:ChatAdminRights = Bool; bots.setBotGroupDefaultAdminRights#925ec9ea admin_rights:ChatAdminRights = Bool; +bots.setBotInfo#a365df7a flags:# lang_code:string about:flags.0?string description:flags.1?string = Bool; +bots.getBotInfo#75ec12e6 lang_code:string = Vector; payments.getPaymentForm#37148dbb flags:# invoice:InputInvoice theme_params:flags.0?DataJSON = payments.PaymentForm; payments.getPaymentReceipt#2478d1cc peer:InputPeer msg_id:int = payments.PaymentReceipt; @@ -1953,13 +1974,16 @@ payments.assignAppStoreTransaction#80ed747d receipt:bytes purpose:InputStorePaym payments.assignPlayMarketTransaction#dffd50d3 receipt:DataJSON purpose:InputStorePaymentPurpose = Updates; payments.canPurchasePremium#9fc19eb6 purpose:InputStorePaymentPurpose = Bool; -stickers.createStickerSet#9021ab67 flags:# masks:flags.0?true animated:flags.1?true videos:flags.4?true user_id:InputUser title:string short_name:string thumb:flags.2?InputDocument stickers:Vector software:flags.3?string = messages.StickerSet; +stickers.createStickerSet#9021ab67 flags:# masks:flags.0?true animated:flags.1?true videos:flags.4?true emojis:flags.5?true text_color:flags.6?true user_id:InputUser title:string short_name:string thumb:flags.2?InputDocument stickers:Vector software:flags.3?string = messages.StickerSet; stickers.removeStickerFromSet#f7760f51 sticker:InputDocument = messages.StickerSet; stickers.changeStickerPosition#ffb6d4ca sticker:InputDocument position:int = messages.StickerSet; stickers.addStickerToSet#8653febe stickerset:InputStickerSet sticker:InputStickerSetItem = messages.StickerSet; -stickers.setStickerSetThumb#9a364e30 stickerset:InputStickerSet thumb:InputDocument = messages.StickerSet; +stickers.setStickerSetThumb#a76a5392 flags:# stickerset:InputStickerSet thumb:flags.0?InputDocument thumb_document_id:flags.1?long = messages.StickerSet; stickers.checkShortName#284b3639 short_name:string = Bool; stickers.suggestShortName#4dafc503 title:string = stickers.SuggestedShortName; +stickers.changeSticker#f5537ebc flags:# sticker:InputDocument emoji:flags.0?string mask_coords:flags.1?MaskCoords keywords:flags.2?string = messages.StickerSet; +stickers.renameStickerSet#124b1c00 stickerset:InputStickerSet title:string = messages.StickerSet; +stickers.deleteStickerSet#87704394 stickerset:InputStickerSet = Bool; phone.getCallConfig#55451fa9 = DataJSON; phone.requestCall#42ff96ed flags:# video:flags.0?true user_id:InputUser random_id:int g_a_hash:bytes protocol:PhoneCallProtocol = phone.PhoneCall; diff --git a/td/telegram/ConfigManager.cpp b/td/telegram/ConfigManager.cpp index 2640141a0..47bcf6fd7 100644 --- a/td/telegram/ConfigManager.cpp +++ b/td/telegram/ConfigManager.cpp @@ -978,12 +978,23 @@ void ConfigManager::lazy_request_config() { set_timeout_at(expire_time_.at()); } +void ConfigManager::reget_config(Promise &&promise) { + TRY_STATUS_PROMISE(promise, G()->close_status()); + + reget_config_queries_.push_back(std::move(promise)); + if (reget_config_queries_.size() != 1) { + return; + } + + request_config_from_dc_impl(DcId::main(), false); +} + void ConfigManager::try_request_app_config() { if (get_app_config_queries_.size() + reget_app_config_queries_.size() != 1) { return; } - auto query = G()->net_query_creator().create_unauth(telegram_api::help_getAppConfig()); + auto query = G()->net_query_creator().create_unauth(telegram_api::help_getAppConfig(0)); query->total_timeout_limit_ = 60 * 60 * 24; G()->net_query_dispatcher().dispatch_with_callback(std::move(query), actor_shared(this, 1)); } @@ -1253,10 +1264,17 @@ void ConfigManager::on_result(NetQueryPtr res) { return; } - auto result = result_ptr.move_as_ok(); - process_app_config(result); + auto app_config_ptr = result_ptr.move_as_ok(); + if (app_config_ptr->get_id() == telegram_api::help_appConfigNotModified::ID) { + fail_promises(promises, Status::Error(500, "Receive unexpected response")); + fail_promises(unit_promises, Status::Error(500, "Receive unexpected response")); + return; + } + CHECK(app_config_ptr->get_id() == telegram_api::help_appConfig::ID); + auto app_config = telegram_api::move_object_as(app_config_ptr); + process_app_config(app_config->config_); for (auto &promise : promises) { - promise.set_value(convert_json_value_object(result)); + promise.set_value(convert_json_value_object(app_config->config_)); } set_promises(unit_promises); return; @@ -1272,12 +1290,14 @@ void ConfigManager::on_result(NetQueryPtr res) { expire_time_ = Timestamp::in(60.0); // try again in a minute set_timeout_in(expire_time_.in()); } + fail_promises(reget_config_queries_, r_config.move_as_error()); } else { on_dc_options_update(DcOptions()); process_config(r_config.move_as_ok()); if (token == 9) { G()->net_query_dispatcher().update_mtproto_header(); } + set_promises(reget_config_queries_); } } @@ -1332,16 +1352,14 @@ void ConfigManager::process_config(tl_object_ptr config) { send_closure(G()->connection_creator(), &ConnectionCreator::on_dc_options, DcOptions(config->dc_options_)); options.set_option_integer("recent_stickers_limit", config->stickers_recent_limit_); - options.set_option_integer("favorite_stickers_limit", config->stickers_faved_limit_); - options.set_option_integer("saved_animations_limit", config->saved_gifs_limit_); options.set_option_integer("channels_read_media_period", config->channels_read_media_period_); + send_closure(G()->link_manager(), &LinkManager::update_autologin_token, std::move(config->autologin_token_)); + options.set_option_boolean("test_mode", config->test_mode_); options.set_option_integer("forwarded_message_count_max", config->forwarded_count_max_); options.set_option_integer("basic_group_size_max", config->chat_size_max_); options.set_option_integer("supergroup_size_max", config->megagroup_size_max_); - options.set_option_integer("pinned_chat_count_max", config->pinned_dialogs_count_max_); - options.set_option_integer("pinned_archived_chat_count_max", config->pinned_infolder_count_max_); if (is_from_main_dc || !options.have_option("expect_blocking")) { options.set_option_boolean("expect_blocking", config->blocked_mode_); } @@ -1382,8 +1400,6 @@ void ConfigManager::process_config(tl_object_ptr config) { options.set_option_integer("revoke_pm_time_limit", config->revoke_pm_time_limit_); options.set_option_integer("rating_e_decay", config->rating_e_decay_); - - options.set_option_boolean("calls_enabled", config->phonecalls_enabled_); } options.set_option_integer("call_ring_timeout_ms", config->call_ring_timeout_ms_); options.set_option_integer("call_connect_timeout_ms", config->call_connect_timeout_ms_); @@ -1442,6 +1458,7 @@ void ConfigManager::process_config(tl_object_ptr config) { options.set_option_empty("notify_cloud_delay_ms"); options.set_option_empty("notify_default_delay_ms"); options.set_option_empty("large_chat_size"); + options.set_option_empty("calls_enabled"); // TODO implement online status updates // options.set_option_integer("offline_blur_timeout_ms", config->offline_blur_timeout_ms_); @@ -1466,7 +1483,6 @@ void ConfigManager::process_app_config(tl_object_ptr &c CHECK(config != nullptr); LOG(INFO) << "Receive app config " << to_string(config); - string autologin_token; vector autologin_domains; vector url_auth_domains; vector whitelisted_domains; @@ -1693,10 +1709,6 @@ void ConfigManager::process_app_config(tl_object_ptr &c can_archive_and_mute_new_chats_from_unknown_users = get_json_value_bool(std::move(key_value->value_), key); continue; } - if (key == "autologin_token") { - autologin_token = get_json_value_string(std::move(key_value->value_), key); - continue; - } if (key == "autologin_domains") { if (value->get_id() == telegram_api::jsonArray::ID) { auto domains = std::move(static_cast(value)->value_); @@ -1892,8 +1904,8 @@ void ConfigManager::process_app_config(tl_object_ptr &c } config = make_tl_object(std::move(new_values)); - send_closure(G()->link_manager(), &LinkManager::update_autologin_domains, std::move(autologin_token), - std::move(autologin_domains), std::move(url_auth_domains), std::move(whitelisted_domains)); + send_closure(G()->link_manager(), &LinkManager::update_autologin_domains, std::move(autologin_domains), + std::move(url_auth_domains), std::move(whitelisted_domains)); Global &options = *G(); @@ -1977,20 +1989,31 @@ void ConfigManager::process_app_config(tl_object_ptr &c } bool is_premium = options.get_option_boolean("is_premium"); - - auto chat_filter_count_max = options.get_option_integer( - is_premium ? Slice("dialog_filters_limit_premium") : Slice("dialog_filters_limit_default"), is_premium ? 20 : 10); - options.set_option_integer("chat_filter_count_max", static_cast(chat_filter_count_max)); - - auto chat_filter_chosen_chat_count_max = options.get_option_integer( - is_premium ? Slice("dialog_filters_chats_limit_premium") : Slice("dialog_filters_chats_limit_default"), - is_premium ? 200 : 100); - options.set_option_integer("chat_filter_chosen_chat_count_max", - static_cast(chat_filter_chosen_chat_count_max)); - - auto bio_length_max = options.get_option_integer( - is_premium ? Slice("about_length_limit_premium") : Slice("about_length_limit_default"), is_premium ? 140 : 70); - options.set_option_integer("bio_length_max", bio_length_max); + if (is_premium) { + options.set_option_integer("chat_filter_count_max", options.get_option_integer("dialog_filters_limit_premium", 20)); + options.set_option_integer("chat_filter_chosen_chat_count_max", + options.get_option_integer("dialog_filters_chats_limit_premium", 200)); + options.set_option_integer("bio_length_max", options.get_option_integer("about_length_limit_premium", 140)); + options.set_option_integer("saved_animations_limit", options.get_option_integer("saved_gifs_limit_premium", 400)); + options.set_option_integer("favorite_stickers_limit", + options.get_option_integer("stickers_faved_limit_premium", 10)); + options.set_option_integer("pinned_chat_count_max", + options.get_option_integer("dialogs_pinned_limit_premium", 200)); + options.set_option_integer("pinned_archived_chat_count_max", + options.get_option_integer("dialogs_folder_pinned_limit_premium", 200)); + } else { + options.set_option_integer("chat_filter_count_max", options.get_option_integer("dialog_filters_limit_default", 10)); + options.set_option_integer("chat_filter_chosen_chat_count_max", + options.get_option_integer("dialog_filters_chats_limit_default", 100)); + options.set_option_integer("bio_length_max", options.get_option_integer("about_length_limit_default", 70)); + options.set_option_integer("saved_animations_limit", options.get_option_integer("saved_gifs_limit_default", 200)); + options.set_option_integer("favorite_stickers_limit", + options.get_option_integer("stickers_faved_limit_default", 5)); + options.set_option_integer("pinned_chat_count_max", + options.get_option_integer("dialogs_pinned_limit_default", 100)); + options.set_option_integer("pinned_archived_chat_count_max", + options.get_option_integer("dialogs_folder_pinned_limit_default", 100)); + } if (!is_premium_available) { premium_bot_username.clear(); // just in case diff --git a/td/telegram/ConfigManager.h b/td/telegram/ConfigManager.h index 0d5355f67..f4fd21c8a 100644 --- a/td/telegram/ConfigManager.h +++ b/td/telegram/ConfigManager.h @@ -82,6 +82,8 @@ class ConfigManager final : public NetQueryCallback { void lazy_request_config(); + void reget_config(Promise &&promise); + void get_app_config(Promise> &&promise); void reget_app_config(Promise &&promise); @@ -112,6 +114,8 @@ class ConfigManager final : public NetQueryCallback { FloodControlStrict lazy_request_flood_control_; + vector> reget_config_queries_; + vector>> get_app_config_queries_; vector> reget_app_config_queries_; diff --git a/td/telegram/InlineQueriesManager.cpp b/td/telegram/InlineQueriesManager.cpp index 6377887c3..0425993f5 100644 --- a/td/telegram/InlineQueriesManager.cpp +++ b/td/telegram/InlineQueriesManager.cpp @@ -145,7 +145,7 @@ class SetInlineBotResultsQuery final : public Td::ResultHandler { } send_query(G()->net_query_creator().create(telegram_api::messages_setInlineBotResults( flags, false /*ignored*/, false /*ignored*/, inline_query_id, std::move(results), cache_time, next_offset, - std::move(inline_bot_switch_pm)))); + std::move(inline_bot_switch_pm), nullptr))); } void on_result(BufferSlice packet) final { @@ -184,7 +184,7 @@ class RequestSimpleWebViewQuery final : public Td::ResultHandler { theme_parameters->data_ = ThemeManager::get_theme_parameters_json_string(theme, false); } send_query(G()->net_query_creator().create(telegram_api::messages_requestSimpleWebView( - flags, std::move(input_user), url, std::move(theme_parameters), platform))); + flags, false /*ignored*/, std::move(input_user), url, std::move(theme_parameters), platform))); } void on_result(BufferSlice packet) final { diff --git a/td/telegram/LinkManager.cpp b/td/telegram/LinkManager.cpp index f12647ac1..f339ea943 100644 --- a/td/telegram/LinkManager.cpp +++ b/td/telegram/LinkManager.cpp @@ -777,6 +777,7 @@ LinkManager::~LinkManager() = default; void LinkManager::start_up() { autologin_update_time_ = Time::now() - 365 * 86400; + autologin_domains_ = full_split(G()->td_db()->get_binlog_pmc()->get("autologin_domains"), '\xFF'); url_auth_domains_ = full_split(G()->td_db()->get_binlog_pmc()->get("url_auth_domains"), '\xFF'); @@ -1534,10 +1535,13 @@ unique_ptr LinkManager::get_internal_link_passport( callback_url.str()); } -void LinkManager::update_autologin_domains(string autologin_token, vector autologin_domains, - vector url_auth_domains, vector whitelisted_domains) { +void LinkManager::update_autologin_token(string autologin_token) { autologin_update_time_ = Time::now(); autologin_token_ = std::move(autologin_token); +} + +void LinkManager::update_autologin_domains(vector autologin_domains, vector url_auth_domains, + vector whitelisted_domains) { if (autologin_domains_ != autologin_domains) { autologin_domains_ = std::move(autologin_domains); G()->td_db()->get_binlog_pmc()->set("autologin_domains", implode(autologin_domains_, '\xFF')); @@ -1603,7 +1607,7 @@ void LinkManager::get_external_link_info(string &&link, Promiselink_manager(), &LinkManager::get_external_link_info, std::move(link), std::move(promise)); }); - return send_closure(G()->config_manager(), &ConfigManager::reget_app_config, std::move(query_promise)); + return send_closure(G()->config_manager(), &ConfigManager::reget_config, std::move(query_promise)); } if (autologin_token_.empty()) { diff --git a/td/telegram/LinkManager.h b/td/telegram/LinkManager.h index a1f60ee73..cd3295d44 100644 --- a/td/telegram/LinkManager.h +++ b/td/telegram/LinkManager.h @@ -59,8 +59,10 @@ class LinkManager final : public Actor { // checks whether the link is a supported tg or t.me link and parses it static unique_ptr parse_internal_link(Slice link, bool is_trusted = false); - void update_autologin_domains(string autologin_token, vector autologin_domains, - vector url_auth_domains, vector whitelisted_domains); + void update_autologin_token(string autologin_token); + + void update_autologin_domains(vector autologin_domains, vector url_auth_domains, + vector whitelisted_domains); void get_deep_link_info(Slice link, Promise> &&promise); diff --git a/td/telegram/MessageContent.cpp b/td/telegram/MessageContent.cpp index 8e8ab439a..2a2b34ba1 100644 --- a/td/telegram/MessageContent.cpp +++ b/td/telegram/MessageContent.cpp @@ -5235,7 +5235,13 @@ unique_ptr get_action_message_content(Td *td, tl_object_ptr(action_ptr); - return td::make_unique(std::move(action->domain_)); + if (action->attach_menu_) { + return td::make_unique(); + } + if (!action->domain_.empty()) { + return td::make_unique(std::move(action->domain_)); + } + return td::make_unique(); } case telegram_api::messageActionSecureValuesSent::ID: { LOG_IF(ERROR, td->auth_manager_->is_bot()) << "Receive MessageActionSecureValuesSent in " << owner_dialog_id; @@ -5362,8 +5368,6 @@ unique_ptr get_action_message_content(Td *td, tl_object_ptr(std::move(photo)); } - case telegram_api::messageActionAttachMenuBotAllowed::ID: - return td::make_unique(); case telegram_api::messageActionRequestedPeer::ID: { auto action = move_tl_object_as(action_ptr); DialogId dialog_id(action->peer_); diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index c230e106d..f7a65baf7 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -700,7 +700,11 @@ class GetMessageReadParticipantsQuery final : public Td::ResultHandler { return on_error(result_ptr.move_as_error()); } - promise_.set_value(UserId::get_user_ids(result_ptr.ok())); + auto user_ids = + transform(result_ptr.ok(), [](const telegram_api::object_ptr &user_date) { + return user_date->user_id_; + }); + promise_.set_value(UserId::get_user_ids(user_ids)); } void on_error(Status status) final { diff --git a/td/telegram/StickersManager.cpp b/td/telegram/StickersManager.cpp index 065fe1f65..0a8dfbe54 100644 --- a/td/telegram/StickersManager.cpp +++ b/td/telegram/StickersManager.cpp @@ -1159,8 +1159,8 @@ class CreateNewStickerSetQuery final : public Td::ResultHandler { send_query(G()->net_query_creator().create( telegram_api::stickers_createStickerSet(flags, false /*ignored*/, false /*ignored*/, false /*ignored*/, - std::move(input_user), title, short_name, nullptr, - std::move(input_stickers), software), + false /*ignored*/, false /*ignored*/, std::move(input_user), title, + short_name, nullptr, std::move(input_stickers), software), {{short_name}})); } @@ -1226,9 +1226,10 @@ class SetStickerSetThumbnailQuery final : public Td::ResultHandler { } void send(const string &short_name, tl_object_ptr &&input_document) { + int32 flags = telegram_api::stickers_setStickerSetThumb::THUMB_MASK; send_query(G()->net_query_creator().create( - telegram_api::stickers_setStickerSetThumb(make_tl_object(short_name), - std::move(input_document)), + telegram_api::stickers_setStickerSetThumb( + flags, make_tl_object(short_name), std::move(input_document), 0), {{short_name}})); } @@ -7949,7 +7950,7 @@ tl_object_ptr StickersManager::get_input_stic } return make_tl_object(flags, std::move(input_document), sticker->emojis_, - std::move(mask_coords)); + std::move(mask_coords), string()); } void StickersManager::get_suggested_sticker_set_name(string title, Promise &&promise) { diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index 8f3a7a72c..cec1f9d2f 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -5780,10 +5780,6 @@ void Td::on_request(uint64 id, const td_api::createCall &request) { return send_error_raw(id, r_input_user.error().code(), r_input_user.error().message()); } - if (!G()->get_option_boolean("calls_enabled")) { - return send_error_raw(id, 400, "Calls are not enabled for the current user"); - } - CREATE_REQUEST_PROMISE(); auto query_promise = PromiseCreator::lambda([promise = std::move(promise)](Result result) mutable { if (result.is_error()) { diff --git a/td/telegram/UpdatesManager.cpp b/td/telegram/UpdatesManager.cpp index 9c801059c..7736cd1ed 100644 --- a/td/telegram/UpdatesManager.cpp +++ b/td/telegram/UpdatesManager.cpp @@ -801,7 +801,6 @@ bool UpdatesManager::is_acceptable_message(const telegram_api::Message *message_ case telegram_api::messageActionTopicCreate::ID: case telegram_api::messageActionTopicEdit::ID: case telegram_api::messageActionSuggestProfilePhoto::ID: - case telegram_api::messageActionAttachMenuBotAllowed::ID: break; case telegram_api::messageActionChatCreate::ID: { auto chat_create = static_cast(action); @@ -3938,4 +3937,9 @@ void UpdatesManager::on_update(tl_object_ptr update, + Promise &&promise) { + promise.set_value(Unit()); +} + } // namespace td diff --git a/td/telegram/UpdatesManager.h b/td/telegram/UpdatesManager.h index 424c2ea48..cab9a69b2 100644 --- a/td/telegram/UpdatesManager.h +++ b/td/telegram/UpdatesManager.h @@ -589,6 +589,8 @@ class UpdatesManager final : public Actor { void on_update(tl_object_ptr update, Promise &&promise); // unsupported updates + + void on_update(tl_object_ptr update, Promise &&promise); }; } // namespace td diff --git a/td/telegram/Version.h b/td/telegram/Version.h index 03ebd4373..c9b4d4732 100644 --- a/td/telegram/Version.h +++ b/td/telegram/Version.h @@ -10,7 +10,7 @@ namespace td { -constexpr int32 MTPROTO_LAYER = 152; +constexpr int32 MTPROTO_LAYER = 154; enum class Version : int32 { Initial, // 0