From ff9f5b88d9e36d9d895652f24839caed74505777 Mon Sep 17 00:00:00 2001 From: levlam Date: Fri, 11 Mar 2022 13:00:25 +0300 Subject: [PATCH] Ignore invite links to deactivated basic groups. --- td/telegram/ContactsManager.cpp | 12 +++++++++--- td/telegram/ContactsManager.h | 2 +- td/telegram/Td.cpp | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/td/telegram/ContactsManager.cpp b/td/telegram/ContactsManager.cpp index ed63f67b2..41061d62f 100644 --- a/td/telegram/ContactsManager.cpp +++ b/td/telegram/ContactsManager.cpp @@ -7509,9 +7509,15 @@ void ContactsManager::delete_all_revoked_dialog_invite_links(DialogId dialog_id, td_->create_handler(std::move(promise))->send(dialog_id, creator_user_id); } -void ContactsManager::check_dialog_invite_link(const string &invite_link, Promise &&promise) const { - if (invite_link_infos_.count(invite_link) > 0) { - return promise.set_value(Unit()); +void ContactsManager::check_dialog_invite_link(const string &invite_link, bool force, Promise &&promise) { + auto it = invite_link_infos_.find(invite_link); + if (it != invite_link_infos_.end()) { + auto dialog_id = it->second->dialog_id; + if (!force && dialog_id.get_type() == DialogType::Chat && !get_chat_is_active(dialog_id.get_chat_id())) { + invite_link_infos_.erase(it); + } else { + return promise.set_value(Unit()); + } } if (!DialogInviteLink::is_valid_invite_link(invite_link)) { diff --git a/td/telegram/ContactsManager.h b/td/telegram/ContactsManager.h index 1d2f59541..c031d3d48 100644 --- a/td/telegram/ContactsManager.h +++ b/td/telegram/ContactsManager.h @@ -421,7 +421,7 @@ class ContactsManager final : public Actor { void delete_all_revoked_dialog_invite_links(DialogId dialog_id, UserId creator_user_id, Promise &&promise); - void check_dialog_invite_link(const string &invite_link, Promise &&promise) const; + void check_dialog_invite_link(const string &invite_link, bool force, Promise &&promise); void import_dialog_invite_link(const string &invite_link, Promise &&promise); diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index 1190ebc1d..d0067e29f 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -1789,7 +1789,7 @@ class CheckChatInviteLinkRequest final : public RequestActor<> { string invite_link_; void do_run(Promise &&promise) final { - td_->contacts_manager_->check_dialog_invite_link(invite_link_, std::move(promise)); + td_->contacts_manager_->check_dialog_invite_link(invite_link_, get_tries() < 2, std::move(promise)); } void do_send_result() final {