Built motion from commit 3000230.|0.0.51
[motion.git] / server / api / contact_manager / contact_manager.controller.js
1 var _0xc0f8=["\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"];_0xc0f8[0];var _=require(_0xc0f8[1]);var Contact=require(_0xc0f8[3])[_0xc0f8[2]];var ContactPhone=require(_0xc0f8[3])[_0xc0f8[4]];var ContactEmail=require(_0xc0f8[3])[_0xc0f8[5]];var CustomField=require(_0xc0f8[3])[_0xc0f8[6]];var ReportCall=require(_0xc0f8[3])[_0xc0f8[7]];var ReportIntegration=require(_0xc0f8[3])[_0xc0f8[8]];var Service=require(_0xc0f8[3])[_0xc0f8[9]];var ReportCallHistory=require(_0xc0f8[3])[_0xc0f8[11]][_0xc0f8[10]];var ReportMailSession=require(_0xc0f8[3])[_0xc0f8[12]];var ReportMailSessionHistory=require(_0xc0f8[3])[_0xc0f8[11]][_0xc0f8[13]];var Tag=require(_0xc0f8[3])[_0xc0f8[14]];var stream=require(_0xc0f8[15]);var sequelize=require(_0xc0f8[3])[_0xc0f8[16]];var util=require(_0xc0f8[17]);var Util=require(_0xc0f8[18]);exports[_0xc0f8[19]]=function(_0xcb74x11,_0xcb74x12,_0xcb74x13){return Contact[_0xc0f8[28]](_0xc0f8[27])[_0xc0f8[26]](Util[_0xc0f8[25]](_0xcb74x11[_0xc0f8[24]]))[_0xc0f8[23]](function(_0xcb74x15){_0xcb74x12[_0xc0f8[22]](200)[_0xc0f8[21]](_0xcb74x15)})[_0xc0f8[20]](function(_0xcb74x14){return handleError(_0xcb74x12,_0xcb74x14)})};exports[_0xc0f8[29]]=function(_0xcb74x11,_0xcb74x12){Contact[_0xc0f8[45]](_0xcb74x11[_0xc0f8[33]][_0xc0f8[32]],{include:[{model:ContactPhone,as:_0xc0f8[34],include:[{model:ReportCall,as:_0xc0f8[35],include:[{all:true}]},{model:ReportCall,as:_0xc0f8[36],include:[{all:true}]},{model:ReportCallHistory,as:_0xc0f8[37],include:[{all:true}]},{model:ReportCallHistory,as:_0xc0f8[38],include:[{all:true}]}]},{model:ContactEmail,as:_0xc0f8[39],include:[{model:ReportMailSession,as:_0xc0f8[40],include:[{all:true}]},{model:ReportMailSession,as:_0xc0f8[41],include:[{all:true}]},{model:ReportMailSessionHistory,as:_0xc0f8[42],include:[{all:true}]},{model:ReportMailSessionHistory,as:_0xc0f8[43],include:[{all:true}]}]},{model:CustomField,as:_0xc0f8[44]},{model:Service}]})[_0xc0f8[23]](function(_0xcb74x16){if(!_0xcb74x16){return _0xcb74x12[_0xc0f8[31]](404)};return _0xcb74x12[_0xc0f8[22]](200)[_0xc0f8[21]](_0xcb74x16)})[_0xc0f8[20]](function(_0xcb74x14){console[_0xc0f8[30]](_0xcb74x14);return handleError(_0xcb74x12,_0xcb74x14)})};exports[_0xc0f8[46]]=function(_0xcb74x11,_0xcb74x12){ReportIntegration[_0xc0f8[45]](_0xcb74x11[_0xc0f8[33]][_0xc0f8[32]])[_0xc0f8[23]](function(_0xcb74x18){var _0xcb74x19={};switch(_0xcb74x18[_0xc0f8[51]]){case _0xc0f8[48]:_0xcb74x19={model:ContactPhone,as:_0xc0f8[34],where:{phone:_0xcb74x18[_0xc0f8[47]]}};break;case _0xc0f8[50]:_0xcb74x19={model:ContactEmail,as:_0xc0f8[39],where:{email:_0xcb74x18[_0xc0f8[49]]}};break;default:};return Contact[_0xc0f8[55]]({include:[_0xcb74x19,{model:Service,where:{id:_[_0xc0f8[54]](_[_0xc0f8[54]](_0xcb74x11[_0xc0f8[52]].Services,_0xc0f8[53]),_0xc0f8[32])}}]})})[_0xc0f8[23]](function(_0xcb74x17){return _0xcb74x12[_0xc0f8[22]](200)[_0xc0f8[21]](_0xcb74x17)})[_0xc0f8[20]](function(_0xcb74x14){console[_0xc0f8[30]](_0xcb74x14);return handleError(_0xcb74x12,_0xcb74x14)})};exports[_0xc0f8[56]]=function(_0xcb74x11,_0xcb74x12){Contact[_0xc0f8[55]]({where:{$or:{"\x24\x50\x68\x6F\x6E\x65\x73\x2E\x70\x68\x6F\x6E\x65\x24":_0xcb74x11[_0xc0f8[58]][_0xc0f8[57]],"\x24\x45\x6D\x61\x69\x6C\x73\x2E\x65\x6D\x61\x69\x6C\x24":_0xcb74x11[_0xc0f8[58]][_0xc0f8[59]]}},include:[{all:true}]})[_0xc0f8[23]](function(_0xcb74x17){console[_0xc0f8[30]](_0xcb74x17);return _0xcb74x12[_0xc0f8[22]](200)[_0xc0f8[21]](_0xcb74x17)})[_0xc0f8[20]](function(_0xcb74x14){console[_0xc0f8[30]](_0xcb74x14);return handleError(_0xcb74x12,_0xcb74x14)})};exports[_0xc0f8[60]]=function(_0xcb74x11,_0xcb74x12,_0xcb74x13){var _0xcb74x1a=[],_0xcb74x1b=[],_0xcb74x1c={};Tag[_0xc0f8[55]]()[_0xc0f8[23]](function(_0xcb74x23){var _0xcb74x24=[];var _0xcb74x25=_[_0xc0f8[54]](_[_0xc0f8[54]](_0xcb74x23,_0xc0f8[53]),_0xc0f8[75]);if(_0xcb74x11[_0xc0f8[58]][_0xc0f8[76]]){var _0xcb74x26=_0xcb74x11[_0xc0f8[58]][_0xc0f8[76]][_0xc0f8[78]](_0xc0f8[77]);_0xcb74x26[_0xc0f8[63]](function(_0xcb74x1f){if(!_[_0xc0f8[79]](_0xcb74x23,_0xcb74x1f)){_0xcb74x24[_0xc0f8[74]]({name:_0xcb74x1f})}});if(_0xcb74x24[_0xc0f8[80]]){Tag[_0xc0f8[81]](_0xcb74x24,{individualHooks:true})}};_0xcb74x11[_0xc0f8[58]][_0xc0f8[82]]=_0xcb74x11[_0xc0f8[52]][_0xc0f8[32]];var _0xcb74x27=_[_0xc0f8[72]](_[_0xc0f8[54]](_0xcb74x11[_0xc0f8[58]].Phones,_0xc0f8[83]));var _0xcb74x28=[];_0xcb74x27[_0xc0f8[63]](function(_0xcb74x1f){_0xcb74x28[_0xc0f8[74]](ContactPhone[_0xc0f8[73]]({where:{phone:_0xcb74x1f},defaults:{phone:_0xcb74x1f}}))});return _0xcb74x28})[_0xc0f8[70]]()[_0xc0f8[23]](function(_0xcb74x12){_0xcb74x1a=_[_0xc0f8[54]](_0xcb74x12,function(_0xcb74x1f){return _0xcb74x1f[0]});var _0xcb74x21=[];var _0xcb74x22=_[_0xc0f8[72]](_[_0xc0f8[54]](_0xcb74x11[_0xc0f8[58]].Emails,_0xc0f8[71]));_0xcb74x22[_0xc0f8[63]](function(_0xcb74x1f){_0xcb74x21[_0xc0f8[74]](ContactEmail[_0xc0f8[73]]({where:{email:_0xcb74x1f},defaults:{email:_0xcb74x1f}}))});return _0xcb74x21})[_0xc0f8[70]]()[_0xc0f8[23]](function(_0xcb74x12){_0xcb74x1b=_[_0xc0f8[54]](_0xcb74x12,function(_0xcb74x1f){return _0xcb74x1f[0]});delete _0xcb74x11[_0xc0f8[58]][_0xc0f8[34]];delete _0xcb74x11[_0xc0f8[58]][_0xc0f8[39]];_0xcb74x1c=_[_0xc0f8[69]](_0xcb74x11[_0xc0f8[58]][_0xc0f8[68]]);delete _0xcb74x11[_0xc0f8[58]][_0xc0f8[68]];return Contact[_0xc0f8[60]](_0xcb74x11[_0xc0f8[58]])})[_0xc0f8[23]](function(_0xcb74x1d){return [_0xcb74x1d,_0xcb74x1d[_0xc0f8[67]](_0xcb74x1a)]})[_0xc0f8[61]](function(_0xcb74x1d){return [_0xcb74x1d,_0xcb74x1d[_0xc0f8[66]](_0xcb74x1b)]})[_0xc0f8[61]](function(_0xcb74x1d){var _0xcb74x20=_[_0xc0f8[65]](_0xcb74x1c);return [_0xcb74x1d,CustomField[_0xc0f8[55]]({where:{id:_0xcb74x20}})]})[_0xc0f8[61]](function(_0xcb74x1d,_0xcb74x1e){_0xcb74x1e[_0xc0f8[63]](function(_0xcb74x1f){_0xcb74x1f[_0xc0f8[62]]={value:_0xcb74x1c[String(_0xcb74x1f[_0xc0f8[32]])]}});return [_0xcb74x1d,_0xcb74x1d[_0xc0f8[64]](_0xcb74x1e)]})[_0xc0f8[61]](function(_0xcb74x1d){return _0xcb74x12[_0xc0f8[22]](201)[_0xc0f8[21]](_0xcb74x1d)})[_0xc0f8[20]](function(_0xcb74x14){console[_0xc0f8[30]](_0xcb74x14);return _0xcb74x13(_0xcb74x14)})};exports[_0xc0f8[84]]=function(_0xcb74x11,_0xcb74x12,_0xcb74x13){var _0xcb74x1a=[],_0xcb74x1b=[],_0xcb74x1c={};Tag[_0xc0f8[55]]()[_0xc0f8[23]](function(_0xcb74x23){var _0xcb74x24=[];var _0xcb74x25=_[_0xc0f8[54]](_[_0xc0f8[54]](_0xcb74x23,_0xc0f8[53]),_0xc0f8[75]);if(_0xcb74x11[_0xc0f8[58]][_0xc0f8[76]]){var _0xcb74x26=_0xcb74x11[_0xc0f8[58]][_0xc0f8[76]][_0xc0f8[78]](_0xc0f8[77]);_0xcb74x26[_0xc0f8[63]](function(_0xcb74x1f){if(!_[_0xc0f8[79]](_0xcb74x23,_0xcb74x1f)){_0xcb74x24[_0xc0f8[74]]({name:_0xcb74x1f})}});if(_0xcb74x24[_0xc0f8[80]]){Tag[_0xc0f8[81]](_0xcb74x24,{individualHooks:true})}};var _0xcb74x28=[];var _0xcb74x27=_[_0xc0f8[72]](_[_0xc0f8[54]](_0xcb74x11[_0xc0f8[58]].Phones,_0xc0f8[83]));_0xcb74x27[_0xc0f8[63]](function(_0xcb74x1f){_0xcb74x28[_0xc0f8[74]](ContactPhone[_0xc0f8[73]]({where:{phone:_0xcb74x1f},defaults:{phone:_0xcb74x1f}}))});return _0xcb74x28})[_0xc0f8[70]]()[_0xc0f8[23]](function(_0xcb74x12){_0xcb74x1a=_[_0xc0f8[54]](_0xcb74x12,function(_0xcb74x1f){return _0xcb74x1f[0]});var _0xcb74x21=[];var _0xcb74x22=_[_0xc0f8[72]](_[_0xc0f8[54]](_0xcb74x11[_0xc0f8[58]].Emails,_0xc0f8[71]));_0xcb74x22[_0xc0f8[63]](function(_0xcb74x1f){_0xcb74x21[_0xc0f8[74]](ContactEmail[_0xc0f8[73]]({where:{email:_0xcb74x1f},defaults:{email:_0xcb74x1f}}))});return _0xcb74x21})[_0xc0f8[70]]()[_0xc0f8[23]](function(_0xcb74x12){_0xcb74x1b=_[_0xc0f8[54]](_0xcb74x12,function(_0xcb74x1f){return _0xcb74x1f[0]});delete _0xcb74x11[_0xc0f8[58]][_0xc0f8[34]];delete _0xcb74x11[_0xc0f8[58]][_0xc0f8[39]];_0xcb74x1c=_[_0xc0f8[69]](_0xcb74x11[_0xc0f8[58]][_0xc0f8[68]]);delete _0xcb74x11[_0xc0f8[58]][_0xc0f8[68]];delete _0xcb74x11[_0xc0f8[58]][_0xc0f8[44]];var _0xcb74x29=_0xcb74x11[_0xc0f8[58]][_0xc0f8[32]];delete _0xcb74x11[_0xc0f8[58]][_0xc0f8[32]];return Contact[_0xc0f8[45]](_0xcb74x29)})[_0xc0f8[23]](function(_0xcb74x1d){return [_0xcb74x1d,_0xcb74x1d[_0xc0f8[67]](_0xcb74x1a)]})[_0xc0f8[61]](function(_0xcb74x1d){return [_0xcb74x1d,_0xcb74x1d[_0xc0f8[66]](_0xcb74x1b)]})[_0xc0f8[61]](function(_0xcb74x1d){var _0xcb74x20=_[_0xc0f8[65]](_0xcb74x1c);return [_0xcb74x1d,CustomField[_0xc0f8[55]]({where:{id:_0xcb74x20}})]})[_0xc0f8[61]](function(_0xcb74x1d,_0xcb74x1e){_0xcb74x1e[_0xc0f8[63]](function(_0xcb74x1f){_0xcb74x1f[_0xc0f8[62]]={value:_0xcb74x1c[String(_0xcb74x1f[_0xc0f8[32]])]}});return [_0xcb74x1d,_0xcb74x1d[_0xc0f8[64]](_0xcb74x1e)]})[_0xc0f8[61]](function(_0xcb74x1d){return _0xcb74x1d[_0xc0f8[85]](_0xcb74x11[_0xc0f8[58]])})[_0xc0f8[23]](function(_0xcb74x1d){return _0xcb74x12[_0xc0f8[22]](200)[_0xc0f8[21]](_0xcb74x1d)})[_0xc0f8[20]](function(_0xcb74x14){console[_0xc0f8[30]](_0xcb74x14);return handleError(_0xcb74x12,_0xcb74x14)})};exports[_0xc0f8[86]]=function(_0xcb74x11,_0xcb74x12){Contact[_0xc0f8[45]](_0xcb74x11[_0xc0f8[33]][_0xc0f8[32]])[_0xc0f8[23]](function(_0xcb74x16){if(!_0xcb74x16){return _0xcb74x12[_0xc0f8[31]](404)};_0xcb74x16[_0xc0f8[86]]()[_0xc0f8[23]](function(){return _0xcb74x12[_0xc0f8[31]](204)})[_0xc0f8[20]](function(_0xcb74x14){return handleError(_0xcb74x12,_0xcb74x14)})})[_0xc0f8[20]](function(_0xcb74x14){return handleError(_0xcb74x12,_0xcb74x14)})};exports[_0xc0f8[87]]=function(_0xcb74x11,_0xcb74x12){Contact[_0xc0f8[86]]({where:{id:_0xcb74x11[_0xc0f8[24]][_0xc0f8[32]]},individualHooks:true})[_0xc0f8[23]](function(){return _0xcb74x12[_0xc0f8[31]](204)})[_0xc0f8[20]](function(_0xcb74x14){return handleError(_0xcb74x12,_0xcb74x14)})};function handleError(_0xcb74x12,_0xcb74x14){return _0xcb74x12[_0xc0f8[22]](500)[_0xc0f8[21]](_0xcb74x14)}