diff --git a/td/telegram/ContactsManager.cpp b/td/telegram/ContactsManager.cpp index ea7cd21d4..d8526b048 100644 --- a/td/telegram/ContactsManager.cpp +++ b/td/telegram/ContactsManager.cpp @@ -48,7 +48,6 @@ #include "td/telegram/PremiumGiftOption.hpp" #include "td/telegram/ReactionManager.h" #include "td/telegram/SecretChatLayer.h" -#include "td/telegram/SecretChatsManager.h" #include "td/telegram/ServerMessageId.h" #include "td/telegram/StickerPhotoSize.h" #include "td/telegram/StickersManager.h" @@ -8966,27 +8965,6 @@ void ContactsManager::delete_channel(ChannelId channel_id, Promise &&promi td_->create_handler(std::move(promise))->send(channel_id); } -void ContactsManager::delete_dialog(DialogId dialog_id, Promise &&promise) { - if (!td_->dialog_manager_->have_dialog_force(dialog_id, "delete_dialog")) { - return promise.set_error(Status::Error(400, "Chat not found")); - } - - switch (dialog_id.get_type()) { - case DialogType::User: - return td_->messages_manager_->delete_dialog_history(dialog_id, true, true, std::move(promise)); - case DialogType::Chat: - return delete_chat(dialog_id.get_chat_id(), std::move(promise)); - case DialogType::Channel: - return delete_channel(dialog_id.get_channel_id(), std::move(promise)); - case DialogType::SecretChat: - send_closure(td_->secret_chats_manager_, &SecretChatsManager::cancel_chat, dialog_id.get_secret_chat_id(), true, - std::move(promise)); - return; - default: - UNREACHABLE(); - } -} - void ContactsManager::send_update_add_chat_members_privacy_forbidden(DialogId dialog_id, vector user_ids, const char *source) { td_->dialog_manager_->force_create_dialog(dialog_id, "send_update_add_chat_members_privacy_forbidden"); diff --git a/td/telegram/ContactsManager.h b/td/telegram/ContactsManager.h index d6d83f6e7..29ee4685f 100644 --- a/td/telegram/ContactsManager.h +++ b/td/telegram/ContactsManager.h @@ -521,7 +521,9 @@ class ContactsManager final : public Actor { void report_channel_anti_spam_false_positive(ChannelId channel_id, MessageId message_id, Promise &&promise); - void delete_dialog(DialogId dialog_id, Promise &&promise); + void delete_chat(ChatId chat_id, Promise &&promise); + + void delete_channel(ChannelId channel_id, Promise &&promise); void send_update_add_chat_members_privacy_forbidden(DialogId dialog_id, vector user_ids, const char *source); @@ -1987,10 +1989,6 @@ class ContactsManager final : public Actor { tl_object_ptr input_check_password, Promise &&promise); - void delete_chat(ChatId chat_id, Promise &&promise); - - void delete_channel(ChannelId channel_id, Promise &&promise); - void get_channel_statistics_dc_id_impl(ChannelId channel_id, bool for_full_statistics, Promise &&promise); void on_get_support_user(UserId user_id, Promise> &&promise); diff --git a/td/telegram/DialogManager.cpp b/td/telegram/DialogManager.cpp index becd8d132..ff7204912 100644 --- a/td/telegram/DialogManager.cpp +++ b/td/telegram/DialogManager.cpp @@ -19,6 +19,7 @@ #include "td/telegram/misc.h" #include "td/telegram/ReportReason.h" #include "td/telegram/SecretChatId.h" +#include "td/telegram/SecretChatsManager.h" #include "td/telegram/StickerPhotoSize.h" #include "td/telegram/Td.h" #include "td/telegram/UpdatesManager.h" @@ -849,6 +850,27 @@ bool DialogManager::on_get_dialog_error(DialogId dialog_id, const Status &status return false; } +void DialogManager::delete_dialog(DialogId dialog_id, Promise &&promise) { + if (!have_dialog_force(dialog_id, "delete_dialog")) { + return promise.set_error(Status::Error(400, "Chat not found")); + } + + switch (dialog_id.get_type()) { + case DialogType::User: + return td_->messages_manager_->delete_dialog_history(dialog_id, true, true, std::move(promise)); + case DialogType::Chat: + return td_->contacts_manager_->delete_chat(dialog_id.get_chat_id(), std::move(promise)); + case DialogType::Channel: + return td_->contacts_manager_->delete_channel(dialog_id.get_channel_id(), std::move(promise)); + case DialogType::SecretChat: + send_closure(td_->secret_chats_manager_, &SecretChatsManager::cancel_chat, dialog_id.get_secret_chat_id(), true, + std::move(promise)); + return; + default: + UNREACHABLE(); + } +} + string DialogManager::get_dialog_title(DialogId dialog_id) const { switch (dialog_id.get_type()) { case DialogType::User: diff --git a/td/telegram/DialogManager.h b/td/telegram/DialogManager.h index 8f4599a9d..a0a9246c1 100644 --- a/td/telegram/DialogManager.h +++ b/td/telegram/DialogManager.h @@ -111,6 +111,8 @@ class DialogManager final : public Actor { bool on_get_dialog_error(DialogId dialog_id, const Status &status, const char *source); + void delete_dialog(DialogId dialog_id, Promise &&promise); + string get_dialog_title(DialogId dialog_id) const; const DialogPhoto *get_dialog_photo(DialogId dialog_id) const; diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index 8cdccb3a5..01a1c1b17 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -18131,9 +18131,6 @@ DialogId MessagesManager::create_new_group_chat(const vector &user_ids, created_dialogs_.erase(it); - // set default notification settings to newly created chat - on_update_dialog_notify_settings(dialog_id, nullptr, "create_new_group_chat"); - promise.set_value(Unit()); return dialog_id; } @@ -18181,9 +18178,6 @@ DialogId MessagesManager::create_new_channel_chat(const string &title, bool is_f created_dialogs_.erase(it); - // set default notification settings to newly created chat - on_update_dialog_notify_settings(dialog_id, nullptr, "create_new_channel_chat"); - promise.set_value(Unit()); return dialog_id; } diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index 113af3585..cabbe3d3e 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -5374,7 +5374,7 @@ void Td::on_request(uint64 id, const td_api::deleteChat &request) { send_closure(actor_id, &MessagesManager::on_dialog_deleted, dialog_id, std::move(promise)); } }; - contacts_manager_->delete_dialog(dialog_id, std::move(query_promise)); + dialog_manager_->delete_dialog(dialog_id, std::move(query_promise)); } void Td::on_request(uint64 id, const td_api::getMessageThreadHistory &request) { @@ -6037,7 +6037,7 @@ void Td::on_request(uint64 id, const td_api::createSupergroupChat &request) { CREATE_REQUEST(CreateChatRequest, DialogId(ChannelId(request.supergroup_id_)), request.force_); } -void Td::on_request(uint64 id, td_api::createSecretChat &request) { +void Td::on_request(uint64 id, const td_api::createSecretChat &request) { CREATE_REQUEST(CreateChatRequest, DialogId(SecretChatId(request.secret_chat_id_)), true); } @@ -6057,7 +6057,7 @@ void Td::on_request(uint64 id, td_api::createNewSupergroupChat &request) { request.message_auto_delete_time_); } -void Td::on_request(uint64 id, td_api::createNewSecretChat &request) { +void Td::on_request(uint64 id, const td_api::createNewSecretChat &request) { CREATE_REQUEST(CreateNewSecretChatRequest, request.user_id_); } diff --git a/td/telegram/Td.h b/td/telegram/Td.h index 3968ccf9f..c354f246f 100644 --- a/td/telegram/Td.h +++ b/td/telegram/Td.h @@ -896,13 +896,13 @@ class Td final : public Actor { void on_request(uint64 id, const td_api::createSupergroupChat &request); - void on_request(uint64 id, td_api::createSecretChat &request); + void on_request(uint64 id, const td_api::createSecretChat &request); void on_request(uint64 id, td_api::createNewBasicGroupChat &request); void on_request(uint64 id, td_api::createNewSupergroupChat &request); - void on_request(uint64 id, td_api::createNewSecretChat &request); + void on_request(uint64 id, const td_api::createNewSecretChat &request); void on_request(uint64 id, const td_api::createCall &request);