diff --git a/keyserver/src/cron/cron.js b/keyserver/src/cron/cron.js index 6540ed0afc..2b83481e33 100644 --- a/keyserver/src/cron/cron.js +++ b/keyserver/src/cron/cron.js @@ -6,7 +6,6 @@ import schedule from 'node-schedule'; import { backupDB } from './backups.js'; import { createDailyUpdatesThread } from './daily-updates.js'; import { updateAndReloadGeoipDB } from './update-geoip-db.js'; -import { updateIdentityReservedUsernames } from './update-identity-reserved-usernames.js'; import { deleteOrphanedActivity } from '../deleters/activity-deleters.js'; import { deleteExpiredCookies } from '../deleters/cookie-deleters.js'; import { deleteOrphanedDays } from '../deleters/day-deleters.js'; @@ -93,20 +92,7 @@ if (cluster.isMaster) { } }, ); - schedule.scheduleJob( - '0 5 * * *', // every day at 5:00 AM in the keyserver's timezone - async () => { - try { - await updateIdentityReservedUsernames(); - } catch (e) { - console.warn( - 'encountered error while trying to update reserved usernames on ' + - 'identity service', - e, - ); - } - }, - ); + schedule.scheduleJob( '0 0 * * *', // every day at midnight in the keyserver's timezone async () => { diff --git a/keyserver/src/cron/update-identity-reserved-usernames.js b/keyserver/src/cron/update-identity-reserved-usernames.js deleted file mode 100644 index 00b59a7ae8..0000000000 --- a/keyserver/src/cron/update-identity-reserved-usernames.js +++ /dev/null @@ -1,31 +0,0 @@ -// @flow - -import { getRustAPI } from 'rust-node-addon'; - -import type { ReservedUsernameMessage } from 'lib/types/crypto-types.js'; - -import { fetchAllUsernames } from '../fetchers/user-fetchers.js'; -import { addReservedUsernamesStatement } from '../shared/message-statements.js'; -import { fetchOlmAccount } from '../updaters/olm-account-updater.js'; - -async function updateIdentityReservedUsernames(): Promise { - const [usernames, rustAPI, accountInfo] = await Promise.all([ - fetchAllUsernames(), - getRustAPI(), - fetchOlmAccount('content'), - ]); - const issuedAt = new Date().toISOString(); - const reservedUsernameMessage: ReservedUsernameMessage< - $ReadOnlyArray, - > = { - statement: addReservedUsernamesStatement, - payload: usernames, - issuedAt, - }; - const stringifiedMessage = JSON.stringify(reservedUsernameMessage); - const signature = accountInfo.account.sign(stringifiedMessage); - - await rustAPI.addReservedUsernames(stringifiedMessage, signature); -} - -export { updateIdentityReservedUsernames };