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