Let multiple installations be updates if no critical values are set (#3040)
* Let multiple installations be updates if no critical values are set * nits
This commit is contained in:
@@ -238,6 +238,68 @@ describe('PushController', () => {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('properly set badges to 1 with complex query #2903 #3022', (done) => {
|
||||||
|
|
||||||
|
var payload = {
|
||||||
|
data: {
|
||||||
|
alert: "Hello World!",
|
||||||
|
badge: 1,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var installations = [];
|
||||||
|
while(installations.length != 10) {
|
||||||
|
var installation = new Parse.Object("_Installation");
|
||||||
|
installation.set("installationId", "installation_"+installations.length);
|
||||||
|
installation.set("deviceToken","device_token_"+installations.length)
|
||||||
|
installation.set("badge", installations.length);
|
||||||
|
installation.set("originalBadge", installations.length);
|
||||||
|
installation.set("deviceType", "ios");
|
||||||
|
installations.push(installation);
|
||||||
|
}
|
||||||
|
let matchedInstallationsCount = 0;
|
||||||
|
var pushAdapter = {
|
||||||
|
send: function(body, installations) {
|
||||||
|
matchedInstallationsCount += installations.length;
|
||||||
|
var badge = body.data.badge;
|
||||||
|
installations.forEach((installation) => {
|
||||||
|
expect(installation.badge).toEqual(badge);
|
||||||
|
expect(1).toEqual(installation.badge);
|
||||||
|
})
|
||||||
|
return successfulTransmissions(body, installations);
|
||||||
|
},
|
||||||
|
getValidPushTypes: function() {
|
||||||
|
return ["ios"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var config = new Config(Parse.applicationId);
|
||||||
|
var auth = {
|
||||||
|
isMaster: true
|
||||||
|
}
|
||||||
|
|
||||||
|
var pushController = new PushController(pushAdapter, Parse.applicationId, defaultConfiguration.push);
|
||||||
|
Parse.Object.saveAll(installations).then((installations) => {
|
||||||
|
let objectIds = installations.map(installation => {
|
||||||
|
return installation.id;
|
||||||
|
})
|
||||||
|
let where = {
|
||||||
|
objectId: {'$in': objectIds.slice(0, 5)}
|
||||||
|
}
|
||||||
|
return pushController.sendPush(payload, where, config, auth);
|
||||||
|
}).then(() => {
|
||||||
|
expect(matchedInstallationsCount).toBe(5);
|
||||||
|
let query = new Parse.Query(Parse.Installation);
|
||||||
|
query.equalTo('badge', 1);
|
||||||
|
return query.find({useMasterKey: true});
|
||||||
|
}).then((installations) => {
|
||||||
|
expect(installations.length).toBe(5);
|
||||||
|
done();
|
||||||
|
}).catch(() => {
|
||||||
|
fail("should not fail");
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('properly creates _PushStatus', (done) => {
|
it('properly creates _PushStatus', (done) => {
|
||||||
|
|
||||||
var installations = [];
|
var installations = [];
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { ParsePubSub } from './ParsePubSub';
|
import { ParsePubSub } from './ParsePubSub';
|
||||||
|
import Parse from 'parse/node';
|
||||||
import logger from '../logger';
|
import logger from '../logger';
|
||||||
|
|
||||||
class ParseCloudCodePublisher {
|
class ParseCloudCodePublisher {
|
||||||
|
|||||||
@@ -624,6 +624,12 @@ RestWrite.prototype.handleInstallation = function() {
|
|||||||
installationId = installationId.toLowerCase();
|
installationId = installationId.toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Updating _Installation but not updating anything critical
|
||||||
|
if (this.query && !this.data.deviceToken
|
||||||
|
&& !installationId && !this.data.deviceType) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var promise = Promise.resolve();
|
var promise = Promise.resolve();
|
||||||
|
|
||||||
var idMatch; // Will be a match on either objectId or installationId
|
var idMatch; // Will be a match on either objectId or installationId
|
||||||
|
|||||||
Reference in New Issue
Block a user