Built motion from commit 85328c08.|2.5.50
[motion2.git] / server / api / cmContact / cmContact.controller.js
index 0b45dae..cdc606e 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x5669=['merge','c.firstName','c.lastName','c.phone','c.fax','c.email','c.ListId','c.deletedAt','TagIds','Tags','rows','catch','destroy','find','params','tags','findAll','columnName','displayName','alias','values','body','get','mergeWith','join','info','[CmContact][merge]\x20to\x20%s\x20from\x20%s','CmHopperBlack','[CmContact][merge][destroy][CmHopperBlack],\x20%s','ChatInteraction','ChatMessage','ChatOfflineMessage','MailInteraction','MailMessage','SmsInteraction','FaxInteraction','FaxMessage','OpenchannelInteraction','OpenchannelMessage','CmHopperHistory','VoiceCallReport','ChatQueueReport','MailQueueReport','JscriptySessionReport','WhatsappMessage','create','bulkCreate','each','duplicates','$or','ListId','spread','show','omit','format','cf_%d','pickBy','table','cm_contacts','setFields','id\x20=\x20?','toParam','CmHopper','phone','getTags','nolimit','setTags','ids','ContactId','options','include','rawAttributes','includeAll','getHopperFinals','CmHopperFinal','getJscriptySessions','uploadCsv','No\x20ListId\x20specified','binding_keys','No\x20association\x20keys\x20specified!','binding_values','socket_timestamp','Unable\x20to\x20synchronize\x20socket,\x20no\x20timestamp\x20passed','Incorrect\x20binding\x20parameters\x20passed!','No\x20phone\x20column\x20specified','server/files/tmp','file','filename','chmodSync','child_process','fork','../../components/import/cm/csv','CompanyId','path','parse','meta','import','binding','firstName','No\x20firstName\x20column\x20specified','../../components/import/cm/csv2','stringify','message','json','start\x20child\x20process\x20correctly!','pid','exit','error\x20child\x20process','getJourney','mail','chat','openchannel','fax','whatsapp','voice','-createdAt','channel','includes','toLowerCase','range','isValid','Invalid\x20date\x20for\x20range\x20to\x20filter','Invalid\x20createdAt\x20filter','uniqueid','source','destination','starttime','duration','createdAt','userSecondDisposition','userThirdDisposition','UserId','fullname','findAndCountAll','startCase','Account','closed','closedAt','note','secondDisposition','thirdDisposition','key','customerPort','deviceModel','ratingMessage','ratingType','referer','subject','substatus','externalUrl','Owner','flatten','sortBy','rimraf','zip-dir','fast-json-patch','moment','bluebird','mustache','sox','to-csv','fs-extra','lodash','crypto','jsforce','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','localhost','socket.io-emitter','./cmContact.socket','sendStatus','status','end','count','offset','limit','set','apply','reject','save','update','then','error','stack','name','index','CmContact','describe','keys','length','startsWith','cf_','CmCustomField','findOne','all','fieldType','type','model','query','filters','intersection','attributes','fields','hasOwnProperty','order','sort','pick','select','field','color','from','cm_user_has_contacts','uc.CmContactId\x20=\x20c.id','left_join','cm_contact_has_tags','ct.CmContactId\x20=\x20c.id','tools_tags','t.id\x20=\x20ct.TagId','where','c.deletedAt\x20IS\x20NULL','search','sqlOperator','conditions','Tag','value','split','map','forEach','CONCAT(\x27,\x27,\x20`TagIds`,\x20\x27,\x27)\x20LIKE\x20?','union','User','and','datetime','castTo','DATE','buildExpression','text','start','filter','isNil','Contact','push','c.ListId\x20IN\x20?','concat','CONCAT_WS(\x27\x20\x27,\x20c.firstName,\x20c.lastName,\x20c.email)\x20LIKE\x20?','tag','isArray','replace','MATCH\x20(c.firstName,\x20c.lastName,\x20c.phone,\x20c.mobile,\x20c.fax,\x20c.email)\x20AGAINST\x20(?\x20IN\x20BOOLEAN\x20MODE)','getFullTextValue','c.id\x20LIKE\x20?','c.phone\x20LIKE\x20?','c.mobile\x20LIKE\x20?','c.fax\x20LIKE\x20?','isEmail','c.email\x20LIKE\x20?','c.firstName\x20LIKE\x20?','c.lastName\x20LIKE\x20?','group','c.id','Sequelize','QueryTypes','DESC','having','t.id\x20IN\x20?','resolve','user','role','agent','some','isEmpty','sequelize','toString','keyBy'];(function(_0x20a07f,_0x12f151){var _0x1cbe78=function(_0x563eff){while(--_0x563eff){_0x20a07f['push'](_0x20a07f['shift']());}};_0x1cbe78(++_0x12f151);}(_0x5669,0x99));var _0x9566=function(_0x14e589,_0x5d5c97){_0x14e589=_0x14e589-0x0;var _0x4ceb8c=_0x5669[_0x14e589];return _0x4ceb8c;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x9566('0x0'));var zipdir=require(_0x9566('0x1'));var jsonpatch=require(_0x9566('0x2'));var rp=require('request-promise');var moment=require(_0x9566('0x3'));var BPromise=require(_0x9566('0x4'));var Mustache=require(_0x9566('0x5'));var util=require('util');var path=require('path');var sox=require(_0x9566('0x6'));var csv=require(_0x9566('0x7'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x9566('0x8'));var _=require(_0x9566('0x9'));var squel=require('squel');var crypto=require(_0x9566('0xa'));var jsforce=require(_0x9566('0xb'));var deskjs=require('desk.js');var toCsv=require(_0x9566('0x7'));var querystring=require(_0x9566('0xc'));var Papa=require(_0x9566('0xd'));var Redis=require(_0x9566('0xe'));var authService=require('../../components/auth/service');var qs=require(_0x9566('0xf'));var as=require(_0x9566('0x10'));var hardwareService=require(_0x9566('0x11'));var logger=require(_0x9566('0x12'))(_0x9566('0x13'));var utils=require(_0x9566('0x14'));var config=require(_0x9566('0x15'));var licenseUtil=require(_0x9566('0x16'));var db=require(_0x9566('0x17'))['db'];config['redis']=_['defaults'](config[_0x9566('0x18')],{'host':_0x9566('0x19'),'port':0x18eb});var socket=require(_0x9566('0x1a'))(new Redis(config[_0x9566('0x18')]));require(_0x9566('0x1b'))['register'](socket);function respondWithStatusCode(_0x44c979,_0x5bf91e){_0x5bf91e=_0x5bf91e||0xcc;return function(_0x197cb7){if(_0x197cb7){return _0x44c979[_0x9566('0x1c')](_0x5bf91e);}return _0x44c979[_0x9566('0x1d')](_0x5bf91e)[_0x9566('0x1e')]();};}function respondWithResult(_0x1eb54c,_0x2968c9){_0x2968c9=_0x2968c9||0xc8;return function(_0x265c45){if(_0x265c45){return _0x1eb54c['status'](_0x2968c9)['json'](_0x265c45);}};}function respondWithFilteredResult(_0x1b0d78,_0x34a495){return function(_0x3dbdb6){if(_0x3dbdb6){var _0xa87115=_0x3dbdb6[_0x9566('0x1f')],_0x29961e=_0x34a495[_0x9566('0x20')],_0x59a0be=_0x34a495[_0x9566('0x20')]+_0x34a495[_0x9566('0x21')],_0x17a4c7;if(_0x59a0be>=_0xa87115){_0x59a0be=_0xa87115;_0x17a4c7=0xc8;}else{_0x17a4c7=0xce;}_0x1b0d78[_0x9566('0x1d')](_0x17a4c7);return _0x1b0d78[_0x9566('0x22')]('Content-Range',_0x29961e+'-'+_0x59a0be+'/'+_0xa87115)['json'](_0x3dbdb6);}return null;};}function patchUpdates(_0x1bbcfe){return function(_0x57796e){try{jsonpatch[_0x9566('0x23')](_0x57796e,_0x1bbcfe,!![]);}catch(_0x2ce1ab){return BPromise[_0x9566('0x24')](_0x2ce1ab);}return _0x57796e[_0x9566('0x25')]();};}function saveUpdates(_0x26e173,_0x29bfb5){return function(_0x49e579){if(_0x49e579){return _0x49e579[_0x9566('0x26')](_0x26e173)[_0x9566('0x27')](function(_0x500e26){return _0x500e26;});}return null;};}function removeEntity(_0xa16c70,_0x5a3504){return function(_0x4dc7eb){if(_0x4dc7eb){return _0x4dc7eb['destroy']()['then'](function(){_0xa16c70['status'](0xcc)[_0x9566('0x1e')]();});}};}function handleEntityNotFound(_0x2c12dd,_0x4fb655){return function(_0x35b2af){if(!_0x35b2af){_0x2c12dd[_0x9566('0x1c')](0x194);}return _0x35b2af;};}function handleError(_0x201e4e,_0x5b0edc){_0x5b0edc=_0x5b0edc||0x1f4;return function(_0x4721dd){logger[_0x9566('0x28')](_0x4721dd[_0x9566('0x29')]);if(_0x4721dd['name']){delete _0x4721dd[_0x9566('0x2a')];}_0x201e4e['status'](_0x5b0edc)['send'](_0x4721dd);};}exports[_0x9566('0x2b')]=function(_0x247bcf,_0x58ae94){var _0x5a8e61={},_0x29244e={},_0x26029b={'count':0x0,'rows':[]};return db[_0x9566('0x2c')][_0x9566('0x2d')]()[_0x9566('0x27')](function(_0x31c207){var _0x4508e9=[];for(var _0x32b7dd=0x0;_0x32b7dd<Object[_0x9566('0x2e')](_0x31c207)[_0x9566('0x2f')];_0x32b7dd++){var _0x57feb0=Object[_0x9566('0x2e')](_0x31c207)[_0x32b7dd];if(_[_0x9566('0x30')](_0x57feb0,_0x9566('0x31'))){_0x4508e9['push'](db[_0x9566('0x32')][_0x9566('0x33')]({'where':{'id':_['trimStart'](_0x57feb0,'cf_')},'raw':!![]}));}}return BPromise[_0x9566('0x34')](_0x4508e9)['then'](function(_0x43732a){for(var _0x7a4530=0x0;_0x7a4530<_0x43732a['length'];_0x7a4530++){if(_0x43732a[_0x7a4530]){var _0x502139=_0x9566('0x31')+_0x43732a[_0x7a4530]['id'];var _0x336ea5=_0x31c207[_0x502139];_0x336ea5[_0x9566('0x35')]=_0x43732a[_0x7a4530][_0x9566('0x36')];}}return _0x31c207;});})[_0x9566('0x27')](function(_0x4a0afe){_0x29244e[_0x9566('0x37')]=_[_0x9566('0x2e')](_0x4a0afe);_0x29244e[_0x9566('0x38')]=_['keys'](_0x247bcf[_0x9566('0x38')]);_0x29244e[_0x9566('0x39')]=_[_0x9566('0x3a')](_0x29244e[_0x9566('0x37')],_0x29244e[_0x9566('0x38')]);_0x5a8e61[_0x9566('0x3b')]=_[_0x9566('0x3a')](_0x29244e[_0x9566('0x37')],qs['fields'](_0x247bcf['query'][_0x9566('0x3c')]));_0x5a8e61[_0x9566('0x3b')]=_0x5a8e61['attributes'][_0x9566('0x2f')]?_0x5a8e61[_0x9566('0x3b')]:_0x29244e['model'];if(!_0x247bcf[_0x9566('0x38')][_0x9566('0x3d')]('nolimit')){_0x5a8e61['limit']=qs[_0x9566('0x21')](_0x247bcf['query']['limit']);_0x5a8e61[_0x9566('0x20')]=qs[_0x9566('0x20')](_0x247bcf[_0x9566('0x38')][_0x9566('0x20')]);}_0x5a8e61[_0x9566('0x3e')]=qs[_0x9566('0x3f')](_0x247bcf[_0x9566('0x38')][_0x9566('0x3f')]);_0x5a8e61['where']=qs[_0x9566('0x39')](_[_0x9566('0x40')](_0x247bcf[_0x9566('0x38')],_0x29244e[_0x9566('0x39')]),_0x4a0afe);var _0x3ee3a5=[];var _0x5b8b0c=squel[_0x9566('0x41')]()[_0x9566('0x42')]('id')['field'](_0x9566('0x2a'))['field'](_0x9566('0x43'))[_0x9566('0x44')]('tools_tags');var _0x24f73a=squel[_0x9566('0x41')]()[_0x9566('0x44')]('cm_contacts','c')['left_join'](_0x9566('0x45'),'uc',_0x9566('0x46'))[_0x9566('0x47')](_0x9566('0x48'),'ct',_0x9566('0x49'))[_0x9566('0x47')](_0x9566('0x4a'),'t',_0x9566('0x4b'))[_0x9566('0x4c')](_0x9566('0x4d'));var _0x5acddc=squel['expr']();var _0x4874d7=[];var _0x4fc1fa=squel['expr']();var _0x39d9bc;if(_0x247bcf[_0x9566('0x38')][_0x9566('0x4e')]){_0x39d9bc=as['parseSearch'](_0x247bcf[_0x9566('0x38')][_0x9566('0x4e')]);var _0x222aed=_0x39d9bc[_0x9566('0x4f')];for(var _0x1dea8d=0x0;_0x1dea8d<_0x39d9bc[_0x9566('0x50')][_0x9566('0x2f')];_0x1dea8d++){var _0x490612=_0x39d9bc[_0x9566('0x50')][_0x1dea8d];var _0x5d359f='c';var _0x5b9b3d=_(_0x4a0afe)['keys']()['find'](function(_0x3f459b){return _0x3f459b===_0x490612[_0x9566('0x42')];});if(_0x5b9b3d)_0x5b9b3d=_0x4a0afe[_0x490612[_0x9566('0x42')]];if(!_0x5b9b3d){if(_0x490612[_0x9566('0x42')]===_0x9566('0x51')){var _0x59f663=_0x490612[_0x9566('0x52')][_0x9566('0x53')](',')[_0x9566('0x54')](function(_0x33aa91){return Number(_0x33aa91);});_0x59f663[_0x9566('0x55')](function(_0x5a0c22){_0x4fc1fa['or'](_0x9566('0x56'),'%,'+_0x5a0c22+',%');});_0x4874d7=_[_0x9566('0x57')](_0x4874d7,_0x59f663);}else if(_0x490612[_0x9566('0x42')]===_0x9566('0x58')){_0x5acddc[_0x9566('0x59')]('uc.UserId\x20=\x20?',_0x490612[_0x9566('0x52')]);}}else{if(_0x490612[_0x9566('0x42')]==='dateOfBirth'||_0x5b9b3d['fieldType']===_0x9566('0x5a'))_0x490612[_0x9566('0x5b')]=_0x9566('0x5c');var _0x5a542c=as[_0x9566('0x5d')](_0x5d359f,_0x5b9b3d[_0x9566('0x36')],_0x490612);_0x5acddc[_0x222aed](_0x5a542c[_0x9566('0x5e')],_0x5a542c[_0x9566('0x52')][_0x9566('0x5f')],_0x5a542c[_0x9566('0x52')]['end']);}}}else{var _0x58b39b=_(Object[_0x9566('0x2e')](_0x247bcf[_0x9566('0x38')]))[_0x9566('0x54')](function(_0x2d066c){return _0x4a0afe[_0x9566('0x3d')](_0x2d066c)?_0x2d066c:undefined;})[_0x9566('0x60')](function(_0x5c59c2){return!_[_0x9566('0x61')](_0x5c59c2);})['value']();if(_0x247bcf[_0x9566('0x38')][_0x9566('0x62')])_0x58b39b[_0x9566('0x63')](_0x9566('0x62'));if(!_['isEmpty'](_0x58b39b)){_0x58b39b[_0x9566('0x55')](function(_0x4c8a7f){if(_0x4c8a7f==='ListId'){_0x24f73a['where'](_0x9566('0x64'),[][_0x9566('0x65')](_0x247bcf['query'][_0x4c8a7f]));}else if(_0x4c8a7f===_0x9566('0x62')){var _0x17eafa='%'+_0x247bcf[_0x9566('0x38')][_0x4c8a7f]+'%';_0x24f73a[_0x9566('0x4c')](_0x9566('0x66'),_0x17eafa);}else{_0x24f73a[_0x9566('0x4c')]('c.'+_0x4c8a7f+'\x20=\x20?',_0x247bcf[_0x9566('0x38')][_0x4c8a7f]);}});}if(_0x247bcf[_0x9566('0x38')][_0x9566('0x67')]){_0x4874d7=_[_0x9566('0x68')](_0x247bcf[_0x9566('0x38')][_0x9566('0x67')])?_0x247bcf[_0x9566('0x38')][_0x9566('0x67')]:new Array(_0x247bcf['query'][_0x9566('0x67')]);_0x4874d7['forEach'](function(_0x3689b2){_0x4fc1fa['or'](_0x9566('0x56'),'%,'+_0x3689b2+',%');});}if(_0x247bcf[_0x9566('0x38')][_0x9566('0x60')]){var _0x43b08d=_0x247bcf[_0x9566('0x38')][_0x9566('0x60')]['replace']('\x5c','\x5c\x5c')[_0x9566('0x69')](/'/g,'\x27\x27');if(_0x43b08d[_0x9566('0x53')]('\x20')[_0x9566('0x2f')]>0x1){_0x5acddc['or'](_0x9566('0x6a'),qs[_0x9566('0x6b')](_0x43b08d),null);}else{if(qs['isNumeric'](_0x43b08d)){_0x5acddc['or'](_0x9566('0x6c'),_0x43b08d+'%');_0x5acddc['or'](_0x9566('0x6d'),_0x43b08d+'%');_0x5acddc['or'](_0x9566('0x6e'),_0x43b08d+'%');_0x5acddc['or'](_0x9566('0x6f'),_0x43b08d+'%');}else if(qs[_0x9566('0x70')](_0x43b08d)){_0x5acddc['or'](_0x9566('0x71'),_0x43b08d+'%');}else{_0x5acddc['or'](_0x9566('0x72'),'%'+_0x43b08d+'%');_0x5acddc['or'](_0x9566('0x73'),'%'+_0x43b08d+'%');_0x5acddc['or'](_0x9566('0x71'),'%'+_0x43b08d+'%');}}}}_0x24f73a[_0x9566('0x4c')](_0x5acddc);_0x24f73a[_0x9566('0x74')](_0x9566('0x75'));var _0x5b7d20={'type':db[_0x9566('0x76')][_0x9566('0x77')]['SELECT'],'raw':!![]};var _0x31d5c2=_0x24f73a['clone']()[_0x9566('0x42')]('c.id');if(_0x5a8e61['order']){_0x5a8e61['order'][_0x9566('0x55')](function(_0xad39f2){_0x24f73a[_0x9566('0x3e')]('c.'+_0xad39f2[0x0],_0xad39f2[0x1]===_0x9566('0x78')?![]:!![]);});}if(!_['isEmpty'](_0x4874d7)){_0x24f73a[_0x9566('0x79')](_0x4fc1fa);_0x31d5c2['where'](_0x9566('0x7a'),_0x4874d7);}BPromise[_0x9566('0x7b')]()[_0x9566('0x27')](function(){if(!_0x39d9bc)return;if(_0x247bcf[_0x9566('0x7c')][_0x9566('0x7d')]!==_0x9566('0x7e'))return;if(!_[_0x9566('0x7f')](_0x39d9bc[_0x9566('0x50')],[_0x9566('0x42'),_0x9566('0x58')])){return _0x247bcf['user']['getLists']({'attributes':['id'],'raw':!![]})[_0x9566('0x27')](function(_0x5b9856){if(_[_0x9566('0x80')](_0x5b9856)){_0x31d5c2[_0x9566('0x4c')]('c.ListId\x20IS\x20NULL');_0x24f73a[_0x9566('0x4c')]('c.ListId\x20IS\x20NULL');}else{_0x31d5c2['where'](_0x9566('0x64'),_[_0x9566('0x54')](_0x5b9856,'id'));_0x24f73a[_0x9566('0x4c')](_0x9566('0x64'),_[_0x9566('0x54')](_0x5b9856,'id'));}});}})[_0x9566('0x27')](function(){if(_0x247bcf['user'][_0x9566('0x7d')]===_0x9566('0x7e')&&!_0x39d9bc&&!_0x247bcf[_0x9566('0x38')]['ListId'])return[];return db[_0x9566('0x81')]['query'](_0x31d5c2[_0x9566('0x82')](),_0x5b7d20);})[_0x9566('0x27')](function(_0x1f20b8){_0x26029b[_0x9566('0x1f')]=_0x1f20b8['length'];if(_0x26029b[_0x9566('0x1f')]===0x0)return[];return db[_0x9566('0x81')][_0x9566('0x38')](_0x5b8b0c[_0x9566('0x82')](),_0x5b7d20)[_0x9566('0x27')](function(_0xd98978){_0x3ee3a5=_[_0x9566('0x83')](_0xd98978,'id');_0x5b7d20=_[_0x9566('0x84')](_0x5b7d20,{'model':db[_0x9566('0x2c')],'mapToModel':!![],'raw':!![],'nest':!![]});if(_0x247bcf[_0x9566('0x38')][_0x9566('0x3c')]){_0x5a8e61[_0x9566('0x3b')][_0x9566('0x55')](function(_0x5a5441){_0x24f73a[_0x9566('0x42')]('c.'+_0x5a5441);});}else{_0x24f73a['field'](_0x9566('0x75'));_0x24f73a['field'](_0x9566('0x85'));_0x24f73a[_0x9566('0x42')](_0x9566('0x86'));_0x24f73a[_0x9566('0x42')](_0x9566('0x87'));_0x24f73a[_0x9566('0x42')]('c.mobile');_0x24f73a['field'](_0x9566('0x88'));_0x24f73a[_0x9566('0x42')](_0x9566('0x89'));_0x24f73a[_0x9566('0x42')](_0x9566('0x8a'));_0x24f73a[_0x9566('0x42')]('c.createdAt');_0x24f73a['field'](_0x9566('0x8b'));_0x24f73a[_0x9566('0x42')]('c.CompanyId');_0x24f73a['field']('GROUP_CONCAT(DISTINCT\x20t.id)',_0x9566('0x8c'));}if(_0x5a8e61['limit'])_0x24f73a[_0x9566('0x21')](_0x5a8e61['limit']);if(_0x5a8e61[_0x9566('0x20')])_0x24f73a[_0x9566('0x20')](_0x5a8e61[_0x9566('0x20')]);return db[_0x9566('0x81')][_0x9566('0x38')](_0x24f73a[_0x9566('0x82')](),_0x5b7d20);});})[_0x9566('0x27')](function(_0x104674){_0x104674[_0x9566('0x55')](function(_0x877937){if(_0x877937[_0x9566('0x8c')]){_0x877937[_0x9566('0x8d')]=[];_0x877937[_0x9566('0x8c')][_0x9566('0x53')](',')['forEach'](function(_0x2984b4){_0x877937[_0x9566('0x8d')][_0x9566('0x63')](_0x3ee3a5[_0x2984b4]);});}delete _0x877937[_0x9566('0x8c')];});_0x26029b[_0x9566('0x8e')]=_0x104674;return _0x26029b;})['then'](respondWithFilteredResult(_0x58ae94,_0x5a8e61));})[_0x9566('0x8f')](handleError(_0x58ae94,null));};exports[_0x9566('0x90')]=function(_0x2d76f9,_0x222ccc){return db[_0x9566('0x2c')][_0x9566('0x91')]({'where':{'id':_0x2d76f9[_0x9566('0x92')]['id']}})[_0x9566('0x27')](handleEntityNotFound(_0x222ccc,null))[_0x9566('0x27')](removeEntity(_0x222ccc,null))[_0x9566('0x8f')](handleError(_0x222ccc,null));};exports['describe']=function(_0xbab66c,_0x33a0fe){return db[_0x9566('0x2c')]['describe']()[_0x9566('0x27')](function(_0x49a189){delete _0x49a189[_0x9566('0x93')];for(var _0x46233b=0x0;_0x46233b<Object[_0x9566('0x2e')](_0x49a189)[_0x9566('0x2f')];_0x46233b++){var _0x18e1d3=Object[_0x9566('0x2e')](_0x49a189)[_0x46233b];if(!_['startsWith'](_0x18e1d3,_0x9566('0x31'))){_0x49a189[_0x18e1d3]['columnName']=_0x18e1d3;_0x49a189[_0x18e1d3]['displayName']=_0x18e1d3;}}return _0x49a189;})[_0x9566('0x27')](function(_0xd7268b){var _0x5885dd={'where':{'$or':[{'ListId':_0xbab66c[_0x9566('0x38')]['id']},{'ListId':null}]},'raw':!![]};return db[_0x9566('0x32')][_0x9566('0x94')](_0x5885dd)[_0x9566('0x27')](function(_0xc2fb8d){for(var _0xfc8ba7=0x0;_0xfc8ba7<_0xc2fb8d[_0x9566('0x2f')];_0xfc8ba7++){var _0x481458=_0x9566('0x31')+_0xc2fb8d[_0xfc8ba7]['id'];_0xd7268b[_0x481458][_0x9566('0x95')]=_0x481458;_0xd7268b[_0x481458][_0x9566('0x96')]=_0xc2fb8d[_0xfc8ba7][_0x9566('0x97')];_0xd7268b[_0x481458]['custom']={'type':_0xc2fb8d[_0xfc8ba7][_0x9566('0x36')],'values':_0xc2fb8d[_0xfc8ba7][_0x9566('0x98')]};}Object[_0x9566('0x2e')](_0xd7268b)['forEach'](function(_0x25c283){if(!_0xd7268b[_0x25c283][_0x9566('0x3d')]('columnName')){delete _0xd7268b[_0x25c283];}});return _0xd7268b;});})[_0x9566('0x27')](respondWithResult(_0x33a0fe,null))[_0x9566('0x8f')](handleError(_0x33a0fe,null));};exports[_0x9566('0x84')]=function(_0x5b275b,_0x40a5a5){var _0x148a93;var _0x4fa277;var _0x5416b8;if(_0x5b275b[_0x9566('0x99')]['id']){delete _0x5b275b[_0x9566('0x99')]['id'];}return db[_0x9566('0x2c')][_0x9566('0x94')]({'where':{'id':[_0x5b275b[_0x9566('0x99')]['to'],_0x5b275b[_0x9566('0x99')][_0x9566('0x44')]]}})['then'](function(_0xfc251c){if(_0xfc251c){if(_0xfc251c[_0x9566('0x2f')]!==0x2){return null;}_0xfc251c[0x0]=_0xfc251c[0x0][_0x9566('0x9a')]({'plain':!![]});_0xfc251c[0x1]=_0xfc251c[0x1][_0x9566('0x9a')]({'plain':!![]});delete _0xfc251c[0x0]['id'];delete _0xfc251c[0x1]['id'];return _[_0x9566('0x9b')](_0xfc251c[0x0],_0xfc251c[0x1],function(_0x2f97c9,_0x3bd058){if(Array['isArray'](_0x3bd058)&&!_0x3bd058[_0x9566('0x2f')]){return _0x2f97c9;}else if(!_0x3bd058){return _0x2f97c9;}});}})['then'](handleEntityNotFound(_0x40a5a5,null))[_0x9566('0x27')](function(_0x7889eb){if(_0x7889eb){if(_0x7889eb[_0x9566('0x93')]&&_[_0x9566('0x68')](_0x7889eb[_0x9566('0x93')])){_0x7889eb[_0x9566('0x93')]=_0x7889eb[_0x9566('0x93')][_0x9566('0x9c')]();}logger[_0x9566('0x9d')](_0x9566('0x9e'),_0x5b275b[_0x9566('0x99')]['to'],_0x5b275b[_0x9566('0x99')]['from']);return db['CmHopper'][_0x9566('0x90')]({'where':{'ContactId':[_0x5b275b[_0x9566('0x99')]['to'],_0x5b275b[_0x9566('0x99')][_0x9566('0x44')]]}})[_0x9566('0x27')](function(_0x2e8572){logger[_0x9566('0x9d')]('[CmContact][merge][destroy][CmHopper],\x20%s',_0x2e8572);return db[_0x9566('0x9f')]['destroy']({'where':{'ContactId':[_0x5b275b['body']['to'],_0x5b275b[_0x9566('0x99')][_0x9566('0x44')]]}})['then'](function(_0x4f2a68){logger[_0x9566('0x9d')](_0x9566('0xa0'),_0x4f2a68);return db[_0x9566('0x2c')]['create'](_0x7889eb);});});}})['then'](function(_0x4eecc7){if(_0x4eecc7){_0x148a93=_0x4eecc7;_0x4fa277={'ContactId':_0x148a93['id']};_0x5416b8={'where':{'ContactId':[_0x5b275b[_0x9566('0x99')]['to'],_0x5b275b[_0x9566('0x99')][_0x9566('0x44')]]}};return db[_0x9566('0xa1')][_0x9566('0x26')](_0x4fa277,_0x5416b8);}})[_0x9566('0x27')](function(){if(_0x148a93){return db[_0x9566('0xa2')]['update'](_0x4fa277,_0x5416b8);}})[_0x9566('0x27')](function(){if(_0x148a93){return db[_0x9566('0xa3')][_0x9566('0x26')](_0x4fa277,_0x5416b8);}})[_0x9566('0x27')](function(){if(_0x148a93){return db[_0x9566('0xa4')]['update'](_0x4fa277,_0x5416b8);}})[_0x9566('0x27')](function(){if(_0x148a93){return db[_0x9566('0xa5')]['update'](_0x4fa277,_0x5416b8);}})['then'](function(){if(_0x148a93){return db['MailInteraction'][_0x9566('0x26')](_0x4fa277,_0x5416b8);}})[_0x9566('0x27')](function(){if(_0x148a93){return db[_0x9566('0xa5')]['update'](_0x4fa277,_0x5416b8);}})[_0x9566('0x27')](function(){if(_0x148a93){return db[_0x9566('0xa6')][_0x9566('0x26')](_0x4fa277,_0x5416b8);}})[_0x9566('0x27')](function(){if(_0x148a93){return db['SmsMessage'][_0x9566('0x26')](_0x4fa277,_0x5416b8);}})[_0x9566('0x27')](function(){if(_0x148a93){return db[_0x9566('0xa7')][_0x9566('0x26')](_0x4fa277,_0x5416b8);}})[_0x9566('0x27')](function(){if(_0x148a93){return db[_0x9566('0xa8')][_0x9566('0x26')](_0x4fa277,_0x5416b8);}})[_0x9566('0x27')](function(){if(_0x148a93){return db[_0x9566('0xa9')][_0x9566('0x26')](_0x4fa277,_0x5416b8);}})[_0x9566('0x27')](function(){if(_0x148a93){return db[_0x9566('0xaa')]['update'](_0x4fa277,_0x5416b8);}})[_0x9566('0x27')](function(){if(_0x148a93){return db['CmHopperFinal'][_0x9566('0x26')](_0x4fa277,_0x5416b8);}})[_0x9566('0x27')](function(){if(_0x148a93){return db[_0x9566('0xab')][_0x9566('0x26')](_0x4fa277,_0x5416b8);}})[_0x9566('0x27')](function(){if(_0x148a93){return db['ReportAgentPreview'][_0x9566('0x26')](_0x4fa277,_0x5416b8);}})[_0x9566('0x27')](function(){if(_0x148a93){return db[_0x9566('0xac')][_0x9566('0x26')](_0x4fa277,_0x5416b8);}})[_0x9566('0x27')](function(){if(_0x148a93){return db[_0x9566('0xad')][_0x9566('0x26')](_0x4fa277,_0x5416b8);}})[_0x9566('0x27')](function(){if(_0x148a93){return db['FaxQueueReport'][_0x9566('0x26')](_0x4fa277,_0x5416b8);}})[_0x9566('0x27')](function(){if(_0x148a93){return db[_0x9566('0xae')][_0x9566('0x26')](_0x4fa277,_0x5416b8);}})[_0x9566('0x27')](function(){if(_0x148a93){return db['OpenchannelQueueReport'][_0x9566('0x26')](_0x4fa277,_0x5416b8);}})[_0x9566('0x27')](function(){if(_0x148a93){return db['SmsQueueReport']['update'](_0x4fa277,_0x5416b8);}})[_0x9566('0x27')](function(){if(_0x148a93){return db[_0x9566('0xaf')]['update'](_0x4fa277,_0x5416b8);}})[_0x9566('0x27')](function(){if(_0x148a93){return db['WhatsappInteraction'][_0x9566('0x26')](_0x4fa277,_0x5416b8);}})[_0x9566('0x27')](function(){if(_0x148a93){return db[_0x9566('0xb0')][_0x9566('0x26')](_0x4fa277,_0x5416b8);}})['then'](function(){if(_0x148a93){return db['WhatsappQueueReport'][_0x9566('0x26')](_0x4fa277,_0x5416b8);}})['then'](function(){if(_0x148a93){return db['CmContact'][_0x9566('0x90')]({'where':{'id':[_0x5b275b[_0x9566('0x99')]['to'],_0x5b275b[_0x9566('0x99')][_0x9566('0x44')]]}});}})[_0x9566('0x27')](function(){if(_0x148a93){return _0x148a93;}})[_0x9566('0x27')](respondWithResult(_0x40a5a5,null))[_0x9566('0x8f')](handleError(_0x40a5a5,null));};exports[_0x9566('0xb1')]=function(_0x48ce19,_0x4559bc){return db['CmContact'][_0x9566('0x2d')]()[_0x9566('0x27')](function(_0x38c94a){if(_0x48ce19[_0x9566('0x99')][_0x9566('0x93')]&&_[_0x9566('0x68')](_0x48ce19[_0x9566('0x99')]['tags'])){if(_0x48ce19[_0x9566('0x99')][_0x9566('0x93')][_0x9566('0x2f')]){_0x48ce19[_0x9566('0x99')][_0x9566('0x93')]=_0x48ce19[_0x9566('0x99')][_0x9566('0x93')][_0x9566('0x9c')](';')+';';}else{_0x48ce19[_0x9566('0x99')][_0x9566('0x93')]=null;}}else{_0x48ce19['body'][_0x9566('0x93')]=null;}return db['CmContact']['create'](_0x48ce19[_0x9566('0x99')],{'fields':_['keys'](_0x38c94a),'raw':!![]});})[_0x9566('0x27')](respondWithResult(_0x4559bc,0xc9))[_0x9566('0x8f')](handleError(_0x4559bc,null));};exports[_0x9566('0xb2')]=function(_0x138d24,_0x5379a8){var _0x4176f4=[];var _0x5acf37=0x0;var _0x10f187=0x0;var _0x29dc76=0x0;return db[_0x9566('0x2c')]['describe']()[_0x9566('0x27')](function(_0x4a8965){return BPromise[_0x9566('0xb3')](_0x138d24[_0x9566('0x99')],function(_0x50c83a){var _0x32d602={'where':{'$or':[]},'defaults':_0x50c83a,'fields':_[_0x9566('0x2e')](_0x4a8965),'raw':!![]};if(_0x50c83a[_0x9566('0xb4')]){for(var _0x53f142=0x0;_0x53f142<_0x50c83a['duplicates'][_0x9566('0x2f')];_0x53f142++){var _0x5e0967={};_0x5e0967[_0x50c83a['duplicates'][_0x53f142]]=_0x50c83a[_0x50c83a[_0x9566('0xb4')][_0x53f142]];_0x32d602[_0x9566('0x4c')][_0x9566('0xb5')][_0x9566('0x63')](_0x5e0967);}_0x32d602[_0x9566('0x4c')][_0x9566('0xb6')]=_0x50c83a[_0x9566('0xb6')];}return db[_0x9566('0x2c')]['findOrCreate'](_0x32d602)[_0x9566('0xb7')](function(_0x3c3583,_0x121d4d){if(_0x121d4d){_0x5acf37++;}else{_0x29dc76++;}})[_0x9566('0x8f')](function(_0x1f0858){console[_0x9566('0x28')](_0x1f0858);_0x10f187++;});});})[_0x9566('0x27')](function(_0x5c6f70){if(_0x5c6f70){return{'success':_0x5acf37,'failure':_0x10f187,'duplicates':_0x29dc76};}})[_0x9566('0x27')](respondWithResult(_0x5379a8,0xc9))[_0x9566('0x8f')](handleError(_0x5379a8,null));};exports[_0x9566('0xb8')]=function(_0x57dbbf,_0x50018b,_0x404aa8){var _0x5e99b3;return db[_0x9566('0x2c')][_0x9566('0x2d')]()[_0x9566('0x27')](function(_0x1b2ca8){return db[_0x9566('0x2c')][_0x9566('0x91')]({'where':{'id':_0x57dbbf['params']['id']},'include':[{'model':db['Tag'],'as':_0x9566('0x8d'),'attributes':['id','name','color'],'required':_0x57dbbf[_0x9566('0x38')][_0x9566('0x67')]?!![]:![]}],'attributes':_[_0x9566('0x2e')](_0x1b2ca8)});})[_0x9566('0x27')](function(_0xb67804){_0x5e99b3=_0xb67804[_0x9566('0x9a')]({'plain':!![]});var _0x2aa6d3={'where':{'$and':[{'ListId':{'$ne':null}}]}};if(_0xb67804&&_0xb67804['ListId']){if(_0xb67804[_0x9566('0xb6')]){_0x2aa6d3[_0x9566('0x4c')]['$and'][_0x9566('0x63')]({'ListId':{'$ne':_0xb67804['ListId']}});}}return db[_0x9566('0x32')]['findAll'](_0x2aa6d3);})[_0x9566('0x27')](function(_0x2f47a4){return _[_0x9566('0xb9')](_0x5e99b3,_['map'](_0x2f47a4,function(_0x573859){return util[_0x9566('0xba')](_0x9566('0xbb'),_0x573859['id']);}));})[_0x9566('0x27')](handleEntityNotFound(_0x50018b,null))[_0x9566('0x27')](respondWithResult(_0x50018b,null))[_0x9566('0x8f')](handleError(_0x50018b,null));};exports[_0x9566('0x26')]=function(_0x23927c,_0x4bd7c3){var _0x4cec84;if(_0x23927c[_0x9566('0x99')]['id']){delete _0x23927c['body']['id'];}return db[_0x9566('0x2c')][_0x9566('0x91')]({'where':{'id':_0x23927c[_0x9566('0x92')]['id']}})[_0x9566('0x27')](handleEntityNotFound(_0x4bd7c3,null))[_0x9566('0x27')](saveUpdates(_0x23927c[_0x9566('0x99')],null))[_0x9566('0x27')](function(_0x5eb078){_0x4cec84=_0x5eb078;var _0x520777={'where':{'$and':[{'ListId':{'$ne':null}}]}};if(_0x5eb078&&_0x5eb078[_0x9566('0xb6')]){if(_0x5eb078[_0x9566('0xb6')]){_0x520777[_0x9566('0x4c')]['$and'][_0x9566('0x63')]({'ListId':{'$ne':_0x5eb078[_0x9566('0xb6')]}});}}return db[_0x9566('0x32')][_0x9566('0x94')](_0x520777);})[_0x9566('0x27')](function(_0x17cb27){if(_0x17cb27){return _['omit'](_[_0x9566('0xbc')](_0x23927c[_0x9566('0x99')],function(_0x54345a,_0xdf238e){return _[_0x9566('0x30')](_0xdf238e,_0x9566('0x31'));}),_[_0x9566('0x54')](_0x17cb27,function(_0x2cd709){return util['format']('cf_%d',_0x2cd709['id']);}));}})[_0x9566('0x27')](function(_0x10137b){if(_0x10137b&&!_['isEmpty'](_0x10137b)){var _0x19a3b8=squel[_0x9566('0x26')]()[_0x9566('0xbd')](_0x9566('0xbe'))[_0x9566('0xbf')](_0x10137b)[_0x9566('0x4c')](_0x9566('0xc0'),_0x23927c[_0x9566('0x92')]['id'])[_0x9566('0xc1')]();return db['sequelize'][_0x9566('0x38')](_0x19a3b8[_0x9566('0x5e')],{'replacements':_0x19a3b8[_0x9566('0x98')]});}})[_0x9566('0x27')](function(){if(_0x23927c[_0x9566('0x99')]['phone']&&_0x4cec84){return db[_0x9566('0xc2')]['update']({'phone':_0x23927c[_0x9566('0x99')][_0x9566('0xc3')]},{'where':{'ContactId':_0x4cec84['id']}});}})['then'](function(){return _0x4cec84;})[_0x9566('0x27')](respondWithResult(_0x4bd7c3,null))[_0x9566('0x8f')](handleError(_0x4bd7c3,null));};exports[_0x9566('0xc4')]=function(_0x2760ed,_0x9067f8,_0x1cb946){var _0x52dbb4={};var _0x474619={};var _0x897177;var _0x42e10d;return db[_0x9566('0x2c')][_0x9566('0x33')]({'where':{'id':_0x2760ed[_0x9566('0x92')]['id']}})[_0x9566('0x27')](handleEntityNotFound(_0x9067f8,null))[_0x9566('0x27')](function(_0x52220e){if(_0x52220e){_0x897177=_0x52220e;_0x474619[_0x9566('0x37')]=_[_0x9566('0x2e')](db[_0x9566('0x51')]['rawAttributes']);_0x474619[_0x9566('0x38')]=_[_0x9566('0x2e')](_0x2760ed[_0x9566('0x38')]);_0x474619[_0x9566('0x39')]=_[_0x9566('0x3a')](_0x474619['model'],_0x474619['query']);_0x52dbb4[_0x9566('0x3b')]=_[_0x9566('0x3a')](_0x474619[_0x9566('0x37')],qs[_0x9566('0x3c')](_0x2760ed[_0x9566('0x38')][_0x9566('0x3c')]));_0x52dbb4[_0x9566('0x3b')]=_0x52dbb4[_0x9566('0x3b')]['length']?_0x52dbb4['attributes']:_0x474619[_0x9566('0x37')];_0x52dbb4[_0x9566('0x3e')]=qs[_0x9566('0x3f')](_0x2760ed[_0x9566('0x38')]['sort']);_0x52dbb4[_0x9566('0x4c')]=qs['filters'](_[_0x9566('0x40')](_0x2760ed[_0x9566('0x38')],_0x474619['filters']));if(_0x2760ed[_0x9566('0x38')][_0x9566('0x60')]){_0x52dbb4[_0x9566('0x4c')]=_[_0x9566('0x84')](_0x52dbb4[_0x9566('0x4c')],{'$or':_[_0x9566('0x54')](_0x52dbb4[_0x9566('0x3b')],function(_0x24cc2f){var _0xa8cd2e={};_0xa8cd2e[_0x24cc2f]={'$like':'%'+_0x2760ed[_0x9566('0x38')][_0x9566('0x60')]+'%'};return _0xa8cd2e;})});}_0x52dbb4=_[_0x9566('0x84')]({},_0x52dbb4,_0x2760ed['options']);return _0x897177[_0x9566('0xc4')](_0x52dbb4);}})[_0x9566('0x27')](function(_0x2d3b94){if(_0x2d3b94){_0x42e10d=_0x2d3b94['length'];if(!_0x2760ed['query'][_0x9566('0x3d')](_0x9566('0xc5'))){_0x52dbb4[_0x9566('0x21')]=qs[_0x9566('0x21')](_0x2760ed[_0x9566('0x38')][_0x9566('0x21')]);_0x52dbb4[_0x9566('0x20')]=qs[_0x9566('0x20')](_0x2760ed[_0x9566('0x38')][_0x9566('0x20')]);}return _0x897177[_0x9566('0xc4')](_0x52dbb4);}})['then'](function(_0x143050){if(_0x143050){return _0x143050?{'count':_0x42e10d,'rows':_0x143050}:null;}})[_0x9566('0x27')](respondWithResult(_0x9067f8,null))[_0x9566('0x8f')](handleError(_0x9067f8,null));};exports[_0x9566('0xc6')]=function(_0x4f5101,_0x163579,_0x23db7b){if(_0x4f5101[_0x9566('0x99')]['id']){delete _0x4f5101[_0x9566('0x99')]['id'];}return db['CmContact']['findOne']({'where':{'id':_0x4f5101[_0x9566('0x92')]['id']}})[_0x9566('0x27')](handleEntityNotFound(_0x163579,null))[_0x9566('0x27')](function(_0x3eb0e7){if(_0x3eb0e7){return _0x3eb0e7[_0x9566('0xc6')](_0x4f5101['body'][_0x9566('0xc7')]||[]);}return null;})['then'](respondWithResult(_0x163579,null))[_0x9566('0x8f')](handleError(_0x163579,null));};exports['getHoppers']=function(_0x3dd33d,_0x60b969,_0x4cadc1){var _0x1052c8={'raw':![],'where':{}};var _0x580820={};var _0x2f68c9={'count':0x0,'rows':[]};return db[_0x9566('0x2c')][_0x9566('0x33')]({'where':{'id':_0x3dd33d[_0x9566('0x92')]['id']}})[_0x9566('0x27')](handleEntityNotFound(_0x60b969,null))[_0x9566('0x27')](function(_0x3c4c91){if(_0x3c4c91){_0x580820[_0x9566('0x37')]=_[_0x9566('0x2e')](db[_0x9566('0xc2')]['rawAttributes']);_0x580820[_0x9566('0x38')]=_[_0x9566('0x2e')](_0x3dd33d[_0x9566('0x38')]);_0x580820[_0x9566('0x39')]=_[_0x9566('0x3a')](_0x580820['model'],_0x580820[_0x9566('0x38')]);_0x1052c8[_0x9566('0x3b')]=_[_0x9566('0x3a')](_0x580820['model'],qs[_0x9566('0x3c')](_0x3dd33d[_0x9566('0x38')]['fields']));_0x1052c8['attributes']=_0x1052c8['attributes'][_0x9566('0x2f')]?_0x1052c8[_0x9566('0x3b')]:_0x580820[_0x9566('0x37')];if(!_0x3dd33d[_0x9566('0x38')][_0x9566('0x3d')](_0x9566('0xc5'))){_0x1052c8[_0x9566('0x21')]=qs['limit'](_0x3dd33d['query'][_0x9566('0x21')]);_0x1052c8[_0x9566('0x20')]=qs[_0x9566('0x20')](_0x3dd33d[_0x9566('0x38')][_0x9566('0x20')]);}_0x1052c8[_0x9566('0x3e')]=qs['sort'](_0x3dd33d[_0x9566('0x38')][_0x9566('0x3f')]);_0x1052c8['where']=qs[_0x9566('0x39')](_[_0x9566('0x40')](_0x3dd33d[_0x9566('0x38')],_0x580820[_0x9566('0x39')]));_0x1052c8['where'][_0x9566('0xc8')]=_0x3c4c91['id'];if(_0x3dd33d[_0x9566('0x38')][_0x9566('0x60')]){_0x1052c8[_0x9566('0x4c')]=_[_0x9566('0x84')](_0x1052c8[_0x9566('0x4c')],{'$or':_[_0x9566('0x54')](_0x1052c8[_0x9566('0x3b')],function(_0x38c9f2){var _0x287d6b={};_0x287d6b[_0x38c9f2]={'$like':'%'+_0x3dd33d[_0x9566('0x38')][_0x9566('0x60')]+'%'};return _0x287d6b;})});}_0x1052c8=_[_0x9566('0x84')]({},_0x1052c8,_0x3dd33d[_0x9566('0xc9')]);return db['CmHopper'][_0x9566('0x1f')]({'where':_0x1052c8[_0x9566('0x4c')]})[_0x9566('0x27')](function(_0x242d97){_0x2f68c9[_0x9566('0x1f')]=_0x242d97;if(_0x3dd33d[_0x9566('0x38')]['includeAll']){_0x1052c8[_0x9566('0xca')]=[{'all':!![]}];}return db[_0x9566('0xc2')][_0x9566('0x94')](_0x1052c8);})[_0x9566('0x27')](function(_0x4a6773){_0x2f68c9[_0x9566('0x8e')]=_0x4a6773;return _0x2f68c9;});}})[_0x9566('0x27')](respondWithFilteredResult(_0x60b969,_0x1052c8))[_0x9566('0x8f')](handleError(_0x60b969,null));};exports['getHopperHistories']=function(_0x419689,_0x335f96,_0x20d530){var _0x3de25a={'raw':!![],'where':{}};var _0x161e0c={};var _0x5d17f1={'count':0x0,'rows':[]};return db[_0x9566('0x2c')][_0x9566('0x33')]({'where':{'id':_0x419689[_0x9566('0x92')]['id']}})[_0x9566('0x27')](handleEntityNotFound(_0x335f96,null))['then'](function(_0x341e30){if(_0x341e30){_0x161e0c[_0x9566('0x37')]=_[_0x9566('0x2e')](db['CmHopperHistory'][_0x9566('0xcb')]);_0x161e0c[_0x9566('0x38')]=_[_0x9566('0x2e')](_0x419689[_0x9566('0x38')]);_0x161e0c[_0x9566('0x39')]=_['intersection'](_0x161e0c[_0x9566('0x37')],_0x161e0c[_0x9566('0x38')]);_0x3de25a[_0x9566('0x3b')]=_[_0x9566('0x3a')](_0x161e0c[_0x9566('0x37')],qs[_0x9566('0x3c')](_0x419689['query'][_0x9566('0x3c')]));_0x3de25a[_0x9566('0x3b')]=_0x3de25a[_0x9566('0x3b')][_0x9566('0x2f')]?_0x3de25a[_0x9566('0x3b')]:_0x161e0c['model'];if(!_0x419689['query']['hasOwnProperty'](_0x9566('0xc5'))){_0x3de25a[_0x9566('0x21')]=qs['limit'](_0x419689['query'][_0x9566('0x21')]);_0x3de25a['offset']=qs[_0x9566('0x20')](_0x419689[_0x9566('0x38')]['offset']);}_0x3de25a[_0x9566('0x3e')]=qs[_0x9566('0x3f')](_0x419689[_0x9566('0x38')][_0x9566('0x3f')]);_0x3de25a[_0x9566('0x4c')]=qs['filters'](_[_0x9566('0x40')](_0x419689[_0x9566('0x38')],_0x161e0c[_0x9566('0x39')]));_0x3de25a[_0x9566('0x4c')][_0x9566('0xc8')]=_0x341e30['id'];if(_0x419689[_0x9566('0x38')][_0x9566('0x60')]){_0x3de25a[_0x9566('0x4c')]=_[_0x9566('0x84')](_0x3de25a[_0x9566('0x4c')],{'$or':_[_0x9566('0x54')](_0x3de25a[_0x9566('0x3b')],function(_0x2e14a6){var _0x2a4354={};_0x2a4354[_0x2e14a6]={'$like':'%'+_0x419689[_0x9566('0x38')][_0x9566('0x60')]+'%'};return _0x2a4354;})});}_0x3de25a=_['merge']({},_0x3de25a,_0x419689[_0x9566('0xc9')]);return db[_0x9566('0xab')][_0x9566('0x1f')]({'where':_0x3de25a[_0x9566('0x4c')]})['then'](function(_0x318a9a){_0x5d17f1[_0x9566('0x1f')]=_0x318a9a;if(_0x419689['query'][_0x9566('0xcc')]){_0x3de25a[_0x9566('0xca')]=[{'all':!![]}];}return db[_0x9566('0xab')]['findAll'](_0x3de25a);})[_0x9566('0x27')](function(_0xa8ab0a){_0x5d17f1[_0x9566('0x8e')]=_0xa8ab0a;return _0x5d17f1;});}})[_0x9566('0x27')](respondWithFilteredResult(_0x335f96,_0x3de25a))[_0x9566('0x8f')](handleError(_0x335f96,null));};exports[_0x9566('0xcd')]=function(_0x28a49c,_0x185f40,_0x161365){var _0x12aeac={'raw':!![],'where':{}};var _0x2f7427={};var _0x368d64={'count':0x0,'rows':[]};return db['CmContact'][_0x9566('0x33')]({'where':{'id':_0x28a49c['params']['id']}})['then'](handleEntityNotFound(_0x185f40,null))['then'](function(_0x80dfeb){if(_0x80dfeb){_0x2f7427[_0x9566('0x37')]=_[_0x9566('0x2e')](db[_0x9566('0xce')][_0x9566('0xcb')]);_0x2f7427[_0x9566('0x38')]=_[_0x9566('0x2e')](_0x28a49c['query']);_0x2f7427[_0x9566('0x39')]=_['intersection'](_0x2f7427[_0x9566('0x37')],_0x2f7427[_0x9566('0x38')]);_0x12aeac['attributes']=_[_0x9566('0x3a')](_0x2f7427[_0x9566('0x37')],qs[_0x9566('0x3c')](_0x28a49c[_0x9566('0x38')][_0x9566('0x3c')]));_0x12aeac[_0x9566('0x3b')]=_0x12aeac['attributes'][_0x9566('0x2f')]?_0x12aeac[_0x9566('0x3b')]:_0x2f7427['model'];if(!_0x28a49c[_0x9566('0x38')][_0x9566('0x3d')]('nolimit')){_0x12aeac['limit']=qs[_0x9566('0x21')](_0x28a49c['query']['limit']);_0x12aeac['offset']=qs['offset'](_0x28a49c[_0x9566('0x38')][_0x9566('0x20')]);}_0x12aeac[_0x9566('0x3e')]=qs[_0x9566('0x3f')](_0x28a49c[_0x9566('0x38')][_0x9566('0x3f')]);_0x12aeac[_0x9566('0x4c')]=qs[_0x9566('0x39')](_[_0x9566('0x40')](_0x28a49c[_0x9566('0x38')],_0x2f7427[_0x9566('0x39')]));_0x12aeac[_0x9566('0x4c')]['ContactId']=_0x80dfeb['id'];if(_0x28a49c[_0x9566('0x38')]['filter']){_0x12aeac[_0x9566('0x4c')]=_[_0x9566('0x84')](_0x12aeac[_0x9566('0x4c')],{'$or':_[_0x9566('0x54')](_0x12aeac[_0x9566('0x3b')],function(_0x377b0f){var _0x331617={};_0x331617[_0x377b0f]={'$like':'%'+_0x28a49c[_0x9566('0x38')][_0x9566('0x60')]+'%'};return _0x331617;})});}_0x12aeac=_[_0x9566('0x84')]({},_0x12aeac,_0x28a49c[_0x9566('0xc9')]);return db['CmHopperFinal'][_0x9566('0x1f')]({'where':_0x12aeac['where']})[_0x9566('0x27')](function(_0x383bc7){_0x368d64[_0x9566('0x1f')]=_0x383bc7;if(_0x28a49c[_0x9566('0x38')][_0x9566('0xcc')]){_0x12aeac[_0x9566('0xca')]=[{'all':!![]}];}return db[_0x9566('0xce')][_0x9566('0x94')](_0x12aeac);})[_0x9566('0x27')](function(_0x2f6f2d){_0x368d64[_0x9566('0x8e')]=_0x2f6f2d;return _0x368d64;});}})[_0x9566('0x27')](respondWithFilteredResult(_0x185f40,_0x12aeac))[_0x9566('0x8f')](handleError(_0x185f40,null));};exports[_0x9566('0xcf')]=function(_0x4d1d99,_0x46a089,_0x56b19b){var _0x1b4f04={'raw':!![],'where':{}};var _0x4fd388={};var _0x140594={'count':0x0,'rows':[]};return db[_0x9566('0x2c')][_0x9566('0x33')]({'where':{'id':_0x4d1d99[_0x9566('0x92')]['id']}})[_0x9566('0x27')](handleEntityNotFound(_0x46a089,null))[_0x9566('0x27')](function(_0x3272b4){if(_0x3272b4){_0x4fd388[_0x9566('0x37')]=_[_0x9566('0x2e')](db[_0x9566('0xaf')][_0x9566('0xcb')]);_0x4fd388[_0x9566('0x38')]=_[_0x9566('0x2e')](_0x4d1d99['query']);_0x4fd388['filters']=_[_0x9566('0x3a')](_0x4fd388['model'],_0x4fd388[_0x9566('0x38')]);_0x1b4f04[_0x9566('0x3b')]=_[_0x9566('0x3a')](_0x4fd388[_0x9566('0x37')],qs['fields'](_0x4d1d99['query'][_0x9566('0x3c')]));_0x1b4f04[_0x9566('0x3b')]=_0x1b4f04[_0x9566('0x3b')][_0x9566('0x2f')]?_0x1b4f04[_0x9566('0x3b')]:_0x4fd388['model'];if(!_0x4d1d99['query'][_0x9566('0x3d')](_0x9566('0xc5'))){_0x1b4f04[_0x9566('0x21')]=qs[_0x9566('0x21')](_0x4d1d99['query'][_0x9566('0x21')]);_0x1b4f04[_0x9566('0x20')]=qs[_0x9566('0x20')](_0x4d1d99[_0x9566('0x38')][_0x9566('0x20')]);}_0x1b4f04[_0x9566('0x3e')]=qs[_0x9566('0x3f')](_0x4d1d99[_0x9566('0x38')][_0x9566('0x3f')]);_0x1b4f04[_0x9566('0x4c')]=qs[_0x9566('0x39')](_[_0x9566('0x40')](_0x4d1d99[_0x9566('0x38')],_0x4fd388[_0x9566('0x39')]));_0x1b4f04[_0x9566('0x4c')][_0x9566('0xc8')]=_0x3272b4['id'];if(_0x4d1d99[_0x9566('0x38')][_0x9566('0x60')]){_0x1b4f04[_0x9566('0x4c')]=_[_0x9566('0x84')](_0x1b4f04[_0x9566('0x4c')],{'$or':_[_0x9566('0x54')](_0x1b4f04['attributes'],function(_0x3b6b25){var _0x4539b5={};_0x4539b5[_0x3b6b25]={'$like':'%'+_0x4d1d99[_0x9566('0x38')][_0x9566('0x60')]+'%'};return _0x4539b5;})});}_0x1b4f04=_[_0x9566('0x84')]({},_0x1b4f04,_0x4d1d99[_0x9566('0xc9')]);return db[_0x9566('0xaf')][_0x9566('0x1f')]({'where':_0x1b4f04[_0x9566('0x4c')]})[_0x9566('0x27')](function(_0x14a4f6){_0x140594[_0x9566('0x1f')]=_0x14a4f6;if(_0x4d1d99[_0x9566('0x38')][_0x9566('0xcc')]){_0x1b4f04[_0x9566('0xca')]=[{'all':!![]}];}return db['JscriptySessionReport'][_0x9566('0x94')](_0x1b4f04);})[_0x9566('0x27')](function(_0x269b5b){_0x140594[_0x9566('0x8e')]=_0x269b5b;return _0x140594;});}})[_0x9566('0x27')](respondWithFilteredResult(_0x46a089,_0x1b4f04))[_0x9566('0x8f')](handleError(_0x46a089,null));};exports[_0x9566('0xd0')]=function(_0x19b3c6,_0x579771,_0x2f6e57){try{if(!_0x19b3c6['body'][_0x9566('0xb6')]){throw new Error(_0x9566('0xd1'));}if(!_0x19b3c6[_0x9566('0x99')][_0x9566('0xd2')]){throw new Error(_0x9566('0xd3'));}if(!_0x19b3c6['body'][_0x9566('0xd4')]){throw new Error('No\x20association\x20values\x20specified!');}if(!_0x19b3c6[_0x9566('0x99')][_0x9566('0xd5')]){throw new Error(_0x9566('0xd6'));}var _0x1c792c=_0x19b3c6['body'][_0x9566('0xd2')][_0x9566('0x53')](',');var _0x42e6e0=_0x19b3c6[_0x9566('0x99')]['binding_values']['split'](',');if(!_0x1c792c[_0x9566('0x2f')]||!_0x42e6e0[_0x9566('0x2f')]||_0x1c792c[_0x9566('0x2f')]!==_0x42e6e0[_0x9566('0x2f')]){throw new Error(_0x9566('0xd7'));}_0x19b3c6[_0x9566('0x99')][_0x9566('0x3c')]=_['zipObject'](_0x1c792c,_0x42e6e0);if(!_0x19b3c6[_0x9566('0x99')]['fields'][_0x9566('0xc3')]){throw new Error(_0x9566('0xd8'));}if(!_0x19b3c6[_0x9566('0x99')][_0x9566('0x3c')]['firstName']){throw new Error('No\x20firstName\x20column\x20specified');}var _0x1a6ad4=path[_0x9566('0x9c')](config['root'],_0x9566('0xd9'),_0x19b3c6[_0x9566('0xda')][_0x9566('0xdb')]);fs[_0x9566('0xdc')](_0x1a6ad4,parseInt('0777',0x8));var _0x4199df=require(_0x9566('0xdd'))[_0x9566('0xde')](path[_0x9566('0x9c')](__dirname,_0x9566('0xdf')),[_0x1a6ad4,_0x19b3c6[_0x9566('0x99')][_0x9566('0xd2')],_0x19b3c6[_0x9566('0x99')][_0x9566('0xd4')],_0x19b3c6[_0x9566('0x99')][_0x9566('0xb6')],_0x19b3c6[_0x9566('0x99')][_0x9566('0xe0')],_0x19b3c6['body'][_0x9566('0xb4')],_0x19b3c6[_0x9566('0x99')][_0x9566('0xd5')]]);return _0x579771['status'](0xc8)['json']({'message':'File\x20uploaded\x20correctly!','pid':_0x4199df['pid']});}catch(_0x4ed450){return _0x579771[_0x9566('0x1d')](0x1f4)['send'](_0x4ed450);}};exports['upload']=function(_0x5288ca,_0xf009ce,_0x5a717b){var _0x2be708=fs['createReadStream'](_0x5288ca['file'][_0x9566('0xe1')]);Papa[_0x9566('0xe2')](_0x2be708,{'header':!![],'skipEmptyLines':!![],'preview':0x1,'complete':function(_0x70440b){return _0xf009ce[_0x9566('0x1d')](0xc8)['json']({'file':_0x5288ca[_0x9566('0xda')],'fields':_0x70440b[_0x9566('0xe3')]['fields']});}});};exports[_0x9566('0xe4')]=function(_0x2420c1,_0x443189,_0x106e78){return db[_0x9566('0x58')][_0x9566('0x94')]({'raw':!![],'attributes':['id'],'where':{'role':_0x9566('0x7e')}})[_0x9566('0x27')](function(_0x4caa98){var _0x222b34=![];if(!_0x2420c1['body'][_0x9566('0xb6')]){throw new Error(_0x9566('0xd1'));}if(!_0x2420c1['body'][_0x9566('0xe5')][_0x9566('0xc3')]){throw new Error(_0x9566('0xd8'));}if(!_0x2420c1[_0x9566('0x99')][_0x9566('0xe5')][_0x9566('0xe6')]){throw new Error(_0x9566('0xe7'));}if(!_0x2420c1[_0x9566('0x99')][_0x9566('0xd5')]){throw new Error(_0x9566('0xd6'));}var _0x1bf0a3=require(_0x9566('0xdd'))[_0x9566('0xde')](path[_0x9566('0x9c')](__dirname,_0x9566('0xe8')),[_0x2420c1['params']['id'],JSON[_0x9566('0xe9')](_0x2420c1[_0x9566('0x99')]),JSON[_0x9566('0xe9')](_0x4caa98)]);_0x1bf0a3['on'](_0x9566('0xea'),function(_0x517e68){_0x222b34=!![];return _0x443189['status'](0xc8)[_0x9566('0xeb')]({'message':_0x9566('0xec'),'pid':_0x1bf0a3[_0x9566('0xed')]});});_0x1bf0a3['on'](_0x9566('0xee'),function(_0xcb9ddd){if(_0xcb9ddd&&!_0x222b34){return _0x443189[_0x9566('0x1d')](0x1f4)[_0x9566('0xeb')]({'message':_0x9566('0xef'),'pid':_0x1bf0a3[_0x9566('0xed')]});}});})[_0x9566('0x8f')](handleError(_0x443189,null));};exports[_0x9566('0xf0')]=function(_0x4cedaf,_0x45217c){var _0x4eb10c=[_0x9566('0xf1'),_0x9566('0xf2'),'sms',_0x9566('0xf3'),_0x9566('0xf4'),_0x9566('0xf5'),_0x9566('0xf6')];var _0x258246={'offset':0x0,'order':qs[_0x9566('0x3f')](_0x9566('0xf7'))},_0x1a2439={'count':0x0,'rows':[]};Promise['resolve']()[_0x9566('0x27')](function(){if(_0x4cedaf[_0x9566('0x38')][_0x9566('0xf8')]){if(!_[_0x9566('0xf9')](_0x4eb10c,_0x4cedaf[_0x9566('0x38')][_0x9566('0xf8')][_0x9566('0xfa')]())){throw new Error('Invalid\x20channel');}_0x4eb10c=[_0x4cedaf[_0x9566('0x38')][_0x9566('0xf8')]['toLowerCase']()];}if(_0x4cedaf['query'][_0x9566('0xfb')]){try{var _0x1f813f=JSON[_0x9566('0xe2')](_0x4cedaf[_0x9566('0x38')][_0x9566('0xfb')]);if(!moment(_0x1f813f[_0x9566('0x44')])['isValid']()){throw new Error('Invalid\x20date\x20for\x20range\x20from\x20filter');}if(!moment(_0x1f813f['to'])[_0x9566('0xfc')]()){throw new Error(_0x9566('0xfd'));}}catch(_0x3f5f2c){throw new Error(_0x9566('0xfe'));}}if(!_0x4cedaf[_0x9566('0x38')]['hasOwnProperty'](_0x9566('0xc5'))){_0x258246[_0x9566('0x21')]=qs[_0x9566('0x21')](_0x4cedaf['query'][_0x9566('0x21')]||0xa);_0x258246[_0x9566('0x20')]=qs[_0x9566('0x20')](_0x4cedaf['query'][_0x9566('0x20')]);}var _0x5f0cec=_0x4eb10c['map'](function(_0x2a440f){if(_0x2a440f==='voice'){var _0x56a83e={'attributes':['id',_0x9566('0xff'),_0x9566('0x36'),_0x9566('0x100'),_0x9566('0x101'),'callerid',_0x9566('0x102'),'endtime',_0x9566('0x103'),'note',_0x9566('0x104'),'userDisposition',_0x9566('0x105'),_0x9566('0x106'),_0x9566('0x107')],'where':{'ContactId':_0x4cedaf[_0x9566('0x92')]['id']},'include':[{'model':db[_0x9566('0x58')],'as':'User','attributes':['id',_0x9566('0x2a'),_0x9566('0x108'),_0x9566('0x97')]}],'order':[[_0x9566('0x104'),_0x9566('0x78')]]};if(_0x4cedaf[_0x9566('0x38')][_0x9566('0xfb')]){_0x56a83e[_0x9566('0x4c')][_0x9566('0x104')]={'$gte':_0x1f813f[_0x9566('0x44')],'$lte':_0x1f813f['to']};}return db[_0x9566('0xac')][_0x9566('0x109')](_0x56a83e)[_0x9566('0x27')](function(_0x1f1db3){_0x1a2439['count']+=_0x1f1db3[_0x9566('0x1f')];return _['map'](_0x1f1db3['rows'],function(_0x46b684){var _0x2972da=_0x46b684[_0x9566('0x9a')]({'plain':!![]});_0x2972da['channel']=_0x2a440f;if(_0x2972da['User']){_0x2972da[_0x9566('0x58')]={'id':_0x2972da[_0x9566('0x58')]['id'],'name':_0x2972da[_0x9566('0x58')][_0x9566('0x2a')],'fullname':_0x2972da[_0x9566('0x58')][_0x9566('0x108')],'alias':_0x2972da[_0x9566('0x58')][_0x9566('0x97')]};}return _0x2972da;});});}else{var _0x327fb3=_[_0x9566('0x10a')](_0x2a440f)+(_0x2a440f===_0x9566('0xf2')?'Website':_0x9566('0x10b'));var _0x262856={'attributes':['id',_0x9566('0x10c'),_0x9566('0x10d'),'createdAt',_0x9566('0x10e'),'disposition',_0x9566('0x10f'),_0x9566('0x110'),_0x9566('0x107'),_0x327fb3+'Id'],'where':{'ContactId':_0x4cedaf[_0x9566('0x92')]['id']},'include':[{'model':db[_0x327fb3],'as':_0x9566('0x10b'),'attributes':['id',_0x9566('0x2a'),_0x9566('0x111')]},{'model':db[_0x9566('0x58')],'as':'Owner','attributes':['id',_0x9566('0x2a'),_0x9566('0x108')]},{'model':db['Tag'],'as':_0x9566('0x8d'),'attributes':['id','name',_0x9566('0x43')],'through':{'attributes':[]}}],'order':[[_0x9566('0x104'),_0x9566('0x78')]]};if(_0x4cedaf[_0x9566('0x38')][_0x9566('0xfb')]){_0x262856[_0x9566('0x4c')][_0x9566('0x104')]={'$gte':_0x1f813f['from'],'$lte':_0x1f813f['to']};}switch(_0x2a440f){case _0x9566('0xf2'):_0x262856[_0x9566('0x3b')][_0x9566('0x63')]('browserName','customerIp',_0x9566('0x112'),_0x9566('0x113'),'osName',_0x9566('0x114'),_0x9566('0x115'),'ratingValue',_0x9566('0x116'));break;case _0x9566('0xf1'):_0x262856[_0x9566('0x3b')][_0x9566('0x63')](_0x9566('0x117'),_0x9566('0x118'));break;case'openchannel':_0x262856['attributes'][_0x9566('0x63')](_0x9566('0x119'),'threadId');break;}return db[_[_0x9566('0x10a')](_0x2a440f)+'Interaction'][_0x9566('0x109')](_0x262856)[_0x9566('0x27')](function(_0xd49cfb){_0x1a2439[_0x9566('0x1f')]+=_0xd49cfb[_0x9566('0x1f')];return _['map'](_0xd49cfb[_0x9566('0x8e')],function(_0x19cff6){var _0x1aaab0=_0x19cff6['get']({'plain':!![]});_0x1aaab0[_0x9566('0xf8')]=_0x2a440f;if(_0x1aaab0[_0x9566('0x11a')]){_0x1aaab0[_0x9566('0x11a')]={'id':_0x1aaab0[_0x9566('0x11a')]['id'],'name':_0x1aaab0[_0x9566('0x11a')][_0x9566('0x2a')],'fullname':_0x1aaab0['Owner'][_0x9566('0x108')]};}return _0x1aaab0;});});}});return Promise['all'](_0x5f0cec);})[_0x9566('0x27')](function(_0x719d8f){return _(_0x719d8f)[_0x9566('0x11b')]()[_0x9566('0x11c')]('createdAt')['reverse']()[_0x9566('0x52')]();})[_0x9566('0x27')](function(_0x3cebec){_0x1a2439[_0x9566('0x8e')]=_0x258246[_0x9566('0x21')]?_0x3cebec['slice'](_0x258246[_0x9566('0x20')],_0x258246[_0x9566('0x20')]+_0x258246['limit']):_0x3cebec;return _0x1a2439;})[_0x9566('0x27')](respondWithFilteredResult(_0x45217c,_0x258246))[_0x9566('0x8f')](handleError(_0x45217c,null));};
\ No newline at end of file
+var _0xb4f2=['c.mobile\x20LIKE\x20?','c.fax\x20LIKE\x20?','isEmail','c.firstName\x20LIKE\x20?','c.lastName\x20LIKE\x20?','c.email\x20LIKE\x20?','group','c.id','Sequelize','QueryTypes','clone','having','t.id\x20IN\x20?','resolve','role','agent','some','User','user','c.ListId\x20IS\x20NULL','sequelize','toString','keyBy','merge','c.phone','c.mobile','c.fax','c.email','c.ListId','c.createdAt','c.CompanyId','TagIds','Tags','rows','catch','params','columnName','displayName','analytics','CmCustomField','alias','custom','values','body','findAll','get','mergeWith','isArray','tags','join','info','[CmContact][merge]\x20to\x20%s\x20from\x20%s','[CmContact][merge][destroy][CmHopper],\x20%s','CmHopperBlack','ChatInteraction','ChatMessage','ChatOfflineMessage','MailInteraction','MailMessage','SmsInteraction','SmsMessage','FaxMessage','CmHopperFinal','CmHopperHistory','ReportAgentPreview','VoiceCallReport','ChatQueueReport','MailQueueReport','OpenchannelQueueReport','SmsQueueReport','JscriptySessionReport','WhatsappInteraction','WhatsappMessage','WhatsappQueueReport','create','dialTimezone','timezones','utcOffset','bulkCreate','duplicates','$or','findOrCreate','spread','show','Tag','$and','omit','format','cf_%d','pickBy','table','setFields','id\x20=\x20?','toParam','phone','getTags','findOne','rawAttributes','pick','options','setTags','ids','getHoppers','ContactId','includeAll','include','CmHopper','getHopperHistories','getHopperFinals','getJscriptySessions','uploadCsv','No\x20ListId\x20specified','binding_keys','No\x20association\x20keys\x20specified!','binding_values','No\x20association\x20values\x20specified!','socket_timestamp','Unable\x20to\x20synchronize\x20socket,\x20no\x20timestamp\x20passed','Incorrect\x20binding\x20parameters\x20passed!','No\x20firstName\x20column\x20specified','root','server/files/tmp','file','chmodSync','0777','child_process','fork','../../components/import/cm/csv','CompanyId','json','File\x20uploaded\x20correctly!','send','createReadStream','parse','import','binding','firstName','../../components/import/cm/csv2','stringify','error\x20child\x20process','pid','getJourney','mail','sms','openchannel','whatsapp','voice','-createdAt','includes','channel','toLowerCase','range','isValid','Invalid\x20date\x20for\x20range\x20from\x20filter','Invalid\x20date\x20for\x20range\x20to\x20filter','Invalid\x20createdAt\x20filter','uniqueid','destination','callerid','starttime','endtime','duration','userDisposition','userSecondDisposition','userThirdDisposition','UserId','fullname','createdAt','DESC','findAndCountAll','startCase','chat','Website','Account','closed','closedAt','note','thirdDisposition','key','Owner','browserName','customerIp','customerPort','deviceModel','osName','ratingMessage','ratingType','ratingValue','referer','subject','substatus','externalUrl','threadId','Interaction','sortBy','reverse','moment','bluebird','util','path','lodash','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','../../config/environment','../../mysqldb','redis','defaults','socket.io-emitter','./cmContact.socket','register','status','offset','undefined','limit','count','set','Content-Range','update','then','destroy','end','sendStatus','error','stack','name','index','CmContact','describe','keys','length','startsWith','push','trimStart','cf_','fieldType','model','filters','intersection','query','fields','attributes','hasOwnProperty','nolimit','order','sort','where','select','field','color','from','tools_tags','cm_contacts','left_join','cm_user_has_contacts','uc.CmContactId\x20=\x20c.id','cm_contact_has_tags','ct.CmContactId\x20=\x20c.id','t.id\x20=\x20ct.TagId','search','parseSearch','sqlOperator','conditions','find','value','split','map','CONCAT(\x27,\x27,\x20`TagIds`,\x20\x27,\x27)\x20LIKE\x20?','union','and','uc.UserId\x20=\x20?','dateOfBirth','datetime','castTo','type','text','start','filter','isNil','Contact','isEmpty','forEach','ListId','c.ListId\x20IN\x20?','concat','CONCAT_WS(\x27\x20\x27,\x20c.firstName,\x20c.lastName,\x20c.email)\x20LIKE\x20?','\x20=\x20?','tag','replace','getFullTextValue','isNumeric','c.id\x20LIKE\x20?','c.phone\x20LIKE\x20?'];(function(_0x58e469,_0x95ee3e){var _0x4c01c5=function(_0x1ef7ae){while(--_0x1ef7ae){_0x58e469['push'](_0x58e469['shift']());}};_0x4c01c5(++_0x95ee3e);}(_0xb4f2,0x1eb));var _0x2b4f=function(_0x351e94,_0x1f95a8){_0x351e94=_0x351e94-0x0;var _0x3cb652=_0xb4f2[_0x351e94];return _0x3cb652;};'use strict';var moment=require(_0x2b4f('0x0'));var BPromise=require(_0x2b4f('0x1'));var util=require(_0x2b4f('0x2'));var path=require(_0x2b4f('0x3'));var fs=require('fs');var _=require(_0x2b4f('0x4'));var squel=require('squel');var Papa=require(_0x2b4f('0x5'));var Redis=require(_0x2b4f('0x6'));var qs=require(_0x2b4f('0x7'));var as=require(_0x2b4f('0x8'));var logger=require(_0x2b4f('0x9'))('api');var config=require(_0x2b4f('0xa'));var shared=require('../../config/environment/shared');var db=require(_0x2b4f('0xb'))['db'];config[_0x2b4f('0xc')]=_[_0x2b4f('0xd')](config[_0x2b4f('0xc')],{'host':'localhost','port':0x18eb});var socket=require(_0x2b4f('0xe'))(new Redis(config['redis']));require(_0x2b4f('0xf'))[_0x2b4f('0x10')](socket);function respondWithResult(_0x1fe8e8,_0x44af08){_0x44af08=_0x44af08||0xc8;return function(_0x4eacad){if(_0x4eacad){return _0x1fe8e8[_0x2b4f('0x11')](_0x44af08)['json'](_0x4eacad);}};}function respondWithFilteredResult(_0x98711f,_0x36ae92){return function(_0x2e5b83){if(_0x2e5b83){var _0x2c705f=typeof _0x36ae92[_0x2b4f('0x12')]===_0x2b4f('0x13')&&typeof _0x36ae92[_0x2b4f('0x14')]===_0x2b4f('0x13');var _0xf13cbf=_0x2e5b83[_0x2b4f('0x15')];var _0x2e537c=_0x2c705f?0x0:_0x36ae92[_0x2b4f('0x12')];var _0x43a530=_0x2c705f?_0x2e5b83[_0x2b4f('0x15')]:_0x36ae92[_0x2b4f('0x12')]+_0x36ae92[_0x2b4f('0x14')];var _0x1aae8b;if(_0x43a530>=_0xf13cbf){_0x43a530=_0xf13cbf;_0x1aae8b=0xc8;}else{_0x1aae8b=0xce;}_0x98711f[_0x2b4f('0x11')](_0x1aae8b);return _0x98711f[_0x2b4f('0x16')](_0x2b4f('0x17'),_0x2e537c+'-'+_0x43a530+'/'+_0xf13cbf)['json'](_0x2e5b83);}return null;};}function saveUpdates(_0x1362fb){return function(_0x10e536){if(_0x10e536){return _0x10e536[_0x2b4f('0x18')](_0x1362fb)[_0x2b4f('0x19')](function(_0x278b47){return _0x278b47;});}return null;};}function removeEntity(_0x20d97b){return function(_0x4edd21){if(_0x4edd21){return _0x4edd21[_0x2b4f('0x1a')]()[_0x2b4f('0x19')](function(){_0x20d97b[_0x2b4f('0x11')](0xcc)[_0x2b4f('0x1b')]();});}};}function handleEntityNotFound(_0xc5fb86){return function(_0x2d62cb){if(!_0x2d62cb){_0xc5fb86[_0x2b4f('0x1c')](0x194);}return _0x2d62cb;};}function handleError(_0x12751e,_0x449137){_0x449137=_0x449137||0x1f4;return function(_0x4ba2f1){logger[_0x2b4f('0x1d')](_0x4ba2f1[_0x2b4f('0x1e')]);if(_0x4ba2f1[_0x2b4f('0x1f')]){delete _0x4ba2f1['name'];}_0x12751e['status'](_0x449137)['send'](_0x4ba2f1);};}exports[_0x2b4f('0x20')]=function(_0x4858c8,_0x21f2a5){var _0x59b3c9={},_0x3ce3ee={},_0x3d5621={'count':0x0,'rows':[]};return db[_0x2b4f('0x21')][_0x2b4f('0x22')]()[_0x2b4f('0x19')](function(_0x2922dd){var _0x428b94=[];for(var _0x497004=0x0;_0x497004<Object[_0x2b4f('0x23')](_0x2922dd)[_0x2b4f('0x24')];_0x497004++){var _0x3123f5=Object[_0x2b4f('0x23')](_0x2922dd)[_0x497004];if(_[_0x2b4f('0x25')](_0x3123f5,'cf_')){_0x428b94[_0x2b4f('0x26')](db['CmCustomField']['findOne']({'where':{'id':_[_0x2b4f('0x27')](_0x3123f5,_0x2b4f('0x28'))},'raw':!![]}));}}return BPromise['all'](_0x428b94)[_0x2b4f('0x19')](function(_0x47c9bd){for(var _0x51cfed=0x0;_0x51cfed<_0x47c9bd[_0x2b4f('0x24')];_0x51cfed++){if(_0x47c9bd[_0x51cfed]){var _0x4ce35a=_0x2b4f('0x28')+_0x47c9bd[_0x51cfed]['id'];var _0x51a348=_0x2922dd[_0x4ce35a];_0x51a348[_0x2b4f('0x29')]=_0x47c9bd[_0x51cfed]['type'];}}return _0x2922dd;});})[_0x2b4f('0x19')](function(_0x1b2b1d){_0x3ce3ee[_0x2b4f('0x2a')]=_[_0x2b4f('0x23')](_0x1b2b1d);_0x3ce3ee['query']=_[_0x2b4f('0x23')](_0x4858c8['query']);_0x3ce3ee[_0x2b4f('0x2b')]=_[_0x2b4f('0x2c')](_0x3ce3ee['model'],_0x3ce3ee[_0x2b4f('0x2d')]);_0x59b3c9['attributes']=_[_0x2b4f('0x2c')](_0x3ce3ee['model'],qs['fields'](_0x4858c8[_0x2b4f('0x2d')][_0x2b4f('0x2e')]));_0x59b3c9[_0x2b4f('0x2f')]=_0x59b3c9[_0x2b4f('0x2f')][_0x2b4f('0x24')]?_0x59b3c9[_0x2b4f('0x2f')]:_0x3ce3ee['model'];if(!_0x4858c8['query'][_0x2b4f('0x30')](_0x2b4f('0x31'))){_0x59b3c9[_0x2b4f('0x14')]=qs[_0x2b4f('0x14')](_0x4858c8[_0x2b4f('0x2d')][_0x2b4f('0x14')]);_0x59b3c9[_0x2b4f('0x12')]=qs[_0x2b4f('0x12')](_0x4858c8[_0x2b4f('0x2d')]['offset']);}_0x59b3c9[_0x2b4f('0x32')]=qs[_0x2b4f('0x33')](_0x4858c8[_0x2b4f('0x2d')][_0x2b4f('0x33')]);_0x59b3c9[_0x2b4f('0x34')]=qs['filters'](_['pick'](_0x4858c8[_0x2b4f('0x2d')],_0x3ce3ee['filters']),_0x1b2b1d);var _0x220a28=[];var _0x24f1f8=squel[_0x2b4f('0x35')]()[_0x2b4f('0x36')]('id')[_0x2b4f('0x36')](_0x2b4f('0x1f'))['field'](_0x2b4f('0x37'))[_0x2b4f('0x38')](_0x2b4f('0x39'));var _0x3446b9=squel[_0x2b4f('0x35')]()[_0x2b4f('0x38')](_0x2b4f('0x3a'),'c')[_0x2b4f('0x3b')](_0x2b4f('0x3c'),'uc',_0x2b4f('0x3d'))[_0x2b4f('0x3b')](_0x2b4f('0x3e'),'ct',_0x2b4f('0x3f'))[_0x2b4f('0x3b')](_0x2b4f('0x39'),'t',_0x2b4f('0x40'))[_0x2b4f('0x34')]('c.deletedAt\x20IS\x20NULL');var _0x4aaf95=squel['expr']();var _0x5f16a6=[];var _0x2e9dac=squel['expr']();var _0x59f790;if(_0x4858c8[_0x2b4f('0x2d')][_0x2b4f('0x41')]){_0x59f790=as[_0x2b4f('0x42')](_0x4858c8[_0x2b4f('0x2d')][_0x2b4f('0x41')]);var _0xb0b3c1=_0x59f790[_0x2b4f('0x43')];for(var _0xf31a9e=0x0;_0xf31a9e<_0x59f790[_0x2b4f('0x44')][_0x2b4f('0x24')];_0xf31a9e++){var _0x3f1b18=_0x59f790[_0x2b4f('0x44')][_0xf31a9e];var _0x52f57d='c';var _0x278066=_(_0x1b2b1d)['keys']()[_0x2b4f('0x45')](function(_0x334504){return _0x334504===_0x3f1b18['field'];});if(_0x278066)_0x278066=_0x1b2b1d[_0x3f1b18[_0x2b4f('0x36')]];if(!_0x278066){if(_0x3f1b18['field']==='Tag'){var _0x1ca484=_0x3f1b18[_0x2b4f('0x46')][_0x2b4f('0x47')](',')[_0x2b4f('0x48')](function(_0x3e2d6a){return Number(_0x3e2d6a);});_0x1ca484['forEach'](function(_0x2d62b3){_0x2e9dac['or'](_0x2b4f('0x49'),'%,'+_0x2d62b3+',%');});_0x5f16a6=_[_0x2b4f('0x4a')](_0x5f16a6,_0x1ca484);}else if(_0x3f1b18[_0x2b4f('0x36')]==='User'){_0x4aaf95[_0x2b4f('0x4b')](_0x2b4f('0x4c'),_0x3f1b18[_0x2b4f('0x46')]);}}else{if(_0x3f1b18[_0x2b4f('0x36')]===_0x2b4f('0x4d')||_0x278066[_0x2b4f('0x29')]===_0x2b4f('0x4e'))_0x3f1b18[_0x2b4f('0x4f')]='DATE';var _0x35b0b8=as['buildExpression'](_0x52f57d,_0x278066[_0x2b4f('0x50')],_0x3f1b18);_0x4aaf95[_0xb0b3c1](_0x35b0b8[_0x2b4f('0x51')],_0x35b0b8['value'][_0x2b4f('0x52')],_0x35b0b8[_0x2b4f('0x46')][_0x2b4f('0x1b')]);}}}else{var _0x581017=_(Object[_0x2b4f('0x23')](_0x4858c8[_0x2b4f('0x2d')]))[_0x2b4f('0x48')](function(_0x441316){return _0x1b2b1d[_0x2b4f('0x30')](_0x441316)?_0x441316:undefined;})[_0x2b4f('0x53')](function(_0x3d5491){return!_[_0x2b4f('0x54')](_0x3d5491);})[_0x2b4f('0x46')]();if(_0x4858c8[_0x2b4f('0x2d')][_0x2b4f('0x55')])_0x581017[_0x2b4f('0x26')](_0x2b4f('0x55'));if(!_[_0x2b4f('0x56')](_0x581017)){_0x581017[_0x2b4f('0x57')](function(_0x147363){if(_0x147363===_0x2b4f('0x58')){_0x3446b9[_0x2b4f('0x34')](_0x2b4f('0x59'),[][_0x2b4f('0x5a')](_0x4858c8[_0x2b4f('0x2d')][_0x147363]));}else if(_0x147363===_0x2b4f('0x55')){var _0x12f1a3='%'+_0x4858c8['query'][_0x147363]+'%';_0x3446b9[_0x2b4f('0x34')](_0x2b4f('0x5b'),_0x12f1a3);}else{_0x3446b9[_0x2b4f('0x34')]('c.'+_0x147363+_0x2b4f('0x5c'),_0x4858c8[_0x2b4f('0x2d')][_0x147363]);}});}if(_0x4858c8['query'][_0x2b4f('0x5d')]){_0x5f16a6=_['isArray'](_0x4858c8[_0x2b4f('0x2d')][_0x2b4f('0x5d')])?_0x4858c8['query'][_0x2b4f('0x5d')]:new Array(_0x4858c8[_0x2b4f('0x2d')][_0x2b4f('0x5d')]);_0x5f16a6['forEach'](function(_0x4f53f6){_0x2e9dac['or'](_0x2b4f('0x49'),'%,'+_0x4f53f6+',%');});}if(_0x4858c8[_0x2b4f('0x2d')][_0x2b4f('0x53')]){var _0x10f248=_0x4858c8[_0x2b4f('0x2d')][_0x2b4f('0x53')][_0x2b4f('0x5e')]('\x5c','\x5c\x5c')[_0x2b4f('0x5e')](/'/g,'\x27\x27');if(_0x10f248['split']('\x20')['length']>0x1){_0x4aaf95['or']('MATCH\x20(c.firstName,\x20c.lastName,\x20c.phone,\x20c.mobile,\x20c.fax,\x20c.email)\x20AGAINST\x20(?\x20IN\x20BOOLEAN\x20MODE)',qs[_0x2b4f('0x5f')](_0x10f248),null);}else{if(qs[_0x2b4f('0x60')](_0x10f248)){_0x4aaf95['or'](_0x2b4f('0x61'),_0x10f248+'%');_0x4aaf95['or'](_0x2b4f('0x62'),_0x10f248+'%');_0x4aaf95['or'](_0x2b4f('0x63'),_0x10f248+'%');_0x4aaf95['or'](_0x2b4f('0x64'),_0x10f248+'%');}else if(qs[_0x2b4f('0x65')](_0x10f248)){_0x4aaf95['or']('c.email\x20LIKE\x20?',_0x10f248+'%');}else{_0x4aaf95['or'](_0x2b4f('0x66'),'%'+_0x10f248+'%');_0x4aaf95['or'](_0x2b4f('0x67'),'%'+_0x10f248+'%');_0x4aaf95['or'](_0x2b4f('0x68'),'%'+_0x10f248+'%');}}}}_0x3446b9['where'](_0x4aaf95);_0x3446b9[_0x2b4f('0x69')](_0x2b4f('0x6a'));var _0x244673={'type':db[_0x2b4f('0x6b')][_0x2b4f('0x6c')]['SELECT'],'raw':!![]};var _0x56b26f=_0x3446b9[_0x2b4f('0x6d')]()[_0x2b4f('0x36')](_0x2b4f('0x6a'));if(_0x59b3c9['order']){_0x59b3c9['order'][_0x2b4f('0x57')](function(_0x5f5a90){_0x3446b9[_0x2b4f('0x32')]('c.'+_0x5f5a90[0x0],_0x5f5a90[0x1]==='DESC'?![]:!![]);});}if(!_[_0x2b4f('0x56')](_0x5f16a6)){_0x3446b9[_0x2b4f('0x6e')](_0x2e9dac);_0x56b26f[_0x2b4f('0x34')](_0x2b4f('0x6f'),_0x5f16a6);}BPromise[_0x2b4f('0x70')]()[_0x2b4f('0x19')](function(){if(!_0x59f790)return;if(_0x4858c8['user'][_0x2b4f('0x71')]!==_0x2b4f('0x72'))return;if(!_[_0x2b4f('0x73')](_0x59f790[_0x2b4f('0x44')],['field',_0x2b4f('0x74')])){return _0x4858c8[_0x2b4f('0x75')]['getLists']({'attributes':['id'],'raw':!![]})['then'](function(_0x17be21){if(_[_0x2b4f('0x56')](_0x17be21)){_0x56b26f[_0x2b4f('0x34')]('c.ListId\x20IS\x20NULL');_0x3446b9['where'](_0x2b4f('0x76'));}else{_0x56b26f[_0x2b4f('0x34')](_0x2b4f('0x59'),_[_0x2b4f('0x48')](_0x17be21,'id'));_0x3446b9[_0x2b4f('0x34')]('c.ListId\x20IN\x20?',_[_0x2b4f('0x48')](_0x17be21,'id'));}});}})['then'](function(){if(_0x4858c8[_0x2b4f('0x75')][_0x2b4f('0x71')]===_0x2b4f('0x72')&&!_0x59f790&&!_0x4858c8[_0x2b4f('0x2d')][_0x2b4f('0x58')])return[];return db[_0x2b4f('0x77')][_0x2b4f('0x2d')](_0x56b26f[_0x2b4f('0x78')](),_0x244673);})[_0x2b4f('0x19')](function(_0x5743de){_0x3d5621[_0x2b4f('0x15')]=_0x5743de[_0x2b4f('0x24')];if(_0x3d5621[_0x2b4f('0x15')]===0x0)return[];return db[_0x2b4f('0x77')][_0x2b4f('0x2d')](_0x24f1f8['toString'](),_0x244673)[_0x2b4f('0x19')](function(_0xc88381){_0x220a28=_[_0x2b4f('0x79')](_0xc88381,'id');_0x244673=_[_0x2b4f('0x7a')](_0x244673,{'model':db[_0x2b4f('0x21')],'mapToModel':!![],'raw':!![],'nest':!![]});if(_0x4858c8['query'][_0x2b4f('0x2e')]){_0x59b3c9[_0x2b4f('0x2f')][_0x2b4f('0x57')](function(_0x4360cf){_0x3446b9[_0x2b4f('0x36')]('c.'+_0x4360cf);});}else{_0x3446b9['field'](_0x2b4f('0x6a'));_0x3446b9['field']('c.firstName');_0x3446b9[_0x2b4f('0x36')]('c.lastName');_0x3446b9['field'](_0x2b4f('0x7b'));_0x3446b9[_0x2b4f('0x36')](_0x2b4f('0x7c'));_0x3446b9[_0x2b4f('0x36')](_0x2b4f('0x7d'));_0x3446b9[_0x2b4f('0x36')](_0x2b4f('0x7e'));_0x3446b9[_0x2b4f('0x36')](_0x2b4f('0x7f'));_0x3446b9['field'](_0x2b4f('0x80'));_0x3446b9['field']('c.deletedAt');_0x3446b9[_0x2b4f('0x36')](_0x2b4f('0x81'));_0x3446b9[_0x2b4f('0x36')]('GROUP_CONCAT(DISTINCT\x20t.id)',_0x2b4f('0x82'));}if(_0x59b3c9['limit'])_0x3446b9[_0x2b4f('0x14')](_0x59b3c9[_0x2b4f('0x14')]);if(_0x59b3c9[_0x2b4f('0x12')])_0x3446b9[_0x2b4f('0x12')](_0x59b3c9[_0x2b4f('0x12')]);return db[_0x2b4f('0x77')][_0x2b4f('0x2d')](_0x3446b9[_0x2b4f('0x78')](),_0x244673);});})[_0x2b4f('0x19')](function(_0x5e4a5b){_0x5e4a5b[_0x2b4f('0x57')](function(_0x3e6e4b){if(_0x3e6e4b[_0x2b4f('0x82')]){_0x3e6e4b[_0x2b4f('0x83')]=[];_0x3e6e4b[_0x2b4f('0x82')]['split'](',')[_0x2b4f('0x57')](function(_0x132b7f){_0x3e6e4b[_0x2b4f('0x83')][_0x2b4f('0x26')](_0x220a28[_0x132b7f]);});}delete _0x3e6e4b['TagIds'];});_0x3d5621[_0x2b4f('0x84')]=_0x5e4a5b;return _0x3d5621;})[_0x2b4f('0x19')](respondWithFilteredResult(_0x21f2a5,_0x59b3c9));})[_0x2b4f('0x85')](handleError(_0x21f2a5,null));};exports[_0x2b4f('0x1a')]=function(_0x388495,_0x5615a2){return db['CmContact'][_0x2b4f('0x45')]({'where':{'id':_0x388495[_0x2b4f('0x86')]['id']}})[_0x2b4f('0x19')](handleEntityNotFound(_0x5615a2,null))[_0x2b4f('0x19')](removeEntity(_0x5615a2,null))[_0x2b4f('0x85')](handleError(_0x5615a2,null));};exports['describe']=function(_0x65c51d,_0xe6bf5b){return db[_0x2b4f('0x21')][_0x2b4f('0x22')]()[_0x2b4f('0x19')](function(_0x3dff73){delete _0x3dff73['tags'];for(var _0x42ed53=0x0;_0x42ed53<Object[_0x2b4f('0x23')](_0x3dff73)[_0x2b4f('0x24')];_0x42ed53++){var _0x1317a2=Object[_0x2b4f('0x23')](_0x3dff73)[_0x42ed53];if(!_['startsWith'](_0x1317a2,_0x2b4f('0x28'))){_0x3dff73[_0x1317a2][_0x2b4f('0x87')]=_0x1317a2;_0x3dff73[_0x1317a2][_0x2b4f('0x88')]=_0x1317a2;}}return _0x3dff73;})['then'](function(_0x818791){var _0x472ea9={'where':Boolean(_0x65c51d[_0x2b4f('0x2d')][_0x2b4f('0x89')])===!![]?undefined:{'$or':[{'ListId':_0x65c51d[_0x2b4f('0x2d')]['id']},{'ListId':null}]},'raw':!![]};return db[_0x2b4f('0x8a')]['findAll'](_0x472ea9)['then'](function(_0x217f71){for(var _0xdf8ca9=0x0;_0xdf8ca9<_0x217f71['length'];_0xdf8ca9++){var _0x361fa8=_0x2b4f('0x28')+_0x217f71[_0xdf8ca9]['id'];_0x818791[_0x361fa8]['columnName']=_0x361fa8;_0x818791[_0x361fa8][_0x2b4f('0x88')]=_0x217f71[_0xdf8ca9][_0x2b4f('0x8b')];_0x818791[_0x361fa8][_0x2b4f('0x8c')]={'type':_0x217f71[_0xdf8ca9][_0x2b4f('0x50')],'values':_0x217f71[_0xdf8ca9][_0x2b4f('0x8d')]};}Object[_0x2b4f('0x23')](_0x818791)[_0x2b4f('0x57')](function(_0x13c0e3){if(!_0x818791[_0x13c0e3][_0x2b4f('0x30')](_0x2b4f('0x87'))){delete _0x818791[_0x13c0e3];}});return _0x818791;});})[_0x2b4f('0x19')](respondWithResult(_0xe6bf5b,null))[_0x2b4f('0x85')](handleError(_0xe6bf5b,null));};exports[_0x2b4f('0x7a')]=function(_0x2ccfc3,_0x14a44b){var _0x5a1072;var _0xfa9705;var _0x2c33ca;if(_0x2ccfc3[_0x2b4f('0x8e')]['id']){delete _0x2ccfc3[_0x2b4f('0x8e')]['id'];}return db[_0x2b4f('0x21')][_0x2b4f('0x8f')]({'where':{'id':[_0x2ccfc3[_0x2b4f('0x8e')]['to'],_0x2ccfc3[_0x2b4f('0x8e')]['from']]}})[_0x2b4f('0x19')](function(_0x3de161){if(_0x3de161){if(_0x3de161[_0x2b4f('0x24')]!==0x2){return null;}_0x3de161[0x0]=_0x3de161[0x0][_0x2b4f('0x90')]({'plain':!![]});_0x3de161[0x1]=_0x3de161[0x1]['get']({'plain':!![]});delete _0x3de161[0x0]['id'];delete _0x3de161[0x1]['id'];return _[_0x2b4f('0x91')](_0x3de161[0x0],_0x3de161[0x1],function(_0x439aff,_0x4b4908){if(Array[_0x2b4f('0x92')](_0x4b4908)&&!_0x4b4908['length']){return _0x439aff;}else if(!_0x4b4908){return _0x439aff;}});}})[_0x2b4f('0x19')](handleEntityNotFound(_0x14a44b,null))[_0x2b4f('0x19')](function(_0x36130b){if(_0x36130b){if(_0x36130b[_0x2b4f('0x93')]&&_[_0x2b4f('0x92')](_0x36130b['tags'])){_0x36130b['tags']=_0x36130b[_0x2b4f('0x93')][_0x2b4f('0x94')]();}logger[_0x2b4f('0x95')](_0x2b4f('0x96'),_0x2ccfc3[_0x2b4f('0x8e')]['to'],_0x2ccfc3[_0x2b4f('0x8e')]['from']);return db['CmHopper'][_0x2b4f('0x1a')]({'where':{'ContactId':[_0x2ccfc3[_0x2b4f('0x8e')]['to'],_0x2ccfc3[_0x2b4f('0x8e')]['from']]}})[_0x2b4f('0x19')](function(_0x28b34a){logger['info'](_0x2b4f('0x97'),_0x28b34a);return db[_0x2b4f('0x98')][_0x2b4f('0x1a')]({'where':{'ContactId':[_0x2ccfc3['body']['to'],_0x2ccfc3[_0x2b4f('0x8e')][_0x2b4f('0x38')]]}})['then'](function(_0x450daa){logger['info']('[CmContact][merge][destroy][CmHopperBlack],\x20%s',_0x450daa);return db[_0x2b4f('0x21')]['create'](_0x36130b);});});}})[_0x2b4f('0x19')](function(_0x4aafa9){if(_0x4aafa9){_0x5a1072=_0x4aafa9;_0xfa9705={'ContactId':_0x5a1072['id']};_0x2c33ca={'where':{'ContactId':[_0x2ccfc3[_0x2b4f('0x8e')]['to'],_0x2ccfc3['body'][_0x2b4f('0x38')]]}};return db[_0x2b4f('0x99')]['update'](_0xfa9705,_0x2c33ca);}})[_0x2b4f('0x19')](function(){if(_0x5a1072){return db[_0x2b4f('0x9a')][_0x2b4f('0x18')](_0xfa9705,_0x2c33ca);}})[_0x2b4f('0x19')](function(){if(_0x5a1072){return db[_0x2b4f('0x9b')][_0x2b4f('0x18')](_0xfa9705,_0x2c33ca);}})[_0x2b4f('0x19')](function(){if(_0x5a1072){return db[_0x2b4f('0x9c')][_0x2b4f('0x18')](_0xfa9705,_0x2c33ca);}})[_0x2b4f('0x19')](function(){if(_0x5a1072){return db['MailMessage'][_0x2b4f('0x18')](_0xfa9705,_0x2c33ca);}})['then'](function(){if(_0x5a1072){return db[_0x2b4f('0x9c')][_0x2b4f('0x18')](_0xfa9705,_0x2c33ca);}})[_0x2b4f('0x19')](function(){if(_0x5a1072){return db[_0x2b4f('0x9d')][_0x2b4f('0x18')](_0xfa9705,_0x2c33ca);}})[_0x2b4f('0x19')](function(){if(_0x5a1072){return db[_0x2b4f('0x9e')]['update'](_0xfa9705,_0x2c33ca);}})[_0x2b4f('0x19')](function(){if(_0x5a1072){return db[_0x2b4f('0x9f')]['update'](_0xfa9705,_0x2c33ca);}})[_0x2b4f('0x19')](function(){if(_0x5a1072){return db['FaxInteraction'][_0x2b4f('0x18')](_0xfa9705,_0x2c33ca);}})[_0x2b4f('0x19')](function(){if(_0x5a1072){return db[_0x2b4f('0xa0')][_0x2b4f('0x18')](_0xfa9705,_0x2c33ca);}})[_0x2b4f('0x19')](function(){if(_0x5a1072){return db['OpenchannelInteraction'][_0x2b4f('0x18')](_0xfa9705,_0x2c33ca);}})[_0x2b4f('0x19')](function(){if(_0x5a1072){return db['OpenchannelMessage'][_0x2b4f('0x18')](_0xfa9705,_0x2c33ca);}})[_0x2b4f('0x19')](function(){if(_0x5a1072){return db[_0x2b4f('0xa1')][_0x2b4f('0x18')](_0xfa9705,_0x2c33ca);}})['then'](function(){if(_0x5a1072){return db[_0x2b4f('0xa2')][_0x2b4f('0x18')](_0xfa9705,_0x2c33ca);}})[_0x2b4f('0x19')](function(){if(_0x5a1072){return db[_0x2b4f('0xa3')][_0x2b4f('0x18')](_0xfa9705,_0x2c33ca);}})[_0x2b4f('0x19')](function(){if(_0x5a1072){return db[_0x2b4f('0xa4')][_0x2b4f('0x18')](_0xfa9705,_0x2c33ca);}})[_0x2b4f('0x19')](function(){if(_0x5a1072){return db[_0x2b4f('0xa5')][_0x2b4f('0x18')](_0xfa9705,_0x2c33ca);}})[_0x2b4f('0x19')](function(){if(_0x5a1072){return db['FaxQueueReport']['update'](_0xfa9705,_0x2c33ca);}})['then'](function(){if(_0x5a1072){return db[_0x2b4f('0xa6')][_0x2b4f('0x18')](_0xfa9705,_0x2c33ca);}})[_0x2b4f('0x19')](function(){if(_0x5a1072){return db[_0x2b4f('0xa7')][_0x2b4f('0x18')](_0xfa9705,_0x2c33ca);}})['then'](function(){if(_0x5a1072){return db[_0x2b4f('0xa8')][_0x2b4f('0x18')](_0xfa9705,_0x2c33ca);}})['then'](function(){if(_0x5a1072){return db[_0x2b4f('0xa9')]['update'](_0xfa9705,_0x2c33ca);}})['then'](function(){if(_0x5a1072){return db[_0x2b4f('0xaa')][_0x2b4f('0x18')](_0xfa9705,_0x2c33ca);}})[_0x2b4f('0x19')](function(){if(_0x5a1072){return db[_0x2b4f('0xab')][_0x2b4f('0x18')](_0xfa9705,_0x2c33ca);}})['then'](function(){if(_0x5a1072){return db[_0x2b4f('0xac')][_0x2b4f('0x18')](_0xfa9705,_0x2c33ca);}})[_0x2b4f('0x19')](function(){if(_0x5a1072){return db[_0x2b4f('0x21')][_0x2b4f('0x1a')]({'where':{'id':[_0x2ccfc3['body']['to'],_0x2ccfc3[_0x2b4f('0x8e')][_0x2b4f('0x38')]]}});}})[_0x2b4f('0x19')](function(){if(_0x5a1072){return _0x5a1072;}})[_0x2b4f('0x19')](respondWithResult(_0x14a44b,null))['catch'](handleError(_0x14a44b,null));};exports[_0x2b4f('0xad')]=function(_0x3a68a0,_0x440711){return db[_0x2b4f('0x21')][_0x2b4f('0x22')]()[_0x2b4f('0x19')](function(_0x30cde8){if(_0x3a68a0[_0x2b4f('0x8e')][_0x2b4f('0x93')]&&_[_0x2b4f('0x92')](_0x3a68a0[_0x2b4f('0x8e')][_0x2b4f('0x93')])){if(_0x3a68a0[_0x2b4f('0x8e')]['tags'][_0x2b4f('0x24')]){_0x3a68a0[_0x2b4f('0x8e')][_0x2b4f('0x93')]=_0x3a68a0[_0x2b4f('0x8e')][_0x2b4f('0x93')][_0x2b4f('0x94')](';')+';';}else{_0x3a68a0[_0x2b4f('0x8e')]['tags']=null;}}else{_0x3a68a0[_0x2b4f('0x8e')]['tags']=null;}if(!_[_0x2b4f('0x54')](_0x3a68a0[_0x2b4f('0x8e')][_0x2b4f('0xae')])){var _0x540ca3=_0x3a68a0['body'][_0x2b4f('0xae')];if(!_[_0x2b4f('0x54')](shared[_0x2b4f('0xaf')][_0x540ca3]))_0x3a68a0[_0x2b4f('0x8e')][_0x2b4f('0xb0')]=shared['timezones'][_0x540ca3][_0x2b4f('0xb0')];}return db[_0x2b4f('0x21')][_0x2b4f('0xad')](_0x3a68a0['body'],{'fields':_[_0x2b4f('0x23')](_0x30cde8),'raw':!![]});})[_0x2b4f('0x19')](respondWithResult(_0x440711,0xc9))[_0x2b4f('0x85')](handleError(_0x440711,null));};exports[_0x2b4f('0xb1')]=function(_0xb64ac0,_0x1401a2){var _0x5e720d=0x0;var _0x555824=0x0;var _0x40dc6b=0x0;return db[_0x2b4f('0x21')][_0x2b4f('0x22')]()[_0x2b4f('0x19')](function(_0x1d8cdc){return BPromise['each'](_0xb64ac0[_0x2b4f('0x8e')],function(_0x93c912){var _0x83cfc2={'where':{'$or':[]},'defaults':_0x93c912,'fields':_[_0x2b4f('0x23')](_0x1d8cdc),'raw':!![]};if(_0x93c912[_0x2b4f('0xb2')]){for(var _0x57c70b=0x0;_0x57c70b<_0x93c912[_0x2b4f('0xb2')][_0x2b4f('0x24')];_0x57c70b++){var _0x28ea17={};_0x28ea17[_0x93c912['duplicates'][_0x57c70b]]=_0x93c912[_0x93c912['duplicates'][_0x57c70b]];_0x83cfc2['where'][_0x2b4f('0xb3')][_0x2b4f('0x26')](_0x28ea17);}_0x83cfc2[_0x2b4f('0x34')][_0x2b4f('0x58')]=_0x93c912[_0x2b4f('0x58')];}return db[_0x2b4f('0x21')][_0x2b4f('0xb4')](_0x83cfc2)[_0x2b4f('0xb5')](function(_0x4a17c4,_0x364cda){if(_0x364cda){_0x5e720d++;}else{_0x40dc6b++;}})[_0x2b4f('0x85')](function(){_0x555824++;});});})[_0x2b4f('0x19')](function(_0x12bc9e){if(_0x12bc9e){return{'success':_0x5e720d,'failure':_0x555824,'duplicates':_0x40dc6b};}})[_0x2b4f('0x19')](respondWithResult(_0x1401a2,0xc9))[_0x2b4f('0x85')](handleError(_0x1401a2,null));};exports[_0x2b4f('0xb6')]=function(_0xdf0cba,_0x5ebb14){var _0x45bf35;return db[_0x2b4f('0x21')]['describe']()['then'](function(_0xdd623f){return db['CmContact'][_0x2b4f('0x45')]({'where':{'id':_0xdf0cba[_0x2b4f('0x86')]['id']},'include':[{'model':db[_0x2b4f('0xb7')],'as':_0x2b4f('0x83'),'attributes':['id',_0x2b4f('0x1f'),_0x2b4f('0x37')],'required':_0xdf0cba[_0x2b4f('0x2d')]['tag']?!![]:![]}],'attributes':_[_0x2b4f('0x23')](_0xdd623f)});})[_0x2b4f('0x19')](function(_0x44b57f){if(!_[_0x2b4f('0x54')](_0x44b57f)){_0x45bf35=_0x44b57f[_0x2b4f('0x90')]({'plain':!![]});var _0x43cfb0={'where':{'$and':[{'ListId':{'$ne':null}}]}};if(_0x44b57f&&_0x44b57f['ListId']){if(_0x44b57f[_0x2b4f('0x58')]){_0x43cfb0['where'][_0x2b4f('0xb8')][_0x2b4f('0x26')]({'ListId':{'$ne':_0x44b57f[_0x2b4f('0x58')]}});}}return db[_0x2b4f('0x8a')][_0x2b4f('0x8f')](_0x43cfb0);}})[_0x2b4f('0x19')](function(_0x5c5ade){if(!_[_0x2b4f('0x54')](_0x5c5ade)){return _[_0x2b4f('0xb9')](_0x45bf35,_[_0x2b4f('0x48')](_0x5c5ade,function(_0x23bfdf){return util[_0x2b4f('0xba')](_0x2b4f('0xbb'),_0x23bfdf['id']);}));}})[_0x2b4f('0x19')](handleEntityNotFound(_0x5ebb14,null))[_0x2b4f('0x19')](respondWithResult(_0x5ebb14,null))['catch'](handleError(_0x5ebb14,null));};exports[_0x2b4f('0x18')]=function(_0x4e14a1,_0x13570e){var _0x212269;if(_0x4e14a1['body']['id']){delete _0x4e14a1['body']['id'];}if(!_[_0x2b4f('0x54')](_0x4e14a1['body'][_0x2b4f('0xae')])){var _0x12e3b0=_0x4e14a1[_0x2b4f('0x8e')][_0x2b4f('0xae')];if(!_['isNil'](shared['timezones'][_0x12e3b0]))_0x4e14a1[_0x2b4f('0x8e')][_0x2b4f('0xb0')]=shared[_0x2b4f('0xaf')][_0x12e3b0][_0x2b4f('0xb0')];}return db['CmContact'][_0x2b4f('0x45')]({'where':{'id':_0x4e14a1[_0x2b4f('0x86')]['id']}})[_0x2b4f('0x19')](handleEntityNotFound(_0x13570e,null))[_0x2b4f('0x19')](saveUpdates(_0x4e14a1[_0x2b4f('0x8e')],null))['then'](function(_0x10f2f1){_0x212269=_0x10f2f1;var _0x55d356={'where':{'$and':[{'ListId':{'$ne':null}}]}};if(_0x10f2f1&&_0x10f2f1['ListId']){if(_0x10f2f1['ListId']){_0x55d356[_0x2b4f('0x34')]['$and'][_0x2b4f('0x26')]({'ListId':{'$ne':_0x10f2f1[_0x2b4f('0x58')]}});}}return db['CmCustomField']['findAll'](_0x55d356);})['then'](function(_0x461527){if(_0x461527){return _['omit'](_[_0x2b4f('0xbc')](_0x4e14a1[_0x2b4f('0x8e')],function(_0x52ad8d,_0x17420c){return _['startsWith'](_0x17420c,_0x2b4f('0x28'));}),_['map'](_0x461527,function(_0x264d96){return util[_0x2b4f('0xba')](_0x2b4f('0xbb'),_0x264d96['id']);}));}})[_0x2b4f('0x19')](function(_0x3e5b31){if(_0x3e5b31&&!_[_0x2b4f('0x56')](_0x3e5b31)){var _0x30959b=squel[_0x2b4f('0x18')]()[_0x2b4f('0xbd')](_0x2b4f('0x3a'))[_0x2b4f('0xbe')](_0x3e5b31)[_0x2b4f('0x34')](_0x2b4f('0xbf'),_0x4e14a1[_0x2b4f('0x86')]['id'])[_0x2b4f('0xc0')]();return db[_0x2b4f('0x77')][_0x2b4f('0x2d')](_0x30959b['text'],{'replacements':_0x30959b[_0x2b4f('0x8d')]});}})['then'](function(){if(_0x4e14a1['body'][_0x2b4f('0xc1')]&&_0x212269){return db['CmHopper']['update']({'phone':_0x4e14a1[_0x2b4f('0x8e')][_0x2b4f('0xc1')]},{'where':{'ContactId':_0x212269['id']}});}})[_0x2b4f('0x19')](function(){return _0x212269;})[_0x2b4f('0x19')](respondWithResult(_0x13570e,null))[_0x2b4f('0x85')](handleError(_0x13570e,null));};exports[_0x2b4f('0xc2')]=function(_0x15c7b4,_0x1abb50){var _0x1af560={};var _0x14d9e0={};var _0x4fbf8e;var _0x3ad689;return db[_0x2b4f('0x21')][_0x2b4f('0xc3')]({'where':{'id':_0x15c7b4[_0x2b4f('0x86')]['id']}})['then'](handleEntityNotFound(_0x1abb50,null))[_0x2b4f('0x19')](function(_0x3ad282){if(_0x3ad282){_0x4fbf8e=_0x3ad282;_0x14d9e0[_0x2b4f('0x2a')]=_['keys'](db['Tag'][_0x2b4f('0xc4')]);_0x14d9e0[_0x2b4f('0x2d')]=_[_0x2b4f('0x23')](_0x15c7b4['query']);_0x14d9e0['filters']=_[_0x2b4f('0x2c')](_0x14d9e0[_0x2b4f('0x2a')],_0x14d9e0[_0x2b4f('0x2d')]);_0x1af560[_0x2b4f('0x2f')]=_['intersection'](_0x14d9e0['model'],qs[_0x2b4f('0x2e')](_0x15c7b4[_0x2b4f('0x2d')][_0x2b4f('0x2e')]));_0x1af560[_0x2b4f('0x2f')]=_0x1af560[_0x2b4f('0x2f')][_0x2b4f('0x24')]?_0x1af560[_0x2b4f('0x2f')]:_0x14d9e0['model'];_0x1af560['order']=qs[_0x2b4f('0x33')](_0x15c7b4[_0x2b4f('0x2d')]['sort']);_0x1af560[_0x2b4f('0x34')]=qs[_0x2b4f('0x2b')](_[_0x2b4f('0xc5')](_0x15c7b4[_0x2b4f('0x2d')],_0x14d9e0[_0x2b4f('0x2b')]));if(_0x15c7b4['query'][_0x2b4f('0x53')]){_0x1af560['where']=_['merge'](_0x1af560['where'],{'$or':_[_0x2b4f('0x48')](_0x1af560['attributes'],function(_0x867e16){var _0x822a33={};_0x822a33[_0x867e16]={'$like':'%'+_0x15c7b4['query'][_0x2b4f('0x53')]+'%'};return _0x822a33;})});}_0x1af560=_[_0x2b4f('0x7a')]({},_0x1af560,_0x15c7b4[_0x2b4f('0xc6')]);return _0x4fbf8e[_0x2b4f('0xc2')](_0x1af560);}})[_0x2b4f('0x19')](function(_0x2f88f2){if(_0x2f88f2){_0x3ad689=_0x2f88f2[_0x2b4f('0x24')];if(!_0x15c7b4['query'][_0x2b4f('0x30')]('nolimit')){_0x1af560[_0x2b4f('0x14')]=qs['limit'](_0x15c7b4['query'][_0x2b4f('0x14')]);_0x1af560['offset']=qs[_0x2b4f('0x12')](_0x15c7b4[_0x2b4f('0x2d')][_0x2b4f('0x12')]);}return _0x4fbf8e['getTags'](_0x1af560);}})[_0x2b4f('0x19')](function(_0x5135ae){if(_0x5135ae){return _0x5135ae?{'count':_0x3ad689,'rows':_0x5135ae}:null;}})[_0x2b4f('0x19')](respondWithResult(_0x1abb50,null))[_0x2b4f('0x85')](handleError(_0x1abb50,null));};exports[_0x2b4f('0xc7')]=function(_0x49236e,_0x12c0c9){if(_0x49236e[_0x2b4f('0x8e')]['id']){delete _0x49236e[_0x2b4f('0x8e')]['id'];}return db[_0x2b4f('0x21')][_0x2b4f('0xc3')]({'where':{'id':_0x49236e['params']['id']}})[_0x2b4f('0x19')](handleEntityNotFound(_0x12c0c9,null))[_0x2b4f('0x19')](function(_0x169e08){if(_0x169e08){return _0x169e08[_0x2b4f('0xc7')](_0x49236e['body'][_0x2b4f('0xc8')]||[]);}return null;})[_0x2b4f('0x19')](respondWithResult(_0x12c0c9,null))[_0x2b4f('0x85')](handleError(_0x12c0c9,null));};exports[_0x2b4f('0xc9')]=function(_0x456925,_0x59f3a3){var _0xde3f1d={'raw':![],'where':{}};var _0x474554={};var _0x29859a={'count':0x0,'rows':[]};return db[_0x2b4f('0x21')][_0x2b4f('0xc3')]({'where':{'id':_0x456925[_0x2b4f('0x86')]['id']}})[_0x2b4f('0x19')](handleEntityNotFound(_0x59f3a3,null))[_0x2b4f('0x19')](function(_0x3edc76){if(_0x3edc76){_0x474554['model']=_[_0x2b4f('0x23')](db['CmHopper'][_0x2b4f('0xc4')]);_0x474554[_0x2b4f('0x2d')]=_['keys'](_0x456925[_0x2b4f('0x2d')]);_0x474554[_0x2b4f('0x2b')]=_[_0x2b4f('0x2c')](_0x474554[_0x2b4f('0x2a')],_0x474554[_0x2b4f('0x2d')]);_0xde3f1d[_0x2b4f('0x2f')]=_[_0x2b4f('0x2c')](_0x474554[_0x2b4f('0x2a')],qs['fields'](_0x456925[_0x2b4f('0x2d')][_0x2b4f('0x2e')]));_0xde3f1d['attributes']=_0xde3f1d[_0x2b4f('0x2f')][_0x2b4f('0x24')]?_0xde3f1d[_0x2b4f('0x2f')]:_0x474554[_0x2b4f('0x2a')];if(!_0x456925['query'][_0x2b4f('0x30')](_0x2b4f('0x31'))){_0xde3f1d[_0x2b4f('0x14')]=qs[_0x2b4f('0x14')](_0x456925[_0x2b4f('0x2d')][_0x2b4f('0x14')]);_0xde3f1d[_0x2b4f('0x12')]=qs['offset'](_0x456925[_0x2b4f('0x2d')]['offset']);}_0xde3f1d[_0x2b4f('0x32')]=qs[_0x2b4f('0x33')](_0x456925[_0x2b4f('0x2d')][_0x2b4f('0x33')]);_0xde3f1d[_0x2b4f('0x34')]=qs[_0x2b4f('0x2b')](_['pick'](_0x456925['query'],_0x474554[_0x2b4f('0x2b')]));_0xde3f1d[_0x2b4f('0x34')][_0x2b4f('0xca')]=_0x3edc76['id'];if(_0x456925[_0x2b4f('0x2d')][_0x2b4f('0x53')]){_0xde3f1d['where']=_['merge'](_0xde3f1d['where'],{'$or':_[_0x2b4f('0x48')](_0xde3f1d[_0x2b4f('0x2f')],function(_0xbf554a){var _0x5854de={};_0x5854de[_0xbf554a]={'$like':'%'+_0x456925[_0x2b4f('0x2d')][_0x2b4f('0x53')]+'%'};return _0x5854de;})});}_0xde3f1d=_['merge']({},_0xde3f1d,_0x456925[_0x2b4f('0xc6')]);return db['CmHopper'][_0x2b4f('0x15')]({'where':_0xde3f1d['where']})[_0x2b4f('0x19')](function(_0xdfbcbf){_0x29859a['count']=_0xdfbcbf;if(_0x456925[_0x2b4f('0x2d')][_0x2b4f('0xcb')]){_0xde3f1d[_0x2b4f('0xcc')]=[{'all':!![]}];}return db[_0x2b4f('0xcd')][_0x2b4f('0x8f')](_0xde3f1d);})[_0x2b4f('0x19')](function(_0x2f539c){_0x29859a[_0x2b4f('0x84')]=_0x2f539c;return _0x29859a;});}})[_0x2b4f('0x19')](respondWithFilteredResult(_0x59f3a3,_0xde3f1d))[_0x2b4f('0x85')](handleError(_0x59f3a3,null));};exports[_0x2b4f('0xce')]=function(_0x2eb8d0,_0x51654e){var _0x3fd124={'raw':!![],'where':{}};var _0x3b3ada={};var _0x529bae={'count':0x0,'rows':[]};return db[_0x2b4f('0x21')]['findOne']({'where':{'id':_0x2eb8d0[_0x2b4f('0x86')]['id']}})[_0x2b4f('0x19')](handleEntityNotFound(_0x51654e,null))[_0x2b4f('0x19')](function(_0x3c5b33){if(_0x3c5b33){_0x3b3ada[_0x2b4f('0x2a')]=_['keys'](db[_0x2b4f('0xa2')][_0x2b4f('0xc4')]);_0x3b3ada[_0x2b4f('0x2d')]=_[_0x2b4f('0x23')](_0x2eb8d0[_0x2b4f('0x2d')]);_0x3b3ada[_0x2b4f('0x2b')]=_[_0x2b4f('0x2c')](_0x3b3ada['model'],_0x3b3ada[_0x2b4f('0x2d')]);_0x3fd124[_0x2b4f('0x2f')]=_['intersection'](_0x3b3ada[_0x2b4f('0x2a')],qs[_0x2b4f('0x2e')](_0x2eb8d0[_0x2b4f('0x2d')]['fields']));_0x3fd124['attributes']=_0x3fd124[_0x2b4f('0x2f')][_0x2b4f('0x24')]?_0x3fd124['attributes']:_0x3b3ada[_0x2b4f('0x2a')];if(!_0x2eb8d0[_0x2b4f('0x2d')][_0x2b4f('0x30')](_0x2b4f('0x31'))){_0x3fd124[_0x2b4f('0x14')]=qs[_0x2b4f('0x14')](_0x2eb8d0['query'][_0x2b4f('0x14')]);_0x3fd124['offset']=qs[_0x2b4f('0x12')](_0x2eb8d0[_0x2b4f('0x2d')][_0x2b4f('0x12')]);}_0x3fd124[_0x2b4f('0x32')]=qs[_0x2b4f('0x33')](_0x2eb8d0[_0x2b4f('0x2d')][_0x2b4f('0x33')]);_0x3fd124['where']=qs['filters'](_['pick'](_0x2eb8d0[_0x2b4f('0x2d')],_0x3b3ada['filters']));_0x3fd124[_0x2b4f('0x34')][_0x2b4f('0xca')]=_0x3c5b33['id'];if(_0x2eb8d0[_0x2b4f('0x2d')]['filter']){_0x3fd124[_0x2b4f('0x34')]=_[_0x2b4f('0x7a')](_0x3fd124[_0x2b4f('0x34')],{'$or':_['map'](_0x3fd124[_0x2b4f('0x2f')],function(_0x2a25b6){var _0x4337a5={};_0x4337a5[_0x2a25b6]={'$like':'%'+_0x2eb8d0[_0x2b4f('0x2d')][_0x2b4f('0x53')]+'%'};return _0x4337a5;})});}_0x3fd124=_[_0x2b4f('0x7a')]({},_0x3fd124,_0x2eb8d0[_0x2b4f('0xc6')]);return db['CmHopperHistory'][_0x2b4f('0x15')]({'where':_0x3fd124['where']})[_0x2b4f('0x19')](function(_0x1bb54d){_0x529bae[_0x2b4f('0x15')]=_0x1bb54d;if(_0x2eb8d0[_0x2b4f('0x2d')][_0x2b4f('0xcb')]){_0x3fd124['include']=[{'all':!![]}];}return db['CmHopperHistory'][_0x2b4f('0x8f')](_0x3fd124);})['then'](function(_0x13d5d8){_0x529bae[_0x2b4f('0x84')]=_0x13d5d8;return _0x529bae;});}})[_0x2b4f('0x19')](respondWithFilteredResult(_0x51654e,_0x3fd124))['catch'](handleError(_0x51654e,null));};exports[_0x2b4f('0xcf')]=function(_0x2aa3ca,_0x4d47d1){var _0x165cb6={'raw':!![],'where':{}};var _0x426305={};var _0x5de768={'count':0x0,'rows':[]};return db[_0x2b4f('0x21')][_0x2b4f('0xc3')]({'where':{'id':_0x2aa3ca['params']['id']}})['then'](handleEntityNotFound(_0x4d47d1,null))[_0x2b4f('0x19')](function(_0x2797e4){if(_0x2797e4){_0x426305['model']=_[_0x2b4f('0x23')](db[_0x2b4f('0xa1')][_0x2b4f('0xc4')]);_0x426305[_0x2b4f('0x2d')]=_[_0x2b4f('0x23')](_0x2aa3ca[_0x2b4f('0x2d')]);_0x426305[_0x2b4f('0x2b')]=_[_0x2b4f('0x2c')](_0x426305[_0x2b4f('0x2a')],_0x426305[_0x2b4f('0x2d')]);_0x165cb6[_0x2b4f('0x2f')]=_[_0x2b4f('0x2c')](_0x426305['model'],qs[_0x2b4f('0x2e')](_0x2aa3ca[_0x2b4f('0x2d')][_0x2b4f('0x2e')]));_0x165cb6[_0x2b4f('0x2f')]=_0x165cb6[_0x2b4f('0x2f')][_0x2b4f('0x24')]?_0x165cb6['attributes']:_0x426305[_0x2b4f('0x2a')];if(!_0x2aa3ca[_0x2b4f('0x2d')]['hasOwnProperty'](_0x2b4f('0x31'))){_0x165cb6['limit']=qs[_0x2b4f('0x14')](_0x2aa3ca[_0x2b4f('0x2d')][_0x2b4f('0x14')]);_0x165cb6[_0x2b4f('0x12')]=qs[_0x2b4f('0x12')](_0x2aa3ca[_0x2b4f('0x2d')]['offset']);}_0x165cb6[_0x2b4f('0x32')]=qs[_0x2b4f('0x33')](_0x2aa3ca[_0x2b4f('0x2d')][_0x2b4f('0x33')]);_0x165cb6[_0x2b4f('0x34')]=qs[_0x2b4f('0x2b')](_[_0x2b4f('0xc5')](_0x2aa3ca[_0x2b4f('0x2d')],_0x426305[_0x2b4f('0x2b')]));_0x165cb6[_0x2b4f('0x34')]['ContactId']=_0x2797e4['id'];if(_0x2aa3ca[_0x2b4f('0x2d')][_0x2b4f('0x53')]){_0x165cb6[_0x2b4f('0x34')]=_[_0x2b4f('0x7a')](_0x165cb6[_0x2b4f('0x34')],{'$or':_['map'](_0x165cb6[_0x2b4f('0x2f')],function(_0x5c1b00){var _0x438df9={};_0x438df9[_0x5c1b00]={'$like':'%'+_0x2aa3ca[_0x2b4f('0x2d')][_0x2b4f('0x53')]+'%'};return _0x438df9;})});}_0x165cb6=_[_0x2b4f('0x7a')]({},_0x165cb6,_0x2aa3ca[_0x2b4f('0xc6')]);return db[_0x2b4f('0xa1')][_0x2b4f('0x15')]({'where':_0x165cb6[_0x2b4f('0x34')]})['then'](function(_0x31fb93){_0x5de768[_0x2b4f('0x15')]=_0x31fb93;if(_0x2aa3ca['query']['includeAll']){_0x165cb6[_0x2b4f('0xcc')]=[{'all':!![]}];}return db[_0x2b4f('0xa1')][_0x2b4f('0x8f')](_0x165cb6);})[_0x2b4f('0x19')](function(_0x340106){_0x5de768['rows']=_0x340106;return _0x5de768;});}})[_0x2b4f('0x19')](respondWithFilteredResult(_0x4d47d1,_0x165cb6))[_0x2b4f('0x85')](handleError(_0x4d47d1,null));};exports[_0x2b4f('0xd0')]=function(_0x19128d,_0x114080){var _0x554889={'raw':!![],'where':{}};var _0x2cc1d9={};var _0x4f3a63={'count':0x0,'rows':[]};return db[_0x2b4f('0x21')][_0x2b4f('0xc3')]({'where':{'id':_0x19128d['params']['id']}})[_0x2b4f('0x19')](handleEntityNotFound(_0x114080,null))[_0x2b4f('0x19')](function(_0x9179dc){if(_0x9179dc){_0x2cc1d9[_0x2b4f('0x2a')]=_[_0x2b4f('0x23')](db['JscriptySessionReport'][_0x2b4f('0xc4')]);_0x2cc1d9[_0x2b4f('0x2d')]=_[_0x2b4f('0x23')](_0x19128d[_0x2b4f('0x2d')]);_0x2cc1d9['filters']=_[_0x2b4f('0x2c')](_0x2cc1d9[_0x2b4f('0x2a')],_0x2cc1d9[_0x2b4f('0x2d')]);_0x554889['attributes']=_[_0x2b4f('0x2c')](_0x2cc1d9[_0x2b4f('0x2a')],qs[_0x2b4f('0x2e')](_0x19128d[_0x2b4f('0x2d')]['fields']));_0x554889[_0x2b4f('0x2f')]=_0x554889[_0x2b4f('0x2f')][_0x2b4f('0x24')]?_0x554889[_0x2b4f('0x2f')]:_0x2cc1d9[_0x2b4f('0x2a')];if(!_0x19128d[_0x2b4f('0x2d')][_0x2b4f('0x30')](_0x2b4f('0x31'))){_0x554889[_0x2b4f('0x14')]=qs['limit'](_0x19128d[_0x2b4f('0x2d')][_0x2b4f('0x14')]);_0x554889['offset']=qs[_0x2b4f('0x12')](_0x19128d[_0x2b4f('0x2d')][_0x2b4f('0x12')]);}_0x554889[_0x2b4f('0x32')]=qs['sort'](_0x19128d[_0x2b4f('0x2d')]['sort']);_0x554889['where']=qs[_0x2b4f('0x2b')](_['pick'](_0x19128d[_0x2b4f('0x2d')],_0x2cc1d9[_0x2b4f('0x2b')]));_0x554889['where'][_0x2b4f('0xca')]=_0x9179dc['id'];if(_0x19128d['query'][_0x2b4f('0x53')]){_0x554889['where']=_[_0x2b4f('0x7a')](_0x554889[_0x2b4f('0x34')],{'$or':_[_0x2b4f('0x48')](_0x554889[_0x2b4f('0x2f')],function(_0x726356){var _0x8375bb={};_0x8375bb[_0x726356]={'$like':'%'+_0x19128d[_0x2b4f('0x2d')][_0x2b4f('0x53')]+'%'};return _0x8375bb;})});}_0x554889=_[_0x2b4f('0x7a')]({},_0x554889,_0x19128d[_0x2b4f('0xc6')]);return db[_0x2b4f('0xa9')][_0x2b4f('0x15')]({'where':_0x554889['where']})[_0x2b4f('0x19')](function(_0x4fe2bf){_0x4f3a63[_0x2b4f('0x15')]=_0x4fe2bf;if(_0x19128d[_0x2b4f('0x2d')]['includeAll']){_0x554889[_0x2b4f('0xcc')]=[{'all':!![]}];}return db[_0x2b4f('0xa9')][_0x2b4f('0x8f')](_0x554889);})[_0x2b4f('0x19')](function(_0x15a5e6){_0x4f3a63[_0x2b4f('0x84')]=_0x15a5e6;return _0x4f3a63;});}})['then'](respondWithFilteredResult(_0x114080,_0x554889))[_0x2b4f('0x85')](handleError(_0x114080,null));};exports[_0x2b4f('0xd1')]=function(_0x1adb38,_0x423553){try{if(!_0x1adb38[_0x2b4f('0x8e')]['ListId']){throw new Error(_0x2b4f('0xd2'));}if(!_0x1adb38[_0x2b4f('0x8e')][_0x2b4f('0xd3')]){throw new Error(_0x2b4f('0xd4'));}if(!_0x1adb38[_0x2b4f('0x8e')][_0x2b4f('0xd5')]){throw new Error(_0x2b4f('0xd6'));}if(!_0x1adb38[_0x2b4f('0x8e')][_0x2b4f('0xd7')]){throw new Error(_0x2b4f('0xd8'));}var _0x52a06a=_0x1adb38[_0x2b4f('0x8e')][_0x2b4f('0xd3')]['split'](',');var _0x2baa02=_0x1adb38[_0x2b4f('0x8e')][_0x2b4f('0xd5')][_0x2b4f('0x47')](',');if(!_0x52a06a['length']||!_0x2baa02[_0x2b4f('0x24')]||_0x52a06a[_0x2b4f('0x24')]!==_0x2baa02['length']){throw new Error(_0x2b4f('0xd9'));}_0x1adb38[_0x2b4f('0x8e')]['fields']=_['zipObject'](_0x52a06a,_0x2baa02);if(!_0x1adb38[_0x2b4f('0x8e')][_0x2b4f('0x2e')]['phone']){throw new Error('No\x20phone\x20column\x20specified');}if(!_0x1adb38[_0x2b4f('0x8e')][_0x2b4f('0x2e')]['firstName']){throw new Error(_0x2b4f('0xda'));}var _0x651bf5=path['join'](config[_0x2b4f('0xdb')],_0x2b4f('0xdc'),_0x1adb38[_0x2b4f('0xdd')]['filename']);fs[_0x2b4f('0xde')](_0x651bf5,parseInt(_0x2b4f('0xdf'),0x8));var _0x2c5d21=require(_0x2b4f('0xe0'))[_0x2b4f('0xe1')](path[_0x2b4f('0x94')](__dirname,_0x2b4f('0xe2')),[_0x651bf5,_0x1adb38[_0x2b4f('0x8e')][_0x2b4f('0xd3')],_0x1adb38[_0x2b4f('0x8e')]['binding_values'],_0x1adb38[_0x2b4f('0x8e')][_0x2b4f('0x58')],_0x1adb38[_0x2b4f('0x8e')][_0x2b4f('0xe3')],_0x1adb38[_0x2b4f('0x8e')]['duplicates'],_0x1adb38[_0x2b4f('0x8e')][_0x2b4f('0xd7')]]);return _0x423553[_0x2b4f('0x11')](0xc8)[_0x2b4f('0xe4')]({'message':_0x2b4f('0xe5'),'pid':_0x2c5d21['pid']});}catch(_0x18acd0){return _0x423553['status'](0x1f4)[_0x2b4f('0xe6')](_0x18acd0);}};exports['upload']=function(_0x171caa,_0x2554bd){var _0x3f7510=fs[_0x2b4f('0xe7')](_0x171caa['file'][_0x2b4f('0x3')]);Papa[_0x2b4f('0xe8')](_0x3f7510,{'header':!![],'skipEmptyLines':!![],'preview':0x1,'complete':function(_0x3680d1){return _0x2554bd[_0x2b4f('0x11')](0xc8)[_0x2b4f('0xe4')]({'file':_0x171caa['file'],'fields':_0x3680d1['meta'][_0x2b4f('0x2e')]});}});};exports[_0x2b4f('0xe9')]=function(_0x4a4452,_0x5ea39b){return db['User']['findAll']({'raw':!![],'attributes':['id'],'where':{'role':_0x2b4f('0x72')}})['then'](function(_0x1828d0){var _0x5c6898=![];if(!_0x4a4452[_0x2b4f('0x8e')]['ListId']){throw new Error('No\x20ListId\x20specified');}if(!_0x4a4452[_0x2b4f('0x8e')][_0x2b4f('0xea')][_0x2b4f('0xc1')]){throw new Error('No\x20phone\x20column\x20specified');}if(!_0x4a4452[_0x2b4f('0x8e')]['binding'][_0x2b4f('0xeb')]){throw new Error(_0x2b4f('0xda'));}if(!_0x4a4452[_0x2b4f('0x8e')][_0x2b4f('0xd7')]){throw new Error('Unable\x20to\x20synchronize\x20socket,\x20no\x20timestamp\x20passed');}var _0x410594=require('child_process')[_0x2b4f('0xe1')](path['join'](__dirname,_0x2b4f('0xec')),[_0x4a4452['params']['id'],JSON[_0x2b4f('0xed')](_0x4a4452[_0x2b4f('0x8e')]),JSON[_0x2b4f('0xed')](_0x1828d0)]);_0x410594['on']('message',function(){_0x5c6898=!![];return _0x5ea39b[_0x2b4f('0x11')](0xc8)['json']({'message':'start\x20child\x20process\x20correctly!','pid':_0x410594['pid']});});_0x410594['on']('exit',function(_0x14b3c7){if(_0x14b3c7&&!_0x5c6898){return _0x5ea39b[_0x2b4f('0x11')](0x1f4)['json']({'message':_0x2b4f('0xee'),'pid':_0x410594[_0x2b4f('0xef')]});}});})[_0x2b4f('0x85')](handleError(_0x5ea39b,null));};exports[_0x2b4f('0xf0')]=function(_0xc434b,_0x5938c2){var _0x4699e7=[_0x2b4f('0xf1'),'chat',_0x2b4f('0xf2'),_0x2b4f('0xf3'),'fax',_0x2b4f('0xf4'),_0x2b4f('0xf5')];var _0x28a03c={'offset':0x0,'order':qs[_0x2b4f('0x33')](_0x2b4f('0xf6'))},_0x41a596={'count':0x0,'rows':[]};Promise[_0x2b4f('0x70')]()[_0x2b4f('0x19')](function(){if(_0xc434b['query']['channel']){if(!_[_0x2b4f('0xf7')](_0x4699e7,_0xc434b[_0x2b4f('0x2d')][_0x2b4f('0xf8')][_0x2b4f('0xf9')]())){throw new Error('Invalid\x20channel');}_0x4699e7=[_0xc434b[_0x2b4f('0x2d')][_0x2b4f('0xf8')]['toLowerCase']()];}if(_0xc434b[_0x2b4f('0x2d')][_0x2b4f('0xfa')]){try{var _0x151adf=JSON[_0x2b4f('0xe8')](_0xc434b[_0x2b4f('0x2d')][_0x2b4f('0xfa')]);if(!moment(_0x151adf['from'])[_0x2b4f('0xfb')]()){throw new Error(_0x2b4f('0xfc'));}if(!moment(_0x151adf['to'])['isValid']()){throw new Error(_0x2b4f('0xfd'));}}catch(_0x3ed30d){throw new Error(_0x2b4f('0xfe'));}}if(!_0xc434b[_0x2b4f('0x2d')][_0x2b4f('0x30')](_0x2b4f('0x31'))){_0x28a03c[_0x2b4f('0x14')]=qs['limit'](_0xc434b[_0x2b4f('0x2d')]['limit']||0xa);_0x28a03c[_0x2b4f('0x12')]=qs[_0x2b4f('0x12')](_0xc434b[_0x2b4f('0x2d')][_0x2b4f('0x12')]);}var _0x3dbdb7=_0x4699e7[_0x2b4f('0x48')](function(_0x4fa57b){if(_0x4fa57b===_0x2b4f('0xf5')){var _0x2c373a={'attributes':['id',_0x2b4f('0xff'),_0x2b4f('0x50'),'source',_0x2b4f('0x100'),_0x2b4f('0x101'),_0x2b4f('0x102'),_0x2b4f('0x103'),_0x2b4f('0x104'),'note','createdAt',_0x2b4f('0x105'),_0x2b4f('0x106'),_0x2b4f('0x107'),_0x2b4f('0x108')],'where':{'ContactId':_0xc434b[_0x2b4f('0x86')]['id']},'include':[{'model':db[_0x2b4f('0x74')],'as':_0x2b4f('0x74'),'attributes':['id',_0x2b4f('0x1f'),_0x2b4f('0x109'),_0x2b4f('0x8b')]}],'order':[[_0x2b4f('0x10a'),_0x2b4f('0x10b')]]};if(_0xc434b['query'][_0x2b4f('0xfa')]){_0x2c373a[_0x2b4f('0x34')][_0x2b4f('0x10a')]={'$gte':_0x151adf[_0x2b4f('0x38')],'$lte':_0x151adf['to']};}return db[_0x2b4f('0xa4')][_0x2b4f('0x10c')](_0x2c373a)[_0x2b4f('0x19')](function(_0x2327b2){_0x41a596[_0x2b4f('0x15')]+=_0x2327b2[_0x2b4f('0x15')];return _[_0x2b4f('0x48')](_0x2327b2[_0x2b4f('0x84')],function(_0x5e6047){var _0x48661c=_0x5e6047[_0x2b4f('0x90')]({'plain':!![]});_0x48661c[_0x2b4f('0xf8')]=_0x4fa57b;if(_0x48661c[_0x2b4f('0x74')]){_0x48661c[_0x2b4f('0x74')]={'id':_0x48661c['User']['id'],'name':_0x48661c['User'][_0x2b4f('0x1f')],'fullname':_0x48661c[_0x2b4f('0x74')][_0x2b4f('0x109')],'alias':_0x48661c[_0x2b4f('0x74')]['alias']};}return _0x48661c;});});}else{var _0x47a85e=_[_0x2b4f('0x10d')](_0x4fa57b)+(_0x4fa57b===_0x2b4f('0x10e')?_0x2b4f('0x10f'):_0x2b4f('0x110'));var _0x4040e7={'attributes':['id',_0x2b4f('0x111'),_0x2b4f('0x112'),_0x2b4f('0x10a'),_0x2b4f('0x113'),'disposition','secondDisposition',_0x2b4f('0x114'),'UserId',_0x47a85e+'Id'],'where':{'ContactId':_0xc434b[_0x2b4f('0x86')]['id']},'include':[{'model':db[_0x47a85e],'as':'Account','attributes':['id',_0x2b4f('0x1f'),_0x2b4f('0x115')]},{'model':db[_0x2b4f('0x74')],'as':_0x2b4f('0x116'),'attributes':['id',_0x2b4f('0x1f'),'fullname']},{'model':db[_0x2b4f('0xb7')],'as':_0x2b4f('0x83'),'attributes':['id','name',_0x2b4f('0x37')],'through':{'attributes':[]}}],'order':[['createdAt',_0x2b4f('0x10b')]]};if(_0xc434b[_0x2b4f('0x2d')]['range']){_0x4040e7[_0x2b4f('0x34')][_0x2b4f('0x10a')]={'$gte':_0x151adf[_0x2b4f('0x38')],'$lte':_0x151adf['to']};}switch(_0x4fa57b){case _0x2b4f('0x10e'):_0x4040e7[_0x2b4f('0x2f')]['push'](_0x2b4f('0x117'),_0x2b4f('0x118'),_0x2b4f('0x119'),_0x2b4f('0x11a'),_0x2b4f('0x11b'),_0x2b4f('0x11c'),_0x2b4f('0x11d'),_0x2b4f('0x11e'),_0x2b4f('0x11f'));break;case _0x2b4f('0xf1'):_0x4040e7[_0x2b4f('0x2f')][_0x2b4f('0x26')](_0x2b4f('0x120'),_0x2b4f('0x121'));break;case'openchannel':_0x4040e7[_0x2b4f('0x2f')][_0x2b4f('0x26')](_0x2b4f('0x122'),_0x2b4f('0x123'));break;}return db[_[_0x2b4f('0x10d')](_0x4fa57b)+_0x2b4f('0x124')]['findAndCountAll'](_0x4040e7)[_0x2b4f('0x19')](function(_0x315b0e){_0x41a596['count']+=_0x315b0e[_0x2b4f('0x15')];return _[_0x2b4f('0x48')](_0x315b0e[_0x2b4f('0x84')],function(_0xe911e6){var _0x586bf7=_0xe911e6[_0x2b4f('0x90')]({'plain':!![]});_0x586bf7[_0x2b4f('0xf8')]=_0x4fa57b;if(_0x586bf7[_0x2b4f('0x116')]){_0x586bf7[_0x2b4f('0x116')]={'id':_0x586bf7['Owner']['id'],'name':_0x586bf7[_0x2b4f('0x116')]['name'],'fullname':_0x586bf7[_0x2b4f('0x116')]['fullname']};}return _0x586bf7;});});}});return Promise['all'](_0x3dbdb7);})[_0x2b4f('0x19')](function(_0x3a697f){return _(_0x3a697f)['flatten']()[_0x2b4f('0x125')](_0x2b4f('0x10a'))[_0x2b4f('0x126')]()[_0x2b4f('0x46')]();})[_0x2b4f('0x19')](function(_0x388170){_0x41a596['rows']=_0x28a03c['limit']?_0x388170['slice'](_0x28a03c[_0x2b4f('0x12')],_0x28a03c[_0x2b4f('0x12')]+_0x28a03c[_0x2b4f('0x14')]):_0x388170;return _0x41a596;})[_0x2b4f('0x19')](respondWithFilteredResult(_0x5938c2,_0x28a03c))['catch'](handleError(_0x5938c2,null));};
\ No newline at end of file