Built motion from commit 67e5df37.|2.0.60
[motion2.git] / server / api / faxAccount / faxAccount.rpc.js
1 var _0x89f9=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x75\x74\x69\x6C","\x6D\x6F\x6D\x65\x6E\x74","\x62\x6C\x75\x65\x62\x69\x72\x64","\x72\x61\x6E\x64\x6F\x6D\x73\x74\x72\x69\x6E\x67","\x66\x73","\x64\x62","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x79\x73\x71\x6C\x64\x62","\x2E\x2E\x2F\x2E\x2E\x2F\x63\x6F\x6E\x66\x69\x67\x2F\x75\x74\x69\x6C\x73","\x72\x70\x63","\x2E\x2E\x2F\x2E\x2E\x2F\x63\x6F\x6E\x66\x69\x67\x2F\x6C\x6F\x67\x67\x65\x72","\x2E\x2E\x2F\x2E\x2E\x2F\x63\x6F\x6E\x66\x69\x67\x2F\x65\x6E\x76\x69\x72\x6F\x6E\x6D\x65\x6E\x74","\x6A\x61\x79\x73\x6F\x6E\x2F\x70\x72\x6F\x6D\x69\x73\x65","\x68\x74\x74\x70","\x63\x6C\x69\x65\x6E\x74","\x46\x61\x78\x41\x63\x63\x6F\x75\x6E\x74\x2C\x20\x25\x73\x2C\x20\x25\x73","\x65\x72\x72\x6F\x72","\x63\x61\x74\x63\x68","\x72\x65\x71\x75\x65\x73\x74\x20\x73\x65\x6E\x74","\x69\x6E\x66\x6F","\x46\x61\x78\x41\x63\x63\x6F\x75\x6E\x74\x2C\x20\x25\x73\x2C\x20\x25\x73\x2C\x20\x25\x73","\x73\x74\x72\x69\x6E\x67\x69\x66\x79","\x64\x65\x62\x75\x67","\x63\x6F\x64\x65","\x6D\x65\x73\x73\x61\x67\x65","\x72\x65\x73\x75\x6C\x74","\x74\x68\x65\x6E","\x72\x65\x71\x75\x65\x73\x74","\x47\x65\x74\x46\x61\x78\x41\x63\x63\x6F\x75\x6E\x74","\x6F\x70\x74\x69\x6F\x6E\x73","\x72\x61\x77","\x77\x68\x65\x72\x65","\x61\x74\x74\x72\x69\x62\x75\x74\x65\x73","\x6C\x69\x6D\x69\x74","\x69\x6E\x63\x6C\x75\x64\x65","\x6D\x6F\x64\x65\x6C","\x61\x73","\x6D\x61\x70","\x66\x69\x6E\x64\x41\x6C\x6C","\x46\x61\x78\x41\x63\x63\x6F\x75\x6E\x74","\x4E\x6F\x74\x69\x66\x79\x46\x61\x78\x41\x63\x63\x6F\x75\x6E\x74","\x62\x6F\x64\x79","\x66\x61\x78","\x55\x73\x65\x72\x49\x64","\x69\x6E\x74\x65\x72\x61\x63\x74\x69\x6F\x6E","\x61\x67\x65\x6E\x74","\x6E\x61\x6D\x65","\x2C","\x77\x61\x69\x74\x46\x6F\x72\x54\x68\x65\x41\x73\x73\x69\x67\x6E\x65\x64\x41\x67\x65\x6E\x74","\x61\x63\x63\x6F\x75\x6E\x74","\x2A\x2C\x2A\x2C\x2A\x2C\x2A","\x75\x6E\x73\x68\x69\x66\x74","\x61\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x73","\x53\x74\x61\x72\x74","\x73\x74\x61\x72\x74\x52\x6F\x75\x74\x69\x6E\x67","\x69\x64","\x66\x69\x6E\x64","\x55\x73\x65\x72","\x67\x65\x74","\x61\x75\x74\x6F\x63\x6C\x6F\x73\x65","\x6C\x65\x6E\x67\x74\x68","\x63\x6C\x6F\x73\x65","\x75\x6E\x6D\x61\x6E\x61\x67\x65\x64","\x70\x75\x73\x68","\x63\x72\x65\x61\x74\x65\x64","\x69\x6E","\x43\x6F\x6E\x74\x61\x63\x74\x49\x64","\x41\x74\x74\x61\x63\x68\x6D\x65\x6E\x74\x49\x64","\x63\x72\x65\x61\x74\x65","\x46\x61\x78\x4D\x65\x73\x73\x61\x67\x65","\x73\x70\x72\x65\x61\x64","\x63\x6F\x6E\x74\x61\x63\x74","\x46\x61\x78\x49\x6E\x74\x65\x72\x61\x63\x74\x69\x6F\x6E","\x43\x6F\x6E\x74\x61\x63\x74\x20\x6E\x6F\x74\x20\x66\x6F\x75\x6E\x64","\x4C\x69\x73\x74","\x41\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E\x73","\x6F\x6D\x69\x74","\x6C\x69\x73\x74","\x70\x72\x69\x6F\x72\x69\x74\x79","\x61\x73\x63","\x6F\x72\x64\x65\x72\x42\x79","\x43\x6F\x6E\x74\x61\x63\x74\x73","\x66\x72\x6F\x6D","\x4C\x69\x73\x74\x49\x64","\x64\x65\x66\x61\x75\x6C\x74\x73","\x6D\x61\x70\x4B\x65\x79","\x43\x6D\x43\x6F\x6E\x74\x61\x63\x74","\x43\x6D\x4C\x69\x73\x74","\x75\x70\x64\x61\x74\x65\x64\x41\x74","\x44\x45\x53\x43","\x46\x61\x78\x41\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E","\x6E\x6F\x20\x61\x76\x61\x69\x6C\x61\x62\x6C\x65\x20\x61\x74\x74\x72\x69\x62\x75\x74\x65\x73","\x53\x65\x71\x75\x65\x6C\x69\x7A\x65","\x6B\x65\x79\x73","\x63\x72\x65\x61\x74\x65\x64\x41\x74","\x64\x69\x66\x66\x65\x72\x65\x6E\x63\x65","\x43\x6F\x6D\x70\x61\x6E\x79\x49\x64","\x69\x73\x4E\x69\x6C","\x66\x72\x6F\x6D\x20\x69\x73\x20\x6D\x61\x6E\x64\x61\x74\x6F\x72\x79","","\x62\x6F\x64\x79\x20\x69\x73\x20\x6D\x61\x6E\x64\x61\x74\x6F\x72\x79\x20\x61\x6E\x64\x20\x6E\x6F\x74\x20\x65\x6D\x70\x74\x79","\x6D\x61\x70\x4B\x65\x79\x20\x69\x73\x20\x6D\x61\x6E\x64\x61\x74\x6F\x72\x79\x2C\x20\x70\x6C\x65\x61\x73\x65\x20\x75\x73\x65\x20\x6F\x6E\x65\x20\x6F\x66\x20\x74\x68\x65\x73\x65\x3A\x20","\x69\x6E\x63\x6C\x75\x64\x65\x73","\x6D\x61\x70\x4B\x65\x79\x20\x69\x6E\x76\x61\x6C\x69\x64\x2C\x20\x70\x6C\x65\x61\x73\x65\x20\x75\x73\x65\x20\x6F\x6E\x65\x20\x6F\x66\x20\x74\x68\x65\x73\x65\x3A\x20","\x64\x65\x73\x63\x72\x69\x62\x65"];_0x89f9[0];var _=require(_0x89f9[1]);var util=require(_0x89f9[2]);var moment=require(_0x89f9[3]);var BPromise=require(_0x89f9[4]);var rs=require(_0x89f9[5]);var fs=require(_0x89f9[6]);var db=require(_0x89f9[8])[_0x89f9[7]];var utils=require(_0x89f9[9]);var logger=require(_0x89f9[11])(_0x89f9[10]);var config=require(_0x89f9[12]);var jayson=require(_0x89f9[13]);var client=jayson[_0x89f9[15]][_0x89f9[14]]({port:9004});function respondWithRpcPromise(_0xeeecxe,_0xeeecxf,_0xeeecx10){return  new BPromise(function(_0xeeecx11,_0xeeecx12){return client[_0x89f9[28]](_0xeeecxe,_0xeeecx10)[_0x89f9[27]](function(_0xeeecx14){logger[_0x89f9[20]](_0x89f9[16],_0xeeecxf,_0x89f9[19]);logger[_0x89f9[23]](_0x89f9[21],_0xeeecxf,_0x89f9[19],JSON[_0x89f9[22]](_0xeeecx14));if(_0xeeecx14[_0x89f9[17]]){if(_0xeeecx14[_0x89f9[17]][_0x89f9[24]]=== 500){logger[_0x89f9[17]](_0x89f9[16],_0xeeecxf,_0xeeecx14[_0x89f9[17]][_0x89f9[25]]);return _0xeeecx12(_0xeeecx14[_0x89f9[17]][_0x89f9[25]])};logger[_0x89f9[17]](_0x89f9[16],_0xeeecxf,_0xeeecx14[_0x89f9[17]][_0x89f9[25]]);return _0xeeecx11(_0xeeecx14[_0x89f9[17]][_0x89f9[25]])}else {logger[_0x89f9[20]](_0x89f9[16],_0xeeecxf,_0x89f9[19]);_0xeeecx11(_0xeeecx14[_0x89f9[26]][_0x89f9[25]])}})[_0x89f9[18]](function(_0xeeecx13){logger[_0x89f9[17]](_0x89f9[16],_0xeeecxf,_0xeeecx13);_0xeeecx12(_0xeeecx13)})})}exports[_0x89f9[29]]= function(_0xeeecx10){var _0xeeecx15=this;return  new Promise(function(_0xeeecx11,_0xeeecx12){return db[_0x89f9[40]][_0x89f9[39]]({raw:_0xeeecx10[_0x89f9[30]]?(_0xeeecx10[_0x89f9[30]][_0x89f9[31]]=== undefined)?true:false:true,where:_0xeeecx10[_0x89f9[30]]?_0xeeecx10[_0x89f9[30]][_0x89f9[32]]|| null:null,attributes:_0xeeecx10[_0x89f9[30]]?_0xeeecx10[_0x89f9[30]][_0x89f9[33]]|| null:null,limit:_0xeeecx10[_0x89f9[30]]?_0xeeecx10[_0x89f9[30]][_0x89f9[34]]|| null:null,include:_0xeeecx10[_0x89f9[30]]?(_0xeeecx10[_0x89f9[30]][_0x89f9[35]]?_[_0x89f9[38]](_0xeeecx10[_0x89f9[30]][_0x89f9[35]],function(_0xeeecx16){return {model:db[_0xeeecx16[_0x89f9[36]]],as:_0xeeecx16[_0x89f9[37]],attributes:_0xeeecx16[_0x89f9[33]],include:_0xeeecx16[_0x89f9[35]]?_[_0x89f9[38]](_0xeeecx16[_0x89f9[35]],function(_0xeeecx17){return {model:db[_0xeeecx17[_0x89f9[36]]],as:_0xeeecx17[_0x89f9[37]],attributes:_0xeeecx17[_0x89f9[33]],include:_0xeeecx17[_0x89f9[35]]?_[_0x89f9[38]](_0xeeecx17[_0x89f9[35]],function(_0xeeecx18){return {model:db[_0xeeecx18[_0x89f9[36]]],as:_0xeeecx18[_0x89f9[37]],attributes:_0xeeecx18[_0x89f9[33]]}}):[]}}):[]}}):[]):[]})[_0x89f9[27]](function(_0xeeecx14){logger[_0x89f9[20]](_0x89f9[29],_0xeeecx10);logger[_0x89f9[23]](_0x89f9[29],_0xeeecx10,JSON[_0x89f9[22]](_0xeeecx14));_0xeeecx11(_0xeeecx14)})[_0x89f9[18]](function(_0xeeecx13){logger[_0x89f9[17]](_0x89f9[29],_0xeeecx13[_0x89f9[25]],_0xeeecx10);_0xeeecx12(_0xeeecx15[_0x89f9[17]](500,_0xeeecx13[_0x89f9[25]]))})})};exports[_0x89f9[41]]= function(_0xeeecx10,_0xeeecx14,_0xeeecx19){var _0xeeecx15=this;return  new Promise(function(_0xeeecx11,_0xeeecx12){var _0xeeecx1a={body:_0xeeecx10[_0x89f9[42]],channel:_0x89f9[43]};var _0xeeecx1b=[];var _0xeeecx1c=[];var _0xeeecx1d={};return db[_0x89f9[87]][_0x89f9[105]]()[_0x89f9[27]](function(_0xeeecx25){if(!_0xeeecx25){throw  new db[_0x89f9[93]].ValidationError(_0x89f9[92])};_0xeeecx1b= _[_0x89f9[96]](_[_0x89f9[94]](_0xeeecx25),[_0x89f9[95],_0x89f9[89]]);_0xeeecx1c= _[_0x89f9[96]](_[_0x89f9[94]](_0xeeecx25),[_0x89f9[95],_0x89f9[89],_0x89f9[97],_0x89f9[84]]);if(_0xeeecx10[_0x89f9[42]][_0x89f9[56]]){delete _0xeeecx10[_0x89f9[42]][_0x89f9[56]]};if(_[_0x89f9[98]](_0xeeecx10[_0x89f9[42]][_0x89f9[83]])){throw  new db[_0x89f9[93]].ValidationError(_0x89f9[99])};if(_[_0x89f9[98]](_0xeeecx10[_0x89f9[42]][_0x89f9[42]])|| _0xeeecx10[_0x89f9[42]][_0x89f9[42]]=== _0x89f9[100]){throw  new db[_0x89f9[93]].ValidationError(_0x89f9[101])};if(_[_0x89f9[98]](_0xeeecx10[_0x89f9[42]][_0x89f9[86]])){throw  new db[_0x89f9[93]].ValidationError(_0x89f9[102]+ _0xeeecx1c)};if(!_[_0x89f9[103]](_0xeeecx1c,_0xeeecx10[_0x89f9[42]][_0x89f9[86]])){throw  new db[_0x89f9[93]].ValidationError(_0x89f9[104]+ _0xeeecx1c)};_0xeeecx1d[_0xeeecx10[_0x89f9[42]][_0x89f9[86]]]= _0xeeecx10[_0x89f9[42]][_0x89f9[83]]})[_0x89f9[27]](function(){return db[_0x89f9[40]][_0x89f9[57]]({where:{id:_0xeeecx10[_0x89f9[50]][_0x89f9[56]]},include:[{model:db[_0x89f9[88]],as:_0x89f9[75],include:[{model:db[_0x89f9[87]],as:_0x89f9[82],where:_0xeeecx1d,limit:1,order:[[_0x89f9[89],_0x89f9[90]]]}]},{model:db[_0x89f9[91]],as:_0x89f9[76]}]})})[_0x89f9[27]](function(_0xeeecx1e){if(_0xeeecx1e&& _0xeeecx1e[_0x89f9[75]]){var _0xeeecx23=_0xeeecx1e[_0x89f9[59]]({plain:true});_0xeeecx1a[_0x89f9[50]]= _[_0x89f9[77]](_0xeeecx23,[_0x89f9[76],_0x89f9[75]]);_0xeeecx1a[_0x89f9[53]]= _0xeeecx23[_0x89f9[76]];_0xeeecx1a[_0x89f9[78]]= _0xeeecx23[_0x89f9[75]];_0xeeecx1a[_0x89f9[53]]= _[_0x89f9[81]](_0xeeecx1a[_0x89f9[53]],[_0x89f9[79]],[_0x89f9[80]]);if(_0xeeecx1a[_0x89f9[50]][_0x89f9[76]]){delete _0xeeecx1a[_0x89f9[50]][_0x89f9[76]]};if(_0xeeecx1a[_0x89f9[50]][_0x89f9[75]]&& _0xeeecx1a[_0x89f9[50]][_0x89f9[75]][_0x89f9[82]][_0x89f9[61]]){return _0xeeecx1a[_0x89f9[50]][_0x89f9[75]][_0x89f9[82]][0]};var _0xeeecx24=_[_0x89f9[85]](_0xeeecx10[_0x89f9[42]],{firstName:_0xeeecx10[_0x89f9[42]][_0x89f9[83]],phone:_0xeeecx10[_0x89f9[42]][_0x89f9[83]],ListId:_0xeeecx23[_0x89f9[84]]});_0xeeecx24[_0xeeecx10[_0x89f9[42]][_0x89f9[86]]]= _0xeeecx10[_0x89f9[42]][_0x89f9[83]];return db[_0x89f9[87]][_0x89f9[69]](_0xeeecx24,{fields:_0xeeecx1b,raw:true})}})[_0x89f9[27]](function(_0xeeecx1e){_0xeeecx1a[_0x89f9[72]]= _0xeeecx1e;if(_0xeeecx1e){var _0xeeecx22={ContactId:_0xeeecx1e[_0x89f9[56]],FaxAccountId:_0xeeecx10[_0x89f9[50]][_0x89f9[56]],fax:_0xeeecx1e[_0x89f9[43]]};return db[_0x89f9[73]][_0x89f9[57]]({where:{ContactId:_0xeeecx1e[_0x89f9[56]],closed:false,FaxAccountId:_0xeeecx10[_0x89f9[50]][_0x89f9[56]]}})[_0x89f9[27]](function(_0xeeecx21){if(_0xeeecx21){return [_0xeeecx21,false]};return db[_0x89f9[73]][_0x89f9[69]](_0xeeecx22)[_0x89f9[27]](function(_0xeeecx21){return [_0xeeecx21,true]})})}else {throw  new Error(_0x89f9[74])}})[_0x89f9[71]](function(_0xeeecx1e,_0xeeecx20){var _0xeeecx21=_0xeeecx1e[_0x89f9[59]]({plain:true});if(_0xeeecx20){if(_0xeeecx1a[_0x89f9[50]][_0x89f9[60]]){_0xeeecx1a[_0x89f9[53]][_0x89f9[64]]({id:0,priority:_0xeeecx1a[_0x89f9[53]][_0x89f9[61]]+ 1,app:_0x89f9[62],appdata:_0x89f9[63],interval:_0x89f9[51]})};_0xeeecx21[_0x89f9[65]]= true};_0xeeecx1a[_0x89f9[45]]= _0xeeecx21;return db[_0x89f9[70]][_0x89f9[69]]({body:_0xeeecx10[_0x89f9[42]][_0x89f9[42]],FaxAccountId:_0xeeecx10[_0x89f9[50]][_0x89f9[56]],FaxInteractionId:_0xeeecx1e[_0x89f9[56]],direction:_0x89f9[66],ContactId:_0xeeecx1e[_0x89f9[67]],AttachmentId:_0xeeecx10[_0x89f9[42]][_0x89f9[68]]})})[_0x89f9[27]](function(_0xeeecx1e){_0xeeecx1a[_0x89f9[25]]= _0xeeecx1e;if(_0xeeecx1a[_0x89f9[45]][_0x89f9[44]]){return db[_0x89f9[58]][_0x89f9[57]]({attributes:[_0x89f9[56],_0x89f9[47]],where:{id:_0xeeecx1a[_0x89f9[45]][_0x89f9[44]]}})[_0x89f9[27]](function(_0xeeecx1f){if(_0xeeecx1f){_0xeeecx1a[_0x89f9[53]][_0x89f9[52]]({id:0,priority:0,app:_0x89f9[46],appdata:_0xeeecx1f[_0x89f9[47]]+ _0x89f9[48]+ (_0xeeecx1a[_0x89f9[50]][_0x89f9[49]]|| 10),interval:_0x89f9[51]})};return respondWithRpcPromise(_0x89f9[54],_0x89f9[55],_0xeeecx1a)})};return respondWithRpcPromise(_0x89f9[54],_0x89f9[55],_0xeeecx1a)})[_0x89f9[27]](function(_0xeeecx1e){_0xeeecx11(_0xeeecx1e)})[_0x89f9[18]](function(_0xeeecx13){_0xeeecx12(_0xeeecx15[_0x89f9[17]](500,_0xeeecx13[_0x89f9[25]]))})})}