3de8185fca59eb92e6cb017d71de72cc38ebd1a8
[motion.git] / server / api / action / action.controller.js
1 var _0x641f=["\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","\x61\x70\x69","\x2E\x2E\x2F\x2E\x2E\x2F\x63\x6F\x6E\x66\x69\x67\x2F\x6C\x6F\x67\x67\x65\x72\x2E\x6A\x73","\x73\x74\x61\x63\x6B","\x65\x72\x72\x6F\x72","\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","\x71\x75\x65\x75\x65\x53\x74\x61\x74\x75\x73","\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"];_0x641f[0];var _=require(_0x641f[1]);var Action=require(_0x641f[3])[_0x641f[2]];var User=require(_0x641f[3])[_0x641f[4]];var sequelize=require(_0x641f[3])[_0x641f[5]];var BPromise=require(_0x641f[6]);var util=require(_0x641f[7]);var logger=require(_0x641f[9])(_0x641f[8]);function handleError(_0x50f4x9,_0x50f4xa){logger[_0x641f[11]](_0x50f4xa[_0x641f[10]]);return _0x50f4x9[_0x641f[13]](500)[_0x641f[12]](_0x50f4xa)}function responseWithResult(_0x50f4x9,_0x50f4xc){_0x50f4xc= _0x50f4xc|| 200;return function(_0x50f4xd){if(_0x50f4xd){_0x50f4x9[_0x641f[13]](_0x50f4xc)[_0x641f[14]](_0x50f4xd)}}}function handleEntityNotFound(_0x50f4x9){return function(_0x50f4xd){if(!_0x50f4xd){_0x50f4x9[_0x641f[13]](404)[_0x641f[15]]();return null};return _0x50f4xd}}function saveUpdates(_0x50f4x10){return function(_0x50f4xd){return _0x50f4xd[_0x641f[17]](_0x50f4x10)[_0x641f[16]](function(_0x50f4x11){return _0x50f4x11})}}function removeEntity(_0x50f4x9){return function(_0x50f4xd){if(_0x50f4xd){return _0x50f4xd[_0x641f[18]]()[_0x641f[16]](function(){_0x50f4x9[_0x641f[13]](204)[_0x641f[15]]()})}}}exports[_0x641f[19]]= function(_0x50f4x13,_0x50f4x9){return Action[_0x641f[21]]()[_0x641f[16]](responseWithResult(_0x50f4x9))[_0x641f[20]](function(_0x50f4xa){handleError(_0x50f4x9,_0x50f4xa)})};exports[_0x641f[22]]= function(_0x50f4x13,_0x50f4x9,_0x50f4x14){_0x50f4x13[_0x641f[24]][_0x641f[23]]= _0x50f4x13[_0x641f[26]][_0x641f[25]];_[_0x641f[28]](_0x50f4x13[_0x641f[24]],_0x50f4x13[_0x641f[27]]);return BPromise[_0x641f[36]]()[_0x641f[16]](function(){if(!_0x50f4x13[_0x641f[24]][_0x641f[29]]|| _[_0x641f[32]]([_0x641f[30],_0x641f[31]],_0x50f4x13[_0x641f[24]][_0x641f[29]])){switch(_0x50f4x13[_0x641f[24]][_0x641f[35]]){case _0x641f[33]:;case _0x641f[34]:return sendAction(_0x50f4x13,_0x50f4x9);default:return null}};return null})[_0x641f[16]](function(){return Action[_0x641f[22]](_0x50f4x13[_0x641f[24]],{body:_0x50f4x13[_0x641f[24]]})})[_0x641f[16]](function(_0x50f4x15){return _0x50f4x9[_0x641f[13]](201)[_0x641f[12]](_0x50f4x15)})[_0x641f[20]](function(_0x50f4xa){return handleError(_0x50f4x9,_0x50f4xa)})};function sendAction(_0x50f4x13,_0x50f4x9){return BPromise[_0x641f[36]]()[_0x641f[16]](function(){return User[_0x641f[50]](_0x50f4x13[_0x641f[24]][_0x641f[49]])})[_0x641f[16]](function(_0x50f4x17){if(!_0x50f4x17){_0x50f4x9[_0x641f[13]](404)[_0x641f[15]]();return null};_0x50f4x13[_0x641f[24]][_0x641f[37]]= _0x50f4x17[_0x641f[35]];var _0x50f4x15;switch(_0x50f4x13[_0x641f[24]][_0x641f[35]]){case _0x641f[33]:_0x50f4x15= {message:_0x641f[38],agent:_0x50f4x13[_0x641f[24]][_0x641f[37]],queueStatus:_0x50f4x17[_0x641f[39]],action:{action:_0x641f[38],interface:util[_0x641f[42]](_0x641f[40],_0x641f[41],_0x50f4x13[_0x641f[24]][_0x641f[37]]),paused:true,reason:_0x50f4x13[_0x641f[24]][_0x641f[43]]|| _0x50f4x13[_0x641f[24]][_0x641f[44]]|| _0x641f[45]}};break;case _0x641f[34]:_0x50f4x15= {message:_0x641f[38],agent:_0x50f4x13[_0x641f[24]][_0x641f[37]],queueStatus:_0x50f4x17[_0x641f[39]],action:{action:_0x641f[38],interface:util[_0x641f[42]](_0x641f[40],_0x641f[41],_0x50f4x13[_0x641f[24]][_0x641f[37]]),paused:false}};break;default:};if(_0x50f4x15){return _0x50f4x13[_0x641f[48]][_0x641f[47]][_0x641f[46]][_0x641f[12]](_0x50f4x15)};return null})}