diff --git a/keyserver/src/updaters/thread-updaters.js b/keyserver/src/updaters/thread-updaters.js --- a/keyserver/src/updaters/thread-updaters.js +++ b/keyserver/src/updaters/thread-updaters.js @@ -1,7 +1,5 @@ // @flow -import { getRustAPI } from 'rust-node-addon'; - import { specialRoles } from 'lib/permissions/special-roles.js'; import { getRolePermissionBlobs } from 'lib/permissions/thread-permissions.js'; import { filteredThreadIDs } from 'lib/selectors/calendar-filter-selectors.js'; @@ -69,9 +67,8 @@ verifyUserOrCookieIDs, } from '../fetchers/user-fetchers.js'; import type { Viewer } from '../session/viewer.js'; -import { verifyUserLoggedIn } from '../user/login.js'; import { neynarClient } from '../utils/fc-cache.js'; -import { getContentSigningKey } from '../utils/olm-utils.js'; +import { findUserIdentities } from '../utils/identity-utils.js'; import RelationshipChangeset from '../utils/relationship-changeset.js'; type UpdateRoleOptions = { @@ -937,18 +934,7 @@ threadID: string, communityFarcasterChannelTag: string, ): Promise { - const [rustAPI, identityInfo, deviceID] = await Promise.all([ - getRustAPI(), - verifyUserLoggedIn(), - getContentSigningKey(), - ]); - - const response = await rustAPI.findUserIdentities( - identityInfo.userId, - deviceID, - identityInfo.accessToken, - [viewer.userID], - ); + const response = await findUserIdentities([viewer.userID]); const { farcasterID } = response.identities[viewer.userID]; diff --git a/keyserver/src/utils/identity-utils.js b/keyserver/src/utils/identity-utils.js new file mode 100644 --- /dev/null +++ b/keyserver/src/utils/identity-utils.js @@ -0,0 +1,26 @@ +// @flow + +import { getRustAPI } from 'rust-node-addon'; + +import type { UserIdentitiesResponse } from 'lib/types/identity-service-types.js'; + +import { getContentSigningKey } from './olm-utils.js'; +import { verifyUserLoggedIn } from '../user/login.js'; + +async function findUserIdentities( + userIDs: $ReadOnlyArray, +): Promise { + const [rustAPI, identityInfo, deviceID] = await Promise.all([ + getRustAPI(), + verifyUserLoggedIn(), + getContentSigningKey(), + ]); + return await rustAPI.findUserIdentities( + identityInfo.userId, + deviceID, + identityInfo.accessToken, + userIDs, + ); +} + +export { findUserIdentities };