Built motion from commit 8414198.|1.0.15
[motion.git] / server / api / action / action.controller.js
1 var _0xf7a0=["\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"];_0xf7a0[0];var _=require(_0xf7a0[1]);var Action=require(_0xf7a0[3])[_0xf7a0[2]];var User=require(_0xf7a0[3])[_0xf7a0[4]];var sequelize=require(_0xf7a0[3])[_0xf7a0[5]];var BPromise=require(_0xf7a0[6]);var util=require(_0xf7a0[7]);function handleError(_0x14c4x8,_0x14c4x9){console[_0xf7a0[9]](_0x14c4x9[_0xf7a0[8]]);return _0x14c4x8[_0xf7a0[11]](500)[_0xf7a0[10]](_0x14c4x9)}function responseWithResult(_0x14c4x8,_0x14c4xb){_0x14c4xb= _0x14c4xb|| 200;return function(_0x14c4xc){if(_0x14c4xc){_0x14c4x8[_0xf7a0[11]](_0x14c4xb)[_0xf7a0[12]](_0x14c4xc)}}}function handleEntityNotFound(_0x14c4x8){return function(_0x14c4xc){if(!_0x14c4xc){_0x14c4x8[_0xf7a0[11]](404)[_0xf7a0[13]]();return null};return _0x14c4xc}}function saveUpdates(_0x14c4xf){return function(_0x14c4xc){return _0x14c4xc[_0xf7a0[15]](_0x14c4xf)[_0xf7a0[14]](function(_0x14c4x10){return _0x14c4x10})}}function removeEntity(_0x14c4x8){return function(_0x14c4xc){if(_0x14c4xc){return _0x14c4xc[_0xf7a0[16]]()[_0xf7a0[14]](function(){_0x14c4x8[_0xf7a0[11]](204)[_0xf7a0[13]]()})}}}exports[_0xf7a0[17]]= function(_0x14c4x12,_0x14c4x8){return Action[_0xf7a0[19]]()[_0xf7a0[14]](responseWithResult(_0x14c4x8))[_0xf7a0[18]](function(_0x14c4x9){handleError(_0x14c4x8,_0x14c4x9)})};exports[_0xf7a0[20]]= function(_0x14c4x12,_0x14c4x8,_0x14c4x13){_0x14c4x12[_0xf7a0[22]][_0xf7a0[21]]= _0x14c4x12[_0xf7a0[24]][_0xf7a0[23]];_[_0xf7a0[26]](_0x14c4x12[_0xf7a0[22]],_0x14c4x12[_0xf7a0[25]]);return BPromise[_0xf7a0[34]]()[_0xf7a0[14]](function(){if(!_0x14c4x12[_0xf7a0[22]][_0xf7a0[27]]|| _[_0xf7a0[30]]([_0xf7a0[28],_0xf7a0[29]],_0x14c4x12[_0xf7a0[22]][_0xf7a0[27]])){switch(_0x14c4x12[_0xf7a0[22]][_0xf7a0[33]]){case _0xf7a0[31]:;case _0xf7a0[32]:return sendAction(_0x14c4x12,_0x14c4x8);default:return null}};return null})[_0xf7a0[14]](function(){return Action[_0xf7a0[20]](_0x14c4x12[_0xf7a0[22]],{body:_0x14c4x12[_0xf7a0[22]]})})[_0xf7a0[14]](function(_0x14c4x14){return _0x14c4x8[_0xf7a0[11]](201)[_0xf7a0[10]](_0x14c4x14)})[_0xf7a0[18]](function(_0x14c4x9){return handleError(_0x14c4x8,_0x14c4x9)})};function sendAction(_0x14c4x12,_0x14c4x8){return BPromise[_0xf7a0[34]]()[_0xf7a0[14]](function(){if(!_0x14c4x12[_0xf7a0[22]][_0xf7a0[35]]){return User[_0xf7a0[47]](_0x14c4x12[_0xf7a0[22]][_0xf7a0[46]])};return null})[_0xf7a0[14]](function(_0x14c4x16){if(!_0x14c4x16&&  !_0x14c4x12[_0xf7a0[22]][_0xf7a0[35]]){_0x14c4x8[_0xf7a0[11]](404)[_0xf7a0[13]]();return null};if(_0x14c4x16){_0x14c4x12[_0xf7a0[22]][_0xf7a0[35]]= _0x14c4x16[_0xf7a0[33]]};var _0x14c4x14;switch(_0x14c4x12[_0xf7a0[22]][_0xf7a0[33]]){case _0xf7a0[31]:_0x14c4x14= {message:_0xf7a0[36],agent:_0x14c4x12[_0xf7a0[22]][_0xf7a0[35]],action:{action:_0xf7a0[36],interface:util[_0xf7a0[39]](_0xf7a0[37],_0xf7a0[38],_0x14c4x12[_0xf7a0[22]][_0xf7a0[35]]),paused:true,reason:_0x14c4x12[_0xf7a0[22]][_0xf7a0[40]]|| _0x14c4x12[_0xf7a0[22]][_0xf7a0[41]]|| _0xf7a0[42]}};break;case _0xf7a0[32]:_0x14c4x14= {message:_0xf7a0[36],agent:_0x14c4x12[_0xf7a0[22]][_0xf7a0[35]],action:{action:_0xf7a0[36],interface:util[_0xf7a0[39]](_0xf7a0[37],_0xf7a0[38],_0x14c4x12[_0xf7a0[22]][_0xf7a0[35]]),paused:false}};break;default:};if(_0x14c4x14){return _0x14c4x12[_0xf7a0[45]][_0xf7a0[44]][_0xf7a0[43]][_0xf7a0[10]](_0x14c4x14)};return null})}