kuzzleio / kuzzle

Open-source Back-end, self-hostable & ready to use - Real-time, storage, advanced search - Web, Apps, Mobile, IoT -
https://kuzzle.io
Apache License 2.0
1.44k stars 124 forks source link

Add metadata on subscriptions #791

Closed neolas closed 7 years ago

neolas commented 7 years ago

I make a subscription with a custom controller which permits to force filters on backend-side. I would like add some metadatas informations in order to apply some specific soperation on content before notify in my custom pipe (cf #790). For this, I try to add content in request.input.metadata when I make subscription but the field metadata is not filled in notification.

Custom controller :

var filters = {
    equals: {
        'metas.id':request.input.body.thingID,
    }
}
request.input.resource.index = request.input.body.universID;
request.input.resource.collection = 'things';
request.input.body = {};
request.input.body = filters;
request.input.metadata = {'hello':'world'};

this.context.accessors.kuzzle.hotelClerk.addSubscription(request)
    .then(res => { 
        resolve(res); 
    })
    .catch(err => { reject(err);});

I want have metadata {'hello':'world'} in every notifications in this channel. Is it possible by this way and it's a bug or another technique exists ?

Thanks,

ballinette commented 7 years ago

Hi. The medatada option (actually, it will be renamed in volatile in next release) are used to propagate volatile data from the input request to the response.

While subscribing to a room, it is only used to be propagated to other users that are notified about a new subscription, or a leaving subscription, not about other document (see http://docs.kuzzle.io/api-reference/?others#subscribe-to-a-room )

We should discuss about your use case to find the best alternative for that.

scottinet commented 7 years ago

Should be possible after https://github.com/kuzzleio/kuzzle/issues/790 is implemented.