Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3498454
D6790.id22885.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D6790.id22885.diff
View Options
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 rustAPI = await getRustAPI();
const knownUserInfos = await fetchKnownUserInfos(viewer);
const usersToUpdate = values(knownUserInfos).filter(
userID => userID !== deletedUserID,
@@ -96,6 +98,7 @@
});
}
const { anonymousViewerData } = await promiseAll(promises);
+ handleAsyncPromise(rustAPI.deleteUser(deletedUserID));
if (anonymousViewerData) {
viewer.setNewCookie(anonymousViewerData);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Dec 20, 9:12 PM (56 m, 54 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2683140
Default Alt Text
D6790.id22885.diff (2 KB)
Attached To
Mode
D6790: [Keyserver/rust-addon] Call identity deleteUser on account deletion
Attached
Detach File
Event Timeline
Log In to Comment