Add FileType::VideoStory.
This commit is contained in:
parent
b88312dda1
commit
b27b9caa89
@ -126,7 +126,9 @@ Document DocumentsManager::on_get_document(RemoteDocument remote_document, Dialo
|
||||
string video_waveform;
|
||||
if (video != nullptr) {
|
||||
video_duration = static_cast<int32>(std::ceil(video->duration_));
|
||||
video_preload_prefix_size = video->preload_prefix_size_;
|
||||
if (document_subtype == Subtype::Story) {
|
||||
video_preload_prefix_size = video->preload_prefix_size_;
|
||||
}
|
||||
auto video_dimensions = get_dimensions(video->w_, video->h_, "documentAttributeVideo");
|
||||
if (dimensions.width == 0 || (video_dimensions.width != 0 && video_dimensions != dimensions)) {
|
||||
if (dimensions.width != 0) {
|
||||
@ -263,6 +265,14 @@ Document DocumentsManager::on_get_document(RemoteDocument remote_document, Dialo
|
||||
file_type = FileType::Ringtone;
|
||||
default_extension = Slice("mp3");
|
||||
break;
|
||||
case Subtype::Story:
|
||||
if (document_type != Document::Type::Video) {
|
||||
LOG(ERROR) << "Receive story of type " << document_type;
|
||||
document_type = Document::Type::Video;
|
||||
}
|
||||
file_type = FileType::VideoStory;
|
||||
default_extension = Slice("mp4");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ class DocumentsManager {
|
||||
|
||||
tl_object_ptr<td_api::document> get_document_object(FileId file_id, PhotoFormat thumbnail_format) const;
|
||||
|
||||
enum class Subtype : int32 { Background, Pattern, Ringtone, Other };
|
||||
enum class Subtype : int32 { Background, Pattern, Ringtone, Story, Other };
|
||||
|
||||
Document on_get_document(RemoteDocument remote_document, DialogId owner_dialog_id,
|
||||
MultiPromiseActor *load_data_multipromise_ptr = nullptr,
|
||||
|
@ -2731,7 +2731,7 @@ 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) {
|
||||
if (file_type == FileType::Video || file_type == FileType::VideoStory) {
|
||||
flags |= telegram_api::inputMediaUploadedDocument::NOSOUND_VIDEO_MASK;
|
||||
}
|
||||
if (file_type == FileType::DocumentAsFile) {
|
||||
@ -2741,7 +2741,7 @@ 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);
|
||||
CHECK(file_type == FileType::Photo || file_type == FileType::PhotoStory);
|
||||
int32 flags = 0;
|
||||
return make_tl_object<telegram_api::inputMediaUploadedPhoto>(
|
||||
flags, false /*ignored*/, std::move(input_file), vector<tl_object_ptr<telegram_api::InputDocument>>(), 0);
|
||||
|
@ -96,7 +96,8 @@ unique_ptr<StoryContent> get_story_content(Td *td, tl_object_ptr<telegram_api::M
|
||||
}
|
||||
CHECK(document_id == telegram_api::document::ID);
|
||||
auto parsed_document = td->documents_manager_->on_get_document(
|
||||
move_tl_object_as<telegram_api::document>(document_ptr), owner_dialog_id, nullptr);
|
||||
move_tl_object_as<telegram_api::document>(document_ptr), owner_dialog_id, nullptr, Document::Type::Video,
|
||||
DocumentsManager::Subtype::Story);
|
||||
if (parsed_document.empty() || parsed_document.type != Document::Type::Video) {
|
||||
LOG(ERROR) << "Receive a story with " << parsed_document;
|
||||
break;
|
||||
@ -112,7 +113,8 @@ unique_ptr<StoryContent> get_story_content(Td *td, tl_object_ptr<telegram_api::M
|
||||
} else {
|
||||
CHECK(alt_document_id == telegram_api::document::ID);
|
||||
auto parsed_alt_document = td->documents_manager_->on_get_document(
|
||||
move_tl_object_as<telegram_api::document>(alt_document_ptr), owner_dialog_id, nullptr);
|
||||
move_tl_object_as<telegram_api::document>(alt_document_ptr), owner_dialog_id, nullptr,
|
||||
Document::Type::Video, DocumentsManager::Subtype::Story);
|
||||
if (parsed_alt_document.empty() || parsed_alt_document.type != Document::Type::Video) {
|
||||
LOG(ERROR) << "Receive alternative " << to_string(alt_document_ptr);
|
||||
} else {
|
||||
@ -152,6 +154,8 @@ Result<unique_ptr<StoryContent>> get_input_story_content(
|
||||
auto input_story = static_cast<const td_api::inputStoryContentVideo *>(input_story_content.get());
|
||||
TRY_RESULT(file_id, td->file_manager_->get_input_file_id(FileType::Video, input_story->video_, owner_dialog_id,
|
||||
false, false));
|
||||
file_id =
|
||||
td->file_manager_->copy_file_id(file_id, FileType::VideoStory, owner_dialog_id, "get_input_story_content");
|
||||
auto sticker_file_ids =
|
||||
td->stickers_manager_->get_attached_sticker_file_ids(input_story->added_sticker_file_ids_);
|
||||
bool has_stickers = !sticker_file_ids.empty();
|
||||
|
@ -276,6 +276,7 @@ Result<FullLocalLocationInfo> check_full_local_location(FullLocalLocationInfo lo
|
||||
constexpr int64 MAX_THUMBNAIL_SIZE = 200 * (1 << 10) - 1 /* 200 KB - 1 B */;
|
||||
constexpr int64 MAX_PHOTO_SIZE = 10 * (1 << 20) /* 10 MB */;
|
||||
constexpr int64 DEFAULT_VIDEO_NOTE_SIZE_MAX = 12 * (1 << 20) /* 12 MB */;
|
||||
constexpr int64 MAX_VIDEO_STORY_SIZE = 30 * (1 << 20) /* 30 MB */;
|
||||
|
||||
FullLocalFileLocation &location = local_info.location_;
|
||||
int64 &size = local_info.size_;
|
||||
@ -338,6 +339,9 @@ Result<FullLocalLocationInfo> check_full_local_location(FullLocalLocationInfo lo
|
||||
size > G()->get_option_integer("video_note_size_max", DEFAULT_VIDEO_NOTE_SIZE_MAX)) {
|
||||
return get_file_size_error(" for a video note");
|
||||
}
|
||||
if (location.file_type_ == FileType::VideoStory && size > MAX_VIDEO_STORY_SIZE) {
|
||||
return get_file_size_error(" for a video story");
|
||||
}
|
||||
return std::move(local_info);
|
||||
}
|
||||
|
||||
|
@ -886,6 +886,11 @@ string FileManager::get_file_name(FileType file_type, Slice path) {
|
||||
return fix_file_extension(file_name, "video", "mp4");
|
||||
}
|
||||
break;
|
||||
case FileType::VideoStory:
|
||||
if (extension != "mp4") {
|
||||
return fix_file_extension(file_name, "video", "mp4");
|
||||
}
|
||||
break;
|
||||
case FileType::Audio:
|
||||
if (extension != "ogg" && extension != "oga" && extension != "mp3" && extension != "mpeg3" &&
|
||||
extension != "m4a") {
|
||||
@ -3227,7 +3232,9 @@ Result<FileId> FileManager::check_input_file_id(FileType type, Result<FileId> re
|
||||
if (real_type != type && !(real_type == FileType::Temp && file_view.has_url()) &&
|
||||
!(is_document_file_type(real_type) && is_document_file_type(type)) &&
|
||||
!(is_background_type(real_type) && is_background_type(type)) &&
|
||||
!(file_view.is_encrypted() && type == FileType::Ringtone)) {
|
||||
!(file_view.is_encrypted() && type == FileType::Ringtone) &&
|
||||
!(real_type == FileType::PhotoStory && type == FileType::Photo) &&
|
||||
!(real_type == FileType::Photo && type == FileType::PhotoStory)) {
|
||||
// TODO: send encrypted file to unencrypted chat
|
||||
return Status::Error(400, PSLICE() << "Can't use file of type " << real_type << " as " << type);
|
||||
}
|
||||
|
@ -95,6 +95,8 @@ tl_object_ptr<td_api::FileType> get_file_type_object(FileType file_type) {
|
||||
return make_tl_object<td_api::fileTypeDocument>();
|
||||
case FileType::PhotoStory:
|
||||
return make_tl_object<td_api::fileTypePhoto>();
|
||||
case FileType::VideoStory:
|
||||
return make_tl_object<td_api::fileTypeVideo>();
|
||||
case FileType::None:
|
||||
return make_tl_object<td_api::fileTypeNone>();
|
||||
default:
|
||||
@ -115,6 +117,8 @@ FileType get_main_file_type(FileType file_type) {
|
||||
return FileType::Document;
|
||||
case FileType::PhotoStory:
|
||||
return FileType::Photo;
|
||||
case FileType::VideoStory:
|
||||
return FileType::Video;
|
||||
default:
|
||||
return file_type;
|
||||
}
|
||||
@ -156,6 +160,8 @@ CSlice get_file_type_name(FileType file_type) {
|
||||
return CSlice("notification_sounds");
|
||||
case FileType::PhotoStory:
|
||||
return CSlice("stories");
|
||||
case FileType::VideoStory:
|
||||
return CSlice("stories");
|
||||
default:
|
||||
UNREACHABLE();
|
||||
return CSlice("none");
|
||||
@ -182,6 +188,7 @@ FileTypeClass get_file_type_class(FileType file_type) {
|
||||
case FileType::DocumentAsFile:
|
||||
case FileType::Ringtone:
|
||||
case FileType::CallLog:
|
||||
case FileType::VideoStory:
|
||||
return FileTypeClass::Document;
|
||||
case FileType::SecureDecrypted:
|
||||
case FileType::SecureEncrypted:
|
||||
@ -246,6 +253,8 @@ StringBuilder &operator<<(StringBuilder &string_builder, FileType file_type) {
|
||||
return string_builder << "CallLog";
|
||||
case FileType::PhotoStory:
|
||||
return string_builder << "PhotoStory";
|
||||
case FileType::VideoStory:
|
||||
return string_builder << "VideoStory";
|
||||
case FileType::Size:
|
||||
case FileType::None:
|
||||
default:
|
||||
@ -267,6 +276,7 @@ FileDirType get_file_dir_type(FileType file_type) {
|
||||
case FileType::Background:
|
||||
case FileType::Ringtone:
|
||||
case FileType::PhotoStory:
|
||||
case FileType::VideoStory:
|
||||
return FileDirType::Secure;
|
||||
default:
|
||||
return FileDirType::Common;
|
||||
@ -281,6 +291,7 @@ bool is_file_big(FileType file_type, int64 expected_size) {
|
||||
case FileType::VideoNote:
|
||||
case FileType::Ringtone:
|
||||
case FileType::CallLog:
|
||||
case FileType::VideoStory:
|
||||
return false;
|
||||
default:
|
||||
break;
|
||||
@ -297,6 +308,7 @@ bool can_reuse_remote_file(FileType file_type) {
|
||||
case FileType::Background:
|
||||
case FileType::CallLog:
|
||||
case FileType::PhotoStory:
|
||||
case FileType::VideoStory:
|
||||
return false;
|
||||
default:
|
||||
return true;
|
||||
|
@ -36,6 +36,7 @@ enum class FileType : int32 {
|
||||
Ringtone,
|
||||
CallLog,
|
||||
PhotoStory,
|
||||
VideoStory,
|
||||
Size,
|
||||
None
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user