diff --git a/ts/RemoteConfig.ts b/ts/RemoteConfig.ts index f8b30c96665e..02d3bbe0154f 100644 --- a/ts/RemoteConfig.ts +++ b/ts/RemoteConfig.ts @@ -23,6 +23,7 @@ export type ConfigKeyType = | 'desktop.sendSenderKey2' | 'desktop.storage' | 'desktop.storageWrite3' + | 'global.calling.maxGroupCallRingSize' | 'global.groupsv2.groupSizeHardLimit' | 'global.groupsv2.maxGroupSize'; type ConfigValueType = { diff --git a/ts/groups/limits.ts b/ts/groups/limits.ts index 18e7d6e3f674..5cb6cc85bc6b 100644 --- a/ts/groups/limits.ts +++ b/ts/groups/limits.ts @@ -3,6 +3,7 @@ import { isNumber } from 'lodash'; import { parseIntOrThrow } from '../util/parseIntOrThrow'; +import { parseIntWithFallback } from '../util/parseIntWithFallback'; import { getValue, ConfigKeyType } from '../RemoteConfig'; function makeGetter(configKey: ConfigKeyType): (fallback?: number) => number { @@ -24,6 +25,10 @@ function makeGetter(configKey: ConfigKeyType): (fallback?: number) => number { export const getGroupSizeRecommendedLimit = makeGetter( 'global.groupsv2.maxGroupSize' ); + export const getGroupSizeHardLimit = makeGetter( 'global.groupsv2.groupSizeHardLimit' ); + +export const getMaxGroupCallRingSize = (): number => + parseIntWithFallback(getValue('global.calling.maxGroupCallRingSize'), 16); diff --git a/ts/test-both/groups/limits_test.ts b/ts/test-both/groups/limits_test.ts index 77a79e7049b0..b38c15eeee75 100644 --- a/ts/test-both/groups/limits_test.ts +++ b/ts/test-both/groups/limits_test.ts @@ -8,12 +8,14 @@ import * as remoteConfig from '../../RemoteConfig'; import { getGroupSizeRecommendedLimit, getGroupSizeHardLimit, + getMaxGroupCallRingSize, } from '../../groups/limits'; describe('group limit utilities', () => { let sinonSandbox: sinon.SinonSandbox; let getRecommendedLimitStub: sinon.SinonStub; let getHardLimitStub: sinon.SinonStub; + let getMaxGroupCallRingSizeStub: sinon.SinonStub; beforeEach(() => { sinonSandbox = sinon.createSandbox(); @@ -25,6 +27,9 @@ describe('group limit utilities', () => { getHardLimitStub = getValueStub.withArgs( 'global.groupsv2.groupSizeHardLimit' ); + getMaxGroupCallRingSizeStub = getValueStub.withArgs( + 'global.calling.maxGroupCallRingSize' + ); }); afterEach(() => { @@ -64,4 +69,21 @@ describe('group limit utilities', () => { assert.strictEqual(getGroupSizeHardLimit(), 123); }); }); + + describe('getMaxGroupCallRingSize', () => { + it('returns 16 if the value in remote config is not defined', () => { + getMaxGroupCallRingSizeStub.returns(undefined); + assert.strictEqual(getMaxGroupCallRingSize(), 16); + }); + + it('returns 16 if the value in remote config is not a parseable integer', () => { + getMaxGroupCallRingSizeStub.returns('uh oh'); + assert.strictEqual(getMaxGroupCallRingSize(), 16); + }); + + it('returns the value in remote config, parsed as an integer', () => { + getMaxGroupCallRingSizeStub.returns('123'); + assert.strictEqual(getMaxGroupCallRingSize(), 123); + }); + }); });