+ New route for /members/me/nickname
! No testing yet that comes in next patch, with any required fixes + db now has specific method for Member::update_nickk
This commit is contained in:
@@ -73,6 +73,7 @@ async fn route_dispatcher(
|
||||
/* MEMBERS */
|
||||
(GET, routes::GET_ONLINE_MEMBERS) => members::get_online_members(pool, resp).await,
|
||||
(GET, routes::GET_MYSELF) => members::get_self(pool, resp, params).await,
|
||||
(POST, routes::SELF_UPDATE_NICKNAME) => members::post_self_nickname(pool, resp, params).await,
|
||||
/* OWNER */
|
||||
(POST, routes::SET_NEW_ADMIN) => admin::new_admin(pool, resp, params).await,
|
||||
/* META ROUTE */
|
||||
|
||||
@@ -46,3 +46,29 @@ pub async fn get_self(p: &Pool, response: &mut Response<Body>, params: HashMap<S
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
pub async fn post_self_nickname(p: &Pool, response: &mut Response<Body>, params: HashMap<String, String>) {
|
||||
/*
|
||||
* @param nick <String>
|
||||
* @respond StatusCode
|
||||
*
|
||||
* Prety straightforward response here as its literally just the status code
|
||||
* Assuming we have good input
|
||||
*/
|
||||
|
||||
let nick = qs_param!(params, "nicK", String);
|
||||
|
||||
*response.status_mut() = if let Some(nick) = nick {
|
||||
|
||||
let uid = qs_param!(params, "id", u64).unwrap();
|
||||
match Member::update_nick(p, uid, nick.as_ref()).await {
|
||||
Ok(_) => StatusCode::OK,
|
||||
Err(e) => {
|
||||
eprintln!("{}", e);
|
||||
StatusCode::INTERNAL_SERVER_ERROR
|
||||
}
|
||||
}
|
||||
} else {
|
||||
StatusCode::BAD_REQUEST
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ pub const MESSAGE_FROM_ID: Rstr = "/message/from_id"; // requires @channel(id)
|
||||
|
||||
pub const GET_ONLINE_MEMBERS: Rstr = "/members/get_online"; // requires none
|
||||
pub const GET_MYSELF: Rstr = "/members/me"; // @requires none
|
||||
pub const SELF_UPDATE_NICKNAME: Rstr= "/members/me/nickname";
|
||||
|
||||
|
||||
// ADMIN ROUTES
|
||||
|
||||
Reference in New Issue
Block a user