minor refactor
changed function names
This commit is contained in:
parent
56eebe5ada
commit
bdf98f3bbd
@ -180,7 +180,7 @@ pub struct Ban {
|
||||
}
|
||||
|
||||
impl Ban {
|
||||
pub async fn get_record_by_wallets(
|
||||
pub async fn get_record(
|
||||
db: &Surreal<Client>,
|
||||
op_wallet: &str,
|
||||
user_wallet: &str,
|
||||
@ -196,12 +196,12 @@ impl Ban {
|
||||
Ok(ban_record)
|
||||
}
|
||||
|
||||
pub async fn ban_a_user(
|
||||
pub async fn create(
|
||||
db: &Surreal<Client>,
|
||||
op_wallet: &str,
|
||||
user_wallet: &str,
|
||||
) -> Result<(), Error> {
|
||||
if Self::get_record_by_wallets(db, op_wallet, user_wallet).await?.is_some() {
|
||||
if Self::get_record(db, op_wallet, user_wallet).await?.is_some() {
|
||||
log::error!("User {user_wallet} is already banned by {op_wallet}");
|
||||
return Err(Error::AlreadyBanned(op_wallet.to_string()));
|
||||
}
|
||||
|
@ -155,7 +155,7 @@ impl BrainGeneralCli for GeneralCliServer {
|
||||
async fn ban_user(&self, req: Request<BanUserReq>) -> Result<Response<Empty>, Status> {
|
||||
let req = check_sig_from_req(req)?;
|
||||
log::info!("Banning user: {}, by: {}", req.user_wallet, req.operator_wallet);
|
||||
db::Ban::ban_a_user(&self.db, &req.operator_wallet, &req.user_wallet).await?;
|
||||
db::Ban::create(&self.db, &req.operator_wallet, &req.user_wallet).await?;
|
||||
Ok(Response::new(Empty {}))
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user