Page MenuHomePhabricator

D9526.id32289.diff
No OneTemporary

D9526.id32289.diff

diff --git a/keyserver/src/creators/account-creator.js b/keyserver/src/creators/account-creator.js
--- a/keyserver/src/creators/account-creator.js
+++ b/keyserver/src/creators/account-creator.js
@@ -189,23 +189,7 @@
...messageInfos,
];
- const issuedAt = new Date().toISOString();
- const payload: $ReadOnlyArray<string> = [request.username];
- const reservedUsernameMessage: ReservedUsernameMessage = {
- statement: 'Add the following usernames to reserved list',
- payload,
- issuedAt,
- };
- const stringifiedMessage = JSON.stringify(reservedUsernameMessage);
-
- handleAsyncPromise(
- (async () => {
- const rustAPI = await getRustAPI();
- const accountInfo = await fetchOlmAccount('content');
- const signature = accountInfo.account.sign(stringifiedMessage);
- await rustAPI.addReservedUsernames(stringifiedMessage, signature);
- })(),
- );
+ handleAsyncPromise(createAndSendReservedUsernameMessage([request.username]));
return {
id,
@@ -302,7 +286,30 @@
}));
const messageDatas = [...ashoatMessageDatas, ...privateMessageDatas];
await Promise.all([createMessages(viewer, messageDatas)]);
+
+ handleAsyncPromise(createAndSendReservedUsernameMessage([request.address]));
+
return id;
}
+async function createAndSendReservedUsernameMessage(
+ payload: $ReadOnlyArray<string>,
+) {
+ const issuedAt = new Date().toISOString();
+ const reservedUsernameMessage: ReservedUsernameMessage = {
+ statement: 'Add the following usernames to reserved list',
+ payload,
+ issuedAt,
+ };
+ const stringifiedMessage = JSON.stringify(reservedUsernameMessage);
+
+ const [rustAPI, accountInfo] = await Promise.all([
+ getRustAPI(),
+ fetchOlmAccount('content'),
+ ]);
+ const signature = accountInfo.account.sign(stringifiedMessage);
+
+ await rustAPI.addReservedUsernames(stringifiedMessage, signature);
+}
+
export { createAccount, processSIWEAccountCreation };
diff --git a/keyserver/src/cron/update-identity-reserved-usernames.js b/keyserver/src/cron/update-identity-reserved-usernames.js
--- a/keyserver/src/cron/update-identity-reserved-usernames.js
+++ b/keyserver/src/cron/update-identity-reserved-usernames.js
@@ -3,7 +3,6 @@
import { getRustAPI } from 'rust-node-addon';
import type { ReservedUsernameMessage } from 'lib/types/crypto-types.js';
-import { isValidEthereumAddress } from 'lib/utils/siwe-utils.js';
import { fetchAllUsernames } from '../fetchers/user-fetchers.js';
import { fetchOlmAccount } from '../updaters/olm-account-updater.js';
@@ -14,13 +13,10 @@
getRustAPI(),
fetchOlmAccount('content'),
]);
- const filteredUsernames = usernames.filter(
- username => !isValidEthereumAddress(username),
- );
const issuedAt = new Date().toISOString();
const reservedUsernameMessage: ReservedUsernameMessage = {
statement: 'Add the following usernames to reserved list',
- payload: filteredUsernames,
+ payload: usernames,
issuedAt,
};
const stringifiedMessage = JSON.stringify(reservedUsernameMessage);

File Metadata

Mime Type
text/plain
Expires
Sat, Nov 9, 3:41 PM (24 m, 22 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2453463
Default Alt Text
D9526.id32289.diff (2 KB)

Event Timeline