Built motion from commit 20e1a16.|0.0.54
[motion.git] / server / api / fax_account / fax_account.controller.js
1 var _0x6b48=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x75\x74\x69\x6C","\x61\x73\x79\x6E\x63","\x54\x72\x75\x6E\x6B","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x46\x61\x78\x41\x63\x63\x6F\x75\x6E\x74","\x46\x61\x78\x41\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E","\x56\x6F\x69\x63\x65\x45\x78\x74\x65\x6E\x73\x69\x6F\x6E","\x73\x65\x71\x75\x65\x6C\x69\x7A\x65","\x69\x6E\x64\x65\x78","\x64\x65\x73\x63\x72\x69\x70\x74\x69\x6F\x6E","\x6E\x61\x6D\x65","\x70\x68\x6F\x6E\x65","\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","\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","\x63\x72\x65\x61\x74\x65","\x62\x6F\x64\x79","\x63\x6F\x6E\x74\x65\x78\x74","\x47\x6F\x74\x6F","\x69\x6E\x62\x6F\x75\x6E\x64\x2D\x66\x61\x78\x2C\x73\x2C\x31","\x69\x6E\x62\x6F\x75\x6E\x64\x2D\x66\x61\x78","\x6C\x6F\x67","\x72\x6F\x6C\x6C\x62\x61\x63\x6B","\x6F\x6B","\x63\x6F\x6D\x6D\x69\x74","\x77\x61\x74\x65\x72\x66\x61\x6C\x6C","\x74\x72\x61\x6E\x73\x61\x63\x74\x69\x6F\x6E","\x75\x70\x64\x61\x74\x65","\x66\x69\x6E\x64\x4F\x6E\x65","\x75\x70\x64\x61\x74\x65\x41\x74\x74\x72\x69\x62\x75\x74\x65\x73","\x76\x6F\x69\x63\x65\x45\x78\x74\x65\x6E\x73\x69\x6F\x6E\x20\x65\x64\x69\x74\x65\x64","\x55\x73\x65\x72\x49\x64","\x6D\x65\x72\x67\x65","\x66\x61\x78\x41\x63\x63\x6F\x75\x6E\x74\x20\x73\x61\x76\x65\x64","\x73\x61\x76\x65","\x64\x65\x73\x74\x72\x6F\x79","\x66\x69\x6E\x64","\x61\x64\x64\x41\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x73","\x6C\x65\x6E\x67\x74\x68","\x61\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x73","\x70\x72\x69\x6F\x72\x69\x74\x79","\x64\x61\x74\x61\x56\x61\x6C\x75\x65\x73","\x62\x75\x6C\x6B\x43\x72\x65\x61\x74\x65","\x66\x69\x6E\x64\x41\x6C\x6C","\x62\x75\x6C\x6B\x44\x65\x73\x74\x72\x6F\x79"];_0x6b48[0];var _=require(_0x6b48[1]);var util=require(_0x6b48[2]);var async=require(_0x6b48[3]);var Trunk=require(_0x6b48[5])[_0x6b48[4]];var FaxAccount=require(_0x6b48[5])[_0x6b48[6]];var FaxApplication=require(_0x6b48[5])[_0x6b48[7]];var VoiceExtension=require(_0x6b48[5])[_0x6b48[8]];var sequelize=require(_0x6b48[5])[_0x6b48[9]];exports[_0x6b48[10]]=function(_0x1b51x9,_0x1b51xa,_0x1b51xb){var _0x1b51xc=[_0x6b48[11],_0x6b48[12],_0x6b48[13]];var _0x1b51xd=_0x1b51x9[_0x6b48[15]][_0x6b48[14]]?parseInt(_0x1b51x9[_0x6b48[15]][_0x6b48[14]],10):100;var _0x1b51xe=_0x1b51x9[_0x6b48[15]][_0x6b48[16]]?parseInt(_0x1b51x9[_0x6b48[15]][_0x6b48[16]],10):0;var _0x1b51xf={where:{},limit:_0x1b51xd,offset:_0x1b51xe*_0x1b51xd};_[_0x6b48[30]](_0x1b51x9[_0x6b48[15]],function(_0x1b51x10,_0x1b51x11){switch(_0x1b51x11){case _0x6b48[14]:;case _0x6b48[16]:break;case _0x6b48[19]:_0x1b51xf[_0x6b48[17]]=util[_0x6b48[22]](_0x6b48[18],_0x1b51x9[_0x6b48[15]][_0x6b48[19]],_0x1b51x9[_0x6b48[15]][_0x6b48[20]]||_0x6b48[21])||null;break;case _0x6b48[20]:break;case _0x6b48[28]:_0x1b51xf[_0x6b48[24]][_0x6b48[23]]=[];_0x1b51xc[_0x6b48[27]](function(_0x1b51x12){var _0x1b51x13={};_0x1b51x13[_0x1b51x12]={$like:_0x6b48[25]+_0x1b51x10+_0x6b48[25]};_0x1b51xf[_0x6b48[24]][_0x6b48[23]][_0x6b48[26]](_0x1b51x13)});break;default:_0x1b51xf[_0x6b48[24]][_0x1b51x11]={$like:{}};_0x1b51xf[_0x6b48[24]][_0x1b51x11][_0x6b48[29]]=_0x6b48[25]+_0x1b51x10+_0x6b48[25]}});FaxAccount[_0x6b48[45]](_0x1b51xf)[_0x6b48[44]](function(_0x1b51x15){var _0x1b51x16=Math[_0x6b48[36]](_0x1b51x15[_0x6b48[35]]/_0x1b51xd);var _0x1b51x17=_0x1b51x16>(_0x1b51xf[_0x6b48[37]]+1)?util[_0x6b48[22]](_0x6b48[38],_0x1b51x9[_0x6b48[39]],_0x1b51x9[_0x6b48[41]][_0x6b48[40]],_0x1b51x9[_0x6b48[42]],_0x1b51xe+1):null;var _0x1b51x18=_0x1b51xe>0?util[_0x6b48[22]](_0x6b48[38],_0x1b51x9[_0x6b48[39]],_0x1b51x9[_0x6b48[41]][_0x6b48[40]],_0x1b51x9[_0x6b48[42]],_0x1b51xe-1):null;_0x1b51xa[_0x6b48[33]](200)[_0x6b48[32]]({count:_0x1b51x15[_0x6b48[35]],rows:_0x1b51x15[_0x6b48[43]],next_page:_0x1b51x17,previous_page:_0x1b51x18,total_pages:_0x1b51x16})})[_0x6b48[34]](function(_0x1b51x14){_0x1b51xa[_0x6b48[33]](500)[_0x6b48[32]]({error:_0x6b48[31]})})};exports[_0x6b48[46]]=function(_0x1b51x9,_0x1b51xa,_0x1b51xb){FaxAccount[_0x6b48[50]](_0x1b51x9[_0x6b48[49]][_0x6b48[48]])[_0x6b48[44]](function(_0x1b51x19){if(!_0x1b51x19){return _0x1b51xa[_0x6b48[47]](404)};return _0x1b51xa[_0x6b48[32]](_0x1b51x19)})[_0x6b48[34]](function(_0x1b51x14){return _0x1b51xb(_0x1b51x14)})};exports[_0x6b48[51]]=function(_0x1b51x9,_0x1b51xa,_0x1b51xb){return sequelize[_0x6b48[62]]()[_0x6b48[44]](function(_0x1b51x1a){async[_0x6b48[61]]([function(_0x1b51x1b){return FaxAccount[_0x6b48[51]](_0x1b51x9[_0x6b48[52]],{transaction:_0x1b51x1a})[_0x6b48[44]](function(_0x1b51x19){_0x1b51x1b(null,_0x1b51x19)})[_0x6b48[34]](function(_0x1b51x14){_0x1b51x1b(_0x1b51x14)})},function(_0x1b51x19,_0x1b51x1b){return Trunk[_0x6b48[50]](_0x1b51x9[_0x6b48[52]].TrunkId,{transaction:_0x1b51x1a})[_0x6b48[44]](function(_0x1b51x1c){_0x1b51x1b(null,_0x1b51x19,_0x1b51x1c)})[_0x6b48[34]](function(_0x1b51x14){_0x1b51x1b(_0x1b51x14)})},function(_0x1b51x19,_0x1b51x1c,_0x1b51x1b){return VoiceExtension[_0x6b48[51]]({context:_0x1b51x1c[_0x6b48[53]],exten:_0x1b51x9[_0x6b48[52]][_0x6b48[13]],priority:1,app:_0x6b48[54],appdata:_0x6b48[55],type:_0x6b48[56],TrunkId:_0x1b51x1c[_0x6b48[48]]},{transaction:_0x1b51x1a})[_0x6b48[44]](function(_0x1b51x1d){_0x1b51x1b(null,_0x1b51x19)})[_0x6b48[34]](function(_0x1b51x14){_0x1b51x1b(_0x1b51x14)})}],function(_0x1b51x14,_0x1b51x19){if(_0x1b51x14){console[_0x6b48[57]](_0x1b51x14);_0x1b51x1a[_0x6b48[58]]();return _0x1b51xa[_0x6b48[33]](404)[_0x6b48[32]](_0x1b51x14)}else {console[_0x6b48[57]](_0x6b48[59]);_0x1b51x1a[_0x6b48[60]]();return _0x1b51xa[_0x6b48[33]](201)[_0x6b48[32]](_0x1b51x19)}})})};exports[_0x6b48[63]]=function(_0x1b51x9,_0x1b51xa,_0x1b51xb){if(_0x1b51x9[_0x6b48[52]][_0x6b48[48]]){delete _0x1b51x9[_0x6b48[52]][_0x6b48[48]]};return sequelize[_0x6b48[62]]()[_0x6b48[44]](function(_0x1b51x1a){async[_0x6b48[61]]([function(_0x1b51x1b){return FaxAccount[_0x6b48[64]]({where:{id:_0x1b51x9[_0x6b48[49]][_0x6b48[48]]},include:[{model:Trunk}]},{transaction:_0x1b51x1a})[_0x6b48[44]](function(_0x1b51x19){_0x1b51x1b(null,_0x1b51x19)})[_0x6b48[34]](function(_0x1b51x14){_0x1b51x1b(_0x1b51x14)})},function(_0x1b51x19,_0x1b51x1b){return Trunk[_0x6b48[50]](_0x1b51x9[_0x6b48[52]].TrunkId,{transaction:_0x1b51x1a})[_0x6b48[44]](function(_0x1b51x1e){return _0x1b51x19[_0x6b48[65]]({TrunkId:_0x1b51x1e[_0x6b48[48]]},{transaction:_0x1b51x1a})[_0x6b48[44]](function(_0x1b51x1f){_0x1b51x1b(null,_0x1b51x19,_0x1b51x1e)})[_0x6b48[34]](function(_0x1b51x14){_0x1b51x1b(_0x1b51x14)})})[_0x6b48[34]](function(_0x1b51x14){_0x1b51x1b(_0x1b51x14)})},function(_0x1b51x19,_0x1b51x1e,_0x1b51x1b){return VoiceExtension[_0x6b48[64]]({where:{priority:1,exten:_0x1b51x19[_0x6b48[13]],context:_0x1b51x19[_0x6b48[4]][_0x6b48[53]]}},{transaction:_0x1b51x1a})[_0x6b48[44]](function(_0x1b51x1d){if(!_0x1b51x1d){_0x1b51x1b(null,_0x1b51x19)};return _0x1b51x1d[_0x6b48[65]]({exten:_0x1b51x9[_0x6b48[52]][_0x6b48[13]],context:_0x1b51x1e[_0x6b48[53]],TrunkId:_0x1b51x9[_0x6b48[52]][_0x6b48[67]]},{transaction:_0x1b51x1a})[_0x6b48[44]](function(){console[_0x6b48[57]](_0x6b48[66]);_0x1b51x1b(null,_0x1b51x19)})[_0x6b48[34]](function(_0x1b51x14){_0x1b51x1b(_0x1b51x14)})})[_0x6b48[34]](function(_0x1b51x14){_0x1b51x1b(_0x1b51x14)})},function(_0x1b51x19,_0x1b51x1b){var _0x1b51x20=_[_0x6b48[68]](_0x1b51x19,_0x1b51x9[_0x6b48[52]]);return _0x1b51x20[_0x6b48[70]]({transaction:_0x1b51x1a})[_0x6b48[44]](function(){console[_0x6b48[57]](_0x6b48[69]);_0x1b51x1b(null,_0x1b51x19)})[_0x6b48[34]](function(_0x1b51x14){_0x1b51x1b(_0x1b51x14)})}],function(_0x1b51x14,_0x1b51x19){if(_0x1b51x14){console[_0x6b48[57]](_0x1b51x14);_0x1b51x1a[_0x6b48[58]]();return _0x1b51xa[_0x6b48[33]](404)[_0x6b48[32]](_0x1b51x14)}else {console[_0x6b48[57]](_0x6b48[59]);_0x1b51x1a[_0x6b48[60]]();return _0x1b51xa[_0x6b48[33]](201)[_0x6b48[32]](_0x1b51x19)}})})};exports[_0x6b48[71]]=function(_0x1b51x9,_0x1b51xa,_0x1b51xb){FaxAccount[_0x6b48[72]]({where:{id:_0x1b51x9[_0x6b48[49]][_0x6b48[48]]}})[_0x6b48[44]](function(_0x1b51x19){if(!_0x1b51x19){return _0x1b51xa[_0x6b48[47]](404)};_0x1b51x19[_0x6b48[71]]()[_0x6b48[44]](function(){return _0x1b51xa[_0x6b48[47]](204)})[_0x6b48[34]](function(_0x1b51x14){_0x1b51xb(_0x1b51x14)})})[_0x6b48[34]](function(_0x1b51x14){_0x1b51xb(_0x1b51x14)})};exports[_0x6b48[73]]=function(_0x1b51x9,_0x1b51xa,_0x1b51xb){FaxApplication[_0x6b48[79]]({where:{id:_0x1b51x9[_0x6b48[52]][_0x6b48[75]]}})[_0x6b48[44]](function(_0x1b51x21){var _0x1b51x22=_0x1b51x21;return sequelize[_0x6b48[62]](function(_0x1b51x1a){return FaxApplication[_0x6b48[71]]({where:{id:_0x1b51x9[_0x6b48[52]][_0x6b48[75]]}},{transaction:_0x1b51x1a})[_0x6b48[44]](function(){var _0x1b51x23=[];for(var _0x1b51x24=0;_0x1b51x24<_0x1b51x9[_0x6b48[52]][_0x6b48[75]][_0x6b48[74]];_0x1b51x24++){var _0x1b51x25=_[_0x6b48[72]](_0x1b51x22,{"\x69\x64":_0x1b51x9[_0x6b48[52]][_0x6b48[75]][_0x1b51x24]});if(_0x1b51x25){_0x1b51x25[_0x6b48[76]]=_0x1b51x24+1;_0x1b51x23[_0x6b48[26]](_0x1b51x25[_0x6b48[77]])}};return FaxApplication[_0x6b48[78]](_0x1b51x23,{transaction:_0x1b51x1a})[_0x6b48[44]](function(_0x1b51x1f){return _0x1b51x1f})})})[_0x6b48[44]](function(_0x1b51x15){return _0x1b51xa[_0x6b48[33]](200)[_0x6b48[32]](_0x1b51x15)})[_0x6b48[34]](function(_0x1b51x14){return handleError(_0x1b51xa,_0x1b51x14)})})[_0x6b48[34]](function(_0x1b51x14){return _0x1b51xb(_0x1b51x14)})};exports[_0x6b48[80]]=function(_0x1b51x9,_0x1b51xa){FaxAccount[_0x6b48[71]]({where:{id:_0x1b51x9[_0x6b48[15]][_0x6b48[48]]},individualHooks:true})[_0x6b48[44]](function(){return _0x1b51xa[_0x6b48[47]](204)})[_0x6b48[34]](function(_0x1b51x14){return handleError(_0x1b51xa,_0x1b51x14)})};function handleError(_0x1b51xa,_0x1b51x14){return _0x1b51xa[_0x6b48[33]](500)[_0x6b48[32]](_0x1b51x14)}