Skip to content

Commit 34851c0

Browse files
flovilmartdrew-gross
authored andcommitted
Makes sure we don't delete Installations at large when updating a token (#1475) (#1486)
1 parent 686cc4a commit 34851c0

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/RestWrite.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -659,10 +659,23 @@ RestWrite.prototype.handleInstallation = function() {
659659
// device token.
660660
var delQuery = {
661661
'deviceToken': this.data.deviceToken,
662-
'installationId': {
662+
};
663+
// We have a unique install Id, use that to preserve
664+
// the interesting installation
665+
if (this.data.installationId) {
666+
delQuery['installationId'] = {
663667
'$ne': this.data.installationId
664668
}
665-
};
669+
} else if (idMatch.objectId && this.data.objectId
670+
&& idMatch.objectId == this.data.objectId) {
671+
// we passed an objectId, preserve that instalation
672+
delQuery['objectId'] = {
673+
'$ne': idMatch.objectId
674+
}
675+
} else {
676+
// What to do here? can't really clean up everything...
677+
return idMatch.objectId;
678+
}
666679
if (this.data.appIdentifier) {
667680
delQuery['appIdentifier'] = this.data.appIdentifier;
668681
}

0 commit comments

Comments
 (0)