Add MessageReactions::add_dependencies.

This commit is contained in:
levlam 2022-09-24 21:07:35 +03:00
parent da00ea6f86
commit 375446ac88
3 changed files with 17 additions and 6 deletions

View File

@ -9,6 +9,7 @@
#include "td/telegram/AccessRights.h"
#include "td/telegram/ConfigManager.h"
#include "td/telegram/ContactsManager.h"
#include "td/telegram/Dependencies.h"
#include "td/telegram/Global.h"
#include "td/telegram/MessageSender.h"
#include "td/telegram/MessagesManager.h"
@ -804,6 +805,17 @@ vector<td_api::object_ptr<td_api::messageReaction>> MessageReactions::get_messag
});
}
void MessageReactions::add_dependencies(Dependencies &dependencies) const {
for (const auto &reaction : reactions_) {
const auto &dialog_ids = reaction.get_recent_chooser_dialog_ids();
for (auto dialog_id : dialog_ids) {
// don't load the dialog itself
// it will be created in get_message_reaction_object if needed
dependencies.add_dialog_dependencies(dialog_id);
}
}
}
bool MessageReactions::need_update_message_reactions(const MessageReactions *old_reactions,
const MessageReactions *new_reactions) {
if (old_reactions == nullptr) {

View File

@ -24,6 +24,8 @@
namespace td {
class Dependencies;
class Td;
class MessageReaction {
@ -173,6 +175,8 @@ struct MessageReactions {
vector<td_api::object_ptr<td_api::messageReaction>> get_message_reactions_object(Td *td, UserId my_user_id,
UserId peer_user_id) const;
void add_dependencies(Dependencies &dependencies) const;
static bool need_update_message_reactions(const MessageReactions *old_reactions,
const MessageReactions *new_reactions);

View File

@ -25505,13 +25505,8 @@ void MessagesManager::add_message_dependencies(Dependencies &dependencies, const
LOG(INFO) << "Add min reacted " << recent_chooser_min_channel.first;
td_->contacts_manager_->add_min_channel(recent_chooser_min_channel.first, recent_chooser_min_channel.second);
}
const auto &dialog_ids = reaction.get_recent_chooser_dialog_ids();
for (auto dialog_id : dialog_ids) {
// don't load the dialog itself
// it will be created in get_message_reaction_object if needed
dependencies.add_dialog_dependencies(dialog_id);
}
}
m->reactions->add_dependencies(dependencies);
}
add_message_content_dependencies(dependencies, m->content.get());
add_reply_markup_dependencies(dependencies, m->reply_markup.get());