Skip to content

Commit

Permalink
[keyserver] Remove extraneous verifyClientSupported calls
Browse files Browse the repository at this point in the history
Summary:
In the past, we had calls to `validateInput` in each responder, which in turn calls `verifyClientSupported`. When the input did not need validation because there was no input, we would instead add direct calls to `verifyClientSupported`.

However, now `validateInput` is called implicitly before each responder. As such, `verifyClientSupported` is also called implicitly, and we don't need any explicit calls to it in responders.

Test Plan: Careful reading of the code. I think this change is relatively safe since I'm just removing a call that already occurs elsewhere

Reviewers: michal, marcin

Reviewed By: marcin

Subscribers: tomek, wyilio

Differential Revision: https://phab.comm.dev/D9581
  • Loading branch information
Ashoat committed Oct 26, 2023
1 parent 10bd397 commit a13ec69
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 13 deletions.
7 changes: 1 addition & 6 deletions keyserver/src/responders/keys-responders.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import { ServerError } from 'lib/utils/errors.js';
import { tShape, tNull } from 'lib/utils/validation-utils.js';

import { fetchSessionPublicKeys } from '../fetchers/key-fetchers.js';
import { verifyClientSupported } from '../session/version.js';
import type { Viewer } from '../session/viewer.js';
import { fetchCallUpdateOlmAccount } from '../updaters/olm-account-updater.js';

Expand Down Expand Up @@ -63,11 +62,7 @@ function retrieveSessionInitializationKeysSet(
return { identityKeys, oneTimeKey, prekey, prekeySignature };
}

async function getOlmSessionInitializationDataResponder(
viewer: Viewer,
): Promise<GetOlmSessionInitializationDataResponse> {
await verifyClientSupported(viewer);

async function getOlmSessionInitializationDataResponder(): Promise<GetOlmSessionInitializationDataResponse> {
const {
identityKeys: notificationsIdentityKeys,
prekey: notificationsPrekey,
Expand Down
7 changes: 0 additions & 7 deletions keyserver/src/responders/user-responders.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ import {
createNewUserCookie,
setNewSession,
} from '../session/cookies.js';
import { verifyClientSupported } from '../session/version.js';
import type { Viewer } from '../session/viewer.js';
import {
accountUpdater,
Expand Down Expand Up @@ -176,9 +175,6 @@ async function passwordUpdateResponder(
}

async function sendVerificationEmailResponder(viewer: Viewer): Promise<void> {
if (!viewer.isSocket) {
await verifyClientSupported(viewer, viewer.platformDetails);
}
await checkAndSendVerificationEmail(viewer);
}

Expand All @@ -200,9 +196,6 @@ export const logOutResponseValidator: TInterface<LogOutResponse> =
});

async function logOutResponder(viewer: Viewer): Promise<LogOutResponse> {
if (!viewer.isSocket) {
await verifyClientSupported(viewer, viewer.platformDetails);
}
if (viewer.loggedIn) {
const [anonymousViewerData] = await Promise.all([
createNewAnonymousCookie({
Expand Down

0 comments on commit a13ec69

Please sign in to comment.