aboutsummaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/Matrix.cpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/plugins/Matrix.cpp b/src/plugins/Matrix.cpp
index 6040edd..38ab6d0 100644
--- a/src/plugins/Matrix.cpp
+++ b/src/plugins/Matrix.cpp
@@ -4870,20 +4870,14 @@ namespace QuickMedia {
if(filename.empty())
filename = file_get_filename(filepath);
- int upload_limit;
+ int64_t upload_limit;
PluginResult config_result = get_config(&upload_limit);
if(config_result != PluginResult::OK) {
err_msg = "Failed to get file size limit from server";
return config_result;
}
- // Checking for sane file size limit client side, to prevent loading a huge file and crashing
- if(file_analyzer.get_file_size() > 300 * 1024 * 1024) { // 300mb
- err_msg = "File is too large! client-side limit is set to 300mb";
- return PluginResult::ERR;
- }
-
- if((int)file_analyzer.get_file_size() > upload_limit) {
+ if(file_analyzer.get_file_size() > upload_limit) {
err_msg = "File is too large! max upload size on your homeserver is " + std::to_string((double)upload_limit / 1024.0 / 1024.0) + " mb, the file you tried to upload is " + std::to_string((double)file_analyzer.get_file_size() / 1024.0 / 1024.0) + " mb";
return PluginResult::ERR;
}
@@ -4912,6 +4906,12 @@ namespace QuickMedia {
fprintf(stderr, "Failed to create temporary file for video thumbnail, ignoring thumbnail...\n");
}
} else if(upload_thumbnail && is_content_type_image(file_analyzer.get_content_type())) {
+ // Checking for sane file size limit client side, to prevent loading a huge file and crashing
+ if(file_analyzer.get_file_size() > 300 * 1024 * 1024) { // 300mb
+ err_msg = "File is too large! client-side limit for images is set to 300mb";
+ return PluginResult::ERR;
+ }
+
char tmp_filename[] = "/tmp/quickmedia_thumbnail_XXXXXX";
int tmp_file = mkstemp(tmp_filename);
if(tmp_file != -1) {
@@ -5758,7 +5758,7 @@ namespace QuickMedia {
return message->user->room->get_user_display_name(message->user);
}
- PluginResult Matrix::get_config(int *upload_size) {
+ PluginResult Matrix::get_config(int64_t *upload_size) {
// TODO: What if the upload limit changes? is it possible for the upload limit to change while the server is running?
if(upload_limit) {
*upload_size = upload_limit.value();
@@ -5782,10 +5782,10 @@ namespace QuickMedia {
return PluginResult::ERR;
const rapidjson::Value &upload_size_json = GetMember(json_root, "m.upload.size");
- if(!upload_size_json.IsInt())
+ if(!upload_size_json.IsInt64())
return PluginResult::ERR;
- upload_limit = upload_size_json.GetInt();
+ upload_limit = upload_size_json.GetInt64();
*upload_size = upload_limit.value();
return PluginResult::OK;
}