More warning removals and more db-lib result wrapping
This should be everything now
This commit is contained in:
parent
4615374357
commit
afdeef0a49
@ -3,7 +3,7 @@ use mysql_async::prelude::Queryable;
|
||||
use mysql_async::Error as SqlError;
|
||||
|
||||
use crate::{Channel, UBigInt, Integer};
|
||||
use crate::{sql_err, Response};
|
||||
use crate::Response;
|
||||
|
||||
use rand::RngCore;
|
||||
|
||||
@ -75,11 +75,8 @@ impl Channel {
|
||||
let mut conn = p.get_conn().await?;
|
||||
|
||||
let q = "DELETE FROM channels WHERE id = :id";
|
||||
let result = conn.exec_drop(q, params!{"id" => id}).await;
|
||||
return match result {
|
||||
Ok(_) => Ok(Response::Success),
|
||||
Err(sql) => Ok(Response::Other(sql_err!(sql)))
|
||||
}
|
||||
conn.exec_drop(q, params!{"id" => id}).await?;
|
||||
Ok(Response::Success)
|
||||
}
|
||||
|
||||
|
||||
|
@ -86,6 +86,7 @@ pub async fn delete_channel(pool: &Pool, response: &mut Response<Body>, params:
|
||||
let uid = qs_param!(params, "id", u64).unwrap();
|
||||
let permissions = match Member::get(pool, uid).await {
|
||||
Ok(Row(user)) => user.permissions,
|
||||
Ok(_) => 0,
|
||||
Err(e) => {
|
||||
eprintln!("{}", e);
|
||||
0
|
||||
@ -112,6 +113,7 @@ pub async fn delete_channel(pool: &Pool, response: &mut Response<Body>, params:
|
||||
if let Some(id) = channel_id {
|
||||
match Channel::delete(pool, id).await {
|
||||
Ok(Success) => {/* nothing to do on sucess */},
|
||||
Ok(_) => {/* can't actually happen */}
|
||||
Err(e) => { // ngmi
|
||||
eprintln!("{}", e);
|
||||
*response.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
|
||||
|
@ -121,8 +121,14 @@ async fn allowed_perm_invite(pool: &Pool, uid: u64) -> bool {
|
||||
use crate::perms;
|
||||
|
||||
return match Member::get(pool, uid).await {
|
||||
db::Response::Row(user) => perms::has_perm(user.permissions, perms::CREATE_PERM_INVITES),
|
||||
_ => false
|
||||
Ok(response) => match response {
|
||||
db::Response::Row(user) => perms::has_perm(user.permissions, perms::CREATE_PERM_INVITES),
|
||||
_ => false
|
||||
},
|
||||
Err(e) => {
|
||||
eprintln!("[HTTP-DB-ERROR] {}", e);
|
||||
false
|
||||
}
|
||||
};
|
||||
}
|
||||
pub async fn create(pool: &Pool, response: &mut Response<Body>, params: HashMap<String, String>) {
|
||||
|
@ -190,7 +190,7 @@ async fn attempt_owner_creation(name: &str) {
|
||||
else {
|
||||
eprintln!("Could not generate a proper secret");
|
||||
}
|
||||
p.disconnect();
|
||||
let _ = p.disconnect().await;
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
|
Loading…
Reference in New Issue
Block a user