π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[rust][contacts] use bare transfers for profile pictures
Neeraj Guptafafc7531b19a
diff --git a/rust/contacts/src/client.rs b/rust/contacts/src/client.rsindex 8dedc7d0c2..8d11d71745 100644--- a/rust/contacts/src/client.rs+++ b/rust/contacts/src/client.rs@@ -42,6 +42,7 @@ pub struct OpenContactsCtxResult {pub struct ContactsCtx {user_id: i64,http: HttpClient,+ object_store_http: ente_core::http::ObjectStoreHttpClient,master_key: Arc<RwLock<SecretVec>>,root_contact_key: Arc<RwLock<SecretVec>>,wrapped_root_key: Arc<RwLock<WrappedRootContactKey>>,@@ -101,6 +102,7 @@ impl ContactsCtx {let ctx = Self {user_id: input.user_id,+ object_store_http: http.object_store(),http,master_key: Arc::new(RwLock::new(SecretVec::new(input.master_key))),root_contact_key: Arc::new(RwLock::new(SecretVec::new(root_contact_key))),@@ -269,7 +271,7 @@ impl ContactsCtx {).await?;- self.http+ self.object_store_http.put_bytes(&upload.url,&encrypted_picture,@@ -315,7 +317,7 @@ impl ContactsCtx {.http.get_json::<SignedUrlResponse>(&format!("/contacts/{contact_id}/profile-picture"), &[]).await?;- let encrypted_picture = self.http.get_bytes(&download.url).await?;+ let encrypted_picture = self.object_store_http.get_bytes(&download.url).await?;contacts_crypto::decrypt_profile_picture(&encrypted_picture, &contact_key)}diff --git a/rust/contacts/tests/contacts_mock.rs b/rust/contacts/tests/contacts_mock.rsindex 4c44b7535c..1e93585d66 100644--- a/rust/contacts/tests/contacts_mock.rs+++ b/rust/contacts/tests/contacts_mock.rs@@ -196,16 +196,6 @@ async fn set_profile_picture_uses_signed_upload_url_and_commit() {.await;let upload_url = format!("{}/upload/ua_picture1", server.url());- let encrypted_picture = {- let contact_key = contacts_crypto::unwrap_contact_key(- current_entity["encryptedKey"].as_str().unwrap(),- &root_key,- )- .unwrap();- contacts_crypto::encrypt_profile_picture(&picture_bytes, &contact_key).unwrap()- };- let _content_md5 = contacts_crypto::content_md5_base64(&encrypted_picture);-let upload_url_mock = server.mock("POST", "/contacts/ct_picture1/profile-picture/upload-url").with_status(200)@@ -222,6 +212,14 @@ async fn set_profile_picture_uses_signed_upload_url_and_commit() {let upload_bytes_mock = server.mock("PUT", "/upload/ua_picture1")+ .match_header("x-auth-token", Matcher::Missing)+ .match_header("x-client-package", Matcher::Missing)+ .match_header("x-client-version", Matcher::Missing)+ .match_header("user-agent", Matcher::Missing)+ .match_header(+ "content-md5",+ Matcher::Regex(r"^[A-Za-z0-9+/]+={0,2}$".to_string()),+ ).with_status(200).expect(1).create_async()@@ -329,6 +327,10 @@ async fn get_profile_picture_uses_signed_download_url() {let download_mock = server.mock("GET", "/download/ua_picture1")+ .match_header("x-auth-token", Matcher::Missing)+ .match_header("x-client-package", Matcher::Missing)+ .match_header("x-client-version", Matcher::Missing)+ .match_header("user-agent", Matcher::Missing).with_status(200).with_body(encrypted_picture.clone()).expect(1)