From 0dad023262100e2d07241ef01064ae2f2ed74a18 Mon Sep 17 00:00:00 2001 From: levlam Date: Thu, 8 Feb 2024 15:09:26 +0300 Subject: [PATCH] Allow to use Premium custom emoji from group emoji set in supergroups. --- td/telegram/ContactsManager.cpp | 5 ++++- td/telegram/ContactsManager.h | 2 +- td/telegram/MessageEntity.cpp | 3 ++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/td/telegram/ContactsManager.cpp b/td/telegram/ContactsManager.cpp index 7d8c48aee..887edf45d 100644 --- a/td/telegram/ContactsManager.cpp +++ b/td/telegram/ContactsManager.cpp @@ -5429,10 +5429,13 @@ FolderId ContactsManager::get_secret_chat_initial_folder_id(SecretChatId secret_ return c->initial_folder_id; } -bool ContactsManager::can_use_premium_custom_emoji() const { +bool ContactsManager::can_use_premium_custom_emoji(DialogId dialog_id) const { if (td_->option_manager_->get_option_boolean("is_premium")) { return true; } + if (dialog_id.get_type() == DialogType::Channel && is_megagroup_channel(dialog_id.get_channel_id())) { + return true; + } if (!td_->auth_manager_->is_bot()) { return false; } diff --git a/td/telegram/ContactsManager.h b/td/telegram/ContactsManager.h index cbb9db23f..734eeb0e0 100644 --- a/td/telegram/ContactsManager.h +++ b/td/telegram/ContactsManager.h @@ -316,7 +316,7 @@ class ContactsManager final : public Actor { void unregister_message_channels(MessageFullId message_full_id, vector channel_ids); - bool can_use_premium_custom_emoji() const; + bool can_use_premium_custom_emoji(DialogId dialog_id) const; UserId get_my_id() const; diff --git a/td/telegram/MessageEntity.cpp b/td/telegram/MessageEntity.cpp index e9ff7b0cf..1699bf310 100644 --- a/td/telegram/MessageEntity.cpp +++ b/td/telegram/MessageEntity.cpp @@ -4731,7 +4731,8 @@ void remove_unallowed_entities(const Td *td, FormattedText &text, DialogId dialo remove_intersecting_entities(text.entities); } } - if (dialog_id != td->dialog_manager_->get_my_dialog_id() && !td->contacts_manager_->can_use_premium_custom_emoji()) { + if (dialog_id != td->dialog_manager_->get_my_dialog_id() && + !td->contacts_manager_->can_use_premium_custom_emoji(dialog_id)) { remove_premium_custom_emoji_entities(td, text.entities, false); } }