// // Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2024 // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // #pragma once #include "td/telegram/td_api.h" #include "td/telegram/telegram_api.h" #include "td/utils/common.h" #include "td/utils/FlatHashMap.h" #include "td/utils/HashTableUtils.h" #include "td/utils/StringBuilder.h" namespace td { struct ReactionTypeHash; class ReactionType { string reaction_; friend bool operator<(const ReactionType &lhs, const ReactionType &rhs); friend bool operator==(const ReactionType &lhs, const ReactionType &rhs); friend StringBuilder &operator<<(StringBuilder &string_builder, const ReactionType &reaction_type); friend struct ReactionTypeHash; public: ReactionType() = default; explicit ReactionType(string &&emoji); explicit ReactionType(const telegram_api::object_ptr &reaction); explicit ReactionType(const td_api::object_ptr &type); static ReactionType paid(); static vector get_reaction_types( const vector> &reactions); static vector get_reaction_types(const vector> &reactions); static vector> get_input_reactions( const vector &reaction_types); static vector> get_reaction_types_object( const vector &reaction_types, bool paid_reactions_available); telegram_api::object_ptr get_input_reaction() const; td_api::object_ptr get_reaction_type_object() const; td_api::object_ptr get_update_default_reaction_type() const; uint64 get_hash() const; bool is_custom_reaction() const; bool is_paid_reaction() const; bool is_active_reaction(const FlatHashMap &active_reaction_pos) const; bool is_empty() const { return reaction_.empty(); } const string &get_string() const { return reaction_; } template void store(StorerT &storer) const; template void parse(ParserT &parser); }; struct ReactionTypeHash { uint32 operator()(const ReactionType &reaction_type) const { return Hash()(reaction_type.reaction_); } }; bool operator<(const ReactionType &lhs, const ReactionType &rhs); bool operator==(const ReactionType &lhs, const ReactionType &rhs); inline bool operator!=(const ReactionType &lhs, const ReactionType &rhs) { return !(lhs == rhs); } StringBuilder &operator<<(StringBuilder &string_builder, const ReactionType &reaction_type); int64 get_reaction_types_hash(const vector &reaction_types); } // namespace td