Remove PhotoWithSpoiler and VideoWithSpoiler file types.

This commit is contained in:
levlam 2022-12-21 17:37:16 +03:00
parent 816c7d312a
commit b8f4df741b
6 changed files with 8 additions and 33 deletions

View File

@ -2214,8 +2214,8 @@ Result<InputMessageContent> get_input_message_content(
}
case td_api::inputMessagePhoto::ID: {
auto input_message = static_cast<td_api::inputMessagePhoto *>(input_message_content.get());
auto file_type = input_message->has_spoiler_ ? FileType::PhotoWithSpoiler : FileType::Photo;
r_file_id = td->file_manager_->get_input_file_id(file_type, input_message->photo_, dialog_id, false, is_secret);
r_file_id =
td->file_manager_->get_input_file_id(FileType::Photo, input_message->photo_, dialog_id, false, is_secret);
input_thumbnail = std::move(input_message->thumbnail_);
if (!input_message->added_sticker_file_ids_.empty()) {
sticker_file_ids = td->stickers_manager_->get_attached_sticker_file_ids(input_message->added_sticker_file_ids_);
@ -2231,8 +2231,8 @@ Result<InputMessageContent> get_input_message_content(
}
case td_api::inputMessageVideo::ID: {
auto input_message = static_cast<td_api::inputMessageVideo *>(input_message_content.get());
auto file_type = input_message->has_spoiler_ ? FileType::VideoWithSpoiler : FileType::Video;
r_file_id = td->file_manager_->get_input_file_id(file_type, input_message->video_, dialog_id, false, is_secret);
r_file_id =
td->file_manager_->get_input_file_id(FileType::Video, input_message->video_, dialog_id, false, is_secret);
input_thumbnail = std::move(input_message->thumbnail_);
if (!input_message->added_sticker_file_ids_.empty()) {
sticker_file_ids = td->stickers_manager_->get_attached_sticker_file_ids(input_message->added_sticker_file_ids_);
@ -2660,12 +2660,9 @@ tl_object_ptr<telegram_api::InputMedia> get_fake_input_media(Td *td, tl_object_p
}
string mime_type = MimeType::from_extension(path_view.extension());
int32 flags = 0;
if (file_type == FileType::Video || file_type == FileType::VideoWithSpoiler) {
if (file_type == FileType::Video) {
flags |= telegram_api::inputMediaUploadedDocument::NOSOUND_VIDEO_MASK;
}
if (file_type == FileType::VideoWithSpoiler) {
flags |= telegram_api::inputMediaUploadedDocument::SPOILER_MASK;
}
if (file_type == FileType::DocumentAsFile) {
flags |= telegram_api::inputMediaUploadedDocument::FORCE_FILE_MASK;
}
@ -2673,11 +2670,8 @@ tl_object_ptr<telegram_api::InputMedia> get_fake_input_media(Td *td, tl_object_p
flags, false /*ignored*/, false /*ignored*/, false /*ignored*/, std::move(input_file), nullptr, mime_type,
std::move(attributes), vector<tl_object_ptr<telegram_api::InputDocument>>(), 0);
} else {
CHECK(file_type == FileType::Photo || file_type == FileType::PhotoWithSpoiler);
CHECK(file_type == FileType::Photo);
int32 flags = 0;
if (file_type == FileType::PhotoWithSpoiler) {
flags |= telegram_api::inputMediaUploadedPhoto::SPOILER_MASK;
}
return make_tl_object<telegram_api::inputMediaUploadedPhoto>(
flags, false /*ignored*/, std::move(input_file), vector<tl_object_ptr<telegram_api::InputDocument>>(), 0);
}

View File

@ -393,7 +393,6 @@ class FullRemoteFileLocation {
auto &thumbnail = source.thumbnail();
switch (thumbnail.file_type) {
case FileType::Photo:
case FileType::PhotoWithSpoiler:
return make_tl_object<telegram_api::inputPhotoFileLocation>(
id, access_hash, BufferSlice(file_reference_),
std::string(1, static_cast<char>(static_cast<uint8>(thumbnail.thumbnail_type))));

View File

@ -237,8 +237,8 @@ void FullRemoteFileLocation::parse(ParserT &parser) {
break;
case PhotoSizeSource::Type::Thumbnail:
if (photo().source_.get_file_type("FullRemoteFileLocation::parse") != file_type_ ||
(file_type_ != FileType::Photo && file_type_ != FileType::PhotoWithSpoiler &&
file_type_ != FileType::Thumbnail && file_type_ != FileType::EncryptedThumbnail)) {
(file_type_ != FileType::Photo && file_type_ != FileType::Thumbnail &&
file_type_ != FileType::EncryptedThumbnail)) {
parser.set_error("Invalid FileType in PhotoRemoteFileLocation Thumbnail");
}
break;

View File

@ -861,7 +861,6 @@ string FileManager::get_file_name(FileType file_type, Slice path) {
break;
case FileType::ProfilePhoto:
case FileType::Photo:
case FileType::PhotoWithSpoiler:
if (extension != "jpg" && extension != "jpeg" && extension != "gif" && extension != "png" && extension != "tif" &&
extension != "bmp") {
return fix_file_extension(file_name, "photo", "jpg");
@ -874,7 +873,6 @@ string FileManager::get_file_name(FileType file_type, Slice path) {
}
break;
case FileType::Video:
case FileType::VideoWithSpoiler:
case FileType::VideoNote:
if (extension != "mov" && extension != "3gp" && extension != "mpeg4" && extension != "mp4" &&
extension != "mkv") {

View File

@ -93,10 +93,6 @@ tl_object_ptr<td_api::FileType> get_file_type_object(FileType file_type) {
return make_tl_object<td_api::fileTypeNotificationSound>();
case FileType::CallLog:
return make_tl_object<td_api::fileTypeDocument>();
case FileType::PhotoWithSpoiler:
return make_tl_object<td_api::fileTypePhoto>();
case FileType::VideoWithSpoiler:
return make_tl_object<td_api::fileTypeVideo>();
case FileType::None:
return make_tl_object<td_api::fileTypeNone>();
default:
@ -115,10 +111,6 @@ FileType get_main_file_type(FileType file_type) {
return FileType::Document;
case FileType::CallLog:
return FileType::Document;
case FileType::PhotoWithSpoiler:
return FileType::Photo;
case FileType::VideoWithSpoiler:
return FileType::Video;
default:
return file_type;
}
@ -171,7 +163,6 @@ FileTypeClass get_file_type_class(FileType file_type) {
case FileType::Thumbnail:
case FileType::EncryptedThumbnail:
case FileType::Wallpaper:
case FileType::PhotoWithSpoiler:
return FileTypeClass::Photo;
case FileType::Video:
case FileType::VoiceNote:
@ -184,7 +175,6 @@ FileTypeClass get_file_type_class(FileType file_type) {
case FileType::DocumentAsFile:
case FileType::Ringtone:
case FileType::CallLog:
case FileType::VideoWithSpoiler:
return FileTypeClass::Document;
case FileType::SecureDecrypted:
case FileType::SecureEncrypted:
@ -247,10 +237,6 @@ StringBuilder &operator<<(StringBuilder &string_builder, FileType file_type) {
return string_builder << "NotificationSound";
case FileType::CallLog:
return string_builder << "CallLog";
case FileType::PhotoWithSpoiler:
return string_builder << "PhotoWithSpoiler";
case FileType::VideoWithSpoiler:
return string_builder << "VideoWithSpoiler";
case FileType::Size:
case FileType::None:
default:

View File

@ -35,8 +35,6 @@ enum class FileType : int32 {
DocumentAsFile,
Ringtone,
CallLog,
PhotoWithSpoiler,
VideoWithSpoiler,
Size,
None
};