From 4124b08bb2232a60e38d059624da3f741701d2ac Mon Sep 17 00:00:00 2001 From: Radical Date: Tue, 20 May 2025 22:20:32 +0200 Subject: [PATCH 1/2] style: change function name --- src/api/v1/users/mod.rs | 2 +- src/structs.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/api/v1/users/mod.rs b/src/api/v1/users/mod.rs index f79bb5a..de9aec0 100644 --- a/src/api/v1/users/mod.rs +++ b/src/api/v1/users/mod.rs @@ -42,7 +42,7 @@ pub async fn res( return Ok(error); } - let accounts = User::fetch_all(&data.pool, start, amount).await; + let accounts = User::fetch_amount(&data.pool, start, amount).await; if let Err(error) = accounts { return Ok(error); diff --git a/src/structs.rs b/src/structs.rs index 26bd89d..a6e1587 100644 --- a/src/structs.rs +++ b/src/structs.rs @@ -837,7 +837,7 @@ impl User { Ok(user.build()) } - pub async fn fetch_all(pool: &Pool, start: i32, amount: i32) -> Result, HttpResponse> { + pub async fn fetch_amount(pool: &Pool, start: i32, amount: i32) -> Result, HttpResponse> { let row = sqlx::query_as("SELECT CAST(uuid AS VARCHAR), username, display_name, avatar, email FROM users ORDER BY username LIMIT $1 OFFSET $2") .bind(amount) .bind(start) From 85f6db499fd01d38c7b4374fec53ae13508f78c1 Mon Sep 17 00:00:00 2001 From: Radical Date: Tue, 20 May 2025 22:20:45 +0200 Subject: [PATCH 2/2] fix: use patch request for updating user --- src/api/v1/users/me.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/api/v1/users/me.rs b/src/api/v1/users/me.rs index 09cb400..bd6a12d 100644 --- a/src/api/v1/users/me.rs +++ b/src/api/v1/users/me.rs @@ -1,4 +1,4 @@ -use actix_web::{get, post, web, Error, HttpRequest, HttpResponse}; +use actix_web::{get, patch, web, Error, HttpRequest, HttpResponse}; use serde::Deserialize; use crate::{api::v1::auth::check_access_token, structs::Me, utils::get_auth_header, Data}; @@ -38,7 +38,7 @@ struct NewInfo { email: Option, } -#[post("/me")] +#[patch("/me")] pub async fn update(req: HttpRequest, new_info: web::Json, data: web::Data) -> Result { let headers = req.headers(); @@ -62,7 +62,7 @@ pub async fn update(req: HttpRequest, new_info: web::Json, data: web::D return Ok(error); } - let me = me_result; + let me = me_result.unwrap(); if let Some(username) = &new_info.username { todo!();