Add ContactsManager::can_use_premium_custom_emoji.

This commit is contained in:
levlam 2023-10-17 01:25:58 +03:00
parent cc08225d30
commit e556ed04a0
3 changed files with 15 additions and 2 deletions

View File

@ -5931,6 +5931,17 @@ FolderId ContactsManager::get_secret_chat_initial_folder_id(SecretChatId secret_
return c->initial_folder_id; return c->initial_folder_id;
} }
bool ContactsManager::can_use_premium_custom_emoji() const {
if (td_->option_manager_->get_option_boolean("is_premium")) {
return true;
}
if (!td_->auth_manager_->is_bot()) {
return false;
}
const User *u = get_user(get_my_id());
return u == nullptr || u->usernames.get_active_usernames().size() > (u->usernames.has_editable_username() ? 1u : 0u);
}
UserId ContactsManager::get_my_id() const { UserId ContactsManager::get_my_id() const {
LOG_IF(ERROR, !my_id_.is_valid()) << "Wrong or unknown my ID returned"; LOG_IF(ERROR, !my_id_.is_valid()) << "Wrong or unknown my ID returned";
return my_id_; return my_id_;

View File

@ -290,6 +290,8 @@ class ContactsManager final : public Actor {
void unregister_message_channels(MessageFullId message_full_id, vector<ChannelId> channel_ids); void unregister_message_channels(MessageFullId message_full_id, vector<ChannelId> channel_ids);
bool can_use_premium_custom_emoji() const;
UserId get_my_id() const; UserId get_my_id() const;
void set_my_online_status(bool is_online, bool send_update, bool is_local); void set_my_online_status(bool is_online, bool send_update, bool is_local);

View File

@ -4531,8 +4531,8 @@ void remove_unallowed_entities(const Td *td, FormattedText &text, DialogId dialo
remove_intersecting_entities(text.entities); remove_intersecting_entities(text.entities);
} }
} }
if (!td->option_manager_->get_option_boolean("is_premium") && if (dialog_id != DialogId(td->contacts_manager_->get_my_id()) &&
dialog_id != DialogId(td->contacts_manager_->get_my_id())) { !td->contacts_manager_->can_use_premium_custom_emoji()) {
remove_premium_custom_emoji_entities(td, text.entities, false); remove_premium_custom_emoji_entities(td, text.entities, false);
} }
} }