added roominvites in frontend in a notifications page and added clap to define backend port

This commit is contained in:
2025-12-31 12:14:46 +01:00
parent bd99c82d2d
commit 6bd1921806
5 changed files with 177 additions and 14 deletions

View File

@@ -20,8 +20,7 @@ pub async fn room_id_from_uuid(db: &PgPool, room_uuid: Uuid) -> Result<i32, (Sta
.bind(room_uuid)
.fetch_one(db)
.await
// FIX: hmm probably the wrong error here
.map_err(|_| (StatusCode::UNAUTHORIZED, String::from("Wrong token")))
.map_err(|_| (StatusCode::NOT_FOUND, "Failed to find room".into()))
}
pub async fn username_from_uuid(
@@ -50,3 +49,14 @@ pub async fn id_from_username(db: &PgPool, username: String) -> Result<i32, (Sta
.await
.map_err(|_| (StatusCode::NOT_FOUND, "User not found".into()))
}
pub async fn room_name_from_uuid(
db: &PgPool,
room_uuid: Uuid,
) -> Result<String, (StatusCode, String)> {
sqlx::query_scalar("SELECT name FROM room_ WHERE uuid = $1")
.bind(room_uuid)
.fetch_one(db)
.await
.map_err(|_| (StatusCode::NOT_FOUND, "Failed to find room".into()))
}