From 614c7bb2b265d1d615c2ec88c6794a5568e5ab91 Mon Sep 17 00:00:00 2001 From: bitfl0wer Date: Mon, 14 Aug 2023 00:02:03 +0200 Subject: [PATCH] Change UserMeta::get() to take self instead of Self --- src/api/users/users.rs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/api/users/users.rs b/src/api/users/users.rs index 5041bf5..43e4dfd 100644 --- a/src/api/users/users.rs +++ b/src/api/users/users.rs @@ -21,8 +21,8 @@ impl UserMeta { /// # Reference /// See and /// - pub async fn get(user: &mut UserMeta, id: Option<&String>) -> ChorusResult { - User::get(user, id).await + pub async fn get(&mut self, id: Option<&String>) -> ChorusResult { + User::get(self, id).await } /// Gets the user's settings. @@ -56,12 +56,7 @@ impl UserMeta { request, limit_type: LimitType::default(), }; - let user_updated = chorus_request - .deserialize_response::(self) - .await - .unwrap(); - self.object = Arc::new(RwLock::new(user_updated.clone())); - Ok(user_updated) + chorus_request.deserialize_response::(self).await } /// Deletes the user from the Instance. @@ -104,7 +99,11 @@ impl User { match chorus_request.send_request(user).await { Ok(result) => { let result_text = result.text().await.unwrap(); - Ok(serde_json::from_str::(&result_text).unwrap()) + let api_user = serde_json::from_str::(&result_text).unwrap(); + user.gateway + .observe(Arc::new(RwLock::new(api_user.clone()))) + .await; + Ok(api_user) } Err(e) => Err(e), }