Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Explain the pending outgoing Space friend request limit

Anand Baburajana217457aa767
diff --git a/rust/bindings/wasm/space/src/space.rs b/rust/bindings/wasm/space/src/space.rs
index b1e76097ba..d951ca1544 100644
--- a/rust/bindings/wasm/space/src/space.rs
+++ b/rust/bindings/wasm/space/src/space.rs
@@ -35,6 +35,9 @@ impl Error {
Self::Space(ente_space::Error::FriendRequestLimitReached) => {
Some("friend_request_limit_reached")
}
+ Self::Space(ente_space::Error::SentFriendRequestLimitReached) => {
+ Some("sent_friend_request_limit_reached")
+ }
Self::Space(ente_space::Error::FriendRequestUnavailable) => {
Some("friend_request_unavailable")
}
diff --git a/rust/crates/space/src/client/friends.rs b/rust/crates/space/src/client/friends.rs
index 1641a3fcfb..787eb6e8db 100644
--- a/rust/crates/space/src/client/friends.rs
+++ b/rust/crates/space/src/client/friends.rs
@@ -14,6 +14,7 @@ fn map_friend_mutation_error(error: http::Error) -> Error {
http::Error::Api { code, .. } => match code.as_str() {
"SPACE_SELF_FRIENDSHIP" => Error::SelfFriendship,
"SPACE_FRIEND_REQUEST_LIMIT_REACHED" => Error::FriendRequestLimitReached,
+ "SPACE_SENT_FRIEND_REQUEST_LIMIT_REACHED" => Error::SentFriendRequestLimitReached,
"SPACE_FRIEND_REQUEST_UNAVAILABLE" => Error::FriendRequestUnavailable,
_ => error.into(),
},
diff --git a/rust/crates/space/src/error.rs b/rust/crates/space/src/error.rs
index 5552f7294c..1ffc53d2e9 100644
--- a/rust/crates/space/src/error.rs
+++ b/rust/crates/space/src/error.rs
@@ -48,6 +48,9 @@ pub enum Error {
#[error("space friend request limit reached")]
FriendRequestLimitReached,
+ #[error("space sent friend request limit reached")]
+ SentFriendRequestLimitReached,
+
#[error("friend request is no longer available")]
FriendRequestUnavailable,
diff --git a/web/apps/space/src/utils/friend-errors.ts b/web/apps/space/src/utils/friend-errors.ts
index 4d2c230763..1e06fdbf83 100644
--- a/web/apps/space/src/utils/friend-errors.ts
+++ b/web/apps/space/src/utils/friend-errors.ts
@@ -12,5 +12,8 @@ export const friendRequestErrorMessage = (error: unknown, username: string) => {
if (isNamedError(error, "friend_request_limit_reached")) {
return `@${username} can't receive more friend requests right now.`;
}
+ if (isNamedError(error, "sent_friend_request_limit_reached")) {
+ return "You have too many pending friend requests. Cancel a sent request or wait for someone to respond.";
+ }
return "Couldn't send the friend request. Please try again.";
};
diff --git a/web/apps/space/tests/friend-errors.test.ts b/web/apps/space/tests/friend-errors.test.ts
index 070695119b..a958e36dbe 100644
--- a/web/apps/space/tests/friend-errors.test.ts
+++ b/web/apps/space/tests/friend-errors.test.ts
@@ -96,6 +96,11 @@ test.each([
409,
"@friend can't receive more friend requests right now.",
],
+ [
+ "SPACE_SENT_FRIEND_REQUEST_LIMIT_REACHED",
+ 409,
+ "You have too many pending friend requests. Cancel a sent request or wait for someone to respond.",
+ ],
["CONFLICT", 409, "Couldn't send the friend request. Please try again."],
] as const)(
"%s reaches the add-friend message",