feat: implement user ban check by node operator in app deployement

This commit is contained in:
Noor 2025-03-24 12:40:16 +00:00
parent beb56f5a9c
commit 9eeb9390fd
Signed by: noormohammedb
GPG Key ID: E424C39E19EFD7DF
2 changed files with 17 additions and 0 deletions

@ -1006,6 +1006,15 @@ impl BrainData {
} }
} }
} }
if let Some(node) = self.find_app_node_by_pubkey(&node_pubkey) {
if let Some(account) = self.accounts.get(user_wallet) {
if account.banned_by.contains(&node.operator_wallet) {
return true;
}
}
}
false false
} }

@ -507,6 +507,14 @@ impl BrainAppCli for BrainAppCliMock {
) -> Result<tonic::Response<NewAppRes>, Status> { ) -> Result<tonic::Response<NewAppRes>, Status> {
let req_data = check_sig_from_req(req)?; let req_data = check_sig_from_req(req)?;
log::info!("Creating new container: {req_data:?}"); log::info!("Creating new container: {req_data:?}");
if self
.data
.is_user_banned_by_node(&req_data.admin_pubkey, &req_data.node_pubkey)
{
return Err(Status::permission_denied(
"This operator banned you. What did you do?",
));
}
let admin_pubkey = req_data.admin_pubkey.clone(); let admin_pubkey = req_data.admin_pubkey.clone();
let (oneshot_tx, oneshot_rx) = tokio::sync::oneshot::channel(); let (oneshot_tx, oneshot_rx) = tokio::sync::oneshot::channel();
self.data.send_new_container_req(req_data, oneshot_tx).await; self.data.send_new_container_req(req_data, oneshot_tx).await;