From 5d5ae0b715de7c3453dc1392df299ef3bb58990c Mon Sep 17 00:00:00 2001 From: Gabriel Grubba Date: Fri, 16 Aug 2024 10:39:01 -0300 Subject: [PATCH] DEV: move max_attachment_size_for_user to private class method --- app/controllers/uploads_controller.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/uploads_controller.rb b/app/controllers/uploads_controller.rb index de80ba88212..89a61835676 100644 --- a/app/controllers/uploads_controller.rb +++ b/app/controllers/uploads_controller.rb @@ -227,7 +227,7 @@ class UploadsController < ApplicationController "upload.attachments.too_large_humanized", max_size: ActiveSupport::NumberHelper.number_to_human_size( - UploadsController.max_attachment_size_for_user(current_user).kilobytes, + max_attachment_size_for_user(current_user).kilobytes, ), ), ) @@ -276,7 +276,7 @@ class UploadsController < ApplicationController if url.present? && is_api maximum_upload_size = [ SiteSetting.max_image_size_kb, - UploadsController.max_attachment_size_for_user(current_user), + max_attachment_size_for_user(current_user), ].max.kilobytes tempfile = begin @@ -318,7 +318,7 @@ class UploadsController < ApplicationController private - def self.max_attachment_size_for_user(user) + def max_attachment_size_for_user(user) if user.id == Discourse::SYSTEM_USER_ID && !SiteSetting.system_user_max_attachment_size_kb.zero? SiteSetting.system_user_max_attachment_size_kb else @@ -331,7 +331,7 @@ class UploadsController < ApplicationController # they may have already been reduced in size by preprocessors) def attachment_too_big?(file_name, file_size) !FileHelper.is_supported_image?(file_name) && - file_size >= UploadsController.max_attachment_size_for_user(current_user).kilobytes + file_size >= max_attachment_size_for_user(current_user).kilobytes end # Gifs are not resized on the client and not reduced in size by UploadCreator