Use main remote location for upload.
GitOrigin-RevId: 1a77b73bf73608e219cbf2a0d888f33b0c406a80
This commit is contained in:
parent
15cdfb974a
commit
c1a201fd7f
@ -309,8 +309,8 @@ tl_object_ptr<telegram_api::InputMedia> AnimationsManager::get_input_media(
|
||||
if (file_view.is_encrypted()) {
|
||||
return nullptr;
|
||||
}
|
||||
if (file_view.has_remote_location() && !file_view.remote_location().is_web() && input_file == nullptr) {
|
||||
return make_tl_object<telegram_api::inputMediaDocument>(0, file_view.remote_location().as_input_document(), 0);
|
||||
if (file_view.has_remote_location() && !file_view.main_remote_location().is_web() && input_file == nullptr) {
|
||||
return make_tl_object<telegram_api::inputMediaDocument>(0, file_view.main_remote_location().as_input_document(), 0);
|
||||
}
|
||||
if (file_view.has_url()) {
|
||||
return make_tl_object<telegram_api::inputMediaDocumentExternal>(0, file_view.url(), 0);
|
||||
@ -362,7 +362,7 @@ SecretInputMedia AnimationsManager::get_secret_input_media(FileId animation_file
|
||||
return SecretInputMedia{};
|
||||
}
|
||||
if (file_view.has_remote_location()) {
|
||||
input_file = file_view.remote_location().as_input_encrypted_file();
|
||||
input_file = file_view.main_remote_location().as_input_encrypted_file();
|
||||
}
|
||||
if (!input_file) {
|
||||
return SecretInputMedia{};
|
||||
|
@ -194,7 +194,7 @@ SecretInputMedia AudiosManager::get_secret_input_media(FileId audio_file_id,
|
||||
return SecretInputMedia{};
|
||||
}
|
||||
if (file_view.has_remote_location()) {
|
||||
input_file = file_view.remote_location().as_input_encrypted_file();
|
||||
input_file = file_view.main_remote_location().as_input_encrypted_file();
|
||||
}
|
||||
if (!input_file) {
|
||||
return SecretInputMedia{};
|
||||
@ -225,8 +225,8 @@ tl_object_ptr<telegram_api::InputMedia> AudiosManager::get_input_media(
|
||||
if (file_view.is_encrypted()) {
|
||||
return nullptr;
|
||||
}
|
||||
if (file_view.has_remote_location() && !file_view.remote_location().is_web() && input_file == nullptr) {
|
||||
return make_tl_object<telegram_api::inputMediaDocument>(0, file_view.remote_location().as_input_document(), 0);
|
||||
if (file_view.has_remote_location() && !file_view.main_remote_location().is_web() && input_file == nullptr) {
|
||||
return make_tl_object<telegram_api::inputMediaDocument>(0, file_view.main_remote_location().as_input_document(), 0);
|
||||
}
|
||||
if (file_view.has_url()) {
|
||||
return make_tl_object<telegram_api::inputMediaDocumentExternal>(0, file_view.url(), 0);
|
||||
|
@ -4023,9 +4023,9 @@ void ContactsManager::set_profile_photo(const tl_object_ptr<td_api::InputFile> &
|
||||
|
||||
FileView file_view = td_->file_manager_->get_file_view(file_id);
|
||||
CHECK(!file_view.is_encrypted());
|
||||
if (file_view.has_remote_location() && !file_view.remote_location().is_web()) {
|
||||
if (file_view.has_remote_location() && !file_view.main_remote_location().is_web()) {
|
||||
td_->create_handler<UpdateProfilePhotoQuery>(std::move(promise))
|
||||
->send(td_->file_manager_->dup_file_id(file_id), file_view.remote_location().as_input_photo());
|
||||
->send(td_->file_manager_->dup_file_id(file_id), file_view.main_remote_location().as_input_photo());
|
||||
return;
|
||||
}
|
||||
|
||||
@ -10418,14 +10418,14 @@ void ContactsManager::on_upload_profile_photo(FileId file_id, tl_object_ptr<tele
|
||||
|
||||
FileView file_view = td_->file_manager_->get_file_view(file_id);
|
||||
if (file_view.has_remote_location() && input_file == nullptr) {
|
||||
if (file_view.remote_location().is_web()) {
|
||||
if (file_view.main_remote_location().is_web()) {
|
||||
// TODO reupload
|
||||
promise.set_error(Status::Error(400, "Can't use web photo as profile photo"));
|
||||
return;
|
||||
}
|
||||
|
||||
td_->create_handler<UpdateProfilePhotoQuery>(std::move(promise))
|
||||
->send(file_id, file_view.remote_location().as_input_photo());
|
||||
->send(file_id, file_view.main_remote_location().as_input_photo());
|
||||
return;
|
||||
}
|
||||
CHECK(input_file != nullptr);
|
||||
|
@ -523,7 +523,7 @@ SecretInputMedia DocumentsManager::get_secret_input_media(FileId document_file_i
|
||||
return SecretInputMedia{};
|
||||
}
|
||||
if (file_view.has_remote_location()) {
|
||||
input_file = file_view.remote_location().as_input_encrypted_file();
|
||||
input_file = file_view.main_remote_location().as_input_encrypted_file();
|
||||
}
|
||||
if (!input_file) {
|
||||
return SecretInputMedia{};
|
||||
@ -550,8 +550,8 @@ tl_object_ptr<telegram_api::InputMedia> DocumentsManager::get_input_media(
|
||||
if (file_view.is_encrypted()) {
|
||||
return nullptr;
|
||||
}
|
||||
if (file_view.has_remote_location() && !file_view.remote_location().is_web() && input_file == nullptr) {
|
||||
return make_tl_object<telegram_api::inputMediaDocument>(0, file_view.remote_location().as_input_document(), 0);
|
||||
if (file_view.has_remote_location() && !file_view.main_remote_location().is_web() && input_file == nullptr) {
|
||||
return make_tl_object<telegram_api::inputMediaDocument>(0, file_view.main_remote_location().as_input_document(), 0);
|
||||
}
|
||||
if (file_view.has_url()) {
|
||||
return make_tl_object<telegram_api::inputMediaDocumentExternal>(0, file_view.url(), 0);
|
||||
|
@ -650,19 +650,19 @@ void InlineQueriesManager::answer_inline_query(int64 inline_query_id, bool is_pe
|
||||
if (file_view.is_encrypted()) {
|
||||
return promise.set_error(Status::Error(400, "Can't send encrypted file"));
|
||||
}
|
||||
if (file_view.remote_location().is_web()) {
|
||||
if (file_view.main_remote_location().is_web()) {
|
||||
return promise.set_error(Status::Error(400, "Can't send web file"));
|
||||
}
|
||||
|
||||
if (file_type == FileType::Photo) {
|
||||
auto result = make_tl_object<telegram_api::inputBotInlineResultPhoto>(
|
||||
id, type, file_view.remote_location().as_input_photo(), std::move(inline_message));
|
||||
id, type, file_view.main_remote_location().as_input_photo(), std::move(inline_message));
|
||||
results.push_back(std::move(result));
|
||||
continue;
|
||||
}
|
||||
|
||||
auto result = make_tl_object<telegram_api::inputBotInlineResultDocument>(
|
||||
flags, id, type, title, description, file_view.remote_location().as_input_document(),
|
||||
flags, id, type, title, description, file_view.main_remote_location().as_input_document(),
|
||||
std::move(inline_message));
|
||||
results.push_back(std::move(result));
|
||||
continue;
|
||||
|
@ -2972,9 +2972,9 @@ void merge_message_contents(Td *td, const MessageContent *old_content, MessageCo
|
||||
if (new_file_view.remote_location().is_web()) {
|
||||
LOG(ERROR) << "Have remote web photo location";
|
||||
} else if (!old_file_view.has_remote_location() ||
|
||||
old_file_view.remote_location().get_file_reference() !=
|
||||
old_file_view.main_remote_location().get_file_reference() !=
|
||||
new_file_view.remote_location().get_file_reference() ||
|
||||
old_file_view.remote_location().get_access_hash() !=
|
||||
old_file_view.main_remote_location().get_access_hash() !=
|
||||
new_file_view.remote_location().get_access_hash()) {
|
||||
FileId file_id = td->file_manager_->register_remote(
|
||||
FullRemoteFileLocation({FileType::Photo, 'i'}, new_file_view.remote_location().get_id(),
|
||||
|
@ -6681,12 +6681,12 @@ void MessagesManager::on_upload_dialog_photo(FileId file_id, tl_object_ptr<teleg
|
||||
FileView file_view = td_->file_manager_->get_file_view(file_id);
|
||||
CHECK(!file_view.is_encrypted());
|
||||
if (input_file == nullptr && file_view.has_remote_location()) {
|
||||
if (file_view.remote_location().is_web()) {
|
||||
if (file_view.main_remote_location().is_web()) {
|
||||
// TODO reupload
|
||||
promise.set_error(Status::Error(400, "Can't use web photo as profile photo"));
|
||||
return;
|
||||
}
|
||||
auto input_photo = file_view.remote_location().as_input_photo();
|
||||
auto input_photo = file_view.main_remote_location().as_input_photo();
|
||||
input_chat_photo = make_tl_object<telegram_api::inputChatPhoto>(std::move(input_photo));
|
||||
} else {
|
||||
input_chat_photo = make_tl_object<telegram_api::inputChatUploadedPhoto>(std::move(input_file));
|
||||
@ -22210,9 +22210,9 @@ void MessagesManager::set_dialog_photo(DialogId dialog_id, const tl_object_ptr<t
|
||||
|
||||
FileView file_view = td_->file_manager_->get_file_view(file_id);
|
||||
CHECK(!file_view.is_encrypted());
|
||||
if (file_view.has_remote_location() && !file_view.remote_location().is_web()) {
|
||||
if (file_view.has_remote_location() && !file_view.main_remote_location().is_web()) {
|
||||
// file has already been uploaded, just send change photo request
|
||||
auto input_photo = file_view.remote_location().as_input_photo();
|
||||
auto input_photo = file_view.main_remote_location().as_input_photo();
|
||||
send_edit_dialog_photo_query(
|
||||
dialog_id, file_id, make_tl_object<telegram_api::inputChatPhoto>(std::move(input_photo)), std::move(promise));
|
||||
return;
|
||||
|
@ -627,12 +627,13 @@ tl_object_ptr<telegram_api::InputMedia> photo_get_input_media(FileManager *file_
|
||||
if (file_view.is_encrypted()) {
|
||||
return nullptr;
|
||||
}
|
||||
if (file_view.has_remote_location() && !file_view.remote_location().is_web() && input_file == nullptr) {
|
||||
if (file_view.has_remote_location() && !file_view.main_remote_location().is_web() && input_file == nullptr) {
|
||||
int32 flags = 0;
|
||||
if (ttl != 0) {
|
||||
flags |= telegram_api::inputMediaPhoto::TTL_SECONDS_MASK;
|
||||
}
|
||||
return make_tl_object<telegram_api::inputMediaPhoto>(flags, file_view.remote_location().as_input_photo(), ttl);
|
||||
return make_tl_object<telegram_api::inputMediaPhoto>(flags, file_view.main_remote_location().as_input_photo(),
|
||||
ttl);
|
||||
}
|
||||
if (file_view.has_url()) {
|
||||
int32 flags = 0;
|
||||
@ -695,8 +696,8 @@ SecretInputMedia photo_get_secret_input_media(FileManager *file_manager, const P
|
||||
return {};
|
||||
}
|
||||
if (file_view.has_remote_location()) {
|
||||
LOG(INFO) << "HAS REMOTE LOCATION";
|
||||
input_file = file_view.remote_location().as_input_encrypted_file();
|
||||
LOG(INFO) << "Photo has remote location";
|
||||
input_file = file_view.main_remote_location().as_input_encrypted_file();
|
||||
}
|
||||
if (input_file == nullptr) {
|
||||
return {};
|
||||
|
@ -1648,7 +1648,7 @@ SecretInputMedia StickersManager::get_secret_input_media(FileId sticker_file_id,
|
||||
auto file_view = td_->file_manager_->get_file_view(sticker_file_id);
|
||||
if (file_view.is_encrypted_secret()) {
|
||||
if (file_view.has_remote_location()) {
|
||||
input_file = file_view.remote_location().as_input_encrypted_file();
|
||||
input_file = file_view.main_remote_location().as_input_encrypted_file();
|
||||
}
|
||||
if (!input_file) {
|
||||
return {};
|
||||
@ -1715,8 +1715,8 @@ tl_object_ptr<telegram_api::InputMedia> StickersManager::get_input_media(
|
||||
if (file_view.is_encrypted()) {
|
||||
return nullptr;
|
||||
}
|
||||
if (file_view.has_remote_location() && !file_view.remote_location().is_web() && input_file == nullptr) {
|
||||
return make_tl_object<telegram_api::inputMediaDocument>(0, file_view.remote_location().as_input_document(), 0);
|
||||
if (file_view.has_remote_location() && !file_view.main_remote_location().is_web() && input_file == nullptr) {
|
||||
return make_tl_object<telegram_api::inputMediaDocument>(0, file_view.main_remote_location().as_input_document(), 0);
|
||||
}
|
||||
if (file_view.has_url()) {
|
||||
return make_tl_object<telegram_api::inputMediaDocumentExternal>(0, file_view.url(), 0);
|
||||
@ -3296,12 +3296,12 @@ void StickersManager::send_get_attached_stickers_query(FileId file_id, Promise<U
|
||||
|
||||
tl_object_ptr<telegram_api::InputStickeredMedia> input_stickered_media;
|
||||
string file_reference;
|
||||
if (file_view.remote_location().is_photo()) {
|
||||
auto input_photo = file_view.remote_location().as_input_photo();
|
||||
if (file_view.main_remote_location().is_photo()) {
|
||||
auto input_photo = file_view.main_remote_location().as_input_photo();
|
||||
file_reference = input_photo->file_reference_.as_slice().str();
|
||||
input_stickered_media = make_tl_object<telegram_api::inputStickeredMediaPhoto>(std::move(input_photo));
|
||||
} else {
|
||||
auto input_document = file_view.remote_location().as_input_document();
|
||||
auto input_document = file_view.main_remote_location().as_input_document();
|
||||
file_reference = input_document->file_reference_.as_slice().str();
|
||||
input_stickered_media = make_tl_object<telegram_api::inputStickeredMediaDocument>(std::move(input_document));
|
||||
}
|
||||
@ -3429,13 +3429,13 @@ Result<std::tuple<FileId, bool, bool>> StickersManager::prepare_input_file(
|
||||
return Status::Error(400, "Can't use encrypted file");
|
||||
}
|
||||
|
||||
if (file_view.has_remote_location() && file_view.remote_location().is_web()) {
|
||||
if (file_view.has_remote_location() && file_view.main_remote_location().is_web()) {
|
||||
return Status::Error(400, "Can't use web file to create a sticker");
|
||||
}
|
||||
bool is_url = false;
|
||||
bool is_local = false;
|
||||
if (file_view.has_remote_location()) {
|
||||
CHECK(file_view.remote_location().is_document());
|
||||
CHECK(file_view.main_remote_location().is_document());
|
||||
} else {
|
||||
if (file_view.has_url()) {
|
||||
is_url = true;
|
||||
@ -3487,7 +3487,7 @@ tl_object_ptr<telegram_api::inputStickerSetItem> StickersManager::get_input_stic
|
||||
FileId file_id) const {
|
||||
FileView file_view = td_->file_manager_->get_file_view(file_id);
|
||||
CHECK(file_view.has_remote_location());
|
||||
auto input_document = file_view.remote_location().as_input_document();
|
||||
auto input_document = file_view.main_remote_location().as_input_document();
|
||||
|
||||
tl_object_ptr<telegram_api::maskCoords> mask_coords;
|
||||
if (sticker->mask_position_ != nullptr && sticker->mask_position_->point_ != nullptr) {
|
||||
@ -3808,13 +3808,13 @@ void StickersManager::set_sticker_position_in_set(const tl_object_ptr<td_api::In
|
||||
|
||||
auto file_id = r_file_id.move_as_ok();
|
||||
auto file_view = td_->file_manager_->get_file_view(file_id);
|
||||
if (!file_view.has_remote_location() || !file_view.remote_location().is_document() ||
|
||||
file_view.remote_location().is_web()) {
|
||||
if (!file_view.has_remote_location() || !file_view.main_remote_location().is_document() ||
|
||||
file_view.main_remote_location().is_web()) {
|
||||
return promise.set_error(Status::Error(7, "Wrong sticker file specified"));
|
||||
}
|
||||
|
||||
td_->create_handler<SetStickerPositionQuery>(std::move(promise))
|
||||
->send(file_view.remote_location().as_input_document(), position);
|
||||
->send(file_view.main_remote_location().as_input_document(), position);
|
||||
}
|
||||
|
||||
void StickersManager::remove_sticker_from_set(const tl_object_ptr<td_api::InputFile> &sticker,
|
||||
@ -3826,13 +3826,13 @@ void StickersManager::remove_sticker_from_set(const tl_object_ptr<td_api::InputF
|
||||
|
||||
auto file_id = r_file_id.move_as_ok();
|
||||
auto file_view = td_->file_manager_->get_file_view(file_id);
|
||||
if (!file_view.has_remote_location() || !file_view.remote_location().is_document() ||
|
||||
file_view.remote_location().is_web()) {
|
||||
if (!file_view.has_remote_location() || !file_view.main_remote_location().is_document() ||
|
||||
file_view.main_remote_location().is_web()) {
|
||||
return promise.set_error(Status::Error(7, "Wrong sticker file specified"));
|
||||
}
|
||||
|
||||
td_->create_handler<DeleteStickerFromSetQuery>(std::move(promise))
|
||||
->send(file_view.remote_location().as_input_document());
|
||||
->send(file_view.main_remote_location().as_input_document());
|
||||
}
|
||||
|
||||
vector<FileId> StickersManager::get_attached_sticker_file_ids(const vector<int32> &int_file_ids) {
|
||||
|
@ -174,7 +174,7 @@ SecretInputMedia VideoNotesManager::get_secret_input_media(FileId video_note_fil
|
||||
return SecretInputMedia{};
|
||||
}
|
||||
if (file_view.has_remote_location()) {
|
||||
input_file = file_view.remote_location().as_input_encrypted_file();
|
||||
input_file = file_view.main_remote_location().as_input_encrypted_file();
|
||||
}
|
||||
if (!input_file) {
|
||||
return SecretInputMedia{};
|
||||
@ -202,8 +202,8 @@ tl_object_ptr<telegram_api::InputMedia> VideoNotesManager::get_input_media(
|
||||
if (file_view.is_encrypted()) {
|
||||
return nullptr;
|
||||
}
|
||||
if (file_view.has_remote_location() && !file_view.remote_location().is_web() && input_file == nullptr) {
|
||||
return make_tl_object<telegram_api::inputMediaDocument>(0, file_view.remote_location().as_input_document(), 0);
|
||||
if (file_view.has_remote_location() && !file_view.main_remote_location().is_web() && input_file == nullptr) {
|
||||
return make_tl_object<telegram_api::inputMediaDocument>(0, file_view.main_remote_location().as_input_document(), 0);
|
||||
}
|
||||
if (file_view.has_url()) {
|
||||
return make_tl_object<telegram_api::inputMediaDocumentExternal>(0, file_view.url(), 0);
|
||||
|
@ -201,7 +201,7 @@ SecretInputMedia VideosManager::get_secret_input_media(FileId video_file_id,
|
||||
return SecretInputMedia{};
|
||||
}
|
||||
if (file_view.has_remote_location()) {
|
||||
input_file = file_view.remote_location().as_input_encrypted_file();
|
||||
input_file = file_view.main_remote_location().as_input_encrypted_file();
|
||||
}
|
||||
if (!input_file) {
|
||||
return SecretInputMedia{};
|
||||
@ -228,12 +228,12 @@ tl_object_ptr<telegram_api::InputMedia> VideosManager::get_input_media(
|
||||
if (file_view.is_encrypted()) {
|
||||
return nullptr;
|
||||
}
|
||||
if (file_view.has_remote_location() && !file_view.remote_location().is_web() && input_file == nullptr) {
|
||||
if (file_view.has_remote_location() && !file_view.main_remote_location().is_web() && input_file == nullptr) {
|
||||
int32 flags = 0;
|
||||
if (ttl != 0) {
|
||||
flags |= telegram_api::inputMediaDocument::TTL_SECONDS_MASK;
|
||||
}
|
||||
return make_tl_object<telegram_api::inputMediaDocument>(flags, file_view.remote_location().as_input_document(),
|
||||
return make_tl_object<telegram_api::inputMediaDocument>(flags, file_view.main_remote_location().as_input_document(),
|
||||
ttl);
|
||||
}
|
||||
if (file_view.has_url()) {
|
||||
|
@ -147,7 +147,7 @@ SecretInputMedia VoiceNotesManager::get_secret_input_media(FileId voice_file_id,
|
||||
return SecretInputMedia{};
|
||||
}
|
||||
if (file_view.has_remote_location()) {
|
||||
input_file = file_view.remote_location().as_input_encrypted_file();
|
||||
input_file = file_view.main_remote_location().as_input_encrypted_file();
|
||||
}
|
||||
if (!input_file) {
|
||||
return SecretInputMedia{};
|
||||
@ -169,8 +169,8 @@ tl_object_ptr<telegram_api::InputMedia> VoiceNotesManager::get_input_media(
|
||||
if (file_view.is_encrypted()) {
|
||||
return nullptr;
|
||||
}
|
||||
if (file_view.has_remote_location() && !file_view.remote_location().is_web() && input_file == nullptr) {
|
||||
return make_tl_object<telegram_api::inputMediaDocument>(0, file_view.remote_location().as_input_document(), 0);
|
||||
if (file_view.has_remote_location() && !file_view.main_remote_location().is_web() && input_file == nullptr) {
|
||||
return make_tl_object<telegram_api::inputMediaDocument>(0, file_view.main_remote_location().as_input_document(), 0);
|
||||
}
|
||||
if (file_view.has_url()) {
|
||||
return make_tl_object<telegram_api::inputMediaDocumentExternal>(0, file_view.url(), 0);
|
||||
|
@ -469,13 +469,16 @@ bool FileView::has_alive_remote_location() const {
|
||||
}
|
||||
|
||||
bool FileView::has_active_upload_remote_location() const {
|
||||
if (!has_remote_location()) {
|
||||
return false;
|
||||
}
|
||||
if (!has_alive_remote_location()) {
|
||||
return false;
|
||||
}
|
||||
if (remote_location().is_encrypted_any()) {
|
||||
if (main_remote_location().is_encrypted_any()) {
|
||||
return true;
|
||||
}
|
||||
return remote_location().has_file_reference();
|
||||
return main_remote_location().has_file_reference();
|
||||
}
|
||||
|
||||
bool FileView::has_active_download_remote_location() const {
|
||||
@ -497,6 +500,11 @@ const FullRemoteFileLocation &FileView::remote_location() const {
|
||||
return node_->remote_.full.value();
|
||||
}
|
||||
|
||||
const FullRemoteFileLocation &FileView::main_remote_location() const {
|
||||
CHECK(has_remote_location());
|
||||
return node_->remote_.full.value();
|
||||
}
|
||||
|
||||
bool FileView::has_generate_location() const {
|
||||
return node_->generate_ != nullptr;
|
||||
}
|
||||
|
@ -240,6 +240,7 @@ class FileView {
|
||||
bool has_active_upload_remote_location() const;
|
||||
bool has_active_download_remote_location() const;
|
||||
const FullRemoteFileLocation &remote_location() const;
|
||||
const FullRemoteFileLocation &main_remote_location() const;
|
||||
bool has_generate_location() const;
|
||||
const FullGenerateFileLocation &generate_location() const;
|
||||
|
||||
|
Reference in New Issue
Block a user