mirror of
https://forgejo.ellis.link/continuwuation/continuwuity/
synced 2026-04-03 08:35:39 +00:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cb70d51e2b | ||
|
|
bfb827a418 | ||
|
|
e2fb588a8c | ||
|
|
43c4dfc5df |
26
Cargo.lock
generated
26
Cargo.lock
generated
@@ -568,7 +568,7 @@ checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b"
|
||||
|
||||
[[package]]
|
||||
name = "conduit"
|
||||
version = "0.3.1"
|
||||
version = "0.3.2"
|
||||
dependencies = [
|
||||
"argon2",
|
||||
"async-trait",
|
||||
@@ -2698,7 +2698,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "ruma"
|
||||
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 = [
|
||||
"assign",
|
||||
"js_int",
|
||||
@@ -2718,7 +2718,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "ruma-appservice-api"
|
||||
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 = [
|
||||
"js_int",
|
||||
"ruma-common",
|
||||
@@ -2730,7 +2730,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "ruma-client-api"
|
||||
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 = [
|
||||
"as_variant",
|
||||
"assign",
|
||||
@@ -2752,7 +2752,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "ruma-common"
|
||||
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 = [
|
||||
"as_variant",
|
||||
"base64 0.22.1",
|
||||
@@ -2782,7 +2782,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "ruma-events"
|
||||
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 = [
|
||||
"as_variant",
|
||||
"indexmap 2.2.6",
|
||||
@@ -2804,7 +2804,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "ruma-federation-api"
|
||||
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 = [
|
||||
"js_int",
|
||||
"ruma-common",
|
||||
@@ -2816,7 +2816,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "ruma-identifiers-validation"
|
||||
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 = [
|
||||
"js_int",
|
||||
"thiserror",
|
||||
@@ -2825,7 +2825,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "ruma-identity-service-api"
|
||||
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 = [
|
||||
"js_int",
|
||||
"ruma-common",
|
||||
@@ -2835,7 +2835,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "ruma-macros"
|
||||
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 = [
|
||||
"once_cell",
|
||||
"proc-macro-crate",
|
||||
@@ -2850,7 +2850,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "ruma-push-gateway-api"
|
||||
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 = [
|
||||
"js_int",
|
||||
"ruma-common",
|
||||
@@ -2862,7 +2862,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "ruma-signatures"
|
||||
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 = [
|
||||
"base64 0.22.1",
|
||||
"ed25519-dalek",
|
||||
@@ -2878,7 +2878,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "ruma-state-res"
|
||||
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 = [
|
||||
"itertools",
|
||||
"js_int",
|
||||
|
||||
@@ -10,7 +10,7 @@ authors = [
|
||||
homepage = "https://conduwuit.puppyirl.gay/"
|
||||
repository = "https://github.com/girlbossceo/conduwuit"
|
||||
readme = "README.md"
|
||||
version = "0.3.1"
|
||||
version = "0.3.2"
|
||||
edition = "2021"
|
||||
|
||||
# See also `rust-toolchain.toml`
|
||||
|
||||
@@ -130,7 +130,7 @@ pub(crate) async fn create_content_route(
|
||||
mxc.clone(),
|
||||
body.filename
|
||||
.as_ref()
|
||||
.map(|filename| "inline; filename=".to_owned() + filename)
|
||||
.map(|filename| format!("attachment; filename={filename}"))
|
||||
.as_deref(),
|
||||
body.content_type.as_deref(),
|
||||
&body.file,
|
||||
@@ -173,15 +173,16 @@ pub(crate) async fn get_content_route(body: Ruma<get_content::v3::Request>) -> R
|
||||
let mxc = format!("mxc://{}/{}", body.server_name, body.media_id);
|
||||
|
||||
if let Some(FileMeta {
|
||||
content_disposition,
|
||||
content_type,
|
||||
file,
|
||||
..
|
||||
}) = services().media.get(mxc.clone()).await?
|
||||
{
|
||||
// TODO: safely sanitise filename to be included in the content-disposition
|
||||
Ok(get_content::v3::Response {
|
||||
file,
|
||||
content_type,
|
||||
content_disposition,
|
||||
content_disposition: Some("attachment".to_owned()),
|
||||
cross_origin_resource_policy: Some(CORP_CROSS_ORIGIN.to_owned()),
|
||||
cache_control: Some(CACHE_CONTROL_IMMUTABLE.into()),
|
||||
})
|
||||
@@ -243,7 +244,7 @@ pub(crate) async fn get_content_as_filename_route(
|
||||
Ok(get_content_as_filename::v3::Response {
|
||||
file,
|
||||
content_type,
|
||||
content_disposition: Some(format!("inline; filename={}", body.filename)),
|
||||
content_disposition: Some("attachment".to_owned()),
|
||||
cross_origin_resource_policy: Some(CORP_CROSS_ORIGIN.to_owned()),
|
||||
cache_control: Some(CACHE_CONTROL_IMMUTABLE.into()),
|
||||
})
|
||||
@@ -258,7 +259,7 @@ pub(crate) async fn get_content_as_filename_route(
|
||||
.await
|
||||
{
|
||||
Ok(remote_content_response) => Ok(get_content_as_filename::v3::Response {
|
||||
content_disposition: Some(format!("inline: filename={}", body.filename)),
|
||||
content_disposition: Some("attachment".to_owned()),
|
||||
content_type: remote_content_response.content_type,
|
||||
file: remote_content_response.file,
|
||||
cross_origin_resource_policy: Some(CORP_CROSS_ORIGIN.to_owned()),
|
||||
@@ -327,6 +328,7 @@ pub(crate) async fn get_content_thumbnail_route(
|
||||
content_type,
|
||||
cross_origin_resource_policy: Some(CORP_CROSS_ORIGIN.to_owned()),
|
||||
cache_control: Some(CACHE_CONTROL_IMMUTABLE.into()),
|
||||
content_disposition: Some("attachment".to_owned()),
|
||||
})
|
||||
} else if !server_is_ours(&body.server_name) && body.allow_remote {
|
||||
if services()
|
||||
@@ -371,7 +373,13 @@ pub(crate) async fn get_content_thumbnail_route(
|
||||
)
|
||||
.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: Some(CORP_CROSS_ORIGIN.to_owned()),
|
||||
cache_control: Some(CACHE_CONTROL_IMMUTABLE.to_owned()),
|
||||
content_disposition: Some("attachment".to_owned()),
|
||||
})
|
||||
},
|
||||
Err(e) => {
|
||||
debug_warn!("Fetching media `{}` failed: {:?}", mxc, e);
|
||||
@@ -434,13 +442,19 @@ async fn get_remote_content(
|
||||
.create(
|
||||
None,
|
||||
mxc.to_owned(),
|
||||
content_response.content_disposition.as_deref(),
|
||||
Some("attachment"),
|
||||
content_response.content_type.as_deref(),
|
||||
&content_response.file,
|
||||
)
|
||||
.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: Some(CORP_CROSS_ORIGIN.to_owned()),
|
||||
cache_control: Some(CACHE_CONTROL_IMMUTABLE.to_owned()),
|
||||
})
|
||||
}
|
||||
|
||||
async fn download_image(client: &reqwest::Client, url: &str) -> Result<UrlPreviewData> {
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
#[derive(Debug)]
|
||||
pub(crate) struct FileMeta {
|
||||
#[allow(dead_code)]
|
||||
pub(crate) content_disposition: Option<String>,
|
||||
pub(crate) content_type: Option<String>,
|
||||
pub(crate) file: Vec<u8>,
|
||||
|
||||
Reference in New Issue
Block a user