Admin and opertor features #3

Merged
noormohammedb merged 6 commits from general_and_admin into main 2025-05-25 21:40:46 +00:00
2 changed files with 4 additions and 4 deletions
Showing only changes of commit bdf98f3bbd - Show all commits

@ -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 {}))
}