fixed room creation not giving membership

This commit is contained in:
2025-12-15 15:02:36 +01:00
parent 0365c7978c
commit 5ec961255d
3 changed files with 27 additions and 5 deletions

View File

@@ -23,3 +23,14 @@ pub async fn room_id_from_uuid(db: &PgPool, room_uuid: Uuid) -> Result<i32, (Sta
// FIX: hmm probably the wrong error here
.map_err(|_| (StatusCode::UNAUTHORIZED, String::from("Wrong token")))
}
pub async fn username_from_uuid(
db: &PgPool,
user_uuid: Uuid,
) -> Result<String, (StatusCode, String)> {
sqlx::query_scalar("SELECT username FROM user_ WHERE uuid = $1")
.bind(user_uuid)
.fetch_one(db)
.await
.map_err(|_| (StatusCode::UNAUTHORIZED, String::from("Wrong token")))
}