handle_mp
functionhandle_mp()
Funktion veranlasst laden und löschen der mp-
Dokumente.
var handle_mp = function(req, cb){
var id = req.params.id
, rb = req.body;
if(_.isString(rb)){
// switch
if(rb == ctrlstr.load){
log.info(ok
, "try to publish to get_mp channel");
mem.publish("get_mp", id , function(err){
if(!err){
if(_.isFunction(cb)){
cb(ok)
}
log.info(ok
, " published to get_mp channel");
}else{
var ro = {error:err};
log.error(ro
, " error on attempt to publish to get_mp channel");
if(_.isFunction(cb)){
cb(ro)
}
}
});
}
if(rb == ctrlstr.rm){
log.info(ok
, "try to publish to rm_mp channel");
mem.publish("rm_mp", id , function(err){
if(!err){
if(_.isFunction(cb)){
cb(ok)
}
log.info(ok
, " published to rm_mp channel");
}else{
var ro = {error:err};
log.error(ro
, " error on attempt to publish to rm_mp channel");
if(_.isFunction(cb)){
cb(ro)
}
}
});
}
};
}
exports.handle_mp = handle_mp;