diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index cc5719aa1..78897c876 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -1561,8 +1561,10 @@ messageSponsor url:string photo:photo info:string = MessageSponsor; //@sponsor Information about the sponsor of the message //@title Title of the sponsored message //@button_text Text for the message action button +//@accent_color_id Identifier of the accent color for title, button text and message background +//@background_custom_emoji_id Identifier of a custom emoji to be shown on the message background; 0 if none //@additional_info If non-empty, additional information about the sponsored message to be shown along with the message -sponsoredMessage message_id:int53 is_recommended:Bool can_be_reported:Bool content:MessageContent sponsor:messageSponsor title:string button_text:string additional_info:string = SponsoredMessage; +sponsoredMessage message_id:int53 is_recommended:Bool can_be_reported:Bool content:MessageContent sponsor:messageSponsor title:string button_text:string accent_color_id:int32 background_custom_emoji_id:int64 additional_info:string = SponsoredMessage; //@description Contains a list of sponsored messages @messages List of sponsored messages @messages_between The minimum number of messages between shown sponsored messages, or 0 if only one sponsored message must be shown after all ordinary messages sponsoredMessages messages:vector messages_between:int32 = SponsoredMessages; diff --git a/td/telegram/SponsoredMessageManager.cpp b/td/telegram/SponsoredMessageManager.cpp index b4737d05b..98550a893 100644 --- a/td/telegram/SponsoredMessageManager.cpp +++ b/td/telegram/SponsoredMessageManager.cpp @@ -15,9 +15,11 @@ #include "td/telegram/MessageSelfDestructType.h" #include "td/telegram/net/NetQueryCreator.h" #include "td/telegram/OptionManager.h" +#include "td/telegram/PeerColor.h" #include "td/telegram/Photo.h" #include "td/telegram/Td.h" #include "td/telegram/telegram_api.h" +#include "td/telegram/ThemeManager.h" #include "td/telegram/UserId.h" #include "td/telegram/UserManager.h" @@ -195,11 +197,12 @@ struct SponsoredMessageManager::SponsoredMessage { Photo photo; string title; string button_text; + PeerColor peer_color; string sponsor_info; string additional_info; SponsoredMessage(int64 local_id, bool is_recommended, bool can_be_reported, unique_ptr content, - string url, Photo photo, string title, string button_text, string sponsor_info, + string url, Photo photo, string title, string button_text, PeerColor peer_color, string sponsor_info, string additional_info) : local_id(local_id) , is_recommended(is_recommended) @@ -209,6 +212,7 @@ struct SponsoredMessageManager::SponsoredMessage { , photo(std::move(photo)) , title(std::move(title)) , button_text(std::move(button_text)) + , peer_color(std::move(peer_color)) , sponsor_info(std::move(sponsor_info)) , additional_info(std::move(additional_info)) { } @@ -277,7 +281,9 @@ td_api::object_ptr SponsoredMessageManager::get_sponso return td_api::make_object( sponsored_message.local_id, sponsored_message.is_recommended, sponsored_message.can_be_reported, get_message_content_object(sponsored_message.content.get(), td_, dialog_id, 0, false, true, -1, false, false), - std::move(sponsor), sponsored_message.title, sponsored_message.button_text, sponsored_message.additional_info); + std::move(sponsor), sponsored_message.title, sponsored_message.button_text, + td_->theme_manager_->get_accent_color_id_object(sponsored_message.peer_color.accent_color_id_, AccentColorId()), + sponsored_message.peer_color.background_custom_emoji_id_.get(), sponsored_message.additional_info); } td_api::object_ptr SponsoredMessageManager::get_sponsored_messages_object( @@ -357,8 +363,8 @@ void SponsoredMessageManager::on_get_dialog_sponsored_messages( std::move(sponsored_message->entities_), true, true, 0, false, "on_get_dialog_sponsored_messages"); MessageSelfDestructType ttl; - auto content = get_message_content(td_, std::move(message_text), nullptr, DialogId(), G()->unix_time(), - true, UserId(), &ttl, nullptr, "on_get_dialog_sponsored_messages"); + auto content = get_message_content(td_, std::move(message_text), nullptr, DialogId(), G()->unix_time(), true, + UserId(), &ttl, nullptr, "on_get_dialog_sponsored_messages"); if (!ttl.is_empty()) { LOG(ERROR) << "Receive sponsored message with " << ttl; continue; @@ -380,8 +386,8 @@ void SponsoredMessageManager::on_get_dialog_sponsored_messages( messages->messages.emplace_back( local_id, sponsored_message->recommended_, sponsored_message->can_report_, std::move(content), std::move(sponsored_message->url_), std::move(photo), std::move(sponsored_message->title_), - std::move(sponsored_message->button_text_), std::move(sponsored_message->sponsor_info_), - std::move(sponsored_message->additional_info_)); + std::move(sponsored_message->button_text_), PeerColor(sponsored_message->color_), + std::move(sponsored_message->sponsor_info_), std::move(sponsored_message->additional_info_)); } messages->messages_between = sponsored_messages->posts_between_; break; diff --git a/td/telegram/ThemeManager.cpp b/td/telegram/ThemeManager.cpp index ee5a934e2..da1f571e0 100644 --- a/td/telegram/ThemeManager.cpp +++ b/td/telegram/ThemeManager.cpp @@ -678,9 +678,8 @@ string ThemeManager::get_theme_parameters_json_string(const td_api::object_ptrauth_manager_->is_bot() || accent_color_id.is_built_in() || - accent_colors_.light_colors_.count(accent_color_id) != 0) { + if (accent_color_id.is_valid() && (td_->auth_manager_->is_bot() || accent_color_id.is_built_in() || + accent_colors_.light_colors_.count(accent_color_id) != 0)) { return accent_color_id.get(); } if (!fallback_accent_color_id.is_valid()) { diff --git a/td/telegram/UserManager.cpp b/td/telegram/UserManager.cpp index 2745371e5..abf8cc1a4 100644 --- a/td/telegram/UserManager.cpp +++ b/td/telegram/UserManager.cpp @@ -7751,13 +7751,12 @@ td_api::object_ptr UserManager::get_user_object(UserId user_id, co auto emoji_status = u->last_sent_emoji_status.get_emoji_status_object(); auto have_access = user_id == get_my_id() || have_input_peer_user(u, user_id, AccessRights::Know); - auto accent_color_id = u->accent_color_id.is_valid() ? u->accent_color_id : AccentColorId(user_id); auto restricts_new_chats = u->contact_require_premium && !u->is_mutual_contact; return td_api::make_object( user_id.get(), u->first_name, u->last_name, u->usernames.get_usernames_object(), u->phone_number, get_user_status_object(user_id, u, G()->unix_time()), get_profile_photo_object(td_->file_manager_.get(), u->photo), - td_->theme_manager_->get_accent_color_id_object(accent_color_id, AccentColorId(user_id)), + td_->theme_manager_->get_accent_color_id_object(u->accent_color_id, AccentColorId(user_id)), u->background_custom_emoji_id.get(), td_->theme_manager_->get_profile_accent_color_id_object(u->profile_accent_color_id), u->profile_background_custom_emoji_id.get(), std::move(emoji_status), u->is_contact, u->is_mutual_contact, diff --git a/td/telegram/WebPageBlock.cpp b/td/telegram/WebPageBlock.cpp index 0fd54513d..50cb3fb25 100644 --- a/td/telegram/WebPageBlock.cpp +++ b/td/telegram/WebPageBlock.cpp @@ -2219,9 +2219,7 @@ unique_ptr get_web_page_block(Td *td, tl_object_ptrtitle_), get_dialog_photo(td->file_manager_.get(), DialogId(channel_id), has_access_hash ? channel->access_hash_ : 0, std::move(channel->photo_)), - std::move(channel->username_), - peer_color.accent_color_id_.is_valid() ? peer_color.accent_color_id_ : AccentColorId(channel_id), - channel_id); + std::move(channel->username_), peer_color.accent_color_id_, channel_id); } } else { LOG(ERROR) << "Receive wrong channel " << to_string(page_block->channel_);