diff --git a/td/telegram/ChatReactions.cpp b/td/telegram/ChatReactions.cpp index ac2c6370e..879be05f3 100644 --- a/td/telegram/ChatReactions.cpp +++ b/td/telegram/ChatReactions.cpp @@ -19,8 +19,8 @@ ChatReactions::ChatReactions(telegram_api::object_ptr(chat_reactions_ptr); - allow_all_ = true; - allow_custom_ = chat_reactions->allow_custom_; + allow_all_regular_ = true; + allow_all_custom_ = chat_reactions->allow_custom_; break; } case telegram_api::chatReactionsSome::ID: { @@ -36,14 +36,14 @@ ChatReactions::ChatReactions(telegram_api::object_ptr &&chat_reactions_ptr, - bool allow_custom) { + bool allow_all_custom) { if (chat_reactions_ptr == nullptr) { return; } switch (chat_reactions_ptr->get_id()) { case td_api::chatAvailableReactionsAll::ID: - allow_all_ = true; - allow_custom_ = allow_custom; + allow_all_regular_ = true; + allow_all_custom_ = allow_all_custom; break; case td_api::chatAvailableReactionsSome::ID: { auto chat_reactions = move_tl_object_as(chat_reactions_ptr); @@ -61,8 +61,8 @@ ChatReactions ChatReactions::get_active_reactions( const FlatHashMap &active_reaction_pos) const { ChatReactions result = *this; if (!reaction_types_.empty()) { - CHECK(!allow_all_); - CHECK(!allow_custom_); + CHECK(!allow_all_regular_); + CHECK(!allow_all_custom_); td::remove_if(result.reaction_types_, [&](const ReactionType &reaction_type) { return !reaction_type.is_active_reaction(active_reaction_pos); }); @@ -71,15 +71,15 @@ ChatReactions ChatReactions::get_active_reactions( } bool ChatReactions::is_allowed_reaction_type(const ReactionType &reaction_type) const { - CHECK(!allow_all_); - if (allow_custom_ && reaction_type.is_custom_reaction()) { + CHECK(!allow_all_regular_); + if (allow_all_custom_ && reaction_type.is_custom_reaction()) { return true; } return td::contains(reaction_types_, reaction_type); } td_api::object_ptr ChatReactions::get_chat_available_reactions_object() const { - if (allow_all_) { + if (allow_all_regular_) { return td_api::make_object(); } return td_api::make_object(transform( @@ -87,12 +87,12 @@ td_api::object_ptr ChatReactions::get_chat_avail } telegram_api::object_ptr ChatReactions::get_input_chat_reactions() const { - if (allow_all_) { + if (allow_all_regular_) { int32 flags = 0; - if (allow_custom_) { + if (allow_all_custom_) { flags |= telegram_api::chatReactionsAll::ALLOW_CUSTOM_MASK; } - return telegram_api::make_object(flags, allow_custom_); + return telegram_api::make_object(flags, allow_all_custom_); } if (!reaction_types_.empty()) { return telegram_api::make_object(transform( @@ -102,13 +102,13 @@ telegram_api::object_ptr ChatReactions::get_input_c } bool operator==(const ChatReactions &lhs, const ChatReactions &rhs) { - // don't compare allow_custom_ - return lhs.reaction_types_ == rhs.reaction_types_ && lhs.allow_all_ == rhs.allow_all_; + // don't compare allow_all_custom_ + return lhs.reaction_types_ == rhs.reaction_types_ && lhs.allow_all_regular_ == rhs.allow_all_regular_; } StringBuilder &operator<<(StringBuilder &string_builder, const ChatReactions &reactions) { - if (reactions.allow_all_) { - if (reactions.allow_custom_) { + if (reactions.allow_all_regular_) { + if (reactions.allow_all_custom_) { return string_builder << "AllReactions"; } return string_builder << "AllRegularReactions"; diff --git a/td/telegram/ChatReactions.h b/td/telegram/ChatReactions.h index d0ebe7703..eeea67243 100644 --- a/td/telegram/ChatReactions.h +++ b/td/telegram/ChatReactions.h @@ -18,8 +18,8 @@ namespace td { struct ChatReactions { vector reaction_types_; - bool allow_all_ = false; // implies empty reaction_types_ - bool allow_custom_ = false; // implies allow_all_ + bool allow_all_regular_ = false; // implies empty reaction_types_ + bool allow_all_custom_ = false; // implies allow_all_regular_ ChatReactions() = default; @@ -28,9 +28,10 @@ struct ChatReactions { explicit ChatReactions(telegram_api::object_ptr &&chat_reactions_ptr); - ChatReactions(td_api::object_ptr &&chat_reactions_ptr, bool allow_custom); + ChatReactions(td_api::object_ptr &&chat_reactions_ptr, bool allow_all_custom); - ChatReactions(bool allow_all, bool allow_custom) : allow_all_(allow_all), allow_custom_(allow_custom) { + ChatReactions(bool allow_all_regular, bool allow_all_custom) + : allow_all_regular_(allow_all_regular), allow_all_custom_(allow_all_custom) { } ChatReactions get_active_reactions( @@ -43,7 +44,7 @@ struct ChatReactions { td_api::object_ptr get_chat_available_reactions_object() const; bool empty() const { - return reaction_types_.empty() && !allow_all_; + return reaction_types_.empty() && !allow_all_regular_; } template diff --git a/td/telegram/ChatReactions.hpp b/td/telegram/ChatReactions.hpp index 8bae2e417..fbe5090ae 100644 --- a/td/telegram/ChatReactions.hpp +++ b/td/telegram/ChatReactions.hpp @@ -18,8 +18,8 @@ template void ChatReactions::store(StorerT &storer) const { bool has_reactions = !reaction_types_.empty(); BEGIN_STORE_FLAGS(); - STORE_FLAG(allow_all_); - STORE_FLAG(allow_custom_); + STORE_FLAG(allow_all_regular_); + STORE_FLAG(allow_all_custom_); STORE_FLAG(has_reactions); END_STORE_FLAGS(); if (has_reactions) { @@ -31,8 +31,8 @@ template void ChatReactions::parse(ParserT &parser) { bool has_reactions; BEGIN_PARSE_FLAGS(); - PARSE_FLAG(allow_all_); - PARSE_FLAG(allow_custom_); + PARSE_FLAG(allow_all_regular_); + PARSE_FLAG(allow_all_custom_); PARSE_FLAG(has_reactions); END_PARSE_FLAGS(); if (has_reactions) { diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index e23ff6467..25ba3a43f 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -23816,9 +23816,9 @@ ChatReactions MessagesManager::get_message_available_reactions(const Dialog *d, active_reactions = ChatReactions(); } - if (active_reactions.allow_all_) { + if (active_reactions.allow_all_regular_) { active_reactions.reaction_types_ = active_reaction_types_; - active_reactions.allow_all_ = false; + active_reactions.allow_all_regular_ = false; } if (can_use_reactions && m->reactions != nullptr) { for (const auto &reaction : m->reactions->reactions_) { @@ -23831,7 +23831,7 @@ ChatReactions MessagesManager::get_message_available_reactions(const Dialog *d, } } if (disallow_custom_for_non_premium && !td_->option_manager_->get_option_boolean("is_premium")) { - active_reactions.allow_custom_ = false; + active_reactions.allow_all_custom_ = false; } return active_reactions; } diff --git a/td/telegram/ReactionManager.cpp b/td/telegram/ReactionManager.cpp index f1f3f1012..017e055aa 100644 --- a/td/telegram/ReactionManager.cpp +++ b/td/telegram/ReactionManager.cpp @@ -238,7 +238,7 @@ td_api::object_ptr ReactionManager::get_sorted_avail auto top_reactions = top_reactions_.reaction_types_; LOG(INFO) << "Have available reactions " << available_reactions << " to be sorted by top reactions " << top_reactions << " and recent reactions " << recent_reactions; - if (active_reactions.allow_custom_ && active_reactions.allow_all_) { + if (active_reactions.allow_all_custom_ && active_reactions.allow_all_regular_) { for (auto &reaction_type : recent_reactions) { if (reaction_type.is_custom_reaction()) { show_premium = true; @@ -273,7 +273,7 @@ td_api::object_ptr ReactionManager::get_sorted_avail } reaction_objects.push_back( td_api::make_object(reaction_type.get_reaction_type_object(), false)); - } else if (reaction_type.is_custom_reaction() && available_reactions.allow_custom_ && + } else if (reaction_type.is_custom_reaction() && available_reactions.allow_all_custom_ && added_custom_reaction_types.insert(reaction_type).second) { // add implicitly available custom reaction reaction_objects.push_back( @@ -320,13 +320,13 @@ td_api::object_ptr ReactionManager::get_sorted_avail return td_api::make_object( std::move(top_reaction_objects), std::move(recent_reaction_objects), std::move(popular_reaction_objects), - available_reactions.allow_custom_); + available_reactions.allow_all_custom_); } td_api::object_ptr ReactionManager::get_available_reactions(int32 row_size) { ChatReactions available_reactions; available_reactions.reaction_types_ = active_reaction_types_; - available_reactions.allow_custom_ = true; + available_reactions.allow_all_custom_ = true; return get_sorted_available_reactions(std::move(available_reactions), ChatReactions(true, true), row_size); }