[PushController] Fixes issue with undefined push_time (#3717) (#3824)

* Fixes #3717

This fixes PR #3717. Sending push with parse-server@2.4.0 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
This commit is contained in:
Felipe Andrade
2017-05-20 13:07:45 -03:00
committed by Florent Vilmart
parent 35d781a160
commit 03b6449fe1
2 changed files with 55 additions and 5 deletions

View File

@@ -14,7 +14,10 @@ export class PushController {
}
// Replace the expiration_time and push_time with a valid Unix epoch milliseconds time
body.expiration_time = PushController.getExpirationTime(body);
body.push_time = PushController.getPushTime(body);
const push_time = PushController.getPushTime(body);
if (typeof push_time !== 'undefined') {
body['push_time'] = push_time;
}
// TODO: If the req can pass the checking, we return immediately instead of waiting
// pushes to be sent. We probably change this behaviour in the future.
let badgeUpdate = () => {
@@ -50,7 +53,7 @@ export class PushController {
onPushStatusSaved(pushStatus.objectId);
return badgeUpdate();
}).then(() => {
if (body.push_time && config.hasPushScheduledSupport) {
if (body.hasOwnProperty('push_time') && config.hasPushScheduledSupport) {
return Promise.resolve();
}
return config.pushControllerQueue.enqueue(body, where, config, auth, pushStatus);