Add getDeviceIds to axolotlstore
And add tests for getDeviceIds and removeAllSessions
This commit is contained in:
parent
121671c99f
commit
f413f03a6b
4 changed files with 102 additions and 3 deletions
|
@ -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));
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue