mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2026-02-15 07:28:59 +00:00
Fallback to global media tier CDN number
Co-authored-by: trevor-signal <131492920+trevor-signal@users.noreply.github.com>
This commit is contained in:
@@ -41,6 +41,7 @@ export type ConfigKeyType =
|
||||
| 'desktop.releaseNotes.dev'
|
||||
| 'global.attachments.maxBytes'
|
||||
| 'global.attachments.maxReceiveBytes'
|
||||
| 'global.backups.mediaTierFallbackCdnNumber'
|
||||
| 'global.calling.maxGroupCallRingSize'
|
||||
| 'global.groupsv2.groupSizeHardLimit'
|
||||
| 'global.groupsv2.maxGroupSize'
|
||||
|
||||
@@ -17,6 +17,7 @@ import {
|
||||
AttachmentVariant,
|
||||
AttachmentPermanentlyUndownloadableError,
|
||||
} from '../../types/Attachment';
|
||||
import { updateRemoteConfig } from '../../test-both/helpers/RemoteConfigStub';
|
||||
|
||||
describe('utils/downloadAttachment', () => {
|
||||
const baseAttachment = {
|
||||
@@ -300,7 +301,8 @@ describe('utils/downloadAttachment', () => {
|
||||
describe('getCdnNumberForBackupTier', () => {
|
||||
let sandbox: sinon.SinonSandbox;
|
||||
|
||||
beforeEach(() => {
|
||||
beforeEach(async () => {
|
||||
await DataWriter.removeAll();
|
||||
sandbox = sinon.createSandbox();
|
||||
sandbox.stub(window.storage, 'get').callsFake(key => {
|
||||
if (key === 'masterKey') {
|
||||
@@ -311,11 +313,19 @@ describe('getCdnNumberForBackupTier', () => {
|
||||
}
|
||||
return undefined;
|
||||
});
|
||||
await updateRemoteConfig([
|
||||
{
|
||||
name: 'global.backups.mediaTierFallbackCdnNumber',
|
||||
enabled: true,
|
||||
value: '42',
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
await DataWriter.clearAllBackupCdnObjectMetadata();
|
||||
sandbox.restore();
|
||||
await updateRemoteConfig([]);
|
||||
});
|
||||
|
||||
const baseAttachment = {
|
||||
@@ -334,7 +344,7 @@ describe('getCdnNumberForBackupTier', () => {
|
||||
...baseAttachment,
|
||||
backupLocator: { mediaName: 'mediaName' },
|
||||
});
|
||||
assert.equal(result, 3);
|
||||
assert.equal(result, 42);
|
||||
});
|
||||
it('uses cdn number in DB if none on attachment', async () => {
|
||||
await DataWriter.saveBackupCdnObjectMetadata([
|
||||
|
||||
@@ -176,6 +176,7 @@ const DEFAULT_REMOTE_CONFIG = [
|
||||
['desktop.internalUser', { enabled: true }],
|
||||
['desktop.releaseNotes', { enabled: true }],
|
||||
['desktop.senderKey.retry', { enabled: true }],
|
||||
['global.backups.mediaTierFallbackCdnNumber', { enabled: true, value: '3' }],
|
||||
['global.groupsv2.groupSizeHardLimit', { enabled: true, value: '64' }],
|
||||
['global.groupsv2.maxGroupSize', { enabled: true, value: '32' }],
|
||||
] as const;
|
||||
|
||||
@@ -46,8 +46,8 @@ import { MAX_BACKUP_THUMBNAIL_SIZE } from '../types/VisualAttachment';
|
||||
import { missingCaseError } from '../util/missingCaseError';
|
||||
import { IV_LENGTH, MAC_LENGTH } from '../types/Crypto';
|
||||
import { BackupCredentialType } from '../types/backups';
|
||||
|
||||
const DEFAULT_BACKUP_CDN_NUMBER = 3;
|
||||
import { getValue } from '../RemoteConfig';
|
||||
import { parseIntOrThrow } from '../util/parseIntOrThrow';
|
||||
|
||||
export function getCdnKey(attachment: ProcessedAttachment): string {
|
||||
const cdnKey = attachment.cdnId || attachment.cdnKey;
|
||||
@@ -93,7 +93,10 @@ export async function getCdnNumberForBackupTier(
|
||||
if (backupCdnInfo.isInBackupTier) {
|
||||
backupCdnNumber = backupCdnInfo.cdnNumber;
|
||||
} else {
|
||||
backupCdnNumber = DEFAULT_BACKUP_CDN_NUMBER;
|
||||
backupCdnNumber = parseIntOrThrow(
|
||||
getValue('global.backups.mediaTierFallbackCdnNumber'),
|
||||
'global.backups.mediaTierFallbackCdnNumber must be set'
|
||||
);
|
||||
}
|
||||
}
|
||||
return backupCdnNumber;
|
||||
|
||||
Reference in New Issue
Block a user