Browse Source

Improve validation of activities and asset profiles when combining custom asset profile symbol with data source other than MANUAL

pull/7721/head
Thomas Kaul 5 days ago
parent
commit
96767f915f
  1. 15
      apps/api/src/app/import/import.service.ts
  2. 10
      apps/api/src/services/data-provider/data-provider.service.ts

15
apps/api/src/app/import/import.service.ts

@ -212,12 +212,21 @@ export class ImportService {
for (const [index, assetProfileWithMarketData] of ( for (const [index, assetProfileWithMarketData] of (
assetProfilesWithMarketDataDto ?? [] assetProfilesWithMarketDataDto ?? []
).entries()) { ).entries()) {
const { dataSource, symbol } = assetProfileWithMarketData;
if ( if (
assetProfileWithMarketData.dataSource === DataSource.MANUAL && dataSource === DataSource.MANUAL &&
!isValidCustomAssetProfileSymbol(assetProfileWithMarketData.symbol) !isValidCustomAssetProfileSymbol(symbol)
) {
throw new Error(
`assetProfiles.${index}.symbol ("${symbol}") must be a UUID or start with the prefix "${ghostfolioPrefix}_" for the data source ("${DataSource.MANUAL}")`
);
} else if (
dataSource !== DataSource.MANUAL &&
isValidCustomAssetProfileSymbol(symbol)
) { ) {
throw new Error( throw new Error(
`assetProfiles.${index}.symbol ("${assetProfileWithMarketData.symbol}") must be a UUID or start with the prefix "${ghostfolioPrefix}_" for the data source ("${DataSource.MANUAL}")` `assetProfiles.${index}.symbol ("${symbol}") is not valid for the data source ("${dataSource}")`
); );
} }
} }

10
apps/api/src/services/data-provider/data-provider.service.ts

@ -23,6 +23,7 @@ import {
getStartOfUtcDate, getStartOfUtcDate,
isCurrency, isCurrency,
isDerivedCurrency, isDerivedCurrency,
isValidCustomAssetProfileSymbol,
isValidSearchQuery isValidSearchQuery
} from '@ghostfolio/common/helper'; } from '@ghostfolio/common/helper';
import { import {
@ -254,6 +255,15 @@ export class DataProviderService implements OnModuleInit {
); );
} }
if (
dataSource !== DataSource.MANUAL &&
isValidCustomAssetProfileSymbol(symbol)
) {
throw new Error(
`${activityPath}.symbol ("${symbol}") is not valid for the specified data source ("${maskedDataSource}")`
);
}
if ( if (
this.configurationService.get('ENABLE_FEATURE_SUBSCRIPTION') && this.configurationService.get('ENABLE_FEATURE_SUBSCRIPTION') &&
subscription?.type === SubscriptionType.Basic subscription?.type === SubscriptionType.Basic

Loading…
Cancel
Save