Never send unknown accent color identifiers to the app.
This commit is contained in:
parent
25ef762e25
commit
00a6167952
@ -59,11 +59,6 @@ class AccentColorId {
|
||||
return id != other.id;
|
||||
}
|
||||
|
||||
int32 get_accent_color_id_object() const {
|
||||
CHECK(is_valid());
|
||||
return id;
|
||||
}
|
||||
|
||||
template <class StorerT>
|
||||
void store(StorerT &storer) const {
|
||||
storer.store_int(id);
|
||||
|
@ -51,6 +51,7 @@
|
||||
#include "td/telegram/Td.h"
|
||||
#include "td/telegram/TdDb.h"
|
||||
#include "td/telegram/telegram_api.h"
|
||||
#include "td/telegram/ThemeManager.h"
|
||||
#include "td/telegram/UpdatesManager.h"
|
||||
#include "td/telegram/Version.h"
|
||||
|
||||
@ -19462,8 +19463,9 @@ td_api::object_ptr<td_api::updateUser> ContactsManager::get_update_unknown_user_
|
||||
auto have_access = user_id == get_my_id() || user_messages_.count(user_id) != 0;
|
||||
return td_api::make_object<td_api::updateUser>(td_api::make_object<td_api::user>(
|
||||
user_id.get(), "", "", nullptr, "", td_api::make_object<td_api::userStatusEmpty>(), nullptr,
|
||||
AccentColorId(user_id).get_accent_color_id_object(), 0, nullptr, false, false, false, false, false, false, "",
|
||||
false, false, false, false, have_access, td_api::make_object<td_api::userTypeUnknown>(), "", false));
|
||||
td_->theme_manager_->get_accent_color_id_object(AccentColorId(user_id)), 0, nullptr, false, false, false, false,
|
||||
false, false, "", false, false, false, false, have_access, td_api::make_object<td_api::userTypeUnknown>(), "",
|
||||
false));
|
||||
}
|
||||
|
||||
int64 ContactsManager::get_user_id_object(UserId user_id, const char *source) const {
|
||||
@ -19501,10 +19503,10 @@ tl_object_ptr<td_api::user> ContactsManager::get_user_object(UserId user_id, con
|
||||
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,
|
||||
get_user_status_object(user_id, u, G()->unix_time()),
|
||||
get_profile_photo_object(td_->file_manager_.get(), u->photo), accent_color_id.get_accent_color_id_object(),
|
||||
u->background_custom_emoji_id.get(), std::move(emoji_status), u->is_contact, u->is_mutual_contact,
|
||||
u->is_close_friend, u->is_verified, u->is_premium, u->is_support,
|
||||
get_restriction_reason_description(u->restriction_reasons), u->is_scam, u->is_fake,
|
||||
get_profile_photo_object(td_->file_manager_.get(), u->photo),
|
||||
td_->theme_manager_->get_accent_color_id_object(accent_color_id), u->background_custom_emoji_id.get(),
|
||||
std::move(emoji_status), u->is_contact, u->is_mutual_contact, u->is_close_friend, u->is_verified, u->is_premium,
|
||||
u->is_support, get_restriction_reason_description(u->restriction_reasons), u->is_scam, u->is_fake,
|
||||
u->max_active_story_id.is_valid(), get_user_has_unread_stories(u), have_access, std::move(type), u->language_code,
|
||||
u->attach_menu_enabled);
|
||||
}
|
||||
@ -19907,9 +19909,9 @@ tl_object_ptr<td_api::chatInviteLinkInfo> ContactsManager::get_chat_invite_link_
|
||||
|
||||
return td_api::make_object<td_api::chatInviteLinkInfo>(
|
||||
td_->messages_manager_->get_chat_id_object(dialog_id, "chatInviteLinkInfo"), accessible_for, std::move(chat_type),
|
||||
title, get_chat_photo_info_object(td_->file_manager_.get(), photo), accent_color_id.get_accent_color_id_object(),
|
||||
description, participant_count, std::move(member_user_ids), creates_join_request, is_public, is_verified, is_scam,
|
||||
is_fake);
|
||||
title, get_chat_photo_info_object(td_->file_manager_.get(), photo),
|
||||
td_->theme_manager_->get_accent_color_id_object(accent_color_id), description, participant_count,
|
||||
std::move(member_user_ids), creates_join_request, is_public, is_verified, is_scam, is_fake);
|
||||
}
|
||||
|
||||
void ContactsManager::get_support_user(Promise<td_api::object_ptr<td_api::user>> &&promise) {
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "td/telegram/StickersManager.h"
|
||||
#include "td/telegram/Td.h"
|
||||
#include "td/telegram/telegram_api.h"
|
||||
#include "td/telegram/ThemeManager.h"
|
||||
|
||||
#include "td/utils/buffer.h"
|
||||
#include "td/utils/logging.h"
|
||||
@ -432,8 +433,9 @@ static td_api::object_ptr<td_api::ChatEventAction> get_chat_event_action_object(
|
||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionChangeColor>(action_ptr);
|
||||
auto old_accent_color_id = AccentColorId(action->prev_value_);
|
||||
auto new_accent_color_id = AccentColorId(action->new_value_);
|
||||
return td_api::make_object<td_api::chatEventAccentColorChanged>(old_accent_color_id.get_accent_color_id_object(),
|
||||
new_accent_color_id.get_accent_color_id_object());
|
||||
return td_api::make_object<td_api::chatEventAccentColorChanged>(
|
||||
td->theme_manager_->get_accent_color_id_object(old_accent_color_id),
|
||||
td->theme_manager_->get_accent_color_id_object(new_accent_color_id));
|
||||
}
|
||||
case telegram_api::channelAdminLogEventActionChangeBackgroundEmoji::ID: {
|
||||
auto action = move_tl_object_as<telegram_api::channelAdminLogEventActionChangeBackgroundEmoji>(action_ptr);
|
||||
|
@ -74,6 +74,7 @@
|
||||
#include "td/telegram/Td.h"
|
||||
#include "td/telegram/TdDb.h"
|
||||
#include "td/telegram/telegram_api.h"
|
||||
#include "td/telegram/ThemeManager.h"
|
||||
#include "td/telegram/TopDialogCategory.h"
|
||||
#include "td/telegram/TopDialogManager.h"
|
||||
#include "td/telegram/TranslationManager.h"
|
||||
@ -20747,7 +20748,7 @@ td_api::object_ptr<td_api::chat> MessagesManager::get_chat_object(const Dialog *
|
||||
return make_tl_object<td_api::chat>(
|
||||
d->dialog_id.get(), get_chat_type_object(d->dialog_id), get_dialog_title(d->dialog_id),
|
||||
get_chat_photo_info_object(td_->file_manager_.get(), get_dialog_photo(d->dialog_id)),
|
||||
get_dialog_accent_color_id(d->dialog_id).get_accent_color_id_object(),
|
||||
td_->theme_manager_->get_accent_color_id_object(get_dialog_accent_color_id(d->dialog_id)),
|
||||
get_dialog_background_custom_emoji_id(d->dialog_id).get(),
|
||||
get_dialog_default_permissions(d->dialog_id).get_chat_permissions_object(),
|
||||
get_message_object(d->dialog_id, get_message(d, d->last_message_id), "get_chat_object"),
|
||||
@ -32437,7 +32438,7 @@ void MessagesManager::on_dialog_accent_color_id_updated(DialogId dialog_id) {
|
||||
send_closure(G()->td(), &Td::send_update,
|
||||
td_api::make_object<td_api::updateChatAccentColor>(
|
||||
get_chat_id_object(dialog_id, "updateChatAccentColor"),
|
||||
get_dialog_accent_color_id(dialog_id).get_accent_color_id_object()));
|
||||
td_->theme_manager_->get_accent_color_id_object(get_dialog_accent_color_id(dialog_id))));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -377,6 +377,14 @@ string ThemeManager::get_theme_parameters_json_string(const td_api::object_ptr<t
|
||||
}
|
||||
}
|
||||
|
||||
int32 ThemeManager::get_accent_color_id_object(AccentColorId accent_color_id) const {
|
||||
CHECK(accent_color_id.is_valid());
|
||||
if (accent_color_id.is_built_in() || accent_colors_.light_colors_.count(accent_color_id) != 0) {
|
||||
return accent_color_id.get();
|
||||
}
|
||||
return 5;
|
||||
}
|
||||
|
||||
td_api::object_ptr<td_api::themeSettings> ThemeManager::get_theme_settings_object(const ThemeSettings &settings) const {
|
||||
auto fill = [colors = settings.message_colors]() mutable -> td_api::object_ptr<td_api::BackgroundFill> {
|
||||
if (colors.size() >= 3) {
|
||||
|
@ -37,6 +37,8 @@ class ThemeManager final : public Actor {
|
||||
static string get_theme_parameters_json_string(const td_api::object_ptr<td_api::themeParameters> &theme,
|
||||
bool for_web_view);
|
||||
|
||||
int32 get_accent_color_id_object(AccentColorId accent_color_id) const;
|
||||
|
||||
void get_current_state(vector<td_api::object_ptr<td_api::Update>> &updates) const;
|
||||
|
||||
private:
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "td/telegram/PhotoFormat.h"
|
||||
#include "td/telegram/Td.h"
|
||||
#include "td/telegram/telegram_api.h"
|
||||
#include "td/telegram/ThemeManager.h"
|
||||
#include "td/telegram/Version.h"
|
||||
#include "td/telegram/VideosManager.h"
|
||||
#include "td/telegram/VideosManager.hpp"
|
||||
@ -1440,7 +1441,7 @@ class WebPageBlockChatLink final : public WebPageBlock {
|
||||
td_api::object_ptr<td_api::PageBlock> get_page_block_object(Context *context) const final {
|
||||
return make_tl_object<td_api::pageBlockChatLink>(
|
||||
title, get_chat_photo_info_object(context->td_->file_manager_.get(), &photo),
|
||||
accent_color_id.get_accent_color_id_object(), username);
|
||||
context->td_->theme_manager_->get_accent_color_id_object(accent_color_id), username);
|
||||
}
|
||||
|
||||
template <class StorerT>
|
||||
|
Loading…
Reference in New Issue
Block a user