Prefer InputFile over remote location in get_input_media.
GitOrigin-RevId: 01db2a0669b966ddac59b7f18b62f154cb54a427
This commit is contained in:
parent
37efb237c7
commit
ed25f88c19
@ -296,15 +296,14 @@ tl_object_ptr<telegram_api::InputMedia> AnimationsManager::get_input_media(
|
|||||||
if (file_view.is_encrypted()) {
|
if (file_view.is_encrypted()) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
if (file_view.has_remote_location() && !file_view.remote_location().is_web()) {
|
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);
|
return make_tl_object<telegram_api::inputMediaDocument>(0, file_view.remote_location().as_input_document(), 0);
|
||||||
}
|
}
|
||||||
if (file_view.has_url()) {
|
if (file_view.has_url()) {
|
||||||
return make_tl_object<telegram_api::inputMediaDocumentExternal>(0, file_view.url(), 0);
|
return make_tl_object<telegram_api::inputMediaDocumentExternal>(0, file_view.url(), 0);
|
||||||
}
|
}
|
||||||
CHECK(!file_view.has_remote_location());
|
|
||||||
|
|
||||||
if (input_file) {
|
if (input_file != nullptr) {
|
||||||
const Animation *animation = get_animation(file_id);
|
const Animation *animation = get_animation(file_id);
|
||||||
CHECK(animation != nullptr);
|
CHECK(animation != nullptr);
|
||||||
|
|
||||||
@ -331,6 +330,8 @@ tl_object_ptr<telegram_api::InputMedia> AnimationsManager::get_input_media(
|
|||||||
return make_tl_object<telegram_api::inputMediaUploadedDocument>(
|
return make_tl_object<telegram_api::inputMediaUploadedDocument>(
|
||||||
flags, false /*ignored*/, std::move(input_file), std::move(input_thumbnail), mime_type, std::move(attributes),
|
flags, false /*ignored*/, std::move(input_file), std::move(input_thumbnail), mime_type, std::move(attributes),
|
||||||
vector<tl_object_ptr<telegram_api::InputDocument>>(), 0);
|
vector<tl_object_ptr<telegram_api::InputDocument>>(), 0);
|
||||||
|
} else {
|
||||||
|
CHECK(!file_view.has_remote_location());
|
||||||
}
|
}
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -218,13 +218,12 @@ tl_object_ptr<telegram_api::InputMedia> AudiosManager::get_input_media(
|
|||||||
if (file_view.is_encrypted()) {
|
if (file_view.is_encrypted()) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
if (file_view.has_remote_location() && !file_view.remote_location().is_web()) {
|
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);
|
return make_tl_object<telegram_api::inputMediaDocument>(0, file_view.remote_location().as_input_document(), 0);
|
||||||
}
|
}
|
||||||
if (file_view.has_url()) {
|
if (file_view.has_url()) {
|
||||||
return make_tl_object<telegram_api::inputMediaDocumentExternal>(0, file_view.url(), 0);
|
return make_tl_object<telegram_api::inputMediaDocumentExternal>(0, file_view.url(), 0);
|
||||||
}
|
}
|
||||||
CHECK(!file_view.has_remote_location());
|
|
||||||
|
|
||||||
if (input_file != nullptr) {
|
if (input_file != nullptr) {
|
||||||
const Audio *audio = get_audio(file_id);
|
const Audio *audio = get_audio(file_id);
|
||||||
@ -248,6 +247,8 @@ tl_object_ptr<telegram_api::InputMedia> AudiosManager::get_input_media(
|
|||||||
return make_tl_object<telegram_api::inputMediaUploadedDocument>(
|
return make_tl_object<telegram_api::inputMediaUploadedDocument>(
|
||||||
flags, false /*ignored*/, std::move(input_file), std::move(input_thumbnail), mime_type, std::move(attributes),
|
flags, false /*ignored*/, std::move(input_file), std::move(input_thumbnail), mime_type, std::move(attributes),
|
||||||
vector<tl_object_ptr<telegram_api::InputDocument>>(), 0);
|
vector<tl_object_ptr<telegram_api::InputDocument>>(), 0);
|
||||||
|
} else {
|
||||||
|
CHECK(!file_view.has_remote_location());
|
||||||
}
|
}
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -9720,7 +9720,7 @@ void ContactsManager::on_upload_profile_photo(FileId file_id, tl_object_ptr<tele
|
|||||||
uploaded_profile_photos_.erase(it);
|
uploaded_profile_photos_.erase(it);
|
||||||
|
|
||||||
FileView file_view = td_->file_manager_->get_file_view(file_id);
|
FileView file_view = td_->file_manager_->get_file_view(file_id);
|
||||||
if (file_view.has_remote_location()) {
|
if (file_view.has_remote_location() && input_file == nullptr) {
|
||||||
if (file_view.remote_location().is_web()) {
|
if (file_view.remote_location().is_web()) {
|
||||||
// TODO reupload
|
// TODO reupload
|
||||||
promise.set_error(Status::Error(400, "Can't use web photo as profile photo"));
|
promise.set_error(Status::Error(400, "Can't use web photo as profile photo"));
|
||||||
|
@ -483,13 +483,12 @@ tl_object_ptr<telegram_api::InputMedia> DocumentsManager::get_input_media(
|
|||||||
if (file_view.is_encrypted()) {
|
if (file_view.is_encrypted()) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
if (file_view.has_remote_location() && !file_view.remote_location().is_web()) {
|
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);
|
return make_tl_object<telegram_api::inputMediaDocument>(0, file_view.remote_location().as_input_document(), 0);
|
||||||
}
|
}
|
||||||
if (file_view.has_url()) {
|
if (file_view.has_url()) {
|
||||||
return make_tl_object<telegram_api::inputMediaDocumentExternal>(0, file_view.url(), 0);
|
return make_tl_object<telegram_api::inputMediaDocumentExternal>(0, file_view.url(), 0);
|
||||||
}
|
}
|
||||||
CHECK(!file_view.has_remote_location());
|
|
||||||
|
|
||||||
if (input_file != nullptr) {
|
if (input_file != nullptr) {
|
||||||
const Document *document = get_document(file_id);
|
const Document *document = get_document(file_id);
|
||||||
@ -506,6 +505,8 @@ tl_object_ptr<telegram_api::InputMedia> DocumentsManager::get_input_media(
|
|||||||
return make_tl_object<telegram_api::inputMediaUploadedDocument>(
|
return make_tl_object<telegram_api::inputMediaUploadedDocument>(
|
||||||
flags, false /*ignored*/, std::move(input_file), std::move(input_thumbnail), document->mime_type,
|
flags, false /*ignored*/, std::move(input_file), std::move(input_thumbnail), document->mime_type,
|
||||||
std::move(attributes), vector<tl_object_ptr<telegram_api::InputDocument>>(), 0);
|
std::move(attributes), vector<tl_object_ptr<telegram_api::InputDocument>>(), 0);
|
||||||
|
} else {
|
||||||
|
CHECK(!file_view.has_remote_location());
|
||||||
}
|
}
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -564,7 +564,7 @@ tl_object_ptr<telegram_api::InputMedia> photo_get_input_media(FileManager *file_
|
|||||||
if (file_view.is_encrypted()) {
|
if (file_view.is_encrypted()) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
if (file_view.has_remote_location() && !file_view.remote_location().is_web()) {
|
if (file_view.has_remote_location() && !file_view.remote_location().is_web() && input_file == nullptr) {
|
||||||
int32 flags = 0;
|
int32 flags = 0;
|
||||||
if (ttl != 0) {
|
if (ttl != 0) {
|
||||||
flags |= telegram_api::inputMediaPhoto::TTL_SECONDS_MASK;
|
flags |= telegram_api::inputMediaPhoto::TTL_SECONDS_MASK;
|
||||||
@ -579,7 +579,9 @@ tl_object_ptr<telegram_api::InputMedia> photo_get_input_media(FileManager *file_
|
|||||||
LOG(INFO) << "Create inputMediaPhotoExternal with a URL " << file_view.url() << " and ttl " << ttl;
|
LOG(INFO) << "Create inputMediaPhotoExternal with a URL " << file_view.url() << " and ttl " << ttl;
|
||||||
return make_tl_object<telegram_api::inputMediaPhotoExternal>(flags, file_view.url(), ttl);
|
return make_tl_object<telegram_api::inputMediaPhotoExternal>(flags, file_view.url(), ttl);
|
||||||
}
|
}
|
||||||
CHECK(!file_view.has_remote_location());
|
if (input_file == nullptr) {
|
||||||
|
CHECK(!file_view.has_remote_location());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (input_file != nullptr) {
|
if (input_file != nullptr) {
|
||||||
int32 flags = 0;
|
int32 flags = 0;
|
||||||
|
@ -1521,13 +1521,12 @@ tl_object_ptr<telegram_api::InputMedia> StickersManager::get_input_media(
|
|||||||
if (file_view.is_encrypted()) {
|
if (file_view.is_encrypted()) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
if (file_view.has_remote_location() && !file_view.remote_location().is_web()) {
|
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);
|
return make_tl_object<telegram_api::inputMediaDocument>(0, file_view.remote_location().as_input_document(), 0);
|
||||||
}
|
}
|
||||||
if (file_view.has_url()) {
|
if (file_view.has_url()) {
|
||||||
return make_tl_object<telegram_api::inputMediaDocumentExternal>(0, file_view.url(), 0);
|
return make_tl_object<telegram_api::inputMediaDocumentExternal>(0, file_view.url(), 0);
|
||||||
}
|
}
|
||||||
CHECK(!file_view.has_remote_location());
|
|
||||||
|
|
||||||
if (input_file != nullptr) {
|
if (input_file != nullptr) {
|
||||||
const Sticker *s = get_sticker(file_id);
|
const Sticker *s = get_sticker(file_id);
|
||||||
@ -1548,6 +1547,8 @@ tl_object_ptr<telegram_api::InputMedia> StickersManager::get_input_media(
|
|||||||
return make_tl_object<telegram_api::inputMediaUploadedDocument>(
|
return make_tl_object<telegram_api::inputMediaUploadedDocument>(
|
||||||
flags, false /*ignored*/, std::move(input_file), std::move(input_thumbnail), "image/webp",
|
flags, false /*ignored*/, std::move(input_file), std::move(input_thumbnail), "image/webp",
|
||||||
std::move(attributes), vector<tl_object_ptr<telegram_api::InputDocument>>(), 0);
|
std::move(attributes), vector<tl_object_ptr<telegram_api::InputDocument>>(), 0);
|
||||||
|
} else {
|
||||||
|
CHECK(!file_view.has_remote_location());
|
||||||
}
|
}
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -195,13 +195,12 @@ tl_object_ptr<telegram_api::InputMedia> VideoNotesManager::get_input_media(
|
|||||||
if (file_view.is_encrypted()) {
|
if (file_view.is_encrypted()) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
if (file_view.has_remote_location() && !file_view.remote_location().is_web()) {
|
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);
|
return make_tl_object<telegram_api::inputMediaDocument>(0, file_view.remote_location().as_input_document(), 0);
|
||||||
}
|
}
|
||||||
if (file_view.has_url()) {
|
if (file_view.has_url()) {
|
||||||
return make_tl_object<telegram_api::inputMediaDocumentExternal>(0, file_view.url(), 0);
|
return make_tl_object<telegram_api::inputMediaDocumentExternal>(0, file_view.url(), 0);
|
||||||
}
|
}
|
||||||
CHECK(!file_view.has_remote_location());
|
|
||||||
|
|
||||||
if (input_file != nullptr) {
|
if (input_file != nullptr) {
|
||||||
const VideoNote *video_note = get_video_note(file_id);
|
const VideoNote *video_note = get_video_note(file_id);
|
||||||
@ -219,6 +218,8 @@ tl_object_ptr<telegram_api::InputMedia> VideoNotesManager::get_input_media(
|
|||||||
return make_tl_object<telegram_api::inputMediaUploadedDocument>(
|
return make_tl_object<telegram_api::inputMediaUploadedDocument>(
|
||||||
flags, false /*ignored*/, std::move(input_file), std::move(input_thumbnail), "video/mp4", std::move(attributes),
|
flags, false /*ignored*/, std::move(input_file), std::move(input_thumbnail), "video/mp4", std::move(attributes),
|
||||||
vector<tl_object_ptr<telegram_api::InputDocument>>(), 0);
|
vector<tl_object_ptr<telegram_api::InputDocument>>(), 0);
|
||||||
|
} else {
|
||||||
|
CHECK(!file_view.has_remote_location());
|
||||||
}
|
}
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -222,7 +222,7 @@ tl_object_ptr<telegram_api::InputMedia> VideosManager::get_input_media(
|
|||||||
if (file_view.is_encrypted()) {
|
if (file_view.is_encrypted()) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
if (file_view.has_remote_location() && !file_view.remote_location().is_web()) {
|
if (file_view.has_remote_location() && !file_view.remote_location().is_web() && input_file == nullptr) {
|
||||||
int32 flags = 0;
|
int32 flags = 0;
|
||||||
if (ttl != 0) {
|
if (ttl != 0) {
|
||||||
flags |= telegram_api::inputMediaDocument::TTL_SECONDS_MASK;
|
flags |= telegram_api::inputMediaDocument::TTL_SECONDS_MASK;
|
||||||
@ -237,7 +237,6 @@ tl_object_ptr<telegram_api::InputMedia> VideosManager::get_input_media(
|
|||||||
}
|
}
|
||||||
return make_tl_object<telegram_api::inputMediaDocumentExternal>(flags, file_view.url(), ttl);
|
return make_tl_object<telegram_api::inputMediaDocumentExternal>(flags, file_view.url(), ttl);
|
||||||
}
|
}
|
||||||
CHECK(!file_view.has_remote_location());
|
|
||||||
|
|
||||||
if (input_file != nullptr) {
|
if (input_file != nullptr) {
|
||||||
const Video *video = get_video(file_id);
|
const Video *video = get_video(file_id);
|
||||||
@ -277,6 +276,8 @@ tl_object_ptr<telegram_api::InputMedia> VideosManager::get_input_media(
|
|||||||
return make_tl_object<telegram_api::inputMediaUploadedDocument>(
|
return make_tl_object<telegram_api::inputMediaUploadedDocument>(
|
||||||
flags, false /*ignored*/, std::move(input_file), std::move(input_thumbnail), mime_type, std::move(attributes),
|
flags, false /*ignored*/, std::move(input_file), std::move(input_thumbnail), mime_type, std::move(attributes),
|
||||||
std::move(added_stickers), ttl);
|
std::move(added_stickers), ttl);
|
||||||
|
} else {
|
||||||
|
CHECK(!file_view.has_remote_location());
|
||||||
}
|
}
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -168,13 +168,12 @@ tl_object_ptr<telegram_api::InputMedia> VoiceNotesManager::get_input_media(
|
|||||||
if (file_view.is_encrypted()) {
|
if (file_view.is_encrypted()) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
if (file_view.has_remote_location() && !file_view.remote_location().is_web()) {
|
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);
|
return make_tl_object<telegram_api::inputMediaDocument>(0, file_view.remote_location().as_input_document(), 0);
|
||||||
}
|
}
|
||||||
if (file_view.has_url()) {
|
if (file_view.has_url()) {
|
||||||
return make_tl_object<telegram_api::inputMediaDocumentExternal>(0, file_view.url(), 0);
|
return make_tl_object<telegram_api::inputMediaDocumentExternal>(0, file_view.url(), 0);
|
||||||
}
|
}
|
||||||
CHECK(!file_view.has_remote_location());
|
|
||||||
|
|
||||||
if (input_file != nullptr) {
|
if (input_file != nullptr) {
|
||||||
const VoiceNote *voice_note = get_voice_note(file_id);
|
const VoiceNote *voice_note = get_voice_note(file_id);
|
||||||
@ -194,6 +193,8 @@ tl_object_ptr<telegram_api::InputMedia> VoiceNotesManager::get_input_media(
|
|||||||
return make_tl_object<telegram_api::inputMediaUploadedDocument>(
|
return make_tl_object<telegram_api::inputMediaUploadedDocument>(
|
||||||
0, false /*ignored*/, std::move(input_file), nullptr, mime_type, std::move(attributes),
|
0, false /*ignored*/, std::move(input_file), nullptr, mime_type, std::move(attributes),
|
||||||
vector<tl_object_ptr<telegram_api::InputDocument>>(), 0);
|
vector<tl_object_ptr<telegram_api::InputDocument>>(), 0);
|
||||||
|
} else {
|
||||||
|
CHECK(!file_view.has_remote_location());
|
||||||
}
|
}
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
Loading…
Reference in New Issue
Block a user