Built motion from commit 3c2ce842.|2.6.31
[motion2.git] / server / api / cmContact / cmContact.controller.js
index 68a2d59..d428970 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x9957=['c.deletedAt','c.CompanyId','GROUP_CONCAT(DISTINCT\x20t.id)','TagIds','Tags','catch','params','describe','tags','columnName','displayName','findAll','alias','values','body','get','join','info','CmHopper','CmHopperBlack','[CmContact][merge][destroy][CmHopperBlack],\x20%s','ChatMessage','ChatOfflineMessage','MailInteraction','MailMessage','FaxMessage','OpenchannelInteraction','OpenchannelMessage','CmHopperFinal','ReportAgentPreview','ChatQueueReport','MailQueueReport','OpenchannelQueueReport','JscriptySessionReport','create','bulkCreate','duplicates','$or','findOrCreate','show','$and','omit','format','cf_%d','table','cm_contacts','id\x20=\x20?','toParam','text','phone','rawAttributes','options','getTags','setTags','ids','getHoppers','ContactId','include','rows','getHopperHistories','CmHopperHistory','includeAll','getHopperFinals','getJscriptySessions','uploadCsv','No\x20ListId\x20specified','binding_keys','binding_values','No\x20association\x20values\x20specified!','socket_timestamp','Unable\x20to\x20synchronize\x20socket,\x20no\x20timestamp\x20passed','Incorrect\x20binding\x20parameters\x20passed!','zipObject','firstName','No\x20firstName\x20column\x20specified','root','server/files/tmp','file','filename','chmodSync','0777','../../components/import/cm/csv','CompanyId','File\x20uploaded\x20correctly!','pid','send','upload','createReadStream','parse','meta','import','binding','child_process','fork','../../components/import/cm/csv2','message','exit','error\x20child\x20process','getJourney','chat','sms','fax','voice','channel','includes','toLowerCase','Invalid\x20channel','range','isValid','Invalid\x20date\x20for\x20range\x20from\x20filter','Invalid\x20createdAt\x20filter','source','callerid','endtime','duration','note','userThirdDisposition','fullname','createdAt','VoiceCallReport','findAndCountAll','startCase','closed','closedAt','disposition','secondDisposition','thirdDisposition','UserId','Account','Owner','customerIp','deviceModel','osName','ratingMessage','ratingType','ratingValue','referer','mail','subject','openchannel','externalUrl','threadId','Interaction','all','flatten','sortBy','reverse','html-pdf','eml-format','rimraf','zip-dir','request-promise','moment','bluebird','mustache','path','sox','to-csv','ejs','lodash','squel','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/utils','../../config/license/util','../../mysqldb','redis','defaults','localhost','socket.io-emitter','register','sendStatus','status','end','json','count','limit','Content-Range','apply','reject','save','update','then','destroy','error','stack','name','index','keys','length','startsWith','push','CmCustomField','findOne','trimStart','cf_','type','model','query','intersection','fields','attributes','hasOwnProperty','nolimit','offset','order','sort','where','filters','pick','field','color','select','from','left_join','uc.CmContactId\x20=\x20c.id','ct.CmContactId\x20=\x20c.id','tools_tags','t.id\x20=\x20ct.TagId','c.deletedAt\x20IS\x20NULL','expr','search','sqlOperator','conditions','find','Tag','split','map','forEach','CONCAT(\x27,\x27,\x20`TagIds`,\x20\x27,\x27)\x20LIKE\x20?','union','User','and','uc.UserId\x20=\x20?','value','dateOfBirth','fieldType','datetime','DATE','buildExpression','start','filter','isNil','ListId','c.ListId\x20IN\x20?','concat','Contact','CONCAT_WS(\x27\x20\x27,\x20c.firstName,\x20c.lastName,\x20c.email)\x20LIKE\x20?','\x20=\x20?','tag','isArray','replace','getFullTextValue','isNumeric','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?','group','c.id','QueryTypes','SELECT','clone','DESC','isEmpty','having','t.id\x20IN\x20?','resolve','user','role','agent','some','getLists','c.ListId\x20IS\x20NULL','sequelize','toString','keyBy','merge','CmContact','c.lastName','c.mobile','c.fax','c.email','c.createdAt'];(function(_0x3d5ad8,_0x338d1c){var _0x40bf6a=function(_0x4be312){while(--_0x4be312){_0x3d5ad8['push'](_0x3d5ad8['shift']());}};_0x40bf6a(++_0x338d1c);}(_0x9957,0x93));var _0x7995=function(_0x6c993a,_0x5ea3ab){_0x6c993a=_0x6c993a-0x0;var _0x27f547=_0x9957[_0x6c993a];return _0x27f547;};'use strict';var pdf=require(_0x7995('0x0'));var emlformat=require(_0x7995('0x1'));var rimraf=require(_0x7995('0x2'));var zipdir=require(_0x7995('0x3'));var jsonpatch=require('fast-json-patch');var rp=require(_0x7995('0x4'));var moment=require(_0x7995('0x5'));var BPromise=require(_0x7995('0x6'));var Mustache=require(_0x7995('0x7'));var util=require('util');var path=require(_0x7995('0x8'));var sox=require(_0x7995('0x9'));var csv=require(_0x7995('0xa'));var ejs=require(_0x7995('0xb'));var fs=require('fs');var _=require(_0x7995('0xc'));var squel=require(_0x7995('0xd'));var crypto=require('crypto');var jsforce=require(_0x7995('0xe'));var deskjs=require(_0x7995('0xf'));var toCsv=require('to-csv');var querystring=require(_0x7995('0x10'));var Papa=require(_0x7995('0x11'));var Redis=require(_0x7995('0x12'));var authService=require(_0x7995('0x13'));var qs=require(_0x7995('0x14'));var as=require(_0x7995('0x15'));var hardwareService=require(_0x7995('0x16'));var logger=require('../../config/logger')(_0x7995('0x17'));var utils=require(_0x7995('0x18'));var config=require('../../config/environment');var licenseUtil=require(_0x7995('0x19'));var db=require(_0x7995('0x1a'))['db'];config[_0x7995('0x1b')]=_[_0x7995('0x1c')](config[_0x7995('0x1b')],{'host':_0x7995('0x1d'),'port':0x18eb});var socket=require(_0x7995('0x1e'))(new Redis(config['redis']));require('./cmContact.socket')[_0x7995('0x1f')](socket);function respondWithStatusCode(_0x2233dd,_0x24b5bb){_0x24b5bb=_0x24b5bb||0xcc;return function(_0x321ae8){if(_0x321ae8){return _0x2233dd[_0x7995('0x20')](_0x24b5bb);}return _0x2233dd[_0x7995('0x21')](_0x24b5bb)[_0x7995('0x22')]();};}function respondWithResult(_0x41cbf0,_0x5377e5){_0x5377e5=_0x5377e5||0xc8;return function(_0x2eeacc){if(_0x2eeacc){return _0x41cbf0['status'](_0x5377e5)[_0x7995('0x23')](_0x2eeacc);}};}function respondWithFilteredResult(_0x37f297,_0x43d4b8){return function(_0x291317){if(_0x291317){var _0x1e1415=_0x291317[_0x7995('0x24')],_0x37a7d4=_0x43d4b8['offset'],_0x4faa60=_0x43d4b8['offset']+_0x43d4b8[_0x7995('0x25')],_0x54c9ae;if(_0x4faa60>=_0x1e1415){_0x4faa60=_0x1e1415;_0x54c9ae=0xc8;}else{_0x54c9ae=0xce;}_0x37f297[_0x7995('0x21')](_0x54c9ae);return _0x37f297['set'](_0x7995('0x26'),_0x37a7d4+'-'+_0x4faa60+'/'+_0x1e1415)['json'](_0x291317);}return null;};}function patchUpdates(_0x4b1a8e){return function(_0x3e4c54){try{jsonpatch[_0x7995('0x27')](_0x3e4c54,_0x4b1a8e,!![]);}catch(_0x350fd9){return BPromise[_0x7995('0x28')](_0x350fd9);}return _0x3e4c54[_0x7995('0x29')]();};}function saveUpdates(_0x1c278a,_0x5d40ae){return function(_0x32a09a){if(_0x32a09a){return _0x32a09a[_0x7995('0x2a')](_0x1c278a)[_0x7995('0x2b')](function(_0x285437){return _0x285437;});}return null;};}function removeEntity(_0x563799,_0x13bc35){return function(_0x475351){if(_0x475351){return _0x475351[_0x7995('0x2c')]()['then'](function(){_0x563799[_0x7995('0x21')](0xcc)[_0x7995('0x22')]();});}};}function handleEntityNotFound(_0x401dc3,_0x268ce7){return function(_0x3a3fcf){if(!_0x3a3fcf){_0x401dc3[_0x7995('0x20')](0x194);}return _0x3a3fcf;};}function handleError(_0x56691a,_0x47625f){_0x47625f=_0x47625f||0x1f4;return function(_0x5911c3){logger[_0x7995('0x2d')](_0x5911c3[_0x7995('0x2e')]);if(_0x5911c3[_0x7995('0x2f')]){delete _0x5911c3[_0x7995('0x2f')];}_0x56691a[_0x7995('0x21')](_0x47625f)['send'](_0x5911c3);};}exports[_0x7995('0x30')]=function(_0x514445,_0x456a28){var _0x3250e0={},_0x4253e5={},_0x574574={'count':0x0,'rows':[]};return db['CmContact']['describe']()[_0x7995('0x2b')](function(_0xe6b0b3){var _0x327a81=[];for(var _0x2b874d=0x0;_0x2b874d<Object[_0x7995('0x31')](_0xe6b0b3)[_0x7995('0x32')];_0x2b874d++){var _0x538841=Object['keys'](_0xe6b0b3)[_0x2b874d];if(_[_0x7995('0x33')](_0x538841,'cf_')){_0x327a81[_0x7995('0x34')](db[_0x7995('0x35')][_0x7995('0x36')]({'where':{'id':_[_0x7995('0x37')](_0x538841,_0x7995('0x38'))},'raw':!![]}));}}return BPromise['all'](_0x327a81)[_0x7995('0x2b')](function(_0x33e24e){for(var _0x5dd802=0x0;_0x5dd802<_0x33e24e['length'];_0x5dd802++){if(_0x33e24e[_0x5dd802]){var _0x577412=_0x7995('0x38')+_0x33e24e[_0x5dd802]['id'];var _0x3acfc3=_0xe6b0b3[_0x577412];_0x3acfc3['fieldType']=_0x33e24e[_0x5dd802][_0x7995('0x39')];}}return _0xe6b0b3;});})['then'](function(_0x37917b){_0x4253e5[_0x7995('0x3a')]=_[_0x7995('0x31')](_0x37917b);_0x4253e5['query']=_['keys'](_0x514445[_0x7995('0x3b')]);_0x4253e5['filters']=_['intersection'](_0x4253e5[_0x7995('0x3a')],_0x4253e5[_0x7995('0x3b')]);_0x3250e0['attributes']=_[_0x7995('0x3c')](_0x4253e5[_0x7995('0x3a')],qs[_0x7995('0x3d')](_0x514445[_0x7995('0x3b')][_0x7995('0x3d')]));_0x3250e0['attributes']=_0x3250e0[_0x7995('0x3e')][_0x7995('0x32')]?_0x3250e0[_0x7995('0x3e')]:_0x4253e5[_0x7995('0x3a')];if(!_0x514445['query'][_0x7995('0x3f')](_0x7995('0x40'))){_0x3250e0[_0x7995('0x25')]=qs[_0x7995('0x25')](_0x514445[_0x7995('0x3b')][_0x7995('0x25')]);_0x3250e0['offset']=qs[_0x7995('0x41')](_0x514445[_0x7995('0x3b')][_0x7995('0x41')]);}_0x3250e0[_0x7995('0x42')]=qs[_0x7995('0x43')](_0x514445[_0x7995('0x3b')][_0x7995('0x43')]);_0x3250e0[_0x7995('0x44')]=qs[_0x7995('0x45')](_[_0x7995('0x46')](_0x514445[_0x7995('0x3b')],_0x4253e5[_0x7995('0x45')]),_0x37917b);var _0x7b4e67=[];var _0x53cda2=squel['select']()[_0x7995('0x47')]('id')[_0x7995('0x47')]('name')['field'](_0x7995('0x48'))['from']('tools_tags');var _0x23da6b=squel[_0x7995('0x49')]()[_0x7995('0x4a')]('cm_contacts','c')[_0x7995('0x4b')]('cm_user_has_contacts','uc',_0x7995('0x4c'))['left_join']('cm_contact_has_tags','ct',_0x7995('0x4d'))[_0x7995('0x4b')](_0x7995('0x4e'),'t',_0x7995('0x4f'))['where'](_0x7995('0x50'));var _0x40fc68=squel[_0x7995('0x51')]();var _0x6c7bec=[];var _0x4e09b7=squel['expr']();var _0x1c37c6;if(_0x514445['query'][_0x7995('0x52')]){_0x1c37c6=as['parseSearch'](_0x514445[_0x7995('0x3b')]['search']);var _0x1e795e=_0x1c37c6[_0x7995('0x53')];for(var _0x4d9245=0x0;_0x4d9245<_0x1c37c6[_0x7995('0x54')][_0x7995('0x32')];_0x4d9245++){var _0x314145=_0x1c37c6[_0x7995('0x54')][_0x4d9245];var _0x4c6837='c';var _0x2458cb=_(_0x37917b)[_0x7995('0x31')]()[_0x7995('0x55')](function(_0x491184){return _0x491184===_0x314145[_0x7995('0x47')];});if(_0x2458cb)_0x2458cb=_0x37917b[_0x314145[_0x7995('0x47')]];if(!_0x2458cb){if(_0x314145[_0x7995('0x47')]===_0x7995('0x56')){var _0x255313=_0x314145['value'][_0x7995('0x57')](',')[_0x7995('0x58')](function(_0x5921b9){return Number(_0x5921b9);});_0x255313[_0x7995('0x59')](function(_0x5843ba){_0x4e09b7['or'](_0x7995('0x5a'),'%,'+_0x5843ba+',%');});_0x6c7bec=_[_0x7995('0x5b')](_0x6c7bec,_0x255313);}else if(_0x314145[_0x7995('0x47')]===_0x7995('0x5c')){_0x40fc68[_0x7995('0x5d')](_0x7995('0x5e'),_0x314145[_0x7995('0x5f')]);}}else{if(_0x314145['field']===_0x7995('0x60')||_0x2458cb[_0x7995('0x61')]===_0x7995('0x62'))_0x314145['castTo']=_0x7995('0x63');var _0x1fe77e=as[_0x7995('0x64')](_0x4c6837,_0x2458cb['type'],_0x314145);_0x40fc68[_0x1e795e](_0x1fe77e['text'],_0x1fe77e['value'][_0x7995('0x65')],_0x1fe77e[_0x7995('0x5f')]['end']);}}}else{var _0x1cd85=_(Object[_0x7995('0x31')](_0x514445[_0x7995('0x3b')]))[_0x7995('0x58')](function(_0xc04004){return _0x37917b['hasOwnProperty'](_0xc04004)?_0xc04004:undefined;})[_0x7995('0x66')](function(_0x4ab09f){return!_[_0x7995('0x67')](_0x4ab09f);})[_0x7995('0x5f')]();if(_0x514445[_0x7995('0x3b')]['Contact'])_0x1cd85['push']('Contact');if(!_['isEmpty'](_0x1cd85)){_0x1cd85[_0x7995('0x59')](function(_0x3709de){if(_0x3709de===_0x7995('0x68')){_0x23da6b[_0x7995('0x44')](_0x7995('0x69'),[][_0x7995('0x6a')](_0x514445[_0x7995('0x3b')][_0x3709de]));}else if(_0x3709de===_0x7995('0x6b')){var _0x328671='%'+_0x514445[_0x7995('0x3b')][_0x3709de]+'%';_0x23da6b[_0x7995('0x44')](_0x7995('0x6c'),_0x328671);}else{_0x23da6b[_0x7995('0x44')]('c.'+_0x3709de+_0x7995('0x6d'),_0x514445[_0x7995('0x3b')][_0x3709de]);}});}if(_0x514445[_0x7995('0x3b')][_0x7995('0x6e')]){_0x6c7bec=_[_0x7995('0x6f')](_0x514445[_0x7995('0x3b')]['tag'])?_0x514445[_0x7995('0x3b')][_0x7995('0x6e')]:new Array(_0x514445[_0x7995('0x3b')][_0x7995('0x6e')]);_0x6c7bec['forEach'](function(_0x53125a){_0x4e09b7['or'](_0x7995('0x5a'),'%,'+_0x53125a+',%');});}if(_0x514445[_0x7995('0x3b')][_0x7995('0x66')]){var _0x332a85=_0x514445['query'][_0x7995('0x66')][_0x7995('0x70')]('\x5c','\x5c\x5c')[_0x7995('0x70')](/'/g,'\x27\x27');if(_0x332a85[_0x7995('0x57')]('\x20')['length']>0x1){_0x40fc68['or']('MATCH\x20(c.firstName,\x20c.lastName,\x20c.phone,\x20c.mobile,\x20c.fax,\x20c.email)\x20AGAINST\x20(?\x20IN\x20BOOLEAN\x20MODE)',qs[_0x7995('0x71')](_0x332a85),null);}else{if(qs[_0x7995('0x72')](_0x332a85)){_0x40fc68['or'](_0x7995('0x73'),_0x332a85+'%');_0x40fc68['or'](_0x7995('0x74'),_0x332a85+'%');_0x40fc68['or'](_0x7995('0x75'),_0x332a85+'%');_0x40fc68['or'](_0x7995('0x76'),_0x332a85+'%');}else if(qs[_0x7995('0x77')](_0x332a85)){_0x40fc68['or'](_0x7995('0x78'),_0x332a85+'%');}else{_0x40fc68['or'](_0x7995('0x79'),'%'+_0x332a85+'%');_0x40fc68['or']('c.lastName\x20LIKE\x20?','%'+_0x332a85+'%');_0x40fc68['or'](_0x7995('0x78'),'%'+_0x332a85+'%');}}}}_0x23da6b[_0x7995('0x44')](_0x40fc68);_0x23da6b[_0x7995('0x7a')](_0x7995('0x7b'));var _0x59c5aa={'type':db['Sequelize'][_0x7995('0x7c')][_0x7995('0x7d')],'raw':!![]};var _0x47d5d7=_0x23da6b[_0x7995('0x7e')]()[_0x7995('0x47')](_0x7995('0x7b'));if(_0x3250e0[_0x7995('0x42')]){_0x3250e0[_0x7995('0x42')]['forEach'](function(_0x457d09){_0x23da6b['order']('c.'+_0x457d09[0x0],_0x457d09[0x1]===_0x7995('0x7f')?![]:!![]);});}if(!_[_0x7995('0x80')](_0x6c7bec)){_0x23da6b[_0x7995('0x81')](_0x4e09b7);_0x47d5d7[_0x7995('0x44')](_0x7995('0x82'),_0x6c7bec);}BPromise[_0x7995('0x83')]()[_0x7995('0x2b')](function(){if(!_0x1c37c6)return;if(_0x514445[_0x7995('0x84')][_0x7995('0x85')]!==_0x7995('0x86'))return;if(!_[_0x7995('0x87')](_0x1c37c6[_0x7995('0x54')],['field',_0x7995('0x5c')])){return _0x514445[_0x7995('0x84')][_0x7995('0x88')]({'attributes':['id'],'raw':!![]})[_0x7995('0x2b')](function(_0x2c6548){if(_['isEmpty'](_0x2c6548)){_0x47d5d7['where'](_0x7995('0x89'));_0x23da6b[_0x7995('0x44')](_0x7995('0x89'));}else{_0x47d5d7[_0x7995('0x44')]('c.ListId\x20IN\x20?',_[_0x7995('0x58')](_0x2c6548,'id'));_0x23da6b['where']('c.ListId\x20IN\x20?',_[_0x7995('0x58')](_0x2c6548,'id'));}});}})[_0x7995('0x2b')](function(){if(_0x514445[_0x7995('0x84')][_0x7995('0x85')]===_0x7995('0x86')&&!_0x1c37c6&&!_0x514445[_0x7995('0x3b')][_0x7995('0x68')])return[];return db[_0x7995('0x8a')][_0x7995('0x3b')](_0x47d5d7[_0x7995('0x8b')](),_0x59c5aa);})['then'](function(_0x2dc1f7){_0x574574[_0x7995('0x24')]=_0x2dc1f7[_0x7995('0x32')];if(_0x574574['count']===0x0)return[];return db[_0x7995('0x8a')][_0x7995('0x3b')](_0x53cda2[_0x7995('0x8b')](),_0x59c5aa)[_0x7995('0x2b')](function(_0x3b0d30){_0x7b4e67=_[_0x7995('0x8c')](_0x3b0d30,'id');_0x59c5aa=_[_0x7995('0x8d')](_0x59c5aa,{'model':db[_0x7995('0x8e')],'mapToModel':!![],'raw':!![],'nest':!![]});if(_0x514445[_0x7995('0x3b')][_0x7995('0x3d')]){_0x3250e0[_0x7995('0x3e')]['forEach'](function(_0x5e8b4c){_0x23da6b[_0x7995('0x47')]('c.'+_0x5e8b4c);});}else{_0x23da6b[_0x7995('0x47')](_0x7995('0x7b'));_0x23da6b[_0x7995('0x47')]('c.firstName');_0x23da6b[_0x7995('0x47')](_0x7995('0x8f'));_0x23da6b['field']('c.phone');_0x23da6b[_0x7995('0x47')](_0x7995('0x90'));_0x23da6b['field'](_0x7995('0x91'));_0x23da6b['field'](_0x7995('0x92'));_0x23da6b[_0x7995('0x47')]('c.ListId');_0x23da6b['field'](_0x7995('0x93'));_0x23da6b['field'](_0x7995('0x94'));_0x23da6b[_0x7995('0x47')](_0x7995('0x95'));_0x23da6b[_0x7995('0x47')](_0x7995('0x96'),_0x7995('0x97'));}if(_0x3250e0[_0x7995('0x25')])_0x23da6b[_0x7995('0x25')](_0x3250e0[_0x7995('0x25')]);if(_0x3250e0[_0x7995('0x41')])_0x23da6b[_0x7995('0x41')](_0x3250e0[_0x7995('0x41')]);return db[_0x7995('0x8a')][_0x7995('0x3b')](_0x23da6b[_0x7995('0x8b')](),_0x59c5aa);});})[_0x7995('0x2b')](function(_0x6ad274){_0x6ad274[_0x7995('0x59')](function(_0x2ff7ba){if(_0x2ff7ba[_0x7995('0x97')]){_0x2ff7ba[_0x7995('0x98')]=[];_0x2ff7ba[_0x7995('0x97')][_0x7995('0x57')](',')[_0x7995('0x59')](function(_0x260ef1){_0x2ff7ba[_0x7995('0x98')][_0x7995('0x34')](_0x7b4e67[_0x260ef1]);});}delete _0x2ff7ba[_0x7995('0x97')];});_0x574574['rows']=_0x6ad274;return _0x574574;})[_0x7995('0x2b')](respondWithFilteredResult(_0x456a28,_0x3250e0));})[_0x7995('0x99')](handleError(_0x456a28,null));};exports['destroy']=function(_0x4c85cb,_0x15e8d1){return db[_0x7995('0x8e')][_0x7995('0x55')]({'where':{'id':_0x4c85cb[_0x7995('0x9a')]['id']}})[_0x7995('0x2b')](handleEntityNotFound(_0x15e8d1,null))[_0x7995('0x2b')](removeEntity(_0x15e8d1,null))['catch'](handleError(_0x15e8d1,null));};exports[_0x7995('0x9b')]=function(_0xb68962,_0x3fea6a){return db[_0x7995('0x8e')][_0x7995('0x9b')]()[_0x7995('0x2b')](function(_0x151d99){delete _0x151d99[_0x7995('0x9c')];for(var _0x560095=0x0;_0x560095<Object[_0x7995('0x31')](_0x151d99)[_0x7995('0x32')];_0x560095++){var _0x5c04c9=Object['keys'](_0x151d99)[_0x560095];if(!_[_0x7995('0x33')](_0x5c04c9,_0x7995('0x38'))){_0x151d99[_0x5c04c9][_0x7995('0x9d')]=_0x5c04c9;_0x151d99[_0x5c04c9][_0x7995('0x9e')]=_0x5c04c9;}}return _0x151d99;})[_0x7995('0x2b')](function(_0x4a02ea){var _0x35f6cb={'where':{'$or':[{'ListId':_0xb68962[_0x7995('0x3b')]['id']},{'ListId':null}]},'raw':!![]};return db['CmCustomField'][_0x7995('0x9f')](_0x35f6cb)[_0x7995('0x2b')](function(_0x489bac){for(var _0x1535a3=0x0;_0x1535a3<_0x489bac['length'];_0x1535a3++){var _0x135191=_0x7995('0x38')+_0x489bac[_0x1535a3]['id'];_0x4a02ea[_0x135191][_0x7995('0x9d')]=_0x135191;_0x4a02ea[_0x135191][_0x7995('0x9e')]=_0x489bac[_0x1535a3][_0x7995('0xa0')];_0x4a02ea[_0x135191]['custom']={'type':_0x489bac[_0x1535a3][_0x7995('0x39')],'values':_0x489bac[_0x1535a3][_0x7995('0xa1')]};}Object[_0x7995('0x31')](_0x4a02ea)['forEach'](function(_0x29dff6){if(!_0x4a02ea[_0x29dff6][_0x7995('0x3f')](_0x7995('0x9d'))){delete _0x4a02ea[_0x29dff6];}});return _0x4a02ea;});})[_0x7995('0x2b')](respondWithResult(_0x3fea6a,null))['catch'](handleError(_0x3fea6a,null));};exports[_0x7995('0x8d')]=function(_0xf59a39,_0x3a5f5e){var _0x4aafa3;var _0x5358d4;var _0x3fc10;if(_0xf59a39[_0x7995('0xa2')]['id']){delete _0xf59a39['body']['id'];}return db['CmContact'][_0x7995('0x9f')]({'where':{'id':[_0xf59a39[_0x7995('0xa2')]['to'],_0xf59a39[_0x7995('0xa2')][_0x7995('0x4a')]]}})[_0x7995('0x2b')](function(_0x551b5e){if(_0x551b5e){if(_0x551b5e['length']!==0x2){return null;}_0x551b5e[0x0]=_0x551b5e[0x0][_0x7995('0xa3')]({'plain':!![]});_0x551b5e[0x1]=_0x551b5e[0x1]['get']({'plain':!![]});delete _0x551b5e[0x0]['id'];delete _0x551b5e[0x1]['id'];return _['mergeWith'](_0x551b5e[0x0],_0x551b5e[0x1],function(_0x208998,_0x3b731e){if(Array[_0x7995('0x6f')](_0x3b731e)&&!_0x3b731e['length']){return _0x208998;}else if(!_0x3b731e){return _0x208998;}});}})[_0x7995('0x2b')](handleEntityNotFound(_0x3a5f5e,null))[_0x7995('0x2b')](function(_0x2b0b79){if(_0x2b0b79){if(_0x2b0b79[_0x7995('0x9c')]&&_[_0x7995('0x6f')](_0x2b0b79['tags'])){_0x2b0b79[_0x7995('0x9c')]=_0x2b0b79[_0x7995('0x9c')][_0x7995('0xa4')]();}logger[_0x7995('0xa5')]('[CmContact][merge]\x20to\x20%s\x20from\x20%s',_0xf59a39[_0x7995('0xa2')]['to'],_0xf59a39[_0x7995('0xa2')]['from']);return db[_0x7995('0xa6')][_0x7995('0x2c')]({'where':{'ContactId':[_0xf59a39['body']['to'],_0xf59a39[_0x7995('0xa2')]['from']]}})[_0x7995('0x2b')](function(_0x51e7d7){logger[_0x7995('0xa5')]('[CmContact][merge][destroy][CmHopper],\x20%s',_0x51e7d7);return db[_0x7995('0xa7')][_0x7995('0x2c')]({'where':{'ContactId':[_0xf59a39['body']['to'],_0xf59a39[_0x7995('0xa2')]['from']]}})['then'](function(_0x7b9e26){logger[_0x7995('0xa5')](_0x7995('0xa8'),_0x7b9e26);return db[_0x7995('0x8e')]['create'](_0x2b0b79);});});}})[_0x7995('0x2b')](function(_0x35044a){if(_0x35044a){_0x4aafa3=_0x35044a;_0x5358d4={'ContactId':_0x4aafa3['id']};_0x3fc10={'where':{'ContactId':[_0xf59a39['body']['to'],_0xf59a39['body'][_0x7995('0x4a')]]}};return db['ChatInteraction'][_0x7995('0x2a')](_0x5358d4,_0x3fc10);}})[_0x7995('0x2b')](function(){if(_0x4aafa3){return db[_0x7995('0xa9')]['update'](_0x5358d4,_0x3fc10);}})['then'](function(){if(_0x4aafa3){return db[_0x7995('0xaa')]['update'](_0x5358d4,_0x3fc10);}})[_0x7995('0x2b')](function(){if(_0x4aafa3){return db[_0x7995('0xab')][_0x7995('0x2a')](_0x5358d4,_0x3fc10);}})[_0x7995('0x2b')](function(){if(_0x4aafa3){return db['MailMessage']['update'](_0x5358d4,_0x3fc10);}})['then'](function(){if(_0x4aafa3){return db[_0x7995('0xab')][_0x7995('0x2a')](_0x5358d4,_0x3fc10);}})[_0x7995('0x2b')](function(){if(_0x4aafa3){return db[_0x7995('0xac')][_0x7995('0x2a')](_0x5358d4,_0x3fc10);}})[_0x7995('0x2b')](function(){if(_0x4aafa3){return db['SmsInteraction']['update'](_0x5358d4,_0x3fc10);}})[_0x7995('0x2b')](function(){if(_0x4aafa3){return db['SmsMessage']['update'](_0x5358d4,_0x3fc10);}})[_0x7995('0x2b')](function(){if(_0x4aafa3){return db['FaxInteraction']['update'](_0x5358d4,_0x3fc10);}})[_0x7995('0x2b')](function(){if(_0x4aafa3){return db[_0x7995('0xad')][_0x7995('0x2a')](_0x5358d4,_0x3fc10);}})['then'](function(){if(_0x4aafa3){return db[_0x7995('0xae')][_0x7995('0x2a')](_0x5358d4,_0x3fc10);}})[_0x7995('0x2b')](function(){if(_0x4aafa3){return db[_0x7995('0xaf')][_0x7995('0x2a')](_0x5358d4,_0x3fc10);}})[_0x7995('0x2b')](function(){if(_0x4aafa3){return db[_0x7995('0xb0')][_0x7995('0x2a')](_0x5358d4,_0x3fc10);}})[_0x7995('0x2b')](function(){if(_0x4aafa3){return db['CmHopperHistory'][_0x7995('0x2a')](_0x5358d4,_0x3fc10);}})[_0x7995('0x2b')](function(){if(_0x4aafa3){return db[_0x7995('0xb1')][_0x7995('0x2a')](_0x5358d4,_0x3fc10);}})[_0x7995('0x2b')](function(){if(_0x4aafa3){return db['VoiceCallReport'][_0x7995('0x2a')](_0x5358d4,_0x3fc10);}})[_0x7995('0x2b')](function(){if(_0x4aafa3){return db[_0x7995('0xb2')]['update'](_0x5358d4,_0x3fc10);}})['then'](function(){if(_0x4aafa3){return db['FaxQueueReport'][_0x7995('0x2a')](_0x5358d4,_0x3fc10);}})[_0x7995('0x2b')](function(){if(_0x4aafa3){return db[_0x7995('0xb3')][_0x7995('0x2a')](_0x5358d4,_0x3fc10);}})[_0x7995('0x2b')](function(){if(_0x4aafa3){return db[_0x7995('0xb4')]['update'](_0x5358d4,_0x3fc10);}})[_0x7995('0x2b')](function(){if(_0x4aafa3){return db['SmsQueueReport'][_0x7995('0x2a')](_0x5358d4,_0x3fc10);}})[_0x7995('0x2b')](function(){if(_0x4aafa3){return db[_0x7995('0xb5')][_0x7995('0x2a')](_0x5358d4,_0x3fc10);}})[_0x7995('0x2b')](function(){if(_0x4aafa3){return db[_0x7995('0x8e')][_0x7995('0x2c')]({'where':{'id':[_0xf59a39[_0x7995('0xa2')]['to'],_0xf59a39[_0x7995('0xa2')][_0x7995('0x4a')]]}});}})[_0x7995('0x2b')](function(){if(_0x4aafa3){return _0x4aafa3;}})['then'](respondWithResult(_0x3a5f5e,null))[_0x7995('0x99')](handleError(_0x3a5f5e,null));};exports['create']=function(_0x422d1f,_0x3d1298){return db['CmContact']['describe']()[_0x7995('0x2b')](function(_0x267859){if(_0x422d1f[_0x7995('0xa2')][_0x7995('0x9c')]&&_[_0x7995('0x6f')](_0x422d1f[_0x7995('0xa2')][_0x7995('0x9c')])){if(_0x422d1f[_0x7995('0xa2')][_0x7995('0x9c')][_0x7995('0x32')]){_0x422d1f[_0x7995('0xa2')][_0x7995('0x9c')]=_0x422d1f['body']['tags'][_0x7995('0xa4')](';')+';';}else{_0x422d1f[_0x7995('0xa2')][_0x7995('0x9c')]=null;}}else{_0x422d1f[_0x7995('0xa2')][_0x7995('0x9c')]=null;}return db['CmContact'][_0x7995('0xb6')](_0x422d1f[_0x7995('0xa2')],{'fields':_['keys'](_0x267859),'raw':!![]});})[_0x7995('0x2b')](respondWithResult(_0x3d1298,0xc9))['catch'](handleError(_0x3d1298,null));};exports[_0x7995('0xb7')]=function(_0x30cda5,_0x234a40){var _0x5860d4=[];var _0x3501ac=0x0;var _0x1cd9a0=0x0;var _0x29dcaf=0x0;return db[_0x7995('0x8e')][_0x7995('0x9b')]()[_0x7995('0x2b')](function(_0x3c03d6){return BPromise['each'](_0x30cda5['body'],function(_0x5aee3b){var _0x406f82={'where':{'$or':[]},'defaults':_0x5aee3b,'fields':_[_0x7995('0x31')](_0x3c03d6),'raw':!![]};if(_0x5aee3b['duplicates']){for(var _0x4eb988=0x0;_0x4eb988<_0x5aee3b[_0x7995('0xb8')][_0x7995('0x32')];_0x4eb988++){var _0x48d4a7={};_0x48d4a7[_0x5aee3b['duplicates'][_0x4eb988]]=_0x5aee3b[_0x5aee3b['duplicates'][_0x4eb988]];_0x406f82['where'][_0x7995('0xb9')][_0x7995('0x34')](_0x48d4a7);}_0x406f82[_0x7995('0x44')][_0x7995('0x68')]=_0x5aee3b['ListId'];}return db[_0x7995('0x8e')][_0x7995('0xba')](_0x406f82)['spread'](function(_0x1fc3a1,_0x21d990){if(_0x21d990){_0x3501ac++;}else{_0x29dcaf++;}})[_0x7995('0x99')](function(_0x580917){console[_0x7995('0x2d')](_0x580917);_0x1cd9a0++;});});})[_0x7995('0x2b')](function(_0x49412e){if(_0x49412e){return{'success':_0x3501ac,'failure':_0x1cd9a0,'duplicates':_0x29dcaf};}})[_0x7995('0x2b')](respondWithResult(_0x234a40,0xc9))[_0x7995('0x99')](handleError(_0x234a40,null));};exports[_0x7995('0xbb')]=function(_0x6b9ae0,_0x1d907c,_0x30f457){var _0x8abd9a;return db[_0x7995('0x8e')][_0x7995('0x9b')]()[_0x7995('0x2b')](function(_0x9a19f){return db[_0x7995('0x8e')][_0x7995('0x55')]({'where':{'id':_0x6b9ae0['params']['id']},'include':[{'model':db[_0x7995('0x56')],'as':_0x7995('0x98'),'attributes':['id',_0x7995('0x2f'),_0x7995('0x48')],'required':_0x6b9ae0['query'][_0x7995('0x6e')]?!![]:![]}],'attributes':_[_0x7995('0x31')](_0x9a19f)});})[_0x7995('0x2b')](function(_0x52af9b){_0x8abd9a=_0x52af9b[_0x7995('0xa3')]({'plain':!![]});var _0x3366a7={'where':{'$and':[{'ListId':{'$ne':null}}]}};if(_0x52af9b&&_0x52af9b[_0x7995('0x68')]){if(_0x52af9b[_0x7995('0x68')]){_0x3366a7[_0x7995('0x44')][_0x7995('0xbc')][_0x7995('0x34')]({'ListId':{'$ne':_0x52af9b['ListId']}});}}return db[_0x7995('0x35')]['findAll'](_0x3366a7);})[_0x7995('0x2b')](function(_0x164c61){return _[_0x7995('0xbd')](_0x8abd9a,_['map'](_0x164c61,function(_0xd012b9){return util['format']('cf_%d',_0xd012b9['id']);}));})['then'](handleEntityNotFound(_0x1d907c,null))['then'](respondWithResult(_0x1d907c,null))[_0x7995('0x99')](handleError(_0x1d907c,null));};exports[_0x7995('0x2a')]=function(_0x5d2973,_0x45978a){var _0x3edba1;if(_0x5d2973['body']['id']){delete _0x5d2973[_0x7995('0xa2')]['id'];}return db[_0x7995('0x8e')][_0x7995('0x55')]({'where':{'id':_0x5d2973[_0x7995('0x9a')]['id']}})[_0x7995('0x2b')](handleEntityNotFound(_0x45978a,null))['then'](saveUpdates(_0x5d2973[_0x7995('0xa2')],null))[_0x7995('0x2b')](function(_0x12127d){_0x3edba1=_0x12127d;var _0x186ebe={'where':{'$and':[{'ListId':{'$ne':null}}]}};if(_0x12127d&&_0x12127d['ListId']){if(_0x12127d[_0x7995('0x68')]){_0x186ebe[_0x7995('0x44')][_0x7995('0xbc')][_0x7995('0x34')]({'ListId':{'$ne':_0x12127d[_0x7995('0x68')]}});}}return db[_0x7995('0x35')][_0x7995('0x9f')](_0x186ebe);})[_0x7995('0x2b')](function(_0x1c3074){if(_0x1c3074){return _[_0x7995('0xbd')](_['pickBy'](_0x5d2973[_0x7995('0xa2')],function(_0x521712,_0x139204){return _[_0x7995('0x33')](_0x139204,_0x7995('0x38'));}),_['map'](_0x1c3074,function(_0x58569c){return util[_0x7995('0xbe')](_0x7995('0xbf'),_0x58569c['id']);}));}})['then'](function(_0x15ed0f){if(_0x15ed0f&&!_['isEmpty'](_0x15ed0f)){var _0x43de18=squel[_0x7995('0x2a')]()[_0x7995('0xc0')](_0x7995('0xc1'))['setFields'](_0x15ed0f)['where'](_0x7995('0xc2'),_0x5d2973[_0x7995('0x9a')]['id'])[_0x7995('0xc3')]();return db[_0x7995('0x8a')]['query'](_0x43de18[_0x7995('0xc4')],{'replacements':_0x43de18[_0x7995('0xa1')]});}})[_0x7995('0x2b')](function(){if(_0x5d2973[_0x7995('0xa2')][_0x7995('0xc5')]&&_0x3edba1){return db['CmHopper']['update']({'phone':_0x5d2973['body'][_0x7995('0xc5')]},{'where':{'ContactId':_0x3edba1['id']}});}})[_0x7995('0x2b')](function(){return _0x3edba1;})['then'](respondWithResult(_0x45978a,null))[_0x7995('0x99')](handleError(_0x45978a,null));};exports['getTags']=function(_0x29c0f4,_0x19e449,_0x1e7398){var _0x467913={};var _0x4f145e={};var _0x3fbafb;var _0x2caacd;return db[_0x7995('0x8e')][_0x7995('0x36')]({'where':{'id':_0x29c0f4[_0x7995('0x9a')]['id']}})[_0x7995('0x2b')](handleEntityNotFound(_0x19e449,null))[_0x7995('0x2b')](function(_0x152c2a){if(_0x152c2a){_0x3fbafb=_0x152c2a;_0x4f145e[_0x7995('0x3a')]=_[_0x7995('0x31')](db[_0x7995('0x56')][_0x7995('0xc6')]);_0x4f145e[_0x7995('0x3b')]=_[_0x7995('0x31')](_0x29c0f4['query']);_0x4f145e[_0x7995('0x45')]=_['intersection'](_0x4f145e[_0x7995('0x3a')],_0x4f145e[_0x7995('0x3b')]);_0x467913['attributes']=_[_0x7995('0x3c')](_0x4f145e['model'],qs[_0x7995('0x3d')](_0x29c0f4[_0x7995('0x3b')]['fields']));_0x467913['attributes']=_0x467913['attributes'][_0x7995('0x32')]?_0x467913[_0x7995('0x3e')]:_0x4f145e[_0x7995('0x3a')];_0x467913[_0x7995('0x42')]=qs['sort'](_0x29c0f4[_0x7995('0x3b')][_0x7995('0x43')]);_0x467913[_0x7995('0x44')]=qs[_0x7995('0x45')](_[_0x7995('0x46')](_0x29c0f4[_0x7995('0x3b')],_0x4f145e[_0x7995('0x45')]));if(_0x29c0f4[_0x7995('0x3b')]['filter']){_0x467913[_0x7995('0x44')]=_[_0x7995('0x8d')](_0x467913[_0x7995('0x44')],{'$or':_[_0x7995('0x58')](_0x467913['attributes'],function(_0x3e90a5){var _0x3a2958={};_0x3a2958[_0x3e90a5]={'$like':'%'+_0x29c0f4[_0x7995('0x3b')][_0x7995('0x66')]+'%'};return _0x3a2958;})});}_0x467913=_[_0x7995('0x8d')]({},_0x467913,_0x29c0f4[_0x7995('0xc7')]);return _0x3fbafb['getTags'](_0x467913);}})[_0x7995('0x2b')](function(_0x2ee5d8){if(_0x2ee5d8){_0x2caacd=_0x2ee5d8[_0x7995('0x32')];if(!_0x29c0f4[_0x7995('0x3b')][_0x7995('0x3f')](_0x7995('0x40'))){_0x467913[_0x7995('0x25')]=qs[_0x7995('0x25')](_0x29c0f4[_0x7995('0x3b')][_0x7995('0x25')]);_0x467913[_0x7995('0x41')]=qs[_0x7995('0x41')](_0x29c0f4[_0x7995('0x3b')][_0x7995('0x41')]);}return _0x3fbafb[_0x7995('0xc8')](_0x467913);}})[_0x7995('0x2b')](function(_0xcd587e){if(_0xcd587e){return _0xcd587e?{'count':_0x2caacd,'rows':_0xcd587e}:null;}})[_0x7995('0x2b')](respondWithResult(_0x19e449,null))[_0x7995('0x99')](handleError(_0x19e449,null));};exports[_0x7995('0xc9')]=function(_0x37e69d,_0x51f854,_0x4cf7f1){if(_0x37e69d[_0x7995('0xa2')]['id']){delete _0x37e69d[_0x7995('0xa2')]['id'];}return db['CmContact'][_0x7995('0x36')]({'where':{'id':_0x37e69d['params']['id']}})[_0x7995('0x2b')](handleEntityNotFound(_0x51f854,null))['then'](function(_0x314901){if(_0x314901){return _0x314901[_0x7995('0xc9')](_0x37e69d[_0x7995('0xa2')][_0x7995('0xca')]||[]);}return null;})[_0x7995('0x2b')](respondWithResult(_0x51f854,null))[_0x7995('0x99')](handleError(_0x51f854,null));};exports[_0x7995('0xcb')]=function(_0x1fa59d,_0x10f635,_0x456cc9){var _0x49e85c={'raw':![],'where':{}};var _0x3b9e74={};var _0xb6f004={'count':0x0,'rows':[]};return db[_0x7995('0x8e')][_0x7995('0x36')]({'where':{'id':_0x1fa59d['params']['id']}})[_0x7995('0x2b')](handleEntityNotFound(_0x10f635,null))[_0x7995('0x2b')](function(_0x2f5904){if(_0x2f5904){_0x3b9e74[_0x7995('0x3a')]=_['keys'](db[_0x7995('0xa6')][_0x7995('0xc6')]);_0x3b9e74[_0x7995('0x3b')]=_[_0x7995('0x31')](_0x1fa59d[_0x7995('0x3b')]);_0x3b9e74[_0x7995('0x45')]=_[_0x7995('0x3c')](_0x3b9e74[_0x7995('0x3a')],_0x3b9e74[_0x7995('0x3b')]);_0x49e85c['attributes']=_[_0x7995('0x3c')](_0x3b9e74['model'],qs[_0x7995('0x3d')](_0x1fa59d[_0x7995('0x3b')][_0x7995('0x3d')]));_0x49e85c[_0x7995('0x3e')]=_0x49e85c['attributes'][_0x7995('0x32')]?_0x49e85c[_0x7995('0x3e')]:_0x3b9e74[_0x7995('0x3a')];if(!_0x1fa59d[_0x7995('0x3b')][_0x7995('0x3f')](_0x7995('0x40'))){_0x49e85c[_0x7995('0x25')]=qs[_0x7995('0x25')](_0x1fa59d[_0x7995('0x3b')][_0x7995('0x25')]);_0x49e85c[_0x7995('0x41')]=qs[_0x7995('0x41')](_0x1fa59d[_0x7995('0x3b')][_0x7995('0x41')]);}_0x49e85c['order']=qs['sort'](_0x1fa59d[_0x7995('0x3b')][_0x7995('0x43')]);_0x49e85c[_0x7995('0x44')]=qs['filters'](_[_0x7995('0x46')](_0x1fa59d[_0x7995('0x3b')],_0x3b9e74[_0x7995('0x45')]));_0x49e85c['where'][_0x7995('0xcc')]=_0x2f5904['id'];if(_0x1fa59d[_0x7995('0x3b')][_0x7995('0x66')]){_0x49e85c[_0x7995('0x44')]=_[_0x7995('0x8d')](_0x49e85c[_0x7995('0x44')],{'$or':_[_0x7995('0x58')](_0x49e85c[_0x7995('0x3e')],function(_0xebba79){var _0x3e28b6={};_0x3e28b6[_0xebba79]={'$like':'%'+_0x1fa59d[_0x7995('0x3b')]['filter']+'%'};return _0x3e28b6;})});}_0x49e85c=_['merge']({},_0x49e85c,_0x1fa59d[_0x7995('0xc7')]);return db['CmHopper'][_0x7995('0x24')]({'where':_0x49e85c[_0x7995('0x44')]})[_0x7995('0x2b')](function(_0x28fb29){_0xb6f004[_0x7995('0x24')]=_0x28fb29;if(_0x1fa59d['query']['includeAll']){_0x49e85c[_0x7995('0xcd')]=[{'all':!![]}];}return db[_0x7995('0xa6')][_0x7995('0x9f')](_0x49e85c);})[_0x7995('0x2b')](function(_0x62653d){_0xb6f004[_0x7995('0xce')]=_0x62653d;return _0xb6f004;});}})[_0x7995('0x2b')](respondWithFilteredResult(_0x10f635,_0x49e85c))[_0x7995('0x99')](handleError(_0x10f635,null));};exports[_0x7995('0xcf')]=function(_0x1b4c68,_0x5ad1a1,_0x2ebf7c){var _0x267ffa={'raw':!![],'where':{}};var _0x38e67a={};var _0xc8259b={'count':0x0,'rows':[]};return db['CmContact']['findOne']({'where':{'id':_0x1b4c68['params']['id']}})['then'](handleEntityNotFound(_0x5ad1a1,null))['then'](function(_0x3b4941){if(_0x3b4941){_0x38e67a['model']=_['keys'](db[_0x7995('0xd0')][_0x7995('0xc6')]);_0x38e67a[_0x7995('0x3b')]=_['keys'](_0x1b4c68[_0x7995('0x3b')]);_0x38e67a['filters']=_[_0x7995('0x3c')](_0x38e67a[_0x7995('0x3a')],_0x38e67a[_0x7995('0x3b')]);_0x267ffa['attributes']=_[_0x7995('0x3c')](_0x38e67a[_0x7995('0x3a')],qs[_0x7995('0x3d')](_0x1b4c68['query'][_0x7995('0x3d')]));_0x267ffa[_0x7995('0x3e')]=_0x267ffa[_0x7995('0x3e')][_0x7995('0x32')]?_0x267ffa[_0x7995('0x3e')]:_0x38e67a['model'];if(!_0x1b4c68[_0x7995('0x3b')][_0x7995('0x3f')](_0x7995('0x40'))){_0x267ffa['limit']=qs[_0x7995('0x25')](_0x1b4c68[_0x7995('0x3b')][_0x7995('0x25')]);_0x267ffa[_0x7995('0x41')]=qs[_0x7995('0x41')](_0x1b4c68['query'][_0x7995('0x41')]);}_0x267ffa[_0x7995('0x42')]=qs[_0x7995('0x43')](_0x1b4c68[_0x7995('0x3b')][_0x7995('0x43')]);_0x267ffa[_0x7995('0x44')]=qs[_0x7995('0x45')](_['pick'](_0x1b4c68['query'],_0x38e67a[_0x7995('0x45')]));_0x267ffa[_0x7995('0x44')]['ContactId']=_0x3b4941['id'];if(_0x1b4c68['query'][_0x7995('0x66')]){_0x267ffa[_0x7995('0x44')]=_[_0x7995('0x8d')](_0x267ffa[_0x7995('0x44')],{'$or':_[_0x7995('0x58')](_0x267ffa[_0x7995('0x3e')],function(_0x39a023){var _0x4dca11={};_0x4dca11[_0x39a023]={'$like':'%'+_0x1b4c68[_0x7995('0x3b')][_0x7995('0x66')]+'%'};return _0x4dca11;})});}_0x267ffa=_[_0x7995('0x8d')]({},_0x267ffa,_0x1b4c68[_0x7995('0xc7')]);return db[_0x7995('0xd0')][_0x7995('0x24')]({'where':_0x267ffa['where']})[_0x7995('0x2b')](function(_0x406712){_0xc8259b[_0x7995('0x24')]=_0x406712;if(_0x1b4c68[_0x7995('0x3b')][_0x7995('0xd1')]){_0x267ffa[_0x7995('0xcd')]=[{'all':!![]}];}return db[_0x7995('0xd0')]['findAll'](_0x267ffa);})[_0x7995('0x2b')](function(_0x202102){_0xc8259b[_0x7995('0xce')]=_0x202102;return _0xc8259b;});}})[_0x7995('0x2b')](respondWithFilteredResult(_0x5ad1a1,_0x267ffa))['catch'](handleError(_0x5ad1a1,null));};exports[_0x7995('0xd2')]=function(_0x5c9894,_0x21ba9b,_0x440c83){var _0x479b60={'raw':!![],'where':{}};var _0x4a313b={};var _0x478c12={'count':0x0,'rows':[]};return db[_0x7995('0x8e')][_0x7995('0x36')]({'where':{'id':_0x5c9894[_0x7995('0x9a')]['id']}})[_0x7995('0x2b')](handleEntityNotFound(_0x21ba9b,null))[_0x7995('0x2b')](function(_0x2da21e){if(_0x2da21e){_0x4a313b[_0x7995('0x3a')]=_[_0x7995('0x31')](db[_0x7995('0xb0')][_0x7995('0xc6')]);_0x4a313b[_0x7995('0x3b')]=_[_0x7995('0x31')](_0x5c9894['query']);_0x4a313b['filters']=_[_0x7995('0x3c')](_0x4a313b['model'],_0x4a313b['query']);_0x479b60[_0x7995('0x3e')]=_[_0x7995('0x3c')](_0x4a313b[_0x7995('0x3a')],qs[_0x7995('0x3d')](_0x5c9894[_0x7995('0x3b')][_0x7995('0x3d')]));_0x479b60[_0x7995('0x3e')]=_0x479b60[_0x7995('0x3e')][_0x7995('0x32')]?_0x479b60[_0x7995('0x3e')]:_0x4a313b[_0x7995('0x3a')];if(!_0x5c9894[_0x7995('0x3b')]['hasOwnProperty'](_0x7995('0x40'))){_0x479b60[_0x7995('0x25')]=qs[_0x7995('0x25')](_0x5c9894[_0x7995('0x3b')][_0x7995('0x25')]);_0x479b60[_0x7995('0x41')]=qs[_0x7995('0x41')](_0x5c9894['query'][_0x7995('0x41')]);}_0x479b60[_0x7995('0x42')]=qs[_0x7995('0x43')](_0x5c9894[_0x7995('0x3b')][_0x7995('0x43')]);_0x479b60['where']=qs[_0x7995('0x45')](_['pick'](_0x5c9894[_0x7995('0x3b')],_0x4a313b[_0x7995('0x45')]));_0x479b60[_0x7995('0x44')]['ContactId']=_0x2da21e['id'];if(_0x5c9894[_0x7995('0x3b')][_0x7995('0x66')]){_0x479b60[_0x7995('0x44')]=_[_0x7995('0x8d')](_0x479b60[_0x7995('0x44')],{'$or':_[_0x7995('0x58')](_0x479b60[_0x7995('0x3e')],function(_0x4fb899){var _0x55656a={};_0x55656a[_0x4fb899]={'$like':'%'+_0x5c9894[_0x7995('0x3b')][_0x7995('0x66')]+'%'};return _0x55656a;})});}_0x479b60=_[_0x7995('0x8d')]({},_0x479b60,_0x5c9894[_0x7995('0xc7')]);return db[_0x7995('0xb0')][_0x7995('0x24')]({'where':_0x479b60['where']})[_0x7995('0x2b')](function(_0x2e21a1){_0x478c12[_0x7995('0x24')]=_0x2e21a1;if(_0x5c9894[_0x7995('0x3b')]['includeAll']){_0x479b60['include']=[{'all':!![]}];}return db[_0x7995('0xb0')][_0x7995('0x9f')](_0x479b60);})['then'](function(_0x3130f2){_0x478c12[_0x7995('0xce')]=_0x3130f2;return _0x478c12;});}})['then'](respondWithFilteredResult(_0x21ba9b,_0x479b60))[_0x7995('0x99')](handleError(_0x21ba9b,null));};exports[_0x7995('0xd3')]=function(_0x45d8a2,_0x26ab59,_0xfe4f58){var _0x4b3689={'raw':!![],'where':{}};var _0x548e90={};var _0x9bde3d={'count':0x0,'rows':[]};return db[_0x7995('0x8e')][_0x7995('0x36')]({'where':{'id':_0x45d8a2[_0x7995('0x9a')]['id']}})[_0x7995('0x2b')](handleEntityNotFound(_0x26ab59,null))['then'](function(_0xd0da6e){if(_0xd0da6e){_0x548e90[_0x7995('0x3a')]=_[_0x7995('0x31')](db[_0x7995('0xb5')][_0x7995('0xc6')]);_0x548e90['query']=_['keys'](_0x45d8a2['query']);_0x548e90['filters']=_[_0x7995('0x3c')](_0x548e90[_0x7995('0x3a')],_0x548e90['query']);_0x4b3689[_0x7995('0x3e')]=_[_0x7995('0x3c')](_0x548e90['model'],qs['fields'](_0x45d8a2[_0x7995('0x3b')][_0x7995('0x3d')]));_0x4b3689[_0x7995('0x3e')]=_0x4b3689[_0x7995('0x3e')][_0x7995('0x32')]?_0x4b3689[_0x7995('0x3e')]:_0x548e90[_0x7995('0x3a')];if(!_0x45d8a2['query']['hasOwnProperty'](_0x7995('0x40'))){_0x4b3689[_0x7995('0x25')]=qs[_0x7995('0x25')](_0x45d8a2['query'][_0x7995('0x25')]);_0x4b3689[_0x7995('0x41')]=qs[_0x7995('0x41')](_0x45d8a2[_0x7995('0x3b')][_0x7995('0x41')]);}_0x4b3689[_0x7995('0x42')]=qs[_0x7995('0x43')](_0x45d8a2[_0x7995('0x3b')][_0x7995('0x43')]);_0x4b3689['where']=qs['filters'](_[_0x7995('0x46')](_0x45d8a2['query'],_0x548e90[_0x7995('0x45')]));_0x4b3689['where'][_0x7995('0xcc')]=_0xd0da6e['id'];if(_0x45d8a2[_0x7995('0x3b')][_0x7995('0x66')]){_0x4b3689['where']=_['merge'](_0x4b3689[_0x7995('0x44')],{'$or':_[_0x7995('0x58')](_0x4b3689[_0x7995('0x3e')],function(_0x13c279){var _0xc6d48c={};_0xc6d48c[_0x13c279]={'$like':'%'+_0x45d8a2[_0x7995('0x3b')][_0x7995('0x66')]+'%'};return _0xc6d48c;})});}_0x4b3689=_[_0x7995('0x8d')]({},_0x4b3689,_0x45d8a2[_0x7995('0xc7')]);return db[_0x7995('0xb5')][_0x7995('0x24')]({'where':_0x4b3689['where']})[_0x7995('0x2b')](function(_0xe43c99){_0x9bde3d[_0x7995('0x24')]=_0xe43c99;if(_0x45d8a2[_0x7995('0x3b')][_0x7995('0xd1')]){_0x4b3689['include']=[{'all':!![]}];}return db[_0x7995('0xb5')][_0x7995('0x9f')](_0x4b3689);})[_0x7995('0x2b')](function(_0x3946cb){_0x9bde3d[_0x7995('0xce')]=_0x3946cb;return _0x9bde3d;});}})[_0x7995('0x2b')](respondWithFilteredResult(_0x26ab59,_0x4b3689))[_0x7995('0x99')](handleError(_0x26ab59,null));};exports[_0x7995('0xd4')]=function(_0x2acd21,_0x547430,_0x5405ca){try{if(!_0x2acd21[_0x7995('0xa2')][_0x7995('0x68')]){throw new Error(_0x7995('0xd5'));}if(!_0x2acd21[_0x7995('0xa2')][_0x7995('0xd6')]){throw new Error('No\x20association\x20keys\x20specified!');}if(!_0x2acd21[_0x7995('0xa2')][_0x7995('0xd7')]){throw new Error(_0x7995('0xd8'));}if(!_0x2acd21[_0x7995('0xa2')][_0x7995('0xd9')]){throw new Error(_0x7995('0xda'));}var _0x34692c=_0x2acd21[_0x7995('0xa2')][_0x7995('0xd6')]['split'](',');var _0x4f7c20=_0x2acd21[_0x7995('0xa2')][_0x7995('0xd7')][_0x7995('0x57')](',');if(!_0x34692c[_0x7995('0x32')]||!_0x4f7c20[_0x7995('0x32')]||_0x34692c[_0x7995('0x32')]!==_0x4f7c20[_0x7995('0x32')]){throw new Error(_0x7995('0xdb'));}_0x2acd21['body']['fields']=_[_0x7995('0xdc')](_0x34692c,_0x4f7c20);if(!_0x2acd21[_0x7995('0xa2')][_0x7995('0x3d')][_0x7995('0xc5')]){throw new Error('No\x20phone\x20column\x20specified');}if(!_0x2acd21['body'][_0x7995('0x3d')][_0x7995('0xdd')]){throw new Error(_0x7995('0xde'));}var _0x1522c4=path[_0x7995('0xa4')](config[_0x7995('0xdf')],_0x7995('0xe0'),_0x2acd21[_0x7995('0xe1')][_0x7995('0xe2')]);fs[_0x7995('0xe3')](_0x1522c4,parseInt(_0x7995('0xe4'),0x8));var _0x3c62ad=require('child_process')['fork'](path[_0x7995('0xa4')](__dirname,_0x7995('0xe5')),[_0x1522c4,_0x2acd21[_0x7995('0xa2')][_0x7995('0xd6')],_0x2acd21['body'][_0x7995('0xd7')],_0x2acd21['body'][_0x7995('0x68')],_0x2acd21[_0x7995('0xa2')][_0x7995('0xe6')],_0x2acd21[_0x7995('0xa2')][_0x7995('0xb8')],_0x2acd21[_0x7995('0xa2')]['socket_timestamp']]);return _0x547430[_0x7995('0x21')](0xc8)[_0x7995('0x23')]({'message':_0x7995('0xe7'),'pid':_0x3c62ad[_0x7995('0xe8')]});}catch(_0x5edf32){return _0x547430['status'](0x1f4)[_0x7995('0xe9')](_0x5edf32);}};exports[_0x7995('0xea')]=function(_0x518d4e,_0x1cda2e,_0x4bb32b){var _0x2958e9=fs[_0x7995('0xeb')](_0x518d4e[_0x7995('0xe1')]['path']);Papa[_0x7995('0xec')](_0x2958e9,{'header':!![],'skipEmptyLines':!![],'preview':0x1,'complete':function(_0x1142fe){return _0x1cda2e[_0x7995('0x21')](0xc8)['json']({'file':_0x518d4e[_0x7995('0xe1')],'fields':_0x1142fe[_0x7995('0xed')][_0x7995('0x3d')]});}});};exports[_0x7995('0xee')]=function(_0x437ee2,_0x46f341,_0x1f6c3e){return db[_0x7995('0x5c')][_0x7995('0x9f')]({'raw':!![],'attributes':['id'],'where':{'role':'agent'}})[_0x7995('0x2b')](function(_0x16aaf9){var _0x191da7=![];if(!_0x437ee2[_0x7995('0xa2')]['ListId']){throw new Error(_0x7995('0xd5'));}if(!_0x437ee2[_0x7995('0xa2')][_0x7995('0xef')][_0x7995('0xc5')]){throw new Error('No\x20phone\x20column\x20specified');}if(!_0x437ee2[_0x7995('0xa2')][_0x7995('0xef')][_0x7995('0xdd')]){throw new Error(_0x7995('0xde'));}if(!_0x437ee2[_0x7995('0xa2')][_0x7995('0xd9')]){throw new Error(_0x7995('0xda'));}var _0x5e3421=require(_0x7995('0xf0'))[_0x7995('0xf1')](path[_0x7995('0xa4')](__dirname,_0x7995('0xf2')),[_0x437ee2[_0x7995('0x9a')]['id'],JSON['stringify'](_0x437ee2[_0x7995('0xa2')]),JSON['stringify'](_0x16aaf9)]);_0x5e3421['on'](_0x7995('0xf3'),function(_0x38aace){_0x191da7=!![];return _0x46f341[_0x7995('0x21')](0xc8)['json']({'message':'start\x20child\x20process\x20correctly!','pid':_0x5e3421['pid']});});_0x5e3421['on'](_0x7995('0xf4'),function(_0x1763aa){if(_0x1763aa&&!_0x191da7){return _0x46f341[_0x7995('0x21')](0x1f4)[_0x7995('0x23')]({'message':_0x7995('0xf5'),'pid':_0x5e3421[_0x7995('0xe8')]});}});})['catch'](handleError(_0x46f341,null));};exports[_0x7995('0xf6')]=function(_0x37860d,_0x37539a){var _0x3bb0db=['mail',_0x7995('0xf7'),_0x7995('0xf8'),'openchannel',_0x7995('0xf9'),'whatsapp',_0x7995('0xfa')];var _0x45df6d={'offset':0x0,'order':qs['sort']('-createdAt')},_0x3e7779={'count':0x0,'rows':[]};Promise[_0x7995('0x83')]()[_0x7995('0x2b')](function(){if(_0x37860d[_0x7995('0x3b')][_0x7995('0xfb')]){if(!_[_0x7995('0xfc')](_0x3bb0db,_0x37860d[_0x7995('0x3b')][_0x7995('0xfb')][_0x7995('0xfd')]())){throw new Error(_0x7995('0xfe'));}_0x3bb0db=[_0x37860d[_0x7995('0x3b')][_0x7995('0xfb')]['toLowerCase']()];}if(_0x37860d['query'][_0x7995('0xff')]){try{var _0xa129d3=JSON[_0x7995('0xec')](_0x37860d[_0x7995('0x3b')]['range']);if(!moment(_0xa129d3['from'])[_0x7995('0x100')]()){throw new Error(_0x7995('0x101'));}if(!moment(_0xa129d3['to'])['isValid']()){throw new Error('Invalid\x20date\x20for\x20range\x20to\x20filter');}}catch(_0x952d6c){throw new Error(_0x7995('0x102'));}}if(!_0x37860d[_0x7995('0x3b')][_0x7995('0x3f')](_0x7995('0x40'))){_0x45df6d['limit']=qs[_0x7995('0x25')](_0x37860d[_0x7995('0x3b')]['limit']||0xa);_0x45df6d[_0x7995('0x41')]=qs[_0x7995('0x41')](_0x37860d[_0x7995('0x3b')]['offset']);}var _0x6b65e8=_0x3bb0db[_0x7995('0x58')](function(_0x1fb4c3){if(_0x1fb4c3===_0x7995('0xfa')){var _0x113e03={'attributes':['id','uniqueid','type',_0x7995('0x103'),'destination',_0x7995('0x104'),'starttime',_0x7995('0x105'),_0x7995('0x106'),_0x7995('0x107'),'createdAt','userDisposition','userSecondDisposition',_0x7995('0x108')],'where':{'ContactId':_0x37860d[_0x7995('0x9a')]['id']},'include':[{'model':db[_0x7995('0x5c')],'as':'User','attributes':['id',_0x7995('0x2f'),_0x7995('0x109'),'alias']}],'order':[[_0x7995('0x10a'),_0x7995('0x7f')]]};if(_0x37860d[_0x7995('0x3b')][_0x7995('0xff')]){_0x113e03[_0x7995('0x44')]['createdAt']={'$gte':_0xa129d3['from'],'$lte':_0xa129d3['to']};}return db[_0x7995('0x10b')][_0x7995('0x10c')](_0x113e03)[_0x7995('0x2b')](function(_0xc0f1fa){_0x3e7779[_0x7995('0x24')]+=_0xc0f1fa[_0x7995('0x24')];return _[_0x7995('0x58')](_0xc0f1fa[_0x7995('0xce')],function(_0xbc3cbd){var _0xe95666=_0xbc3cbd['get']({'plain':!![]});_0xe95666[_0x7995('0xfb')]=_0x1fb4c3;if(_0xe95666[_0x7995('0x5c')]){_0xe95666[_0x7995('0x5c')]={'id':_0xe95666[_0x7995('0x5c')]['id'],'name':_0xe95666[_0x7995('0x5c')][_0x7995('0x2f')],'fullname':_0xe95666[_0x7995('0x5c')]['fullname'],'alias':_0xe95666['User'][_0x7995('0xa0')]};}return _0xe95666;});});}else{var _0x2aec8d=_[_0x7995('0x10d')](_0x1fb4c3)+(_0x1fb4c3===_0x7995('0xf7')?'Website':'Account');var _0x4b477a={'attributes':['id',_0x7995('0x10e'),_0x7995('0x10f'),'createdAt',_0x7995('0x107'),_0x7995('0x110'),_0x7995('0x111'),_0x7995('0x112'),_0x7995('0x113'),_0x2aec8d+'Id'],'where':{'ContactId':_0x37860d[_0x7995('0x9a')]['id']},'include':[{'model':db[_0x2aec8d],'as':_0x7995('0x114'),'attributes':['id',_0x7995('0x2f'),'key']},{'model':db[_0x7995('0x5c')],'as':_0x7995('0x115'),'attributes':['id',_0x7995('0x2f'),'fullname']},{'model':db[_0x7995('0x56')],'as':'Tags','attributes':['id','name','color'],'through':{'attributes':[]}}],'order':[['createdAt',_0x7995('0x7f')]]};if(_0x37860d['query'][_0x7995('0xff')]){_0x4b477a[_0x7995('0x44')]['createdAt']={'$gte':_0xa129d3[_0x7995('0x4a')],'$lte':_0xa129d3['to']};}switch(_0x1fb4c3){case _0x7995('0xf7'):_0x4b477a[_0x7995('0x3e')][_0x7995('0x34')]('browserName',_0x7995('0x116'),'customerPort',_0x7995('0x117'),_0x7995('0x118'),_0x7995('0x119'),_0x7995('0x11a'),_0x7995('0x11b'),_0x7995('0x11c'));break;case _0x7995('0x11d'):_0x4b477a[_0x7995('0x3e')][_0x7995('0x34')](_0x7995('0x11e'),'substatus');break;case _0x7995('0x11f'):_0x4b477a[_0x7995('0x3e')]['push'](_0x7995('0x120'),_0x7995('0x121'));break;}return db[_[_0x7995('0x10d')](_0x1fb4c3)+_0x7995('0x122')][_0x7995('0x10c')](_0x4b477a)[_0x7995('0x2b')](function(_0x5dc3ed){_0x3e7779[_0x7995('0x24')]+=_0x5dc3ed['count'];return _[_0x7995('0x58')](_0x5dc3ed[_0x7995('0xce')],function(_0x1e18dd){var _0xb79b0b=_0x1e18dd[_0x7995('0xa3')]({'plain':!![]});_0xb79b0b[_0x7995('0xfb')]=_0x1fb4c3;if(_0xb79b0b['Owner']){_0xb79b0b[_0x7995('0x115')]={'id':_0xb79b0b[_0x7995('0x115')]['id'],'name':_0xb79b0b[_0x7995('0x115')]['name'],'fullname':_0xb79b0b[_0x7995('0x115')][_0x7995('0x109')]};}return _0xb79b0b;});});}});return Promise[_0x7995('0x123')](_0x6b65e8);})[_0x7995('0x2b')](function(_0x15fac9){return _(_0x15fac9)[_0x7995('0x124')]()[_0x7995('0x125')](_0x7995('0x10a'))[_0x7995('0x126')]()[_0x7995('0x5f')]();})[_0x7995('0x2b')](function(_0x5c3b98){_0x3e7779[_0x7995('0xce')]=_0x45df6d[_0x7995('0x25')]?_0x5c3b98['slice'](_0x45df6d[_0x7995('0x41')],_0x45df6d[_0x7995('0x41')]+_0x45df6d[_0x7995('0x25')]):_0x5c3b98;return _0x3e7779;})[_0x7995('0x2b')](respondWithFilteredResult(_0x37539a,_0x45df6d))[_0x7995('0x99')](handleError(_0x37539a,null));};
\ No newline at end of file
+var _0x52d0=['query','user','CmContact','find','params','catch','tags','keys','startsWith','cf_','columnName','analytics','CmCustomField','displayName','alias','type','Custom\x20field\x20%s\x20not\x20found\x20on\x20cm_contacts\x20table','hasOwnProperty','merge','body','from','length','get','mergeWith','isArray','join','info','[CmContact][merge]\x20to\x20%s\x20from\x20%s','CmHopper','[CmContact][merge][destroy][CmHopper],\x20%s','CmHopperBlack','[CmContact][merge][destroy][CmHopperBlack],\x20%s','update','ChatMessage','ChatOfflineMessage','MailMessage','MailInteraction','SmsMessage','FaxInteraction','FaxMessage','OpenchannelInteraction','OpenchannelMessage','CmContactHasItem','CmHopperFinal','ReportAgentPreview','ChatQueueReport','FaxQueueReport','MailQueueReport','OpenchannelQueueReport','SmsQueueReport','WhatsappInteraction','WhatsappMessage','WhatsappQueueReport','dialTimezone','isNil','timezones','additionalPhones','bulkCreate','duplicates','where','$or','push','ListId','findOrCreate','spread','contact','all','show','Tag','Tags','color','tag','Phones','ContactItemType','Phones.OrderBy','$and','map','format','cf_%d','utcOffset','omit','pickBy','table','cm_contacts','setFields','id\x20=\x20?','toParam','sequelize','text','values','phone','getTags','findOne','model','rawAttributes','filters','intersection','attributes','order','sort','pick','filter','setTags','ids','setAdditionalPhones','items','item_types','ItemTypeId','description','OrderBy','contact\x20phone\x20exists','PHONE','item','ItemType','literal','`ItemType`.OrderBy','ItemType.OrderBy','CmHopperAdditionalPhone','duplicateAdditionalPhones','fromContactId','toContactId','hopperId','fields','nolimit','ContactId','options','includeAll','include','rows','getHopperHistories','CmHopperHistory','getHopperFinals','getJscriptySessions','JscriptySessionReport','uploadCsv','No\x20ListId\x20specified','binding_keys','No\x20association\x20keys\x20specified!','No\x20association\x20values\x20specified!','socket_timestamp','Unable\x20to\x20synchronize\x20socket,\x20no\x20timestamp\x20passed','split','binding_values','Incorrect\x20binding\x20parameters\x20passed!','No\x20phone\x20column\x20specified','No\x20firstName\x20column\x20specified','root','server/files/tmp','filename','0777','child_process','../../components/import/cm/csv','CompanyId','File\x20uploaded\x20correctly!','pid','send','upload','file','parse','meta','import','User','agent','binding','firstName','fork','../../components/import/cm/csv2','stringify','message','start\x20child\x20process\x20correctly!','exit','error\x20child\x20process','importUpdates','../../components/import/cm/csvUpdates','getJourney','chat','sms','openchannel','fax','whatsapp','voice','-createdAt','resolve','includes','channel','toLowerCase','Invalid\x20channel','isValid','Invalid\x20date\x20for\x20range\x20from\x20filter','Invalid\x20date\x20for\x20range\x20to\x20filter','uniqueid','source','callerid','starttime','endtime','duration','note','userDisposition','userSecondDisposition','userThirdDisposition','UserId','fullname','DESC','createdAt','VoiceCallReport','startCase','Website','closed','disposition','secondDisposition','key','Owner','customerIp','deviceModel','osName','ratingType','ratingValue','referer','mail','subject','substatus','externalUrl','threadId','Interaction','findAndCountAll','flatten','sortBy','reverse','value','moment','util','path','lodash','squel','ioredis','../../components/contacts','../../components/parsers/qs','api','../../config/environment','../../config/environment/shared','../../mysqldb','redis','defaults','localhost','socket.io-emitter','./cmContact.socket','register','status','json','offset','limit','undefined','count','set','Content-Range','then','destroy','end','stack','name','describe','getOptions','findAll'];(function(_0x5d25ed,_0x3004e0){var _0x1cd0b7=function(_0x21a0b4){while(--_0x21a0b4){_0x5d25ed['push'](_0x5d25ed['shift']());}};_0x1cd0b7(++_0x3004e0);}(_0x52d0,0x1ec));var _0x052d=function(_0x326017,_0x5205fd){_0x326017=_0x326017-0x0;var _0x5e43b1=_0x52d0[_0x326017];return _0x5e43b1;};'use strict';var moment=require(_0x052d('0x0'));var BPromise=require('bluebird');var util=require(_0x052d('0x1'));var path=require(_0x052d('0x2'));var fs=require('fs');var _=require(_0x052d('0x3'));var squel=require(_0x052d('0x4'));var Papa=require('papaparse');var Redis=require(_0x052d('0x5'));var contacts=require(_0x052d('0x6'));var qs=require(_0x052d('0x7'));var logger=require('../../config/logger')(_0x052d('0x8'));var config=require(_0x052d('0x9'));var shared=require(_0x052d('0xa'));var db=require(_0x052d('0xb'))['db'];config[_0x052d('0xc')]=_[_0x052d('0xd')](config[_0x052d('0xc')],{'host':_0x052d('0xe'),'port':0x18eb});var socket=require(_0x052d('0xf'))(new Redis(config['redis']));require(_0x052d('0x10'))[_0x052d('0x11')](socket);function respondWithResult(_0x23d3dd,_0x1e4f6a){_0x1e4f6a=_0x1e4f6a||0xc8;return function(_0x1122cf){if(_0x1122cf){return _0x23d3dd[_0x052d('0x12')](_0x1e4f6a)[_0x052d('0x13')](_0x1122cf);}};}function respondWithFilteredResult(_0x3d64e5,_0x411f89){return function(_0x51ff7e){if(_0x51ff7e){var _0x5e3778=typeof _0x411f89[_0x052d('0x14')]==='undefined'&&typeof _0x411f89[_0x052d('0x15')]===_0x052d('0x16');var _0x3d4cd8=_0x51ff7e[_0x052d('0x17')];var _0x1b01c9=_0x5e3778?0x0:_0x411f89['offset'];var _0x47546a=_0x5e3778?_0x51ff7e[_0x052d('0x17')]:_0x411f89[_0x052d('0x14')]+_0x411f89['limit'];var _0x377326;if(_0x47546a>=_0x3d4cd8){_0x47546a=_0x3d4cd8;_0x377326=0xc8;}else{_0x377326=0xce;}_0x3d64e5[_0x052d('0x12')](_0x377326);return _0x3d64e5[_0x052d('0x18')](_0x052d('0x19'),_0x1b01c9+'-'+_0x47546a+'/'+_0x3d4cd8)[_0x052d('0x13')](_0x51ff7e);}return null;};}function saveUpdates(_0x125a07){return function(_0x28e7bd){if(_0x28e7bd){return _0x28e7bd['update'](_0x125a07)[_0x052d('0x1a')](function(_0x4631f8){return _0x4631f8;});}return null;};}function removeEntity(_0x2df059){return function(_0x2a73df){if(_0x2a73df){return _0x2a73df[_0x052d('0x1b')]()[_0x052d('0x1a')](function(){_0x2df059[_0x052d('0x12')](0xcc)[_0x052d('0x1c')]();});}};}function handleEntityNotFound(_0x3d1cc6){return function(_0x5c3929){if(!_0x5c3929){_0x3d1cc6['sendStatus'](0x194);}return _0x5c3929;};}function handleError(_0x107847,_0x4f2ee0){_0x4f2ee0=_0x4f2ee0||0x1f4;return function(_0x2b853c){logger['error'](_0x2b853c[_0x052d('0x1d')]);if(_0x2b853c['name']){delete _0x2b853c[_0x052d('0x1e')];}_0x107847[_0x052d('0x12')](_0x4f2ee0)['send'](_0x2b853c);};}exports['index']=function(_0x155f36,_0x1b2f85){var _0x44b4e0={};return contacts[_0x052d('0x1f')]()['then'](function(_0x3406b3){_0x44b4e0=qs[_0x052d('0x20')](_0x3406b3,_0x155f36);return contacts[_0x052d('0x21')](_0x155f36[_0x052d('0x22')],_0x155f36[_0x052d('0x23')],_0x44b4e0,_0x3406b3);})[_0x052d('0x1a')](respondWithFilteredResult(_0x1b2f85,_0x44b4e0))['catch'](handleError(_0x1b2f85,null));};exports[_0x052d('0x1b')]=function(_0x770543,_0x219fd3){return db[_0x052d('0x24')][_0x052d('0x25')]({'where':{'id':_0x770543[_0x052d('0x26')]['id']}})[_0x052d('0x1a')](handleEntityNotFound(_0x219fd3,null))['then'](removeEntity(_0x219fd3,null))[_0x052d('0x27')](handleError(_0x219fd3,null));};exports[_0x052d('0x1f')]=function(_0x2137ea,_0x1bf018){return db[_0x052d('0x24')][_0x052d('0x1f')]()['then'](function(_0x16ee67){delete _0x16ee67[_0x052d('0x28')];for(var _0x3e6fb6=0x0;_0x3e6fb6<Object['keys'](_0x16ee67)['length'];_0x3e6fb6++){var _0x4dd7d3=Object[_0x052d('0x29')](_0x16ee67)[_0x3e6fb6];if(!_[_0x052d('0x2a')](_0x4dd7d3,_0x052d('0x2b'))){_0x16ee67[_0x4dd7d3][_0x052d('0x2c')]=_0x4dd7d3;_0x16ee67[_0x4dd7d3]['displayName']=_0x4dd7d3;}}return _0x16ee67;})[_0x052d('0x1a')](function(_0x4d343a){var _0x449701={'where':Boolean(_0x2137ea[_0x052d('0x22')][_0x052d('0x2d')])===!![]?undefined:{'$or':[{'ListId':_0x2137ea[_0x052d('0x22')]['id']},{'ListId':null}]},'raw':!![]};return db[_0x052d('0x2e')][_0x052d('0x21')](_0x449701)[_0x052d('0x1a')](function(_0x494be3){for(var _0x593378=0x0;_0x593378<_0x494be3['length'];_0x593378++){var _0x542b7f=_0x052d('0x2b')+_0x494be3[_0x593378]['id'];if(_0x4d343a[_0x542b7f]){_0x4d343a[_0x542b7f][_0x052d('0x2c')]=_0x542b7f;_0x4d343a[_0x542b7f][_0x052d('0x2f')]=_0x494be3[_0x593378][_0x052d('0x30')];_0x4d343a[_0x542b7f]['custom']={'type':_0x494be3[_0x593378][_0x052d('0x31')],'values':_0x494be3[_0x593378]['values']};}else{logger['info'](_0x052d('0x32'),_0x542b7f);}}Object[_0x052d('0x29')](_0x4d343a)['forEach'](function(_0x2fc0ec){if(!_0x4d343a[_0x2fc0ec][_0x052d('0x33')](_0x052d('0x2c'))){delete _0x4d343a[_0x2fc0ec];}});return _0x4d343a;});})[_0x052d('0x1a')](respondWithResult(_0x1bf018,null))[_0x052d('0x27')](handleError(_0x1bf018,null));};exports[_0x052d('0x34')]=function(_0x463a66,_0x20d684){var _0x376f3e;var _0x370f14;var _0x2bbae1;if(_0x463a66['body']['id']){delete _0x463a66[_0x052d('0x35')]['id'];}return db[_0x052d('0x24')][_0x052d('0x21')]({'where':{'id':[_0x463a66[_0x052d('0x35')]['to'],_0x463a66[_0x052d('0x35')][_0x052d('0x36')]]}})[_0x052d('0x1a')](function(_0x911227){if(_0x911227){if(_0x911227[_0x052d('0x37')]!==0x2){return null;}_0x911227[0x0]=_0x911227[0x0]['get']({'plain':!![]});_0x911227[0x1]=_0x911227[0x1][_0x052d('0x38')]({'plain':!![]});delete _0x911227[0x0]['id'];delete _0x911227[0x1]['id'];return _[_0x052d('0x39')](_0x911227[0x0],_0x911227[0x1],function(_0x3efe3e,_0x584e2c){if(Array[_0x052d('0x3a')](_0x584e2c)&&!_0x584e2c['length']){return _0x3efe3e;}else if(!_0x584e2c){return _0x3efe3e;}});}})[_0x052d('0x1a')](handleEntityNotFound(_0x20d684,null))[_0x052d('0x1a')](function(_0x321c48){if(_0x321c48){if(_0x321c48['tags']&&_[_0x052d('0x3a')](_0x321c48[_0x052d('0x28')])){_0x321c48[_0x052d('0x28')]=_0x321c48['tags'][_0x052d('0x3b')]();}logger[_0x052d('0x3c')](_0x052d('0x3d'),_0x463a66[_0x052d('0x35')]['to'],_0x463a66[_0x052d('0x35')][_0x052d('0x36')]);return db[_0x052d('0x3e')][_0x052d('0x1b')]({'where':{'ContactId':[_0x463a66['body']['to'],_0x463a66[_0x052d('0x35')][_0x052d('0x36')]]}})['then'](function(_0x4ea7ce){logger[_0x052d('0x3c')](_0x052d('0x3f'),_0x4ea7ce);return db[_0x052d('0x40')][_0x052d('0x1b')]({'where':{'ContactId':[_0x463a66['body']['to'],_0x463a66[_0x052d('0x35')][_0x052d('0x36')]]}})[_0x052d('0x1a')](function(_0x48322a){logger[_0x052d('0x3c')](_0x052d('0x41'),_0x48322a);return db[_0x052d('0x24')]['create'](_0x321c48);});});}})[_0x052d('0x1a')](function(_0x3d846d){if(_0x3d846d){_0x376f3e=_0x3d846d;_0x370f14={'ContactId':_0x376f3e['id']};_0x2bbae1={'where':{'ContactId':[_0x463a66[_0x052d('0x35')]['to'],_0x463a66[_0x052d('0x35')][_0x052d('0x36')]]}};return db['ChatInteraction'][_0x052d('0x42')](_0x370f14,_0x2bbae1);}})['then'](function(){if(_0x376f3e){return db[_0x052d('0x43')][_0x052d('0x42')](_0x370f14,_0x2bbae1);}})[_0x052d('0x1a')](function(){if(_0x376f3e){return db[_0x052d('0x44')][_0x052d('0x42')](_0x370f14,_0x2bbae1);}})[_0x052d('0x1a')](function(){if(_0x376f3e){return db['MailInteraction'][_0x052d('0x42')](_0x370f14,_0x2bbae1);}})[_0x052d('0x1a')](function(){if(_0x376f3e){return db[_0x052d('0x45')][_0x052d('0x42')](_0x370f14,_0x2bbae1);}})['then'](function(){if(_0x376f3e){return db[_0x052d('0x46')][_0x052d('0x42')](_0x370f14,_0x2bbae1);}})[_0x052d('0x1a')](function(){if(_0x376f3e){return db[_0x052d('0x45')][_0x052d('0x42')](_0x370f14,_0x2bbae1);}})[_0x052d('0x1a')](function(){if(_0x376f3e){return db['SmsInteraction'][_0x052d('0x42')](_0x370f14,_0x2bbae1);}})[_0x052d('0x1a')](function(){if(_0x376f3e){return db[_0x052d('0x47')][_0x052d('0x42')](_0x370f14,_0x2bbae1);}})['then'](function(){if(_0x376f3e){return db[_0x052d('0x48')][_0x052d('0x42')](_0x370f14,_0x2bbae1);}})[_0x052d('0x1a')](function(){if(_0x376f3e){return db[_0x052d('0x49')][_0x052d('0x42')](_0x370f14,_0x2bbae1);}})[_0x052d('0x1a')](function(){if(_0x376f3e){return db[_0x052d('0x4a')]['update'](_0x370f14,_0x2bbae1);}})[_0x052d('0x1a')](function(){if(_0x376f3e){return db[_0x052d('0x4b')][_0x052d('0x42')](_0x370f14,_0x2bbae1);}})[_0x052d('0x1a')](function(){if(_0x376f3e){return db[_0x052d('0x4c')][_0x052d('0x42')]({'CmContactId':_0x376f3e['id']},{'where':{'CmContactId':[_0x463a66[_0x052d('0x35')]['to'],_0x463a66['body'][_0x052d('0x36')]]}});}})[_0x052d('0x1a')](function(){if(_0x376f3e){return db[_0x052d('0x4d')][_0x052d('0x42')](_0x370f14,_0x2bbae1);}})[_0x052d('0x1a')](function(){if(_0x376f3e){return db['CmHopperHistory'][_0x052d('0x42')](_0x370f14,_0x2bbae1);}})[_0x052d('0x1a')](function(){if(_0x376f3e){return db[_0x052d('0x4e')][_0x052d('0x42')](_0x370f14,_0x2bbae1);}})[_0x052d('0x1a')](function(){if(_0x376f3e){return db['VoiceCallReport'][_0x052d('0x42')](_0x370f14,_0x2bbae1);}})[_0x052d('0x1a')](function(){if(_0x376f3e){return db[_0x052d('0x4f')][_0x052d('0x42')](_0x370f14,_0x2bbae1);}})['then'](function(){if(_0x376f3e){return db[_0x052d('0x50')]['update'](_0x370f14,_0x2bbae1);}})[_0x052d('0x1a')](function(){if(_0x376f3e){return db[_0x052d('0x51')][_0x052d('0x42')](_0x370f14,_0x2bbae1);}})[_0x052d('0x1a')](function(){if(_0x376f3e){return db[_0x052d('0x52')][_0x052d('0x42')](_0x370f14,_0x2bbae1);}})[_0x052d('0x1a')](function(){if(_0x376f3e){return db[_0x052d('0x53')][_0x052d('0x42')](_0x370f14,_0x2bbae1);}})[_0x052d('0x1a')](function(){if(_0x376f3e){return db['JscriptySessionReport'][_0x052d('0x42')](_0x370f14,_0x2bbae1);}})[_0x052d('0x1a')](function(){if(_0x376f3e){return db[_0x052d('0x54')][_0x052d('0x42')](_0x370f14,_0x2bbae1);}})['then'](function(){if(_0x376f3e){return db[_0x052d('0x55')][_0x052d('0x42')](_0x370f14,_0x2bbae1);}})[_0x052d('0x1a')](function(){if(_0x376f3e){return db[_0x052d('0x56')][_0x052d('0x42')](_0x370f14,_0x2bbae1);}})[_0x052d('0x1a')](function(){if(_0x376f3e){return db[_0x052d('0x24')][_0x052d('0x1b')]({'where':{'id':[_0x463a66['body']['to'],_0x463a66[_0x052d('0x35')][_0x052d('0x36')]]}});}})['then'](function(){if(_0x376f3e){return _0x376f3e;}})['then'](respondWithResult(_0x20d684,null))[_0x052d('0x27')](handleError(_0x20d684,null));};exports['create']=function(_0xa42f71,_0x172036){return db[_0x052d('0x24')][_0x052d('0x1f')]()[_0x052d('0x1a')](function(_0x27f004){if(_0xa42f71[_0x052d('0x35')]['tags']&&_['isArray'](_0xa42f71[_0x052d('0x35')][_0x052d('0x28')])){if(_0xa42f71[_0x052d('0x35')][_0x052d('0x28')][_0x052d('0x37')]){_0xa42f71[_0x052d('0x35')][_0x052d('0x28')]=_0xa42f71[_0x052d('0x35')][_0x052d('0x28')]['join'](';')+';';}else{_0xa42f71[_0x052d('0x35')]['tags']=null;}}else{_0xa42f71[_0x052d('0x35')][_0x052d('0x28')]=null;}if(!_['isNil'](_0xa42f71[_0x052d('0x35')][_0x052d('0x57')])){var _0x51fc29=_0xa42f71[_0x052d('0x35')][_0x052d('0x57')];if(!_[_0x052d('0x58')](shared[_0x052d('0x59')][_0x51fc29]))_0xa42f71['body']['utcOffset']=shared[_0x052d('0x59')][_0x51fc29]['utcOffset'];}return db[_0x052d('0x24')]['create'](_0xa42f71[_0x052d('0x35')],{'fields':_[_0x052d('0x29')](_0x27f004),'raw':!![]});})[_0x052d('0x1a')](function(_0x5ac198){if(_0xa42f71[_0x052d('0x35')][_0x052d('0x5a')]){return insertAdditionalPhones(_0x5ac198,_0xa42f71['body'][_0x052d('0x5a')]);}else{return _0x5ac198;}})[_0x052d('0x1a')](respondWithResult(_0x172036,0xc9))[_0x052d('0x27')](handleError(_0x172036,null));};exports[_0x052d('0x5b')]=function(_0x29cf40,_0x4a3745){var _0x26a5ab=0x0;var _0x145fd1=0x0;var _0x535e70=0x0;var _0x4537fd=[];return db[_0x052d('0x24')][_0x052d('0x1f')]()[_0x052d('0x1a')](function(_0x4aba40){return BPromise['each'](_0x29cf40[_0x052d('0x35')],function(_0x3b3d49){var _0xb6e1a2={'where':{'$or':[]},'defaults':_0x3b3d49,'fields':_[_0x052d('0x29')](_0x4aba40),'raw':!![]};if(_0x3b3d49['duplicates']){for(var _0x5a417c=0x0;_0x5a417c<_0x3b3d49['duplicates'][_0x052d('0x37')];_0x5a417c++){var _0x290e7a={};_0x290e7a[_0x3b3d49[_0x052d('0x5c')][_0x5a417c]]=_0x3b3d49[_0x3b3d49[_0x052d('0x5c')][_0x5a417c]];_0xb6e1a2[_0x052d('0x5d')][_0x052d('0x5e')][_0x052d('0x5f')](_0x290e7a);}_0xb6e1a2['where'][_0x052d('0x60')]=_0x3b3d49[_0x052d('0x60')];}return db[_0x052d('0x24')][_0x052d('0x61')](_0xb6e1a2)[_0x052d('0x62')](function(_0x53a924,_0x2d1daf){if(_0x2d1daf){if(_0x3b3d49['hasOwnProperty'](_0x052d('0x5a'))){_0x4537fd[_0x052d('0x5f')]({'contact':_0x53a924,'additionalPhones':_0x3b3d49[_0x052d('0x5a')]});}_0x26a5ab++;}else{_0x535e70++;}})[_0x052d('0x27')](function(){_0x145fd1++;});});})[_0x052d('0x1a')](function(_0x3bc0a0){if(_0x3bc0a0){if(_0x4537fd['length']>0x0){return new Promise(function(_0x4f6df5){var _0x38f520=[];for(var _0x947785=0x0;_0x947785<_0x4537fd[_0x052d('0x37')];_0x947785++){_0x38f520[_0x052d('0x5f')](insertAdditionalPhones(_0x4537fd[_0x947785][_0x052d('0x63')],_0x4537fd[_0x947785][_0x052d('0x5a')]));}Promise[_0x052d('0x64')](_0x38f520)['then'](function(){_0x4f6df5(0x1);});})[_0x052d('0x1a')](function(){return{'success':_0x26a5ab,'failure':_0x145fd1,'duplicates':_0x535e70};});}else{return{'success':_0x26a5ab,'failure':_0x145fd1,'duplicates':_0x535e70};}}})[_0x052d('0x1a')](respondWithResult(_0x4a3745,0xc9))['catch'](handleError(_0x4a3745,null));};exports[_0x052d('0x65')]=function(_0x181547,_0x1431ab){var _0x41ebce;return db[_0x052d('0x24')]['describe']()[_0x052d('0x1a')](function(_0x278558){return db['CmContact'][_0x052d('0x25')]({'where':{'id':_0x181547[_0x052d('0x26')]['id']},'include':[{'model':db[_0x052d('0x66')],'as':_0x052d('0x67'),'attributes':['id',_0x052d('0x1e'),_0x052d('0x68')],'required':_0x181547[_0x052d('0x22')][_0x052d('0x69')]?!![]:![]},{'model':db[_0x052d('0x4c')],'as':_0x052d('0x6a'),'where':{'CmContactId':_0x181547['params']['id']},'required':![],'include':[{'model':db[_0x052d('0x6b')],'as':'ItemType'}]}],'order':[db['sequelize']['literal'](_0x052d('0x6c'))],'attributes':_['keys'](_0x278558)});})[_0x052d('0x1a')](function(_0x143dcf){if(!_[_0x052d('0x58')](_0x143dcf)){_0x41ebce=_0x143dcf['get']({'plain':!![]});var _0x2ce831={'where':{'$and':[{'ListId':{'$ne':null}}]}};if(_0x143dcf&&_0x143dcf[_0x052d('0x60')]){if(_0x143dcf[_0x052d('0x60')]){_0x2ce831['where'][_0x052d('0x6d')]['push']({'ListId':{'$ne':_0x143dcf[_0x052d('0x60')]}});}}return db[_0x052d('0x2e')][_0x052d('0x21')](_0x2ce831);}})[_0x052d('0x1a')](function(_0x4bbc26){if(!_[_0x052d('0x58')](_0x4bbc26)){return _['omit'](_0x41ebce,_[_0x052d('0x6e')](_0x4bbc26,function(_0x4246b4){return util[_0x052d('0x6f')](_0x052d('0x70'),_0x4246b4['id']);}));}})[_0x052d('0x1a')](handleEntityNotFound(_0x1431ab,null))[_0x052d('0x1a')](respondWithResult(_0x1431ab,null))['catch'](handleError(_0x1431ab,null));};exports[_0x052d('0x42')]=function(_0x59f474,_0xc14636){var _0x5b2459;if(_0x59f474['body']['id']){delete _0x59f474[_0x052d('0x35')]['id'];}if(!_[_0x052d('0x58')](_0x59f474[_0x052d('0x35')][_0x052d('0x57')])){var _0x56406c=_0x59f474[_0x052d('0x35')][_0x052d('0x57')];if(!_[_0x052d('0x58')](shared[_0x052d('0x59')][_0x56406c]))_0x59f474['body']['utcOffset']=shared[_0x052d('0x59')][_0x56406c][_0x052d('0x71')];}return db[_0x052d('0x24')][_0x052d('0x25')]({'where':{'id':_0x59f474['params']['id']}})['then'](handleEntityNotFound(_0xc14636,null))[_0x052d('0x1a')](saveUpdates(_0x59f474[_0x052d('0x35')],null))['then'](function(_0x2af7f9){_0x5b2459=_0x2af7f9;var _0x23889b={'where':{'$and':[{'ListId':{'$ne':null}}]}};if(_0x2af7f9&&_0x2af7f9['ListId']){if(_0x2af7f9[_0x052d('0x60')]){_0x23889b[_0x052d('0x5d')][_0x052d('0x6d')][_0x052d('0x5f')]({'ListId':{'$ne':_0x2af7f9[_0x052d('0x60')]}});}}return db[_0x052d('0x2e')][_0x052d('0x21')](_0x23889b);})[_0x052d('0x1a')](function(_0x4c8eca){if(_0x4c8eca){return _[_0x052d('0x72')](_[_0x052d('0x73')](_0x59f474['body'],function(_0x4108c0,_0x56aeb2){return _[_0x052d('0x2a')](_0x56aeb2,_0x052d('0x2b'));}),_[_0x052d('0x6e')](_0x4c8eca,function(_0x3c8ee0){return util['format'](_0x052d('0x70'),_0x3c8ee0['id']);}));}})['then'](function(_0x306046){if(_0x306046&&!_['isEmpty'](_0x306046)){var _0x4b7174=squel['update']()[_0x052d('0x74')](_0x052d('0x75'))[_0x052d('0x76')](_0x306046)[_0x052d('0x5d')](_0x052d('0x77'),_0x59f474['params']['id'])[_0x052d('0x78')]();return db[_0x052d('0x79')][_0x052d('0x22')](_0x4b7174[_0x052d('0x7a')],{'replacements':_0x4b7174[_0x052d('0x7b')]});}})['then'](function(){if(_0x59f474[_0x052d('0x35')][_0x052d('0x7c')]&&_0x5b2459){return db[_0x052d('0x3e')][_0x052d('0x42')]({'phone':_0x59f474[_0x052d('0x35')][_0x052d('0x7c')],'OrderBy':0x0},{'where':{'ContactId':_0x5b2459['id']}});}})[_0x052d('0x1a')](function(){return _0x5b2459;})['then'](respondWithResult(_0xc14636,null))[_0x052d('0x27')](handleError(_0xc14636,null));};exports[_0x052d('0x7d')]=function(_0x3b3d1a,_0x18ccec){var _0x447b70={};var _0x226c81={};var _0x32e933;var _0x1c665c;return db[_0x052d('0x24')][_0x052d('0x7e')]({'where':{'id':_0x3b3d1a[_0x052d('0x26')]['id']}})[_0x052d('0x1a')](handleEntityNotFound(_0x18ccec,null))[_0x052d('0x1a')](function(_0x41bb50){if(_0x41bb50){_0x32e933=_0x41bb50;_0x226c81[_0x052d('0x7f')]=_[_0x052d('0x29')](db['Tag'][_0x052d('0x80')]);_0x226c81[_0x052d('0x22')]=_['keys'](_0x3b3d1a[_0x052d('0x22')]);_0x226c81[_0x052d('0x81')]=_[_0x052d('0x82')](_0x226c81[_0x052d('0x7f')],_0x226c81[_0x052d('0x22')]);_0x447b70[_0x052d('0x83')]=_[_0x052d('0x82')](_0x226c81[_0x052d('0x7f')],qs['fields'](_0x3b3d1a[_0x052d('0x22')]['fields']));_0x447b70[_0x052d('0x83')]=_0x447b70[_0x052d('0x83')][_0x052d('0x37')]?_0x447b70[_0x052d('0x83')]:_0x226c81[_0x052d('0x7f')];_0x447b70[_0x052d('0x84')]=qs[_0x052d('0x85')](_0x3b3d1a[_0x052d('0x22')][_0x052d('0x85')]);_0x447b70[_0x052d('0x5d')]=qs[_0x052d('0x81')](_[_0x052d('0x86')](_0x3b3d1a['query'],_0x226c81[_0x052d('0x81')]));if(_0x3b3d1a[_0x052d('0x22')][_0x052d('0x87')]){_0x447b70[_0x052d('0x5d')]=_[_0x052d('0x34')](_0x447b70['where'],{'$or':_['map'](_0x447b70[_0x052d('0x83')],function(_0x33c034){var _0x548140={};_0x548140[_0x33c034]={'$like':'%'+_0x3b3d1a[_0x052d('0x22')]['filter']+'%'};return _0x548140;})});}_0x447b70=_[_0x052d('0x34')]({},_0x447b70,_0x3b3d1a['options']);return _0x32e933[_0x052d('0x7d')](_0x447b70);}})[_0x052d('0x1a')](function(_0x3774f0){if(_0x3774f0){_0x1c665c=_0x3774f0[_0x052d('0x37')];if(!_0x3b3d1a[_0x052d('0x22')][_0x052d('0x33')]('nolimit')){_0x447b70[_0x052d('0x15')]=qs[_0x052d('0x15')](_0x3b3d1a[_0x052d('0x22')][_0x052d('0x15')]);_0x447b70['offset']=qs['offset'](_0x3b3d1a['query'][_0x052d('0x14')]);}return _0x32e933['getTags'](_0x447b70);}})[_0x052d('0x1a')](function(_0x205392){if(_0x205392){return _0x205392?{'count':_0x1c665c,'rows':_0x205392}:null;}})['then'](respondWithResult(_0x18ccec,null))['catch'](handleError(_0x18ccec,null));};exports[_0x052d('0x88')]=function(_0x4bbb63,_0x2db3af){if(_0x4bbb63['body']['id']){delete _0x4bbb63[_0x052d('0x35')]['id'];}return db['CmContact'][_0x052d('0x7e')]({'where':{'id':_0x4bbb63[_0x052d('0x26')]['id']}})[_0x052d('0x1a')](handleEntityNotFound(_0x2db3af,null))[_0x052d('0x1a')](function(_0xec1d69){if(_0xec1d69){return _0xec1d69[_0x052d('0x88')](_0x4bbb63['body'][_0x052d('0x89')]||[]);}return null;})['then'](respondWithResult(_0x2db3af,null))[_0x052d('0x27')](handleError(_0x2db3af,null));};exports[_0x052d('0x8a')]=function(_0x58b4fe,_0x38b274){var _0x293d94=[];_0x293d94[_0x052d('0x5f')](addAdditionalPhones(_0x58b4fe[_0x052d('0x35')]));Promise['all'](_0x293d94)[_0x052d('0x1a')](function(){_0x293d94=[];_0x293d94[_0x052d('0x5f')](deleteCmHopperPhones(_0x58b4fe[_0x052d('0x35')]['id']));_0x293d94[_0x052d('0x5f')](addCmHopperPhones(_0x58b4fe[_0x052d('0x35')]['id']));Promise[_0x052d('0x64')](_0x293d94)[_0x052d('0x1a')](function(){return[0x1];})[_0x052d('0x1a')](respondWithResult(_0x38b274,null));});};function addAdditionalPhones(_0x26eec6){var _0xc7794d;return new Promise(function(_0x217df9){return db[_0x052d('0x4c')][_0x052d('0x1b')]({'where':{'CmContactId':_0x26eec6['id']}})['then'](function(){db[_0x052d('0x6b')][_0x052d('0x21')]({'raw':!![],'attributes':['id','OrderBy']})[_0x052d('0x1a')](function(_0x1eb78d){var _0x2dcf23=[];for(var _0x5877d8=0x0;_0x5877d8<_0x26eec6[_0x052d('0x8b')][_0x052d('0x37')];_0x5877d8++){var _0x28603f=_0x26eec6[_0x052d('0x8c')]?_[_0x052d('0x58')](_0x26eec6[_0x052d('0x8c')][_0x5877d8])?'':_0x26eec6[_0x052d('0x8c')][_0x5877d8]:_0x26eec6['items'][_0x5877d8][_0x052d('0x8d')]?_0x26eec6['items'][_0x5877d8][_0x052d('0x8d')]:'';var _0x29dd7d=_[_0x052d('0x58')](_0x26eec6[_0x052d('0x8b')][_0x5877d8][_0x052d('0x8e')])?'':_0x26eec6['items'][_0x5877d8][_0x052d('0x8e')];var _0x3ff9e1=_0x28603f+':'+_0x26eec6[_0x052d('0x8b')][_0x5877d8]['phone']+'ยง'+_0x29dd7d;if(_['isNil'](_0xc7794d))_0xc7794d=_0x3ff9e1;else _0xc7794d+=';'+_0x3ff9e1;var _0x36399f=null;var _0x36c806=null;if(_0x26eec6[_0x052d('0x8c')]){if(!_['isNil'](_0x26eec6[_0x052d('0x8c')][_0x5877d8])){_0x36c806=_[_0x052d('0x25')](_0x1eb78d,function(_0x249892){return _0x249892['id']===_0x26eec6[_0x052d('0x8c')][_0x5877d8];});if(!_[_0x052d('0x58')](_0x36c806)){_0x36399f=_0x36c806[_0x052d('0x8f')];}}}else{if(!_[_0x052d('0x58')](_0x26eec6[_0x052d('0x8b')][_0x5877d8])){_0x36c806=_[_0x052d('0x25')](_0x1eb78d,function(_0xf41878){return _0xf41878['id']===_0x26eec6[_0x052d('0x8b')][_0x5877d8]['ItemTypeId'];});if(!_[_0x052d('0x58')](_0x36c806)){_0x36399f=_0x5877d8;}}}if(_['isNil'](_0x36399f)){_0x36399f=0x64;}_0x2dcf23[_0x052d('0x5f')](addAdditionalPhone(_0x26eec6['id'],_0x26eec6[_0x052d('0x8b')][_0x5877d8]['phone'],_0x26eec6['item_types']?_['isNil'](_0x26eec6[_0x052d('0x8c')][_0x5877d8])?null:_0x26eec6[_0x052d('0x8c')][_0x5877d8]:_0x26eec6[_0x052d('0x8b')][_0x5877d8][_0x052d('0x8d')]?_0x26eec6['items'][_0x5877d8]['ItemTypeId']:null,_0x36399f,_0x29dd7d));}Promise[_0x052d('0x64')](_0x2dcf23)[_0x052d('0x1a')](function(){db[_0x052d('0x24')][_0x052d('0x42')]({'AdditionalPhones':_0xc7794d},{'where':{'id':_0x26eec6['id']}})[_0x052d('0x1a')](function(){_0x217df9(0x1);});});});});});}function addAdditionalPhone(_0x2b4cb5,_0x2781e7,_0x31a883,_0x58ecc9,_0x1c5a89){return db[_0x052d('0x4c')][_0x052d('0x25')]({'where':{'CmContactId':_0x2b4cb5,'item':_0x2781e7}})[_0x052d('0x1a')](function(_0x58f274){if(_0x58f274)logger[_0x052d('0x3c')](_0x052d('0x90'),_0x58f274);else{db['CmContactHasItem']['create']({'CmContactId':_0x2b4cb5,'item':_0x2781e7,'ItemTypeId':_0x31a883,'OrderBy':_0x58ecc9,'ItemClass':_0x052d('0x91'),'description':_0x1c5a89});}});}function deleteCmHopperPhones(_0x3e0b98){return new Promise(function(_0x48c046){return db[_0x052d('0x3e')]['findAll']({'raw':!![],'attributes':['id'],'where':{'ContactId':_0x3e0b98}})['then'](function(_0x5ddc30){db['CmHopperAdditionalPhone']['destroy']({'where':{'CmHopperId':{'$in':_['map'](_0x5ddc30,'id')}}});})[_0x052d('0x1a')](function(){_0x48c046(0x1);});});}function addCmHopperPhones(_0x13f444){return new Promise(function(_0x5c2b63){return db['CmHopper'][_0x052d('0x21')]({'raw':!![],'attributes':['id'],'where':{'ContactId':_0x13f444}})['then'](function(_0x2ffc36){var _0x45ce9e=[];_[_0x052d('0x6e')](_0x2ffc36,function(_0x525e19){_0x45ce9e[_0x052d('0x5f')](createCmHopperPhone(_0x13f444,_0x525e19['id']));});Promise['all'](_0x45ce9e)['then'](function(){_0x5c2b63(0x1);});});});}function createCmHopperPhone(_0x4dd349,_0x45b165){return new Promise(function(_0x5015b2){db[_0x052d('0x4c')][_0x052d('0x21')]({'raw':!![],'attributes':[_0x052d('0x92'),'OrderBy'],'where':{'CmContactId':_0x4dd349,'ItemClass':'PHONE'},'include':[{'model':db[_0x052d('0x6b')],'attributes':[_0x052d('0x8f')],'as':_0x052d('0x93')}],'order':[_0x052d('0x8f'),db['sequelize'][_0x052d('0x94')](_0x052d('0x95'))]})['then'](function(_0x425ad3){var _0xc2016a=0x1;var _0x5155c3=_[_0x052d('0x6e')](_0x425ad3,function(_0x341088){_0x341088['CmHopperId']=_0x45b165;_0x341088[_0x052d('0x7c')]=_0x341088[_0x052d('0x92')];_0x341088[_0x052d('0x8f')]=_0xc2016a;delete _0x341088[_0x052d('0x96')];_0xc2016a=_0xc2016a+0x1;return _0x341088;});return db[_0x052d('0x97')][_0x052d('0x5b')](_0x5155c3,{});})[_0x052d('0x1a')](function(){_0x5015b2(0x1);});});}function insertAdditionalPhones(_0x30ed8e,_0x279152){return new Promise(function(_0x55fb4f){var _0x1b423a=[];for(var _0x2a4399=0x0;_0x2a4399<_0x279152['length'];_0x2a4399++){var _0x2f75ba=_0x279152[_0x2a4399];_0x1b423a[_0x052d('0x5f')](parseContactItemType(_0x2f75ba));}Promise['all'](_0x1b423a)[_0x052d('0x1a')](function(){var _0xe415d4={'id':_0x30ed8e['id'],'items':_0x279152};return addAdditionalPhones(_0xe415d4)[_0x052d('0x1a')](function(){return addCmHopperPhones(_0x30ed8e['id']);});})[_0x052d('0x1a')](function(){_0x55fb4f(_0x30ed8e);});});}function parseContactItemType(_0x4fb2ec){return new Promise(function(_0x182371){if(_0x4fb2ec['hasOwnProperty'](_0x052d('0x8d'))){_0x182371(_0x4fb2ec);}else{return db[_0x052d('0x6b')][_0x052d('0x25')]({'where':{'name':_0x4fb2ec[_0x052d('0x93')]}})['then'](function(_0x1c2ddd){if(_['isNil'](_0x1c2ddd))_0x4fb2ec[_0x052d('0x8d')]=null;else _0x4fb2ec[_0x052d('0x8d')]=_0x1c2ddd['id'];_0x182371(_0x4fb2ec);});}});}exports['getAdditionalPhones']=function(_0x13ff36,_0x330061){return db[_0x052d('0x4c')][_0x052d('0x21')]({'raw':!![],'where':{'CmContactId':_0x13ff36['params']['id'],'ItemClass':_0x052d('0x91')},'include':[{'model':db[_0x052d('0x6b')],'as':'ItemType'}],'order':[[_0x052d('0x8f')],[db[_0x052d('0x79')][_0x052d('0x94')](_0x052d('0x95'))]]})['then'](function(_0x449854){return _0x449854;})[_0x052d('0x1a')](respondWithResult(_0x330061,null))[_0x052d('0x27')](handleError(_0x330061,null));};exports[_0x052d('0x98')]=function(_0x288640,_0x2dd694){return db[_0x052d('0x4c')][_0x052d('0x21')]({'raw':!![],'where':{'CmContactId':_0x288640['body'][_0x052d('0x99')]}})[_0x052d('0x1a')](function(_0xee0083){var _0x181ada=_[_0x052d('0x6e')](_0xee0083,function(_0x4aedb8){_0x4aedb8['CmContactId']=_0x288640[_0x052d('0x35')][_0x052d('0x9a')];return _0x4aedb8;});return db['CmContactHasItem'][_0x052d('0x5b')](_0x181ada,{});})[_0x052d('0x1a')](function(){return addCmHopperPhones(_0x288640[_0x052d('0x35')]['toContactId']);})[_0x052d('0x1a')](function(){return['ok'];})[_0x052d('0x1a')](respondWithResult(_0x2dd694,null))[_0x052d('0x27')](handleError(_0x2dd694,null));};exports['rescheduleAdditionalPhones']=function(_0x544f32,_0x769e98){var _0x33b66d=[];_0x33b66d['push'](createCmHopperPhone(_0x544f32[_0x052d('0x35')]['id'],_0x544f32[_0x052d('0x35')][_0x052d('0x9b')]));Promise[_0x052d('0x64')](_0x33b66d)['then'](function(){return[0x1];})['then'](respondWithResult(_0x769e98,null));};exports['getHoppers']=function(_0x3ae928,_0x3bba51){var _0x100f14={'raw':![],'where':{}};var _0x3921ff={};var _0x2d0f44={'count':0x0,'rows':[]};return db['CmContact'][_0x052d('0x7e')]({'where':{'id':_0x3ae928['params']['id']}})[_0x052d('0x1a')](handleEntityNotFound(_0x3bba51,null))['then'](function(_0x5dca93){if(_0x5dca93){_0x3921ff[_0x052d('0x7f')]=_[_0x052d('0x29')](db[_0x052d('0x3e')][_0x052d('0x80')]);_0x3921ff[_0x052d('0x22')]=_['keys'](_0x3ae928[_0x052d('0x22')]);_0x3921ff[_0x052d('0x81')]=_['intersection'](_0x3921ff[_0x052d('0x7f')],_0x3921ff[_0x052d('0x22')]);_0x100f14['attributes']=_['intersection'](_0x3921ff[_0x052d('0x7f')],qs['fields'](_0x3ae928['query'][_0x052d('0x9c')]));_0x100f14[_0x052d('0x83')]=_0x100f14[_0x052d('0x83')][_0x052d('0x37')]?_0x100f14[_0x052d('0x83')]:_0x3921ff[_0x052d('0x7f')];if(!_0x3ae928['query'][_0x052d('0x33')](_0x052d('0x9d'))){_0x100f14[_0x052d('0x15')]=qs[_0x052d('0x15')](_0x3ae928[_0x052d('0x22')][_0x052d('0x15')]);_0x100f14[_0x052d('0x14')]=qs[_0x052d('0x14')](_0x3ae928[_0x052d('0x22')][_0x052d('0x14')]);}_0x100f14['order']=qs['sort'](_0x3ae928[_0x052d('0x22')][_0x052d('0x85')]);_0x100f14[_0x052d('0x5d')]=qs['filters'](_[_0x052d('0x86')](_0x3ae928['query'],_0x3921ff[_0x052d('0x81')]));_0x100f14['where'][_0x052d('0x9e')]=_0x5dca93['id'];if(_0x3ae928['query'][_0x052d('0x87')]){_0x100f14['where']=_[_0x052d('0x34')](_0x100f14[_0x052d('0x5d')],{'$or':_['map'](_0x100f14['attributes'],function(_0x37a839){var _0x168f89={};_0x168f89[_0x37a839]={'$like':'%'+_0x3ae928[_0x052d('0x22')][_0x052d('0x87')]+'%'};return _0x168f89;})});}_0x100f14=_[_0x052d('0x34')]({},_0x100f14,_0x3ae928[_0x052d('0x9f')]);return db[_0x052d('0x3e')][_0x052d('0x17')]({'where':_0x100f14['where']})[_0x052d('0x1a')](function(_0x25e38b){_0x2d0f44[_0x052d('0x17')]=_0x25e38b;if(_0x3ae928['query'][_0x052d('0xa0')]){_0x100f14[_0x052d('0xa1')]=[{'all':!![]}];}return db[_0x052d('0x3e')][_0x052d('0x21')](_0x100f14);})[_0x052d('0x1a')](function(_0x62062a){_0x2d0f44[_0x052d('0xa2')]=_0x62062a;return _0x2d0f44;});}})[_0x052d('0x1a')](respondWithFilteredResult(_0x3bba51,_0x100f14))['catch'](handleError(_0x3bba51,null));};exports[_0x052d('0xa3')]=function(_0x16ab5f,_0x192c42){var _0x41a43a={'raw':!![],'where':{}};var _0xc59689={};var _0x151590={'count':0x0,'rows':[]};return db[_0x052d('0x24')][_0x052d('0x7e')]({'where':{'id':_0x16ab5f['params']['id']}})[_0x052d('0x1a')](handleEntityNotFound(_0x192c42,null))[_0x052d('0x1a')](function(_0x4121a2){if(_0x4121a2){_0xc59689['model']=_[_0x052d('0x29')](db[_0x052d('0xa4')]['rawAttributes']);_0xc59689[_0x052d('0x22')]=_[_0x052d('0x29')](_0x16ab5f[_0x052d('0x22')]);_0xc59689[_0x052d('0x81')]=_['intersection'](_0xc59689[_0x052d('0x7f')],_0xc59689[_0x052d('0x22')]);_0x41a43a[_0x052d('0x83')]=_[_0x052d('0x82')](_0xc59689[_0x052d('0x7f')],qs['fields'](_0x16ab5f[_0x052d('0x22')][_0x052d('0x9c')]));_0x41a43a['attributes']=_0x41a43a['attributes'][_0x052d('0x37')]?_0x41a43a['attributes']:_0xc59689['model'];if(!_0x16ab5f['query'][_0x052d('0x33')](_0x052d('0x9d'))){_0x41a43a[_0x052d('0x15')]=qs[_0x052d('0x15')](_0x16ab5f['query'][_0x052d('0x15')]);_0x41a43a[_0x052d('0x14')]=qs['offset'](_0x16ab5f[_0x052d('0x22')][_0x052d('0x14')]);}_0x41a43a['order']=qs[_0x052d('0x85')](_0x16ab5f[_0x052d('0x22')]['sort']);_0x41a43a[_0x052d('0x5d')]=qs[_0x052d('0x81')](_[_0x052d('0x86')](_0x16ab5f[_0x052d('0x22')],_0xc59689[_0x052d('0x81')]));_0x41a43a[_0x052d('0x5d')]['ContactId']=_0x4121a2['id'];if(_0x16ab5f['query'][_0x052d('0x87')]){_0x41a43a[_0x052d('0x5d')]=_[_0x052d('0x34')](_0x41a43a[_0x052d('0x5d')],{'$or':_[_0x052d('0x6e')](_0x41a43a['attributes'],function(_0x3d3814){var _0x488cd3={};_0x488cd3[_0x3d3814]={'$like':'%'+_0x16ab5f[_0x052d('0x22')]['filter']+'%'};return _0x488cd3;})});}_0x41a43a=_[_0x052d('0x34')]({},_0x41a43a,_0x16ab5f['options']);return db[_0x052d('0xa4')][_0x052d('0x17')]({'where':_0x41a43a['where']})['then'](function(_0x3a582f){_0x151590[_0x052d('0x17')]=_0x3a582f;if(_0x16ab5f[_0x052d('0x22')]['includeAll']){_0x41a43a[_0x052d('0xa1')]=[{'all':!![]}];}return db[_0x052d('0xa4')]['findAll'](_0x41a43a);})[_0x052d('0x1a')](function(_0x5ba39d){_0x151590['rows']=_0x5ba39d;return _0x151590;});}})[_0x052d('0x1a')](respondWithFilteredResult(_0x192c42,_0x41a43a))[_0x052d('0x27')](handleError(_0x192c42,null));};exports[_0x052d('0xa5')]=function(_0x128f34,_0x3e274e){var _0x41be43={'raw':!![],'where':{}};var _0xa2f18b={};var _0x57fa05={'count':0x0,'rows':[]};return db['CmContact'][_0x052d('0x7e')]({'where':{'id':_0x128f34[_0x052d('0x26')]['id']}})['then'](handleEntityNotFound(_0x3e274e,null))['then'](function(_0x20f0f6){if(_0x20f0f6){_0xa2f18b[_0x052d('0x7f')]=_[_0x052d('0x29')](db[_0x052d('0x4d')]['rawAttributes']);_0xa2f18b[_0x052d('0x22')]=_['keys'](_0x128f34[_0x052d('0x22')]);_0xa2f18b[_0x052d('0x81')]=_[_0x052d('0x82')](_0xa2f18b[_0x052d('0x7f')],_0xa2f18b[_0x052d('0x22')]);_0x41be43[_0x052d('0x83')]=_[_0x052d('0x82')](_0xa2f18b[_0x052d('0x7f')],qs[_0x052d('0x9c')](_0x128f34[_0x052d('0x22')][_0x052d('0x9c')]));_0x41be43['attributes']=_0x41be43[_0x052d('0x83')]['length']?_0x41be43['attributes']:_0xa2f18b['model'];if(!_0x128f34[_0x052d('0x22')][_0x052d('0x33')]('nolimit')){_0x41be43['limit']=qs[_0x052d('0x15')](_0x128f34[_0x052d('0x22')]['limit']);_0x41be43['offset']=qs['offset'](_0x128f34[_0x052d('0x22')][_0x052d('0x14')]);}_0x41be43[_0x052d('0x84')]=qs['sort'](_0x128f34['query']['sort']);_0x41be43[_0x052d('0x5d')]=qs[_0x052d('0x81')](_['pick'](_0x128f34['query'],_0xa2f18b['filters']));_0x41be43[_0x052d('0x5d')][_0x052d('0x9e')]=_0x20f0f6['id'];if(_0x128f34[_0x052d('0x22')][_0x052d('0x87')]){_0x41be43[_0x052d('0x5d')]=_[_0x052d('0x34')](_0x41be43[_0x052d('0x5d')],{'$or':_['map'](_0x41be43[_0x052d('0x83')],function(_0x3faff9){var _0x52cfa0={};_0x52cfa0[_0x3faff9]={'$like':'%'+_0x128f34[_0x052d('0x22')][_0x052d('0x87')]+'%'};return _0x52cfa0;})});}_0x41be43=_[_0x052d('0x34')]({},_0x41be43,_0x128f34[_0x052d('0x9f')]);return db[_0x052d('0x4d')]['count']({'where':_0x41be43[_0x052d('0x5d')]})['then'](function(_0x515aa){_0x57fa05[_0x052d('0x17')]=_0x515aa;if(_0x128f34['query'][_0x052d('0xa0')]){_0x41be43['include']=[{'all':!![]}];}return db[_0x052d('0x4d')][_0x052d('0x21')](_0x41be43);})[_0x052d('0x1a')](function(_0x3ef31b){_0x57fa05[_0x052d('0xa2')]=_0x3ef31b;return _0x57fa05;});}})[_0x052d('0x1a')](respondWithFilteredResult(_0x3e274e,_0x41be43))['catch'](handleError(_0x3e274e,null));};exports[_0x052d('0xa6')]=function(_0x56f6d0,_0xc43697){var _0x5bc16f={'raw':!![],'where':{}};var _0x3158c7={};var _0x117b86={'count':0x0,'rows':[]};return db[_0x052d('0x24')][_0x052d('0x7e')]({'where':{'id':_0x56f6d0[_0x052d('0x26')]['id']}})['then'](handleEntityNotFound(_0xc43697,null))[_0x052d('0x1a')](function(_0x2c2652){if(_0x2c2652){_0x3158c7[_0x052d('0x7f')]=_[_0x052d('0x29')](db['JscriptySessionReport'][_0x052d('0x80')]);_0x3158c7[_0x052d('0x22')]=_['keys'](_0x56f6d0[_0x052d('0x22')]);_0x3158c7[_0x052d('0x81')]=_[_0x052d('0x82')](_0x3158c7['model'],_0x3158c7['query']);_0x5bc16f[_0x052d('0x83')]=_[_0x052d('0x82')](_0x3158c7[_0x052d('0x7f')],qs[_0x052d('0x9c')](_0x56f6d0['query'][_0x052d('0x9c')]));_0x5bc16f[_0x052d('0x83')]=_0x5bc16f[_0x052d('0x83')]['length']?_0x5bc16f[_0x052d('0x83')]:_0x3158c7[_0x052d('0x7f')];if(!_0x56f6d0[_0x052d('0x22')][_0x052d('0x33')]('nolimit')){_0x5bc16f[_0x052d('0x15')]=qs[_0x052d('0x15')](_0x56f6d0[_0x052d('0x22')][_0x052d('0x15')]);_0x5bc16f[_0x052d('0x14')]=qs[_0x052d('0x14')](_0x56f6d0[_0x052d('0x22')][_0x052d('0x14')]);}_0x5bc16f['order']=qs[_0x052d('0x85')](_0x56f6d0[_0x052d('0x22')][_0x052d('0x85')]);_0x5bc16f['where']=qs[_0x052d('0x81')](_['pick'](_0x56f6d0[_0x052d('0x22')],_0x3158c7[_0x052d('0x81')]));_0x5bc16f['where']['ContactId']=_0x2c2652['id'];if(_0x56f6d0[_0x052d('0x22')][_0x052d('0x87')]){_0x5bc16f[_0x052d('0x5d')]=_[_0x052d('0x34')](_0x5bc16f[_0x052d('0x5d')],{'$or':_[_0x052d('0x6e')](_0x5bc16f[_0x052d('0x83')],function(_0xaef1b7){var _0x209fef={};_0x209fef[_0xaef1b7]={'$like':'%'+_0x56f6d0[_0x052d('0x22')][_0x052d('0x87')]+'%'};return _0x209fef;})});}_0x5bc16f=_[_0x052d('0x34')]({},_0x5bc16f,_0x56f6d0['options']);return db[_0x052d('0xa7')][_0x052d('0x17')]({'where':_0x5bc16f[_0x052d('0x5d')]})['then'](function(_0x599232){_0x117b86['count']=_0x599232;if(_0x56f6d0['query'][_0x052d('0xa0')]){_0x5bc16f[_0x052d('0xa1')]=[{'all':!![]}];}return db[_0x052d('0xa7')][_0x052d('0x21')](_0x5bc16f);})[_0x052d('0x1a')](function(_0x539c78){_0x117b86[_0x052d('0xa2')]=_0x539c78;return _0x117b86;});}})[_0x052d('0x1a')](respondWithFilteredResult(_0xc43697,_0x5bc16f))[_0x052d('0x27')](handleError(_0xc43697,null));};exports[_0x052d('0xa8')]=function(_0x22ce66,_0x67e7be){try{if(!_0x22ce66[_0x052d('0x35')]['ListId']){throw new Error(_0x052d('0xa9'));}if(!_0x22ce66[_0x052d('0x35')][_0x052d('0xaa')]){throw new Error(_0x052d('0xab'));}if(!_0x22ce66[_0x052d('0x35')]['binding_values']){throw new Error(_0x052d('0xac'));}if(!_0x22ce66['body'][_0x052d('0xad')]){throw new Error(_0x052d('0xae'));}var _0x54f458=_0x22ce66[_0x052d('0x35')]['binding_keys'][_0x052d('0xaf')](',');var _0x123a74=_0x22ce66[_0x052d('0x35')][_0x052d('0xb0')]['split'](',');if(!_0x54f458[_0x052d('0x37')]||!_0x123a74['length']||_0x54f458[_0x052d('0x37')]!==_0x123a74['length']){throw new Error(_0x052d('0xb1'));}_0x22ce66[_0x052d('0x35')][_0x052d('0x9c')]=_['zipObject'](_0x54f458,_0x123a74);if(!_0x22ce66[_0x052d('0x35')][_0x052d('0x9c')][_0x052d('0x7c')]){throw new Error(_0x052d('0xb2'));}if(!_0x22ce66[_0x052d('0x35')]['fields']['firstName']){throw new Error(_0x052d('0xb3'));}var _0x20b47d=path[_0x052d('0x3b')](config[_0x052d('0xb4')],_0x052d('0xb5'),_0x22ce66['file'][_0x052d('0xb6')]);fs['chmodSync'](_0x20b47d,parseInt(_0x052d('0xb7'),0x8));var _0x56b397=require(_0x052d('0xb8'))['fork'](path[_0x052d('0x3b')](__dirname,_0x052d('0xb9')),[_0x20b47d,_0x22ce66[_0x052d('0x35')][_0x052d('0xaa')],_0x22ce66[_0x052d('0x35')][_0x052d('0xb0')],_0x22ce66[_0x052d('0x35')]['ListId'],_0x22ce66['body'][_0x052d('0xba')],_0x22ce66[_0x052d('0x35')][_0x052d('0x5c')],_0x22ce66['body'][_0x052d('0xad')]]);return _0x67e7be[_0x052d('0x12')](0xc8)[_0x052d('0x13')]({'message':_0x052d('0xbb'),'pid':_0x56b397[_0x052d('0xbc')]});}catch(_0x3f14fd){return _0x67e7be[_0x052d('0x12')](0x1f4)[_0x052d('0xbd')](_0x3f14fd);}};exports[_0x052d('0xbe')]=function(_0x3326c4,_0x3760ca){var _0x1fc211=fs['createReadStream'](_0x3326c4[_0x052d('0xbf')][_0x052d('0x2')]);Papa[_0x052d('0xc0')](_0x1fc211,{'header':!![],'skipEmptyLines':!![],'preview':0x1,'complete':function(_0x773671){return _0x3760ca[_0x052d('0x12')](0xc8)[_0x052d('0x13')]({'file':_0x3326c4['file'],'fields':_0x773671[_0x052d('0xc1')]['fields']});}});};exports[_0x052d('0xc2')]=function(_0x2692b3,_0x31a154){return db[_0x052d('0xc3')]['findAll']({'raw':!![],'attributes':['id'],'where':{'role':_0x052d('0xc4')}})['then'](function(_0x7ff9b1){var _0x432cd3=![];if(!_0x2692b3[_0x052d('0x35')]['ListId']){throw new Error('No\x20ListId\x20specified');}if(!_0x2692b3[_0x052d('0x35')][_0x052d('0xc5')][_0x052d('0x7c')]){throw new Error(_0x052d('0xb2'));}if(!_0x2692b3[_0x052d('0x35')][_0x052d('0xc5')][_0x052d('0xc6')]){throw new Error(_0x052d('0xb3'));}if(!_0x2692b3[_0x052d('0x35')]['socket_timestamp']){throw new Error(_0x052d('0xae'));}var _0x22fec4=require(_0x052d('0xb8'))[_0x052d('0xc7')](path['join'](__dirname,_0x052d('0xc8')),[_0x2692b3[_0x052d('0x26')]['id'],JSON[_0x052d('0xc9')](_0x2692b3[_0x052d('0x35')]),JSON[_0x052d('0xc9')](_0x7ff9b1)]);_0x22fec4['on'](_0x052d('0xca'),function(){_0x432cd3=!![];return _0x31a154[_0x052d('0x12')](0xc8)[_0x052d('0x13')]({'message':_0x052d('0xcb'),'pid':_0x22fec4[_0x052d('0xbc')]});});_0x22fec4['on'](_0x052d('0xcc'),function(_0x28dfa0){if(_0x28dfa0&&!_0x432cd3){return _0x31a154[_0x052d('0x12')](0x1f4)[_0x052d('0x13')]({'message':_0x052d('0xcd'),'pid':_0x22fec4[_0x052d('0xbc')]});}});})[_0x052d('0x27')](handleError(_0x31a154,null));};exports[_0x052d('0xce')]=function(_0x4c4429,_0x50de10){return db[_0x052d('0xc3')][_0x052d('0x21')]({'raw':!![],'attributes':['id'],'where':{'role':'agent'}})['then'](function(_0x349380){var _0x1fafc3=![];if(!_0x4c4429[_0x052d('0x35')][_0x052d('0x60')]){throw new Error('No\x20ListId\x20specified');}if(!_0x4c4429[_0x052d('0x35')]['binding'][_0x052d('0x7c')]){throw new Error(_0x052d('0xb2'));}if(!_0x4c4429[_0x052d('0x35')]['binding'][_0x052d('0xc6')]){throw new Error(_0x052d('0xb3'));}if(!_0x4c4429[_0x052d('0x35')][_0x052d('0xad')]){throw new Error(_0x052d('0xae'));}var _0x2d0ff4=require(_0x052d('0xb8'))[_0x052d('0xc7')](path['join'](__dirname,_0x052d('0xcf')),[_0x4c4429[_0x052d('0x26')]['id'],JSON[_0x052d('0xc9')](_0x4c4429[_0x052d('0x35')]),JSON[_0x052d('0xc9')](_0x349380)]);_0x2d0ff4['on'](_0x052d('0xca'),function(){_0x1fafc3=!![];return _0x50de10[_0x052d('0x12')](0xc8)[_0x052d('0x13')]({'message':_0x052d('0xcb'),'pid':_0x2d0ff4[_0x052d('0xbc')]});});_0x2d0ff4['on'](_0x052d('0xcc'),function(_0x29f8a1){if(_0x29f8a1&&!_0x1fafc3){return _0x50de10['status'](0x1f4)[_0x052d('0x13')]({'message':_0x052d('0xcd'),'pid':_0x2d0ff4['pid']});}});})[_0x052d('0x27')](handleError(_0x50de10,null));};exports[_0x052d('0xd0')]=function(_0x13d15c,_0x118de2){var _0x32f605=['mail',_0x052d('0xd1'),_0x052d('0xd2'),_0x052d('0xd3'),_0x052d('0xd4'),_0x052d('0xd5'),_0x052d('0xd6')];var _0x91d110={'offset':0x0,'order':qs[_0x052d('0x85')](_0x052d('0xd7'))},_0x3b3783={'count':0x0,'rows':[]};Promise[_0x052d('0xd8')]()[_0x052d('0x1a')](function(){if(_0x13d15c[_0x052d('0x22')]['channel']){if(!_[_0x052d('0xd9')](_0x32f605,_0x13d15c[_0x052d('0x22')][_0x052d('0xda')][_0x052d('0xdb')]())){throw new Error(_0x052d('0xdc'));}_0x32f605=[_0x13d15c[_0x052d('0x22')][_0x052d('0xda')][_0x052d('0xdb')]()];}if(_0x13d15c[_0x052d('0x22')]['range']){try{var _0xb1a9ef=JSON[_0x052d('0xc0')](_0x13d15c[_0x052d('0x22')]['range']);if(!moment(_0xb1a9ef[_0x052d('0x36')])[_0x052d('0xdd')]()){throw new Error(_0x052d('0xde'));}if(!moment(_0xb1a9ef['to'])[_0x052d('0xdd')]()){throw new Error(_0x052d('0xdf'));}}catch(_0x7089c4){throw new Error('Invalid\x20createdAt\x20filter');}}if(!_0x13d15c[_0x052d('0x22')][_0x052d('0x33')](_0x052d('0x9d'))){_0x91d110[_0x052d('0x15')]=qs[_0x052d('0x15')](_0x13d15c[_0x052d('0x22')]['limit']||0xa);_0x91d110[_0x052d('0x14')]=qs['offset'](_0x13d15c[_0x052d('0x22')][_0x052d('0x14')]);}var _0x1e3925=_0x32f605[_0x052d('0x6e')](function(_0x3fac69){if(_0x3fac69==='voice'){var _0x51ce4d={'attributes':['id',_0x052d('0xe0'),_0x052d('0x31'),_0x052d('0xe1'),'destination',_0x052d('0xe2'),_0x052d('0xe3'),_0x052d('0xe4'),_0x052d('0xe5'),_0x052d('0xe6'),'createdAt',_0x052d('0xe7'),_0x052d('0xe8'),_0x052d('0xe9'),_0x052d('0xea')],'where':{'ContactId':_0x13d15c[_0x052d('0x26')]['id']},'include':[{'model':db[_0x052d('0xc3')],'as':'User','attributes':['id','name',_0x052d('0xeb'),'alias']}],'order':[['createdAt',_0x052d('0xec')]]};if(_0x13d15c[_0x052d('0x22')]['range']){_0x51ce4d[_0x052d('0x5d')][_0x052d('0xed')]={'$gte':_0xb1a9ef[_0x052d('0x36')],'$lte':_0xb1a9ef['to']};}return db[_0x052d('0xee')]['findAndCountAll'](_0x51ce4d)['then'](function(_0x3e6316){_0x3b3783[_0x052d('0x17')]+=_0x3e6316[_0x052d('0x17')];return _[_0x052d('0x6e')](_0x3e6316[_0x052d('0xa2')],function(_0x283572){var _0x69397b=_0x283572[_0x052d('0x38')]({'plain':!![]});_0x69397b[_0x052d('0xda')]=_0x3fac69;if(_0x69397b['User']){_0x69397b[_0x052d('0xc3')]={'id':_0x69397b[_0x052d('0xc3')]['id'],'name':_0x69397b[_0x052d('0xc3')][_0x052d('0x1e')],'fullname':_0x69397b['User'][_0x052d('0xeb')],'alias':_0x69397b[_0x052d('0xc3')][_0x052d('0x30')]};}return _0x69397b;});});}else{var _0x2b91e4=_[_0x052d('0xef')](_0x3fac69)+(_0x3fac69===_0x052d('0xd1')?_0x052d('0xf0'):'Account');var _0x44f94f={'attributes':['id',_0x052d('0xf1'),'closedAt',_0x052d('0xed'),'note',_0x052d('0xf2'),_0x052d('0xf3'),'thirdDisposition',_0x052d('0xea'),_0x2b91e4+'Id'],'where':{'ContactId':_0x13d15c[_0x052d('0x26')]['id']},'include':[{'model':db[_0x2b91e4],'as':'Account','attributes':['id',_0x052d('0x1e'),_0x052d('0xf4')]},{'model':db['User'],'as':_0x052d('0xf5'),'attributes':['id',_0x052d('0x1e'),_0x052d('0xeb')]},{'model':db[_0x052d('0x66')],'as':'Tags','attributes':['id',_0x052d('0x1e'),_0x052d('0x68')],'through':{'attributes':[]}}],'order':[[_0x052d('0xed'),_0x052d('0xec')]]};if(_0x13d15c[_0x052d('0x22')]['range']){_0x44f94f[_0x052d('0x5d')][_0x052d('0xed')]={'$gte':_0xb1a9ef['from'],'$lte':_0xb1a9ef['to']};}switch(_0x3fac69){case'chat':_0x44f94f[_0x052d('0x83')]['push']('browserName',_0x052d('0xf6'),'customerPort',_0x052d('0xf7'),_0x052d('0xf8'),'ratingMessage',_0x052d('0xf9'),_0x052d('0xfa'),_0x052d('0xfb'));break;case _0x052d('0xfc'):_0x44f94f[_0x052d('0x83')][_0x052d('0x5f')](_0x052d('0xfd'),_0x052d('0xfe'));break;case _0x052d('0xd3'):_0x44f94f[_0x052d('0x83')]['push'](_0x052d('0xff'),_0x052d('0x100'));break;}return db[_['startCase'](_0x3fac69)+_0x052d('0x101')][_0x052d('0x102')](_0x44f94f)[_0x052d('0x1a')](function(_0x190df7){_0x3b3783[_0x052d('0x17')]+=_0x190df7['count'];return _['map'](_0x190df7['rows'],function(_0x393a6d){var _0x48e971=_0x393a6d[_0x052d('0x38')]({'plain':!![]});_0x48e971[_0x052d('0xda')]=_0x3fac69;if(_0x48e971[_0x052d('0xf5')]){_0x48e971[_0x052d('0xf5')]={'id':_0x48e971[_0x052d('0xf5')]['id'],'name':_0x48e971[_0x052d('0xf5')][_0x052d('0x1e')],'fullname':_0x48e971['Owner'][_0x052d('0xeb')]};}return _0x48e971;});});}});return Promise[_0x052d('0x64')](_0x1e3925);})[_0x052d('0x1a')](function(_0x315824){return _(_0x315824)[_0x052d('0x103')]()[_0x052d('0x104')]('createdAt')[_0x052d('0x105')]()[_0x052d('0x106')]();})[_0x052d('0x1a')](function(_0x8eef28){_0x3b3783[_0x052d('0xa2')]=_0x91d110[_0x052d('0x15')]?_0x8eef28['slice'](_0x91d110[_0x052d('0x14')],_0x91d110[_0x052d('0x14')]+_0x91d110['limit']):_0x8eef28;return _0x3b3783;})[_0x052d('0x1a')](respondWithFilteredResult(_0x118de2,_0x91d110))[_0x052d('0x27')](handleError(_0x118de2,null));};
\ No newline at end of file