tons of cursor-shit cleaning, finished implementing cnxId in observer
This commit is contained in:
@@ -14,6 +14,7 @@ export async function dispatchActions(redisCnx, msg, chan, rules) {
|
||||
|
||||
const action = msg.action
|
||||
const sender = msg.sender ?? null
|
||||
const cnxId = msg.cnxId ?? null
|
||||
const reqid = ('reqid' in msg) ? msg.reqid.substr(0, 50) : null
|
||||
const roles = Array.isArray(msg.roles) ? msg.roles : ['*']
|
||||
|
||||
@@ -21,8 +22,9 @@ export async function dispatchActions(redisCnx, msg, chan, rules) {
|
||||
if(!sender) return(true)
|
||||
replyToAction(redisCnx, {
|
||||
action,
|
||||
reqid,
|
||||
sender,
|
||||
reqid,
|
||||
cnxId,
|
||||
success: false,
|
||||
err: 'Missing or invalid action',
|
||||
})
|
||||
@@ -39,6 +41,7 @@ export async function dispatchActions(redisCnx, msg, chan, rules) {
|
||||
action,
|
||||
reqid,
|
||||
sender,
|
||||
cnxId,
|
||||
success: false,
|
||||
err: 'Unauthorized action !',
|
||||
})
|
||||
@@ -51,6 +54,7 @@ export async function dispatchActions(redisCnx, msg, chan, rules) {
|
||||
action,
|
||||
reqid,
|
||||
sender,
|
||||
cnxId,
|
||||
success: false,
|
||||
err: `Unknown action: ${action}`,
|
||||
})
|
||||
@@ -62,13 +66,14 @@ export async function dispatchActions(redisCnx, msg, chan, rules) {
|
||||
}
|
||||
|
||||
try {
|
||||
await handler.call(redisCnx, action, ('payload' in msg) ? msg.payload : null, reqid, sender, roles)
|
||||
await handler.call(redisCnx, action, ('payload' in msg) ? msg.payload : null, reqid, sender, cnxId, roles)
|
||||
} catch(err) {
|
||||
console.error(`[${redisCnx.redisId}] Action ${action} failed:`, err)
|
||||
replyToAction(redisCnx, {
|
||||
action,
|
||||
reqid,
|
||||
sender,
|
||||
cnxId,
|
||||
success: false,
|
||||
err: err.message ?? `${action} failed`,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user