Built motion from commit e75a21b.|1.0.17
[motion.git] / server / api / action / action.controller.js
1 var _0xcbc9=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x41\x63\x74\x69\x6F\x6E","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x55\x73\x65\x72","\x73\x65\x71\x75\x65\x6C\x69\x7A\x65","\x62\x6C\x75\x65\x62\x69\x72\x64","\x75\x74\x69\x6C","\x73\x74\x61\x63\x6B","\x6C\x6F\x67","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x6A\x73\x6F\x6E","\x65\x6E\x64","\x74\x68\x65\x6E","\x75\x70\x64\x61\x74\x65\x41\x74\x74\x72\x69\x62\x75\x74\x65\x73","\x64\x65\x73\x74\x72\x6F\x79","\x69\x6E\x64\x65\x78","\x63\x61\x74\x63\x68","\x66\x69\x6E\x64\x41\x6C\x6C","\x63\x72\x65\x61\x74\x65","\x55\x73\x65\x72\x49\x64","\x62\x6F\x64\x79","\x69\x64","\x75\x73\x65\x72","\x70\x61\x72\x61\x6D\x73","\x6D\x65\x72\x67\x65","\x63\x68\x61\x6E\x6E\x65\x6C","\x61\x6C\x6C","\x76\x6F\x69\x63\x65","\x69\x6E\x63\x6C\x75\x64\x65\x73","\x70\x61\x75\x73\x65","\x75\x6E\x70\x61\x75\x73\x65","\x6E\x61\x6D\x65","\x72\x65\x73\x6F\x6C\x76\x65","\x64\x61\x74\x61\x32","\x51\x75\x65\x75\x65\x50\x61\x75\x73\x65","\x25\x73\x2F\x25\x73","\x53\x49\x50","\x66\x6F\x72\x6D\x61\x74","\x74\x79\x70\x65","\x64\x61\x74\x61\x34","\x44\x45\x46\x41\x55\x4C\x54\x20\x50\x41\x55\x53\x45","\x61\x6D\x69","\x6C\x6F\x63\x61\x6C\x73","\x61\x70\x70","\x61\x67\x65\x6E\x74","\x66\x69\x6E\x64\x42\x79\x49\x64"];_0xcbc9[0];var _=require(_0xcbc9[1]);var Action=require(_0xcbc9[3])[_0xcbc9[2]];var User=require(_0xcbc9[3])[_0xcbc9[4]];var sequelize=require(_0xcbc9[3])[_0xcbc9[5]];var BPromise=require(_0xcbc9[6]);var util=require(_0xcbc9[7]);function handleError(_0x3fc6x8,_0x3fc6x9){console[_0xcbc9[9]](_0x3fc6x9[_0xcbc9[8]]);return _0x3fc6x8[_0xcbc9[11]](500)[_0xcbc9[10]](_0x3fc6x9)}function responseWithResult(_0x3fc6x8,_0x3fc6xb){_0x3fc6xb= _0x3fc6xb|| 200;return function(_0x3fc6xc){if(_0x3fc6xc){_0x3fc6x8[_0xcbc9[11]](_0x3fc6xb)[_0xcbc9[12]](_0x3fc6xc)}}}function handleEntityNotFound(_0x3fc6x8){return function(_0x3fc6xc){if(!_0x3fc6xc){_0x3fc6x8[_0xcbc9[11]](404)[_0xcbc9[13]]();return null};return _0x3fc6xc}}function saveUpdates(_0x3fc6xf){return function(_0x3fc6xc){return _0x3fc6xc[_0xcbc9[15]](_0x3fc6xf)[_0xcbc9[14]](function(_0x3fc6x10){return _0x3fc6x10})}}function removeEntity(_0x3fc6x8){return function(_0x3fc6xc){if(_0x3fc6xc){return _0x3fc6xc[_0xcbc9[16]]()[_0xcbc9[14]](function(){_0x3fc6x8[_0xcbc9[11]](204)[_0xcbc9[13]]()})}}}exports[_0xcbc9[17]]= function(_0x3fc6x12,_0x3fc6x8){return Action[_0xcbc9[19]]()[_0xcbc9[14]](responseWithResult(_0x3fc6x8))[_0xcbc9[18]](function(_0x3fc6x9){handleError(_0x3fc6x8,_0x3fc6x9)})};exports[_0xcbc9[20]]= function(_0x3fc6x12,_0x3fc6x8,_0x3fc6x13){_0x3fc6x12[_0xcbc9[22]][_0xcbc9[21]]= _0x3fc6x12[_0xcbc9[24]][_0xcbc9[23]];_[_0xcbc9[26]](_0x3fc6x12[_0xcbc9[22]],_0x3fc6x12[_0xcbc9[25]]);return BPromise[_0xcbc9[34]]()[_0xcbc9[14]](function(){if(!_0x3fc6x12[_0xcbc9[22]][_0xcbc9[27]]|| _[_0xcbc9[30]]([_0xcbc9[28],_0xcbc9[29]],_0x3fc6x12[_0xcbc9[22]][_0xcbc9[27]])){switch(_0x3fc6x12[_0xcbc9[22]][_0xcbc9[33]]){case _0xcbc9[31]:;case _0xcbc9[32]:return sendAction(_0x3fc6x12,_0x3fc6x8);default:return null}};return null})[_0xcbc9[14]](function(){return Action[_0xcbc9[20]](_0x3fc6x12[_0xcbc9[22]],{body:_0x3fc6x12[_0xcbc9[22]]})})[_0xcbc9[14]](function(_0x3fc6x14){return _0x3fc6x8[_0xcbc9[11]](201)[_0xcbc9[10]](_0x3fc6x14)})[_0xcbc9[18]](function(_0x3fc6x9){return handleError(_0x3fc6x8,_0x3fc6x9)})};function sendAction(_0x3fc6x12,_0x3fc6x8){return BPromise[_0xcbc9[34]]()[_0xcbc9[14]](function(){if(!_0x3fc6x12[_0xcbc9[22]][_0xcbc9[35]]){return User[_0xcbc9[47]](_0x3fc6x12[_0xcbc9[22]][_0xcbc9[46]])};return null})[_0xcbc9[14]](function(_0x3fc6x16){if(!_0x3fc6x16&&  !_0x3fc6x12[_0xcbc9[22]][_0xcbc9[35]]){_0x3fc6x8[_0xcbc9[11]](404)[_0xcbc9[13]]();return null};if(_0x3fc6x16){_0x3fc6x12[_0xcbc9[22]][_0xcbc9[35]]= _0x3fc6x16[_0xcbc9[33]]};var _0x3fc6x14;switch(_0x3fc6x12[_0xcbc9[22]][_0xcbc9[33]]){case _0xcbc9[31]:_0x3fc6x14= {message:_0xcbc9[36],agent:_0x3fc6x12[_0xcbc9[22]][_0xcbc9[35]],action:{action:_0xcbc9[36],interface:util[_0xcbc9[39]](_0xcbc9[37],_0xcbc9[38],_0x3fc6x12[_0xcbc9[22]][_0xcbc9[35]]),paused:true,reason:_0x3fc6x12[_0xcbc9[22]][_0xcbc9[40]]|| _0x3fc6x12[_0xcbc9[22]][_0xcbc9[41]]|| _0xcbc9[42]}};break;case _0xcbc9[32]:_0x3fc6x14= {message:_0xcbc9[36],agent:_0x3fc6x12[_0xcbc9[22]][_0xcbc9[35]],action:{action:_0xcbc9[36],interface:util[_0xcbc9[39]](_0xcbc9[37],_0xcbc9[38],_0x3fc6x12[_0xcbc9[22]][_0xcbc9[35]]),paused:false}};break;default:};if(_0x3fc6x14){return _0x3fc6x12[_0xcbc9[45]][_0xcbc9[44]][_0xcbc9[43]][_0xcbc9[10]](_0x3fc6x14)};return null})}