|
|
@ -1,4 +1,5 @@ |
|
|
|
import { Activity } from '@ghostfolio/api/app/order/interfaces/activities.interface'; |
|
|
|
import { UserService } from '@ghostfolio/api/app/user/user.service'; |
|
|
|
import { |
|
|
|
CallHandler, |
|
|
|
ExecutionContext, |
|
|
@ -12,7 +13,7 @@ import { map } from 'rxjs/operators'; |
|
|
|
export class RedactValuesInResponseInterceptor<T> |
|
|
|
implements NestInterceptor<T, any> |
|
|
|
{ |
|
|
|
public constructor() {} |
|
|
|
public constructor(private userService: UserService) {} |
|
|
|
|
|
|
|
public intercept( |
|
|
|
context: ExecutionContext, |
|
|
@ -23,7 +24,10 @@ export class RedactValuesInResponseInterceptor<T> |
|
|
|
const request = context.switchToHttp().getRequest(); |
|
|
|
const hasImpersonationId = !!request.headers?.['impersonation-id']; |
|
|
|
|
|
|
|
if (hasImpersonationId) { |
|
|
|
if ( |
|
|
|
hasImpersonationId || |
|
|
|
this.userService.isRestrictedView(request.user) |
|
|
|
) { |
|
|
|
if (data.accounts) { |
|
|
|
for (const accountId of Object.keys(data.accounts)) { |
|
|
|
if (data.accounts[accountId]?.balance !== undefined) { |
|
|
@ -38,6 +42,34 @@ export class RedactValuesInResponseInterceptor<T> |
|
|
|
activity.Account.balance = null; |
|
|
|
} |
|
|
|
|
|
|
|
if (activity.comment !== undefined) { |
|
|
|
activity.comment = null; |
|
|
|
} |
|
|
|
|
|
|
|
if (activity.fee !== undefined) { |
|
|
|
activity.fee = null; |
|
|
|
} |
|
|
|
|
|
|
|
if (activity.feeInBaseCurrency !== undefined) { |
|
|
|
activity.feeInBaseCurrency = null; |
|
|
|
} |
|
|
|
|
|
|
|
if (activity.quantity !== undefined) { |
|
|
|
activity.quantity = null; |
|
|
|
} |
|
|
|
|
|
|
|
if (activity.unitPrice !== undefined) { |
|
|
|
activity.unitPrice = null; |
|
|
|
} |
|
|
|
|
|
|
|
if (activity.value !== undefined) { |
|
|
|
activity.value = null; |
|
|
|
} |
|
|
|
|
|
|
|
if (activity.valueInBaseCurrency !== undefined) { |
|
|
|
activity.valueInBaseCurrency = null; |
|
|
|
} |
|
|
|
|
|
|
|
return activity; |
|
|
|
}); |
|
|
|
} |
|
|
|