Add inputMessageDocument.force_file.

GitOrigin-RevId: 7f2780ba7f333e5f8df9c28bab429b8b12eaf26c
This commit is contained in:
levlam 2020-06-22 02:02:21 +03:00
parent 4f005e3356
commit d5b4c57993
24 changed files with 84 additions and 48 deletions

View File

@ -1644,8 +1644,8 @@ inputMessageAnimation animation:InputFile thumbnail:inputThumbnail added_sticker
//@performer Performer of the audio; 0-64 characters, may be replaced by the server @caption Audio caption; 0-GetOption("message_caption_length_max") characters //@performer Performer of the audio; 0-64 characters, may be replaced by the server @caption Audio caption; 0-GetOption("message_caption_length_max") characters
inputMessageAudio audio:InputFile album_cover_thumbnail:inputThumbnail duration:int32 title:string performer:string caption:formattedText = InputMessageContent; inputMessageAudio audio:InputFile album_cover_thumbnail:inputThumbnail duration:int32 title:string performer:string caption:formattedText = InputMessageContent;
//@description A document message (general file) @document Document to be sent @thumbnail Document thumbnail, if available @caption Document caption; 0-GetOption("message_caption_length_max") characters //@description A document message (general file) @document Document to be sent @thumbnail Document thumbnail, if available @force_file If true, automatic file type detection will be disabled and the document will be always sent as file. Always true for files sent to secret chats @caption Document caption; 0-GetOption("message_caption_length_max") characters
inputMessageDocument document:InputFile thumbnail:inputThumbnail caption:formattedText = InputMessageContent; inputMessageDocument document:InputFile thumbnail:inputThumbnail force_file:Bool caption:formattedText = InputMessageContent;
//@description A photo message @photo Photo to send @thumbnail Photo thumbnail to be sent, this is sent to the other party in secret chats only @added_sticker_file_ids File identifiers of the stickers added to the photo, if applicable @width Photo width @height Photo height @caption Photo caption; 0-GetOption("message_caption_length_max") characters //@description A photo message @photo Photo to send @thumbnail Photo thumbnail to be sent, this is sent to the other party in secret chats only @added_sticker_file_ids File identifiers of the stickers added to the photo, if applicable @width Photo width @height Photo height @caption Photo caption; 0-GetOption("message_caption_length_max") characters
//@ttl Photo TTL (Time To Live), in seconds (0-60). A non-zero TTL can be specified only in private chats //@ttl Photo TTL (Time To Live), in seconds (0-60). A non-zero TTL can be specified only in private chats

Binary file not shown.

View File

@ -49,7 +49,7 @@ inputMediaUploadedPhoto#1e287d04 flags:# file:InputFile stickers:flags.0?Vector<
inputMediaPhoto#b3ba0635 flags:# id:InputPhoto ttl_seconds:flags.0?int = InputMedia; inputMediaPhoto#b3ba0635 flags:# id:InputPhoto ttl_seconds:flags.0?int = InputMedia;
inputMediaGeoPoint#f9c44144 geo_point:InputGeoPoint = InputMedia; inputMediaGeoPoint#f9c44144 geo_point:InputGeoPoint = InputMedia;
inputMediaContact#f8ab7dfb phone_number:string first_name:string last_name:string vcard:string = InputMedia; inputMediaContact#f8ab7dfb phone_number:string first_name:string last_name:string vcard:string = InputMedia;
inputMediaUploadedDocument#5b38c6c1 flags:# nosound_video:flags.3?true file:InputFile thumb:flags.2?InputFile mime_type:string attributes:Vector<DocumentAttribute> stickers:flags.0?Vector<InputDocument> ttl_seconds:flags.1?int = InputMedia; inputMediaUploadedDocument#5b38c6c1 flags:# nosound_video:flags.3?true force_file:flags.4?true file:InputFile thumb:flags.2?InputFile mime_type:string attributes:Vector<DocumentAttribute> stickers:flags.0?Vector<InputDocument> ttl_seconds:flags.1?int = InputMedia;
inputMediaDocument#23ab23d2 flags:# id:InputDocument ttl_seconds:flags.0?int = InputMedia; inputMediaDocument#23ab23d2 flags:# id:InputDocument ttl_seconds:flags.0?int = InputMedia;
inputMediaVenue#c13d1c11 geo_point:InputGeoPoint title:string address:string provider:string venue_id:string venue_type:string = InputMedia; inputMediaVenue#c13d1c11 geo_point:InputGeoPoint title:string address:string provider:string venue_id:string venue_type:string = InputMedia;
inputMediaPhotoExternal#e5bbfe1a flags:# url:string ttl_seconds:flags.0?int = InputMedia; inputMediaPhotoExternal#e5bbfe1a flags:# url:string ttl_seconds:flags.0?int = InputMedia;

Binary file not shown.

View File

@ -381,8 +381,8 @@ tl_object_ptr<telegram_api::InputMedia> AnimationsManager::get_input_media(
flags |= telegram_api::inputMediaUploadedDocument::THUMB_MASK; flags |= telegram_api::inputMediaUploadedDocument::THUMB_MASK;
} }
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*/, false /*ignored*/, std::move(input_file), std::move(input_thumbnail), mime_type,
vector<tl_object_ptr<telegram_api::InputDocument>>(), 0); std::move(attributes), vector<tl_object_ptr<telegram_api::InputDocument>>(), 0);
} else { } else {
CHECK(!file_view.has_remote_location()); CHECK(!file_view.has_remote_location());
} }

View File

@ -253,8 +253,8 @@ tl_object_ptr<telegram_api::InputMedia> AudiosManager::get_input_media(
flags |= telegram_api::inputMediaUploadedDocument::THUMB_MASK; flags |= telegram_api::inputMediaUploadedDocument::THUMB_MASK;
} }
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*/, false /*ignored*/, std::move(input_file), std::move(input_thumbnail), mime_type,
vector<tl_object_ptr<telegram_api::InputDocument>>(), 0); std::move(attributes), vector<tl_object_ptr<telegram_api::InputDocument>>(), 0);
} else { } else {
CHECK(!file_view.has_remote_location()); CHECK(!file_view.has_remote_location());
} }

View File

@ -599,9 +599,12 @@ tl_object_ptr<telegram_api::InputMedia> DocumentsManager::get_input_media(
if (input_thumbnail != nullptr) { if (input_thumbnail != nullptr) {
flags |= telegram_api::inputMediaUploadedDocument::THUMB_MASK; flags |= telegram_api::inputMediaUploadedDocument::THUMB_MASK;
} }
if (file_view.get_type() == FileType::DocumentAsFile) {
flags |= telegram_api::inputMediaUploadedDocument::FORCE_FILE_MASK;
}
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*/, false /*ignored*/, std::move(input_file), std::move(input_thumbnail),
std::move(attributes), vector<tl_object_ptr<telegram_api::InputDocument>>(), 0); document->mime_type, std::move(attributes), vector<tl_object_ptr<telegram_api::InputDocument>>(), 0);
} else { } else {
CHECK(!file_view.has_remote_location()); CHECK(!file_view.has_remote_location());
} }

View File

@ -1855,8 +1855,9 @@ Result<InputMessageContent> get_input_message_content(
} }
case td_api::inputMessageDocument::ID: { case td_api::inputMessageDocument::ID: {
auto input_message = static_cast<td_api::inputMessageDocument *>(input_message_content.get()); auto input_message = static_cast<td_api::inputMessageDocument *>(input_message_content.get());
r_file_id = td->file_manager_->get_input_file_id(FileType::Document, input_message->document_, dialog_id, false, auto file_type = input_message->force_file_ ? FileType::DocumentAsFile : FileType::Document;
is_secret, true); r_file_id =
td->file_manager_->get_input_file_id(file_type, input_message->document_, dialog_id, false, is_secret, true);
input_thumbnail = std::move(input_message->thumbnail_); input_thumbnail = std::move(input_message->thumbnail_);
break; break;
} }

View File

@ -29774,6 +29774,7 @@ bool MessagesManager::update_message_content(DialogId dialog_id, Message *old_me
case FileType::Animation: case FileType::Animation:
case FileType::Audio: case FileType::Audio:
case FileType::Document: case FileType::Document:
case FileType::DocumentAsFile:
case FileType::Sticker: case FileType::Sticker:
case FileType::Video: case FileType::Video:
case FileType::VideoNote: case FileType::VideoNote:

View File

@ -2103,8 +2103,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), mime_type, std::move(attributes), flags, false /*ignored*/, false /*ignored*/, std::move(input_file), std::move(input_thumbnail), mime_type,
vector<tl_object_ptr<telegram_api::InputDocument>>(), 0); std::move(attributes), vector<tl_object_ptr<telegram_api::InputDocument>>(), 0);
} else { } else {
CHECK(!file_view.has_remote_location()); CHECK(!file_view.has_remote_location());
} }

View File

@ -223,8 +223,8 @@ tl_object_ptr<telegram_api::InputMedia> VideoNotesManager::get_input_media(
flags |= telegram_api::inputMediaUploadedDocument::THUMB_MASK; flags |= telegram_api::inputMediaUploadedDocument::THUMB_MASK;
} }
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*/, false /*ignored*/, std::move(input_file), std::move(input_thumbnail), "video/mp4",
vector<tl_object_ptr<telegram_api::InputDocument>>(), 0); std::move(attributes), vector<tl_object_ptr<telegram_api::InputDocument>>(), 0);
} else { } else {
CHECK(!file_view.has_remote_location()); CHECK(!file_view.has_remote_location());
} }

View File

@ -299,8 +299,8 @@ tl_object_ptr<telegram_api::InputMedia> VideosManager::get_input_media(
flags |= telegram_api::inputMediaUploadedDocument::THUMB_MASK; flags |= telegram_api::inputMediaUploadedDocument::THUMB_MASK;
} }
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*/, false /*ignored*/, std::move(input_file), std::move(input_thumbnail), mime_type,
std::move(added_stickers), ttl); std::move(attributes), std::move(added_stickers), ttl);
} else { } else {
CHECK(!file_view.has_remote_location()); CHECK(!file_view.has_remote_location());
} }

View File

@ -192,7 +192,7 @@ tl_object_ptr<telegram_api::InputMedia> VoiceNotesManager::get_input_media(
mime_type = "audio/ogg"; mime_type = "audio/ogg";
} }
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*/, 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 { } else {
CHECK(!file_view.has_remote_location()); CHECK(!file_view.has_remote_location());

View File

@ -2991,7 +2991,7 @@ class CliClient final : public Actor {
std::tie(message_id, document) = split(args); std::tie(message_id, document) = split(args);
send_request(td_api::make_object<td_api::editMessageMedia>( send_request(td_api::make_object<td_api::editMessageMedia>(
as_chat_id(chat_id), as_message_id(message_id), nullptr, as_chat_id(chat_id), as_message_id(message_id), nullptr,
td_api::make_object<td_api::inputMessageDocument>(as_input_file(document), nullptr, as_caption("")))); td_api::make_object<td_api::inputMessageDocument>(as_input_file(document), nullptr, false, as_caption(""))));
} else if (op == "emp") { } else if (op == "emp") {
string chat_id; string chat_id;
string message_id; string message_id;
@ -3188,22 +3188,22 @@ class CliClient final : public Actor {
std::tie(chat_id, emoji) = split(args); std::tie(chat_id, emoji) = split(args);
send_message(chat_id, td_api::make_object<td_api::inputMessageDice>(emoji, op == "sdicecd")); send_message(chat_id, td_api::make_object<td_api::inputMessageDice>(emoji, op == "sdicecd"));
} else if (op == "sd") { } else if (op == "sd" || op == "sdf") {
string chat_id; string chat_id;
string document_path; string document_path;
std::tie(chat_id, document_path) = split(args); std::tie(chat_id, document_path) = split(args);
send_message(chat_id, td_api::make_object<td_api::inputMessageDocument>( send_message(chat_id, td_api::make_object<td_api::inputMessageDocument>(
as_input_file(document_path), nullptr, as_input_file(document_path), nullptr, op == "sdf",
as_caption(u8"\u1680\u180Etest \u180E\n\u180E\n\u180E\n cap\ttion\u180E\u180E"))); as_caption(u8"\u1680\u180Etest \u180E\n\u180E\n\u180E\n cap\ttion\u180E\u180E")));
} else if (op == "sdt") { } else if (op == "sdt" || op == "sdtf") {
string chat_id; string chat_id;
string document_path; string document_path;
string thumbnail_path; string thumbnail_path;
std::tie(chat_id, args) = split(args); std::tie(chat_id, args) = split(args);
std::tie(document_path, thumbnail_path) = split(args); std::tie(document_path, thumbnail_path) = split(args);
send_message(chat_id, send_message(chat_id, td_api::make_object<td_api::inputMessageDocument>(
td_api::make_object<td_api::inputMessageDocument>( as_input_file(document_path), as_input_thumbnail(thumbnail_path), op == "sdtf",
as_input_file(document_path), as_input_thumbnail(thumbnail_path), as_caption("test caption"))); as_caption("test caption")));
} else if (op == "sdg" || op == "sdgu") { } else if (op == "sdg" || op == "sdgu") {
string chat_id; string chat_id;
string document_path; string document_path;
@ -3214,9 +3214,9 @@ class CliClient final : public Actor {
send_request( send_request(
td_api::make_object<td_api::uploadFile>(as_generated_file(document_path, document_conversion), nullptr, 1)); td_api::make_object<td_api::uploadFile>(as_generated_file(document_path, document_conversion), nullptr, 1));
} }
send_message(chat_id, send_message(chat_id, td_api::make_object<td_api::inputMessageDocument>(
td_api::make_object<td_api::inputMessageDocument>( as_generated_file(document_path, document_conversion), nullptr, false,
as_generated_file(document_path, document_conversion), nullptr, as_caption("test caption"))); as_caption("test caption")));
} else if (op == "sdtg") { } else if (op == "sdtg") {
string chat_id; string chat_id;
string document_path; string document_path;
@ -3227,7 +3227,7 @@ class CliClient final : public Actor {
std::tie(thumbnail_path, thumbnail_conversion) = split(args); std::tie(thumbnail_path, thumbnail_conversion) = split(args);
send_message(chat_id, td_api::make_object<td_api::inputMessageDocument>( send_message(chat_id, td_api::make_object<td_api::inputMessageDocument>(
as_input_file(document_path), as_input_thumbnail(thumbnail_path, thumbnail_conversion), as_input_file(document_path), as_input_thumbnail(thumbnail_path, thumbnail_conversion),
as_caption("test caption"))); false, as_caption("test caption")));
} else if (op == "sdgtg") { } else if (op == "sdgtg") {
string chat_id; string chat_id;
string document_path; string document_path;
@ -3238,22 +3238,23 @@ class CliClient final : public Actor {
std::tie(document_path, args) = split(args); std::tie(document_path, args) = split(args);
std::tie(document_conversion, args) = split(args); std::tie(document_conversion, args) = split(args);
std::tie(thumbnail_path, thumbnail_conversion) = split(args); std::tie(thumbnail_path, thumbnail_conversion) = split(args);
send_message(chat_id, td_api::make_object<td_api::inputMessageDocument>( send_message(chat_id,
as_generated_file(document_path, document_conversion), td_api::make_object<td_api::inputMessageDocument>(
as_input_thumbnail(thumbnail_path, thumbnail_conversion), as_caption("test caption"))); as_generated_file(document_path, document_conversion),
as_input_thumbnail(thumbnail_path, thumbnail_conversion), false, as_caption("test caption")));
} else if (op == "sdid") { } else if (op == "sdid") {
string chat_id; string chat_id;
string file_id; string file_id;
std::tie(chat_id, file_id) = split(args); std::tie(chat_id, file_id) = split(args);
send_message(chat_id, td_api::make_object<td_api::inputMessageDocument>(as_input_file_id(file_id), nullptr, send_message(chat_id, td_api::make_object<td_api::inputMessageDocument>(as_input_file_id(file_id), nullptr, false,
as_caption(""))); as_caption("")));
} else if (op == "sdurl") { } else if (op == "sdurl") {
string chat_id; string chat_id;
string url; string url;
std::tie(chat_id, url) = split(args); std::tie(chat_id, url) = split(args);
send_message(chat_id, send_message(chat_id, td_api::make_object<td_api::inputMessageDocument>(as_remote_file(url), nullptr, false,
td_api::make_object<td_api::inputMessageDocument>(as_remote_file(url), nullptr, as_caption(""))); as_caption("")));
} else if (op == "sg") { } else if (op == "sg") {
string chat_id; string chat_id;
string bot_user_id; string bot_user_id;

View File

@ -108,11 +108,12 @@ Result<FileLoader::FileInfo> FileDownloader::init() {
res.ready_parts = bitmask.as_vector(); res.ready_parts = bitmask.as_vector();
res.use_part_count_limit = false; res.use_part_count_limit = false;
res.only_check = only_check_; res.only_check = only_check_;
auto file_type = remote_.file_type_;
res.need_delay = res.need_delay =
!is_small_ && (remote_.file_type_ == FileType::VideoNote || remote_.file_type_ == FileType::Document || !is_small_ &&
remote_.file_type_ == FileType::VoiceNote || remote_.file_type_ == FileType::Audio || (file_type == FileType::VideoNote || file_type == FileType::Document || file_type == FileType::DocumentAsFile ||
remote_.file_type_ == FileType::Video || remote_.file_type_ == FileType::Animation || file_type == FileType::VoiceNote || file_type == FileType::Audio || file_type == FileType::Video ||
(remote_.file_type_ == FileType::Encrypted && size_ > (1 << 20))); file_type == FileType::Animation || (file_type == FileType::Encrypted && size_ > (1 << 20)));
res.offset = offset_; res.offset = offset_;
res.limit = limit_; res.limit = limit_;
return res; return res;

View File

@ -53,6 +53,8 @@ void FileGcWorker::run_gc(const FileGcParameters &parameters, std::vector<FullFi
immune_types[narrow_cast<size_t>(FileType::SecureRaw)] = false; immune_types[narrow_cast<size_t>(FileType::SecureRaw)] = false;
} else if (file_type == FileType::Background) { } else if (file_type == FileType::Background) {
immune_types[narrow_cast<size_t>(FileType::Wallpaper)] = false; immune_types[narrow_cast<size_t>(FileType::Wallpaper)] = false;
} else if (file_type == FileType::Document) {
immune_types[narrow_cast<size_t>(FileType::DocumentAsFile)] = false;
} }
immune_types[narrow_cast<size_t>(file_type)] = false; immune_types[narrow_cast<size_t>(file_type)] = false;
} }

View File

@ -210,6 +210,7 @@ class FullRemoteFileLocation {
case FileType::SecureRaw: case FileType::SecureRaw:
case FileType::Secure: case FileType::Secure:
case FileType::Background: case FileType::Background:
case FileType::DocumentAsFile:
return LocationType::Common; return LocationType::Common;
case FileType::None: case FileType::None:
case FileType::Size: case FileType::Size:

View File

@ -238,6 +238,7 @@ void FullRemoteFileLocation::AsUnique::store(StorerT &storer) const {
case FileType::Animation: case FileType::Animation:
case FileType::VideoNote: case FileType::VideoNote:
case FileType::Background: case FileType::Background:
case FileType::DocumentAsFile:
return 2; return 2;
case FileType::SecureRaw: case FileType::SecureRaw:
case FileType::Secure: case FileType::Secure:

View File

@ -766,7 +766,8 @@ FileManager::FileManager(unique_ptr<Context> context) : context_(std::move(conte
}; };
for (int32 i = 0; i < file_type_size; i++) { for (int32 i = 0; i < file_type_size; i++) {
FileType file_type = static_cast<FileType>(i); FileType file_type = static_cast<FileType>(i);
if (file_type == FileType::SecureRaw || file_type == FileType::Background) { if (file_type == FileType::SecureRaw || file_type == FileType::Background ||
file_type == FileType::DocumentAsFile) {
continue; continue;
} }
auto path = get_files_dir(file_type); auto path = get_files_dir(file_type);
@ -847,6 +848,7 @@ string FileManager::get_file_name(FileType file_type, Slice path) {
case FileType::EncryptedThumbnail: case FileType::EncryptedThumbnail:
case FileType::Secure: case FileType::Secure:
case FileType::SecureRaw: case FileType::SecureRaw:
case FileType::DocumentAsFile:
break; break;
default: default:
UNREACHABLE(); UNREACHABLE();
@ -2726,7 +2728,7 @@ void FileManager::cancel_upload(FileId file_id) {
static bool is_document_type(FileType type) { static bool is_document_type(FileType type) {
return type == FileType::Document || type == FileType::Sticker || type == FileType::Audio || return type == FileType::Document || type == FileType::Sticker || type == FileType::Audio ||
type == FileType::Animation || type == FileType::Background; type == FileType::Animation || type == FileType::Background || type == FileType::DocumentAsFile;
} }
static bool is_background_type(FileType type) { static bool is_background_type(FileType type) {

View File

@ -138,6 +138,8 @@ tl_object_ptr<td_api::storageStatisticsByChat> as_td_api(DialogId dialog_id,
int32 secure_raw_cnt = 0; int32 secure_raw_cnt = 0;
int64 wallpaper_raw_size = 0; int64 wallpaper_raw_size = 0;
int32 wallpaper_raw_cnt = 0; int32 wallpaper_raw_cnt = 0;
int64 document_raw_size = 0;
int32 document_raw_cnt = 0;
for (int32 i = 0; i < file_type_size; i++) { for (int32 i = 0; i < file_type_size; i++) {
FileType file_type = static_cast<FileType>(i); FileType file_type = static_cast<FileType>(i);
auto size = stat_by_type[i].size; auto size = stat_by_type[i].size;
@ -153,6 +155,11 @@ tl_object_ptr<td_api::storageStatisticsByChat> as_td_api(DialogId dialog_id,
wallpaper_raw_cnt = cnt; wallpaper_raw_cnt = cnt;
continue; continue;
} }
if (file_type == FileType::Document) {
document_raw_size = size;
document_raw_cnt = cnt;
continue;
}
if (file_type == FileType::Secure) { if (file_type == FileType::Secure) {
size += secure_raw_size; size += secure_raw_size;
cnt += secure_raw_cnt; cnt += secure_raw_cnt;
@ -161,6 +168,11 @@ tl_object_ptr<td_api::storageStatisticsByChat> as_td_api(DialogId dialog_id,
size += wallpaper_raw_size; size += wallpaper_raw_size;
cnt += wallpaper_raw_cnt; cnt += wallpaper_raw_cnt;
} }
if (file_type == FileType::DocumentAsFile) {
size += document_raw_size;
cnt += document_raw_cnt;
continue;
}
if (size == 0) { if (size == 0) {
continue; continue;
} }

View File

@ -102,7 +102,7 @@ template <class CallbackT>
void scan_fs(CancellationToken &token, CallbackT &&callback) { void scan_fs(CancellationToken &token, CallbackT &&callback) {
for (int32 i = 0; i < file_type_size; i++) { for (int32 i = 0; i < file_type_size; i++) {
auto file_type = static_cast<FileType>(i); auto file_type = static_cast<FileType>(i);
if (file_type == FileType::SecureRaw || file_type == FileType::Wallpaper) { if (file_type == FileType::SecureRaw || file_type == FileType::Wallpaper || file_type == FileType::DocumentAsFile) {
continue; continue;
} }
auto files_dir = get_files_dir(file_type); auto files_dir = get_files_dir(file_type);

View File

@ -32,6 +32,7 @@ enum class FileType : int32 {
SecureRaw, SecureRaw,
Secure, Secure,
Background, Background,
DocumentAsFile,
Size, Size,
None None
}; };
@ -113,6 +114,8 @@ inline tl_object_ptr<td_api::FileType> as_td_api(FileType file_type) {
return make_tl_object<td_api::fileTypeSecure>(); return make_tl_object<td_api::fileTypeSecure>();
case FileType::Background: case FileType::Background:
return make_tl_object<td_api::fileTypeWallpaper>(); return make_tl_object<td_api::fileTypeWallpaper>();
case FileType::DocumentAsFile:
return make_tl_object<td_api::fileTypeDocument>();
case FileType::None: case FileType::None:
return make_tl_object<td_api::fileTypeNone>(); return make_tl_object<td_api::fileTypeNone>();
default: default:
@ -159,6 +162,8 @@ inline CSlice get_file_type_name(FileType file_type) {
return CSlice("passport"); return CSlice("passport");
case FileType::Background: case FileType::Background:
return CSlice("wallpapers"); return CSlice("wallpapers");
case FileType::DocumentAsFile:
return CSlice("documents");
case FileType::Size: case FileType::Size:
case FileType::None: case FileType::None:
default: default:

View File

@ -60,8 +60,12 @@ void NetStatsManager::init() {
}; };
for_each_stat([&](NetStatsInfo &stat, size_t id, CSlice name, FileType file_type) { for_each_stat([&](NetStatsInfo &stat, size_t id, CSlice name, FileType file_type) {
if (file_type == FileType::SecureRaw || file_type == FileType::Wallpaper) { if (file_type == FileType::SecureRaw) {
id++; id += static_cast<size_t>(FileType::SecureRaw) - static_cast<size_t>(FileType::Secure);
} else if (file_type == FileType::Wallpaper) {
id += static_cast<size_t>(FileType::Background) - static_cast<size_t>(FileType::Wallpaper);
} else if (file_type == FileType::DocumentAsFile) {
id += static_cast<size_t>(FileType::Document) - static_cast<size_t>(FileType::DocumentAsFile);
} }
stat.key = "net_stats_" + name.str(); stat.key = "net_stats_" + name.str();
stat.stats.set_callback(make_unique<NetStatsInternalCallback>(actor_id(this), id)); stat.stats.set_callback(make_unique<NetStatsInternalCallback>(actor_id(this), id));
@ -113,7 +117,8 @@ void NetStatsManager::get_network_stats(bool current, Promise<NetworkStats> prom
entry.is_call = true; entry.is_call = true;
result.entries.push_back(std::move(entry)); result.entries.push_back(std::move(entry));
} else if (file_type != FileType::None) { } else if (file_type != FileType::None) {
if (file_type == FileType::SecureRaw || file_type == FileType::Wallpaper) { if (file_type == FileType::SecureRaw || file_type == FileType::Wallpaper ||
file_type == FileType::DocumentAsFile) {
return; return;
} }
@ -193,7 +198,7 @@ void NetStatsManager::add_network_stats_impl(NetStatsInfo &info, const NetworkSt
void NetStatsManager::start_up() { void NetStatsManager::start_up() {
for_each_stat([&](NetStatsInfo &info, size_t id, CSlice name, FileType file_type) { for_each_stat([&](NetStatsInfo &info, size_t id, CSlice name, FileType file_type) {
if (file_type == FileType::SecureRaw || file_type == FileType::Wallpaper) { if (file_type == FileType::SecureRaw || file_type == FileType::Wallpaper || file_type == FileType::DocumentAsFile) {
return; return;
} }
@ -258,6 +263,7 @@ std::vector<std::shared_ptr<NetStatsCallback>> NetStatsManager::get_file_stats_c
auto result = transform(files_stats_, [](auto &stat) { return stat.stats.get_callback(); }); auto result = transform(files_stats_, [](auto &stat) { return stat.stats.get_callback(); });
result[static_cast<int32>(FileType::SecureRaw)] = result[static_cast<int32>(FileType::Secure)]; result[static_cast<int32>(FileType::SecureRaw)] = result[static_cast<int32>(FileType::Secure)];
result[static_cast<int32>(FileType::Wallpaper)] = result[static_cast<int32>(FileType::Background)]; result[static_cast<int32>(FileType::Wallpaper)] = result[static_cast<int32>(FileType::Background)];
result[static_cast<int32>(FileType::DocumentAsFile)] = result[static_cast<int32>(FileType::Document)];
return result; return result;
} }

View File

@ -490,14 +490,14 @@ class TestFileGenerated : public Task {
make_tl_object<td_api::inputFileGenerated>(file_path, "square", 0), make_tl_object<td_api::inputFileGenerated>(file_path, "square", 0),
make_tl_object<td_api::inputThumbnail>( make_tl_object<td_api::inputThumbnail>(
make_tl_object<td_api::inputFileGenerated>(file_path, "thumbnail", 0), 0, 0), make_tl_object<td_api::inputFileGenerated>(file_path, "thumbnail", 0), 0, 0),
make_tl_object<td_api::formattedText>(tag_, Auto()))), true, make_tl_object<td_api::formattedText>(tag_, Auto()))),
[](auto res) { check_td_error(res); }); [](auto res) { check_td_error(res); });
this->send_query( this->send_query(
make_tl_object<td_api::sendMessage>(chat_id_, 0, nullptr, nullptr, make_tl_object<td_api::sendMessage>(chat_id_, 0, nullptr, nullptr,
make_tl_object<td_api::inputMessageDocument>( make_tl_object<td_api::inputMessageDocument>(
make_tl_object<td_api::inputFileGenerated>(file_path, "square", 0), make_tl_object<td_api::inputFileGenerated>(file_path, "square", 0),
nullptr, make_tl_object<td_api::formattedText>(tag_, Auto()))), nullptr, true, make_tl_object<td_api::formattedText>(tag_, Auto()))),
[](auto res) { check_td_error(res); }); [](auto res) { check_td_error(res); });
} }