Explicitly pass use_secret_chats to SecretChatsManager.
This commit is contained in:
parent
f1311610e5
commit
af838647df
@ -69,12 +69,12 @@ namespace td {
|
||||
// TODO
|
||||
// Just fail chat.
|
||||
|
||||
SecretChatsManager::SecretChatsManager(ActorShared<> parent) : parent_(std::move(parent)) {
|
||||
SecretChatsManager::SecretChatsManager(ActorShared<> parent, bool use_secret_chats)
|
||||
: use_secret_chats_(use_secret_chats), parent_(std::move(parent)) {
|
||||
}
|
||||
|
||||
void SecretChatsManager::start_up() {
|
||||
if (!G()->use_secret_chats()) {
|
||||
dummy_mode_ = true;
|
||||
if (!use_secret_chats_) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -161,7 +161,7 @@ void SecretChatsManager::send_set_ttl_message(SecretChatId secret_chat_id, int32
|
||||
}
|
||||
|
||||
void SecretChatsManager::on_update_chat(tl_object_ptr<telegram_api::updateEncryption> update) {
|
||||
if (dummy_mode_ || close_flag_) {
|
||||
if (!use_secret_chats_ || close_flag_) {
|
||||
return;
|
||||
}
|
||||
bool chat_requested = update->chat_->get_id() == telegram_api::encryptedChatRequested::ID;
|
||||
@ -180,8 +180,8 @@ void SecretChatsManager::do_update_chat(tl_object_ptr<telegram_api::updateEncryp
|
||||
|
||||
void SecretChatsManager::on_new_message(tl_object_ptr<telegram_api::EncryptedMessage> &&message_ptr,
|
||||
Promise<Unit> &&promise) {
|
||||
if (dummy_mode_ || close_flag_) {
|
||||
return;
|
||||
if (!use_secret_chats_ || close_flag_) {
|
||||
return promise.set_value(Unit());
|
||||
}
|
||||
CHECK(message_ptr != nullptr);
|
||||
|
||||
@ -200,7 +200,7 @@ void SecretChatsManager::on_new_message(tl_object_ptr<telegram_api::EncryptedMes
|
||||
}
|
||||
|
||||
void SecretChatsManager::replay_binlog_event(BinlogEvent &&binlog_event) {
|
||||
if (dummy_mode_) {
|
||||
if (!use_secret_chats_) {
|
||||
binlog_erase(G()->td_db()->get_binlog(), binlog_event.id_);
|
||||
return;
|
||||
}
|
||||
@ -406,9 +406,6 @@ ActorId<SecretChatActor> SecretChatsManager::create_chat_actor_impl(int32 id, bo
|
||||
|
||||
void SecretChatsManager::hangup() {
|
||||
close_flag_ = true;
|
||||
if (dummy_mode_) {
|
||||
return stop();
|
||||
}
|
||||
for (auto &it : id_to_actor_) {
|
||||
LOG(INFO) << "Ask to close SecretChatActor " << tag("id", it.first);
|
||||
it.second.reset();
|
||||
@ -419,7 +416,7 @@ void SecretChatsManager::hangup() {
|
||||
}
|
||||
|
||||
void SecretChatsManager::hangup_shared() {
|
||||
CHECK(!dummy_mode_);
|
||||
CHECK(use_secret_chats_);
|
||||
auto token = get_link_token();
|
||||
auto it = id_to_actor_.find(static_cast<int32>(token));
|
||||
CHECK(it != id_to_actor_.end());
|
||||
@ -436,7 +433,7 @@ void SecretChatsManager::timeout_expired() {
|
||||
}
|
||||
|
||||
void SecretChatsManager::flush_pending_chat_updates() {
|
||||
if (close_flag_ || dummy_mode_) {
|
||||
if (close_flag_ || !use_secret_chats_) {
|
||||
return;
|
||||
}
|
||||
auto it = pending_chat_updates_.begin();
|
||||
|
@ -28,7 +28,7 @@ struct BinlogEvent;
|
||||
|
||||
class SecretChatsManager final : public Actor {
|
||||
public:
|
||||
explicit SecretChatsManager(ActorShared<> parent);
|
||||
SecretChatsManager(ActorShared<> parent, bool use_secret_chats);
|
||||
|
||||
// proxy query to corresponding SecretChatActor
|
||||
void on_update_chat(tl_object_ptr<telegram_api::updateEncryption> update);
|
||||
@ -52,7 +52,7 @@ class SecretChatsManager final : public Actor {
|
||||
|
||||
private:
|
||||
bool binlog_replay_finish_flag_ = false;
|
||||
bool dummy_mode_ = false;
|
||||
bool use_secret_chats_ = false;
|
||||
bool close_flag_ = false;
|
||||
ActorShared<> parent_;
|
||||
std::map<int32, ActorOwn<SecretChatActor>> id_to_actor_;
|
||||
|
@ -3553,18 +3553,12 @@ void Td::init(Result<TdDb::OpenedDatabase> r_opened_database) {
|
||||
<< " and " << tag("files_directory", events.parameters.files_directory);
|
||||
VLOG(td_init) << "Successfully inited database";
|
||||
|
||||
auto api_id = events.parameters.api_id;
|
||||
auto api_hash = events.parameters.api_hash;
|
||||
|
||||
bool use_storage_optimizer = events.parameters.enable_storage_optimizer;
|
||||
bool ignore_file_names = events.parameters.ignore_file_names;
|
||||
|
||||
G()->init(std::move(events.parameters), actor_id(this), std::move(events.database)).ensure();
|
||||
G()->init(events.parameters, actor_id(this), std::move(events.database)).ensure();
|
||||
|
||||
init_options_and_network();
|
||||
|
||||
option_manager_->set_option_boolean("use_storage_optimizer", use_storage_optimizer);
|
||||
option_manager_->set_option_boolean("ignore_file_names", ignore_file_names);
|
||||
option_manager_->set_option_boolean("use_storage_optimizer", events.parameters.enable_storage_optimizer);
|
||||
option_manager_->set_option_boolean("ignore_file_names", events.parameters.ignore_file_names);
|
||||
|
||||
// we need to process td_api::getOption along with td_api::setOption for consistency
|
||||
// we need to process td_api::setOption before managers and MTProto header are created,
|
||||
@ -3628,7 +3622,8 @@ void Td::init(Result<TdDb::OpenedDatabase> r_opened_database) {
|
||||
});
|
||||
|
||||
VLOG(td_init) << "Create AuthManager";
|
||||
auth_manager_ = td::make_unique<AuthManager>(api_id, api_hash, create_reference());
|
||||
auth_manager_ =
|
||||
td::make_unique<AuthManager>(events.parameters.api_id, events.parameters.api_hash, create_reference());
|
||||
auth_manager_actor_ = register_actor("AuthManager", auth_manager_.get());
|
||||
G()->set_auth_manager(auth_manager_actor_.get());
|
||||
|
||||
@ -3636,6 +3631,10 @@ void Td::init(Result<TdDb::OpenedDatabase> r_opened_database) {
|
||||
|
||||
init_managers();
|
||||
|
||||
secret_chats_manager_ =
|
||||
create_actor<SecretChatsManager>("SecretChatsManager", create_reference(), events.parameters.use_secret_chats);
|
||||
G()->set_secret_chats_manager(secret_chats_manager_.get());
|
||||
|
||||
storage_manager_ = create_actor<StorageManager>("StorageManager", create_reference(), G()->get_gc_scheduler_id());
|
||||
G()->set_storage_manager(storage_manager_.get());
|
||||
|
||||
@ -3937,8 +3936,6 @@ void Td::init_managers() {
|
||||
password_manager_ = create_actor<PasswordManager>("PasswordManager", create_reference());
|
||||
G()->set_password_manager(password_manager_.get());
|
||||
privacy_manager_ = create_actor<PrivacyManager>("PrivacyManager", create_reference());
|
||||
secret_chats_manager_ = create_actor<SecretChatsManager>("SecretChatsManager", create_reference());
|
||||
G()->set_secret_chats_manager(secret_chats_manager_.get());
|
||||
secure_manager_ = create_actor<SecureManager>("SecureManager", create_reference());
|
||||
verify_phone_number_manager_ = create_actor<PhoneNumberManager>(
|
||||
"VerifyPhoneNumberManager", PhoneNumberManager::Type::VerifyPhone, create_reference());
|
||||
|
Loading…
Reference in New Issue
Block a user