mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 16:21:18 +08:00
FEATURE: add system_user_max_attachment_size_kb
site setting (#28351)
* System user attachment size WIP * spec check * controller update * add max to system_user_max_attachment_size_kb * DEV: update to use static method for `max_attachment_size_for_user` add test to use large image. add check for failure. * DEV: update `system_user_max_attachment_size_kb` default value to 0 remove unecessary test. update tests to reflect the new default value of `system_user_max_attachment_size_kb` * DEV: update maximum_file_size to check when is an attachment made by a system user Add tests for when `system_user_max_attachment_size_kb` is over and under the limit Add test for checking interaction with `max_attachment_size_kb` * DEV: move `max_attachment_size_for_user` to private methods * DEV: turn `max_attachment_size_for_user` into a static method * DEV: typo in test case * DEV: move max_attachment_size_for_user to private class method * Revert "DEV: move max_attachment_size_for_user to private class method" This reverts commit 5d5ae0b715de7c3453dc1392df299ef3bb58990c. --------- Co-authored-by: Gabriel Grubba <gabriel@discourse.org>
This commit is contained in:
@ -146,7 +146,14 @@ class UploadValidator < ActiveModel::Validator
|
||||
if upload.for_export
|
||||
SiteSetting.max_export_file_size_kb
|
||||
else
|
||||
SiteSetting.get("max_#{type}_size_kb")
|
||||
if upload.user&.id == Discourse::SYSTEM_USER_ID && type == "attachment"
|
||||
[
|
||||
SiteSetting.get("system_user_max_attachment_size_kb"),
|
||||
SiteSetting.get("max_attachment_size_kb"),
|
||||
].max
|
||||
else
|
||||
SiteSetting.get("max_#{type}_size_kb")
|
||||
end
|
||||
end
|
||||
|
||||
max_size_bytes = max_size_kb.kilobytes
|
||||
|
Reference in New Issue
Block a user