Compare commits

..

2 Commits

2 changed files with 9 additions and 3 deletions

View File

@ -174,16 +174,20 @@ export class SocketUser {
data.objectType,
data.filter
);
if (typeof callback === 'function') {
callback({ success: true });
}
}
async handleSubscribeToObjectUpdateEvent(data, callback) {
const result = await this.updateManager.subscribeToObjectUpdate(
data._id,
data.objectType
);
if (typeof callback === 'function') {
callback(result);
}
}
async handleSubscribeToObjectEventEvent(data) {
await this.eventManager.subscribeToObjectEvent(

View File

@ -2,6 +2,7 @@ import log4js from 'log4js';
import _ from 'lodash';
import { loadConfig } from '../config.js';
import { natsServer } from '../database/nats.js';
import { expandObjectIds } from '../database/utils.js';
const config = loadConfig();
// Setup logger
@ -155,11 +156,12 @@ export class UpdateManager {
`${objectType}s.${id}.object`,
this.socketClient.socketId,
(key, value) => {
const expandedValue = expandObjectIds(value);
logger.trace('Object update event:', id);
this.socketClient.socket.emit('objectUpdate', {
_id: id,
objectType: objectType,
object: { ...value }
object: { ...expandedValue }
});
}
);