Remove devices with no keys

// FREEBIE
This commit is contained in:
lilia 2016-06-01 18:41:51 -07:00
parent b73e7ac28f
commit d89c3e8e86
2 changed files with 14 additions and 2 deletions

View file

@ -38570,7 +38570,13 @@ OutgoingMessage.prototype = {
var promise = Promise.resolve();
updateDevices.forEach(function(device) {
promise = promise.then(function() {
return this.server.getKeysForNumber(number, device).then(handleResult);
return this.server.getKeysForNumber(number, device).then(handleResult).catch(function(e) {
if (e.name === 'HTTPError' && e.code === 404 && device !== 1) {
return this.removeDeviceIdsForNumber(number, [device]);
} else {
throw e;
}
}.bind(this));
}.bind(this));
}.bind(this));

View file

@ -69,7 +69,13 @@ OutgoingMessage.prototype = {
var promise = Promise.resolve();
updateDevices.forEach(function(device) {
promise = promise.then(function() {
return this.server.getKeysForNumber(number, device).then(handleResult);
return this.server.getKeysForNumber(number, device).then(handleResult).catch(function(e) {
if (e.name === 'HTTPError' && e.code === 404 && device !== 1) {
return this.removeDeviceIdsForNumber(number, [device]);
} else {
throw e;
}
}.bind(this));
}.bind(this));
}.bind(this));