Fixed null consumption send to frontend
MODIFY
src/server/rest/service/security/AssetSecurity.ts
src/server/rest/service/security/AssetSecurity.ts
@@ -52,6 +52,7 @@ export default class AssetSecurity {
filteredRequest.assetType = sanitize(request.assetType),
filteredRequest.image = request.image;
filteredRequest.dynamicAsset = UtilsSecurity.filterBoolean(request.dynamicAsset);
+ filteredRequest.consumption = UtilsSecurity.filterAbstractConsumptionRequest(request.consumption);
if (request.coordinates && request.coordinates.length === 2) {
filteredRequest.coordinates = [
sanitize(request.coordinates[0]),

MODIFY
src/server/rest/service/security/UtilsSecurity.ts
src/server/rest/service/security/UtilsSecurity.ts
@@ -105,6 +105,27 @@ export default class UtilsSecurity {
}
}
+ static filterAbstractConsumptionRequest(consumption: AbstractConsumption): AbstractConsumption {
+ const filteredConsumption: AbstractConsumption = {} as AbstractConsumption;
+ if (consumption) {
+ filteredConsumption.consumptionWh = sanitize(consumption.consumptionWh);
+ filteredConsumption.instantAmpsL1 = sanitize(consumption.instantAmpsL1);
+ filteredConsumption.instantAmpsL2 = sanitize(consumption.instantAmpsL2);
+ filteredConsumption.instantAmpsL3 = sanitize(consumption.instantAmpsL3);
+ filteredConsumption.instantAmps = sanitize(consumption.instantAmps);
+ filteredConsumption.instantVoltsL1 = sanitize(consumption.instantVoltsL1);
+ filteredConsumption.instantVoltsL2 = sanitize(consumption.instantVoltsL2)
+ filteredConsumption.instantVoltsL3 = sanitize(consumption.instantVoltsL3);
+ filteredConsumption.instantVolts = sanitize(consumption.instantVolts);
+ filteredConsumption.instantWattsL1 = sanitize(consumption.instantWattsL1);
+ filteredConsumption.instantWattsL2 = sanitize(consumption.instantWattsL2);
+ filteredConsumption.instantWattsL3 = sanitize(consumption.instantWattsL3);
+ filteredConsumption.instantWatts = sanitize(consumption.instantWatts);
+ filteredConsumption.lastMetricWh = sanitize(consumption.lastMetricWh);
+ }
+ return filteredConsumption;
+ }
+
static filterAddressRequest(address: Address): Address {
const filteredAddress: Address = {} as Address;
if (address) {

Fixed null consumption send to frontend