Fix remote config for configs with unspecified on-off values

This commit is contained in:
ayumi-signal 2025-09-02 16:42:04 -07:00 committed by GitHub
commit c09dc17867
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 15 additions and 2 deletions

View file

@ -131,7 +131,7 @@ export const _refreshRemoteConfig = async (
const oldConfig = config;
config = Array.from(newConfigValues.entries()).reduce(
(acc, [name, value]) => {
const enabled = value !== undefined;
const enabled = value !== undefined && value !== 'false';
const previouslyEnabled: boolean = get(
oldConfig,
[name, 'enabled'],

View file

@ -139,6 +139,20 @@ describe('RemoteConfig', () => {
assert.equal(isEnabled('desktop.internalUser'), true);
});
it('is true for true string flag', async () => {
await updateRemoteConfig([
{ name: 'desktop.internalUser', value: 'true' },
]);
assert.equal(isEnabled('desktop.internalUser'), true);
});
it('is false for false string flag', async () => {
await updateRemoteConfig([
{ name: 'desktop.internalUser', value: 'false' },
]);
assert.equal(isEnabled('desktop.internalUser'), false);
});
it('reflects the value of an unknown flag in the config', async () => {
assert.equal(
isEnabled('desktop.unknownFlagName' as ConfigKeyType),

View file

@ -700,7 +700,6 @@ const CHAT_CALLS = {
batchIdentityCheck: 'v1/profile/identity_check/batch',
boostReceiptCredentials: 'v1/subscription/boost/receipt_credentials',
challenge: 'v1/challenge',
config: 'v1/config',
configV2: 'v2/config',
createBoost: 'v1/subscription/boost/create',
deliveryCert: 'v1/certificate/delivery',