mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-11-26 13:34:55 +00:00
Switch device status storage to Firebase from MongoDB
This commit is contained in:
@ -9,7 +9,7 @@ import { OneSignalService } from './services/onesignal.service';
|
|||||||
import { DeviceMessagesService } from './services/device.messages.service';
|
import { DeviceMessagesService } from './services/device.messages.service';
|
||||||
import { DeviceNotificationRepositoryModule } from '../modules/device-notification/device.notification.module';
|
import { DeviceNotificationRepositoryModule } from '../modules/device-notification/device.notification.module';
|
||||||
import { DeviceNotificationRepository } from '../modules/device-notification/repositories';
|
import { DeviceNotificationRepository } from '../modules/device-notification/repositories';
|
||||||
import { DeviceStatusMongoModule } from '../mongoose/devices-status/devices-status.module';
|
import { DeviceStatusFirebaseModule } from '../firebase/devices-status/devices-status.module';
|
||||||
|
|
||||||
@Global()
|
@Global()
|
||||||
@Module({
|
@Module({
|
||||||
@ -27,7 +27,7 @@ import { DeviceStatusMongoModule } from '../mongoose/devices-status/devices-stat
|
|||||||
imports: [
|
imports: [
|
||||||
SpaceRepositoryModule,
|
SpaceRepositoryModule,
|
||||||
DeviceNotificationRepositoryModule,
|
DeviceNotificationRepositoryModule,
|
||||||
DeviceStatusMongoModule,
|
DeviceStatusFirebaseModule,
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
export class HelperModule {}
|
export class HelperModule {}
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
import TuyaWebsocket from '../../config/tuya-web-socket-config';
|
import TuyaWebsocket from '../../config/tuya-web-socket-config';
|
||||||
import { ConfigService } from '@nestjs/config';
|
import { ConfigService } from '@nestjs/config';
|
||||||
import { DeviceStatusMongoService } from '@app/common/mongoose/devices-status/services/devices-status.service';
|
import { DeviceStatusFirebaseService } from '@app/common/firebase/devices-status/services/devices-status.service';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class TuyaWebSocketService {
|
export class TuyaWebSocketService {
|
||||||
@ -9,7 +9,7 @@ export class TuyaWebSocketService {
|
|||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private readonly configService: ConfigService,
|
private readonly configService: ConfigService,
|
||||||
private readonly deviceStatusMongoService: DeviceStatusMongoService,
|
private readonly deviceStatusFirebaseService: DeviceStatusFirebaseService,
|
||||||
) {
|
) {
|
||||||
// Initialize the TuyaWebsocket client
|
// Initialize the TuyaWebsocket client
|
||||||
this.client = new TuyaWebsocket({
|
this.client = new TuyaWebsocket({
|
||||||
@ -37,7 +37,7 @@ export class TuyaWebSocketService {
|
|||||||
|
|
||||||
this.client.message(async (ws: WebSocket, message: any) => {
|
this.client.message(async (ws: WebSocket, message: any) => {
|
||||||
try {
|
try {
|
||||||
await this.deviceStatusMongoService.addDeviceStatusToMongo({
|
await this.deviceStatusFirebaseService.addDeviceStatusToFirebase({
|
||||||
deviceTuyaUuid: message.payload.data.bizData.devId,
|
deviceTuyaUuid: message.payload.data.bizData.devId,
|
||||||
status: message.payload.data.bizData.properties,
|
status: message.payload.data.bizData.properties,
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user