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

@ -214,6 +214,19 @@
});
});
},
getDeviceIds: function(number) {
if (number === null || number === undefined)
throw new Error("Tried to put session for undefined/null key");
return new Promise(function(resolve) {
var contact = new Contact({id: number});
contact.fetch().always(function() {
var sessions = contact.get('sessions') || {};
resolve(_.keys(sessions).map(function(n) {
return parseInt(n);
}));
});
});
},
removeAllSessions: function(number) {
if (number === null || number === undefined)
throw new Error("Tried to put session for undefined/null key");