diff --git a/README.md b/README.md index 7a14736..848134a 100644 --- a/README.md +++ b/README.md @@ -69,6 +69,7 @@ of the notes even if it tried to. | `MAX_VIEWS` | `100` | Maximal number of views. | | `MAX_EXPIRATION` | `360` | Maximal expiration in minutes. | | `ALLOW_ADVANCED` | `true` | Allow custom configuration. If set to `false` all notes will be one view only. | +| `ALLOW_FILES` | `true` | Allow uploading files. If set to `false`, users will only be allowed to create text notes. | | `ID_LENGTH` | `32` | Set the size of the note `id` in bytes. By default this is `32` bytes. This is useful for reducing link size. _This setting does not affect encryption strength_. | | `VERBOSITY` | `warn` | Verbosity level for the backend. [Possible values](https://docs.rs/env_logger/latest/env_logger/#enabling-logging) are: `error`, `warn`, `info`, `debug`, `trace` | | `THEME_IMAGE` | `""` | Custom image for replacing the logo. Must be publicly reachable | diff --git a/packages/backend/src/config.rs b/packages/backend/src/config.rs index ae65940..5947f79 100644 --- a/packages/backend/src/config.rs +++ b/packages/backend/src/config.rs @@ -34,6 +34,10 @@ lazy_static! { .unwrap_or("32".to_string()) .parse() .unwrap(); + pub static ref ALLOW_FILES: bool = std::env::var("ALLOW_FILES") + .unwrap_or("true".to_string()) + .parse() + .unwrap(); } // THEME diff --git a/packages/backend/src/status/model.rs b/packages/backend/src/status/model.rs index 56190bc..98b0c6e 100644 --- a/packages/backend/src/status/model.rs +++ b/packages/backend/src/status/model.rs @@ -9,6 +9,7 @@ pub struct Status { pub max_views: u32, pub max_expiration: u32, pub allow_advanced: bool, + pub allow_files: bool, // Theme pub theme_image: String, pub theme_text: String, diff --git a/packages/backend/src/status/routes.rs b/packages/backend/src/status/routes.rs index a6dad2b..583b26d 100644 --- a/packages/backend/src/status/routes.rs +++ b/packages/backend/src/status/routes.rs @@ -11,10 +11,11 @@ async fn get_status() -> impl Responder { max_views: *config::MAX_VIEWS, max_expiration: *config::MAX_EXPIRATION, allow_advanced: *config::ALLOW_ADVANCED, + allow_files: *config::ALLOW_FILES, theme_image: config::THEME_IMAGE.to_string(), theme_text: config::THEME_TEXT.to_string(), theme_page_title: config::THEME_PAGE_TITLE.to_string(), - theme_favicon: config::THEME_FAVICON.to_string() + theme_favicon: config::THEME_FAVICON.to_string(), }); } diff --git a/packages/frontend/src/lib/views/Create.svelte b/packages/frontend/src/lib/views/Create.svelte index 16164e6..7532324 100644 --- a/packages/frontend/src/lib/views/Create.svelte +++ b/packages/frontend/src/lib/views/Create.svelte @@ -118,12 +118,14 @@ {/if}
- + {#if $status?.allow_files} + + {/if} {#if $status?.allow_advanced}