Add and use add_draft_message_dependencies.
This commit is contained in:
parent
33cbb2f438
commit
ad5655d359
@ -6,6 +6,7 @@
|
||||
//
|
||||
#include "td/telegram/DraftMessage.h"
|
||||
|
||||
#include "td/telegram/Dependencies.h"
|
||||
#include "td/telegram/Global.h"
|
||||
#include "td/telegram/MessageEntity.h"
|
||||
#include "td/telegram/MessagesManager.h"
|
||||
@ -141,17 +142,23 @@ bool need_update_draft_message(const unique_ptr<DraftMessage> &old_draft_message
|
||||
const unique_ptr<DraftMessage> &new_draft_message, bool from_update) {
|
||||
if (new_draft_message == nullptr) {
|
||||
return old_draft_message != nullptr;
|
||||
} else {
|
||||
if (old_draft_message == nullptr) {
|
||||
return true;
|
||||
}
|
||||
if (old_draft_message->reply_to_message_id == new_draft_message->reply_to_message_id &&
|
||||
old_draft_message->input_message_text == new_draft_message->input_message_text) {
|
||||
return old_draft_message->date < new_draft_message->date;
|
||||
} else {
|
||||
return !from_update || old_draft_message->date <= new_draft_message->date;
|
||||
}
|
||||
}
|
||||
if (old_draft_message == nullptr) {
|
||||
return true;
|
||||
}
|
||||
if (old_draft_message->reply_to_message_id == new_draft_message->reply_to_message_id &&
|
||||
old_draft_message->input_message_text == new_draft_message->input_message_text) {
|
||||
return old_draft_message->date < new_draft_message->date;
|
||||
} else {
|
||||
return !from_update || old_draft_message->date <= new_draft_message->date;
|
||||
}
|
||||
}
|
||||
|
||||
void add_draft_message_dependencies(Dependencies &dependencies, const unique_ptr<DraftMessage> &draft_message) {
|
||||
if (draft_message == nullptr) {
|
||||
return;
|
||||
}
|
||||
add_formatted_text_dependencies(dependencies, &draft_message->input_message_text.text);
|
||||
}
|
||||
|
||||
td_api::object_ptr<td_api::draftMessage> get_draft_message_object(const unique_ptr<DraftMessage> &draft_message) {
|
||||
|
@ -19,6 +19,7 @@
|
||||
namespace td {
|
||||
|
||||
class ContactsManager;
|
||||
class Dependencies;
|
||||
class Td;
|
||||
|
||||
class DraftMessage {
|
||||
@ -31,6 +32,8 @@ class DraftMessage {
|
||||
bool need_update_draft_message(const unique_ptr<DraftMessage> &old_draft_message,
|
||||
const unique_ptr<DraftMessage> &new_draft_message, bool from_update);
|
||||
|
||||
void add_draft_message_dependencies(Dependencies &dependencies, const unique_ptr<DraftMessage> &draft_message);
|
||||
|
||||
td_api::object_ptr<td_api::draftMessage> get_draft_message_object(const unique_ptr<DraftMessage> &draft_message);
|
||||
|
||||
unique_ptr<DraftMessage> get_draft_message(ContactsManager *contacts_manager,
|
||||
|
@ -24615,6 +24615,7 @@ void MessagesManager::add_message_dependencies(Dependencies &dependencies, const
|
||||
}
|
||||
add_message_content_dependencies(dependencies, m->content.get(), td_->auth_manager_->is_bot());
|
||||
add_reply_markup_dependencies(dependencies, m->reply_markup.get());
|
||||
add_draft_message_dependencies(dependencies, m->thread_draft_message);
|
||||
}
|
||||
|
||||
void MessagesManager::get_dialog_send_message_as_dialog_ids(
|
||||
@ -37450,9 +37451,7 @@ unique_ptr<MessagesManager::Dialog> MessagesManager::parse_dialog(DialogId dialo
|
||||
d->messages.foreach([&](const MessageId &message_id, const unique_ptr<Message> &message) {
|
||||
add_message_dependencies(dependencies, message.get());
|
||||
});
|
||||
if (d->draft_message != nullptr) {
|
||||
add_formatted_text_dependencies(dependencies, &d->draft_message->input_message_text.text);
|
||||
}
|
||||
add_draft_message_dependencies(dependencies, d->draft_message);
|
||||
for (auto user_id : d->pending_join_request_user_ids) {
|
||||
dependencies.add(user_id);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user