From 3918e131e3ad45f2a7f33a01009cfd040af6877e Mon Sep 17 00:00:00 2001 From: levlam Date: Wed, 7 Aug 2024 17:16:05 +0300 Subject: [PATCH] Add and use ChatReactions::ignore_non_paid_reaction_types. --- td/telegram/ChatReactions.cpp | 6 ++++++ td/telegram/ChatReactions.h | 2 ++ td/telegram/MessagesManager.cpp | 4 +++- td/telegram/ReactionManager.cpp | 3 ++- 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/td/telegram/ChatReactions.cpp b/td/telegram/ChatReactions.cpp index 8e175a9d1..644602e8d 100644 --- a/td/telegram/ChatReactions.cpp +++ b/td/telegram/ChatReactions.cpp @@ -124,6 +124,12 @@ telegram_api::object_ptr ChatReactions::get_input_c return telegram_api::make_object(); } +void ChatReactions::ignore_non_paid_reaction_types() { + reaction_types_.clear(); + allow_all_regular_ = false; + allow_all_custom_ = false; +} + bool operator==(const ChatReactions &lhs, const ChatReactions &rhs) { // don't compare allow_all_custom_ return lhs.reaction_types_ == rhs.reaction_types_ && lhs.allow_all_regular_ == rhs.allow_all_regular_ && diff --git a/td/telegram/ChatReactions.h b/td/telegram/ChatReactions.h index f11a49921..f1ed0aea6 100644 --- a/td/telegram/ChatReactions.h +++ b/td/telegram/ChatReactions.h @@ -55,6 +55,8 @@ struct ChatReactions { return reaction_types_.empty() && !allow_all_regular_ && !paid_reactions_available_; } + void ignore_non_paid_reaction_types(); + bool remove_paid_reactions(); template diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index 26cb4cbcd..e38389fa8 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -22650,8 +22650,10 @@ ChatReactions MessagesManager::get_message_available_reactions(const Dialog *d, bool can_add_new_reactions = m->reactions == nullptr || m->reactions->get_non_paid_reaction_count() < reactions_uniq_max; - if (!can_use_reactions || !can_add_new_reactions) { + if (!can_use_reactions) { active_reactions = ChatReactions(); + } else if (!can_add_new_reactions) { + active_reactions.ignore_non_paid_reaction_types(); } if (active_reactions.allow_all_regular_) { diff --git a/td/telegram/ReactionManager.cpp b/td/telegram/ReactionManager.cpp index aae9c43eb..cdf815940 100644 --- a/td/telegram/ReactionManager.cpp +++ b/td/telegram/ReactionManager.cpp @@ -551,7 +551,8 @@ td_api::object_ptr ReactionManager::get_sorted_avail top_reactions = get_reaction_list(ReactionListType::Top).reaction_types_; } LOG(INFO) << "Have available reactions " << available_reactions << " to be sorted by top reactions " << top_reactions - << " and recent reactions " << recent_reactions; + << " and recent reactions " << recent_reactions + << " and paid reaction = " << available_reactions.paid_reactions_available_; if (active_reactions.allow_all_custom_ && active_reactions.allow_all_regular_) { for (auto &reaction_type : recent_reactions) { if (reaction_type.is_custom_reaction()) {