diff --git a/src/api/client/unstable.rs b/src/api/client/unstable.rs index 2c9add44..66cb31d5 100644 --- a/src/api/client/unstable.rs +++ b/src/api/client/unstable.rs @@ -506,6 +506,10 @@ pub(crate) async fn get_profile_key_route( return Err!(Request(NotFound("The requested profile key does not exist."))); } + if profile_key_value.is_empty() { + return Err!(Request(NotFound("The requested profile key does not exist."))); + } + return Ok(get_profile_key::unstable::Response { value: profile_key_value }); } } @@ -522,5 +526,9 @@ pub(crate) async fn get_profile_key_route( return Err!(Request(NotFound("The requested profile key does not exist."))); } + if profile_key_value.is_empty() { + return Err!(Request(NotFound("The requested profile key does not exist."))); + } + Ok(get_profile_key::unstable::Response { value: profile_key_value }) } diff --git a/src/service/users/mod.rs b/src/service/users/mod.rs index fe064d9c..3c43968a 100644 --- a/src/service/users/mod.rs +++ b/src/service/users/mod.rs @@ -947,12 +947,13 @@ impl Service { user_id: &UserId, profile_key: &str, ) -> Result { - let key = (user_id, profile_key); self.db .useridprofilekey_value - .qry(&key) + .qry(&(user_id, profile_key)) .await - .deserialized() + .deserialized::>() + .map(serde_json::to_value)? + .map_err(Into::into) } /// Gets all the user's profile keys and values in an iterator @@ -960,14 +961,16 @@ impl Service { &'a self, user_id: &'a UserId, ) -> impl Stream + 'a + Send { - type KeyVal = ((Ignore, String), serde_json::Value); + type KeyVal = ((Ignore, String), Raw); let prefix = (user_id, Interfix); self.db .useridprofilekey_value .stream_prefix(&prefix) .ignore_err() - .map(|((_, key), val): KeyVal| (key, val)) + .ready_filter_map(|((_, key), val): KeyVal| { + Some((key, serde_json::to_value(val).ok()?)) + }) } /// Sets a new profile key value, removes the key if value is None