Do not mark the empty pushs as failed (#4497)

This commit is contained in:
Florent Vilmart
2018-01-13 15:12:19 -05:00
committed by GitHub
parent 75fa16aa7e
commit 33890bbbfc
2 changed files with 3 additions and 5 deletions

View File

@@ -951,7 +951,7 @@ describe('PushController', () => {
}); });
}); });
it('should mark the _PushStatus as failed when audience has no deviceToken', (done) => { it('should not mark the _PushStatus as failed when audience has no deviceToken', (done) => {
var auth = { var auth = {
isMaster: true isMaster: true
} }
@@ -999,8 +999,6 @@ describe('PushController', () => {
var config = Config.get(Parse.applicationId); var config = Config.get(Parse.applicationId);
return Parse.Object.saveAll(installations).then(() => { return Parse.Object.saveAll(installations).then(() => {
return pushController.sendPush(payload, {}, config, auth) return pushController.sendPush(payload, {}, config, auth)
.then(() => { done.fail('should not success') })
.catch(() => {})
}).then(() => new Promise(resolve => setTimeout(resolve, 100))); }).then(() => new Promise(resolve => setTimeout(resolve, 100)));
}).then(() => { }).then(() => {
const query = new Parse.Query('_PushStatus'); const query = new Parse.Query('_PushStatus');
@@ -1008,7 +1006,7 @@ describe('PushController', () => {
expect(results.length).toBe(1); expect(results.length).toBe(1);
const pushStatus = results[0]; const pushStatus = results[0];
expect(pushStatus.get('numSent')).toBe(0); expect(pushStatus.get('numSent')).toBe(0);
expect(pushStatus.get('status')).toBe('failed'); expect(pushStatus.get('status')).toBe('succeeded');
done(); done();
}); });
}).catch((err) => { }).catch((err) => {

View File

@@ -38,7 +38,7 @@ export class PushQueue {
{limit: 0, count: true}); {limit: 0, count: true});
}).then(({results, count}) => { }).then(({results, count}) => {
if (!results || count == 0) { if (!results || count == 0) {
return Promise.reject({error: 'PushController: no results in query'}) return pushStatus.complete();
} }
pushStatus.setRunning(Math.ceil(count / limit)); pushStatus.setRunning(Math.ceil(count / limit));
let skip = 0; let skip = 0;