Add protection from chat folder deletion and recreation with the same identifier while chat list is loaded.
This commit is contained in:
parent
1601b703de
commit
6fe43311cb
@ -15837,7 +15837,8 @@ void MessagesManager::get_dialogs_from_list(DialogListId dialog_list_id, int32 l
|
|||||||
Promise<td_api::object_ptr<td_api::chats>> &&promise) {
|
Promise<td_api::object_ptr<td_api::chats>> &&promise) {
|
||||||
CHECK(!td_->auth_manager_->is_bot());
|
CHECK(!td_->auth_manager_->is_bot());
|
||||||
|
|
||||||
if (get_dialog_list(dialog_list_id) == nullptr) {
|
auto *list = get_dialog_list(dialog_list_id);
|
||||||
|
if (list == nullptr) {
|
||||||
return promise.set_error(Status::Error(400, "Chat list not found"));
|
return promise.set_error(Status::Error(400, "Chat list not found"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -15848,6 +15849,7 @@ void MessagesManager::get_dialogs_from_list(DialogListId dialog_list_id, int32 l
|
|||||||
auto task_id = ++current_get_dialogs_task_id_;
|
auto task_id = ++current_get_dialogs_task_id_;
|
||||||
auto &task = get_dialogs_tasks_[task_id];
|
auto &task = get_dialogs_tasks_[task_id];
|
||||||
task.dialog_list_id = dialog_list_id;
|
task.dialog_list_id = dialog_list_id;
|
||||||
|
task.dialog_list_unique_id = list->unique_id_;
|
||||||
task.retry_count = 5;
|
task.retry_count = 5;
|
||||||
task.limit = limit;
|
task.limit = limit;
|
||||||
task.promise = std::move(promise);
|
task.promise = std::move(promise);
|
||||||
@ -15890,7 +15892,7 @@ void MessagesManager::on_get_dialogs_from_list(int64 task_id, Result<Unit> &&res
|
|||||||
}
|
}
|
||||||
auto &task = task_it->second;
|
auto &task = task_it->second;
|
||||||
auto list_ptr = get_dialog_list(task.dialog_list_id);
|
auto list_ptr = get_dialog_list(task.dialog_list_id);
|
||||||
if (result.is_ok() && list_ptr == nullptr) {
|
if (result.is_ok() && (list_ptr == nullptr || list_ptr->unique_id_ != task.dialog_list_unique_id)) {
|
||||||
CHECK(!task.dialog_list_id.is_folder());
|
CHECK(!task.dialog_list_id.is_folder());
|
||||||
result = Status::Error(400, "Chat list not found");
|
result = Status::Error(400, "Chat list not found");
|
||||||
}
|
}
|
||||||
@ -35608,11 +35610,13 @@ MessagesManager::DialogListView MessagesManager::get_dialog_lists(const Dialog *
|
|||||||
|
|
||||||
MessagesManager::DialogList &MessagesManager::add_dialog_list(DialogListId dialog_list_id) {
|
MessagesManager::DialogList &MessagesManager::add_dialog_list(DialogListId dialog_list_id) {
|
||||||
CHECK(!td_->auth_manager_->is_bot());
|
CHECK(!td_->auth_manager_->is_bot());
|
||||||
if (dialog_lists_.count(dialog_list_id) == 0) {
|
bool is_new = dialog_lists_.count(dialog_list_id) == 0;
|
||||||
LOG(INFO) << "Create " << dialog_list_id;
|
|
||||||
}
|
|
||||||
auto &list = dialog_lists_[dialog_list_id];
|
auto &list = dialog_lists_[dialog_list_id];
|
||||||
list.dialog_list_id = dialog_list_id;
|
list.dialog_list_id = dialog_list_id;
|
||||||
|
if (is_new) {
|
||||||
|
LOG(INFO) << "Create " << dialog_list_id;
|
||||||
|
list.unique_id_ = ++current_dialog_list_unique_id_;
|
||||||
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1370,6 +1370,7 @@ class MessagesManager final : public Actor {
|
|||||||
int32 in_memory_dialog_total_count_ = 0;
|
int32 in_memory_dialog_total_count_ = 0;
|
||||||
int32 server_dialog_total_count_ = -1;
|
int32 server_dialog_total_count_ = -1;
|
||||||
int32 secret_chat_total_count_ = -1;
|
int32 secret_chat_total_count_ = -1;
|
||||||
|
int64 unique_id_ = 0;
|
||||||
|
|
||||||
vector<Promise<Unit>> load_list_queries_;
|
vector<Promise<Unit>> load_list_queries_;
|
||||||
|
|
||||||
@ -3270,6 +3271,7 @@ class MessagesManager final : public Actor {
|
|||||||
|
|
||||||
int64 current_pinned_dialog_order_ = static_cast<int64>(MIN_PINNED_DIALOG_DATE) << 32;
|
int64 current_pinned_dialog_order_ = static_cast<int64>(MIN_PINNED_DIALOG_DATE) << 32;
|
||||||
|
|
||||||
|
int64 current_dialog_list_unique_id_ = 0;
|
||||||
std::unordered_map<DialogListId, DialogList, DialogListIdHash> dialog_lists_;
|
std::unordered_map<DialogListId, DialogList, DialogListIdHash> dialog_lists_;
|
||||||
std::unordered_map<FolderId, DialogFolder, FolderIdHash> dialog_folders_;
|
std::unordered_map<FolderId, DialogFolder, FolderIdHash> dialog_folders_;
|
||||||
|
|
||||||
@ -3327,6 +3329,7 @@ class MessagesManager final : public Actor {
|
|||||||
|
|
||||||
struct GetDialogsTask {
|
struct GetDialogsTask {
|
||||||
DialogListId dialog_list_id;
|
DialogListId dialog_list_id;
|
||||||
|
int64 dialog_list_unique_id;
|
||||||
int32 limit;
|
int32 limit;
|
||||||
int32 retry_count;
|
int32 retry_count;
|
||||||
DialogDate last_dialog_date = MIN_DIALOG_DATE;
|
DialogDate last_dialog_date = MIN_DIALOG_DATE;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user