From 9eeb9390fd247a335b937a1af5893febe76ac11c Mon Sep 17 00:00:00 2001 From: Noor Date: Mon, 24 Mar 2025 12:40:16 +0000 Subject: [PATCH] feat: implement user ban check by node operator in app deployement --- src/data.rs | 9 +++++++++ src/grpc.rs | 8 ++++++++ 2 files changed, 17 insertions(+) diff --git a/src/data.rs b/src/data.rs index 4559116..dbe6bc4 100644 --- a/src/data.rs +++ b/src/data.rs @@ -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 } diff --git a/src/grpc.rs b/src/grpc.rs index 7584dcb..9eebffa 100644 --- a/src/grpc.rs +++ b/src/grpc.rs @@ -507,6 +507,14 @@ impl BrainAppCli for BrainAppCliMock { ) -> Result, Status> { let req_data = check_sig_from_req(req)?; 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 (oneshot_tx, oneshot_rx) = tokio::sync::oneshot::channel(); self.data.send_new_container_req(req_data, oneshot_tx).await;