Page MenuHomePhabricator

D6790.diff
No OneTemporary

D6790.diff

diff --git a/keyserver/addons/rust-node-addon/index.js b/keyserver/addons/rust-node-addon/index.js
--- a/keyserver/addons/rust-node-addon/index.js
+++ b/keyserver/addons/rust-node-addon/index.js
@@ -17,6 +17,7 @@
password: string,
userPublicKey: string,
) => Promise<string>,
+ +deleteUser: (userId: string) => Promise<boolean>,
};
async function getRustAPI(): Promise<RustAPI> {
@@ -41,8 +42,8 @@
throw new Error('Failed to load native binding');
}
- const { registerUser } = nativeBinding;
- return { registerUser };
+ const { registerUser, deleteUser } = nativeBinding;
+ return { registerUser, deleteUser };
}
export { getRustAPI };
diff --git a/keyserver/addons/rust-node-addon/src/delete_user.rs b/keyserver/addons/rust-node-addon/src/delete_user.rs
new file mode 100644
--- /dev/null
+++ b/keyserver/addons/rust-node-addon/src/delete_user.rs
@@ -0,0 +1,30 @@
+use crate::identity::identity_service_client::IdentityServiceClient;
+use crate::identity::DeleteUserRequest;
+use crate::IDENTITY_SERVICE_SOCKET_ADDR;
+use napi::bindgen_prelude::{Error, Result, Status};
+use tonic::Request;
+use tracing::instrument;
+
+#[napi]
+#[instrument(skip_all)]
+pub async fn delete_user(user_id: String) -> Result<()> {
+ let mut identity_client =
+ IdentityServiceClient::connect(IDENTITY_SERVICE_SOCKET_ADDR.as_str())
+ .await
+ .map_err(|_| {
+ Error::new(
+ Status::GenericFailure,
+ "Unable to connect to identity service".to_string(),
+ )
+ })?;
+
+ let request = Request::new(DeleteUserRequest {
+ user_id: user_id.clone(),
+ });
+ identity_client
+ .delete_user(request)
+ .await
+ .map_err(|e| Error::new(Status::GenericFailure, e.to_string()))?;
+
+ Ok(())
+}
diff --git a/keyserver/addons/rust-node-addon/src/lib.rs b/keyserver/addons/rust-node-addon/src/lib.rs
--- a/keyserver/addons/rust-node-addon/src/lib.rs
+++ b/keyserver/addons/rust-node-addon/src/lib.rs
@@ -1,3 +1,4 @@
+pub mod delete_user;
pub mod identity_client;
pub mod identity {
tonic::include_proto!("identity");
diff --git a/keyserver/src/deleters/account-deleters.js b/keyserver/src/deleters/account-deleters.js
--- a/keyserver/src/deleters/account-deleters.js
+++ b/keyserver/src/deleters/account-deleters.js
@@ -1,5 +1,6 @@
// @flow
+import { getRustAPI } from 'rust-node-addon';
import bcrypt from 'twin-bcrypt';
import type {
@@ -48,6 +49,7 @@
const deletedUserID = viewer.userID;
await rescindPushNotifs(SQL`n.user = ${deletedUserID}`, SQL`NULL`);
+ const rustAPIPromise = getRustAPI();
const knownUserInfos = await fetchKnownUserInfos(viewer);
const usersToUpdate = values(knownUserInfos).filter(
userID => userID !== deletedUserID,
@@ -95,7 +97,9 @@
deviceToken: viewer.deviceToken,
});
}
- const { anonymousViewerData } = await promiseAll(promises);
+ promises.rustAPI = rustAPIPromise;
+ const { anonymousViewerData, rustAPI } = await promiseAll(promises);
+ handleAsyncPromise(rustAPI.deleteUser(deletedUserID));
if (anonymousViewerData) {
viewer.setNewCookie(anonymousViewerData);
}

File Metadata

Mime Type
text/plain
Expires
Fri, Dec 20, 4:06 PM (18 h, 44 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2678646
Default Alt Text
D6790.diff (3 KB)

Event Timeline