-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Add support for push scheduling #3717
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
Conversation
Add a configuration flag on the server to handle the availability of push scheduling.
src/Controllers/PushController.js
Outdated
* @returns {Number|undefined} The push time if it exists in the request | ||
*/ | ||
static getPushTime(body = {}) { | ||
var hasPushTime = !!body['push_time']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use body.hasOwnProperty('push_time')
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've used the same convention found in the getExpirationTime function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, bad conventions from when I started a year ago
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking great!
Can you add the option to the CLI definitions as well?
I know it's a lot but...
src/Controllers/PushController.js
Outdated
@@ -49,6 +50,9 @@ export class PushController { | |||
onPushStatusSaved(pushStatus.objectId); | |||
return badgeUpdate(); | |||
}).then(() => { | |||
if (body.push_time) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if body.push_time is set and the config is not enabled for scheduling, we should warn that the message will be delivered right away no? Only skip if configured, what do you think? I'm thinking of all other users :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense. I've updated the code to only allow skipping on the right configuration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@flovilmart What do you mean about CLI definitions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only skip push sending if scheduling is configured
Codecov Report
@@ Coverage Diff @@
## master #3717 +/- ##
==========================================
- Coverage 90.42% 90.31% -0.11%
==========================================
Files 114 114
Lines 7412 7432 +20
==========================================
+ Hits 6702 6712 +10
- Misses 710 720 +10
Continue to review full report at Codecov.
|
@flovilmart the code is updated with additional commits :) |
* @param {Object} request A request object | ||
* @returns {Number|undefined} The push time if it exists in the request | ||
*/ | ||
static getPushTime(body = {}) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we add a test for that piece?
There is a bit of logic there, even trivial but that would help not introduce any regression.
I could add them on the top of your branch if you don't have much time :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, we've to add a test. Any help is appreciated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i wish i knew enough to help.. i will check your test to help further in any future contribution. Tks in advance @flovilmart
@felipemobile thanks for getting that one started, I just merged #3722 |
* Fixes #3717 This fixes PR #3717. Sending push with [email protected] returns error 504 GATEWAY_TIMEOUT. This happens when push_time is not set (default). * Fix lint issues * Fix in PushController and add tests Add a test to check push_time format and if it should schedule push when the parse-server is configured
Add a configuration flag on the server to handle the availability of
push scheduling.