Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3396564
D9526.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
D9526.diff
View Options
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
Details
Attached
Mime Type
text/plain
Expires
Mon, Dec 2, 1:18 PM (20 h, 38 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2605392
Default Alt Text
D9526.diff (2 KB)
Attached To
Mode
D9526: [keyserver] add eth addresses to reserved usernames table
Attached
Detach File
Event Timeline
Log In to Comment