Page MenuHomePhabricator

D12526.id41583.diff
No OneTemporary

D12526.id41583.diff

diff --git a/services/identity/src/database/device_list.rs b/services/identity/src/database/device_list.rs
--- a/services/identity/src/database/device_list.rs
+++ b/services/identity/src/database/device_list.rs
@@ -17,6 +17,7 @@
use serde::Serialize;
use tracing::{debug, error, trace, warn};
+use crate::error::consume_error;
use crate::{
client_service::FlattenedDeviceKeyUpload,
constants::{
@@ -1353,6 +1354,16 @@
self
.delete_otks_table_rows_for_user_device(user_id, &device_id)
.await?;
+
+ let device_id = device_id.to_string();
+ tokio::spawn(async move {
+ debug!(
+ "Attempting to delete Tunnelbroker data for device: {}",
+ &device_id
+ );
+ let result = crate::tunnelbroker::delete_device_data(&device_id).await;
+ consume_error(result);
+ });
}
Ok(update_result)
diff --git a/services/identity/src/grpc_services/authenticated.rs b/services/identity/src/grpc_services/authenticated.rs
--- a/services/identity/src/grpc_services/authenticated.rs
+++ b/services/identity/src/grpc_services/authenticated.rs
@@ -93,6 +93,18 @@
Ok((user_id, device_id))
}
+fn spawn_delete_tunnelbroker_data_task(device_id: &str) {
+ let device_id = device_id.to_string();
+ tokio::spawn(async move {
+ debug!(
+ "Attempting to delete Tunnelbroker data for device: {}",
+ &device_id
+ );
+ let result = crate::tunnelbroker::delete_device_data(&device_id).await;
+ consume_error(result);
+ });
+}
+
#[tonic::async_trait]
impl IdentityClientService for AuthenticatedService {
#[tracing::instrument(skip_all)]
@@ -373,7 +385,7 @@
self
.db_client
- .delete_access_token_data(&user_id, device_id)
+ .delete_access_token_data(&user_id, &device_id)
.await
.map_err(handle_db_error)?;
@@ -411,6 +423,8 @@
consume_error(result);
});
+ spawn_delete_tunnelbroker_data_task(&device_id);
+
let response = Empty {};
Ok(Response::new(response))
}
@@ -446,6 +460,8 @@
.await
.map_err(handle_db_error)?;
+ spawn_delete_tunnelbroker_data_task(&device_id);
+
let response = Empty {};
Ok(Response::new(response))
}
diff --git a/services/identity/src/tunnelbroker.rs b/services/identity/src/tunnelbroker.rs
--- a/services/identity/src/tunnelbroker.rs
+++ b/services/identity/src/tunnelbroker.rs
@@ -2,7 +2,7 @@
use grpc_clients::tunnelbroker::create_tunnelbroker_client as shared_tb_client;
use grpc_clients::tunnelbroker::protos;
use protos::tunnelbroker_service_client::TunnelbrokerServiceClient;
-use protos::{Empty, MessageToDevice};
+use protos::{DeleteDeviceDataRequest, Empty, MessageToDevice};
use tonic::transport::Channel;
use tonic::Response;
use tonic::Status;
@@ -72,3 +72,15 @@
Ok(())
}
+
+pub async fn delete_device_data(
+ device_id: &str,
+) -> Result<Response<Empty>, Error> {
+ let mut tunnelbroker_client = create_tunnelbroker_client().await?;
+
+ let request = DeleteDeviceDataRequest {
+ device_id: device_id.to_string(),
+ };
+ let grpc_message = tonic::Request::new(request);
+ Ok(tunnelbroker_client.delete_device_data(grpc_message).await?)
+}

File Metadata

Mime Type
text/plain
Expires
Sun, Nov 17, 5:45 AM (21 h, 1 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2515294
Default Alt Text
D12526.id41583.diff (3 KB)

Event Timeline