2022-08-30 10:45:27 +02:00
|
|
|
//
|
2024-01-01 01:07:21 +01:00
|
|
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2024
|
2022-08-30 10:45:27 +02:00
|
|
|
//
|
|
|
|
// 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
|
|
|
|
|
2023-08-04 17:39:07 +02:00
|
|
|
#include "td/telegram/ReactionType.h"
|
2022-08-30 10:45:27 +02:00
|
|
|
#include "td/telegram/td_api.h"
|
|
|
|
#include "td/telegram/telegram_api.h"
|
|
|
|
|
|
|
|
#include "td/utils/common.h"
|
2022-09-08 20:04:23 +02:00
|
|
|
#include "td/utils/FlatHashMap.h"
|
2022-08-30 10:45:27 +02:00
|
|
|
#include "td/utils/StringBuilder.h"
|
|
|
|
|
|
|
|
namespace td {
|
|
|
|
|
2024-04-22 02:19:40 +02:00
|
|
|
class Td;
|
|
|
|
|
2022-08-30 10:45:27 +02:00
|
|
|
struct ChatReactions {
|
2023-08-04 17:39:07 +02:00
|
|
|
vector<ReactionType> reaction_types_;
|
2023-11-19 00:03:19 +01:00
|
|
|
bool allow_all_regular_ = false; // implies empty reaction_types_
|
|
|
|
bool allow_all_custom_ = false; // implies allow_all_regular_
|
2024-04-22 02:19:40 +02:00
|
|
|
int32 reactions_limit_ = 0;
|
2022-08-30 10:45:27 +02:00
|
|
|
|
|
|
|
ChatReactions() = default;
|
|
|
|
|
2024-04-22 02:19:40 +02:00
|
|
|
static ChatReactions legacy(vector<ReactionType> &&reactions) {
|
|
|
|
ChatReactions result;
|
|
|
|
result.reaction_types_ = std::move(reactions);
|
|
|
|
return result;
|
2022-08-30 10:45:27 +02:00
|
|
|
}
|
|
|
|
|
2024-04-22 02:19:40 +02:00
|
|
|
ChatReactions(telegram_api::object_ptr<telegram_api::ChatReactions> &&chat_reactions_ptr, int32 reactions_limit);
|
2022-08-30 10:45:27 +02:00
|
|
|
|
2023-11-19 00:03:19 +01:00
|
|
|
ChatReactions(td_api::object_ptr<td_api::ChatAvailableReactions> &&chat_reactions_ptr, bool allow_all_custom);
|
2022-08-30 10:45:27 +02:00
|
|
|
|
2023-11-19 00:03:19 +01:00
|
|
|
ChatReactions(bool allow_all_regular, bool allow_all_custom)
|
|
|
|
: allow_all_regular_(allow_all_regular), allow_all_custom_(allow_all_custom) {
|
2022-08-30 10:45:27 +02:00
|
|
|
}
|
|
|
|
|
2023-08-04 17:39:07 +02:00
|
|
|
ChatReactions get_active_reactions(
|
|
|
|
const FlatHashMap<ReactionType, size_t, ReactionTypeHash> &active_reaction_pos) const;
|
2022-09-08 16:56:39 +02:00
|
|
|
|
2023-08-04 17:39:07 +02:00
|
|
|
bool is_allowed_reaction_type(const ReactionType &reaction) const;
|
2022-09-09 15:34:14 +02:00
|
|
|
|
2022-08-30 10:45:27 +02:00
|
|
|
telegram_api::object_ptr<telegram_api::ChatReactions> get_input_chat_reactions() const;
|
|
|
|
|
2024-04-22 02:19:40 +02:00
|
|
|
td_api::object_ptr<td_api::ChatAvailableReactions> get_chat_available_reactions_object(Td *td) const;
|
2022-08-30 10:45:27 +02:00
|
|
|
|
|
|
|
bool empty() const {
|
2023-11-19 00:03:19 +01:00
|
|
|
return reaction_types_.empty() && !allow_all_regular_;
|
2022-08-30 10:45:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class StorerT>
|
2023-08-06 01:32:09 +02:00
|
|
|
void store(StorerT &storer) const;
|
2022-08-30 10:45:27 +02:00
|
|
|
|
|
|
|
template <class ParserT>
|
2023-08-06 01:32:09 +02:00
|
|
|
void parse(ParserT &parser);
|
2022-08-30 10:45:27 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
bool operator==(const ChatReactions &lhs, const ChatReactions &rhs);
|
|
|
|
|
|
|
|
inline bool operator!=(const ChatReactions &lhs, const ChatReactions &rhs) {
|
|
|
|
return !(lhs == rhs);
|
|
|
|
}
|
|
|
|
|
|
|
|
StringBuilder &operator<<(StringBuilder &string_builder, const ChatReactions &reactions);
|
|
|
|
|
|
|
|
} // namespace td
|