...
 
Commits (4)
...@@ -195,7 +195,7 @@ export class AppManager { ...@@ -195,7 +195,7 @@ export class AppManager {
continue; continue;
} }
await this.initializeApp(items.get(rl.getID()), rl, true); await this.initializeApp(items.get(rl.getID()), rl, true).catch(console.error);
} }
// Let's ensure the required settings are all set // Let's ensure the required settings are all set
...@@ -205,7 +205,7 @@ export class AppManager { ...@@ -205,7 +205,7 @@ export class AppManager {
} }
if (!this.areRequiredSettingsSet(rl.getStorageItem())) { if (!this.areRequiredSettingsSet(rl.getStorageItem())) {
await rl.setStatus(AppStatus.INVALID_SETTINGS_DISABLED); await rl.setStatus(AppStatus.INVALID_SETTINGS_DISABLED).catch(console.error);
} }
} }
...@@ -213,7 +213,7 @@ export class AppManager { ...@@ -213,7 +213,7 @@ export class AppManager {
// but are not currently disabled. // but are not currently disabled.
for (const rl of this.apps.values()) { for (const rl of this.apps.values()) {
if (!AppStatusUtils.isDisabled(rl.getStatus()) && AppStatusUtils.isEnabled(rl.getPreviousStatus())) { if (!AppStatusUtils.isDisabled(rl.getStatus()) && AppStatusUtils.isEnabled(rl.getPreviousStatus())) {
await this.enableApp(items.get(rl.getID()), rl, true, rl.getPreviousStatus() === AppStatus.MANUALLY_ENABLED); await this.enableApp(items.get(rl.getID()), rl, true, rl.getPreviousStatus() === AppStatus.MANUALLY_ENABLED).catch(console.error);
} }
} }
...@@ -589,7 +589,7 @@ export class AppManager { ...@@ -589,7 +589,7 @@ export class AppManager {
const appStorageItem = app.getStorageItem(); const appStorageItem = app.getStorageItem();
const subscriptionInfo = appStorageItem.marketplaceInfo && appStorageItem.marketplaceInfo.subscriptionInfo; const subscriptionInfo = appStorageItem.marketplaceInfo && appStorageItem.marketplaceInfo.subscriptionInfo;
if (subscriptionInfo && subscriptionInfo.startDate === appInfo.subscriptionInfo.startDate) { if (subscriptionInfo && subscriptionInfo.license.license === appInfo.subscriptionInfo.license.license) {
return; return;
} }
...@@ -702,7 +702,11 @@ export class AppManager { ...@@ -702,7 +702,11 @@ export class AppManager {
// This is async, but we don't care since it only updates in the database // This is async, but we don't care since it only updates in the database
// and it should not mutate any properties we care about // and it should not mutate any properties we care about
storageItem.status = app.getStatus(); storageItem.status = app.getStatus();
this.storage.update(storageItem); this.storage.update(storageItem).catch(() => {
/**
* Avoiding some UNHANDLED_PROMISE_REJECTION
*/
});
} }
return result; return result;
......
...@@ -4,6 +4,7 @@ import { InvalidLicenseError } from '../errors'; ...@@ -4,6 +4,7 @@ import { InvalidLicenseError } from '../errors';
import { IMarketplaceInfo } from '../marketplace'; import { IMarketplaceInfo } from '../marketplace';
import { AppLicenseValidationResult } from '../marketplace/license'; import { AppLicenseValidationResult } from '../marketplace/license';
import { Crypto } from '../marketplace/license'; import { Crypto } from '../marketplace/license';
import { MarketplacePurchaseType } from '../marketplace/MarketplacePurchaseType';
enum LicenseVersion { enum LicenseVersion {
v1 = 1, v1 = 1,
...@@ -18,7 +19,7 @@ export class AppLicenseManager { ...@@ -18,7 +19,7 @@ export class AppLicenseManager {
} }
public async validate(validationResult: AppLicenseValidationResult, appMarketplaceInfo?: IMarketplaceInfo): Promise<void> { public async validate(validationResult: AppLicenseValidationResult, appMarketplaceInfo?: IMarketplaceInfo): Promise<void> {
if (!appMarketplaceInfo || !appMarketplaceInfo.subscriptionInfo) { if (!appMarketplaceInfo || appMarketplaceInfo.purchaseType !== MarketplacePurchaseType.PurchaseTypeSubscription) {
return; return;
} }
...@@ -43,7 +44,7 @@ export class AppLicenseManager { ...@@ -43,7 +44,7 @@ export class AppLicenseManager {
private async validateV1(appMarketplaceInfo: IMarketplaceInfo, license: any, validationResult: AppLicenseValidationResult): Promise<void> { private async validateV1(appMarketplaceInfo: IMarketplaceInfo, license: any, validationResult: AppLicenseValidationResult): Promise<void> {
if (license.isBundle && (!appMarketplaceInfo.bundledIn || !appMarketplaceInfo.bundledIn.find((value) => value.bundleId === license.appId))) { if (license.isBundle && (!appMarketplaceInfo.bundledIn || !appMarketplaceInfo.bundledIn.find((value) => value.bundleId === license.appId))) {
validationResult.addError('bundle', 'License issued for a bundle that does not contain the app'); validationResult.addError('bundle', 'License issued for a bundle that does not contain the app');
} else if (license.appId !== appMarketplaceInfo.id) { } else if (!license.isBundle && license.appId !== appMarketplaceInfo.id) {
validationResult.addError('appId', `License hasn't been issued for this app`); validationResult.addError('appId', `License hasn't been issued for this app`);
} }
......
...@@ -17,7 +17,7 @@ export interface IMarketplaceInfo extends IAppInfo { ...@@ -17,7 +17,7 @@ export interface IMarketplaceInfo extends IAppInfo {
modifiedDate: string; modifiedDate: string;
price: number; price: number;
subscriptionInfo?: IMarketplaceSubscriptionInfo; subscriptionInfo?: IMarketplaceSubscriptionInfo;
puchaseType: MarketplacePurchaseType; purchaseType: MarketplacePurchaseType;
pricingPlans?: Array<IMarketplacePricingPlan>; pricingPlans?: Array<IMarketplacePricingPlan>;
bundledIn?: Array<IMarketplaceSimpleBundleInfo>; bundledIn?: Array<IMarketplaceSimpleBundleInfo>;
} }