import { publishActionReply } from '../../actionsHelper.js' export const construct = (redisCnx) => { // console.log('Hello after login from utilities...') // redisCnx.v42=0 // setInterval(redisCnx.move4243.bind(redisCnx), 200) } export const methods = { /* Event-Rx: { "action": "TIME" "reqid": "6az5e4r6a" } Event-Tx: { "action": "TIME", "success": true, "payload" : { gpsTime: "2022-09-01T14:42:22.603Z", redisTime: "2022-09-01T14:42:22.603Z" }, "reqid": "6az5e4r6a" } */ async action_TIME(action, payload, reqid, sender, roles){ publishActionReply(this, { action, reqid, sender, replyChannel: this.config.gps.gpsActionsReply, reply: { success: true, payload: { gpsTime: new Date().toISOString(), redisTime: await this.redisClient.time(), }, }, }) }, /* Event-Rx: { "action": "RELOADCONFIG" "reqid": "6az5e4r6a" } Event-Tx: { "action": "RELOADCONFIG", "success": true, "reqid": "6az5e4r6a" } */ async action_RELOADCONFIG(action, payload, reqid, sender, roles){ const replyOpts = { action, reqid, sender, replyChannel: this.config.gps.gpsActionsReply, } if(!this.accessRights.canDo(roles, action)) { publishActionReply(this, { ...replyOpts, reply: { success: false, err: 'Unauthorized action !', } }) return } this.reloadAccessRights() publishActionReply(this, { ...replyOpts, reply: { success: true, } }) }, /* Event-Rx: { "action": "GETCONFIG" "reqid": "6az5e4r6a" } Event-Tx: { "action": "GETCONFIG", "success": true, "reqid": "6az5e4r6a", payload: { ...the access rights, and roles... } } */ async action_GETCONFIG(action, payload, reqid, sender, roles){ const replyOpts = { action, reqid, sender, replyChannel: this.config.gps.gpsActionsReply, } if(!this.accessRights.canDo(roles, action)) { publishActionReply(this, { ...replyOpts, reply: { success: false, err: 'Unauthorized action !', } }) return } publishActionReply(this, { ...replyOpts, reply: { success: true, payload: this.getAccessRights(), } }) }, }