sent attachment content-disposition on thumbnails too

Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
strawberry 2024-05-05 15:39:59 -04:00 committed by June
parent 43c4dfc5df
commit e2fb588a8c
2 changed files with 27 additions and 14 deletions

24
Cargo.lock generated
View file

@ -2698,7 +2698,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma" name = "ruma"
version = "0.9.4" version = "0.9.4"
source = "git+https://github.com/girlbossceo/ruma?branch=conduwuit-changes#1c291e18efd0559c2dd76b27d555c86471cbb0fd" source = "git+https://github.com/girlbossceo/ruma?branch=conduwuit-changes#b8f30d4da497d7f74a64c5b92f64e551685445ae"
dependencies = [ dependencies = [
"assign", "assign",
"js_int", "js_int",
@ -2718,7 +2718,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-appservice-api" name = "ruma-appservice-api"
version = "0.9.0" version = "0.9.0"
source = "git+https://github.com/girlbossceo/ruma?branch=conduwuit-changes#1c291e18efd0559c2dd76b27d555c86471cbb0fd" source = "git+https://github.com/girlbossceo/ruma?branch=conduwuit-changes#b8f30d4da497d7f74a64c5b92f64e551685445ae"
dependencies = [ dependencies = [
"js_int", "js_int",
"ruma-common", "ruma-common",
@ -2730,7 +2730,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-client-api" name = "ruma-client-api"
version = "0.17.4" version = "0.17.4"
source = "git+https://github.com/girlbossceo/ruma?branch=conduwuit-changes#1c291e18efd0559c2dd76b27d555c86471cbb0fd" source = "git+https://github.com/girlbossceo/ruma?branch=conduwuit-changes#b8f30d4da497d7f74a64c5b92f64e551685445ae"
dependencies = [ dependencies = [
"as_variant", "as_variant",
"assign", "assign",
@ -2752,7 +2752,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-common" name = "ruma-common"
version = "0.12.1" version = "0.12.1"
source = "git+https://github.com/girlbossceo/ruma?branch=conduwuit-changes#1c291e18efd0559c2dd76b27d555c86471cbb0fd" source = "git+https://github.com/girlbossceo/ruma?branch=conduwuit-changes#b8f30d4da497d7f74a64c5b92f64e551685445ae"
dependencies = [ dependencies = [
"as_variant", "as_variant",
"base64 0.22.1", "base64 0.22.1",
@ -2782,7 +2782,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-events" name = "ruma-events"
version = "0.27.11" version = "0.27.11"
source = "git+https://github.com/girlbossceo/ruma?branch=conduwuit-changes#1c291e18efd0559c2dd76b27d555c86471cbb0fd" source = "git+https://github.com/girlbossceo/ruma?branch=conduwuit-changes#b8f30d4da497d7f74a64c5b92f64e551685445ae"
dependencies = [ dependencies = [
"as_variant", "as_variant",
"indexmap 2.2.6", "indexmap 2.2.6",
@ -2804,7 +2804,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-federation-api" name = "ruma-federation-api"
version = "0.8.0" version = "0.8.0"
source = "git+https://github.com/girlbossceo/ruma?branch=conduwuit-changes#1c291e18efd0559c2dd76b27d555c86471cbb0fd" source = "git+https://github.com/girlbossceo/ruma?branch=conduwuit-changes#b8f30d4da497d7f74a64c5b92f64e551685445ae"
dependencies = [ dependencies = [
"js_int", "js_int",
"ruma-common", "ruma-common",
@ -2816,7 +2816,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-identifiers-validation" name = "ruma-identifiers-validation"
version = "0.9.3" version = "0.9.3"
source = "git+https://github.com/girlbossceo/ruma?branch=conduwuit-changes#1c291e18efd0559c2dd76b27d555c86471cbb0fd" source = "git+https://github.com/girlbossceo/ruma?branch=conduwuit-changes#b8f30d4da497d7f74a64c5b92f64e551685445ae"
dependencies = [ dependencies = [
"js_int", "js_int",
"thiserror", "thiserror",
@ -2825,7 +2825,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-identity-service-api" name = "ruma-identity-service-api"
version = "0.8.0" version = "0.8.0"
source = "git+https://github.com/girlbossceo/ruma?branch=conduwuit-changes#1c291e18efd0559c2dd76b27d555c86471cbb0fd" source = "git+https://github.com/girlbossceo/ruma?branch=conduwuit-changes#b8f30d4da497d7f74a64c5b92f64e551685445ae"
dependencies = [ dependencies = [
"js_int", "js_int",
"ruma-common", "ruma-common",
@ -2835,7 +2835,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-macros" name = "ruma-macros"
version = "0.12.0" version = "0.12.0"
source = "git+https://github.com/girlbossceo/ruma?branch=conduwuit-changes#1c291e18efd0559c2dd76b27d555c86471cbb0fd" source = "git+https://github.com/girlbossceo/ruma?branch=conduwuit-changes#b8f30d4da497d7f74a64c5b92f64e551685445ae"
dependencies = [ dependencies = [
"once_cell", "once_cell",
"proc-macro-crate", "proc-macro-crate",
@ -2850,7 +2850,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-push-gateway-api" name = "ruma-push-gateway-api"
version = "0.8.0" version = "0.8.0"
source = "git+https://github.com/girlbossceo/ruma?branch=conduwuit-changes#1c291e18efd0559c2dd76b27d555c86471cbb0fd" source = "git+https://github.com/girlbossceo/ruma?branch=conduwuit-changes#b8f30d4da497d7f74a64c5b92f64e551685445ae"
dependencies = [ dependencies = [
"js_int", "js_int",
"ruma-common", "ruma-common",
@ -2862,7 +2862,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-signatures" name = "ruma-signatures"
version = "0.14.0" version = "0.14.0"
source = "git+https://github.com/girlbossceo/ruma?branch=conduwuit-changes#1c291e18efd0559c2dd76b27d555c86471cbb0fd" source = "git+https://github.com/girlbossceo/ruma?branch=conduwuit-changes#b8f30d4da497d7f74a64c5b92f64e551685445ae"
dependencies = [ dependencies = [
"base64 0.22.1", "base64 0.22.1",
"ed25519-dalek", "ed25519-dalek",
@ -2878,7 +2878,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-state-res" name = "ruma-state-res"
version = "0.10.0" version = "0.10.0"
source = "git+https://github.com/girlbossceo/ruma?branch=conduwuit-changes#1c291e18efd0559c2dd76b27d555c86471cbb0fd" source = "git+https://github.com/girlbossceo/ruma?branch=conduwuit-changes#b8f30d4da497d7f74a64c5b92f64e551685445ae"
dependencies = [ dependencies = [
"itertools", "itertools",
"js_int", "js_int",

View file

@ -328,6 +328,7 @@ pub(crate) async fn get_content_thumbnail_route(
content_type, content_type,
cross_origin_resource_policy: Some(CORP_CROSS_ORIGIN.to_owned()), cross_origin_resource_policy: Some(CORP_CROSS_ORIGIN.to_owned()),
cache_control: Some(CACHE_CONTROL_IMMUTABLE.into()), cache_control: Some(CACHE_CONTROL_IMMUTABLE.into()),
content_disposition: Some("attachment".to_owned()),
}) })
} else if !server_is_ours(&body.server_name) && body.allow_remote { } else if !server_is_ours(&body.server_name) && body.allow_remote {
if services() if services()
@ -372,7 +373,13 @@ pub(crate) async fn get_content_thumbnail_route(
) )
.await?; .await?;
Ok(get_thumbnail_response) Ok(get_content_thumbnail::v3::Response {
file: get_thumbnail_response.file,
content_type: get_thumbnail_response.content_type,
cross_origin_resource_policy: get_thumbnail_response.cross_origin_resource_policy,
cache_control: get_thumbnail_response.cache_control,
content_disposition: Some("attachment".to_owned()),
})
}, },
Err(e) => { Err(e) => {
debug_warn!("Fetching media `{}` failed: {:?}", mxc, e); debug_warn!("Fetching media `{}` failed: {:?}", mxc, e);
@ -441,7 +448,13 @@ async fn get_remote_content(
) )
.await?; .await?;
Ok(content_response) Ok(get_content::v3::Response {
file: content_response.file,
content_type: content_response.content_type,
content_disposition: Some("attachment".to_owned()),
cross_origin_resource_policy: content_response.cross_origin_resource_policy,
cache_control: content_response.cache_control,
})
} }
async fn download_image(client: &reqwest::Client, url: &str) -> Result<UrlPreviewData> { async fn download_image(client: &reqwest::Client, url: &str) -> Result<UrlPreviewData> {