Refactored size checks for attachments and check base64 upload length

This commit is contained in:
Jan Böhmer 2026-07-09 19:33:11 +02:00
parent a356b94c34
commit 76a36386fc
5 changed files with 33 additions and 68 deletions

View file

@ -65,18 +65,4 @@ class AttachmentsSettings
envVar: "bool:ATTACHMENT_SHOW_HTML_FILES", envVarMode: EnvVarMode::OVERWRITE
)]
public bool $showHTMLAttachments = false;
public function getMaxFileSizeInMegabytes(): int
{
$size = $this->maxFileSize;
$unit = strtoupper(substr($size, -1));
$value = (int) rtrim($size, 'KMG');
return match ($unit) {
'K' => (int) ceil($value / 1024),
'M' => $value,
'G' => $value * 1024,
default => $value, // No unit specified, assume megabytes
};
}
}