2015-11-03 22:17:24 +03:00
|
|
|
var _ = require('lodash'),
|
|
|
|
api = require('../api'),
|
|
|
|
flagIsSet;
|
|
|
|
|
|
|
|
flagIsSet = function flagIsSet(flag) {
|
|
|
|
return api.settings.read({key: 'labs', context: {internal: true}}).then(function (response) {
|
|
|
|
var labs,
|
|
|
|
labsValue;
|
|
|
|
|
|
|
|
labs = _.find(response.settings, function (setting) {
|
|
|
|
return setting.key === 'labs';
|
|
|
|
});
|
|
|
|
|
2015-11-04 17:20:05 +03:00
|
|
|
if (!labs || !labs.value) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
labsValue = JSON.parse(labs.value);
|
|
|
|
} catch (e) {
|
|
|
|
return false;
|
|
|
|
}
|
2015-11-03 22:17:24 +03:00
|
|
|
|
|
|
|
return !!labsValue[flag] && labsValue[flag] === true;
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports.isSet = flagIsSet;
|