From c916566e76c8fe1d27e8ecac0e50dc0068cfdabc Mon Sep 17 00:00:00 2001 From: levlam Date: Sat, 3 Oct 2020 21:47:12 +0300 Subject: [PATCH] Fix MessagesManager::get_chat_object. GitOrigin-RevId: a5dddba5f844b8064fe7083c8532f9d2286b9dba --- td/telegram/MessagesManager.cpp | 14 +++++--------- td/telegram/MessagesManager.h | 4 ++-- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index 62d3f7f08..becb6fa96 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -18848,15 +18848,11 @@ td_api::object_ptr MessagesManager::get_chat_action_bar_o return nullptr; } -td_api::object_ptr MessagesManager::get_chat_object(const Dialog *d, int64 real_order) const { +td_api::object_ptr MessagesManager::get_chat_object(const Dialog *d) const { CHECK(d != nullptr); auto chat_source = is_dialog_sponsored(d) ? sponsored_dialog_source_.get_chat_source_object() : nullptr; - if (real_order == DEFAULT_ORDER) { - real_order = d->order; - } - bool can_delete_for_self = false; bool can_delete_for_all_users = false; if (chat_source != nullptr) { @@ -18869,7 +18865,7 @@ td_api::object_ptr MessagesManager::get_chat_object(const Dialog * // can't delete break; } - } else if (!td_->auth_manager_->is_bot() && real_order != DEFAULT_ORDER) { + } else if (!td_->auth_manager_->is_bot() && have_input_peer(d->dialog_id, AccessRights::Read)) { switch (d->dialog_id.get_type()) { case DialogType::User: can_delete_for_self = true; @@ -26891,10 +26887,10 @@ void MessagesManager::send_update_delete_messages(DialogId dialog_id, vector(dialog_id.get(), std::move(message_ids), is_permanent, from_cache)); } -void MessagesManager::send_update_new_chat(Dialog *d, int64 real_order) { +void MessagesManager::send_update_new_chat(Dialog *d) { CHECK(d != nullptr); CHECK(d->messages == nullptr); - auto chat_object = get_chat_object(d, real_order); + auto chat_object = get_chat_object(d); bool has_action_bar = chat_object->action_bar_ != nullptr; d->last_sent_has_scheduled_messages = chat_object->has_scheduled_messages_; send_closure(G()->td(), &Td::send_update, make_tl_object(std::move(chat_object))); @@ -32339,7 +32335,7 @@ MessagesManager::Dialog *MessagesManager::add_new_dialog(unique_ptr &&d, fix_dialog_action_bar(dialog); - send_update_new_chat(dialog, order); + send_update_new_chat(dialog); fix_new_dialog(dialog, std::move(last_database_message), last_database_message_id, order, last_clear_history_date, last_clear_history_message_id, is_loaded_from_database); diff --git a/td/telegram/MessagesManager.h b/td/telegram/MessagesManager.h index 16315dd61..2b2fbb28e 100644 --- a/td/telegram/MessagesManager.h +++ b/td/telegram/MessagesManager.h @@ -2187,7 +2187,7 @@ class MessagesManager : public Actor { void send_update_delete_messages(DialogId dialog_id, vector &&message_ids, bool is_permanent, bool from_cache) const; - void send_update_new_chat(Dialog *d, int64 real_order); + void send_update_new_chat(Dialog *d); void send_update_chat_draft_message(const Dialog *d); @@ -2388,7 +2388,7 @@ class MessagesManager : public Actor { td_api::object_ptr get_chat_action_bar_object(const Dialog *d, bool hide_unarchive = false) const; - td_api::object_ptr get_chat_object(const Dialog *d, int64 real_order = DEFAULT_ORDER) const; + td_api::object_ptr get_chat_object(const Dialog *d) const; bool have_dialog_info(DialogId dialog_id) const; bool have_dialog_info_force(DialogId dialog_id) const;