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

Extract permissions functions #14777

Merged
merged 5 commits into from
Jun 11, 2019
Merged

Extract permissions functions #14777

merged 5 commits into from
Jun 11, 2019

Conversation

sampaiodiego
Copy link
Member

@sampaiodiego sampaiodiego commented Jun 10, 2019

This is the very first step in moving the code base away from any Meteor dependency.

The idea is to do this in parts, without breaking any code that depends on the "extracted" functions. So all extracted functions will be changed to return Promises, but to not break the current code we'll be also exporting those functions with Promise.await, so they'll still run "sync" in a Fiber environment.

So as you can see, here is the new promisified version of canAccessRoom and here is the Promise.await version being exported. So from now on, all code running within a Fiber that wants to use the canAccessRoom function will have to import the Promise.await version (as you can see here)

The same applies to all other rewrited functions like hasPermission.

In order to accomplish that, we had to move away from Meteor collections as well, because they are designed to run within a Fiber. So I have created a new raw.js file in /model directory, that exports the new "raw" (actually, MongoDB driver collections) version of a regular model. The collections methods are being rewritten as needed.

The last bit included in this PR is related to Settings, the same reason as the collections, the old settings objects relies on Fibers, so I've created a simple cached get/set functions feeded by a new observer

@sampaiodiego sampaiodiego requested a review from rodrigok June 10, 2019 20:27
ggazzo
ggazzo previously approved these changes Jun 10, 2019
@ggazzo ggazzo dismissed their stale review June 10, 2019 20:48

users broken

ggazzo
ggazzo previously approved these changes Jun 10, 2019
@ggazzo ggazzo merged commit 3db08c7 into develop Jun 11, 2019
@ggazzo ggazzo deleted the demeteorize-canacessroom branch June 11, 2019 20:44
@sampaiodiego sampaiodiego mentioned this pull request Jun 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants