60d0b87f71d691722aa29a747984ddbbf61aea44
[motion.git] / server / api / contact_manager / contact_manager.controller.js
1 var _0x7a09=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x43\x6F\x6E\x74\x61\x63\x74","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x43\x6F\x6E\x74\x61\x63\x74\x50\x68\x6F\x6E\x65","\x43\x6F\x6E\x74\x61\x63\x74\x45\x6D\x61\x69\x6C","\x43\x75\x73\x74\x6F\x6D\x46\x69\x65\x6C\x64","\x52\x65\x70\x6F\x72\x74\x43\x61\x6C\x6C","\x52\x65\x70\x6F\x72\x74\x43\x61\x6C\x6C\x48\x69\x73\x74\x6F\x72\x79","\x68\x69\x73\x74\x6F\x72\x79","\x52\x65\x70\x6F\x72\x74\x4D\x61\x69\x6C\x53\x65\x73\x73\x69\x6F\x6E","\x52\x65\x70\x6F\x72\x74\x4D\x61\x69\x6C\x53\x65\x73\x73\x69\x6F\x6E\x48\x69\x73\x74\x6F\x72\x79","\x54\x61\x67","\x73\x74\x72\x65\x61\x6D","\x73\x65\x71\x75\x65\x6C\x69\x7A\x65","\x75\x74\x69\x6C","\x69\x6E\x64\x65\x78","\x6E\x61\x6D\x65","\x73\x75\x72\x6E\x61\x6D\x65","\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","\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","\x6C\x6F\x67","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x50\x68\x6F\x6E\x65\x73","\x49\x6E\x62\x6F\x75\x6E\x64\x73","\x4F\x75\x74\x62\x6F\x75\x6E\x64\x73","\x48\x69\x73\x74\x6F\x72\x79\x49\x6E\x62\x6F\x75\x6E\x64\x73","\x48\x69\x73\x74\x6F\x72\x79\x4F\x75\x74\x62\x6F\x75\x6E\x64\x73","\x45\x6D\x61\x69\x6C\x73","\x49\x6E\x62\x6F\x75\x6E\x64\x4D\x65\x73\x73\x61\x67\x65\x73","\x4F\x75\x74\x62\x6F\x75\x6E\x64\x4D\x65\x73\x73\x61\x67\x65\x73","\x48\x69\x73\x74\x6F\x72\x79\x49\x6E\x62\x6F\x75\x6E\x64\x4D\x65\x73\x73\x61\x67\x65\x73","\x48\x69\x73\x74\x6F\x72\x79\x4F\x75\x74\x62\x6F\x75\x6E\x64\x4D\x65\x73\x73\x61\x67\x65\x73","\x43\x75\x73\x74\x6F\x6D\x46\x69\x65\x6C\x64\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x67\x65\x74\x48\x69\x73\x74\x6F\x72\x79","\x63\x6F\x6E\x74\x61\x63\x74\x56\x61\x6C\x69\x64\x61\x74\x69\x6F\x6E","\x70\x68\x6F\x6E\x65\x73","\x62\x6F\x64\x79","\x65\x6D\x61\x69\x6C\x73","\x66\x69\x6E\x64\x41\x6C\x6C","\x63\x72\x65\x61\x74\x65","\x73\x70\x72\x65\x61\x64","\x43\x6F\x6E\x74\x61\x63\x74\x48\x61\x73\x43\x75\x73\x74\x6F\x6D\x46\x69\x65\x6C\x64","\x73\x65\x74\x43\x75\x73\x74\x6F\x6D\x46\x69\x65\x6C\x64\x73","\x6B\x65\x79\x73","\x73\x65\x74\x45\x6D\x61\x69\x6C\x73","\x73\x65\x74\x50\x68\x6F\x6E\x65\x73","\x6D\x61\x70","\x63\x75\x73\x74\x6F\x6D\x46\x69\x65\x6C\x64\x73","\x63\x6C\x6F\x6E\x65","\x61\x6C\x6C","\x65\x6D\x61\x69\x6C","\x70\x6C\x75\x63\x6B","\x75\x6E\x69\x71","\x66\x69\x6E\x64\x4F\x72\x43\x72\x65\x61\x74\x65","\x64\x61\x74\x61\x56\x61\x6C\x75\x65\x73","\x74\x61\x67\x73","\x2C","\x73\x70\x6C\x69\x74","\x69\x6E\x63\x6C\x75\x64\x65\x73","\x6C\x65\x6E\x67\x74\x68","\x62\x75\x6C\x6B\x43\x72\x65\x61\x74\x65","\x55\x73\x65\x72\x49\x64","\x75\x73\x65\x72","\x70\x68\x6F\x6E\x65","\x75\x70\x64\x61\x74\x65","\x75\x70\x64\x61\x74\x65\x41\x74\x74\x72\x69\x62\x75\x74\x65\x73","\x64\x65\x73\x74\x72\x6F\x79","\x62\x75\x6C\x6B\x44\x65\x73\x74\x72\x6F\x79"];_0x7a09[0];var _=require(_0x7a09[1]);var Contact=require(_0x7a09[3])[_0x7a09[2]];var ContactPhone=require(_0x7a09[3])[_0x7a09[4]];var ContactEmail=require(_0x7a09[3])[_0x7a09[5]];var CustomField=require(_0x7a09[3])[_0x7a09[6]];var ReportCall=require(_0x7a09[3])[_0x7a09[7]];var ReportCallHistory=require(_0x7a09[3])[_0x7a09[9]][_0x7a09[8]];var ReportMailSession=require(_0x7a09[3])[_0x7a09[10]];var ReportMailSessionHistory=require(_0x7a09[3])[_0x7a09[9]][_0x7a09[11]];var Tag=require(_0x7a09[3])[_0x7a09[12]];var stream=require(_0x7a09[13]);var sequelize=require(_0x7a09[3])[_0x7a09[14]];var util=require(_0x7a09[15]);exports[_0x7a09[16]]=function(_0x8c6fxe,_0x8c6fxf){var _0x8c6fx10=[_0x7a09[17],_0x7a09[18],_0x7a09[19]];var _0x8c6fx11=_0x8c6fxe[_0x7a09[21]][_0x7a09[20]]?parseInt(_0x8c6fxe[_0x7a09[21]][_0x7a09[20]],10):100;var _0x8c6fx12=_0x8c6fxe[_0x7a09[21]][_0x7a09[22]]?parseInt(_0x8c6fxe[_0x7a09[21]][_0x7a09[22]],10):0;var _0x8c6fx13={where:{},limit:_0x8c6fx11,offset:_0x8c6fx12*_0x8c6fx11};_[_0x7a09[36]](_0x8c6fxe[_0x7a09[21]],function(_0x8c6fx14,_0x8c6fx15){switch(_0x8c6fx15){case _0x7a09[20]:;case _0x7a09[22]:break ;;case _0x7a09[25]:_0x8c6fx13[_0x7a09[23]]=util[_0x7a09[28]](_0x7a09[24],_0x8c6fxe[_0x7a09[21]][_0x7a09[25]],_0x8c6fxe[_0x7a09[21]][_0x7a09[26]]||_0x7a09[27])||null;break ;;case _0x7a09[26]:break ;;case _0x7a09[34]:_0x8c6fx13[_0x7a09[30]][_0x7a09[29]]=[];_0x8c6fx10[_0x7a09[33]](function(_0x8c6fx16){var _0x8c6fx17={};_0x8c6fx17[_0x8c6fx16]={$like:_0x7a09[31]+_0x8c6fx14+_0x7a09[31]};_0x8c6fx13[_0x7a09[30]][_0x7a09[29]][_0x7a09[32]](_0x8c6fx17);});break ;;default:_0x8c6fx13[_0x7a09[30]][_0x8c6fx15]={$like:{}};_0x8c6fx13[_0x7a09[30]][_0x8c6fx15][_0x7a09[35]]=_0x7a09[31]+_0x8c6fx14+_0x7a09[31];;}});Contact[_0x7a09[51]](_0x8c6fx13)[_0x7a09[50]](function(_0x8c6fx19){var _0x8c6fx1a=Math[_0x7a09[42]](_0x8c6fx19[_0x7a09[41]]/_0x8c6fx11);var _0x8c6fx1b=_0x8c6fx1a>(_0x8c6fx13[_0x7a09[43]]+1)?util[_0x7a09[28]](_0x7a09[44],_0x8c6fxe[_0x7a09[45]],_0x8c6fxe[_0x7a09[47]][_0x7a09[46]],_0x8c6fxe[_0x7a09[48]],_0x8c6fx12+1):null;var _0x8c6fx1c=_0x8c6fx12>0?util[_0x7a09[28]](_0x7a09[44],_0x8c6fxe[_0x7a09[45]],_0x8c6fxe[_0x7a09[47]][_0x7a09[46]],_0x8c6fxe[_0x7a09[48]],_0x8c6fx12-1):null;_0x8c6fxf[_0x7a09[39]](200)[_0x7a09[38]]({count:_0x8c6fx19[_0x7a09[41]],rows:_0x8c6fx19[_0x7a09[49]],next_page:_0x8c6fx1b,previous_page:_0x8c6fx1c,total_pages:_0x8c6fx1a});})[_0x7a09[40]](function(_0x8c6fx18){_0x8c6fxf[_0x7a09[39]](500)[_0x7a09[38]]({error:_0x7a09[37]})});};exports[_0x7a09[52]]=function(_0x8c6fxe,_0x8c6fxf){Contact[_0x7a09[68]](_0x8c6fxe[_0x7a09[56]][_0x7a09[55]],{include:[{model:ContactPhone,as:_0x7a09[57],include:[{model:ReportCall,as:_0x7a09[58],include:[{all:true}]},{model:ReportCall,as:_0x7a09[59],include:[{all:true}]},{model:ReportCallHistory,as:_0x7a09[60],include:[{all:true}]},{model:ReportCallHistory,as:_0x7a09[61],include:[{all:true}]}]},{model:ContactEmail,as:_0x7a09[62],include:[{model:ReportMailSession,as:_0x7a09[63],include:[{all:true}]},{model:ReportMailSession,as:_0x7a09[64],include:[{all:true}]},{model:ReportMailSessionHistory,as:_0x7a09[65],include:[{all:true}]},{model:ReportMailSessionHistory,as:_0x7a09[66],include:[{all:true}]}]},{model:CustomField,as:_0x7a09[67]}]})[_0x7a09[50]](function(_0x8c6fx1d){if(!_0x8c6fx1d){return _0x8c6fxf[_0x7a09[54]](404)};return _0x8c6fxf[_0x7a09[38]](_0x8c6fx1d);})[_0x7a09[40]](function(_0x8c6fx18){console[_0x7a09[53]](_0x8c6fx18);return handleError(_0x8c6fxf,_0x8c6fx18);})};exports[_0x7a09[69]]=function(_0x8c6fxe,_0x8c6fxf){};exports[_0x7a09[70]]=function(_0x8c6fxe,_0x8c6fxf){Contact[_0x7a09[74]]({where:{$or:{"\x24\x50\x68\x6F\x6E\x65\x73\x2E\x70\x68\x6F\x6E\x65\x24":_0x8c6fxe[_0x7a09[72]][_0x7a09[71]],"\x24\x45\x6D\x61\x69\x6C\x73\x2E\x65\x6D\x61\x69\x6C\x24":_0x8c6fxe[_0x7a09[72]][_0x7a09[73]]}},include:[{all:true}]})[_0x7a09[50]](function(_0x8c6fx1e){console[_0x7a09[53]](_0x8c6fx1e);return _0x8c6fxf[_0x7a09[39]](200)[_0x7a09[38]](_0x8c6fx1e);})[_0x7a09[40]](function(_0x8c6fx18){console[_0x7a09[53]](_0x8c6fx18);return handleError(_0x8c6fxf,_0x8c6fx18);})};exports[_0x7a09[75]]=function(_0x8c6fxe,_0x8c6fxf,_0x8c6fx1f){var _0x8c6fx20=[],_0x8c6fx21=[],_0x8c6fx22={};Tag[_0x7a09[74]]()[_0x7a09[50]](function(_0x8c6fx29){var _0x8c6fx2a=[];var _0x8c6fx2b=_[_0x7a09[87]](_[_0x7a09[87]](_0x8c6fx29,_0x7a09[90]),_0x7a09[17]);if(_0x8c6fxe[_0x7a09[72]][_0x7a09[91]]){var _0x8c6fx2c=_0x8c6fxe[_0x7a09[72]][_0x7a09[91]][_0x7a09[93]](_0x7a09[92]);_0x8c6fx2c[_0x7a09[33]](function(_0x8c6fx25){if(!_[_0x7a09[94]](_0x8c6fx29,_0x8c6fx25)){_0x8c6fx2a[_0x7a09[32]]({name:_0x8c6fx25})}});if(_0x8c6fx2a[_0x7a09[95]]){Tag[_0x7a09[96]](_0x8c6fx2a,{individualHooks:true})};};_0x8c6fxe[_0x7a09[72]][_0x7a09[97]]=_0x8c6fxe[_0x7a09[98]][_0x7a09[55]];var _0x8c6fx2d=_[_0x7a09[88]](_[_0x7a09[87]](_0x8c6fxe[_0x7a09[72]].Phones,_0x7a09[99]));var _0x8c6fx2e=[];_0x8c6fx2d[_0x7a09[33]](function(_0x8c6fx25){_0x8c6fx2e[_0x7a09[32]](ContactPhone[_0x7a09[89]]({where:{phone:_0x8c6fx25},defaults:{phone:_0x8c6fx25}}))});return _0x8c6fx2e;})[_0x7a09[85]]()[_0x7a09[50]](function(_0x8c6fxf){_0x8c6fx20=_[_0x7a09[82]](_0x8c6fxf,function(_0x8c6fx25){return _0x8c6fx25[0]});var _0x8c6fx27=[];var _0x8c6fx28=_[_0x7a09[88]](_[_0x7a09[87]](_0x8c6fxe[_0x7a09[72]].Emails,_0x7a09[86]));_0x8c6fx28[_0x7a09[33]](function(_0x8c6fx25){_0x8c6fx27[_0x7a09[32]](ContactEmail[_0x7a09[89]]({where:{email:_0x8c6fx25},defaults:{email:_0x8c6fx25}}))});return _0x8c6fx27;})[_0x7a09[85]]()[_0x7a09[50]](function(_0x8c6fxf){_0x8c6fx21=_[_0x7a09[82]](_0x8c6fxf,function(_0x8c6fx25){return _0x8c6fx25[0]});delete _0x8c6fxe[_0x7a09[72]][_0x7a09[57]];delete _0x8c6fxe[_0x7a09[72]][_0x7a09[62]];_0x8c6fx22=_[_0x7a09[84]](_0x8c6fxe[_0x7a09[72]][_0x7a09[83]]);delete _0x8c6fxe[_0x7a09[72]][_0x7a09[83]];return Contact[_0x7a09[75]](_0x8c6fxe[_0x7a09[72]]);})[_0x7a09[50]](function(_0x8c6fx23){return [_0x8c6fx23,_0x8c6fx23[_0x7a09[81]](_0x8c6fx20)]})[_0x7a09[76]](function(_0x8c6fx23){return [_0x8c6fx23,_0x8c6fx23[_0x7a09[80]](_0x8c6fx21)]})[_0x7a09[76]](function(_0x8c6fx23){var _0x8c6fx26=_[_0x7a09[79]](_0x8c6fx22);return [_0x8c6fx23,CustomField[_0x7a09[74]]({where:{id:_0x8c6fx26}})];})[_0x7a09[76]](function(_0x8c6fx23,_0x8c6fx24){_0x8c6fx24[_0x7a09[33]](function(_0x8c6fx25){_0x8c6fx25[_0x7a09[77]]={value:_0x8c6fx22[String(_0x8c6fx25[_0x7a09[55]])]}});return [_0x8c6fx23,_0x8c6fx23[_0x7a09[78]](_0x8c6fx24)];})[_0x7a09[76]](function(_0x8c6fx23){return _0x8c6fxf[_0x7a09[39]](201)[_0x7a09[38]](_0x8c6fx23)})[_0x7a09[40]](function(_0x8c6fx18){console[_0x7a09[53]](_0x8c6fx18);return _0x8c6fx1f(_0x8c6fx18);});};exports[_0x7a09[100]]=function(_0x8c6fxe,_0x8c6fxf,_0x8c6fx1f){var _0x8c6fx20=[],_0x8c6fx21=[],_0x8c6fx22={};Tag[_0x7a09[74]]()[_0x7a09[50]](function(_0x8c6fx29){var _0x8c6fx2a=[];var _0x8c6fx2b=_[_0x7a09[87]](_[_0x7a09[87]](_0x8c6fx29,_0x7a09[90]),_0x7a09[17]);if(_0x8c6fxe[_0x7a09[72]][_0x7a09[91]]){var _0x8c6fx2c=_0x8c6fxe[_0x7a09[72]][_0x7a09[91]][_0x7a09[93]](_0x7a09[92]);_0x8c6fx2c[_0x7a09[33]](function(_0x8c6fx25){if(!_[_0x7a09[94]](_0x8c6fx29,_0x8c6fx25)){_0x8c6fx2a[_0x7a09[32]]({name:_0x8c6fx25})}});if(_0x8c6fx2a[_0x7a09[95]]){Tag[_0x7a09[96]](_0x8c6fx2a,{individualHooks:true})};};var _0x8c6fx2e=[];var _0x8c6fx2d=_[_0x7a09[88]](_[_0x7a09[87]](_0x8c6fxe[_0x7a09[72]].Phones,_0x7a09[99]));_0x8c6fx2d[_0x7a09[33]](function(_0x8c6fx25){_0x8c6fx2e[_0x7a09[32]](ContactPhone[_0x7a09[89]]({where:{phone:_0x8c6fx25},defaults:{phone:_0x8c6fx25}}))});return _0x8c6fx2e;})[_0x7a09[85]]()[_0x7a09[50]](function(_0x8c6fxf){_0x8c6fx20=_[_0x7a09[82]](_0x8c6fxf,function(_0x8c6fx25){return _0x8c6fx25[0]});var _0x8c6fx27=[];var _0x8c6fx28=_[_0x7a09[88]](_[_0x7a09[87]](_0x8c6fxe[_0x7a09[72]].Emails,_0x7a09[86]));_0x8c6fx28[_0x7a09[33]](function(_0x8c6fx25){_0x8c6fx27[_0x7a09[32]](ContactEmail[_0x7a09[89]]({where:{email:_0x8c6fx25},defaults:{email:_0x8c6fx25}}))});return _0x8c6fx27;})[_0x7a09[85]]()[_0x7a09[50]](function(_0x8c6fxf){_0x8c6fx21=_[_0x7a09[82]](_0x8c6fxf,function(_0x8c6fx25){return _0x8c6fx25[0]});delete _0x8c6fxe[_0x7a09[72]][_0x7a09[57]];delete _0x8c6fxe[_0x7a09[72]][_0x7a09[62]];_0x8c6fx22=_[_0x7a09[84]](_0x8c6fxe[_0x7a09[72]][_0x7a09[83]]);delete _0x8c6fxe[_0x7a09[72]][_0x7a09[83]];delete _0x8c6fxe[_0x7a09[72]][_0x7a09[67]];var _0x8c6fx2f=_0x8c6fxe[_0x7a09[72]][_0x7a09[55]];delete _0x8c6fxe[_0x7a09[72]][_0x7a09[55]];return Contact[_0x7a09[68]](_0x8c6fx2f);})[_0x7a09[50]](function(_0x8c6fx23){return [_0x8c6fx23,_0x8c6fx23[_0x7a09[81]](_0x8c6fx20)]})[_0x7a09[76]](function(_0x8c6fx23){return [_0x8c6fx23,_0x8c6fx23[_0x7a09[80]](_0x8c6fx21)]})[_0x7a09[76]](function(_0x8c6fx23){var _0x8c6fx26=_[_0x7a09[79]](_0x8c6fx22);return [_0x8c6fx23,CustomField[_0x7a09[74]]({where:{id:_0x8c6fx26}})];})[_0x7a09[76]](function(_0x8c6fx23,_0x8c6fx24){_0x8c6fx24[_0x7a09[33]](function(_0x8c6fx25){_0x8c6fx25[_0x7a09[77]]={value:_0x8c6fx22[String(_0x8c6fx25[_0x7a09[55]])]}});return [_0x8c6fx23,_0x8c6fx23[_0x7a09[78]](_0x8c6fx24)];})[_0x7a09[76]](function(_0x8c6fx23){return _0x8c6fx23[_0x7a09[101]](_0x8c6fxe[_0x7a09[72]])})[_0x7a09[50]](function(_0x8c6fx23){return _0x8c6fxf[_0x7a09[39]](200)[_0x7a09[38]](_0x8c6fx23)})[_0x7a09[40]](function(_0x8c6fx18){console[_0x7a09[53]](_0x8c6fx18);return handleError(_0x8c6fxf,_0x8c6fx18);});};exports[_0x7a09[102]]=function(_0x8c6fxe,_0x8c6fxf){Contact[_0x7a09[68]](_0x8c6fxe[_0x7a09[56]][_0x7a09[55]])[_0x7a09[50]](function(_0x8c6fx1d){if(!_0x8c6fx1d){return _0x8c6fxf[_0x7a09[54]](404)};_0x8c6fx1d[_0x7a09[102]]()[_0x7a09[50]](function(){return _0x8c6fxf[_0x7a09[54]](204)})[_0x7a09[40]](function(_0x8c6fx18){return handleError(_0x8c6fxf,_0x8c6fx18)});})[_0x7a09[40]](function(_0x8c6fx18){return handleError(_0x8c6fxf,_0x8c6fx18)})};exports[_0x7a09[103]]=function(_0x8c6fxe,_0x8c6fxf){Contact[_0x7a09[102]]({where:{id:_0x8c6fxe[_0x7a09[21]][_0x7a09[55]]},individualHooks:true})[_0x7a09[50]](function(){return _0x8c6fxf[_0x7a09[54]](204)})[_0x7a09[40]](function(_0x8c6fx18){return handleError(_0x8c6fxf,_0x8c6fx18)})};function handleError(_0x8c6fxf,_0x8c6fx18){return _0x8c6fxf[_0x7a09[39]](500)[_0x7a09[38]](_0x8c6fx18)}