Add limit on maximum videoNote size.
This commit is contained in:
parent
f0333aa578
commit
c2028aed4f
@ -1684,7 +1684,7 @@ void ConfigManager::process_app_config(tl_object_ptr<telegram_api::JSONValue> &c
|
||||
for (auto &video_note_setting : video_note_settings) {
|
||||
CHECK(video_note_setting != nullptr);
|
||||
if (video_note_setting->key_ != "diameter" && video_note_setting->key_ != "video_bitrate" &&
|
||||
video_note_setting->key_ != "audio_bitrate") {
|
||||
video_note_setting->key_ != "audio_bitrate" && video_note_setting->key_ != "max_size") {
|
||||
continue;
|
||||
}
|
||||
if (video_note_setting->value_->get_id() == telegram_api::jsonNumber::ID) {
|
||||
@ -1700,6 +1700,9 @@ void ConfigManager::process_app_config(tl_object_ptr<telegram_api::JSONValue> &c
|
||||
if (video_note_setting->key_ == "audio_bitrate") {
|
||||
G()->shared_config().set_option_integer("suggested_video_note_audio_bitrate", setting_value);
|
||||
}
|
||||
if (video_note_setting->key_ == "max_size") {
|
||||
G()->shared_config().set_option_integer("video_note_size_max", setting_value);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
LOG(ERROR) << "Receive unexpected video note setting " << to_string(video_note_setting);
|
||||
|
@ -35839,7 +35839,7 @@ void MessagesManager::on_get_channel_difference(
|
||||
}
|
||||
|
||||
if (!is_final) {
|
||||
LOG_IF(ERROR, timeout > 0) << "Have timeout in not final ChannelDifference in " << dialog_id;
|
||||
LOG_IF(ERROR, timeout > 0) << "Have timeout in nonfinal ChannelDifference in " << dialog_id;
|
||||
get_channel_difference(dialog_id, d->pts, true, "on_get_channel_difference");
|
||||
return;
|
||||
}
|
||||
|
@ -3565,6 +3565,8 @@ bool Td::is_internal_config_option(Slice name) {
|
||||
name == "rating_e_decay" || name == "recent_stickers_limit";
|
||||
case 's':
|
||||
return name == "saved_animations_limit";
|
||||
case 'v':
|
||||
return name == "video_note_size_max";
|
||||
case 'w':
|
||||
return name == "webfile_dc_id";
|
||||
default:
|
||||
|
@ -3624,7 +3624,7 @@ class CliClient final : public Actor {
|
||||
string video_path;
|
||||
get_args(args, chat_id, video_path);
|
||||
send_message(chat_id,
|
||||
td_api::make_object<td_api::inputMessageVideoNote>(as_input_file(video_path), nullptr, 1, 5));
|
||||
td_api::make_object<td_api::inputMessageVideoNote>(as_input_file(video_path), nullptr, 10, 5));
|
||||
} else if (op == "svenue") {
|
||||
string chat_id;
|
||||
string latitude;
|
||||
|
@ -920,6 +920,7 @@ bool FileManager::are_modification_times_equal(int64 old_mtime, int64 new_mtime)
|
||||
Status FileManager::check_local_location(FullLocalFileLocation &location, int64 &size, bool skip_file_size_checks) {
|
||||
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 */;
|
||||
|
||||
if (location.path_.empty()) {
|
||||
return Status::Error(400, "File must have non-empty path");
|
||||
@ -967,13 +968,17 @@ Status FileManager::check_local_location(FullLocalFileLocation &location, int64
|
||||
return Status::Error(400, PSLICE() << "File \"" << location.path_ << "\" is too big for a thumbnail "
|
||||
<< tag("size", format::as_size(size)));
|
||||
}
|
||||
if (location.file_type_ == FileType::Photo && size > MAX_PHOTO_SIZE) {
|
||||
return Status::Error(400, PSLICE() << "File \"" << location.path_ << "\" is too big for a photo "
|
||||
<< tag("size", format::as_size(size)));
|
||||
}
|
||||
if (size > MAX_FILE_SIZE) {
|
||||
return Status::Error(400, PSLICE() << "File \"" << location.path_ << "\" of size " << size << " bytes is too big");
|
||||
}
|
||||
if (location.file_type_ == FileType::Photo && size > MAX_PHOTO_SIZE) {
|
||||
return Status::Error(
|
||||
400, PSLICE() << "File \"" << location.path_ << "\" is too big " << tag("size", format::as_size(size)));
|
||||
400, PSLICE() << "File \"" << location.path_ << "\" of size " << size << " bytes is too big for a photo");
|
||||
}
|
||||
if (location.file_type_ == FileType::VideoNote &&
|
||||
size > G()->shared_config().get_option_integer("video_note_size_max", DEFAULT_VIDEO_NOTE_SIZE_MAX)) {
|
||||
return Status::Error(
|
||||
400, PSLICE() << "File \"" << location.path_ << "\" of size " << size << " bytes is too big for a video note");
|
||||
}
|
||||
return Status::OK();
|
||||
}
|
||||
|
@ -182,6 +182,7 @@ bool is_file_big(FileType file_type, int64 expected_size) {
|
||||
case FileType::ProfilePhoto:
|
||||
case FileType::Photo:
|
||||
case FileType::EncryptedThumbnail:
|
||||
case FileType::VideoNote:
|
||||
return false;
|
||||
default:
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user