diff --git a/td/telegram/MessageReaction.cpp b/td/telegram/MessageReaction.cpp index f9dc4bf76..39e4e7038 100644 --- a/td/telegram/MessageReaction.cpp +++ b/td/telegram/MessageReaction.cpp @@ -433,16 +433,33 @@ void MessageReaction::set_is_chosen(bool is_chosen, DialogId chooser_dialog_id, } } -td_api::object_ptr MessageReaction::get_message_reaction_object(Td *td) const { +td_api::object_ptr MessageReaction::get_message_reaction_object(Td *td, UserId my_user_id, + UserId peer_user_id) const { CHECK(!is_empty()); vector> recent_choosers; - for (auto dialog_id : recent_chooser_dialog_ids_) { - auto recent_chooser = get_min_message_sender_object(td, dialog_id, "get_message_reaction_object"); - if (recent_chooser != nullptr) { - recent_choosers.push_back(std::move(recent_chooser)); - if (recent_choosers.size() == MAX_RECENT_CHOOSERS) { - break; + if (my_user_id.is_valid()) { + CHECK(peer_user_id.is_valid()); + if (is_chosen()) { + auto recent_chooser = get_min_message_sender_object(td, DialogId(my_user_id), "get_message_reaction_object"); + if (recent_chooser != nullptr) { + recent_choosers.push_back(std::move(recent_chooser)); + } + } + if (choose_count_ >= (is_chosen() ? 2 : 1)) { + auto recent_chooser = get_min_message_sender_object(td, DialogId(peer_user_id), "get_message_reaction_object"); + if (recent_chooser != nullptr) { + recent_choosers.push_back(std::move(recent_chooser)); + } + } + } else { + for (auto dialog_id : recent_chooser_dialog_ids_) { + auto recent_chooser = get_min_message_sender_object(td, dialog_id, "get_message_reaction_object"); + if (recent_chooser != nullptr) { + recent_choosers.push_back(std::move(recent_chooser)); + if (recent_choosers.size() == MAX_RECENT_CHOOSERS) { + break; + } } } } diff --git a/td/telegram/MessageReaction.h b/td/telegram/MessageReaction.h index 6c30a8a4e..9051a8a99 100644 --- a/td/telegram/MessageReaction.h +++ b/td/telegram/MessageReaction.h @@ -85,7 +85,8 @@ class MessageReaction { return recent_chooser_min_channels_; } - td_api::object_ptr get_message_reaction_object(Td *td) const; + td_api::object_ptr get_message_reaction_object(Td *td, UserId my_user_id, + UserId peer_user_id) const; template void store(StorerT &storer) const; diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index 541197a34..e0532471b 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -6961,8 +6961,14 @@ td_api::object_ptr MessagesManager::get_message_ vector> reactions; if (has_reactions) { - reactions = transform(m->reactions->reactions_, [td = td_](const MessageReaction &reaction) { - return reaction.get_message_reaction_object(td); + UserId my_user_id; + UserId peer_user_id; + if (dialog_id.get_type() == DialogType::User) { + my_user_id = td_->contacts_manager_->get_my_id(); + peer_user_id = dialog_id.get_user_id(); + } + reactions = transform(m->reactions->reactions_, [td = td_, my_user_id, peer_user_id](const MessageReaction &reaction) { + return reaction.get_message_reaction_object(td, my_user_id, peer_user_id); }); }