make set avatar, displayname, and blurhash async and forgot another let _

Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
strawberry 2024-01-14 01:42:37 -05:00 committed by June
parent 9ec1532580
commit 149d22eef7
5 changed files with 49 additions and 22 deletions

View file

@ -205,7 +205,8 @@ pub async fn register_route(body: Ruma<register::v3::Request>) -> Result<registe
services()
.users
.set_displayname(&user_id, Some(displayname.clone()))?;
.set_displayname(&user_id, Some(displayname.clone()))
.await?;
// Initial account data
services().account_data.update(

View file

@ -27,7 +27,8 @@ pub async fn set_displayname_route(
services()
.users
.set_displayname(sender_user, body.displayname.clone())?;
.set_displayname(sender_user, body.displayname.clone())
.await?;
// Send a new membership event and presence update into all joined rooms
let all_rooms_joined: Vec<_> = services()
@ -132,13 +133,16 @@ pub async fn get_displayname_route(
let _ = services().users.create(&body.user_id, None);
let _ = services()
.users
.set_displayname(&body.user_id, response.displayname.clone());
.set_displayname(&body.user_id, response.displayname.clone())
.await;
let _ = services()
.users
.set_avatar_url(&body.user_id, response.avatar_url);
.set_avatar_url(&body.user_id, response.avatar_url)
.await;
let _ = services()
.users
.set_blurhash(&body.user_id, response.blurhash);
.set_blurhash(&body.user_id, response.blurhash)
.await;
return Ok(get_display_name::v3::Response {
displayname: response.displayname,
@ -162,11 +166,13 @@ pub async fn set_avatar_url_route(
services()
.users
.set_avatar_url(sender_user, body.avatar_url.clone())?;
.set_avatar_url(sender_user, body.avatar_url.clone())
.await?;
services()
.users
.set_blurhash(sender_user, body.blurhash.clone())?;
.set_blurhash(sender_user, body.blurhash.clone())
.await?;
// Send a new membership event and presence update into all joined rooms
let all_joined_rooms: Vec<_> = services()
@ -271,13 +277,16 @@ pub async fn get_avatar_url_route(
let _ = services().users.create(&body.user_id, None);
let _ = services()
.users
.set_displayname(&body.user_id, response.displayname);
.set_displayname(&body.user_id, response.displayname)
.await;
let _ = services()
.users
.set_avatar_url(&body.user_id, response.avatar_url.clone());
.set_avatar_url(&body.user_id, response.avatar_url.clone())
.await;
let _ = services()
.users
.set_blurhash(&body.user_id, response.blurhash.clone());
.set_blurhash(&body.user_id, response.blurhash.clone())
.await;
return Ok(get_avatar_url::v3::Response {
avatar_url: response.avatar_url,
@ -320,13 +329,16 @@ pub async fn get_profile_route(
let _ = services().users.create(&body.user_id, None);
let _ = services()
.users
.set_displayname(&body.user_id, response.displayname.clone());
.set_displayname(&body.user_id, response.displayname.clone())
.await;
let _ = services()
.users
.set_avatar_url(&body.user_id, response.avatar_url.clone());
.set_avatar_url(&body.user_id, response.avatar_url.clone())
.await;
let _ = services()
.users
.set_blurhash(&body.user_id, response.blurhash.clone());
.set_blurhash(&body.user_id, response.blurhash.clone())
.await;
return Ok(get_profile::v3::Response {
displayname: response.displayname,

View file

@ -600,7 +600,8 @@ impl Service {
services()
.users
.set_displayname(&user_id, Some(displayname))?;
.set_displayname(&user_id, Some(displayname))
.await?;
// Initial account data
services().account_data.update(

View file

@ -58,13 +58,18 @@ impl Service {
},
)
.await?;
services()
let _ = services()
.users
.set_displayname(user_id, response.displayname.clone())?;
services()
.set_displayname(user_id, response.displayname.clone())
.await;
let _ = services()
.users
.set_avatar_url(user_id, response.avatar_url)?;
services().users.set_blurhash(user_id, response.blurhash)?;
.set_avatar_url(user_id, response.avatar_url)
.await;
let _ = services()
.users
.set_blurhash(user_id, response.blurhash)
.await;
};
}

View file

@ -314,7 +314,11 @@ impl Service {
}
/// Sets a new displayname or removes it if displayname is None. You still need to nofify all rooms of this change.
pub fn set_displayname(&self, user_id: &UserId, displayname: Option<String>) -> Result<()> {
pub async fn set_displayname(
&self,
user_id: &UserId,
displayname: Option<String>,
) -> Result<()> {
self.db.set_displayname(user_id, displayname)
}
@ -324,7 +328,11 @@ impl Service {
}
/// Sets a new avatar_url or removes it if avatar_url is None.
pub fn set_avatar_url(&self, user_id: &UserId, avatar_url: Option<OwnedMxcUri>) -> Result<()> {
pub async fn set_avatar_url(
&self,
user_id: &UserId,
avatar_url: Option<OwnedMxcUri>,
) -> Result<()> {
self.db.set_avatar_url(user_id, avatar_url)
}
@ -334,7 +342,7 @@ impl Service {
}
/// Sets a new avatar_url or removes it if avatar_url is None.
pub fn set_blurhash(&self, user_id: &UserId, blurhash: Option<String>) -> Result<()> {
pub async fn set_blurhash(&self, user_id: &UserId, blurhash: Option<String>) -> Result<()> {
self.db.set_blurhash(user_id, blurhash)
}