Built motion from commit a8d3a8d.|0.0.25
[motion.git] / server / api / trunk / trunk.controller.js
1 var _0x689d=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x54\x72\x75\x6E\x6B","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x56\x6F\x69\x63\x65\x45\x78\x74\x65\x6E\x73\x69\x6F\x6E","\x73\x65\x71\x75\x65\x6C\x69\x7A\x65","\x75\x74\x69\x6C","\x69\x6E\x64\x65\x78","\x6E\x61\x6D\x65","\x68\x6F\x73\x74","\x63\x6F\x6E\x74\x65\x78\x74","\x64\x65\x73\x63\x72\x69\x70\x74\x69\x6F\x6E","\x70\x65\x72\x5F\x70\x61\x67\x65","\x71\x75\x65\x72\x79","\x70\x61\x67\x65","\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","\x72\x6F\x6C\x65","\x73\x70\x6C\x69\x74","\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\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","\x74\x72\x75\x6E\x6B\x56\x61\x6C\x69\x64\x61\x74\x69\x6F\x6E","\x62\x6F\x64\x79","\x6C\x6F\x67","\x66\x69\x6E\x64\x41\x6C\x6C","\x63\x72\x65\x61\x74\x65","\x74\x72\x75\x6E\x6B\x73\x20\x66\x69\x6E\x64\x61\x6C\x6C","\x46\x69\x6E\x64\x69\x6E\x67\x20\x61\x70\x70\x20\x72\x6F\x77\x2E\x2E\x2E\x2E\x2E","\x6C\x65\x6E\x67\x74\x68","\x4D\x45\x53\x53\x41\x47\x45\x5F\x45\x58\x49\x53\x54\x5F\x54\x52\x55\x4E\x4B","\x74\x72\x75\x6E\x6B\x73\x20\x63\x72\x65\x61\x74\x65","\x75\x70\x64\x61\x74\x65","\x6D\x65\x72\x67\x65","\x63\x75\x74\x64\x69\x67\x69\x74\x73","\x6C\x69\x74\x65\x72\x61\x6C","\x73\x61\x76\x65","\x74\x72\x61\x6E\x73\x61\x63\x74\x69\x6F\x6E","\x64\x65\x73\x74\x72\x6F\x79","\x4D\x45\x53\x53\x41\x47\x45\x5F\x54\x52\x55\x4E\x4B\x5F\x4F\x55\x54\x42\x4F\x55\x4E\x44\x5F\x41\x53\x53\x4F\x43\x49\x41\x54\x45\x44","\x67\x65\x74\x56\x6F\x69\x63\x65\x45\x78\x74\x65\x6E\x73\x69\x6F\x6E\x73","\x62\x75\x6C\x6B\x44\x65\x73\x74\x72\x6F\x79","\x56\x6F\x69\x63\x65\x45\x78\x74\x65\x6E\x73\x69\x6F\x6E\x73"];_0x689d[0];var _=require(_0x689d[1]);var Trunk=require(_0x689d[3])[_0x689d[2]];var VoiceExtension=require(_0x689d[3])[_0x689d[4]];var sequelize=require(_0x689d[3])[_0x689d[5]];var util=require(_0x689d[6]);exports[_0x689d[7]]=function(_0xbcd2x6,_0xbcd2x7,_0xbcd2x8){var _0xbcd2x9=[_0x689d[8],_0x689d[9],_0x689d[10],_0x689d[11]];var _0xbcd2xa=_0xbcd2x6[_0x689d[13]][_0x689d[12]]?parseInt(_0xbcd2x6[_0x689d[13]][_0x689d[12]],10):100;var _0xbcd2xb=_0xbcd2x6[_0x689d[13]][_0x689d[14]]?parseInt(_0xbcd2x6[_0x689d[13]][_0x689d[14]],10):0;var _0xbcd2xc={where:{},limit:_0xbcd2xa,offset:_0xbcd2xb*_0xbcd2xa};_[_0x689d[30]](_0xbcd2x6[_0x689d[13]],function(_0xbcd2xd,_0xbcd2xe){switch(_0xbcd2xe){case _0x689d[12]:;case _0x689d[14]:break ;;case _0x689d[17]:_0xbcd2xc[_0x689d[15]]=util[_0x689d[20]](_0x689d[16],_0xbcd2x6[_0x689d[13]][_0x689d[17]],_0xbcd2x6[_0x689d[13]][_0x689d[18]]||_0x689d[19])||null;break ;;case _0x689d[18]:break ;;case _0x689d[26]:_0xbcd2xc[_0x689d[22]][_0x689d[21]]=[];_0xbcd2x9[_0x689d[25]](function(_0xbcd2xf){var _0xbcd2x10={};_0xbcd2x10[_0xbcd2xf]={$like:_0x689d[23]+_0xbcd2xd+_0x689d[23]};_0xbcd2xc[_0x689d[22]][_0x689d[21]][_0x689d[24]](_0xbcd2x10);});break ;;case _0x689d[27]:_0xbcd2xc[_0x689d[22]][_0x689d[27]]={$or:_0xbcd2xd[_0x689d[28]](/[\s,]+/)};break ;;default:_0xbcd2xc[_0x689d[22]][_0xbcd2xe]={$like:{}};_0xbcd2xc[_0x689d[22]][_0xbcd2xe][_0x689d[29]]=_0x689d[23]+_0xbcd2xd+_0x689d[23];;}});Trunk[_0x689d[44]](_0xbcd2xc)[_0x689d[43]](function(_0xbcd2x12){var _0xbcd2x13=Math[_0x689d[36]](_0xbcd2x12[_0x689d[35]]/_0xbcd2xa);var _0xbcd2x14=_0xbcd2x13>(_0xbcd2xc[_0x689d[37]]+1)?util[_0x689d[20]](_0x689d[38],_0xbcd2x6[_0x689d[39]],_0xbcd2x6[_0x689d[40]][_0x689d[9]],_0xbcd2x6[_0x689d[41]],_0xbcd2xb+1):null;var _0xbcd2x15=_0xbcd2xb>0?util[_0x689d[20]](_0x689d[38],_0xbcd2x6[_0x689d[39]],_0xbcd2x6[_0x689d[40]][_0x689d[9]],_0xbcd2x6[_0x689d[41]],_0xbcd2xb-1):null;_0xbcd2x7[_0x689d[33]](200)[_0x689d[32]]({count:_0xbcd2x12[_0x689d[35]],rows:_0xbcd2x12[_0x689d[42]],next_page:_0xbcd2x14,previous_page:_0xbcd2x15,total_pages:_0xbcd2x13});})[_0x689d[34]](function(_0xbcd2x11){_0xbcd2x7[_0x689d[33]](500)[_0x689d[32]]({error:_0x689d[31]})});};exports[_0x689d[45]]=function(_0xbcd2x6,_0xbcd2x7){Trunk[_0x689d[49]](_0xbcd2x6[_0x689d[48]][_0x689d[47]])[_0x689d[43]](function(_0xbcd2x16){if(!_0xbcd2x16){return _0xbcd2x7[_0x689d[46]](404)};return _0xbcd2x7[_0x689d[32]](_0xbcd2x16);})[_0x689d[34]](function(_0xbcd2x11){return handleError(_0xbcd2x7,_0xbcd2x11)})};exports[_0x689d[50]]=function(_0xbcd2x6,_0xbcd2x7){console[_0x689d[52]](_0xbcd2x6[_0x689d[51]]);Trunk[_0x689d[53]]({where:{name:_0xbcd2x6[_0x689d[51]][_0x689d[8]]}})[_0x689d[43]](function(_0xbcd2x17){if(!_0xbcd2x17){return _0xbcd2x7[_0x689d[46]](404)};return _0xbcd2x7[_0x689d[32]](_0xbcd2x17);})[_0x689d[34]](function(_0xbcd2x11){return handleError(_0xbcd2x7,_0xbcd2x11)});};exports[_0x689d[54]]=function(_0xbcd2x6,_0xbcd2x7){Trunk[_0x689d[53]]({where:{name:_0xbcd2x6[_0x689d[51]][_0x689d[8]]}})[_0x689d[43]](function(_0xbcd2x18){console[_0x689d[52]](_0xbcd2x18);console[_0x689d[52]](_0x689d[56]);if(!_0xbcd2x18){return _0xbcd2x7[_0x689d[46]](404)};if(_0xbcd2x18[_0x689d[57]]>0){return _0xbcd2x7[_0x689d[33]](500)[_0x689d[32]]({message:_0x689d[58]})};Trunk[_0x689d[54]](_0xbcd2x6[_0x689d[51]])[_0x689d[43]](function(_0xbcd2x16){return _0xbcd2x7[_0x689d[33]](201)[_0x689d[32]](_0xbcd2x16)})[_0x689d[34]](function(_0xbcd2x11){console[_0x689d[52]](_0x689d[59],_0xbcd2x11);return handleError(_0xbcd2x7,_0xbcd2x11);});})[_0x689d[34]](function(_0xbcd2x11){console[_0x689d[52]](_0x689d[55],_0xbcd2x11);return handleError(_0xbcd2x7,_0xbcd2x11);})};exports[_0x689d[60]]=function(_0xbcd2x6,_0xbcd2x7,_0xbcd2x8){Trunk[_0x689d[53]]({where:{name:_0xbcd2x6[_0x689d[51]][_0x689d[8]],id:{$ne:_0xbcd2x6[_0x689d[51]][_0x689d[47]]}}})[_0x689d[43]](function(_0xbcd2x18){console[_0x689d[52]](_0xbcd2x18);console[_0x689d[52]](_0x689d[56]);if(!_0xbcd2x18){return _0xbcd2x7[_0x689d[46]](404)};if(_0xbcd2x18[_0x689d[57]]>0){return _0xbcd2x7[_0x689d[33]](500)[_0x689d[32]]({message:_0x689d[58]})};if(_0xbcd2x6[_0x689d[51]][_0x689d[47]]){delete _0xbcd2x6[_0x689d[51]][_0x689d[47]]};Trunk[_0x689d[49]](_0xbcd2x6[_0x689d[48]][_0x689d[47]])[_0x689d[43]](function(_0xbcd2x16){if(!_0xbcd2x16){return _0xbcd2x7[_0x689d[46]](404)};var _0xbcd2x19=_[_0x689d[61]](_0xbcd2x16,_0xbcd2x6[_0x689d[51]]);return sequelize[_0x689d[65]](function(_0xbcd2x1a){return _0xbcd2x19[_0x689d[64]]({transaction:_0xbcd2x1a})[_0x689d[43]](function(_0xbcd2x16){return VoiceExtension[_0x689d[60]]({trunk:_0xbcd2x16[_0x689d[8]],cutdigits:sequelize[_0x689d[63]](_0x689d[62])},{where:{TrunkId:_0xbcd2x16[_0x689d[47]]}},{transaction:_0xbcd2x1a})[_0x689d[43]](function(){return _0xbcd2x7[_0x689d[33]](200)[_0x689d[32]](_0xbcd2x16)})})})[_0x689d[34]](function(_0xbcd2x11){return handleError(_0xbcd2x7,_0xbcd2x11)});})[_0x689d[34]](function(_0xbcd2x11){return _0xbcd2x8(_0xbcd2x11)});})[_0x689d[34]](function(_0xbcd2x11){return _0xbcd2x8(_0xbcd2x11)})};exports[_0x689d[66]]=function(_0xbcd2x6,_0xbcd2x7){Trunk[_0x689d[49]](_0xbcd2x6[_0x689d[48]][_0x689d[47]])[_0x689d[43]](function(_0xbcd2x16){if(!_0xbcd2x16){return _0xbcd2x7[_0x689d[46]](404)};_0xbcd2x16[_0x689d[68]]({where:{isApp:true}})[_0x689d[43]](function(_0xbcd2x1b){console[_0x689d[52]](_0xbcd2x1b[_0x689d[57]]);if(_0xbcd2x1b[_0x689d[57]]>0){return _0xbcd2x7[_0x689d[33]](500)[_0x689d[32]]({message:_0x689d[67]})};_0xbcd2x16[_0x689d[66]]()[_0x689d[43]](function(){return _0xbcd2x7[_0x689d[46]](204)})[_0x689d[34]](function(_0xbcd2x11){return handleError(_0xbcd2x7,_0xbcd2x11)});})[_0x689d[34]](function(_0xbcd2x11){return handleError(_0xbcd2x7,_0xbcd2x11)});})[_0x689d[34]](function(_0xbcd2x11){return handleError(_0xbcd2x7,_0xbcd2x11)})};exports[_0x689d[69]]=function(_0xbcd2x6,_0xbcd2x7){var _0xbcd2x1c=false;Trunk[_0x689d[53]]({where:{id:_0xbcd2x6[_0x689d[13]][_0x689d[47]]},include:[{all:true}]})[_0x689d[43]](function(_0xbcd2x17){if(!_0xbcd2x17){return _0xbcd2x7[_0x689d[46]](404)};_0xbcd2x17[_0x689d[25]](function(_0xbcd2x1d){if(_0xbcd2x1d[_0x689d[70]][_0x689d[57]]>0){_0xbcd2x1c=true}});if(_0xbcd2x1c){return _0xbcd2x7[_0x689d[33]](500)[_0x689d[32]]({message:_0x689d[67]})};Trunk[_0x689d[66]]({where:{id:_0xbcd2x6[_0x689d[13]][_0x689d[47]]},individualHooks:true})[_0x689d[43]](function(){return _0xbcd2x7[_0x689d[46]](204)})[_0x689d[34]](function(_0xbcd2x11){return handleError(_0xbcd2x7,_0xbcd2x11)});})[_0x689d[34]](function(_0xbcd2x11){return handleError(_0xbcd2x7,_0xbcd2x11)});};function handleError(_0xbcd2x7,_0xbcd2x11){return _0xbcd2x7[_0x689d[33]](500)[_0x689d[32]](_0xbcd2x11)}