Skip to content

Commit

Permalink
[keyserver] Script to delete user
Browse files Browse the repository at this point in the history
Summary: This script will let us ban spambots like Emilia: [ENG-9502](https://linear.app/comm/issue/ENG-9502/ban-emilia).

Test Plan:
I ran this in my local environment, but my user ID isn't 256 on staging, so I got this error:

```
[Error: user_is_not_staff] { code: 'GenericFailure' }
```

Once identity 0.41 is deployed to prod, I can try testing this in production.

Reviewers: varun

Reviewed By: varun

Subscribers: tomek

Differential Revision: https://phab.comm.dev/D13691
  • Loading branch information
Ashoat committed Oct 10, 2024
1 parent 77102c8 commit 9013866
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
15 changes: 15 additions & 0 deletions keyserver/src/scripts/delete-account.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// @flow

import { main } from './utils.js';
import { deleteAccount } from '../deleters/account-deleters.js';
import { createScriptViewer } from '../session/scripts.js';
import { privilegedDeleteUsers } from '../utils/identity-utils.js';

async function deleteTargetAccount() {
const targetUserID = '';
await privilegedDeleteUsers([targetUserID]);
const viewer = createScriptViewer(targetUserID);
await deleteAccount(viewer);
}

main([deleteTargetAccount]);
18 changes: 17 additions & 1 deletion keyserver/src/utils/identity-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,20 @@ async function findUserIdentities(
);
}

export { findUserIdentities };
async function privilegedDeleteUsers(
userIDs: $ReadOnlyArray<string>,
): Promise<void> {
const [rustAPI, identityInfo, deviceID] = await Promise.all([
getRustAPI(),
verifyUserLoggedIn(),
getContentSigningKey(),
]);
await rustAPI.privilegedDeleteUsers(
identityInfo.userId,
deviceID,
identityInfo.accessToken,
userIDs,
);
}

export { findUserIdentities, privilegedDeleteUsers };

0 comments on commit 9013866

Please sign in to comment.