Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KZL 454 - Allow subscribe filters on metadata #1185

Merged
merged 2 commits into from
Aug 28, 2018

Conversation

Aschen
Copy link
Contributor

@Aschen Aschen commented Aug 17, 2018

What does this PR do ?

When subscribing to realtime notification, you can provide some filters.
These filters can not involve metadata because the realtime engine is called before the document is saved (no metadata at this point) and the result is cached. When we notify the second time, we fetch the cache instead of calling koncorde again so the filters can never apply on metadata fields.

This PR allow the usage of metadata fields in subscription filters.
This functionality was needed by kuzzleio/kuzzle-plugin-sample-custom-policies#1 to display notifications about document only to their respective author.

The publish method of the Notifier does not put the result in cache anymore.
Moreover, the notification before the document is saved (pending state) are now deprecated and they will be removed in Kuzzle v2.

Documentation: kuzzleio/documentation#522

How should this be manually tested?

  • Step 1 : Create two users: user1 and user2
  • Step 2 : Create the index my-index and the collectionmy-collection
  • Step 3 : Use this code to subscribe to document created by user1: subscribe.js
  • Step 4 : Create a document when logged as user2 and then create a document when logged as user1

Other changes

  • Disable the room caching when document are created or updated, Koncorde is called two time now
  • Deprecate the pending notifications

@Aschen Aschen self-assigned this Aug 17, 2018
@Aschen Aschen changed the base branch from master to 1.x August 17, 2018 15:29
@Aschen Aschen removed the wip label Aug 20, 2018
@codecov-io
Copy link

codecov-io commented Aug 20, 2018

Codecov Report

Merging #1185 into 1.x will increase coverage by 0.02%.
The diff coverage is 61.53%.

Impacted file tree graph

@@            Coverage Diff             @@
##              1.x    #1185      +/-   ##
==========================================
+ Coverage   93.92%   93.95%   +0.02%     
==========================================
  Files          91       91              
  Lines        6424     6416       -8     
==========================================
- Hits         6034     6028       -6     
+ Misses        390      388       -2
Impacted Files Coverage Δ
lib/api/controllers/documentController.js 99.15% <ø> (ø) ⬆️
lib/api/core/notifier.js 76.03% <61.53%> (+0.06%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4c2be61...4362546. Read the comment docs.

@alexandrebouthinon alexandrebouthinon merged commit 1655cdf into 1.x Aug 28, 2018
@alexandrebouthinon alexandrebouthinon deleted the KZL-454/allow-subscribe-filter-on-metadata branch August 28, 2018 09:32
@scottinet scottinet mentioned this pull request Sep 13, 2018
scottinet added a commit that referenced this pull request Sep 13, 2018
* fixes #1125 - aggs & sort on user search (#1144)

* Add AdminController (#1129)

* KZL-143 KZL-145 add admin controller and reset cache action

* Boyscout: fix crash because kuzzle try to load protocols in simplefiles

* Add tests for adminController

* Add resetKuzzleData and resetSecurity

* fix features for admin controller

* Add resetDatabase

* fix tests

* fix tests

* fix tests

* Add default rights restrictions for admin controller

* Fix test

* Fix test

* Use API for all actions except dump

* Add generateDump

* Fix tests and remove old cli tests

* Remove reset security scenario

* Make sonarqube happy

* Remove references to cliController

* Fix features

* fix internal error

* remove internal broker

* re-add shutdown

* fix test

* Put shutdown in adminController

* Reset defaults roles and profiles with resetSecurity

* replace ws by uws

* Nitpicking

* increase coverage

* increase coverage

* increase coverage

* fix linter

* increase coverage

* put back proxyBroker

* fix tests

* remove tests

* fix tests

* nitpicking

* Updates for PR

* Put back defaut config

* Disable dump if it is specified in config

* fix message in cli

* add truncate() method on repositories + refactor admin controller to use truncate()

* fix admin controller

* fix test

* Add Janitor core component

* return number of deleted objects in truncate

* fix linter

* catch TypeError for scanStream

* fix linter

* Please sonarqube

* fix linter

* Nitpicking

* Updates for PR

* update headers

* fix linter

* fix tests

* deprecate "constructor" auth option and replace it with "authenticator" (#1145)

* deprecate "constructor" auth option and replace it with "authenticator"

* fix sonarqube issues

* Add action and controller in request input for http events (#1143)

* Add action and controller in request input for http events

* put back some code

* nitpicking

* Add forgotten files --'

* Test Kuzzle against different node LTS versions (#1147)

* set ulimits for elasticsearch (#1148)

* Update kuzzle-common-objects module (#1150)

* adapt tests to new common objects version

* dependencies update

* npm audit fix

* update to plugin auth local 5.1.3 (#1149)

* update to plugin auth local 5.1.3

* adapt tests to new common objects version

* dependencies update

* npm audit fix

* prevent a breaking change when upgrade from a pre-1.4.0 version

* Revert "prevent a breaking change when upgrade from a pre-1.4.0 version"

This reverts commit 8328f50.

* prevent a breaking change occuring when upgrading Kuzzle with old config files (#1154)

* Inject protocol informations into the RequestContext object (#1155)

* inject protocol info into requestcontext

* fix incoming context infos coming from the proxy

* revert debug modification

* no need to manually copy incoming headers

* update unit tests

* fix sonarqube issu

* jsdoc fix

* fixes #1146, passport login request missing headers (#1153)

* fixes #1146, passport login request missing headers

* oauth - add some comments on arbritraty method & url

* Add script to build and push docker images (#1152)

* Add script to build and push docker images

* Add script to build and push docker images

* Fix build script

* add comment to secret env

* Use kuzzleteam account for dockerhub

* Update subnmodule

* Dont build and push on hotfix merge

* fix #1161 (#1162)

* fix startup message (#1163)

* Fix #1131: listCollections limited to the provided collection name, when specified (#1157)

* fixes #1156 - missing version in swagger output (#1164)

* add token infos to login response (#1171)

* disable dump by default (#1172)

* disable dump by default

* fix tests:

* fix #447: allow to search document with empty query through a HTTP GET request

* fix unit test

* Replace ParseError errors with BadRequestError objects (#1158)

* replace ParseError (deprecated) with BadRequestError

* fix #1168: remove useless CLI --port option  (#1177)

* fix #1168

* remove useless --port option in CLI start command

* fix #1174 (#1176)

* Fix #1115: Standardize the scrollId return value (#1173)

* Standardize the scrollId return value

* typo

* typo

* Initialize repositories before plugins (#1167)

* Initialize repositories before plugins

* remove one then() level

* Use local multi-stage build for kuzzleio/plugin-dev and kuzzleio/kuzzle (#1178)

* Update Dockerfile and build-docker-images script\n Now with multi-stage build and support for 1.x and 2.x development branch
* Remove pm2 from prod image
* Use latest node 8 version

* Add metadata to published documents (#1186)

* KZL 454 - Allow subscribe filters on metadata (#1185)

* Do not cache requests with publish(), call koncorde two times instead

* Add functionnal test for subscription filter on metadata

* Add LGTM.com code quality badges (#1187)

* KZL 290 - Add fixtures for securities (#1182)

* Move mappings and fixtures loading to Janitor

* Fix bug in repository#delete when object is not present

* Add ability to load roles, profiles and users to Janitor and CLI

* Add test for Janitor#loadSecurities

* remove .only from test

* Fix #1184: Better error message when object not found in repositories
Refactor repository loadOneFromDatabase method to reject with an explicit 404 when not found
Allow the old api usage which return a null object when not found for SecurityController#persistUser and PluginRepository#load

* Fix test

* rename getUserId

* Update for PR

* refactor janitor _create* method

* Please sonarqube

* typo

* Plugins/Protocols manifest.json overhaul (#1181)

* wip

* change reporter to dot

* fix polluting console outputs

* upgrade unit tests to make them handle the new plugin structure

* new manifest.json handling tests+fixes

* fix sonarqube issue

* x_x

* implement @benoitvidis asked changes

* fix circular json in manifest objects

* add control to manifest stringification

* remove privileged mode for protocols

* Update docker build script for new branch name 1-dev (#1190)

* Update images build script

* push only if we are on the major build

* remove test

* update default plugins (#1193)

* KZL-174 Expose to plugins a SDK instance directly mapped to the funnel (#1179)

* wip

* KZL-177: custom "funnel" network wrapper for SDK

* KZL-178: Export javascript SDK to plugins

* refactor executePluginRequest: now returns a promise

* KZL-177: revert funnelcallController => now sdk wrapper calls directly funnel.executePluginRequest

* mark `pluginContext.accessor.execute` as deprecated

* clean code

* update package-lock

* fix comment

* tix typo

* dependencies update

* remove debug config

* Release 1.5.0

* dependencies update
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants