fix: update check for desktop app
This commit is contained in:
@@ -39,6 +39,7 @@ export const registerOpenChamberRoutes = (app, dependencies) => {
|
||||
arch: parseString(req.query.arch),
|
||||
instanceMode: parseString(req.query.instanceMode),
|
||||
currentVersion: parseString(req.query.currentVersion),
|
||||
installId: parseString(req.query.installId),
|
||||
reportUsage: parseReportUsage(parseString(req.query.reportUsage)),
|
||||
});
|
||||
res.json(updateInfo);
|
||||
|
||||
@@ -125,9 +125,10 @@ async function checkForUpdatesFromApi(currentVersion, options = {}) {
|
||||
const appType = normalizeAppType(options.appType);
|
||||
const hostPlatform = mapPlatform(process.platform);
|
||||
const hostArch = mapArch(process.arch);
|
||||
const shouldTrustClientPlatform = appType === 'vscode' || appType === 'mobile-capacitor';
|
||||
const shouldTrustClientPlatform = appType === 'desktop-electron' || appType === 'vscode' || appType === 'mobile-capacitor';
|
||||
const platform = shouldTrustClientPlatform ? normalizePlatform(options.platform) : hostPlatform;
|
||||
const arch = shouldTrustClientPlatform ? normalizeArch(options.arch) : hostArch;
|
||||
const reportUsage = options.reportUsage !== false;
|
||||
const payload = {
|
||||
appType,
|
||||
deviceClass: normalizeDeviceClass(options.deviceClass),
|
||||
@@ -135,9 +136,9 @@ async function checkForUpdatesFromApi(currentVersion, options = {}) {
|
||||
arch,
|
||||
channel: 'stable',
|
||||
currentVersion,
|
||||
installId: getOrCreateInstallId(appType),
|
||||
installId: reportUsage ? (options.installId || getOrCreateInstallId(appType)) : undefined,
|
||||
instanceMode: options.instanceMode || 'unknown',
|
||||
reportUsage: options.reportUsage !== false,
|
||||
reportUsage,
|
||||
};
|
||||
|
||||
const response = await fetch(UPDATE_CHECK_URL, {
|
||||
|
||||
@@ -134,11 +134,19 @@ describe('checkForUpdates', () => {
|
||||
const result = await checkForUpdates({
|
||||
appType: 'desktop-electron',
|
||||
currentVersion: '1.9.10',
|
||||
installId: '4f4dfead-9688-4c4f-97d7-4607fbbfc3ab',
|
||||
platform: 'windows',
|
||||
arch: 'arm64',
|
||||
});
|
||||
|
||||
expect(result.available).toBe(true);
|
||||
expect(result.version).toBe('1.10.0');
|
||||
expect(fetchMock).toHaveBeenCalledTimes(1);
|
||||
expect(JSON.parse(fetchMock.mock.calls[0][1].body)).toMatchObject({
|
||||
installId: '4f4dfead-9688-4c4f-97d7-4607fbbfc3ab',
|
||||
platform: 'windows',
|
||||
arch: 'arm64',
|
||||
});
|
||||
});
|
||||
|
||||
it('resolves an Android APK asset when the update API returns an AAB', async () => {
|
||||
|
||||
Reference in New Issue
Block a user