Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function cmd_delete(args, done){
// TODO - there must be other data to remove if we delete a dojo??
var user = args.user;
var query = {userId:user.id, dojoId:args.id};
async.waterfall([
async.apply(isUserChampionAndDojoAdmin, query, user),
deleteDojo,
deleteUsersDojos,
deleteDojoLead,
deleteSalesForce
], done);
function deleteDojo(hasPermission, done) {
if(hasPermission) {
var dojo = {
id: args.id,
deleted: 1,
deletedBy: args.user.id,
deletedAt: new Date()
};
seneca.make$(ENTITY_NS).save$(dojo, done);
hoodie.database.add('foo', function (err, db) {
if (err) {
return test.done(err)
}
var doc1 = {id: 'wibble', title: 'Test Document 1'}
var doc2 = {id: 'wobble', title: 'Test Document 2'}
async.parallel([
async.apply(db.add, 'mytype', doc1),
async.apply(db.add, 'mytype', doc2)
], function (err) {
if (err) {
return test.done(err)
}
db.findAll(function (err, docs) {
if (err) {
return test.done(err)
}
test.equal(docs.length, 2)
test.equal(docs[0].id, 'wibble')
test.equal(docs[0].type, 'mytype')
test.equal(docs[0].title, 'Test Document 1')
test.equal(docs[1].id, 'wobble')
test.equal(docs[1].type, 'mytype')
test.equal(docs[1].title, 'Test Document 2')
exports['account.add / findAll / get / remove / update'] = function (test) {
var hoodie = new PluginAPI(DEFAULT_OPTIONS)
var userdoc = {
id: 'testuser',
password: 'testing'
}
async.series([
async.apply(hoodie.account.findAll, 'user'),
async.apply(hoodie.account.add, 'user', userdoc),
hoodie.account.findAll,
async.apply(hoodie.account.find, 'user', 'testuser'),
async.apply(hoodie.account.update, 'user', 'testuser', {wibble: 'wobble'}),
async.apply(hoodie.account.find, 'user', 'testuser'),
async.apply(hoodie.account.remove, 'user', 'testuser'),
hoodie.account.findAll
], function (err, results) {
if (err) {
return test.done(err)
}
var docs1 = results[0]
var docs2 = results[2]
var userdoc1 = results[3]
var userdoc2 = results[5]
var docs3 = results[7]
languageDirection: function (next) {
translator.translate('[[language:dir]]', res.locals.config.userLang, function (translated) {
next(null, translated);
});
},
browserTitle: function (next) {
translator.translate(controllers.helpers.buildTitle(translator.unescape(data.title)), function (translated) {
next(null, translated);
});
},
navigation: async.apply(navigation.get, req.uid),
banned: async.apply(user.bans.isBanned, req.uid),
banReason: async.apply(user.bans.getReason, req.uid),
unreadData: async.apply(topics.getUnreadData, { uid: req.uid }),
unreadChatCount: async.apply(messaging.getUnreadCount, req.uid),
unreadNotificationCount: async.apply(user.notifications.getUnreadCount, req.uid),
}, next);
},
function (results, next) {
}
};
if (AppUtils.getProperty(params, props.publishingFogInstance + '.uuid')
=== AppUtils.getProperty(params, props.destinationFogInstanceUUID + '.uuid')) {
watefallMethods = [
async.apply(RoutingService.createRoute, routingProps, params),
async.apply(ElementInstanceService.getElementInstanceRouteDetails, destElementProps),
async.apply(ElementInstanceService.updateElemInstance, updateRebuildPubProps),
async.apply(ElementInstanceService.updateElemInstance, updateRebuildDestProps),
async.apply(ChangeTrackingService.updateChangeTracking, pubChangeTrackingProps)
];
} else {
watefallMethods = [
async.apply(ComsatService.openPortOnRadomComsat, params),
createSatellitePort,
async.apply(ElementService.getNetworkElement, pubNetworkElementProps),
async.apply(createPubNetworkElementInstance, pubNetworkElementInstanceProps),
async.apply(ElementService.getNetworkElement, destNetworkElementProps),
async.apply(createDestNetworkElementInstance, destNetworkElementInstanceProps),
async.apply(NetworkPairingService.createNetworkPairing, networkPairingProps),
async.apply(RoutingService.createRoute, pubRoutingProps),
async.apply(RoutingService.createRoute, destRoutingProps),
async.apply(ElementInstanceService.updateElemInstance, updateRebuildPubProps),
async.apply(ElementInstanceService.updateElemInstance, updateRebuildDestProps),
fns.forEach(function(f) {
bound.push(async.apply(f, roleId));
});
function fetchAndCheckArchive(archiveName, archivefile, checksum, callback) {
return async.waterfall([
async.apply(fetchArchive, archiveName, archivefile),
async.apply(verifyChecksum, archivefile, checksum)
], callback);
}
RealTime.prototype.loadScore = function (scoreId, callback) {
var score = { users: {}, events: [] };
async.waterfall([
async.apply(schema.models.Score.find.bind(schema.models.Score), scoreId),
function (scoredb, callback) {
score.scoredb = scoredb;
score.git = new Score(scoredb.sid);
score.git.getScore('master', callback);
},
function (scoreContent, callback) {
score.fdata = new Fermata.Data(JSON.parse(scoreContent));
this.scores[scoreId] = score;
callback();
}.bind(this)
], callback);
};
async.each(hooks, function (hook, next) {
async.parallel({
'hourly': async.apply(analytics.getHourlyStatsForSet, 'analytics:' + hook.type + ':' + hook.hook, Date.now(), 24),
'daily': async.apply(analytics.getDailyStatsForSet, 'analytics:' + hook.type + ':' + hook.hook, Date.now(), 30)
}, function (err, stats) {
hook.stats = stats;
next(err);
});
}, function(err) {
callback(err, hooks);
if(req.query.t){
params.bodyParams.t = req.query.t;
}
params.bodyParams.trackId = req.params.trackId;
logger.info("Parameters:" + JSON.stringify(params.bodyParams));
async.waterfall([
async.apply(UserService.getUser, userProps, params),
async.apply(ElementInstanceService.getDetailedElementInstances, elementInstanceProps),
async.apply(ElementInstanceConnectionsService.findBySourceElementInstance, elementInstanceConnectionProps),
async.apply(ElementInstancePortService.findElementInstancePortsByElementIds, elementInstancePortProps),
async.apply(NetworkPairingService.findByElementInstancePortId, networkPairingProps),
async.apply(SatellitePortService.findBySatellitePortIds, satellitePortProps),
async.apply(SatelliteService.findBySatelliteIds, satelliteProps),
async.apply(RoutingService.isDebugging, debugProps),
async.apply(RoutingService.isViewer, viewerProps),
async.apply(ElementInstanceService.getDataTrackDetails, dataTrackProps),
getElementInstanceDetails
], function(err, result) {
AppUtils.sendResponse(res, err, 'instance', params.response, result);
});
};