-* Removing ugle tuple indexing with some cleaner binds
- Removing warning of unused var + Adding 404 response to /badge/update/name when the badge_id isn't real
This commit is contained in:
parent
b289f5c811
commit
0e607eac1d
@ -37,12 +37,12 @@ async fn get(pool: &Pool, id: u64) -> SqlResult<Option<Badge>> {
|
|||||||
let q = "SELECT name, color, permissions FROM badges WHERE id = :id";
|
let q = "SELECT name, color, permissions FROM badges WHERE id = :id";
|
||||||
let row: Option<(String, u32, u64)> = conn.exec_first(q, params!{ "id" => id}).await?;
|
let row: Option<(String, u32, u64)> = conn.exec_first(q, params!{ "id" => id}).await?;
|
||||||
match row {
|
match row {
|
||||||
Some(row) => {
|
Some((name, color, perms)) => {
|
||||||
let b = Badge {
|
let b = Badge {
|
||||||
id,
|
id,
|
||||||
name: row.0,
|
name,
|
||||||
color: row.1,
|
color,
|
||||||
perms: row.2,
|
perms
|
||||||
};
|
};
|
||||||
Ok(Some(b))
|
Ok(Some(b))
|
||||||
},
|
},
|
||||||
|
@ -100,7 +100,9 @@ pub async fn update_name(p: &Pool, response: &mut Response<Body>, params: HashMa
|
|||||||
set_json_body(response, json!({"badge-update": payload}));
|
set_json_body(response, json!({"badge-update": payload}));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Ok(false) => {},
|
Ok(false) => {
|
||||||
|
*response.status_mut() = StatusCode::NOT_FOUND;
|
||||||
|
},
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
eprintln!("[HTTP][ERROR] /badges/update/name {}", e);
|
eprintln!("[HTTP][ERROR] /badges/update/name {}", e);
|
||||||
*response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
|
*response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
|
||||||
@ -115,9 +117,8 @@ pub async fn update_name(p: &Pool, response: &mut Response<Body>, params: HashMa
|
|||||||
pub async fn delete(p: &Pool, response: &mut Response<Body>, params: HashMap<String, String>) {
|
pub async fn delete(p: &Pool, response: &mut Response<Body>, params: HashMap<String, String>) {
|
||||||
if let Some(id) = qs_param!(params, "badge_id", u64) {
|
if let Some(id) = qs_param!(params, "badge_id", u64) {
|
||||||
match db::badges::delete(p, id).await {
|
match db::badges::delete(p, id).await {
|
||||||
Ok(id) => {
|
Ok(_id) => {
|
||||||
// TODO: add rtc notification here
|
// TODO: add rtc notification here
|
||||||
println!("TODO remove me at some point {}", id);
|
|
||||||
},
|
},
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
eprintln!("[HTTP][ERROR] /badge/delete {}", e);
|
eprintln!("[HTTP][ERROR] /badge/delete {}", e);
|
||||||
|
Loading…
Reference in New Issue
Block a user