Makes sure we don't delete Installations at large when updating a token (#1475) (#1486)

This commit is contained in:
Florent Vilmart
2016-04-14 15:59:59 -04:00
committed by Drew
parent 686cc4ab95
commit 34851c0ae5

View File

@@ -659,10 +659,23 @@ RestWrite.prototype.handleInstallation = function() {
// device token.
var delQuery = {
'deviceToken': this.data.deviceToken,
'installationId': {
};
// We have a unique install Id, use that to preserve
// the interesting installation
if (this.data.installationId) {
delQuery['installationId'] = {
'$ne': this.data.installationId
}
};
} else if (idMatch.objectId && this.data.objectId
&& idMatch.objectId == this.data.objectId) {
// we passed an objectId, preserve that instalation
delQuery['objectId'] = {
'$ne': idMatch.objectId
}
} else {
// What to do here? can't really clean up everything...
return idMatch.objectId;
}
if (this.data.appIdentifier) {
delQuery['appIdentifier'] = this.data.appIdentifier;
}