From 34851c0ae546c96a5e180f644248a04d10d5fc00 Mon Sep 17 00:00:00 2001 From: Florent Vilmart Date: Thu, 14 Apr 2016 15:59:59 -0400 Subject: [PATCH] Makes sure we don't delete Installations at large when updating a token (#1475) (#1486) --- src/RestWrite.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/RestWrite.js b/src/RestWrite.js index bd220b86..3e5fa337 100644 --- a/src/RestWrite.js +++ b/src/RestWrite.js @@ -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; }