diff --git a/keyserver/src/cron/compare-users.js b/keyserver/src/cron/compare-users.js --- a/keyserver/src/cron/compare-users.js +++ b/keyserver/src/cron/compare-users.js @@ -2,7 +2,7 @@ import { getRustAPI } from 'rust-node-addon'; import { deleteCookies } from '../deleters/cookie-deleters.js'; -import { fetchNativeCookieIDsForUserIDs } from '../fetchers/cookie-fetchers.js'; +import { fetchCookieIDsToInvalidateToPopulateIdentityService } from '../fetchers/cookie-fetchers.js'; import { fetchAllUserIDs } from '../fetchers/user-fetchers.js'; async function compareMySQLUsersToIdentityService(): Promise { @@ -23,7 +23,7 @@ if (usersMissingFromIdentity.length === 0) { return; } - const cookieIDs = await fetchNativeCookieIDsForUserIDs( + const cookieIDs = await fetchCookieIDsToInvalidateToPopulateIdentityService( usersMissingFromIdentity, ); if (cookieIDs.length === 0) { diff --git a/keyserver/src/fetchers/cookie-fetchers.js b/keyserver/src/fetchers/cookie-fetchers.js --- a/keyserver/src/fetchers/cookie-fetchers.js +++ b/keyserver/src/fetchers/cookie-fetchers.js @@ -1,7 +1,5 @@ // @flow -import { deviceTypes } from 'lib/types/device-types.js'; - import { dbQuery, SQL } from '../database/database.js'; // This function is used for invalidating native sessions so that we can trigger @@ -10,16 +8,23 @@ // password on the keyserver to populate the identity service. We only // invalidate native sessions because web sessions don't cache the user's // password, and we don't want any user-visible issues to result from this. -async function fetchNativeCookieIDsForUserIDs( +async function fetchCookieIDsToInvalidateToPopulateIdentityService( userIDs: $ReadOnlyArray, ): Promise { + // Native clients before codeVersion 193 don't provide the info necessary to + // call the identity service, so there's no point to invalidating their + // sessions. On Android, builds 193/194 have a bug that breaks log-in, so we + // don't want to invalidate their sessions. const query = SQL` SELECT id FROM cookies - WHERE platform IN (${deviceTypes}) AND user IN (${userIDs}) + WHERE user IN (${userIDs}) AND ( + (platform = 'ios' AND JSON_EXTRACT(versions, '$.codeVersion') > 192) OR + (platform = 'android' AND JSON_EXTRACT(versions, '$.codeVersion') > 194) + ) `; const [result] = await dbQuery(query); return result.map(({ id }) => id.toString()); } -export { fetchNativeCookieIDsForUserIDs }; +export { fetchCookieIDsToInvalidateToPopulateIdentityService };