diff --git a/apps/api/src/app/activities/activities.controller.ts b/apps/api/src/app/activities/activities.controller.ts index 36a9c76fa4..90851b2ca4 100644 --- a/apps/api/src/app/activities/activities.controller.ts +++ b/apps/api/src/app/activities/activities.controller.ts @@ -33,7 +33,7 @@ import { Query, UseInterceptors } from '@nestjs/common'; -import { Order, SymbolProfile } from '@prisma/client'; +import { Order, Prisma } from '@prisma/client'; import { parseISO } from 'date-fns'; import { StatusCodes, getReasonPhrase } from 'http-status-codes'; @@ -217,16 +217,7 @@ export class ActivitiesController { userId, userSubscription }: ImpersonationContext - ): Promise< - Order & { - assetProfile: SymbolProfile; - - /** - * @deprecated Use `assetProfile` instead - */ - SymbolProfile: SymbolProfile; - } - > { + ): Promise> { // Evaluate the more restrictive subscription of the authenticated user // and the owner of the activity const subscription = @@ -312,10 +303,7 @@ export class ActivitiesController { }); } - return { - ...activity, - assetProfile: activity.SymbolProfile - }; + return activity; } @HasPermission(permissions.updateActivity) diff --git a/apps/api/src/helper/object.helper.spec.ts b/apps/api/src/helper/object.helper.spec.ts index c8422ea05f..5543441dbc 100644 --- a/apps/api/src/helper/object.helper.spec.ts +++ b/apps/api/src/helper/object.helper.spec.ts @@ -3082,20 +3082,6 @@ describe('redactAttributes', () => { feeInBaseCurrency: 18.2, id: '8c623328-6035-4b5f-b6d5-702cc1c9c56b', quantity: 50, - // The relation of the database is part of the response next to the - // asset profile - SymbolProfile: { - comment: 'Reviewed by the administrator', - name: 'Apple Inc', - scraperConfiguration: { - headers: { Authorization: 'Bearer TOKEN' }, - mode: 'lazy', - selector: '.price', - url: 'https://example.org/get_price' - }, - symbol: 'AAPL', - symbolMapping: { YAHOO: 'AAPL' } - }, type: 'BUY', unitPrice: 220.79, value: 11039.5, @@ -3125,6 +3111,49 @@ describe('redactAttributes', () => { feeInBaseCurrency: null, id: '8c623328-6035-4b5f-b6d5-702cc1c9c56b', quantity: null, + type: 'BUY', + // A price per unit stays visible, like the average price and the market + // price of a holding + unitPrice: 220.79, + value: null, + valueInBaseCurrency: null + }); + }); + + // The endpoint POST api/v1/activities returns a row of the database with the + // relation to the symbol profile + it('should redact an activity with the relation to the symbol profile', () => { + expect( + redactPaths({ + object: { + comment: 'Bought on a dip', + currency: 'USD', + fee: 19.9, + id: '8c623328-6035-4b5f-b6d5-702cc1c9c56b', + quantity: 50, + SymbolProfile: { + comment: 'Reviewed by the administrator', + name: 'Apple Inc', + scraperConfiguration: { + headers: { Authorization: 'Bearer TOKEN' }, + mode: 'lazy', + selector: '.price', + url: 'https://example.org/get_price' + }, + symbol: 'AAPL', + symbolMapping: { YAHOO: 'AAPL' } + }, + type: 'BUY', + unitPrice: 220.79 + }, + paths: DEFAULT_REDACTED_PATHS + }) + ).toStrictEqual({ + comment: null, + currency: 'USD', + fee: null, + id: '8c623328-6035-4b5f-b6d5-702cc1c9c56b', + quantity: null, SymbolProfile: { comment: null, name: 'Apple Inc', @@ -3133,15 +3162,12 @@ describe('redactAttributes', () => { symbolMapping: null }, type: 'BUY', - // A price per unit stays visible, like the average price and the market - // price of a holding - unitPrice: 220.79, - value: null, - valueInBaseCurrency: null + unitPrice: 220.79 }); }); - // The write endpoints return a row of the database, which has no relation + // The endpoints PUT and DELETE api/v1/activities/:id return a row of the + // database without the relations it('should redact an activity without the relations', () => { expect( redactPaths({ diff --git a/libs/common/src/lib/config.ts b/libs/common/src/lib/config.ts index 73bf5cc00c..dbf873df2a 100644 --- a/libs/common/src/lib/config.ts +++ b/libs/common/src/lib/config.ts @@ -180,16 +180,9 @@ export const DEFAULT_REDACTED_PATHS = [ 'settings.emergencyFund', 'settings.projectedTotalAmount', 'settings.savingsRate', - - /* @deprecated */ 'SymbolProfile.comment', - - /* @deprecated */ 'SymbolProfile.scraperConfiguration', - - /* @deprecated */ 'SymbolProfile.symbolMapping', - 'totalBalanceInBaseCurrency', 'totalDividendInBaseCurrency', 'totalInterestInBaseCurrency',