π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Update Space Rust client contracts
Neeraj Gupta7444423def6d
diff --git a/rust/bindings/wasm/ente-wasm/src/space.rs b/rust/bindings/wasm/ente-wasm/src/space.rsindex a7f3700f7b..4fd4132bd7 100644--- a/rust/bindings/wasm/ente-wasm/src/space.rs+++ b/rust/bindings/wasm/ente-wasm/src/space.rs@@ -8,9 +8,9 @@ use ente_core::{};use ente_space::{AccountSpaceCtx, CreatedSpace, CreatedSpaceLink, DecryptedMessage, DecryptedPost,- DecryptedSpaceProfile, MessageConversationActivity, MessageConversationPost, MessageResponse,- OpenAccountSpaceCtxInput, OpenSpaceLinkCtxInput, PostResponse, ProfileAvatarResponse,- ProfileCoverResponse, SpaceActorResponse, SpaceError as CoreSpaceError, SpaceLinkCtx,+ DecryptedSpaceProfile, MessageConversationActivity, MessageResponse, OpenAccountSpaceCtxInput,+ OpenSpaceLinkCtxInput, PostResponse, ProfileAvatarResponse, ProfileCoverResponse,+ SpaceActorResponse, SpaceError as CoreSpaceError, SpaceLinkCtx,};use serde::{Deserialize, Serialize};use serde_wasm_bindgen as swb;@@ -145,8 +145,6 @@ struct ActorJs {key_version: i32,profile: Option<String>,avatar: Option<ProfileAvatarResponse>,- friends: Option<i64>,- posts: Option<i64>,}#[derive(Serialize)]@@ -232,18 +230,9 @@ struct MessageConversationActivityJs {activity_type: String,created_at: String,outgoing: bool,- message: Option<MessageJs>,- post: Option<MessageConversationPostJs>,-}--#[derive(Serialize)]-#[serde(rename_all = "camelCase")]-struct MessageConversationPostJs {- post_id: i64,- space_id: String,- space_slug: String,- is_deleted: bool,- objects: Vec<PostObjectJs>,+ message_id: Option<String>,+ post_id: Option<i64>,+ post_space_id: Option<String>,}#[derive(Serialize)]@@ -364,8 +353,6 @@ fn actor_to_js(key_version: actor.key_version,profile: optional_utf8_field(profile, "actor profile")?,avatar: actor.avatar,- friends: actor.friends,- posts: actor.posts,})}@@ -571,7 +558,7 @@ async fn account_message_response_to_js(viewer_space_id: &str,message: MessageResponse,) -> Result<MessageJs, WasmSpaceError> {- if message.kind != "post_like" {+ if message.kind != "post_like" && message.kind != "friend_added" {let decrypted = ctx.decrypt_message(viewer_space_id, &message).await?;return account_message_to_js(ctx, message, decrypted).await;}@@ -599,38 +586,18 @@ async fn account_message_response_to_js(})}-async fn message_conversation_activity_to_js(- ctx: &AccountSpaceCtx,- viewer_space_id: &str,+fn message_conversation_activity_to_js(activity: MessageConversationActivity,-) -> Result<MessageConversationActivityJs, WasmSpaceError> {- let message = match activity.message {- Some(message) => Some(account_message_response_to_js(ctx, viewer_space_id, message).await?),- None => None,- };- Ok(MessageConversationActivityJs {+) -> MessageConversationActivityJs {+ MessageConversationActivityJs {id: activity.id,activity_type: activity.activity_type,created_at: activity.created_at,outgoing: activity.outgoing,- message,- post: activity- .post- .map(message_conversation_post_to_js)- .transpose()?,- })-}--fn message_conversation_post_to_js(- post: MessageConversationPost,-) -> Result<MessageConversationPostJs, WasmSpaceError> {- Ok(MessageConversationPostJs {- post_id: post.post_id,- space_id: post.space_id,- space_slug: post.space_slug,- is_deleted: post.is_deleted,- objects: post_objects_to_js(None, post.objects)?,- })+ message_id: activity.message_id,+ post_id: activity.post_id,+ post_space_id: activity.post_space_id,+ }}/// Open an authenticated space context for web.@@ -974,12 +941,13 @@ impl SpaceAccountCtxHandle {/// Fetch one post with its caption decrypted.pub async fn get_post(&self,+ space_id: String,post_id: i64,viewer_space_id: Option<String>,) -> Result<JsValue, WasmSpaceError> {let post = self.inner- .get_post(post_id, viewer_space_id.as_deref())+ .get_post(&space_id, post_id, viewer_space_id.as_deref()).await?;let decrypted = self.inner@@ -1021,7 +989,10 @@ impl SpaceAccountCtxHandle {Some(&post_key),).await?;- let post = self.inner.get_post(post_id, Some(&space_id)).await?;+ let post = self+ .inner+ .get_post(&space_id, post_id, Some(&space_id))+ .await?;let decrypted = self.inner.decrypt_post_for_viewer(&post.space_id, Some(&space_id), &post)@@ -1032,12 +1003,13 @@ impl SpaceAccountCtxHandle {/// Download and decrypt one object from a space post.pub async fn download_post_asset(&self,+ space_id: String,post_id: i64,viewer_space_id: Option<String>,object_key: String,) -> Result<Vec<u8>, WasmSpaceError> {self.inner- .download_post_asset(post_id, viewer_space_id.as_deref(), &object_key)+ .download_post_asset(&space_id, post_id, viewer_space_id.as_deref(), &object_key).await.map_err(Into::into)}@@ -1130,6 +1102,7 @@ impl SpaceAccountCtxHandle {/// List people who liked a post.pub async fn list_post_likers(&self,+ space_id: String,post_id: i64,viewer_space_id: Option<String>,cursor: Option<String>,@@ -1137,7 +1110,13 @@ impl SpaceAccountCtxHandle {) -> Result<JsValue, WasmSpaceError> {let page = self.inner- .list_post_likers(post_id, viewer_space_id.as_deref(), cursor, limit)+ .list_post_likers(+ &space_id,+ post_id,+ viewer_space_id.as_deref(),+ cursor,+ limit,+ ).await?;let mut likers = Vec::with_capacity(page.likers.len());for liker in page.likers {@@ -1196,12 +1175,13 @@ impl SpaceAccountCtxHandle {pub async fn reply_to_post(&self,sender_space_id: String,+ post_space_id: String,post_id: i64,text: String,) -> Result<JsValue, WasmSpaceError> {let message = self.inner- .reply_to_post(&sender_space_id, post_id, &text)+ .reply_to_post(&sender_space_id, &post_space_id, post_id, &text).await?;let decrypted = self.inner@@ -1265,12 +1245,7 @@ impl SpaceAccountCtxHandle {chat_summaries.insert(friend_space_id,ConversationChatSummaryJs {- latest_activity: message_conversation_activity_to_js(- &self.inner,- &space_id,- summary.latest_activity,- )- .await?,+ latest_activity: message_conversation_activity_to_js(summary.latest_activity),unread: summary.unread,unread_count: summary.unread_count,notification_unread: summary.notification_unread,@@ -1318,7 +1293,10 @@ impl SpaceAccountCtxHandle {post_id: i64,caption: Option<String>,) -> Result<(), WasmSpaceError> {- let post = self.inner.get_post(post_id, Some(&space_id)).await?;+ let post = self+ .inner+ .get_post(&space_id, post_id, Some(&space_id))+ .await?;let decrypted_post = self.inner.decrypt_post_for_viewer(&post.space_id, Some(&space_id), &post)diff --git a/rust/e2e/tests/space_e2e.rs b/rust/e2e/tests/space_e2e.rsindex d037e385f8..239cefed07 100644--- a/rust/e2e/tests/space_e2e.rs+++ b/rust/e2e/tests/space_e2e.rs@@ -122,7 +122,7 @@ async fn space_bootstrap_posts_friend_share_and_link_suite() {.await.expect("post creation should succeed");let owner_post = owner_ctx- .fetch_post_decrypted(post_id)+ .fetch_post_decrypted(&owner_space.space_id, post_id, None).await.expect("owner should decrypt post");assert_eq!(@@ -148,7 +148,12 @@ async fn space_bootstrap_posts_friend_share_and_link_suite() {owner_feed_decrypted.caption_plaintext.as_deref(),Some(br#"{"caption":"hello world"}"#.as_slice()));- space::assert_http_status(owner_ctx.like_post(post_id, true).await, 400);+ space::assert_http_status(+ owner_ctx+ .like_post(&owner_space.space_id, post_id, true)+ .await,+ 400,+ );space::assert_http_status(friend_ctx@@ -234,12 +239,12 @@ async fn space_bootstrap_posts_friend_share_and_link_suite() {);let liked = friend_ctx- .like_post(post_id, true)+ .like_post(&friend_space.space_id, post_id, true).await.expect("liking post should succeed");assert!(liked.liked);let likers = owner_ctx- .list_post_likers(post_id, None, Some(10))+ .list_post_likers(&owner_space.space_id, post_id, None, None, Some(10)).await.expect("post likers should load");assert_eq!(likers.likers.len(), 1);@@ -254,7 +259,12 @@ async fn space_bootstrap_posts_friend_share_and_link_suite() {Some(friend_profile_payload.as_slice()));- space::assert_http_status(outsider_ctx.fetch_post_decrypted(post_id).await, 403);+ space::assert_http_status(+ outsider_ctx+ .fetch_post_decrypted(&owner_space.space_id, post_id, None)+ .await,+ 403,+ );let link_profile = link_ctx.get_space_profile_decrypted(None)@@ -387,7 +397,7 @@ async fn space_unfriend_revokes_reciprocal_account_access_suite() {.expect("friend feed should load before unfriend");assert!(feed.items.iter().any(|item| item.post_id == post_id));friend_ctx- .like_post(post_id, true)+ .like_post(&friend_space.space_id, post_id, true).await.expect("friend should like owner post before unfriend");let direct_message = friend_ctx@@ -516,12 +526,32 @@ async fn space_unfriend_revokes_reciprocal_account_access_suite() {.await,403,);- space::assert_http_status(friend_ctx.fetch_post_decrypted(post_id).await, 403);- space::assert_http_status(friend_ctx.like_post(post_id, true).await, 403);- space::assert_http_status(friend_ctx.reply_to_post(post_id, "should fail").await, 403);+ space::assert_http_status(+ friend_ctx+ .fetch_post_decrypted(&owner_space.space_id, post_id, Some(&friend_space.space_id))+ .await,+ 403,+ );+ space::assert_http_status(+ friend_ctx+ .like_post(&friend_space.space_id, post_id, true)+ .await,+ 403,+ );+ space::assert_http_status(+ friend_ctx+ .reply_to_post(+ &friend_space.space_id,+ &owner_space.space_id,+ post_id,+ "should fail",+ )+ .await,+ 403,+ );let likers = owner_ctx- .list_post_likers(post_id, None, Some(10))+ .list_post_likers(&owner_space.space_id, post_id, None, None, Some(10)).await.expect("owner should still load post likers after unfriend");assert_eq!(likers.likers.len(), 1);diff --git a/rust/space/src/client/assets.rs b/rust/space/src/client/assets.rsindex a25b51daed..10a6d8250a 100644--- a/rust/space/src/client/assets.rs+++ b/rust/space/src/client/assets.rs@@ -203,15 +203,15 @@ impl AccountSpaceCtx {object_id: &str,) -> Result<AssetDownloadResponse> {let mut query = vec![- ("spaceId", space_id.to_owned()),("assetType", asset_type.to_owned()),("objectID", object_id.to_owned()),];if let Some(value) = viewer_space_id.filter(|value| !value.trim().is_empty()) {query.push(("viewerSpaceId", value.to_owned()));}+ let path = format!("/spaces/{space_id}/assets/redirect");self.client()- .get_json("/space/assets/redirect", &query)+ .get_json(&path, &query).await.map_err(Into::into)}@@ -241,15 +241,13 @@ impl AccountSpaceCtx {viewer_space_id: Option<&str>,object_key: &str,) -> Result<AssetDownloadResponse> {- let mut query = vec![- ("spaceId", space_id.to_owned()),- ("objectKey", object_key.to_owned()),- ];+ let mut query = vec![("objectKey", object_key.to_owned())];if let Some(value) = viewer_space_id.filter(|value| !value.trim().is_empty()) {query.push(("viewerSpaceId", value.to_owned()));}+ let path = format!("/spaces/{space_id}/assets/redirect");self.client()- .get_json("/space/assets/redirect", &query)+ .get_json(&path, &query).await.map_err(Into::into)}diff --git a/rust/space/src/client/keys.rs b/rust/space/src/client/keys.rsindex 1f70342bc2..b27b34fed6 100644--- a/rust/space/src/client/keys.rs+++ b/rust/space/src/client/keys.rs@@ -21,12 +21,13 @@ impl AccountSpaceCtx {space_id: &str,viewer_space_id: Option<&str>,) -> Result<Vec<SpaceKeyVersionResponse>> {- let mut query = vec![("spaceId", space_id.to_owned())];+ let mut query = Vec::new();if let Some(value) = viewer_space_id.filter(|value| !value.trim().is_empty()) {query.push(("viewerSpaceId", value.to_owned()));}+ let path = format!("/spaces/{space_id}/versions");self.client()- .get_json("/space/versions", &query)+ .get_json(&path, &query).await.map_err(Into::into)}diff --git a/rust/space/src/client/link_ctx.rs b/rust/space/src/client/link_ctx.rsindex 2692c007c1..2f47234551 100644--- a/rust/space/src/client/link_ctx.rs+++ b/rust/space/src/client/link_ctx.rs@@ -110,12 +110,13 @@ impl SpaceLinkCtx {&self,version: Option<i32>,) -> Result<SpaceProfileResponse> {- let mut query = vec![("spaceId", self.space_id.clone())];+ let mut query = Vec::new();if let Some(value) = version {query.push(("version", value.to_string()));}+ let path = format!("/spaces/{}/profile", self.space_id);self.client- .get_json("/space/profile", &query)+ .get_json(&path, &query).await.map_err(Into::into)}@@ -138,21 +139,22 @@ impl SpaceLinkCtx {}pub async fn list_posts(&self, cursor: Option<String>, limit: Option<i32>) -> Result<PostPage> {- let mut query = vec![("spaceId", self.space_id.clone())];+ let mut query = Vec::new();if let Some(value) = cursor.filter(|value| !value.trim().is_empty()) {query.push(("cursor", value));}if let Some(value) = limit {query.push(("limit", value.to_string()));}+ let path = format!("/spaces/{}/posts", self.space_id);self.client- .get_json("/space/posts", &query)+ .get_json(&path, &query).await.map_err(Into::into)}pub async fn get_post(&self, post_id: i64) -> Result<PostResponse> {- let path = format!("/space/posts/{post_id}");+ let path = format!("/spaces/{}/posts/{post_id}", self.space_id);self.client.get_json(&path, &[]).await.map_err(Into::into)}@@ -248,7 +250,7 @@ impl SpaceLinkCtx {if let Some(value) = limit {query.push(("limit", value.to_string()));}- let path = format!("/space/posts/{post_id}/likes");+ let path = format!("/spaces/{}/posts/{post_id}/likes", self.space_id);self.client.get_json(&path, &query).await@@ -256,9 +258,10 @@ impl SpaceLinkCtx {}pub async fn list_space_key_versions(&self) -> Result<Vec<SpaceKeyVersionResponse>> {- let query = vec![("spaceId", self.space_id.clone())];+ let query = Vec::new();+ let path = format!("/spaces/{}/versions", self.space_id);self.client- .get_json("/space/versions", &query)+ .get_json(&path, &query).await.map_err(Into::into)}@@ -271,12 +274,10 @@ impl SpaceLinkCtx {}pub async fn get_asset_url(&self, object_key: &str) -> Result<AssetDownloadResponse> {- let query = vec![- ("spaceId", self.space_id.clone()),- ("objectKey", object_key.to_owned()),- ];+ let query = vec![("objectKey", object_key.to_owned())];+ let path = format!("/spaces/{}/assets/redirect", self.space_id);self.client- .get_json("/space/assets/redirect", &query)+ .get_json(&path, &query).await.map_err(Into::into)}@@ -287,12 +288,12 @@ impl SpaceLinkCtx {object_id: &str,) -> Result<AssetDownloadResponse> {let query = vec![- ("spaceId", self.space_id.clone()),("assetType", asset_type.to_owned()),("objectID", object_id.to_owned()),];+ let path = format!("/spaces/{}/assets/redirect", self.space_id);self.client- .get_json("/space/assets/redirect", &query)+ .get_json(&path, &query).await.map_err(Into::into)}diff --git a/rust/space/src/client/messages.rs b/rust/space/src/client/messages.rsindex 2f41d3b995..7ca1a39a51 100644--- a/rust/space/src/client/messages.rs+++ b/rust/space/src/client/messages.rs@@ -16,8 +16,8 @@ use crate::crypto::{use crate::error::{Result, SpaceError};use crate::models::{DecryptedMessage, MessagePayload, MessageQuote};use crate::transport::{- ConversationsResponse, CreateMessageRequest, LikeMessageRequest, LikeMessageResponse,- MessagePage, MessageResponse, SpaceActorResponse,+ ConversationsResponse, CreateMessageRequest, LikeMessageResponse, MessagePage, MessageResponse,+ SpaceActorResponse,};use ente_core::crypto::{decode_b64, encode_b64};@@ -41,7 +41,7 @@ impl AccountSpaceCtx {if let Some(value) = limit {query.push(("limit", value.to_string()));}- let path = format!("/spaces/{viewer_space_id}/messages/{space_id}");+ let path = format!("/spaces/{viewer_space_id}/friends/{space_id}/messages");self.client().get_json(&path, &query).await@@ -66,7 +66,7 @@ impl AccountSpaceCtx {let request = self.message_request_for_payload(sender_space_id, &friend.public_key, &payload, None).await?;- let path = format!("/spaces/{sender_space_id}/messages/{space_id}");+ let path = format!("/spaces/{sender_space_id}/friends/{space_id}/messages");self.client().post_json(&path, &request).await@@ -101,7 +101,7 @@ impl AccountSpaceCtx {Some(reply_message_id),).await?;- let path = format!("/spaces/{sender_space_id}/messages/{space_id}");+ let path = format!("/spaces/{sender_space_id}/friends/{space_id}/messages");self.client().post_json(&path, &request).await@@ -111,10 +111,13 @@ impl AccountSpaceCtx {pub async fn reply_to_post(&self,sender_space_id: &str,+ post_space_id: &str,post_id: i64,text: &str,) -> Result<MessageResponse> {- let post = self.get_post(post_id, Some(sender_space_id)).await?;+ let post = self+ .get_post(post_space_id, post_id, Some(sender_space_id))+ .await?;if self.resolve_owned_space_access(&post.space_id).await?@@ -196,12 +199,18 @@ impl AccountSpaceCtx {if message_id.is_empty() {return Err(SpaceError::InvalidInput("message id is required".into()));}- let request = LikeMessageRequest { like };- let path = format!("/spaces/{space_id}/message/{message_id}/like");- self.client()- .post_json(&path, &request)- .await- .map_err(Into::into)+ let path = format!("/spaces/{space_id}/messages/{message_id}/like");+ if like {+ self.client()+ .put_json(&path, &serde_json::json!({}))+ .await+ .map_err(Into::into)+ } else {+ self.client()+ .delete_json(&path, &[])+ .await+ .map_err(Into::into)+ }}pub async fn delete_message(&self, space_id: &str, message_id: &str) -> Result<()> {@@ -209,7 +218,7 @@ impl AccountSpaceCtx {if message_id.is_empty() {return Err(SpaceError::InvalidInput("message id is required".into()));}- let path = format!("/spaces/{space_id}/message/{message_id}");+ let path = format!("/spaces/{space_id}/messages/{message_id}");self.client().delete_empty(&path, &[]).awaitdiff --git a/rust/space/src/client/posts.rs b/rust/space/src/client/posts.rsindex 16f411980c..a89cc5a11c 100644--- a/rust/space/src/client/posts.rs+++ b/rust/space/src/client/posts.rs@@ -14,9 +14,9 @@ use crate::crypto::{decrypt_secretbox_payload, encrypt_secretbox_payload, generause crate::error::{Result, SpaceError};use crate::models::{DecryptedPost, FeedItem, FeedPage, HydratedKeys, PostObjectMetadata};use crate::transport::{- CreatePostRequest, CreatePostResponse, LikePostRequest, LikePostResponse,- ListPostLikersResponse, MarkNotificationsReadRequest, PostObjectPayload, PostPage,- PostResponse, SpaceActorResponse, SpaceUnreadStatusResponse, UpdatePostCaptionRequest,+ CreatePostRequest, CreatePostResponse, LikePostResponse, ListPostLikersResponse,+ PostObjectPayload, PostPage, PostResponse, SpaceActorResponse, SpaceUnreadStatusResponse,+ UpdatePostCaptionRequest,};use ente_core::crypto::{decode_b64, encode_b64};@@ -71,7 +71,7 @@ impl AccountSpaceCtx {cursor: Option<String>,limit: Option<i32>,) -> Result<PostPage> {- let mut query = vec![("spaceId", space_id.to_owned())];+ let mut query = Vec::new();if let Some(value) = viewer_space_id.filter(|value| !value.trim().is_empty()) {query.push(("viewerSpaceId", value.to_owned()));}@@ -81,8 +81,9 @@ impl AccountSpaceCtx {if let Some(value) = limit {query.push(("limit", value.to_string()));}+ let path = format!("/spaces/{space_id}/posts");self.client()- .get_json("/space/posts", &query)+ .get_json(&path, &query).await.map_err(Into::into)}@@ -127,19 +128,20 @@ impl AccountSpaceCtx {"friend space id is required".into(),));}- let path = format!("/spaces/{space_id}/messages/read");+ let path = format!("/spaces/{space_id}/friends/{friend_space_id}/read");self.client()- .post_json(&path, &MarkNotificationsReadRequest { friend_space_id })+ .post_json(&path, &serde_json::json!({})).await.map_err(Into::into)}pub async fn get_post(&self,+ space_id: &str,post_id: i64,viewer_space_id: Option<&str>,) -> Result<PostResponse> {- let path = format!("/space/posts/{post_id}");+ let path = format!("/spaces/{space_id}/posts/{post_id}");let mut query = Vec::new();if let Some(value) = viewer_space_id.filter(|value| !value.trim().is_empty()) {query.push(("viewerSpaceId", value.to_owned()));@@ -152,21 +154,23 @@ impl AccountSpaceCtx {pub async fn fetch_post_decrypted(&self,+ space_id: &str,post_id: i64,viewer_space_id: Option<&str>,) -> Result<DecryptedPost> {- let post = self.get_post(post_id, viewer_space_id).await?;+ let post = self.get_post(space_id, post_id, viewer_space_id).await?;self.decrypt_post_for_viewer(&post.space_id, viewer_space_id, &post).await}pub async fn download_post_asset(&self,+ space_id: &str,post_id: i64,viewer_space_id: Option<&str>,object_key: &str,) -> Result<Vec<u8>> {- let post = self.get_post(post_id, viewer_space_id).await?;+ let post = self.get_post(space_id, post_id, viewer_space_id).await?;let decrypted = self.decrypt_post_for_viewer(&post.space_id, viewer_space_id, &post).await?;@@ -396,15 +400,22 @@ impl AccountSpaceCtx {like: bool,) -> Result<LikePostResponse> {let path = format!("/spaces/{space_id}/posts/{post_id}/like");- let request = LikePostRequest { like };- self.client()- .post_json(&path, &request)- .await- .map_err(Into::into)+ if like {+ self.client()+ .put_json(&path, &serde_json::json!({}))+ .await+ .map_err(Into::into)+ } else {+ self.client()+ .delete_json(&path, &[])+ .await+ .map_err(Into::into)+ }}pub async fn list_post_likers(&self,+ space_id: &str,post_id: i64,viewer_space_id: Option<&str>,cursor: Option<String>,@@ -420,7 +431,7 @@ impl AccountSpaceCtx {if let Some(value) = limit {query.push(("limit", value.to_string()));}- let path = format!("/space/posts/{post_id}/likes");+ let path = format!("/spaces/{space_id}/posts/{post_id}/likes");self.client().get_json(&path, &query).awaitdiff --git a/rust/space/src/client/profiles.rs b/rust/space/src/client/profiles.rsindex bd0ed1219b..aaaae18410 100644--- a/rust/space/src/client/profiles.rs+++ b/rust/space/src/client/profiles.rs@@ -23,15 +23,16 @@ impl AccountSpaceCtx {viewer_space_id: Option<&str>,version: Option<i32>,) -> Result<SpaceProfileResponse> {- let mut query = vec![("spaceId", space_id.to_owned())];+ let mut query = Vec::new();if let Some(value) = viewer_space_id.filter(|value| !value.trim().is_empty()) {query.push(("viewerSpaceId", value.to_owned()));}if let Some(value) = version {query.push(("version", value.to_string()));}+ let path = format!("/spaces/{space_id}/profile");self.client()- .get_json("/space/profile", &query)+ .get_json(&path, &query).await.map_err(Into::into)}diff --git a/rust/space/src/client/tests.rs b/rust/space/src/client/tests.rsindex fb5b38ab6e..991a1a883a 100644--- a/rust/space/src/client/tests.rs+++ b/rust/space/src/client/tests.rs@@ -275,12 +275,8 @@ async fn space_link_decrypt_post_key_uses_post_version() {.expect("wrapped previous key"),);let versions = server- .mock("GET", "/space/versions")+ .mock("GET", "/spaces/space_owner_gallery/versions").match_header("x-auth-token", "link-token")- .match_query(Matcher::UrlEncoded(- "spaceId".into(),- "space_owner_gallery".into(),- )).with_status(200).with_body(json!([{@@ -342,12 +338,9 @@ async fn space_link_download_post_asset_with_key_skips_post_fetch() {encrypt_asset_payload(&post_key, b"post-image").expect("asset encryption");let redirect = server- .mock("GET", "/space/assets/redirect")+ .mock("GET", "/spaces/space_owner_gallery/assets/redirect").match_header("x-auth-token", "link-token")- .match_query(Matcher::AllOf(vec![- Matcher::UrlEncoded("spaceId".into(), "space_owner_gallery".into()),- Matcher::UrlEncoded("objectKey".into(), object_key.into()),- ]))+ .match_query(Matcher::UrlEncoded("objectKey".into(), object_key.into())).with_status(200).with_body(json!({@@ -769,10 +762,9 @@ async fn account_download_profile_avatar_uses_object_id_redirect() {let encrypted_asset =encrypt_asset_payload(&space_key, b"avatar-image").expect("asset encryption");let redirect = server- .mock("GET", "/space/assets/redirect")+ .mock("GET", "/spaces/space_owner_main/assets/redirect").match_header("x-space-session-token", "space-session-token").match_query(Matcher::AllOf(vec![- Matcher::UrlEncoded("spaceId".into(), "space_owner_main".into()),Matcher::UrlEncoded("assetType".into(), "avatar".into()),Matcher::UrlEncoded("objectID".into(), "avatar-object".into()),]))@@ -816,10 +808,9 @@ async fn space_link_download_profile_cover_uses_object_id_redirect() {let encrypted_asset =encrypt_asset_payload(&space_key, b"cover-image").expect("asset encryption");let redirect = server- .mock("GET", "/space/assets/redirect")+ .mock("GET", "/spaces/space_owner_gallery/assets/redirect").match_header("x-auth-token", "link-token").match_query(Matcher::AllOf(vec![- Matcher::UrlEncoded("spaceId".into(), "space_owner_gallery".into()),Matcher::UrlEncoded("assetType".into(), "cover".into()),Matcher::UrlEncoded("objectID".into(), "cover-object".into()),]))@@ -1188,12 +1179,8 @@ async fn get_space_profile_decrypted_loads_and_decrypts_profile() {let encrypted_profile =encode_b64(&encrypt_secretbox_payload(&space_key, b"profile-json").expect("profile wrap"));let profile = server- .mock("GET", "/space/profile")+ .mock("GET", "/spaces/space_owner_main/profile").match_header("x-space-session-token", "space-session-token")- .match_query(Matcher::UrlEncoded(- "spaceId".into(),- "space_owner_main".into(),- )).with_status(200).with_body(json!({@@ -1369,9 +1356,8 @@ async fn like_post_uses_post_like_endpoint() {let mut server = Server::new_async().await;let ctx = test_account_ctx(&server.url());let like = server- .mock("POST", "/spaces/space_owner_main/posts/42/like")+ .mock("PUT", "/spaces/space_owner_main/posts/42/like").match_header("x-space-session-token", "space-session-token")- .match_body(Matcher::JsonString(json!({"like": true}).to_string())).with_status(200).with_body(json!({"liked": true}).to_string()).create_async()@@ -1398,11 +1384,8 @@ async fn unread_methods_use_read_marker_endpoints() {.create_async().await;let notifications_read = server- .mock("POST", "/spaces/space_owner_main/messages/read")+ .mock("POST", "/spaces/space_owner_main/friends/space_friend/read").match_header("x-space-session-token", "space-session-token")- .match_body(Matcher::JsonString(- json!({"friendSpaceId": "space_friend"}).to_string(),- )).with_status(200).with_body(json!({"notificationsUnread": false}).to_string()).create_async()@@ -1451,7 +1434,10 @@ async fn message_actions_use_message_endpoints() {.create_async().await;let reply = server- .mock("POST", "/spaces/space_owner_main/messages/space_friend")+ .mock(+ "POST",+ "/spaces/space_owner_main/friends/space_friend/messages",+ ).match_header("x-space-session-token", "space-session-token").match_body(Matcher::AllOf(vec![Matcher::Regex("\"replyMessageId\":\"wmsg_parent\"".into()),@@ -1490,15 +1476,14 @@ async fn message_actions_use_message_endpoints() {.create_async().await;let like = server- .mock("POST", "/spaces/space_owner_main/message/wmsg_reply/like")+ .mock("PUT", "/spaces/space_owner_main/messages/wmsg_reply/like").match_header("x-space-session-token", "space-session-token")- .match_body(Matcher::JsonString(json!({"like": true}).to_string())).with_status(200).with_body(json!({"liked": true}).to_string()).create_async().await;let delete = server- .mock("DELETE", "/spaces/space_owner_main/message/wmsg_reply")+ .mock("DELETE", "/spaces/space_owner_main/messages/wmsg_reply").match_header("x-space-session-token", "space-session-token").with_status(200).create_async()@@ -1571,7 +1556,7 @@ async fn list_post_likers_uses_post_likes_endpoint() {let mut server = Server::new_async().await;let ctx = test_account_ctx(&server.url());let likers = server- .mock("GET", "/space/posts/42/likes")+ .mock("GET", "/spaces/space_owner_main/posts/42/likes").match_header("x-space-session-token", "space-session-token").match_query(Matcher::AllOf(vec![Matcher::UrlEncoded("viewerSpaceId".into(), "space_owner_main".into()),@@ -1597,6 +1582,7 @@ async fn list_post_likers_uses_post_likes_endpoint() {let response = ctx.list_post_likers(+ "space_owner_main",42,Some("space_owner_main"),Some("3000:7".to_owned()),@@ -1684,7 +1670,7 @@ async fn space_link_list_post_likers_uses_session_token() {1,);let likers = server- .mock("GET", "/space/posts/42/likes")+ .mock("GET", "/spaces/space_owner_main/posts/42/likes").match_header("x-auth-token", "link-session-token").with_status(200).with_body(json!({"likers": [], "nextCursor": ""}).to_string())@@ -2017,10 +2003,9 @@ async fn list_posts_uses_space_posts_page_endpoint() {let mut server = Server::new_async().await;let ctx = test_account_ctx(&server.url());let posts = server- .mock("GET", "/space/posts")+ .mock("GET", "/spaces/space_owner_gallery/posts").match_header("x-space-session-token", "space-session-token").match_query(Matcher::AllOf(vec![- Matcher::UrlEncoded("spaceId".into(), "space_owner_gallery".into()),Matcher::UrlEncoded("viewerSpaceId".into(), "space_owner_main".into()),Matcher::UrlEncoded("cursor".into(), "42".into()),Matcher::UrlEncoded("limit".into(), "5".into()),@@ -2092,7 +2077,7 @@ async fn fetch_post_decrypted_uses_post_by_id_endpoint() {.create_async().await;let post = server- .mock("GET", "/space/posts/42")+ .mock("GET", "/spaces/space_owner_gallery/posts/42").match_header("x-space-session-token", "space-session-token").with_status(200).with_body(@@ -2117,7 +2102,7 @@ async fn fetch_post_decrypted_uses_post_by_id_endpoint() {.await;let decrypted = ctx- .fetch_post_decrypted(42, None)+ .fetch_post_decrypted("space_owner_gallery", 42, None).await.expect("post should decrypt");diff --git a/rust/space/src/lib.rs b/rust/space/src/lib.rsindex 49d947e41b..4995414fd1 100644--- a/rust/space/src/lib.rs+++ b/rust/space/src/lib.rs@@ -20,8 +20,8 @@ pub use models::{pub use transport::{ConversationChatSummaryResponse, ConversationsResponse, EntityKeyPayload,FriendRelationshipResponse, FriendShareResponse, FriendStatusResponse, LikeMessageResponse,- LikePostResponse, ListPostLikersResponse, MessageConversationActivity, MessageConversationPost,- MessagePage, MessageResponse, PostLikerResponse, PostObjectPayload, PostPage, PostResponse,+ LikePostResponse, ListPostLikersResponse, MessageConversationActivity, MessagePage,+ MessageResponse, PostLikerResponse, PostObjectPayload, PostPage, PostResponse,PresignUploadResponse, ProfileAvatarPayload, ProfileAvatarResponse, ProfileCoverPayload,ProfileCoverResponse, SpaceActorResponse, SpaceFriendRequestResponse, SpaceFriendResponse,SpaceKeyResponse, SpaceKeyVersionResponse, SpaceLinkLoginResponse, SpaceLinkStatusResponse,diff --git a/rust/space/src/transport.rs b/rust/space/src/transport.rsindex 3d05e5188b..ed9960173d 100644--- a/rust/space/src/transport.rs+++ b/rust/space/src/transport.rs@@ -113,35 +113,17 @@ pub struct CreatePostResponse {pub post_id: i64,}-#[derive(Debug, Clone, Serialize)]-#[serde(rename_all = "camelCase")]-pub struct LikePostRequest {- pub like: bool,-}-#[derive(Debug, Clone, Serialize, Deserialize)]pub struct LikePostResponse {pub liked: bool,}-#[derive(Debug, Clone, Serialize)]-#[serde(rename_all = "camelCase")]-pub struct MarkNotificationsReadRequest {- pub friend_space_id: String,-}-#[derive(Debug, Clone, Serialize, Deserialize)]#[serde(rename_all = "camelCase")]pub struct SpaceUnreadStatusResponse {pub notifications_unread: bool,}-#[derive(Debug, Clone, Serialize)]-#[serde(rename_all = "camelCase")]-pub struct LikeMessageRequest {- pub like: bool,-}-#[derive(Debug, Clone, Serialize, Deserialize)]pub struct LikeMessageResponse {pub liked: bool,@@ -221,21 +203,11 @@ pub struct MessageConversationActivity {#[serde(default)]pub outgoing: bool,#[serde(default)]- pub message: Option<MessageResponse>,- #[serde(default)]- pub post: Option<MessageConversationPost>,-}--#[derive(Debug, Clone, Serialize, Deserialize)]-#[serde(rename_all = "camelCase")]-pub struct MessageConversationPost {- pub post_id: i64,- pub space_id: String,- pub space_slug: String,+ pub message_id: Option<String>,#[serde(default)]- pub is_deleted: bool,+ pub post_id: Option<i64>,#[serde(default)]- pub objects: Vec<PostObjectPayload>,+ pub post_space_id: Option<String>,}#[derive(Debug, Clone, Serialize, Deserialize)]@@ -306,10 +278,6 @@ pub struct SpaceActorResponse {pub encrypted_profile: String,#[serde(default)]pub avatar: Option<ProfileAvatarResponse>,- #[serde(default)]- pub friends: Option<i64>,- #[serde(default)]- pub posts: Option<i64>,}#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]@@ -476,7 +444,7 @@ mod tests {}#[test]- fn conversations_response_deserializes_minimal_embedded_actors() {+ fn conversations_response_deserializes_thin_activity() {let response: ConversationsResponse = serde_json::from_str(r#"{"friends":[{"friend":{"spaceId":"space_friend","spaceSlug":"friend-main"},"createdAt":"2026-05-25T00:00:00Z"}],@@ -487,15 +455,7 @@ mod tests {"id":"message:msg_1","type":"message","createdAt":"2026-05-25T00:00:00Z",- "message":{- "messageId":"msg_1",- "kind":"regular",- "sender":{"spaceSlug":"owner-main"},- "recipient":{"spaceSlug":"friend-main"},- "text":"hello",- "createdAt":"2026-05-25T00:00:00Z",- "updatedAt":"2026-05-25T00:00:00Z"- }+ "messageId":"msg_1"}}}@@ -505,15 +465,9 @@ mod tests {let friend = &response.friends[0];assert_eq!(friend.friend.space_slug, "friend-main");- let message = response.chat_summaries["space_friend"]- .latest_activity- .message- .as_ref()- .expect("latest activity message should be preserved");- assert_eq!(message.sender.space_slug, "owner-main");- assert_eq!(message.sender.public_key, "");- assert_eq!(message.recipient.space_slug, "friend-main");- assert_eq!(message.recipient.space_id, "");+ let activity = &response.chat_summaries["space_friend"].latest_activity;+ assert_eq!(activity.message_id.as_deref(), Some("msg_1"));+ assert_eq!(activity.post_id, None);}}