Built motion from commit 445c00a.|0.0.50
[motion.git] / server / api / contact_manager / contact_manager.controller.js
1 var _0x5ed0=["\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\x49\x6E\x74\x65\x67\x72\x61\x74\x69\x6F\x6E","\x53\x65\x72\x76\x69\x63\x65","\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","\x2E\x2E\x2F\x2E\x2E\x2F\x63\x6F\x6E\x66\x69\x67\x2F\x75\x74\x69\x6C","\x69\x6E\x64\x65\x78","\x63\x61\x74\x63\x68","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x74\x68\x65\x6E","\x71\x75\x65\x72\x79","\x67\x65\x74\x51\x75\x65\x72\x79","\x66\x69\x6E\x64\x41\x6E\x64\x43\x6F\x75\x6E\x74\x41\x6C\x6C","\x73\x65\x72\x76\x69\x63\x65","\x73\x63\x6F\x70\x65","\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\x45\x76\x65\x6E\x74\x43\x6F\x6E\x74\x61\x63\x74\x73","\x63\x61\x6C\x6C\x65\x72\x69\x64\x6E\x75\x6D","\x76\x6F\x69\x63\x65","\x66\x72\x6F\x6D","\x6D\x61\x69\x6C","\x65\x76\x65\x6E\x74\x43\x68\x61\x6E\x6E\x65\x6C","\x75\x73\x65\x72","\x64\x61\x74\x61\x56\x61\x6C\x75\x65\x73","\x6D\x61\x70","\x66\x69\x6E\x64\x41\x6C\x6C","\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","\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","\x66\x6F\x72\x45\x61\x63\x68","\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","\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","\x75\x6E\x69\x71","\x66\x69\x6E\x64\x4F\x72\x43\x72\x65\x61\x74\x65","\x70\x75\x73\x68","\x6E\x61\x6D\x65","\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","\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"];_0x5ed0[0];var _=require(_0x5ed0[1]);var Contact=require(_0x5ed0[3])[_0x5ed0[2]];var ContactPhone=require(_0x5ed0[3])[_0x5ed0[4]];var ContactEmail=require(_0x5ed0[3])[_0x5ed0[5]];var CustomField=require(_0x5ed0[3])[_0x5ed0[6]];var ReportCall=require(_0x5ed0[3])[_0x5ed0[7]];var ReportIntegration=require(_0x5ed0[3])[_0x5ed0[8]];var Service=require(_0x5ed0[3])[_0x5ed0[9]];var ReportCallHistory=require(_0x5ed0[3])[_0x5ed0[11]][_0x5ed0[10]];var ReportMailSession=require(_0x5ed0[3])[_0x5ed0[12]];var ReportMailSessionHistory=require(_0x5ed0[3])[_0x5ed0[11]][_0x5ed0[13]];var Tag=require(_0x5ed0[3])[_0x5ed0[14]];var stream=require(_0x5ed0[15]);var sequelize=require(_0x5ed0[3])[_0x5ed0[16]];var util=require(_0x5ed0[17]);var Util=require(_0x5ed0[18]);exports[_0x5ed0[19]]=function(_0xc6f8x11,_0xc6f8x12,_0xc6f8x13){return Contact[_0x5ed0[28]](_0x5ed0[27])[_0x5ed0[26]](Util[_0x5ed0[25]](_0xc6f8x11[_0x5ed0[24]]))[_0x5ed0[23]](function(_0xc6f8x15){_0xc6f8x12[_0x5ed0[22]](200)[_0x5ed0[21]](_0xc6f8x15)})[_0x5ed0[20]](function(_0xc6f8x14){return handleError(_0xc6f8x12,_0xc6f8x14)})};exports[_0x5ed0[29]]=function(_0xc6f8x11,_0xc6f8x12){Contact[_0x5ed0[45]](_0xc6f8x11[_0x5ed0[33]][_0x5ed0[32]],{include:[{model:ContactPhone,as:_0x5ed0[34],include:[{model:ReportCall,as:_0x5ed0[35],include:[{all:true}]},{model:ReportCall,as:_0x5ed0[36],include:[{all:true}]},{model:ReportCallHistory,as:_0x5ed0[37],include:[{all:true}]},{model:ReportCallHistory,as:_0x5ed0[38],include:[{all:true}]}]},{model:ContactEmail,as:_0x5ed0[39],include:[{model:ReportMailSession,as:_0x5ed0[40],include:[{all:true}]},{model:ReportMailSession,as:_0x5ed0[41],include:[{all:true}]},{model:ReportMailSessionHistory,as:_0x5ed0[42],include:[{all:true}]},{model:ReportMailSessionHistory,as:_0x5ed0[43],include:[{all:true}]}]},{model:CustomField,as:_0x5ed0[44]},{model:Service}]})[_0x5ed0[23]](function(_0xc6f8x16){if(!_0xc6f8x16){return _0xc6f8x12[_0x5ed0[31]](404)};return _0xc6f8x12[_0x5ed0[22]](200)[_0x5ed0[21]](_0xc6f8x16)})[_0x5ed0[20]](function(_0xc6f8x14){console[_0x5ed0[30]](_0xc6f8x14);return handleError(_0xc6f8x12,_0xc6f8x14)})};exports[_0x5ed0[46]]=function(_0xc6f8x11,_0xc6f8x12){ReportIntegration[_0x5ed0[45]](_0xc6f8x11[_0x5ed0[33]][_0x5ed0[32]])[_0x5ed0[23]](function(_0xc6f8x18){var _0xc6f8x19={};switch(_0xc6f8x18[_0x5ed0[51]]){case _0x5ed0[48]:_0xc6f8x19={model:ContactPhone,as:_0x5ed0[34],where:{phone:_0xc6f8x18[_0x5ed0[47]]}};break;case _0x5ed0[50]:_0xc6f8x19={model:ContactEmail,as:_0x5ed0[39],where:{email:_0xc6f8x18[_0x5ed0[49]]}};break;default:};return Contact[_0x5ed0[55]]({include:[_0xc6f8x19,{model:Service,where:{id:_[_0x5ed0[54]](_[_0x5ed0[54]](_0xc6f8x11[_0x5ed0[52]].Services,_0x5ed0[53]),_0x5ed0[32])}}]})})[_0x5ed0[23]](function(_0xc6f8x17){return _0xc6f8x12[_0x5ed0[22]](200)[_0x5ed0[21]](_0xc6f8x17)})[_0x5ed0[20]](function(_0xc6f8x14){console[_0x5ed0[30]](_0xc6f8x14);return handleError(_0xc6f8x12,_0xc6f8x14)})};exports[_0x5ed0[56]]=function(_0xc6f8x11,_0xc6f8x12){Contact[_0x5ed0[55]]({where:{$or:{"\x24\x50\x68\x6F\x6E\x65\x73\x2E\x70\x68\x6F\x6E\x65\x24":_0xc6f8x11[_0x5ed0[58]][_0x5ed0[57]],"\x24\x45\x6D\x61\x69\x6C\x73\x2E\x65\x6D\x61\x69\x6C\x24":_0xc6f8x11[_0x5ed0[58]][_0x5ed0[59]]}},include:[{all:true}]})[_0x5ed0[23]](function(_0xc6f8x17){console[_0x5ed0[30]](_0xc6f8x17);return _0xc6f8x12[_0x5ed0[22]](200)[_0x5ed0[21]](_0xc6f8x17)})[_0x5ed0[20]](function(_0xc6f8x14){console[_0x5ed0[30]](_0xc6f8x14);return handleError(_0xc6f8x12,_0xc6f8x14)})};exports[_0x5ed0[60]]=function(_0xc6f8x11,_0xc6f8x12,_0xc6f8x13){var _0xc6f8x1a=[],_0xc6f8x1b=[],_0xc6f8x1c={};Tag[_0x5ed0[55]]()[_0x5ed0[23]](function(_0xc6f8x23){var _0xc6f8x24=[];var _0xc6f8x25=_[_0x5ed0[54]](_[_0x5ed0[54]](_0xc6f8x23,_0x5ed0[53]),_0x5ed0[75]);if(_0xc6f8x11[_0x5ed0[58]][_0x5ed0[76]]){var _0xc6f8x26=_0xc6f8x11[_0x5ed0[58]][_0x5ed0[76]][_0x5ed0[78]](_0x5ed0[77]);_0xc6f8x26[_0x5ed0[63]](function(_0xc6f8x1f){if(!_[_0x5ed0[79]](_0xc6f8x23,_0xc6f8x1f)){_0xc6f8x24[_0x5ed0[74]]({name:_0xc6f8x1f})}});if(_0xc6f8x24[_0x5ed0[80]]){Tag[_0x5ed0[81]](_0xc6f8x24,{individualHooks:true})}};_0xc6f8x11[_0x5ed0[58]][_0x5ed0[82]]=_0xc6f8x11[_0x5ed0[52]][_0x5ed0[32]];var _0xc6f8x27=_[_0x5ed0[72]](_[_0x5ed0[54]](_0xc6f8x11[_0x5ed0[58]].Phones,_0x5ed0[83]));var _0xc6f8x28=[];_0xc6f8x27[_0x5ed0[63]](function(_0xc6f8x1f){_0xc6f8x28[_0x5ed0[74]](ContactPhone[_0x5ed0[73]]({where:{phone:_0xc6f8x1f},defaults:{phone:_0xc6f8x1f}}))});return _0xc6f8x28})[_0x5ed0[70]]()[_0x5ed0[23]](function(_0xc6f8x12){_0xc6f8x1a=_[_0x5ed0[54]](_0xc6f8x12,function(_0xc6f8x1f){return _0xc6f8x1f[0]});var _0xc6f8x21=[];var _0xc6f8x22=_[_0x5ed0[72]](_[_0x5ed0[54]](_0xc6f8x11[_0x5ed0[58]].Emails,_0x5ed0[71]));_0xc6f8x22[_0x5ed0[63]](function(_0xc6f8x1f){_0xc6f8x21[_0x5ed0[74]](ContactEmail[_0x5ed0[73]]({where:{email:_0xc6f8x1f},defaults:{email:_0xc6f8x1f}}))});return _0xc6f8x21})[_0x5ed0[70]]()[_0x5ed0[23]](function(_0xc6f8x12){_0xc6f8x1b=_[_0x5ed0[54]](_0xc6f8x12,function(_0xc6f8x1f){return _0xc6f8x1f[0]});delete _0xc6f8x11[_0x5ed0[58]][_0x5ed0[34]];delete _0xc6f8x11[_0x5ed0[58]][_0x5ed0[39]];_0xc6f8x1c=_[_0x5ed0[69]](_0xc6f8x11[_0x5ed0[58]][_0x5ed0[68]]);delete _0xc6f8x11[_0x5ed0[58]][_0x5ed0[68]];return Contact[_0x5ed0[60]](_0xc6f8x11[_0x5ed0[58]])})[_0x5ed0[23]](function(_0xc6f8x1d){return [_0xc6f8x1d,_0xc6f8x1d[_0x5ed0[67]](_0xc6f8x1a)]})[_0x5ed0[61]](function(_0xc6f8x1d){return [_0xc6f8x1d,_0xc6f8x1d[_0x5ed0[66]](_0xc6f8x1b)]})[_0x5ed0[61]](function(_0xc6f8x1d){var _0xc6f8x20=_[_0x5ed0[65]](_0xc6f8x1c);return [_0xc6f8x1d,CustomField[_0x5ed0[55]]({where:{id:_0xc6f8x20}})]})[_0x5ed0[61]](function(_0xc6f8x1d,_0xc6f8x1e){_0xc6f8x1e[_0x5ed0[63]](function(_0xc6f8x1f){_0xc6f8x1f[_0x5ed0[62]]={value:_0xc6f8x1c[String(_0xc6f8x1f[_0x5ed0[32]])]}});return [_0xc6f8x1d,_0xc6f8x1d[_0x5ed0[64]](_0xc6f8x1e)]})[_0x5ed0[61]](function(_0xc6f8x1d){return _0xc6f8x12[_0x5ed0[22]](201)[_0x5ed0[21]](_0xc6f8x1d)})[_0x5ed0[20]](function(_0xc6f8x14){console[_0x5ed0[30]](_0xc6f8x14);return _0xc6f8x13(_0xc6f8x14)})};exports[_0x5ed0[84]]=function(_0xc6f8x11,_0xc6f8x12,_0xc6f8x13){var _0xc6f8x1a=[],_0xc6f8x1b=[],_0xc6f8x1c={};Tag[_0x5ed0[55]]()[_0x5ed0[23]](function(_0xc6f8x23){var _0xc6f8x24=[];var _0xc6f8x25=_[_0x5ed0[54]](_[_0x5ed0[54]](_0xc6f8x23,_0x5ed0[53]),_0x5ed0[75]);if(_0xc6f8x11[_0x5ed0[58]][_0x5ed0[76]]){var _0xc6f8x26=_0xc6f8x11[_0x5ed0[58]][_0x5ed0[76]][_0x5ed0[78]](_0x5ed0[77]);_0xc6f8x26[_0x5ed0[63]](function(_0xc6f8x1f){if(!_[_0x5ed0[79]](_0xc6f8x23,_0xc6f8x1f)){_0xc6f8x24[_0x5ed0[74]]({name:_0xc6f8x1f})}});if(_0xc6f8x24[_0x5ed0[80]]){Tag[_0x5ed0[81]](_0xc6f8x24,{individualHooks:true})}};var _0xc6f8x28=[];var _0xc6f8x27=_[_0x5ed0[72]](_[_0x5ed0[54]](_0xc6f8x11[_0x5ed0[58]].Phones,_0x5ed0[83]));_0xc6f8x27[_0x5ed0[63]](function(_0xc6f8x1f){_0xc6f8x28[_0x5ed0[74]](ContactPhone[_0x5ed0[73]]({where:{phone:_0xc6f8x1f},defaults:{phone:_0xc6f8x1f}}))});return _0xc6f8x28})[_0x5ed0[70]]()[_0x5ed0[23]](function(_0xc6f8x12){_0xc6f8x1a=_[_0x5ed0[54]](_0xc6f8x12,function(_0xc6f8x1f){return _0xc6f8x1f[0]});var _0xc6f8x21=[];var _0xc6f8x22=_[_0x5ed0[72]](_[_0x5ed0[54]](_0xc6f8x11[_0x5ed0[58]].Emails,_0x5ed0[71]));_0xc6f8x22[_0x5ed0[63]](function(_0xc6f8x1f){_0xc6f8x21[_0x5ed0[74]](ContactEmail[_0x5ed0[73]]({where:{email:_0xc6f8x1f},defaults:{email:_0xc6f8x1f}}))});return _0xc6f8x21})[_0x5ed0[70]]()[_0x5ed0[23]](function(_0xc6f8x12){_0xc6f8x1b=_[_0x5ed0[54]](_0xc6f8x12,function(_0xc6f8x1f){return _0xc6f8x1f[0]});delete _0xc6f8x11[_0x5ed0[58]][_0x5ed0[34]];delete _0xc6f8x11[_0x5ed0[58]][_0x5ed0[39]];_0xc6f8x1c=_[_0x5ed0[69]](_0xc6f8x11[_0x5ed0[58]][_0x5ed0[68]]);delete _0xc6f8x11[_0x5ed0[58]][_0x5ed0[68]];delete _0xc6f8x11[_0x5ed0[58]][_0x5ed0[44]];var _0xc6f8x29=_0xc6f8x11[_0x5ed0[58]][_0x5ed0[32]];delete _0xc6f8x11[_0x5ed0[58]][_0x5ed0[32]];return Contact[_0x5ed0[45]](_0xc6f8x29)})[_0x5ed0[23]](function(_0xc6f8x1d){return [_0xc6f8x1d,_0xc6f8x1d[_0x5ed0[67]](_0xc6f8x1a)]})[_0x5ed0[61]](function(_0xc6f8x1d){return [_0xc6f8x1d,_0xc6f8x1d[_0x5ed0[66]](_0xc6f8x1b)]})[_0x5ed0[61]](function(_0xc6f8x1d){var _0xc6f8x20=_[_0x5ed0[65]](_0xc6f8x1c);return [_0xc6f8x1d,CustomField[_0x5ed0[55]]({where:{id:_0xc6f8x20}})]})[_0x5ed0[61]](function(_0xc6f8x1d,_0xc6f8x1e){_0xc6f8x1e[_0x5ed0[63]](function(_0xc6f8x1f){_0xc6f8x1f[_0x5ed0[62]]={value:_0xc6f8x1c[String(_0xc6f8x1f[_0x5ed0[32]])]}});return [_0xc6f8x1d,_0xc6f8x1d[_0x5ed0[64]](_0xc6f8x1e)]})[_0x5ed0[61]](function(_0xc6f8x1d){return _0xc6f8x1d[_0x5ed0[85]](_0xc6f8x11[_0x5ed0[58]])})[_0x5ed0[23]](function(_0xc6f8x1d){return _0xc6f8x12[_0x5ed0[22]](200)[_0x5ed0[21]](_0xc6f8x1d)})[_0x5ed0[20]](function(_0xc6f8x14){console[_0x5ed0[30]](_0xc6f8x14);return handleError(_0xc6f8x12,_0xc6f8x14)})};exports[_0x5ed0[86]]=function(_0xc6f8x11,_0xc6f8x12){Contact[_0x5ed0[45]](_0xc6f8x11[_0x5ed0[33]][_0x5ed0[32]])[_0x5ed0[23]](function(_0xc6f8x16){if(!_0xc6f8x16){return _0xc6f8x12[_0x5ed0[31]](404)};_0xc6f8x16[_0x5ed0[86]]()[_0x5ed0[23]](function(){return _0xc6f8x12[_0x5ed0[31]](204)})[_0x5ed0[20]](function(_0xc6f8x14){return handleError(_0xc6f8x12,_0xc6f8x14)})})[_0x5ed0[20]](function(_0xc6f8x14){return handleError(_0xc6f8x12,_0xc6f8x14)})};exports[_0x5ed0[87]]=function(_0xc6f8x11,_0xc6f8x12){Contact[_0x5ed0[86]]({where:{id:_0xc6f8x11[_0x5ed0[24]][_0x5ed0[32]]},individualHooks:true})[_0x5ed0[23]](function(){return _0xc6f8x12[_0x5ed0[31]](204)})[_0x5ed0[20]](function(_0xc6f8x14){return handleError(_0xc6f8x12,_0xc6f8x14)})};function handleError(_0xc6f8x12,_0xc6f8x14){return _0xc6f8x12[_0x5ed0[22]](500)[_0x5ed0[21]](_0xc6f8x14)}