From c8914da1423ddf0fc27d2707e0fdd637fe69e6eb Mon Sep 17 00:00:00 2001 From: zetxx Date: Mon, 3 Feb 2020 21:31:41 +0200 Subject: [PATCH] fix: corect meta merge --- lib/base.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/base.js b/lib/base.js index 5475e13..f4d88c6 100644 --- a/lib/base.js +++ b/lib/base.js @@ -47,13 +47,17 @@ class Brid { return this.findMethod({method, direction: false, channel: 'external', meta}); } - registerMethod({method, channel, fn, meta}) { - this.log('info', {in: 'base.registerMethod', description: `register method: ${channel}.${method}`, method, channel, meta}); + callRegisteredMethod(fn, ctx, ...args) { + return fn.call(ctx, ...args); + } + + registerMethod({method, channel, fn, meta: metaOld}) { + this.log('info', {in: 'base.registerMethod', description: `register method: ${channel}.${method}`, method, channel, meta: metaOld}); !this.apiMethods[channel] && (this.apiMethods[channel] = {}); this.apiMethods[channel][method] = async(ctx, ...args) => { let [message, meta] = args; this.log('trace', {in: 'base.registerMethod', description: `exec method: ${channel}.${method}`, message, meta}); - return fn.call(ctx, ...args); + return this.callRegisteredMethod(fn, ctx, message, {...metaOld, ...meta, channel, method}); }; }