From 0d2a6ccf14c547f0ae35ef0e19602bc307766641 Mon Sep 17 00:00:00 2001 From: levlam Date: Tue, 23 Apr 2024 22:32:18 +0300 Subject: [PATCH] Add userFullInfo.has_sponsored_messages_enabled. --- td/generate/scheme/td_api.tl | 3 ++- td/telegram/UserManager.cpp | 12 +++++++++--- td/telegram/UserManager.h | 1 + 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 7355a3940..2ec0e268b 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -954,6 +954,7 @@ botInfo short_description:string description:string photo:photo animation:animat //@has_private_forwards True, if the user can't be linked in forwarded messages due to their privacy settings //@has_restricted_voice_and_video_note_messages True, if voice and video notes can't be sent or forwarded to the user //@has_pinned_stories True, if the user has pinned stories +//@has_sponsored_messages_enabled True, if the user always enabled sponsored messages; known only for the current user //@need_phone_number_privacy_exception True, if the current user needs to explicitly allow to share their phone number with the user when the method addContact is used //@set_chat_background True, if the user set chat background for both chat users and it wasn't reverted yet //@bio A short user bio; may be null for bots @@ -963,7 +964,7 @@ botInfo short_description:string description:string photo:photo animation:animat //@group_in_common_count Number of group chats where both the other user and the current user are a member; 0 for the current user //@business_info Information about business settings for Telegram Business accounts; may be null if none //@bot_info For bots, information about the bot; may be null if the user isn't a bot -userFullInfo personal_photo:chatPhoto photo:chatPhoto public_photo:chatPhoto block_list:BlockList can_be_called:Bool supports_video_calls:Bool has_private_calls:Bool has_private_forwards:Bool has_restricted_voice_and_video_note_messages:Bool has_pinned_stories:Bool need_phone_number_privacy_exception:Bool set_chat_background:Bool bio:formattedText birthdate:birthdate personal_chat_id:int53 premium_gift_options:vector group_in_common_count:int32 business_info:businessInfo bot_info:botInfo = UserFullInfo; +userFullInfo personal_photo:chatPhoto photo:chatPhoto public_photo:chatPhoto block_list:BlockList can_be_called:Bool supports_video_calls:Bool has_private_calls:Bool has_private_forwards:Bool has_restricted_voice_and_video_note_messages:Bool has_pinned_stories:Bool has_sponsored_messages_enabled:Bool need_phone_number_privacy_exception:Bool set_chat_background:Bool bio:formattedText birthdate:birthdate personal_chat_id:int53 premium_gift_options:vector group_in_common_count:int32 business_info:businessInfo bot_info:botInfo = UserFullInfo; //@description Represents a list of users @total_count Approximate total number of users found @user_ids A list of user identifiers users total_count:int32 user_ids:vector = Users; diff --git a/td/telegram/UserManager.cpp b/td/telegram/UserManager.cpp index abf8cc1a4..5595554b9 100644 --- a/td/telegram/UserManager.cpp +++ b/td/telegram/UserManager.cpp @@ -1641,6 +1641,7 @@ void UserManager::UserFull::store(StorerT &storer) const { STORE_FLAG(has_business_info); // 25 STORE_FLAG(has_birthdate); STORE_FLAG(has_personal_channel_id); + STORE_FLAG(sponsored_enabled); END_STORE_FLAGS(); if (has_about) { store(about, storer); @@ -1743,6 +1744,7 @@ void UserManager::UserFull::parse(ParserT &parser) { PARSE_FLAG(has_business_info); PARSE_FLAG(has_birthdate); PARSE_FLAG(has_personal_channel_id); + PARSE_FLAG(sponsored_enabled); END_PARSE_FLAGS(); if (has_about) { parse(about, parser); @@ -6729,13 +6731,15 @@ void UserManager::on_get_user_full(telegram_api::object_ptrstories_pinned_available_; auto birthdate = Birthdate(std::move(user->birthday_)); auto personal_channel_id = ChannelId(user->personal_channel_id_); + auto sponsored_enabled = user->sponsored_enabled_; if (user_full->can_be_called != can_be_called || user_full->supports_video_calls != supports_video_calls || user_full->has_private_calls != has_private_calls || user_full->group_administrator_rights != group_administrator_rights || user_full->broadcast_administrator_rights != broadcast_administrator_rights || user_full->premium_gift_options != premium_gift_options || user_full->voice_messages_forbidden != voice_messages_forbidden || - user_full->can_pin_messages != can_pin_messages || user_full->has_pinned_stories != has_pinned_stories) { + user_full->can_pin_messages != can_pin_messages || user_full->has_pinned_stories != has_pinned_stories || + user_full->sponsored_enabled != sponsored_enabled) { user_full->can_be_called = can_be_called; user_full->supports_video_calls = supports_video_calls; user_full->has_private_calls = has_private_calls; @@ -6745,6 +6749,7 @@ void UserManager::on_get_user_full(telegram_api::object_ptrvoice_messages_forbidden = voice_messages_forbidden; user_full->can_pin_messages = can_pin_messages; user_full->has_pinned_stories = has_pinned_stories; + user_full->sponsored_enabled = sponsored_enabled; user_full->is_changed = true; } @@ -7071,6 +7076,7 @@ void UserManager::drop_user_full(UserId user_id) { user_full->read_dates_private = false; user_full->contact_require_premium = false; user_full->birthdate = {}; + user_full->sponsored_enabled = false; user_full->is_changed = true; update_user_full(user_full, user_id, "drop_user_full"); @@ -7852,8 +7858,8 @@ td_api::object_ptr UserManager::get_user_full_info_object( get_chat_photo_object(td_->file_manager_.get(), user_full->fallback_photo), block_list_id.get_block_list_object(), user_full->can_be_called, user_full->supports_video_calls, user_full->has_private_calls, !user_full->private_forward_name.empty(), voice_messages_forbidden, user_full->has_pinned_stories, - user_full->need_phone_number_privacy_exception, user_full->wallpaper_overridden, std::move(bio_object), - user_full->birthdate.get_birthdate_object(), personal_chat_id, + user_full->sponsored_enabled, user_full->need_phone_number_privacy_exception, user_full->wallpaper_overridden, + std::move(bio_object), user_full->birthdate.get_birthdate_object(), personal_chat_id, get_premium_payment_options_object(user_full->premium_gift_options), user_full->common_chat_count, std::move(business_info), std::move(bot_info)); } diff --git a/td/telegram/UserManager.h b/td/telegram/UserManager.h index e7befda63..4284a129d 100644 --- a/td/telegram/UserManager.h +++ b/td/telegram/UserManager.h @@ -598,6 +598,7 @@ class UserManager final : public Actor { bool has_pinned_stories = false; bool read_dates_private = false; bool contact_require_premium = false; + bool sponsored_enabled = false; bool is_common_chat_count_changed = true; bool is_being_updated = false;