Built motion from commit 05106a3.|0.0.33
[motion.git] / server / api / agent / agent.controller.js
1 var _0x6178=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x75\x74\x69\x6C","\x55\x73\x65\x72","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x54\x65\x61\x6D","\x69\x6E\x64\x65\x78","\x66\x75\x6C\x6C\x6E\x61\x6D\x65","\x6E\x61\x6D\x65","\x65\x6D\x61\x69\x6C","\x70\x65\x72\x5F\x70\x61\x67\x65","\x71\x75\x65\x72\x79","\x70\x61\x67\x65","\x61\x67\x65\x6E\x74","\x6F\x72\x64\x65\x72","\x25\x73\x20\x25\x73","\x73\x6F\x72\x74\x5F\x62\x79","\x73\x6F\x72\x74\x5F\x6F\x72\x64\x65\x72","\x41\x53\x43","\x66\x6F\x72\x6D\x61\x74","\x24\x6F\x72","\x77\x68\x65\x72\x65","\x25","\x70\x75\x73\x68","\x66\x6F\x72\x45\x61\x63\x68","\x24","\x24\x6C\x69\x6B\x65","\x66\x6F\x72\x49\x6E","\x53\x6F\x6D\x65\x74\x68\x69\x6E\x67\x20\x62\x6C\x65\x77\x20\x75\x70\x21","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x63\x61\x74\x63\x68","\x63\x6F\x75\x6E\x74","\x63\x65\x69\x6C","\x6F\x66\x66\x73\x65\x74","\x25\x73\x3A\x2F\x2F\x25\x73\x25\x73\x3F\x70\x61\x67\x65\x3D\x25\x64","\x70\x72\x6F\x74\x6F\x63\x6F\x6C","\x68\x6F\x73\x74","\x68\x65\x61\x64\x65\x72\x73","\x62\x61\x73\x65\x55\x72\x6C","\x72\x6F\x77\x73","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6E\x64\x43\x6F\x75\x6E\x74\x41\x6C\x6C","\x73\x68\x6F\x77","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x69\x6E\x74\x65\x72\x6E\x61\x6C\x56\x61\x6C\x69\x64\x61\x74\x69\x6F\x6E","\x69\x6E\x74\x65\x72\x6E\x61\x6C","\x62\x6F\x64\x79","\x66\x69\x6E\x64\x41\x6C\x6C","\x63\x72\x65\x61\x74\x65","\x6C\x6F\x67","\x61\x64\x64\x55\x73\x65\x72","\x66\x69\x6E\x64\x4F\x6E\x65","\x75\x70\x64\x61\x74\x65","\x6D\x65\x72\x67\x65","\x73\x61\x76\x65","\x64\x65\x73\x74\x72\x6F\x79","\x62\x75\x6C\x6B\x44\x65\x73\x74\x72\x6F\x79","\x63\x68\x61\x6E\x67\x65\x50\x61\x73\x73\x77\x6F\x72\x64","\x75\x73\x65\x72","\x6F\x6C\x64\x50\x61\x73\x73\x77\x6F\x72\x64","\x6E\x65\x77\x50\x61\x73\x73\x77\x6F\x72\x64","\x61\x75\x74\x68\x65\x6E\x74\x69\x63\x61\x74\x65","\x70\x61\x73\x73\x77\x6F\x72\x64","\x72\x65\x73\x65\x74\x50\x61\x73\x73\x77\x6F\x72\x64","\x61\x67\x65\x6E\x74\x56\x61\x6C\x69\x64\x61\x74\x69\x6F\x6E","\x66\x69\x65\x6C\x64","\x76\x61\x6C\x75\x65"];_0x6178[0];var _=require(_0x6178[1]);var util=require(_0x6178[2]);var Agent=require(_0x6178[4])[_0x6178[3]];var Team=require(_0x6178[4])[_0x6178[5]];exports[_0x6178[6]]=function(_0x57f2x5,_0x57f2x6,_0x57f2x7){var _0x57f2x8=[_0x6178[7],_0x6178[8],_0x6178[9]];var _0x57f2x9=_0x57f2x5[_0x6178[11]][_0x6178[10]]?parseInt(_0x57f2x5[_0x6178[11]][_0x6178[10]],10):100;var _0x57f2xa=_0x57f2x5[_0x6178[11]][_0x6178[12]]?parseInt(_0x57f2x5[_0x6178[11]][_0x6178[12]],10):0;var _0x57f2xb={where:{role:_0x6178[13]},limit:_0x57f2x9,offset:_0x57f2xa*_0x57f2x9};_[_0x6178[27]](_0x57f2x5[_0x6178[11]],function(_0x57f2xc,_0x57f2xd){switch(_0x57f2xd){case _0x6178[10]:;case _0x6178[12]:break ;;case _0x6178[16]:_0x57f2xb[_0x6178[14]]=util[_0x6178[19]](_0x6178[15],_0x57f2x5[_0x6178[11]][_0x6178[16]],_0x57f2x5[_0x6178[11]][_0x6178[17]]||_0x6178[18])||null;break ;;case _0x6178[17]:break ;;case _0x6178[25]:_0x57f2xb[_0x6178[21]][_0x6178[20]]=[];_0x57f2x8[_0x6178[24]](function(_0x57f2xe){var _0x57f2xf={};_0x57f2xf[_0x57f2xe]={$like:_0x6178[22]+_0x57f2xc+_0x6178[22]};_0x57f2xb[_0x6178[21]][_0x6178[20]][_0x6178[23]](_0x57f2xf);});break ;;default:_0x57f2xb[_0x6178[21]][_0x57f2xd]={$like:{}};_0x57f2xb[_0x6178[21]][_0x57f2xd][_0x6178[26]]=_0x6178[22]+_0x57f2xc+_0x6178[22];;}});Agent[_0x6178[42]](_0x57f2xb)[_0x6178[41]](function(_0x57f2x11){var _0x57f2x12=Math[_0x6178[33]](_0x57f2x11[_0x6178[32]]/_0x57f2x9);var _0x57f2x13=_0x57f2x12>(_0x57f2xb[_0x6178[34]]+1)?util[_0x6178[19]](_0x6178[35],_0x57f2x5[_0x6178[36]],_0x57f2x5[_0x6178[38]][_0x6178[37]],_0x57f2x5[_0x6178[39]],_0x57f2xa+1):null;var _0x57f2x14=_0x57f2xa>0?util[_0x6178[19]](_0x6178[35],_0x57f2x5[_0x6178[36]],_0x57f2x5[_0x6178[38]][_0x6178[37]],_0x57f2x5[_0x6178[39]],_0x57f2xa-1):null;_0x57f2x6[_0x6178[30]](200)[_0x6178[29]]({count:_0x57f2x11[_0x6178[32]],rows:_0x57f2x11[_0x6178[40]],next_page:_0x57f2x13,previous_page:_0x57f2x14,total_pages:_0x57f2x12});})[_0x6178[31]](function(_0x57f2x10){_0x57f2x6[_0x6178[30]](500)[_0x6178[29]]({error:_0x6178[28]})});};exports[_0x6178[43]]=function(_0x57f2x5,_0x57f2x6){Agent[_0x6178[47]](_0x57f2x5[_0x6178[46]][_0x6178[45]])[_0x6178[41]](function(_0x57f2x15){if(!_0x57f2x15){return _0x57f2x6[_0x6178[44]](404)};return _0x57f2x6[_0x6178[29]](_0x57f2x15);})[_0x6178[31]](function(_0x57f2x10){return handleError(_0x57f2x6,_0x57f2x10)})};exports[_0x6178[48]]=function(_0x57f2x5,_0x57f2x6){Agent[_0x6178[51]]({where:{internal:_0x57f2x5[_0x6178[50]][_0x6178[49]]}})[_0x6178[41]](function(_0x57f2x16){if(!_0x57f2x16){return _0x57f2x6[_0x6178[44]](404)};return _0x57f2x6[_0x6178[29]](_0x57f2x16);})[_0x6178[31]](function(_0x57f2x10){return handleError(_0x57f2x6,_0x57f2x10)})};exports[_0x6178[52]]=function(_0x57f2x5,_0x57f2x6){Agent[_0x6178[52]](_0x57f2x5[_0x6178[50]])[_0x6178[41]](function(_0x57f2x15){Team[_0x6178[55]]({where:{defaultEntry:true}})[_0x6178[41]](function(_0x57f2x17){_0x57f2x17[_0x6178[54]](_0x57f2x15[_0x6178[45]])[_0x6178[41]](function(){return _0x57f2x6[_0x6178[30]](201)[_0x6178[29]](_0x57f2x15)})[_0x6178[31]](function(_0x57f2x10){console[_0x6178[53]](_0x57f2x10);return handleError(_0x57f2x6,_0x57f2x10);})})[_0x6178[31]](function(_0x57f2x10){console[_0x6178[53]](_0x57f2x10);return handleError(_0x57f2x6,_0x57f2x10);})})[_0x6178[31]](function(_0x57f2x10){console[_0x6178[53]](_0x57f2x10);return handleError(_0x57f2x6,_0x57f2x10);})};exports[_0x6178[56]]=function(_0x57f2x5,_0x57f2x6){if(_0x57f2x5[_0x6178[50]][_0x6178[45]]){delete _0x57f2x5[_0x6178[50]][_0x6178[45]]};Agent[_0x6178[47]](_0x57f2x5[_0x6178[46]][_0x6178[45]])[_0x6178[41]](function(_0x57f2x15){if(!_0x57f2x15){return _0x57f2x6[_0x6178[44]](404)};var _0x57f2x18=_[_0x6178[57]](_0x57f2x15,_0x57f2x5[_0x6178[50]]);_0x57f2x18[_0x6178[58]]()[_0x6178[41]](function(){return _0x57f2x6[_0x6178[30]](200)[_0x6178[29]](_0x57f2x15)})[_0x6178[31]](function(_0x57f2x10){return handleError(_0x57f2x6,_0x57f2x10)});})[_0x6178[31]](function(_0x57f2x10){return handleError(_0x57f2x6,_0x57f2x10)});};exports[_0x6178[59]]=function(_0x57f2x5,_0x57f2x6){Agent[_0x6178[47]](_0x57f2x5[_0x6178[46]][_0x6178[45]])[_0x6178[41]](function(_0x57f2x15){if(!_0x57f2x15){return _0x57f2x6[_0x6178[44]](404)};_0x57f2x15[_0x6178[59]]()[_0x6178[41]](function(){return _0x57f2x6[_0x6178[44]](204)})[_0x6178[31]](function(_0x57f2x10){return handleError(_0x57f2x6,_0x57f2x10)});})[_0x6178[31]](function(_0x57f2x10){return handleError(_0x57f2x6,_0x57f2x10)})};exports[_0x6178[60]]=function(_0x57f2x5,_0x57f2x6){Agent[_0x6178[59]]({where:{id:_0x57f2x5[_0x6178[11]][_0x6178[45]]},individualHooks:true})[_0x6178[41]](function(){return _0x57f2x6[_0x6178[44]](204)})[_0x6178[31]](function(_0x57f2x10){return handleError(_0x57f2x6,_0x57f2x10)})};exports[_0x6178[61]]=function(_0x57f2x5,_0x57f2x6,_0x57f2x7){console[_0x6178[53]](_0x57f2x5[_0x6178[50]]);var _0x57f2x19=_0x57f2x5[_0x6178[62]][_0x6178[45]];var _0x57f2x1a=String(_0x57f2x5[_0x6178[50]][_0x6178[63]]);var _0x57f2x1b=String(_0x57f2x5[_0x6178[50]][_0x6178[64]]);Agent[_0x6178[47]](_0x57f2x19)[_0x6178[41]](function(_0x57f2x15){if(_0x57f2x15[_0x6178[65]](_0x57f2x1a)){_0x57f2x15[_0x6178[66]]=_0x57f2x1b;_0x57f2x15[_0x6178[58]]()[_0x6178[41]](function(){_0x57f2x6[_0x6178[30]](200)[_0x6178[29]](_0x57f2x15)})[_0x6178[31]](function(_0x57f2x10){return _0x57f2x7(_0x57f2x10)});}else {_0x57f2x6[_0x6178[44]](403)}});};exports[_0x6178[67]]=function(_0x57f2x5,_0x57f2x6,_0x57f2x7){var _0x57f2x1b=String(_0x57f2x5[_0x6178[50]][_0x6178[64]]);Agent[_0x6178[47]](_0x57f2x5[_0x6178[46]][_0x6178[45]])[_0x6178[41]](function(_0x57f2x1c){_0x57f2x1c[_0x6178[66]]=_0x57f2x1b;_0x57f2x1c[_0x6178[58]]()[_0x6178[41]](function(){_0x57f2x6[_0x6178[30]](200)[_0x6178[29]](_0x57f2x1c)})[_0x6178[31]](function(_0x57f2x10){return handleError(_0x57f2x6,_0x57f2x10)});});};exports[_0x6178[68]]=function(_0x57f2x5,_0x57f2x6){var _0x57f2x1d={};_0x57f2x1d[_0x57f2x5[_0x6178[46]][_0x6178[69]]]=_0x57f2x5[_0x6178[50]][_0x6178[70]];Agent[_0x6178[42]]({where:_0x57f2x1d})[_0x6178[41]](function(_0x57f2x11){if(_0x57f2x11[_0x6178[32]]){return _0x57f2x6[_0x6178[30]](200)[_0x6178[29]]({isValid:false,value:_0x57f2x5[_0x6178[50]][_0x6178[70]]})};return _0x57f2x6[_0x6178[30]](200)[_0x6178[29]]({isValid:true,value:_0x57f2x5[_0x6178[50]][_0x6178[70]]});})[_0x6178[31]](function(_0x57f2x10){return handleError(_0x57f2x6,_0x57f2x10)});};function handleError(_0x57f2x6,_0x57f2x10){return _0x57f2x6[_0x6178[30]](500)[_0x6178[29]](_0x57f2x10)}