mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-07-10 15:17:41 +00:00
fix: remove unnecessary validation for missing properties in device status logs
This commit is contained in:
@ -95,13 +95,6 @@ export class DeviceStatusFirebaseService {
|
|||||||
for (const item of batch) {
|
for (const item of batch) {
|
||||||
const device = deviceMap.get(item.deviceTuyaUuid);
|
const device = deviceMap.get(item.deviceTuyaUuid);
|
||||||
if (!device?.uuid) continue;
|
if (!device?.uuid) continue;
|
||||||
if (!Array.isArray(item.log?.properties)) {
|
|
||||||
console.warn(
|
|
||||||
`🚨 Missing properties for device: ${item.deviceTuyaUuid}`,
|
|
||||||
);
|
|
||||||
console.log('🔍 Problematic item:', JSON.stringify(item, null, 2));
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
const logs = item.log.properties.map((property) =>
|
const logs = item.log.properties.map((property) =>
|
||||||
this.deviceStatusLogRepository.create({
|
this.deviceStatusLogRepository.create({
|
||||||
deviceId: device.uuid,
|
deviceId: device.uuid,
|
||||||
|
@ -51,6 +51,9 @@ export class TuyaWebSocketService {
|
|||||||
this.client.message(async (ws: WebSocket, message: any) => {
|
this.client.message(async (ws: WebSocket, message: any) => {
|
||||||
try {
|
try {
|
||||||
const { devId, status, logData } = this.extractMessageData(message);
|
const { devId, status, logData } = this.extractMessageData(message);
|
||||||
|
if (!Array.isArray(logData?.properties)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (this.sosHandlerService.isSosTriggered(status)) {
|
if (this.sosHandlerService.isSosTriggered(status)) {
|
||||||
await this.sosHandlerService.handleSosEventFirebase(devId, logData);
|
await this.sosHandlerService.handleSosEventFirebase(devId, logData);
|
||||||
} else {
|
} else {
|
||||||
@ -107,14 +110,6 @@ export class TuyaWebSocketService {
|
|||||||
console.log(`🔁 Processing batch of size: ${batch.length}`);
|
console.log(`🔁 Processing batch of size: ${batch.length}`);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
batch.forEach((item, index) => {
|
|
||||||
if (!Array.isArray(item?.logData?.properties)) {
|
|
||||||
console.warn(
|
|
||||||
`❌ Item #${index + 1} has invalid or missing 'properties':`,
|
|
||||||
);
|
|
||||||
console.log(JSON.stringify(item, null, 2));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
await this.deviceStatusFirebaseService.addBatchDeviceStatusToOurDb(
|
await this.deviceStatusFirebaseService.addBatchDeviceStatusToOurDb(
|
||||||
batch?.map((item) => ({
|
batch?.map((item) => ({
|
||||||
deviceTuyaUuid: item.devId,
|
deviceTuyaUuid: item.devId,
|
||||||
|
Reference in New Issue
Block a user