Add accent color support for sponsored messages.
This commit is contained in:
parent
654da1d30e
commit
636fee9aaf
@ -1561,8 +1561,10 @@ messageSponsor url:string photo:photo info:string = MessageSponsor;
|
|||||||
//@sponsor Information about the sponsor of the message
|
//@sponsor Information about the sponsor of the message
|
||||||
//@title Title of the sponsored message
|
//@title Title of the sponsored message
|
||||||
//@button_text Text for the message action button
|
//@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
|
//@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
|
//@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<sponsoredMessage> messages_between:int32 = SponsoredMessages;
|
sponsoredMessages messages:vector<sponsoredMessage> messages_between:int32 = SponsoredMessages;
|
||||||
|
@ -15,9 +15,11 @@
|
|||||||
#include "td/telegram/MessageSelfDestructType.h"
|
#include "td/telegram/MessageSelfDestructType.h"
|
||||||
#include "td/telegram/net/NetQueryCreator.h"
|
#include "td/telegram/net/NetQueryCreator.h"
|
||||||
#include "td/telegram/OptionManager.h"
|
#include "td/telegram/OptionManager.h"
|
||||||
|
#include "td/telegram/PeerColor.h"
|
||||||
#include "td/telegram/Photo.h"
|
#include "td/telegram/Photo.h"
|
||||||
#include "td/telegram/Td.h"
|
#include "td/telegram/Td.h"
|
||||||
#include "td/telegram/telegram_api.h"
|
#include "td/telegram/telegram_api.h"
|
||||||
|
#include "td/telegram/ThemeManager.h"
|
||||||
#include "td/telegram/UserId.h"
|
#include "td/telegram/UserId.h"
|
||||||
#include "td/telegram/UserManager.h"
|
#include "td/telegram/UserManager.h"
|
||||||
|
|
||||||
@ -195,11 +197,12 @@ struct SponsoredMessageManager::SponsoredMessage {
|
|||||||
Photo photo;
|
Photo photo;
|
||||||
string title;
|
string title;
|
||||||
string button_text;
|
string button_text;
|
||||||
|
PeerColor peer_color;
|
||||||
string sponsor_info;
|
string sponsor_info;
|
||||||
string additional_info;
|
string additional_info;
|
||||||
|
|
||||||
SponsoredMessage(int64 local_id, bool is_recommended, bool can_be_reported, unique_ptr<MessageContent> content,
|
SponsoredMessage(int64 local_id, bool is_recommended, bool can_be_reported, unique_ptr<MessageContent> 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)
|
string additional_info)
|
||||||
: local_id(local_id)
|
: local_id(local_id)
|
||||||
, is_recommended(is_recommended)
|
, is_recommended(is_recommended)
|
||||||
@ -209,6 +212,7 @@ struct SponsoredMessageManager::SponsoredMessage {
|
|||||||
, photo(std::move(photo))
|
, photo(std::move(photo))
|
||||||
, title(std::move(title))
|
, title(std::move(title))
|
||||||
, button_text(std::move(button_text))
|
, button_text(std::move(button_text))
|
||||||
|
, peer_color(std::move(peer_color))
|
||||||
, sponsor_info(std::move(sponsor_info))
|
, sponsor_info(std::move(sponsor_info))
|
||||||
, additional_info(std::move(additional_info)) {
|
, additional_info(std::move(additional_info)) {
|
||||||
}
|
}
|
||||||
@ -277,7 +281,9 @@ td_api::object_ptr<td_api::sponsoredMessage> SponsoredMessageManager::get_sponso
|
|||||||
return td_api::make_object<td_api::sponsoredMessage>(
|
return td_api::make_object<td_api::sponsoredMessage>(
|
||||||
sponsored_message.local_id, sponsored_message.is_recommended, sponsored_message.can_be_reported,
|
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),
|
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<td_api::sponsoredMessages> SponsoredMessageManager::get_sponsored_messages_object(
|
td_api::object_ptr<td_api::sponsoredMessages> 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,
|
std::move(sponsored_message->entities_), true, true, 0, false,
|
||||||
"on_get_dialog_sponsored_messages");
|
"on_get_dialog_sponsored_messages");
|
||||||
MessageSelfDestructType ttl;
|
MessageSelfDestructType ttl;
|
||||||
auto content = get_message_content(td_, std::move(message_text), nullptr, DialogId(), G()->unix_time(),
|
auto content = get_message_content(td_, std::move(message_text), nullptr, DialogId(), G()->unix_time(), true,
|
||||||
true, UserId(), &ttl, nullptr, "on_get_dialog_sponsored_messages");
|
UserId(), &ttl, nullptr, "on_get_dialog_sponsored_messages");
|
||||||
if (!ttl.is_empty()) {
|
if (!ttl.is_empty()) {
|
||||||
LOG(ERROR) << "Receive sponsored message with " << ttl;
|
LOG(ERROR) << "Receive sponsored message with " << ttl;
|
||||||
continue;
|
continue;
|
||||||
@ -380,8 +386,8 @@ void SponsoredMessageManager::on_get_dialog_sponsored_messages(
|
|||||||
messages->messages.emplace_back(
|
messages->messages.emplace_back(
|
||||||
local_id, sponsored_message->recommended_, sponsored_message->can_report_, std::move(content),
|
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->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->button_text_), PeerColor(sponsored_message->color_),
|
||||||
std::move(sponsored_message->additional_info_));
|
std::move(sponsored_message->sponsor_info_), std::move(sponsored_message->additional_info_));
|
||||||
}
|
}
|
||||||
messages->messages_between = sponsored_messages->posts_between_;
|
messages->messages_between = sponsored_messages->posts_between_;
|
||||||
break;
|
break;
|
||||||
|
@ -678,9 +678,8 @@ string ThemeManager::get_theme_parameters_json_string(const td_api::object_ptr<t
|
|||||||
|
|
||||||
int32 ThemeManager::get_accent_color_id_object(AccentColorId accent_color_id,
|
int32 ThemeManager::get_accent_color_id_object(AccentColorId accent_color_id,
|
||||||
AccentColorId fallback_accent_color_id) const {
|
AccentColorId fallback_accent_color_id) const {
|
||||||
CHECK(accent_color_id.is_valid());
|
if (accent_color_id.is_valid() && (td_->auth_manager_->is_bot() || accent_color_id.is_built_in() ||
|
||||||
if (td_->auth_manager_->is_bot() || accent_color_id.is_built_in() ||
|
accent_colors_.light_colors_.count(accent_color_id) != 0)) {
|
||||||
accent_colors_.light_colors_.count(accent_color_id) != 0) {
|
|
||||||
return accent_color_id.get();
|
return accent_color_id.get();
|
||||||
}
|
}
|
||||||
if (!fallback_accent_color_id.is_valid()) {
|
if (!fallback_accent_color_id.is_valid()) {
|
||||||
|
@ -7751,13 +7751,12 @@ td_api::object_ptr<td_api::user> UserManager::get_user_object(UserId user_id, co
|
|||||||
|
|
||||||
auto emoji_status = u->last_sent_emoji_status.get_emoji_status_object();
|
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 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;
|
auto restricts_new_chats = u->contact_require_premium && !u->is_mutual_contact;
|
||||||
return td_api::make_object<td_api::user>(
|
return td_api::make_object<td_api::user>(
|
||||||
user_id.get(), u->first_name, u->last_name, u->usernames.get_usernames_object(), u->phone_number,
|
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_user_status_object(user_id, u, G()->unix_time()),
|
||||||
get_profile_photo_object(td_->file_manager_.get(), u->photo),
|
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(),
|
u->background_custom_emoji_id.get(),
|
||||||
td_->theme_manager_->get_profile_accent_color_id_object(u->profile_accent_color_id),
|
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,
|
u->profile_background_custom_emoji_id.get(), std::move(emoji_status), u->is_contact, u->is_mutual_contact,
|
||||||
|
@ -2219,9 +2219,7 @@ unique_ptr<WebPageBlock> get_web_page_block(Td *td, tl_object_ptr<telegram_api::
|
|||||||
std::move(channel->title_),
|
std::move(channel->title_),
|
||||||
get_dialog_photo(td->file_manager_.get(), DialogId(channel_id),
|
get_dialog_photo(td->file_manager_.get(), DialogId(channel_id),
|
||||||
has_access_hash ? channel->access_hash_ : 0, std::move(channel->photo_)),
|
has_access_hash ? channel->access_hash_ : 0, std::move(channel->photo_)),
|
||||||
std::move(channel->username_),
|
std::move(channel->username_), peer_color.accent_color_id_, channel_id);
|
||||||
peer_color.accent_color_id_.is_valid() ? peer_color.accent_color_id_ : AccentColorId(channel_id),
|
|
||||||
channel_id);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
LOG(ERROR) << "Receive wrong channel " << to_string(page_block->channel_);
|
LOG(ERROR) << "Receive wrong channel " << to_string(page_block->channel_);
|
||||||
|
Loading…
Reference in New Issue
Block a user