diff --git a/config/defaults.hjson b/config/defaults.hjson index 04e34f978..880af802c 100644 --- a/config/defaults.hjson +++ b/config/defaults.hjson @@ -52,6 +52,8 @@ # hotlinking is allowed. If that is the case for your instance, make sure that this setting is # disabled. cache_external_link_previews: true + # Timeout for uploading images to pictrs (in seconds) + upload_timeout: 30 } # Email sending configuration. All options except login/password are mandatory email: { diff --git a/crates/routes/src/images.rs b/crates/routes/src/images.rs index a537300d2..6b5d9d958 100644 --- a/crates/routes/src/images.rs +++ b/crates/routes/src/images.rs @@ -107,7 +107,7 @@ async fn upload( client_req = client_req.header("X-Forwarded-For", addr.to_string()) }; let res = client_req - .timeout(Duration::from_secs(30)) + .timeout(Duration::from_secs(pictrs_config.upload_timeout)) .body(Body::wrap_stream(make_send(body))) .send() .await diff --git a/crates/utils/src/settings/structs.rs b/crates/utils/src/settings/structs.rs index 3664417be..886cd71b6 100644 --- a/crates/utils/src/settings/structs.rs +++ b/crates/utils/src/settings/structs.rs @@ -89,6 +89,10 @@ pub struct PictrsConfig { /// disabled. #[default(true)] pub cache_external_link_previews: bool, + + /// Timeout for uploading images to pictrs (in seconds) + #[default(30)] + pub upload_timeout: u64, } #[derive(Debug, Deserialize, Serialize, Clone, SmartDefault, Document)]