add ui banner wall when file uploads are disabled

This commit is contained in:
blek 2023-10-21 13:52:03 +10:00
parent e72a556394
commit 93d94b8431
Signed by: blek
GPG Key ID: 14546221E3595D0C
3 changed files with 23 additions and 2 deletions

View File

@ -17,6 +17,10 @@ allow_custom_names=true
# Allow password protection
allow_pass_protection=true
# Reson why the uploads are disabled
# This is shown only if allow_uploads = false
# upload_disable_reason="File uploads were disabled because of an ongoing attack."
# How much files can one
# user have uploaded to the server.
# Note that it does not include expired files

View File

@ -17,6 +17,11 @@ pub struct FilesPolicy {
#[serde(default)]
pub allow_pass_protection: bool,
/// Reson why the uploads are disabled
/// This is shown only if allow_uploads = false
#[serde(default)]
pub upload_disable_reason: Option<String>,
/// Max uploads for IP (doesn't include deleted uploads)
#[serde(default)]
pub max_per_ip: usize,
@ -40,6 +45,7 @@ impl Default for FilesPolicy {
allow_uploads: true,
allow_custom_names: true,
allow_pass_protection: true,
upload_disable_reason: None,
max_per_ip: 8,
file_del_timeout: 1800,
type_whitelist: None,

View File

@ -85,12 +85,23 @@
</label>
</p>
{%- if ! conf.files.allow_uploads -%}
<div class="alert danger" style="margin-bottom:4px">
<div class="alert danger" style="width:426px">
<h1 class="alert-title">
Error
</h1>
<p class="alert-text">
Uploads are temporarily disabled by the administrator.
Uploads are temporarily disabled by the administrator
{%- if let Some(disable_reason) = conf.files.upload_disable_reason -%}
{{- " " -}} because of the following reason:
<span style="display:block;font-family:monospace;padding:12px 0">
{{- disable_reason -}}
</span>
{%- else -%}
.
{%- endif -%}
<span style="display:block">
Check again in a few minutes.
</span>
</p>
</div>
{%- else -%}