style: cargo clippy --fix && cargo fmt
This commit is contained in:
parent
ad24215fef
commit
8e31dc7aca
2 changed files with 14 additions and 12 deletions
|
@ -2,25 +2,27 @@ use std::sync::Arc;
|
||||||
|
|
||||||
use axum::{
|
use axum::{
|
||||||
Extension,
|
Extension,
|
||||||
extract::{Path, State, Json},
|
extract::{Json, Path, State},
|
||||||
http::StatusCode,
|
http::StatusCode,
|
||||||
response::IntoResponse,
|
response::IntoResponse,
|
||||||
};
|
};
|
||||||
use diesel::{insert_into, RunQueryDsl};
|
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
api::v1::auth::CurrentUser, error::Error, objects::{Me, Member, Permissions}, schema::guild_bans::{self, dsl}, utils::global_checks, AppState
|
AppState,
|
||||||
|
api::v1::auth::CurrentUser,
|
||||||
|
error::Error,
|
||||||
|
objects::{Member, Permissions},
|
||||||
|
utils::global_checks,
|
||||||
};
|
};
|
||||||
|
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
pub struct RequstBody {
|
pub struct RequstBody {
|
||||||
reason: String
|
reason: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pub async fn post(
|
pub async fn post(
|
||||||
State(app_state): State<Arc<AppState>>,
|
State(app_state): State<Arc<AppState>>,
|
||||||
Path(member_uuid): Path<Uuid>,
|
Path(member_uuid): Path<Uuid>,
|
||||||
|
@ -38,10 +40,11 @@ pub async fn post(
|
||||||
}
|
}
|
||||||
|
|
||||||
let baner = Member::check_membership(&mut conn, uuid, member.guild_uuid).await?;
|
let baner = Member::check_membership(&mut conn, uuid, member.guild_uuid).await?;
|
||||||
baner.check_permission(&app_state, Permissions::ManageMember).await?;
|
baner
|
||||||
|
.check_permission(&app_state, Permissions::ManageMember)
|
||||||
|
.await?;
|
||||||
|
|
||||||
member.ban(&mut conn, &payload.reason).await?;
|
member.ban(&mut conn, &payload.reason).await?;
|
||||||
|
|
||||||
|
|
||||||
Ok(StatusCode::OK)
|
Ok(StatusCode::OK)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
use axum::http::StatusCode;
|
|
||||||
use diesel::{
|
use diesel::{
|
||||||
ExpressionMethods, Insertable, QueryDsl, Queryable, Selectable, SelectableHelper, delete,
|
ExpressionMethods, Insertable, QueryDsl, Queryable, Selectable, SelectableHelper, delete,
|
||||||
insert_into,
|
insert_into,
|
||||||
|
@ -11,8 +10,8 @@ use crate::{
|
||||||
AppState, Conn,
|
AppState, Conn,
|
||||||
error::Error,
|
error::Error,
|
||||||
objects::{Me, Permissions, Role},
|
objects::{Me, Permissions, Role},
|
||||||
schema::guild_members,
|
|
||||||
schema::guild_bans,
|
schema::guild_bans,
|
||||||
|
schema::guild_members,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{User, load_or_empty};
|
use super::{User, load_or_empty};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue