Add apps.getAllByUser()

This commit is contained in:
Johannes Zellner
2016-02-25 11:28:29 +01:00
parent 00d277b1c3
commit 9688e4c124

View File

@@ -12,6 +12,7 @@ exports = module.exports = {
getBySubdomain: getBySubdomain,
getByIpAddress: getByIpAddress,
getAll: getAll,
getAllByUser: getAllByUser,
purchase: purchase,
install: install,
configure: configure,
@@ -357,6 +358,21 @@ function getAll(callback) {
});
}
function getAllByUser(user, callback) {
assert.strictEqual(typeof user, 'object');
assert.strictEqual(typeof callback, 'function');
getAll(function (error, result) {
if (error) return callback(error);
async.filter(result, function (app, callback) {
hasAccessTo(app, user, function (error, hasAccess) {
callback(hasAccess);
});
}, callback.bind(null, null)); // never error
});
}
function purchase(appStoreId, callback) {
assert.strictEqual(typeof appStoreId, 'string');
assert.strictEqual(typeof callback, 'function');