kuzzle
kuzzle copied to clipboard
Pluigin pipe core:realtime:notification:dispatch:before not able to filter user to be notified
Expected Behavior
The pipe 'core:realtime:notification:dispatch:before' is supposed to allow filtering of user to be notified. But this not possible yet. The connectionId param is undefined. See also : https://github.com/kuzzleio/kuzzle/pull/2364
EDIT --
As i understand if connectionId is undefined event is braodcasted to all users. If i set connectionId to one value, event is sent to only one user. Probleme is I can't notify 2 user out of of 3 subscriber.
Current Behavior
The connectionId param is undefined.
Possible Solution
Trigger the pipe for each client and allow a way to get the client info from the pipe.
Steps to Reproduce
Here is the minimal plugin i wrote:
import { Plugin } from 'kuzzle';
export class SecondPlugin extends Plugin {
async init(config, context) {
this.config = config;
this.context = context;
}
constructor () {
super({ kuzzleVersion: '>=2.8 <3' });
this.pipes = {
'core:realtime:notification:dispatch:before': async (notifCtx) => {
this.context.log.info(`core:realtime:notification:dispatch:before channels: '${notifCtx.channels}' connectionId:'${notifCtx.connectionId}' ${Object.keys(notifCtx)}`)
return notifCtx
},
}
}
}
Here is what appear in the logs:
core:realtime:notification:dispatch:before channels: 'bb3840ac788b1a931da557b1fc7c2ca93d2272970faa0ba1bb1ac0c87578078-311' connectionId:'undefined' channels,connectionId,notification
Context (Environment)
Kuzzle version: 2.19.3 Node.js version: 14 SDK version: not used (event triggered by the console)
Hello @screwt ,
You cannot prevent notifications to be dispatched at this point of the action pipeline.
I answered your original question here: https://stackoverflow.com/questions/72767474/kuzzle-how-to-dispatch-event-only-to-subscribed-user-based-on-a-condition/73441349#73441349
Closing as this has been answered, feel free to reopen if needed