From 674e444d671efa035e048616c12d68ba8577c6f8 Mon Sep 17 00:00:00 2001 From: Stefan Melmuk <509385+stefan0xC@users.noreply.github.com> Date: Thu, 1 May 2025 17:28:23 +0200 Subject: [PATCH 1/2] respond with cipher json when deleting attachments (#5823) --- src/api/core/ciphers.rs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/api/core/ciphers.rs b/src/api/core/ciphers.rs index 6c75d246..6b883bab 100644 --- a/src/api/core/ciphers.rs +++ b/src/api/core/ciphers.rs @@ -1376,7 +1376,7 @@ async fn delete_attachment_post_admin( headers: Headers, conn: DbConn, nt: Notify<'_>, -) -> EmptyResult { +) -> JsonResult { delete_attachment(cipher_id, attachment_id, headers, conn, nt).await } @@ -1387,7 +1387,7 @@ async fn delete_attachment_post( headers: Headers, conn: DbConn, nt: Notify<'_>, -) -> EmptyResult { +) -> JsonResult { delete_attachment(cipher_id, attachment_id, headers, conn, nt).await } @@ -1398,7 +1398,7 @@ async fn delete_attachment( headers: Headers, mut conn: DbConn, nt: Notify<'_>, -) -> EmptyResult { +) -> JsonResult { _delete_cipher_attachment_by_id(&cipher_id, &attachment_id, &headers, &mut conn, &nt).await } @@ -1409,7 +1409,7 @@ async fn delete_attachment_admin( headers: Headers, mut conn: DbConn, nt: Notify<'_>, -) -> EmptyResult { +) -> JsonResult { _delete_cipher_attachment_by_id(&cipher_id, &attachment_id, &headers, &mut conn, &nt).await } @@ -1818,7 +1818,7 @@ async fn _delete_cipher_attachment_by_id( headers: &Headers, conn: &mut DbConn, nt: &Notify<'_>, -) -> EmptyResult { +) -> JsonResult { let Some(attachment) = Attachment::find_by_id(attachment_id, conn).await else { err!("Attachment doesn't exist") }; @@ -1847,11 +1847,11 @@ async fn _delete_cipher_attachment_by_id( ) .await; - if let Some(org_id) = cipher.organization_uuid { + if let Some(ref org_id) = cipher.organization_uuid { log_event( EventType::CipherAttachmentDeleted as i32, &cipher.uuid, - &org_id, + org_id, &headers.user.uuid, headers.device.atype, &headers.ip.ip, @@ -1859,7 +1859,8 @@ async fn _delete_cipher_attachment_by_id( ) .await; } - Ok(()) + let cipher_json = cipher.to_json(&headers.host, &headers.user.uuid, None, CipherSyncType::User, conn).await; + Ok(Json(json!({"cipher":cipher_json}))) } /// This will hold all the necessary data to improve a full sync of all the ciphers From 2697fe8aba9b082aca02b48990bc65e9fc526aa4 Mon Sep 17 00:00:00 2001 From: "Helmut K. C. Tessarek" Date: Thu, 1 May 2025 17:40:26 +0200 Subject: [PATCH 2/2] feat: add feature flag export-attachments (#5784) --- .env.template | 1 + src/config.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/.env.template b/.env.template index a2c3ba19..154e9482 100644 --- a/.env.template +++ b/.env.template @@ -357,6 +357,7 @@ ## - "anon-addy-self-host-alias": Enable configuring self-hosted Anon Addy alias generator. (Needs Android >=2025.2.0) ## - "simple-login-self-host-alias": Enable configuring self-hosted Simple Login alias generator. (Needs Android >=2025.2.0) ## - "mutual-tls": Enable the use of mutual TLS on Android (Client >= 2025.2.0) +## - "export-attachments": Enable support for exporting attachments (Clients >=2025.4.0) # EXPERIMENTAL_CLIENT_FEATURE_FLAGS=fido2-vault-credentials ## Require new device emails. When a user logs in an email is required to be sent. diff --git a/src/config.rs b/src/config.rs index 53bd5592..790443f0 100644 --- a/src/config.rs +++ b/src/config.rs @@ -846,6 +846,7 @@ fn validate_config(cfg: &ConfigItems) -> Result<(), Error> { "anon-addy-self-host-alias", "simple-login-self-host-alias", "mutual-tls", + "export-attachments", ]; let configured_flags = parse_experimental_client_feature_flags(&cfg.experimental_client_feature_flags); let invalid_flags: Vec<_> = configured_flags.keys().filter(|flag| !KNOWN_FLAGS.contains(&flag.as_str())).collect();