// // Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022 // // 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/telegram/UserId.h" #include "td/utils/common.h" #include "td/utils/StringBuilder.h" namespace td { class Td; class MessageReaction { string reaction_; int32 choose_count_ = 0; bool is_chosen_ = false; vector recent_chooser_user_ids_; friend bool operator==(const MessageReaction &lhs, const MessageReaction &rhs); friend StringBuilder &operator<<(StringBuilder &string_builder, const MessageReaction &message_reaction); public: static constexpr size_t MAX_RECENT_CHOOSERS = 3; static constexpr int32 MAX_CHOOSE_COUNT = 2147483640; MessageReaction() = default; MessageReaction(string &&reaction, int32 choose_count, bool is_chosen, vector &&recent_chooser_user_ids) : reaction_(std::move(reaction)) , choose_count_(choose_count) , is_chosen_(is_chosen) , recent_chooser_user_ids_(std::move(recent_chooser_user_ids)) { } bool is_empty() const { return choose_count_ <= 0; } const string &get_reaction() const { return reaction_; } bool is_chosen() const { return is_chosen_; } void set_is_chosen(bool is_chosen) { is_chosen_ = is_chosen; } const vector &get_recent_chooser_user_ids() const { return recent_chooser_user_ids_; } td_api::object_ptr get_message_reaction_object(Td *td) const; template void store(StorerT &storer) const; template void parse(ParserT &parser); }; bool operator==(const MessageReaction &lhs, const MessageReaction &rhs); inline bool operator!=(const MessageReaction &lhs, const MessageReaction &rhs) { return !(lhs == rhs); } StringBuilder &operator<<(StringBuilder &string_builder, const MessageReaction &message_reaction); struct MessageReactions { vector reactions_; bool is_min_ = false; bool need_polling_ = true; bool can_see_all_choosers_ = false; bool has_pending_reaction_ = false; string old_chosen_reaction_; MessageReactions() = default; static unique_ptr get_message_reactions(Td *td, tl_object_ptr &&reactions, bool is_bot); void update_from(const MessageReactions &old_reactions); static bool need_update_message_reactions(const MessageReactions *old_reactions, const MessageReactions *new_reactions); template void store(StorerT &storer) const; template void parse(ParserT &parser); }; } // namespace td