From 54e1a4f100c7b74f09fa28e2a293ca20a07e4cd7 Mon Sep 17 00:00:00 2001 From: levlam Date: Fri, 8 Jun 2018 22:23:49 +0300 Subject: [PATCH] Fix sending secure files to secret chats. GitOrigin-RevId: e5cafeb4d3e48c3b5c925c81dd3406d8b0ce44da --- td/telegram/AnimationsManager.cpp | 2 +- td/telegram/AudiosManager.cpp | 2 +- td/telegram/DocumentsManager.cpp | 4 ++-- td/telegram/Photo.cpp | 2 +- td/telegram/VideoNotesManager.cpp | 2 +- td/telegram/VideosManager.cpp | 2 +- td/telegram/VoiceNotesManager.cpp | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/td/telegram/AnimationsManager.cpp b/td/telegram/AnimationsManager.cpp index 5c8c1a24c..d7f2cc9ae 100644 --- a/td/telegram/AnimationsManager.cpp +++ b/td/telegram/AnimationsManager.cpp @@ -308,7 +308,7 @@ SecretInputMedia AnimationsManager::get_secret_input_media(FileId animation_file CHECK(animation != nullptr); auto file_view = td_->file_manager_->get_file_view(animation_file_id); auto &encryption_key = file_view.encryption_key(); - if (encryption_key.empty()) { + if (!file_view.is_encrypted_secret() || encryption_key.empty()) { return SecretInputMedia{}; } if (file_view.has_remote_location()) { diff --git a/td/telegram/AudiosManager.cpp b/td/telegram/AudiosManager.cpp index 248ea17e7..301be671f 100644 --- a/td/telegram/AudiosManager.cpp +++ b/td/telegram/AudiosManager.cpp @@ -187,7 +187,7 @@ SecretInputMedia AudiosManager::get_secret_input_media(FileId audio_file_id, CHECK(audio != nullptr); auto file_view = td_->file_manager_->get_file_view(audio_file_id); auto &encryption_key = file_view.encryption_key(); - if (encryption_key.empty()) { + if (!file_view.is_encrypted_secret() || encryption_key.empty()) { return SecretInputMedia{}; } if (file_view.has_remote_location()) { diff --git a/td/telegram/DocumentsManager.cpp b/td/telegram/DocumentsManager.cpp index ff329856f..1a453f0fb 100644 --- a/td/telegram/DocumentsManager.cpp +++ b/td/telegram/DocumentsManager.cpp @@ -426,7 +426,7 @@ const DocumentsManager::Document *DocumentsManager::get_document(FileId file_id) bool DocumentsManager::has_input_media(FileId file_id, FileId thumbnail_file_id, bool is_secret) const { auto file_view = td_->file_manager_->get_file_view(file_id); if (is_secret) { - if (file_view.encryption_key().empty() || !file_view.has_remote_location()) { + if (!file_view.is_encrypted_secret() || file_view.encryption_key().empty() || !file_view.has_remote_location()) { return false; } @@ -446,7 +446,7 @@ SecretInputMedia DocumentsManager::get_secret_input_media(FileId document_file_i CHECK(document != nullptr); auto file_view = td_->file_manager_->get_file_view(document_file_id); auto &encryption_key = file_view.encryption_key(); - if (encryption_key.empty()) { + if (!file_view.is_encrypted_secret() || encryption_key.empty()) { return SecretInputMedia{}; } if (file_view.has_remote_location()) { diff --git a/td/telegram/Photo.cpp b/td/telegram/Photo.cpp index 0bff8fa09..de776f51f 100644 --- a/td/telegram/Photo.cpp +++ b/td/telegram/Photo.cpp @@ -595,7 +595,7 @@ SecretInputMedia photo_get_secret_input_media(FileManager *file_manager, const P } auto file_view = file_manager->get_file_view(file_id); auto &encryption_key = file_view.encryption_key(); - if (encryption_key.empty()) { + if (!file_view.is_encrypted_secret() || encryption_key.empty()) { return {}; } if (file_view.has_remote_location()) { diff --git a/td/telegram/VideoNotesManager.cpp b/td/telegram/VideoNotesManager.cpp index e83fefa58..1649b9273 100644 --- a/td/telegram/VideoNotesManager.cpp +++ b/td/telegram/VideoNotesManager.cpp @@ -166,7 +166,7 @@ SecretInputMedia VideoNotesManager::get_secret_input_media(FileId video_note_fil CHECK(video_note != nullptr); auto file_view = td_->file_manager_->get_file_view(video_note_file_id); auto &encryption_key = file_view.encryption_key(); - if (encryption_key.empty()) { + if (!file_view.is_encrypted_secret() || encryption_key.empty()) { return SecretInputMedia{}; } if (file_view.has_remote_location()) { diff --git a/td/telegram/VideosManager.cpp b/td/telegram/VideosManager.cpp index 0d171cd87..0686af093 100644 --- a/td/telegram/VideosManager.cpp +++ b/td/telegram/VideosManager.cpp @@ -195,7 +195,7 @@ SecretInputMedia VideosManager::get_secret_input_media(FileId video_file_id, CHECK(video != nullptr); auto file_view = td_->file_manager_->get_file_view(video_file_id); auto &encryption_key = file_view.encryption_key(); - if (encryption_key.empty()) { + if (!file_view.is_encrypted_secret() || encryption_key.empty()) { return SecretInputMedia{}; } if (file_view.has_remote_location()) { diff --git a/td/telegram/VoiceNotesManager.cpp b/td/telegram/VoiceNotesManager.cpp index 0ba7b9229..57e500ab0 100644 --- a/td/telegram/VoiceNotesManager.cpp +++ b/td/telegram/VoiceNotesManager.cpp @@ -146,7 +146,7 @@ SecretInputMedia VoiceNotesManager::get_secret_input_media(FileId voice_file_id, CHECK(voice_note != nullptr); auto file_view = td_->file_manager_->get_file_view(voice_file_id); auto &encryption_key = file_view.encryption_key(); - if (encryption_key.empty()) { + if (!file_view.is_encrypted_secret() || encryption_key.empty()) { return SecretInputMedia{}; } if (file_view.has_remote_location()) {