Add and use MessageReactions::get_non_paid_reaction_count().

This commit is contained in:
levlam 2024-08-07 16:57:32 +03:00
parent 6450f5a531
commit 56ef439ff8
3 changed files with 13 additions and 1 deletions

View File

@ -964,6 +964,16 @@ td_api::object_ptr<td_api::messageReactions> MessageReactions::get_message_react
can_get_added_reactions_); can_get_added_reactions_);
} }
int32 MessageReactions::get_non_paid_reaction_count() const {
int32 result = 0;
for (const auto &reaction : reactions_) {
if (!reaction.reaction_type_.is_paid_reaction()) {
result++;
}
}
return result;
}
void MessageReactions::add_min_channels(Td *td) const { void MessageReactions::add_min_channels(Td *td) const {
for (const auto &reaction : reactions_) { for (const auto &reaction : reactions_) {
for (const auto &recent_chooser_min_channel : reaction.get_recent_chooser_min_channels()) { for (const auto &recent_chooser_min_channel : reaction.get_recent_chooser_min_channels()) {

View File

@ -200,6 +200,8 @@ struct MessageReactions {
td_api::object_ptr<td_api::messageReactions> get_message_reactions_object(Td *td, UserId my_user_id, td_api::object_ptr<td_api::messageReactions> get_message_reactions_object(Td *td, UserId my_user_id,
UserId peer_user_id) const; UserId peer_user_id) const;
int32 get_non_paid_reaction_count() const;
void add_min_channels(Td *td) const; void add_min_channels(Td *td) const;
void add_dependencies(Dependencies &dependencies) const; void add_dependencies(Dependencies &dependencies) const;

View File

@ -22648,7 +22648,7 @@ ChatReactions MessagesManager::get_message_available_reactions(const Dialog *d,
reactions_uniq_max = active_reactions.reactions_limit_; reactions_uniq_max = active_reactions.reactions_limit_;
} }
bool can_add_new_reactions = bool can_add_new_reactions =
m->reactions == nullptr || static_cast<int64>(m->reactions->reactions_.size()) < reactions_uniq_max; 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 || !can_add_new_reactions) {
active_reactions = ChatReactions(); active_reactions = ChatReactions();