Add getDeviceIds to axolotlstore

And add tests for getDeviceIds and removeAllSessions
This commit is contained in:
lilia 2015-04-21 19:13:13 -07:00
parent 121671c99f
commit f413f03a6b
4 changed files with 102 additions and 3 deletions

View file

@ -89,5 +89,26 @@ AxolotlStore.prototype = {
return new Promise(function(resolve) {
resolve(this.put('session' + identifier, record));
}.bind(this));
}
},
removeAllSessions: function(identifier) {
return new Promise(function(resolve) {
for (key in this.store) {
if (key.match(RegExp('^session' + identifier.replace('\+','\\\+') + '.+'))) {
delete this.store[key];
}
}
resolve();
}.bind(this));
},
getDeviceIds: function(identifier) {
return new Promise(function(resolve) {
var deviceIds = [];
for (key in this.store) {
if (key.match(RegExp('^session' + identifier.replace('\+','\\\+') + '.+'))) {
deviceIds.push(parseInt(key.split('.')[1]));
}
}
resolve(deviceIds);
}.bind(this));
}
};