mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 09:12:45 +08:00
DEV: move max_attachment_size_for_user to private class method
This commit is contained in:
parent
b045591e40
commit
5d5ae0b715
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user