Built motion from commit ffdca78c.|2.6.24
[motion2.git] / server / api / cmContact / cmContact.controller.js
index b39fc25..bf09368 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x975f=['No\x20association\x20values\x20specified!','socket_timestamp','No\x20phone\x20column\x20specified','firstName','No\x20firstName\x20column\x20specified','root','server/files/tmp','file','filename','chmodSync','child_process','fork','CompanyId','duplicates','File\x20uploaded\x20correctly!','pid','upload','createReadStream','parse','import','binding','Unable\x20to\x20synchronize\x20socket,\x20no\x20timestamp\x20passed','stringify','message','exit','html-pdf','eml-format','fast-json-patch','request-promise','bluebird','mustache','util','path','to-csv','ejs','lodash','squel','jsforce','desk.js','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','redis','localhost','socket.io-emitter','./cmContact.socket','register','end','status','json','count','offset','limit','set','Content-Range','apply','reject','save','update','then','destroy','error','stack','name','send','index','CmContact','describe','keys','cf_','push','CmCustomField','trimStart','all','length','type','model','query','intersection','fields','attributes','sort','where','filters','select','field','color','from','tools_tags','cm_contacts','left_join','uc.CmContactId\x20=\x20c.id','ct.CmContactId\x20=\x20c.id','t.id\x20=\x20ct.TagId','expr','search','parseSearch','sqlOperator','conditions','Tag','value','split','map','union','User','and','uc.UserId\x20=\x20?','dateOfBirth','datetime','DATE','buildExpression','text','hasOwnProperty','filter','isNil','Contact','isEmpty','forEach','ListId','c.ListId\x20IN\x20?','concat','CONCAT_WS(\x27\x20\x27,\x20c.firstName,\x20c.lastName,\x20c.email)\x20LIKE\x20?','\x20=\x20?','tag','CONCAT(\x27,\x27,\x20`TagIds`,\x20\x27,\x27)\x20LIKE\x20?','replace','MATCH\x20(c.firstName,\x20c.lastName,\x20c.phone,\x20c.mobile,\x20c.fax,\x20c.email)\x20AGAINST\x20(?\x20IN\x20BOOLEAN\x20MODE)','getFullTextValue','c.id\x20LIKE\x20?','c.phone\x20LIKE\x20?','c.mobile\x20LIKE\x20?','c.fax\x20LIKE\x20?','c.lastName\x20LIKE\x20?','c.email\x20LIKE\x20?','c.id','Sequelize','SELECT','clone','order','DESC','t.id\x20IN\x20?','resolve','user','role','some','getLists','c.ListId\x20IS\x20NULL','agent','sequelize','toString','keyBy','merge','c.lastName','c.phone','c.fax','c.email','c.ListId','c.createdAt','c.deletedAt','c.CompanyId','TagIds','Tags','rows','catch','find','params','tags','startsWith','findAll','columnName','displayName','alias','custom','body','get','mergeWith','isArray','join','[CmContact][merge]\x20to\x20%s\x20from\x20%s','info','[CmContact][merge][destroy][CmHopper],\x20%s','CmHopperBlack','[CmContact][merge][destroy][CmHopperBlack],\x20%s','create','ChatInteraction','ChatMessage','ChatOfflineMessage','MailMessage','MailInteraction','SmsInteraction','SmsMessage','FaxMessage','OpenchannelInteraction','OpenchannelMessage','CmHopperFinal','CmHopperHistory','ReportAgentPreview','VoiceCallReport','FaxQueueReport','OpenchannelQueueReport','JscriptySessionReport','each','$or','spread','show','$and','format','cf_%d','omit','pickBy','setFields','id\x20=\x20?','toParam','CmHopper','phone','getTags','findOne','rawAttributes','pick','options','nolimit','setTags','ids','getHoppers','ContactId','includeAll','include','getHopperFinals','getJscriptySessions','uploadCsv','No\x20ListId\x20specified','binding_keys','binding_values'];(function(_0x4adcac,_0x5e42a3){var _0x4fe974=function(_0xfe70c3){while(--_0xfe70c3){_0x4adcac['push'](_0x4adcac['shift']());}};_0x4fe974(++_0x5e42a3);}(_0x975f,0x109));var _0xf975=function(_0x57486e,_0x32283b){_0x57486e=_0x57486e-0x0;var _0x5f110b=_0x975f[_0x57486e];return _0x5f110b;};'use strict';var pdf=require(_0xf975('0x0'));var emlformat=require(_0xf975('0x1'));var rimraf=require('rimraf');var zipdir=require('zip-dir');var jsonpatch=require(_0xf975('0x2'));var rp=require(_0xf975('0x3'));var moment=require('moment');var BPromise=require(_0xf975('0x4'));var Mustache=require(_0xf975('0x5'));var util=require(_0xf975('0x6'));var path=require(_0xf975('0x7'));var sox=require('sox');var csv=require(_0xf975('0x8'));var ejs=require(_0xf975('0x9'));var fs=require('fs');var _=require(_0xf975('0xa'));var squel=require(_0xf975('0xb'));var crypto=require('crypto');var jsforce=require(_0xf975('0xc'));var deskjs=require(_0xf975('0xd'));var toCsv=require(_0xf975('0x8'));var querystring=require('querystring');var Papa=require(_0xf975('0xe'));var Redis=require(_0xf975('0xf'));var authService=require('../../components/auth/service');var qs=require(_0xf975('0x10'));var as=require(_0xf975('0x11'));var hardwareService=require(_0xf975('0x12'));var logger=require(_0xf975('0x13'))(_0xf975('0x14'));var utils=require(_0xf975('0x15'));var config=require(_0xf975('0x16'));var licenseUtil=require('../../config/license/util');var db=require(_0xf975('0x17'))['db'];config[_0xf975('0x18')]=_['defaults'](config[_0xf975('0x18')],{'host':_0xf975('0x19'),'port':0x18eb});var socket=require(_0xf975('0x1a'))(new Redis(config[_0xf975('0x18')]));require(_0xf975('0x1b'))[_0xf975('0x1c')](socket);function respondWithStatusCode(_0xa84361,_0x525e4a){_0x525e4a=_0x525e4a||0xcc;return function(_0x1a86cd){if(_0x1a86cd){return _0xa84361['sendStatus'](_0x525e4a);}return _0xa84361['status'](_0x525e4a)[_0xf975('0x1d')]();};}function respondWithResult(_0x168a76,_0x24b7dc){_0x24b7dc=_0x24b7dc||0xc8;return function(_0x3bcc62){if(_0x3bcc62){return _0x168a76[_0xf975('0x1e')](_0x24b7dc)[_0xf975('0x1f')](_0x3bcc62);}};}function respondWithFilteredResult(_0x2cffb6,_0x4f6568){return function(_0x4935c3){if(_0x4935c3){var _0xa3a4d6=_0x4935c3[_0xf975('0x20')],_0x3040e0=_0x4f6568[_0xf975('0x21')],_0x26d37c=_0x4f6568['offset']+_0x4f6568[_0xf975('0x22')],_0xd03b1f;if(_0x26d37c>=_0xa3a4d6){_0x26d37c=_0xa3a4d6;_0xd03b1f=0xc8;}else{_0xd03b1f=0xce;}_0x2cffb6[_0xf975('0x1e')](_0xd03b1f);return _0x2cffb6[_0xf975('0x23')](_0xf975('0x24'),_0x3040e0+'-'+_0x26d37c+'/'+_0xa3a4d6)['json'](_0x4935c3);}return null;};}function patchUpdates(_0x5ae154){return function(_0x47387d){try{jsonpatch[_0xf975('0x25')](_0x47387d,_0x5ae154,!![]);}catch(_0x192d47){return BPromise[_0xf975('0x26')](_0x192d47);}return _0x47387d[_0xf975('0x27')]();};}function saveUpdates(_0x53780d,_0x2bf6b9){return function(_0x2906ce){if(_0x2906ce){return _0x2906ce[_0xf975('0x28')](_0x53780d)[_0xf975('0x29')](function(_0x524790){return _0x524790;});}return null;};}function removeEntity(_0x1dfc9d,_0xfc97cf){return function(_0x1b501a){if(_0x1b501a){return _0x1b501a[_0xf975('0x2a')]()[_0xf975('0x29')](function(){_0x1dfc9d[_0xf975('0x1e')](0xcc)['end']();});}};}function handleEntityNotFound(_0x3ee0f5,_0x2b3079){return function(_0x5bfd59){if(!_0x5bfd59){_0x3ee0f5['sendStatus'](0x194);}return _0x5bfd59;};}function handleError(_0x1ed733,_0x393655){_0x393655=_0x393655||0x1f4;return function(_0x5ccc9c){logger[_0xf975('0x2b')](_0x5ccc9c[_0xf975('0x2c')]);if(_0x5ccc9c[_0xf975('0x2d')]){delete _0x5ccc9c[_0xf975('0x2d')];}_0x1ed733[_0xf975('0x1e')](_0x393655)[_0xf975('0x2e')](_0x5ccc9c);};}exports[_0xf975('0x2f')]=function(_0x2be08b,_0x2394de){var _0x2c16a9={},_0x37337c={},_0x3af636={'count':0x0,'rows':[]};return db[_0xf975('0x30')][_0xf975('0x31')]()['then'](function(_0x5a1b4f){var _0xe1acc=[];for(var _0x22e90f=0x0;_0x22e90f<Object[_0xf975('0x32')](_0x5a1b4f)['length'];_0x22e90f++){var _0x54919f=Object[_0xf975('0x32')](_0x5a1b4f)[_0x22e90f];if(_['startsWith'](_0x54919f,_0xf975('0x33'))){_0xe1acc[_0xf975('0x34')](db[_0xf975('0x35')]['findOne']({'where':{'id':_[_0xf975('0x36')](_0x54919f,_0xf975('0x33'))},'raw':!![]}));}}return BPromise[_0xf975('0x37')](_0xe1acc)[_0xf975('0x29')](function(_0x1cbfe1){for(var _0x2f11df=0x0;_0x2f11df<_0x1cbfe1[_0xf975('0x38')];_0x2f11df++){if(_0x1cbfe1[_0x2f11df]){var _0x2e6d33=_0xf975('0x33')+_0x1cbfe1[_0x2f11df]['id'];var _0xb9d6ce=_0x5a1b4f[_0x2e6d33];_0xb9d6ce['fieldType']=_0x1cbfe1[_0x2f11df][_0xf975('0x39')];}}return _0x5a1b4f;});})[_0xf975('0x29')](function(_0x38c2cf){_0x37337c[_0xf975('0x3a')]=_[_0xf975('0x32')](_0x38c2cf);_0x37337c[_0xf975('0x3b')]=_['keys'](_0x2be08b[_0xf975('0x3b')]);_0x37337c['filters']=_['intersection'](_0x37337c['model'],_0x37337c[_0xf975('0x3b')]);_0x2c16a9['attributes']=_[_0xf975('0x3c')](_0x37337c['model'],qs[_0xf975('0x3d')](_0x2be08b[_0xf975('0x3b')][_0xf975('0x3d')]));_0x2c16a9[_0xf975('0x3e')]=_0x2c16a9['attributes']['length']?_0x2c16a9[_0xf975('0x3e')]:_0x37337c[_0xf975('0x3a')];if(!_0x2be08b[_0xf975('0x3b')]['hasOwnProperty']('nolimit')){_0x2c16a9[_0xf975('0x22')]=qs['limit'](_0x2be08b[_0xf975('0x3b')][_0xf975('0x22')]);_0x2c16a9[_0xf975('0x21')]=qs[_0xf975('0x21')](_0x2be08b[_0xf975('0x3b')][_0xf975('0x21')]);}_0x2c16a9['order']=qs[_0xf975('0x3f')](_0x2be08b[_0xf975('0x3b')][_0xf975('0x3f')]);_0x2c16a9[_0xf975('0x40')]=qs[_0xf975('0x41')](_['pick'](_0x2be08b[_0xf975('0x3b')],_0x37337c[_0xf975('0x41')]),_0x38c2cf);var _0x4fbf54=[];var _0x38a8de=squel[_0xf975('0x42')]()[_0xf975('0x43')]('id')['field'](_0xf975('0x2d'))[_0xf975('0x43')](_0xf975('0x44'))[_0xf975('0x45')](_0xf975('0x46'));var _0x58979c=squel[_0xf975('0x42')]()[_0xf975('0x45')](_0xf975('0x47'),'c')[_0xf975('0x48')]('cm_user_has_contacts','uc',_0xf975('0x49'))[_0xf975('0x48')]('cm_contact_has_tags','ct',_0xf975('0x4a'))[_0xf975('0x48')](_0xf975('0x46'),'t',_0xf975('0x4b'))[_0xf975('0x40')]('c.deletedAt\x20IS\x20NULL');var _0x2f7a84=squel[_0xf975('0x4c')]();var _0xb97282=[];var _0x3904a7=squel['expr']();var _0x4839c6;if(_0x2be08b[_0xf975('0x3b')][_0xf975('0x4d')]){_0x4839c6=as[_0xf975('0x4e')](_0x2be08b['query'][_0xf975('0x4d')]);var _0x3d5030=_0x4839c6[_0xf975('0x4f')];for(var _0x1ecbdb=0x0;_0x1ecbdb<_0x4839c6[_0xf975('0x50')]['length'];_0x1ecbdb++){var _0x16f170=_0x4839c6[_0xf975('0x50')][_0x1ecbdb];var _0x5c599f='c';var _0x1f3de5=_(_0x38c2cf)['keys']()['find'](function(_0x1f8ce3){return _0x1f8ce3===_0x16f170['field'];});if(_0x1f3de5)_0x1f3de5=_0x38c2cf[_0x16f170[_0xf975('0x43')]];if(!_0x1f3de5){if(_0x16f170[_0xf975('0x43')]===_0xf975('0x51')){var _0x45c1ed=_0x16f170[_0xf975('0x52')][_0xf975('0x53')](',')[_0xf975('0x54')](function(_0x13a723){return Number(_0x13a723);});_0x45c1ed['forEach'](function(_0xa8218b){_0x3904a7['or']('CONCAT(\x27,\x27,\x20`TagIds`,\x20\x27,\x27)\x20LIKE\x20?','%,'+_0xa8218b+',%');});_0xb97282=_[_0xf975('0x55')](_0xb97282,_0x45c1ed);}else if(_0x16f170[_0xf975('0x43')]===_0xf975('0x56')){_0x2f7a84[_0xf975('0x57')](_0xf975('0x58'),_0x16f170['value']);}}else{if(_0x16f170[_0xf975('0x43')]===_0xf975('0x59')||_0x1f3de5['fieldType']===_0xf975('0x5a'))_0x16f170['castTo']=_0xf975('0x5b');var _0x1c7e6b=as[_0xf975('0x5c')](_0x5c599f,_0x1f3de5[_0xf975('0x39')],_0x16f170);_0x2f7a84[_0x3d5030](_0x1c7e6b[_0xf975('0x5d')],_0x1c7e6b['value']['start'],_0x1c7e6b[_0xf975('0x52')][_0xf975('0x1d')]);}}}else{var _0x1f449f=_(Object['keys'](_0x2be08b[_0xf975('0x3b')]))[_0xf975('0x54')](function(_0x2f63fe){return _0x38c2cf[_0xf975('0x5e')](_0x2f63fe)?_0x2f63fe:undefined;})[_0xf975('0x5f')](function(_0x3bb0e5){return!_[_0xf975('0x60')](_0x3bb0e5);})[_0xf975('0x52')]();if(_0x2be08b[_0xf975('0x3b')][_0xf975('0x61')])_0x1f449f[_0xf975('0x34')]('Contact');if(!_[_0xf975('0x62')](_0x1f449f)){_0x1f449f[_0xf975('0x63')](function(_0x277454){if(_0x277454===_0xf975('0x64')){_0x58979c[_0xf975('0x40')](_0xf975('0x65'),[][_0xf975('0x66')](_0x2be08b[_0xf975('0x3b')][_0x277454]));}else if(_0x277454===_0xf975('0x61')){var _0x4cf0d0='%'+_0x2be08b[_0xf975('0x3b')][_0x277454]+'%';_0x58979c[_0xf975('0x40')](_0xf975('0x67'),_0x4cf0d0);}else{_0x58979c[_0xf975('0x40')]('c.'+_0x277454+_0xf975('0x68'),_0x2be08b[_0xf975('0x3b')][_0x277454]);}});}if(_0x2be08b[_0xf975('0x3b')][_0xf975('0x69')]){_0xb97282=_['isArray'](_0x2be08b[_0xf975('0x3b')][_0xf975('0x69')])?_0x2be08b[_0xf975('0x3b')]['tag']:new Array(_0x2be08b[_0xf975('0x3b')][_0xf975('0x69')]);_0xb97282[_0xf975('0x63')](function(_0x23768e){_0x3904a7['or'](_0xf975('0x6a'),'%,'+_0x23768e+',%');});}if(_0x2be08b[_0xf975('0x3b')][_0xf975('0x5f')]){var _0x2f2d10=_0x2be08b[_0xf975('0x3b')][_0xf975('0x5f')][_0xf975('0x6b')]('\x5c','\x5c\x5c')[_0xf975('0x6b')](/'/g,'\x27\x27');if(_0x2f2d10[_0xf975('0x53')]('\x20')[_0xf975('0x38')]>0x1){_0x2f7a84['or'](_0xf975('0x6c'),qs[_0xf975('0x6d')](_0x2f2d10),null);}else{if(qs['isNumeric'](_0x2f2d10)){_0x2f7a84['or'](_0xf975('0x6e'),_0x2f2d10+'%');_0x2f7a84['or'](_0xf975('0x6f'),_0x2f2d10+'%');_0x2f7a84['or'](_0xf975('0x70'),_0x2f2d10+'%');_0x2f7a84['or'](_0xf975('0x71'),_0x2f2d10+'%');}else if(qs['isEmail'](_0x2f2d10)){_0x2f7a84['or']('c.email\x20LIKE\x20?',_0x2f2d10+'%');}else{_0x2f7a84['or']('c.firstName\x20LIKE\x20?','%'+_0x2f2d10+'%');_0x2f7a84['or'](_0xf975('0x72'),'%'+_0x2f2d10+'%');_0x2f7a84['or'](_0xf975('0x73'),'%'+_0x2f2d10+'%');}}}}_0x58979c[_0xf975('0x40')](_0x2f7a84);_0x58979c['group'](_0xf975('0x74'));var _0x4cf923={'type':db[_0xf975('0x75')]['QueryTypes'][_0xf975('0x76')],'raw':!![]};var _0x2196fb=_0x58979c[_0xf975('0x77')]()[_0xf975('0x43')](_0xf975('0x74'));if(_0x2c16a9[_0xf975('0x78')]){_0x2c16a9[_0xf975('0x78')][_0xf975('0x63')](function(_0x2929cb){_0x58979c['order']('c.'+_0x2929cb[0x0],_0x2929cb[0x1]===_0xf975('0x79')?![]:!![]);});}if(!_[_0xf975('0x62')](_0xb97282)){_0x58979c['having'](_0x3904a7);_0x2196fb[_0xf975('0x40')](_0xf975('0x7a'),_0xb97282);}BPromise[_0xf975('0x7b')]()[_0xf975('0x29')](function(){if(!_0x4839c6)return;if(_0x2be08b[_0xf975('0x7c')][_0xf975('0x7d')]!=='agent')return;if(!_[_0xf975('0x7e')](_0x4839c6[_0xf975('0x50')],['field',_0xf975('0x56')])){return _0x2be08b[_0xf975('0x7c')][_0xf975('0x7f')]({'attributes':['id'],'raw':!![]})[_0xf975('0x29')](function(_0x1905dd){if(_[_0xf975('0x62')](_0x1905dd)){_0x2196fb[_0xf975('0x40')](_0xf975('0x80'));_0x58979c[_0xf975('0x40')]('c.ListId\x20IS\x20NULL');}else{_0x2196fb['where'](_0xf975('0x65'),_['map'](_0x1905dd,'id'));_0x58979c[_0xf975('0x40')](_0xf975('0x65'),_[_0xf975('0x54')](_0x1905dd,'id'));}});}})[_0xf975('0x29')](function(){if(_0x2be08b[_0xf975('0x7c')][_0xf975('0x7d')]===_0xf975('0x81')&&!_0x4839c6&&!_0x2be08b['query'][_0xf975('0x64')])return[];return db[_0xf975('0x82')][_0xf975('0x3b')](_0x2196fb[_0xf975('0x83')](),_0x4cf923);})[_0xf975('0x29')](function(_0x4abe0e){_0x3af636[_0xf975('0x20')]=_0x4abe0e[_0xf975('0x38')];if(_0x3af636['count']===0x0)return[];return db[_0xf975('0x82')][_0xf975('0x3b')](_0x38a8de[_0xf975('0x83')](),_0x4cf923)[_0xf975('0x29')](function(_0x358c0e){_0x4fbf54=_[_0xf975('0x84')](_0x358c0e,'id');_0x4cf923=_[_0xf975('0x85')](_0x4cf923,{'model':db[_0xf975('0x30')],'mapToModel':!![],'raw':!![],'nest':!![]});if(_0x2be08b['query']['fields']){_0x2c16a9['attributes'][_0xf975('0x63')](function(_0x27002f){_0x58979c[_0xf975('0x43')]('c.'+_0x27002f);});}else{_0x58979c[_0xf975('0x43')](_0xf975('0x74'));_0x58979c[_0xf975('0x43')]('c.firstName');_0x58979c[_0xf975('0x43')](_0xf975('0x86'));_0x58979c[_0xf975('0x43')](_0xf975('0x87'));_0x58979c['field']('c.mobile');_0x58979c[_0xf975('0x43')](_0xf975('0x88'));_0x58979c[_0xf975('0x43')](_0xf975('0x89'));_0x58979c[_0xf975('0x43')](_0xf975('0x8a'));_0x58979c[_0xf975('0x43')](_0xf975('0x8b'));_0x58979c['field'](_0xf975('0x8c'));_0x58979c[_0xf975('0x43')](_0xf975('0x8d'));_0x58979c[_0xf975('0x43')]('GROUP_CONCAT(DISTINCT\x20t.id)',_0xf975('0x8e'));}if(_0x2c16a9[_0xf975('0x22')])_0x58979c[_0xf975('0x22')](_0x2c16a9['limit']);if(_0x2c16a9[_0xf975('0x21')])_0x58979c[_0xf975('0x21')](_0x2c16a9[_0xf975('0x21')]);return db[_0xf975('0x82')][_0xf975('0x3b')](_0x58979c[_0xf975('0x83')](),_0x4cf923);});})[_0xf975('0x29')](function(_0x112539){_0x112539[_0xf975('0x63')](function(_0xf94641){if(_0xf94641['TagIds']){_0xf94641[_0xf975('0x8f')]=[];_0xf94641[_0xf975('0x8e')]['split'](',')[_0xf975('0x63')](function(_0x756cce){_0xf94641[_0xf975('0x8f')][_0xf975('0x34')](_0x4fbf54[_0x756cce]);});}delete _0xf94641['TagIds'];});_0x3af636[_0xf975('0x90')]=_0x112539;return _0x3af636;})[_0xf975('0x29')](respondWithFilteredResult(_0x2394de,_0x2c16a9));})[_0xf975('0x91')](handleError(_0x2394de,null));};exports[_0xf975('0x2a')]=function(_0x1d8581,_0x3d659d){return db[_0xf975('0x30')][_0xf975('0x92')]({'where':{'id':_0x1d8581[_0xf975('0x93')]['id']}})['then'](handleEntityNotFound(_0x3d659d,null))['then'](removeEntity(_0x3d659d,null))[_0xf975('0x91')](handleError(_0x3d659d,null));};exports[_0xf975('0x31')]=function(_0x347438,_0x110b23){return db[_0xf975('0x30')][_0xf975('0x31')]()[_0xf975('0x29')](function(_0x3b8727){delete _0x3b8727[_0xf975('0x94')];for(var _0x403047=0x0;_0x403047<Object['keys'](_0x3b8727)[_0xf975('0x38')];_0x403047++){var _0x29e8bb=Object['keys'](_0x3b8727)[_0x403047];if(!_[_0xf975('0x95')](_0x29e8bb,_0xf975('0x33'))){_0x3b8727[_0x29e8bb]['columnName']=_0x29e8bb;_0x3b8727[_0x29e8bb]['displayName']=_0x29e8bb;}}return _0x3b8727;})[_0xf975('0x29')](function(_0x3eccb1){var _0x1e1d5b={'where':{'$or':[{'ListId':_0x347438[_0xf975('0x3b')]['id']},{'ListId':null}]},'raw':!![]};return db[_0xf975('0x35')][_0xf975('0x96')](_0x1e1d5b)[_0xf975('0x29')](function(_0x4092a0){for(var _0x1532f0=0x0;_0x1532f0<_0x4092a0[_0xf975('0x38')];_0x1532f0++){var _0x5a3546=_0xf975('0x33')+_0x4092a0[_0x1532f0]['id'];_0x3eccb1[_0x5a3546][_0xf975('0x97')]=_0x5a3546;_0x3eccb1[_0x5a3546][_0xf975('0x98')]=_0x4092a0[_0x1532f0][_0xf975('0x99')];_0x3eccb1[_0x5a3546][_0xf975('0x9a')]={'type':_0x4092a0[_0x1532f0][_0xf975('0x39')],'values':_0x4092a0[_0x1532f0]['values']};}Object[_0xf975('0x32')](_0x3eccb1)['forEach'](function(_0x53b149){if(!_0x3eccb1[_0x53b149][_0xf975('0x5e')](_0xf975('0x97'))){delete _0x3eccb1[_0x53b149];}});return _0x3eccb1;});})['then'](respondWithResult(_0x110b23,null))[_0xf975('0x91')](handleError(_0x110b23,null));};exports[_0xf975('0x85')]=function(_0x760e9f,_0xcd9efc){var _0x5365cb;var _0x159703;var _0xa361a4;if(_0x760e9f[_0xf975('0x9b')]['id']){delete _0x760e9f[_0xf975('0x9b')]['id'];}return db[_0xf975('0x30')]['findAll']({'where':{'id':[_0x760e9f[_0xf975('0x9b')]['to'],_0x760e9f['body'][_0xf975('0x45')]]}})['then'](function(_0x51285f){if(_0x51285f){if(_0x51285f[_0xf975('0x38')]!==0x2){return null;}_0x51285f[0x0]=_0x51285f[0x0][_0xf975('0x9c')]({'plain':!![]});_0x51285f[0x1]=_0x51285f[0x1][_0xf975('0x9c')]({'plain':!![]});delete _0x51285f[0x0]['id'];delete _0x51285f[0x1]['id'];return _[_0xf975('0x9d')](_0x51285f[0x0],_0x51285f[0x1],function(_0x51f71d,_0xa3787f){if(Array[_0xf975('0x9e')](_0xa3787f)&&!_0xa3787f[_0xf975('0x38')]){return _0x51f71d;}else if(!_0xa3787f){return _0x51f71d;}});}})[_0xf975('0x29')](handleEntityNotFound(_0xcd9efc,null))['then'](function(_0x60bb70){if(_0x60bb70){if(_0x60bb70[_0xf975('0x94')]&&_['isArray'](_0x60bb70['tags'])){_0x60bb70['tags']=_0x60bb70[_0xf975('0x94')][_0xf975('0x9f')]();}logger['info'](_0xf975('0xa0'),_0x760e9f[_0xf975('0x9b')]['to'],_0x760e9f['body']['from']);return db['CmHopper'][_0xf975('0x2a')]({'where':{'ContactId':[_0x760e9f[_0xf975('0x9b')]['to'],_0x760e9f[_0xf975('0x9b')][_0xf975('0x45')]]}})[_0xf975('0x29')](function(_0x59875f){logger[_0xf975('0xa1')](_0xf975('0xa2'),_0x59875f);return db[_0xf975('0xa3')][_0xf975('0x2a')]({'where':{'ContactId':[_0x760e9f[_0xf975('0x9b')]['to'],_0x760e9f[_0xf975('0x9b')][_0xf975('0x45')]]}})[_0xf975('0x29')](function(_0x137378){logger[_0xf975('0xa1')](_0xf975('0xa4'),_0x137378);return db[_0xf975('0x30')][_0xf975('0xa5')](_0x60bb70);});});}})[_0xf975('0x29')](function(_0x5fa4e1){if(_0x5fa4e1){_0x5365cb=_0x5fa4e1;_0x159703={'ContactId':_0x5365cb['id']};_0xa361a4={'where':{'ContactId':[_0x760e9f[_0xf975('0x9b')]['to'],_0x760e9f[_0xf975('0x9b')][_0xf975('0x45')]]}};return db[_0xf975('0xa6')]['update'](_0x159703,_0xa361a4);}})[_0xf975('0x29')](function(){if(_0x5365cb){return db[_0xf975('0xa7')][_0xf975('0x28')](_0x159703,_0xa361a4);}})[_0xf975('0x29')](function(){if(_0x5365cb){return db[_0xf975('0xa8')][_0xf975('0x28')](_0x159703,_0xa361a4);}})['then'](function(){if(_0x5365cb){return db['MailInteraction'][_0xf975('0x28')](_0x159703,_0xa361a4);}})[_0xf975('0x29')](function(){if(_0x5365cb){return db[_0xf975('0xa9')]['update'](_0x159703,_0xa361a4);}})[_0xf975('0x29')](function(){if(_0x5365cb){return db[_0xf975('0xaa')][_0xf975('0x28')](_0x159703,_0xa361a4);}})[_0xf975('0x29')](function(){if(_0x5365cb){return db[_0xf975('0xa9')][_0xf975('0x28')](_0x159703,_0xa361a4);}})[_0xf975('0x29')](function(){if(_0x5365cb){return db[_0xf975('0xab')][_0xf975('0x28')](_0x159703,_0xa361a4);}})[_0xf975('0x29')](function(){if(_0x5365cb){return db[_0xf975('0xac')][_0xf975('0x28')](_0x159703,_0xa361a4);}})[_0xf975('0x29')](function(){if(_0x5365cb){return db['FaxInteraction'][_0xf975('0x28')](_0x159703,_0xa361a4);}})[_0xf975('0x29')](function(){if(_0x5365cb){return db[_0xf975('0xad')][_0xf975('0x28')](_0x159703,_0xa361a4);}})[_0xf975('0x29')](function(){if(_0x5365cb){return db[_0xf975('0xae')][_0xf975('0x28')](_0x159703,_0xa361a4);}})['then'](function(){if(_0x5365cb){return db[_0xf975('0xaf')]['update'](_0x159703,_0xa361a4);}})[_0xf975('0x29')](function(){if(_0x5365cb){return db[_0xf975('0xb0')][_0xf975('0x28')](_0x159703,_0xa361a4);}})[_0xf975('0x29')](function(){if(_0x5365cb){return db[_0xf975('0xb1')][_0xf975('0x28')](_0x159703,_0xa361a4);}})['then'](function(){if(_0x5365cb){return db[_0xf975('0xb2')]['update'](_0x159703,_0xa361a4);}})[_0xf975('0x29')](function(){if(_0x5365cb){return db[_0xf975('0xb3')][_0xf975('0x28')](_0x159703,_0xa361a4);}})[_0xf975('0x29')](function(){if(_0x5365cb){return db['ChatQueueReport'][_0xf975('0x28')](_0x159703,_0xa361a4);}})['then'](function(){if(_0x5365cb){return db[_0xf975('0xb4')][_0xf975('0x28')](_0x159703,_0xa361a4);}})['then'](function(){if(_0x5365cb){return db['MailQueueReport'][_0xf975('0x28')](_0x159703,_0xa361a4);}})[_0xf975('0x29')](function(){if(_0x5365cb){return db[_0xf975('0xb5')][_0xf975('0x28')](_0x159703,_0xa361a4);}})[_0xf975('0x29')](function(){if(_0x5365cb){return db['SmsQueueReport']['update'](_0x159703,_0xa361a4);}})['then'](function(){if(_0x5365cb){return db[_0xf975('0xb6')][_0xf975('0x28')](_0x159703,_0xa361a4);}})[_0xf975('0x29')](function(){if(_0x5365cb){return db['CmContact'][_0xf975('0x2a')]({'where':{'id':[_0x760e9f[_0xf975('0x9b')]['to'],_0x760e9f[_0xf975('0x9b')][_0xf975('0x45')]]}});}})[_0xf975('0x29')](function(){if(_0x5365cb){return _0x5365cb;}})['then'](respondWithResult(_0xcd9efc,null))[_0xf975('0x91')](handleError(_0xcd9efc,null));};exports[_0xf975('0xa5')]=function(_0x12d5a1,_0x412cd0){return db[_0xf975('0x30')]['describe']()[_0xf975('0x29')](function(_0x1d43ea){if(_0x12d5a1['body'][_0xf975('0x94')]&&_[_0xf975('0x9e')](_0x12d5a1[_0xf975('0x9b')][_0xf975('0x94')])){if(_0x12d5a1[_0xf975('0x9b')][_0xf975('0x94')]['length']){_0x12d5a1[_0xf975('0x9b')][_0xf975('0x94')]=_0x12d5a1[_0xf975('0x9b')][_0xf975('0x94')]['join'](';')+';';}else{_0x12d5a1['body']['tags']=null;}}else{_0x12d5a1[_0xf975('0x9b')][_0xf975('0x94')]=null;}return db[_0xf975('0x30')][_0xf975('0xa5')](_0x12d5a1[_0xf975('0x9b')],{'fields':_[_0xf975('0x32')](_0x1d43ea),'raw':!![]});})[_0xf975('0x29')](respondWithResult(_0x412cd0,0xc9))[_0xf975('0x91')](handleError(_0x412cd0,null));};exports['bulkCreate']=function(_0x1d8e4c,_0x8a3466){var _0x453980=[];var _0x33b794=0x0;var _0x55617e=0x0;var _0x275907=0x0;return db[_0xf975('0x30')]['describe']()['then'](function(_0x12ce0c){return BPromise[_0xf975('0xb7')](_0x1d8e4c[_0xf975('0x9b')],function(_0x2d4991){var _0x1425d2={'where':{'$or':[]},'defaults':_0x2d4991,'fields':_[_0xf975('0x32')](_0x12ce0c),'raw':!![]};if(_0x2d4991['duplicates']){for(var _0x292d05=0x0;_0x292d05<_0x2d4991['duplicates'][_0xf975('0x38')];_0x292d05++){var _0x5cdb06={};_0x5cdb06[_0x2d4991['duplicates'][_0x292d05]]=_0x2d4991[_0x2d4991['duplicates'][_0x292d05]];_0x1425d2[_0xf975('0x40')][_0xf975('0xb8')][_0xf975('0x34')](_0x5cdb06);}_0x1425d2[_0xf975('0x40')][_0xf975('0x64')]=_0x2d4991['ListId'];}return db[_0xf975('0x30')]['findOrCreate'](_0x1425d2)[_0xf975('0xb9')](function(_0x482120,_0x34396c){if(_0x34396c){_0x33b794++;}else{_0x275907++;}})['catch'](function(_0x3930c2){console['error'](_0x3930c2);_0x55617e++;});});})['then'](function(_0x21ee31){if(_0x21ee31){return{'success':_0x33b794,'failure':_0x55617e,'duplicates':_0x275907};}})['then'](respondWithResult(_0x8a3466,0xc9))['catch'](handleError(_0x8a3466,null));};exports[_0xf975('0xba')]=function(_0x3273d8,_0x3d4589,_0x5df3c0){var _0x10808d;return db['CmContact'][_0xf975('0x31')]()[_0xf975('0x29')](function(_0x5c292f){return db[_0xf975('0x30')][_0xf975('0x92')]({'where':{'id':_0x3273d8[_0xf975('0x93')]['id']},'include':[{'model':db[_0xf975('0x51')],'as':_0xf975('0x8f'),'attributes':['id',_0xf975('0x2d'),'color'],'required':_0x3273d8[_0xf975('0x3b')][_0xf975('0x69')]?!![]:![]}],'attributes':_['keys'](_0x5c292f)});})[_0xf975('0x29')](function(_0xd04e85){_0x10808d=_0xd04e85['get']({'plain':!![]});var _0x280ce4={'where':{'$and':[{'ListId':{'$ne':null}}]}};if(_0xd04e85&&_0xd04e85[_0xf975('0x64')]){if(_0xd04e85[_0xf975('0x64')]){_0x280ce4[_0xf975('0x40')][_0xf975('0xbb')][_0xf975('0x34')]({'ListId':{'$ne':_0xd04e85[_0xf975('0x64')]}});}}return db[_0xf975('0x35')]['findAll'](_0x280ce4);})[_0xf975('0x29')](function(_0x139a21){return _['omit'](_0x10808d,_[_0xf975('0x54')](_0x139a21,function(_0x5dfbec){return util[_0xf975('0xbc')](_0xf975('0xbd'),_0x5dfbec['id']);}));})[_0xf975('0x29')](handleEntityNotFound(_0x3d4589,null))[_0xf975('0x29')](respondWithResult(_0x3d4589,null))[_0xf975('0x91')](handleError(_0x3d4589,null));};exports['update']=function(_0x15b0e4,_0x1e92db){var _0x177648;if(_0x15b0e4[_0xf975('0x9b')]['id']){delete _0x15b0e4[_0xf975('0x9b')]['id'];}return db['CmContact'][_0xf975('0x92')]({'where':{'id':_0x15b0e4[_0xf975('0x93')]['id']}})[_0xf975('0x29')](handleEntityNotFound(_0x1e92db,null))[_0xf975('0x29')](saveUpdates(_0x15b0e4[_0xf975('0x9b')],null))[_0xf975('0x29')](function(_0x55ad66){_0x177648=_0x55ad66;var _0xba22ca={'where':{'$and':[{'ListId':{'$ne':null}}]}};if(_0x55ad66&&_0x55ad66[_0xf975('0x64')]){if(_0x55ad66[_0xf975('0x64')]){_0xba22ca['where'][_0xf975('0xbb')][_0xf975('0x34')]({'ListId':{'$ne':_0x55ad66[_0xf975('0x64')]}});}}return db[_0xf975('0x35')][_0xf975('0x96')](_0xba22ca);})['then'](function(_0x160699){if(_0x160699){return _[_0xf975('0xbe')](_[_0xf975('0xbf')](_0x15b0e4['body'],function(_0x5a1896,_0x2bbc84){return _[_0xf975('0x95')](_0x2bbc84,_0xf975('0x33'));}),_[_0xf975('0x54')](_0x160699,function(_0x466154){return util[_0xf975('0xbc')](_0xf975('0xbd'),_0x466154['id']);}));}})[_0xf975('0x29')](function(_0x2ce4c3){if(_0x2ce4c3&&!_[_0xf975('0x62')](_0x2ce4c3)){var _0x32480d=squel[_0xf975('0x28')]()['table'](_0xf975('0x47'))[_0xf975('0xc0')](_0x2ce4c3)[_0xf975('0x40')](_0xf975('0xc1'),_0x15b0e4['params']['id'])[_0xf975('0xc2')]();return db[_0xf975('0x82')]['query'](_0x32480d[_0xf975('0x5d')],{'replacements':_0x32480d['values']});}})['then'](function(){if(_0x15b0e4[_0xf975('0x9b')]['phone']&&_0x177648){return db[_0xf975('0xc3')][_0xf975('0x28')]({'phone':_0x15b0e4['body'][_0xf975('0xc4')]},{'where':{'ContactId':_0x177648['id']}});}})['then'](function(){return _0x177648;})[_0xf975('0x29')](respondWithResult(_0x1e92db,null))[_0xf975('0x91')](handleError(_0x1e92db,null));};exports[_0xf975('0xc5')]=function(_0x50fcfb,_0x421e9e,_0x23d9bf){var _0x28eb37={};var _0xcac29b={};var _0xc1e78f;var _0x29ab3e;return db[_0xf975('0x30')][_0xf975('0xc6')]({'where':{'id':_0x50fcfb[_0xf975('0x93')]['id']}})[_0xf975('0x29')](handleEntityNotFound(_0x421e9e,null))[_0xf975('0x29')](function(_0x15da12){if(_0x15da12){_0xc1e78f=_0x15da12;_0xcac29b[_0xf975('0x3a')]=_['keys'](db[_0xf975('0x51')][_0xf975('0xc7')]);_0xcac29b[_0xf975('0x3b')]=_[_0xf975('0x32')](_0x50fcfb['query']);_0xcac29b[_0xf975('0x41')]=_['intersection'](_0xcac29b['model'],_0xcac29b[_0xf975('0x3b')]);_0x28eb37[_0xf975('0x3e')]=_[_0xf975('0x3c')](_0xcac29b[_0xf975('0x3a')],qs['fields'](_0x50fcfb[_0xf975('0x3b')][_0xf975('0x3d')]));_0x28eb37['attributes']=_0x28eb37[_0xf975('0x3e')][_0xf975('0x38')]?_0x28eb37[_0xf975('0x3e')]:_0xcac29b[_0xf975('0x3a')];_0x28eb37[_0xf975('0x78')]=qs[_0xf975('0x3f')](_0x50fcfb[_0xf975('0x3b')][_0xf975('0x3f')]);_0x28eb37[_0xf975('0x40')]=qs['filters'](_[_0xf975('0xc8')](_0x50fcfb[_0xf975('0x3b')],_0xcac29b[_0xf975('0x41')]));if(_0x50fcfb[_0xf975('0x3b')][_0xf975('0x5f')]){_0x28eb37[_0xf975('0x40')]=_[_0xf975('0x85')](_0x28eb37[_0xf975('0x40')],{'$or':_[_0xf975('0x54')](_0x28eb37[_0xf975('0x3e')],function(_0x34d324){var _0x3aba39={};_0x3aba39[_0x34d324]={'$like':'%'+_0x50fcfb[_0xf975('0x3b')][_0xf975('0x5f')]+'%'};return _0x3aba39;})});}_0x28eb37=_[_0xf975('0x85')]({},_0x28eb37,_0x50fcfb[_0xf975('0xc9')]);return _0xc1e78f[_0xf975('0xc5')](_0x28eb37);}})[_0xf975('0x29')](function(_0x9be357){if(_0x9be357){_0x29ab3e=_0x9be357['length'];if(!_0x50fcfb[_0xf975('0x3b')][_0xf975('0x5e')](_0xf975('0xca'))){_0x28eb37[_0xf975('0x22')]=qs[_0xf975('0x22')](_0x50fcfb['query'][_0xf975('0x22')]);_0x28eb37['offset']=qs[_0xf975('0x21')](_0x50fcfb[_0xf975('0x3b')][_0xf975('0x21')]);}return _0xc1e78f[_0xf975('0xc5')](_0x28eb37);}})['then'](function(_0x4afbb1){if(_0x4afbb1){return _0x4afbb1?{'count':_0x29ab3e,'rows':_0x4afbb1}:null;}})[_0xf975('0x29')](respondWithResult(_0x421e9e,null))[_0xf975('0x91')](handleError(_0x421e9e,null));};exports[_0xf975('0xcb')]=function(_0x57cac4,_0x12cf7f,_0x1ba64c){if(_0x57cac4['body']['id']){delete _0x57cac4[_0xf975('0x9b')]['id'];}return db[_0xf975('0x30')][_0xf975('0xc6')]({'where':{'id':_0x57cac4[_0xf975('0x93')]['id']}})[_0xf975('0x29')](handleEntityNotFound(_0x12cf7f,null))[_0xf975('0x29')](function(_0x21a153){if(_0x21a153){return _0x21a153['setTags'](_0x57cac4[_0xf975('0x9b')][_0xf975('0xcc')]||[]);}return null;})['then'](respondWithResult(_0x12cf7f,null))[_0xf975('0x91')](handleError(_0x12cf7f,null));};exports[_0xf975('0xcd')]=function(_0xb16743,_0x158953,_0x63b907){var _0x5aa851={'raw':![],'where':{}};var _0x56014c={};var _0x182b6b={'count':0x0,'rows':[]};return db['CmContact'][_0xf975('0xc6')]({'where':{'id':_0xb16743[_0xf975('0x93')]['id']}})['then'](handleEntityNotFound(_0x158953,null))[_0xf975('0x29')](function(_0x5dd727){if(_0x5dd727){_0x56014c[_0xf975('0x3a')]=_[_0xf975('0x32')](db[_0xf975('0xc3')][_0xf975('0xc7')]);_0x56014c[_0xf975('0x3b')]=_[_0xf975('0x32')](_0xb16743['query']);_0x56014c[_0xf975('0x41')]=_[_0xf975('0x3c')](_0x56014c[_0xf975('0x3a')],_0x56014c[_0xf975('0x3b')]);_0x5aa851['attributes']=_['intersection'](_0x56014c[_0xf975('0x3a')],qs[_0xf975('0x3d')](_0xb16743['query'][_0xf975('0x3d')]));_0x5aa851[_0xf975('0x3e')]=_0x5aa851[_0xf975('0x3e')][_0xf975('0x38')]?_0x5aa851[_0xf975('0x3e')]:_0x56014c[_0xf975('0x3a')];if(!_0xb16743[_0xf975('0x3b')]['hasOwnProperty'](_0xf975('0xca'))){_0x5aa851[_0xf975('0x22')]=qs[_0xf975('0x22')](_0xb16743[_0xf975('0x3b')]['limit']);_0x5aa851[_0xf975('0x21')]=qs['offset'](_0xb16743[_0xf975('0x3b')][_0xf975('0x21')]);}_0x5aa851[_0xf975('0x78')]=qs[_0xf975('0x3f')](_0xb16743['query']['sort']);_0x5aa851['where']=qs[_0xf975('0x41')](_[_0xf975('0xc8')](_0xb16743[_0xf975('0x3b')],_0x56014c['filters']));_0x5aa851[_0xf975('0x40')][_0xf975('0xce')]=_0x5dd727['id'];if(_0xb16743[_0xf975('0x3b')]['filter']){_0x5aa851[_0xf975('0x40')]=_['merge'](_0x5aa851[_0xf975('0x40')],{'$or':_[_0xf975('0x54')](_0x5aa851[_0xf975('0x3e')],function(_0x32b064){var _0x163fdd={};_0x163fdd[_0x32b064]={'$like':'%'+_0xb16743[_0xf975('0x3b')][_0xf975('0x5f')]+'%'};return _0x163fdd;})});}_0x5aa851=_['merge']({},_0x5aa851,_0xb16743[_0xf975('0xc9')]);return db[_0xf975('0xc3')][_0xf975('0x20')]({'where':_0x5aa851[_0xf975('0x40')]})['then'](function(_0x5c533c){_0x182b6b[_0xf975('0x20')]=_0x5c533c;if(_0xb16743[_0xf975('0x3b')][_0xf975('0xcf')]){_0x5aa851[_0xf975('0xd0')]=[{'all':!![]}];}return db[_0xf975('0xc3')][_0xf975('0x96')](_0x5aa851);})['then'](function(_0x212a47){_0x182b6b['rows']=_0x212a47;return _0x182b6b;});}})['then'](respondWithFilteredResult(_0x158953,_0x5aa851))['catch'](handleError(_0x158953,null));};exports['getHopperHistories']=function(_0x2de3fc,_0x298e6c,_0x53bc09){var _0x568f63={'raw':!![],'where':{}};var _0x1a26e4={};var _0x490174={'count':0x0,'rows':[]};return db['CmContact']['findOne']({'where':{'id':_0x2de3fc[_0xf975('0x93')]['id']}})[_0xf975('0x29')](handleEntityNotFound(_0x298e6c,null))[_0xf975('0x29')](function(_0x40c1d6){if(_0x40c1d6){_0x1a26e4[_0xf975('0x3a')]=_[_0xf975('0x32')](db['CmHopperHistory']['rawAttributes']);_0x1a26e4[_0xf975('0x3b')]=_[_0xf975('0x32')](_0x2de3fc[_0xf975('0x3b')]);_0x1a26e4[_0xf975('0x41')]=_['intersection'](_0x1a26e4['model'],_0x1a26e4[_0xf975('0x3b')]);_0x568f63[_0xf975('0x3e')]=_[_0xf975('0x3c')](_0x1a26e4[_0xf975('0x3a')],qs['fields'](_0x2de3fc[_0xf975('0x3b')][_0xf975('0x3d')]));_0x568f63['attributes']=_0x568f63['attributes'][_0xf975('0x38')]?_0x568f63[_0xf975('0x3e')]:_0x1a26e4[_0xf975('0x3a')];if(!_0x2de3fc['query'][_0xf975('0x5e')](_0xf975('0xca'))){_0x568f63[_0xf975('0x22')]=qs['limit'](_0x2de3fc[_0xf975('0x3b')][_0xf975('0x22')]);_0x568f63[_0xf975('0x21')]=qs[_0xf975('0x21')](_0x2de3fc[_0xf975('0x3b')][_0xf975('0x21')]);}_0x568f63['order']=qs['sort'](_0x2de3fc[_0xf975('0x3b')][_0xf975('0x3f')]);_0x568f63[_0xf975('0x40')]=qs[_0xf975('0x41')](_['pick'](_0x2de3fc[_0xf975('0x3b')],_0x1a26e4[_0xf975('0x41')]));_0x568f63[_0xf975('0x40')][_0xf975('0xce')]=_0x40c1d6['id'];if(_0x2de3fc[_0xf975('0x3b')][_0xf975('0x5f')]){_0x568f63[_0xf975('0x40')]=_[_0xf975('0x85')](_0x568f63['where'],{'$or':_['map'](_0x568f63[_0xf975('0x3e')],function(_0xe1107f){var _0x1c0ab5={};_0x1c0ab5[_0xe1107f]={'$like':'%'+_0x2de3fc[_0xf975('0x3b')][_0xf975('0x5f')]+'%'};return _0x1c0ab5;})});}_0x568f63=_['merge']({},_0x568f63,_0x2de3fc[_0xf975('0xc9')]);return db[_0xf975('0xb1')][_0xf975('0x20')]({'where':_0x568f63[_0xf975('0x40')]})['then'](function(_0x376010){_0x490174['count']=_0x376010;if(_0x2de3fc[_0xf975('0x3b')][_0xf975('0xcf')]){_0x568f63['include']=[{'all':!![]}];}return db['CmHopperHistory']['findAll'](_0x568f63);})[_0xf975('0x29')](function(_0x54814a){_0x490174[_0xf975('0x90')]=_0x54814a;return _0x490174;});}})['then'](respondWithFilteredResult(_0x298e6c,_0x568f63))[_0xf975('0x91')](handleError(_0x298e6c,null));};exports[_0xf975('0xd1')]=function(_0xf80911,_0x9b9c74,_0x17c56c){var _0x5eccba={'raw':!![],'where':{}};var _0xdd094d={};var _0x4bffe8={'count':0x0,'rows':[]};return db[_0xf975('0x30')]['findOne']({'where':{'id':_0xf80911['params']['id']}})[_0xf975('0x29')](handleEntityNotFound(_0x9b9c74,null))['then'](function(_0xe6b36b){if(_0xe6b36b){_0xdd094d[_0xf975('0x3a')]=_[_0xf975('0x32')](db[_0xf975('0xb0')]['rawAttributes']);_0xdd094d[_0xf975('0x3b')]=_[_0xf975('0x32')](_0xf80911[_0xf975('0x3b')]);_0xdd094d[_0xf975('0x41')]=_[_0xf975('0x3c')](_0xdd094d[_0xf975('0x3a')],_0xdd094d[_0xf975('0x3b')]);_0x5eccba[_0xf975('0x3e')]=_['intersection'](_0xdd094d['model'],qs[_0xf975('0x3d')](_0xf80911[_0xf975('0x3b')][_0xf975('0x3d')]));_0x5eccba[_0xf975('0x3e')]=_0x5eccba[_0xf975('0x3e')][_0xf975('0x38')]?_0x5eccba[_0xf975('0x3e')]:_0xdd094d[_0xf975('0x3a')];if(!_0xf80911['query'][_0xf975('0x5e')]('nolimit')){_0x5eccba['limit']=qs['limit'](_0xf80911['query'][_0xf975('0x22')]);_0x5eccba[_0xf975('0x21')]=qs[_0xf975('0x21')](_0xf80911[_0xf975('0x3b')][_0xf975('0x21')]);}_0x5eccba['order']=qs[_0xf975('0x3f')](_0xf80911[_0xf975('0x3b')][_0xf975('0x3f')]);_0x5eccba[_0xf975('0x40')]=qs['filters'](_[_0xf975('0xc8')](_0xf80911[_0xf975('0x3b')],_0xdd094d[_0xf975('0x41')]));_0x5eccba['where'][_0xf975('0xce')]=_0xe6b36b['id'];if(_0xf80911['query'][_0xf975('0x5f')]){_0x5eccba['where']=_[_0xf975('0x85')](_0x5eccba['where'],{'$or':_['map'](_0x5eccba[_0xf975('0x3e')],function(_0x526a90){var _0x289f07={};_0x289f07[_0x526a90]={'$like':'%'+_0xf80911[_0xf975('0x3b')]['filter']+'%'};return _0x289f07;})});}_0x5eccba=_[_0xf975('0x85')]({},_0x5eccba,_0xf80911[_0xf975('0xc9')]);return db[_0xf975('0xb0')][_0xf975('0x20')]({'where':_0x5eccba[_0xf975('0x40')]})[_0xf975('0x29')](function(_0x2b0bb0){_0x4bffe8[_0xf975('0x20')]=_0x2b0bb0;if(_0xf80911[_0xf975('0x3b')]['includeAll']){_0x5eccba['include']=[{'all':!![]}];}return db[_0xf975('0xb0')][_0xf975('0x96')](_0x5eccba);})[_0xf975('0x29')](function(_0x2d279d){_0x4bffe8[_0xf975('0x90')]=_0x2d279d;return _0x4bffe8;});}})[_0xf975('0x29')](respondWithFilteredResult(_0x9b9c74,_0x5eccba))[_0xf975('0x91')](handleError(_0x9b9c74,null));};exports[_0xf975('0xd2')]=function(_0x437578,_0x2be1fa,_0x4d9b05){var _0x81a4f9={'raw':!![],'where':{}};var _0x7fa04e={};var _0x138796={'count':0x0,'rows':[]};return db['CmContact'][_0xf975('0xc6')]({'where':{'id':_0x437578[_0xf975('0x93')]['id']}})[_0xf975('0x29')](handleEntityNotFound(_0x2be1fa,null))[_0xf975('0x29')](function(_0x2fc9d0){if(_0x2fc9d0){_0x7fa04e[_0xf975('0x3a')]=_[_0xf975('0x32')](db[_0xf975('0xb6')]['rawAttributes']);_0x7fa04e[_0xf975('0x3b')]=_[_0xf975('0x32')](_0x437578['query']);_0x7fa04e[_0xf975('0x41')]=_[_0xf975('0x3c')](_0x7fa04e[_0xf975('0x3a')],_0x7fa04e[_0xf975('0x3b')]);_0x81a4f9[_0xf975('0x3e')]=_[_0xf975('0x3c')](_0x7fa04e[_0xf975('0x3a')],qs['fields'](_0x437578[_0xf975('0x3b')][_0xf975('0x3d')]));_0x81a4f9['attributes']=_0x81a4f9[_0xf975('0x3e')][_0xf975('0x38')]?_0x81a4f9[_0xf975('0x3e')]:_0x7fa04e[_0xf975('0x3a')];if(!_0x437578[_0xf975('0x3b')][_0xf975('0x5e')](_0xf975('0xca'))){_0x81a4f9[_0xf975('0x22')]=qs[_0xf975('0x22')](_0x437578[_0xf975('0x3b')][_0xf975('0x22')]);_0x81a4f9['offset']=qs[_0xf975('0x21')](_0x437578[_0xf975('0x3b')][_0xf975('0x21')]);}_0x81a4f9[_0xf975('0x78')]=qs[_0xf975('0x3f')](_0x437578[_0xf975('0x3b')][_0xf975('0x3f')]);_0x81a4f9[_0xf975('0x40')]=qs[_0xf975('0x41')](_[_0xf975('0xc8')](_0x437578[_0xf975('0x3b')],_0x7fa04e[_0xf975('0x41')]));_0x81a4f9[_0xf975('0x40')][_0xf975('0xce')]=_0x2fc9d0['id'];if(_0x437578[_0xf975('0x3b')][_0xf975('0x5f')]){_0x81a4f9[_0xf975('0x40')]=_[_0xf975('0x85')](_0x81a4f9[_0xf975('0x40')],{'$or':_[_0xf975('0x54')](_0x81a4f9['attributes'],function(_0x187046){var _0x3d6381={};_0x3d6381[_0x187046]={'$like':'%'+_0x437578[_0xf975('0x3b')][_0xf975('0x5f')]+'%'};return _0x3d6381;})});}_0x81a4f9=_[_0xf975('0x85')]({},_0x81a4f9,_0x437578['options']);return db[_0xf975('0xb6')]['count']({'where':_0x81a4f9['where']})[_0xf975('0x29')](function(_0x4eb14b){_0x138796[_0xf975('0x20')]=_0x4eb14b;if(_0x437578['query'][_0xf975('0xcf')]){_0x81a4f9['include']=[{'all':!![]}];}return db['JscriptySessionReport'][_0xf975('0x96')](_0x81a4f9);})[_0xf975('0x29')](function(_0x3a06aa){_0x138796['rows']=_0x3a06aa;return _0x138796;});}})[_0xf975('0x29')](respondWithFilteredResult(_0x2be1fa,_0x81a4f9))[_0xf975('0x91')](handleError(_0x2be1fa,null));};exports[_0xf975('0xd3')]=function(_0x347de9,_0x219e58,_0x38cd03){try{if(!_0x347de9[_0xf975('0x9b')][_0xf975('0x64')]){throw new Error(_0xf975('0xd4'));}if(!_0x347de9['body'][_0xf975('0xd5')]){throw new Error('No\x20association\x20keys\x20specified!');}if(!_0x347de9[_0xf975('0x9b')][_0xf975('0xd6')]){throw new Error(_0xf975('0xd7'));}if(!_0x347de9['body'][_0xf975('0xd8')]){throw new Error('Unable\x20to\x20synchronize\x20socket,\x20no\x20timestamp\x20passed');}var _0x3abdc8=_0x347de9[_0xf975('0x9b')]['binding_keys'][_0xf975('0x53')](',');var _0x111cce=_0x347de9[_0xf975('0x9b')]['binding_values'][_0xf975('0x53')](',');if(!_0x3abdc8[_0xf975('0x38')]||!_0x111cce['length']||_0x3abdc8[_0xf975('0x38')]!==_0x111cce[_0xf975('0x38')]){throw new Error('Incorrect\x20binding\x20parameters\x20passed!');}_0x347de9[_0xf975('0x9b')][_0xf975('0x3d')]=_['zipObject'](_0x3abdc8,_0x111cce);if(!_0x347de9['body']['fields']['phone']){throw new Error(_0xf975('0xd9'));}if(!_0x347de9[_0xf975('0x9b')][_0xf975('0x3d')][_0xf975('0xda')]){throw new Error(_0xf975('0xdb'));}var _0x14ff81=path[_0xf975('0x9f')](config[_0xf975('0xdc')],_0xf975('0xdd'),_0x347de9[_0xf975('0xde')][_0xf975('0xdf')]);fs[_0xf975('0xe0')](_0x14ff81,parseInt('0777',0x8));var _0x50e187=require(_0xf975('0xe1'))[_0xf975('0xe2')](path['join'](__dirname,'../../components/import/cm/csv'),[_0x14ff81,_0x347de9[_0xf975('0x9b')][_0xf975('0xd5')],_0x347de9[_0xf975('0x9b')]['binding_values'],_0x347de9[_0xf975('0x9b')][_0xf975('0x64')],_0x347de9[_0xf975('0x9b')][_0xf975('0xe3')],_0x347de9[_0xf975('0x9b')][_0xf975('0xe4')],_0x347de9[_0xf975('0x9b')][_0xf975('0xd8')]]);return _0x219e58[_0xf975('0x1e')](0xc8)[_0xf975('0x1f')]({'message':_0xf975('0xe5'),'pid':_0x50e187[_0xf975('0xe6')]});}catch(_0x443ffb){return _0x219e58['status'](0x1f4)['send'](_0x443ffb);}};exports[_0xf975('0xe7')]=function(_0x8487ea,_0x4c310b,_0x2858f0){var _0x1b6ef5=fs[_0xf975('0xe8')](_0x8487ea[_0xf975('0xde')][_0xf975('0x7')]);Papa[_0xf975('0xe9')](_0x1b6ef5,{'header':!![],'skipEmptyLines':!![],'preview':0x1,'complete':function(_0x399b41){return _0x4c310b[_0xf975('0x1e')](0xc8)[_0xf975('0x1f')]({'file':_0x8487ea[_0xf975('0xde')],'fields':_0x399b41['meta'][_0xf975('0x3d')]});}});};exports[_0xf975('0xea')]=function(_0x18badf,_0x214f95,_0x1692a2){return db[_0xf975('0x56')]['findAll']({'raw':!![],'attributes':['id'],'where':{'role':_0xf975('0x81')}})[_0xf975('0x29')](function(_0xf0c3eb){var _0x55812e=![];if(!_0x18badf['body'][_0xf975('0x64')]){throw new Error(_0xf975('0xd4'));}if(!_0x18badf['body'][_0xf975('0xeb')][_0xf975('0xc4')]){throw new Error(_0xf975('0xd9'));}if(!_0x18badf[_0xf975('0x9b')][_0xf975('0xeb')][_0xf975('0xda')]){throw new Error('No\x20firstName\x20column\x20specified');}if(!_0x18badf[_0xf975('0x9b')]['socket_timestamp']){throw new Error(_0xf975('0xec'));}var _0x511e60=require(_0xf975('0xe1'))['fork'](path[_0xf975('0x9f')](__dirname,'../../components/import/cm/csv2'),[_0x18badf[_0xf975('0x93')]['id'],JSON['stringify'](_0x18badf['body']),JSON[_0xf975('0xed')](_0xf0c3eb)]);_0x511e60['on'](_0xf975('0xee'),function(_0x37ef3d){_0x55812e=!![];return _0x214f95[_0xf975('0x1e')](0xc8)[_0xf975('0x1f')]({'message':'start\x20child\x20process\x20correctly!','pid':_0x511e60[_0xf975('0xe6')]});});_0x511e60['on'](_0xf975('0xef'),function(_0x3ed916){if(_0x3ed916&&!_0x55812e){return _0x214f95[_0xf975('0x1e')](0x1f4)[_0xf975('0x1f')]({'message':'error\x20child\x20process','pid':_0x511e60[_0xf975('0xe6')]});}});})[_0xf975('0x91')](handleError(_0x214f95,null));};
\ No newline at end of file
+var _0xe5f2=['getHopperFinals','CmHopperFinal','include','getJscriptySessions','uploadCsv','No\x20ListId\x20specified','binding_keys','No\x20association\x20keys\x20specified!','binding_values','No\x20association\x20values\x20specified!','Unable\x20to\x20synchronize\x20socket,\x20no\x20timestamp\x20passed','split','Incorrect\x20binding\x20parameters\x20passed!','zipObject','firstName','root','server/files/tmp','file','filename','0777','child_process','fork','../../components/import/cm/csv','socket_timestamp','json','pid','upload','createReadStream','path','parse','meta','User','agent','No\x20phone\x20column\x20specified','binding','No\x20firstName\x20column\x20specified','../../components/import/cm/csv2','stringify','message','exit','importUpdates','../../components/import/cm/csvUpdates','getJourney','mail','chat','sms','openchannel','fax','whatsapp','-createdAt','resolve','channel','toLowerCase','Invalid\x20channel','range','isValid','Invalid\x20date\x20for\x20range\x20from\x20filter','Invalid\x20createdAt\x20filter','voice','source','destination','callerid','starttime','duration','note','userDisposition','userSecondDisposition','UserId','createdAt','findAndCountAll','startCase','Website','Account','closed','disposition','thirdDisposition','key','Owner','fullname','color','DESC','browserName','customerPort','deviceModel','osName','ratingMessage','ratingType','referer','substatus','Interaction','flatten','sortBy','reverse','value','bluebird','util','squel','papaparse','ioredis','../../components/contacts','../../config/logger','api','../../config/environment','../../mysqldb','redis','defaults','localhost','socket.io-emitter','./cmContact.socket','status','undefined','limit','count','set','then','end','error','stack','name','send','index','getOptions','findAll','query','user','destroy','CmContact','find','params','catch','describe','cf_','columnName','analytics','CmCustomField','length','displayName','alias','custom','type','values','info','Custom\x20field\x20%s\x20not\x20found\x20on\x20cm_contacts\x20table','keys','hasOwnProperty','body','from','get','mergeWith','isArray','tags','join','CmHopperBlack','ChatInteraction','update','ChatMessage','ChatOfflineMessage','MailInteraction','MailMessage','SmsInteraction','SmsMessage','FaxInteraction','FaxMessage','OpenchannelInteraction','OpenchannelMessage','CmContactHasItem','CmHopperHistory','ReportAgentPreview','VoiceCallReport','ChatQueueReport','FaxQueueReport','MailQueueReport','OpenchannelQueueReport','SmsQueueReport','JscriptySessionReport','WhatsappMessage','WhatsappQueueReport','create','isNil','dialTimezone','timezones','utcOffset','additionalPhones','each','duplicates','where','$or','ListId','spread','push','contact','all','show','Tag','Tags','Phones','ContactItemType','sequelize','literal','Phones.OrderBy','omit','map','cf_%d','$and','pickBy','startsWith','format','isEmpty','table','cm_contacts','setFields','id\x20=\x20?','toParam','text','phone','findOne','model','rawAttributes','intersection','attributes','fields','order','sort','filters','filter','merge','options','nolimit','offset','setTags','setAdditionalPhones','OrderBy','items','item_types','ItemTypeId','description','contact\x20phone\x20exists','PHONE','CmHopper','CmHopperAdditionalPhone','item','`ItemType`.OrderBy','CmHopperId','ItemType','getAdditionalPhones','duplicateAdditionalPhones','fromContactId','toContactId','rescheduleAdditionalPhones','hopperId','getHoppers','pick','ContactId','includeAll','rows','getHopperHistories'];(function(_0x4254af,_0x3c9214){var _0x2fa64d=function(_0x1ee605){while(--_0x1ee605){_0x4254af['push'](_0x4254af['shift']());}};_0x2fa64d(++_0x3c9214);}(_0xe5f2,0x15e));var _0x2e5f=function(_0x593b96,_0x260616){_0x593b96=_0x593b96-0x0;var _0x55b051=_0xe5f2[_0x593b96];return _0x55b051;};'use strict';var moment=require('moment');var BPromise=require(_0x2e5f('0x0'));var util=require(_0x2e5f('0x1'));var path=require('path');var fs=require('fs');var _=require('lodash');var squel=require(_0x2e5f('0x2'));var Papa=require(_0x2e5f('0x3'));var Redis=require(_0x2e5f('0x4'));var contacts=require(_0x2e5f('0x5'));var qs=require('../../components/parsers/qs');var logger=require(_0x2e5f('0x6'))(_0x2e5f('0x7'));var config=require(_0x2e5f('0x8'));var shared=require('../../config/environment/shared');var db=require(_0x2e5f('0x9'))['db'];config[_0x2e5f('0xa')]=_[_0x2e5f('0xb')](config[_0x2e5f('0xa')],{'host':_0x2e5f('0xc'),'port':0x18eb});var socket=require(_0x2e5f('0xd'))(new Redis(config[_0x2e5f('0xa')]));require(_0x2e5f('0xe'))['register'](socket);function respondWithResult(_0x317d1c,_0x3e5e60){_0x3e5e60=_0x3e5e60||0xc8;return function(_0x2e926c){if(_0x2e926c){return _0x317d1c[_0x2e5f('0xf')](_0x3e5e60)['json'](_0x2e926c);}};}function respondWithFilteredResult(_0xd034e5,_0x2bc05f){return function(_0xad288d){if(_0xad288d){var _0x46835a=typeof _0x2bc05f['offset']===_0x2e5f('0x10')&&typeof _0x2bc05f[_0x2e5f('0x11')]==='undefined';var _0x2c28b9=_0xad288d['count'];var _0x3a5dce=_0x46835a?0x0:_0x2bc05f['offset'];var _0xe6b917=_0x46835a?_0xad288d[_0x2e5f('0x12')]:_0x2bc05f['offset']+_0x2bc05f['limit'];var _0x58baa0;if(_0xe6b917>=_0x2c28b9){_0xe6b917=_0x2c28b9;_0x58baa0=0xc8;}else{_0x58baa0=0xce;}_0xd034e5['status'](_0x58baa0);return _0xd034e5[_0x2e5f('0x13')]('Content-Range',_0x3a5dce+'-'+_0xe6b917+'/'+_0x2c28b9)['json'](_0xad288d);}return null;};}function saveUpdates(_0x5457ea){return function(_0x3f0880){if(_0x3f0880){return _0x3f0880['update'](_0x5457ea)[_0x2e5f('0x14')](function(_0x34d9e1){return _0x34d9e1;});}return null;};}function removeEntity(_0x3efc84){return function(_0x27b564){if(_0x27b564){return _0x27b564['destroy']()['then'](function(){_0x3efc84[_0x2e5f('0xf')](0xcc)[_0x2e5f('0x15')]();});}};}function handleEntityNotFound(_0x3647aa){return function(_0x1537c9){if(!_0x1537c9){_0x3647aa['sendStatus'](0x194);}return _0x1537c9;};}function handleError(_0x3f511b,_0x2402f2){_0x2402f2=_0x2402f2||0x1f4;return function(_0x119a29){logger[_0x2e5f('0x16')](_0x119a29[_0x2e5f('0x17')]);if(_0x119a29[_0x2e5f('0x18')]){delete _0x119a29[_0x2e5f('0x18')];}_0x3f511b[_0x2e5f('0xf')](_0x2402f2)[_0x2e5f('0x19')](_0x119a29);};}exports[_0x2e5f('0x1a')]=function(_0x469f34,_0x226015){var _0xc0bad5={};return contacts['describe']()[_0x2e5f('0x14')](function(_0x1c99ac){_0xc0bad5=qs[_0x2e5f('0x1b')](_0x1c99ac,_0x469f34);return contacts[_0x2e5f('0x1c')](_0x469f34[_0x2e5f('0x1d')],_0x469f34[_0x2e5f('0x1e')],_0xc0bad5,_0x1c99ac);})[_0x2e5f('0x14')](respondWithFilteredResult(_0x226015,_0xc0bad5))['catch'](handleError(_0x226015,null));};exports[_0x2e5f('0x1f')]=function(_0x240aa8,_0x22f4ed){return db[_0x2e5f('0x20')][_0x2e5f('0x21')]({'where':{'id':_0x240aa8[_0x2e5f('0x22')]['id']}})['then'](handleEntityNotFound(_0x22f4ed,null))[_0x2e5f('0x14')](removeEntity(_0x22f4ed,null))[_0x2e5f('0x23')](handleError(_0x22f4ed,null));};exports[_0x2e5f('0x24')]=function(_0x2308e7,_0x5651ef){return db['CmContact'][_0x2e5f('0x24')]()['then'](function(_0x4ac62b){delete _0x4ac62b['tags'];for(var _0x4136fa=0x0;_0x4136fa<Object['keys'](_0x4ac62b)['length'];_0x4136fa++){var _0x208e84=Object['keys'](_0x4ac62b)[_0x4136fa];if(!_['startsWith'](_0x208e84,_0x2e5f('0x25'))){_0x4ac62b[_0x208e84][_0x2e5f('0x26')]=_0x208e84;_0x4ac62b[_0x208e84]['displayName']=_0x208e84;}}return _0x4ac62b;})[_0x2e5f('0x14')](function(_0x4555b5){var _0x3475d1={'where':Boolean(_0x2308e7[_0x2e5f('0x1d')][_0x2e5f('0x27')])===!![]?undefined:{'$or':[{'ListId':_0x2308e7[_0x2e5f('0x1d')]['id']},{'ListId':null}]},'raw':!![]};return db[_0x2e5f('0x28')][_0x2e5f('0x1c')](_0x3475d1)[_0x2e5f('0x14')](function(_0x5b0190){for(var _0x250d09=0x0;_0x250d09<_0x5b0190[_0x2e5f('0x29')];_0x250d09++){var _0x3f560b=_0x2e5f('0x25')+_0x5b0190[_0x250d09]['id'];if(_0x4555b5[_0x3f560b]){_0x4555b5[_0x3f560b]['columnName']=_0x3f560b;_0x4555b5[_0x3f560b][_0x2e5f('0x2a')]=_0x5b0190[_0x250d09][_0x2e5f('0x2b')];_0x4555b5[_0x3f560b][_0x2e5f('0x2c')]={'type':_0x5b0190[_0x250d09][_0x2e5f('0x2d')],'values':_0x5b0190[_0x250d09][_0x2e5f('0x2e')]};}else{logger[_0x2e5f('0x2f')](_0x2e5f('0x30'),_0x3f560b);}}Object[_0x2e5f('0x31')](_0x4555b5)['forEach'](function(_0x50a406){if(!_0x4555b5[_0x50a406][_0x2e5f('0x32')](_0x2e5f('0x26'))){delete _0x4555b5[_0x50a406];}});return _0x4555b5;});})[_0x2e5f('0x14')](respondWithResult(_0x5651ef,null))['catch'](handleError(_0x5651ef,null));};exports['merge']=function(_0x47943c,_0x1d8642){var _0x43b49e;var _0x5063da;var _0x267181;if(_0x47943c[_0x2e5f('0x33')]['id']){delete _0x47943c[_0x2e5f('0x33')]['id'];}return db[_0x2e5f('0x20')]['findAll']({'where':{'id':[_0x47943c['body']['to'],_0x47943c[_0x2e5f('0x33')][_0x2e5f('0x34')]]}})[_0x2e5f('0x14')](function(_0x2d000e){if(_0x2d000e){if(_0x2d000e[_0x2e5f('0x29')]!==0x2){return null;}_0x2d000e[0x0]=_0x2d000e[0x0][_0x2e5f('0x35')]({'plain':!![]});_0x2d000e[0x1]=_0x2d000e[0x1][_0x2e5f('0x35')]({'plain':!![]});delete _0x2d000e[0x0]['id'];delete _0x2d000e[0x1]['id'];return _[_0x2e5f('0x36')](_0x2d000e[0x0],_0x2d000e[0x1],function(_0x371684,_0x4af350){if(Array[_0x2e5f('0x37')](_0x4af350)&&!_0x4af350[_0x2e5f('0x29')]){return _0x371684;}else if(!_0x4af350){return _0x371684;}});}})[_0x2e5f('0x14')](handleEntityNotFound(_0x1d8642,null))[_0x2e5f('0x14')](function(_0x55af60){if(_0x55af60){if(_0x55af60[_0x2e5f('0x38')]&&_[_0x2e5f('0x37')](_0x55af60[_0x2e5f('0x38')])){_0x55af60[_0x2e5f('0x38')]=_0x55af60['tags'][_0x2e5f('0x39')]();}logger[_0x2e5f('0x2f')]('[CmContact][merge]\x20to\x20%s\x20from\x20%s',_0x47943c['body']['to'],_0x47943c[_0x2e5f('0x33')][_0x2e5f('0x34')]);return db['CmHopper'][_0x2e5f('0x1f')]({'where':{'ContactId':[_0x47943c[_0x2e5f('0x33')]['to'],_0x47943c[_0x2e5f('0x33')][_0x2e5f('0x34')]]}})[_0x2e5f('0x14')](function(_0x42d80e){logger[_0x2e5f('0x2f')]('[CmContact][merge][destroy][CmHopper],\x20%s',_0x42d80e);return db[_0x2e5f('0x3a')][_0x2e5f('0x1f')]({'where':{'ContactId':[_0x47943c[_0x2e5f('0x33')]['to'],_0x47943c[_0x2e5f('0x33')][_0x2e5f('0x34')]]}})[_0x2e5f('0x14')](function(_0x470c13){logger['info']('[CmContact][merge][destroy][CmHopperBlack],\x20%s',_0x470c13);return db['CmContact']['create'](_0x55af60);});});}})['then'](function(_0x12f8d2){if(_0x12f8d2){_0x43b49e=_0x12f8d2;_0x5063da={'ContactId':_0x43b49e['id']};_0x267181={'where':{'ContactId':[_0x47943c[_0x2e5f('0x33')]['to'],_0x47943c[_0x2e5f('0x33')]['from']]}};return db[_0x2e5f('0x3b')][_0x2e5f('0x3c')](_0x5063da,_0x267181);}})['then'](function(){if(_0x43b49e){return db[_0x2e5f('0x3d')]['update'](_0x5063da,_0x267181);}})['then'](function(){if(_0x43b49e){return db[_0x2e5f('0x3e')]['update'](_0x5063da,_0x267181);}})[_0x2e5f('0x14')](function(){if(_0x43b49e){return db[_0x2e5f('0x3f')][_0x2e5f('0x3c')](_0x5063da,_0x267181);}})[_0x2e5f('0x14')](function(){if(_0x43b49e){return db[_0x2e5f('0x40')][_0x2e5f('0x3c')](_0x5063da,_0x267181);}})[_0x2e5f('0x14')](function(){if(_0x43b49e){return db[_0x2e5f('0x3f')][_0x2e5f('0x3c')](_0x5063da,_0x267181);}})[_0x2e5f('0x14')](function(){if(_0x43b49e){return db['MailMessage'][_0x2e5f('0x3c')](_0x5063da,_0x267181);}})[_0x2e5f('0x14')](function(){if(_0x43b49e){return db[_0x2e5f('0x41')][_0x2e5f('0x3c')](_0x5063da,_0x267181);}})[_0x2e5f('0x14')](function(){if(_0x43b49e){return db[_0x2e5f('0x42')][_0x2e5f('0x3c')](_0x5063da,_0x267181);}})[_0x2e5f('0x14')](function(){if(_0x43b49e){return db[_0x2e5f('0x43')][_0x2e5f('0x3c')](_0x5063da,_0x267181);}})[_0x2e5f('0x14')](function(){if(_0x43b49e){return db[_0x2e5f('0x44')][_0x2e5f('0x3c')](_0x5063da,_0x267181);}})['then'](function(){if(_0x43b49e){return db[_0x2e5f('0x45')][_0x2e5f('0x3c')](_0x5063da,_0x267181);}})[_0x2e5f('0x14')](function(){if(_0x43b49e){return db[_0x2e5f('0x46')][_0x2e5f('0x3c')](_0x5063da,_0x267181);}})[_0x2e5f('0x14')](function(){if(_0x43b49e){return db[_0x2e5f('0x47')][_0x2e5f('0x3c')]({'CmContactId':_0x43b49e['id']},{'where':{'CmContactId':[_0x47943c[_0x2e5f('0x33')]['to'],_0x47943c[_0x2e5f('0x33')][_0x2e5f('0x34')]]}});}})['then'](function(){if(_0x43b49e){return db['CmHopperFinal'][_0x2e5f('0x3c')](_0x5063da,_0x267181);}})[_0x2e5f('0x14')](function(){if(_0x43b49e){return db[_0x2e5f('0x48')][_0x2e5f('0x3c')](_0x5063da,_0x267181);}})[_0x2e5f('0x14')](function(){if(_0x43b49e){return db[_0x2e5f('0x49')][_0x2e5f('0x3c')](_0x5063da,_0x267181);}})['then'](function(){if(_0x43b49e){return db[_0x2e5f('0x4a')][_0x2e5f('0x3c')](_0x5063da,_0x267181);}})[_0x2e5f('0x14')](function(){if(_0x43b49e){return db[_0x2e5f('0x4b')]['update'](_0x5063da,_0x267181);}})[_0x2e5f('0x14')](function(){if(_0x43b49e){return db[_0x2e5f('0x4c')]['update'](_0x5063da,_0x267181);}})[_0x2e5f('0x14')](function(){if(_0x43b49e){return db[_0x2e5f('0x4d')]['update'](_0x5063da,_0x267181);}})[_0x2e5f('0x14')](function(){if(_0x43b49e){return db[_0x2e5f('0x4e')]['update'](_0x5063da,_0x267181);}})['then'](function(){if(_0x43b49e){return db[_0x2e5f('0x4f')][_0x2e5f('0x3c')](_0x5063da,_0x267181);}})['then'](function(){if(_0x43b49e){return db[_0x2e5f('0x50')][_0x2e5f('0x3c')](_0x5063da,_0x267181);}})[_0x2e5f('0x14')](function(){if(_0x43b49e){return db['WhatsappInteraction']['update'](_0x5063da,_0x267181);}})['then'](function(){if(_0x43b49e){return db[_0x2e5f('0x51')][_0x2e5f('0x3c')](_0x5063da,_0x267181);}})[_0x2e5f('0x14')](function(){if(_0x43b49e){return db[_0x2e5f('0x52')][_0x2e5f('0x3c')](_0x5063da,_0x267181);}})[_0x2e5f('0x14')](function(){if(_0x43b49e){return db[_0x2e5f('0x20')][_0x2e5f('0x1f')]({'where':{'id':[_0x47943c[_0x2e5f('0x33')]['to'],_0x47943c[_0x2e5f('0x33')]['from']]}});}})[_0x2e5f('0x14')](function(){if(_0x43b49e){return _0x43b49e;}})['then'](respondWithResult(_0x1d8642,null))['catch'](handleError(_0x1d8642,null));};exports[_0x2e5f('0x53')]=function(_0xc181b2,_0x38f3a4){return db[_0x2e5f('0x20')][_0x2e5f('0x24')]()[_0x2e5f('0x14')](function(_0x336d10){if(_0xc181b2['body']['tags']&&_['isArray'](_0xc181b2[_0x2e5f('0x33')]['tags'])){if(_0xc181b2[_0x2e5f('0x33')][_0x2e5f('0x38')][_0x2e5f('0x29')]){_0xc181b2['body'][_0x2e5f('0x38')]=_0xc181b2[_0x2e5f('0x33')][_0x2e5f('0x38')]['join'](';')+';';}else{_0xc181b2[_0x2e5f('0x33')][_0x2e5f('0x38')]=null;}}else{_0xc181b2[_0x2e5f('0x33')][_0x2e5f('0x38')]=null;}if(!_[_0x2e5f('0x54')](_0xc181b2['body']['dialTimezone'])){var _0xa744cc=_0xc181b2[_0x2e5f('0x33')][_0x2e5f('0x55')];if(!_[_0x2e5f('0x54')](shared[_0x2e5f('0x56')][_0xa744cc]))_0xc181b2['body'][_0x2e5f('0x57')]=shared[_0x2e5f('0x56')][_0xa744cc][_0x2e5f('0x57')];}return db[_0x2e5f('0x20')][_0x2e5f('0x53')](_0xc181b2[_0x2e5f('0x33')],{'fields':_[_0x2e5f('0x31')](_0x336d10),'raw':!![]});})['then'](function(_0x38c6af){if(_0xc181b2[_0x2e5f('0x33')]['additionalPhones']){return insertAdditionalPhones(_0x38c6af,_0xc181b2[_0x2e5f('0x33')][_0x2e5f('0x58')]);}else{return _0x38c6af;}})[_0x2e5f('0x14')](respondWithResult(_0x38f3a4,0xc9))[_0x2e5f('0x23')](handleError(_0x38f3a4,null));};exports['bulkCreate']=function(_0x4ae44d,_0x5de56e){var _0x6289fb=0x0;var _0x2aa641=0x0;var _0x30d2b2=0x0;var _0x15d6ca=[];return db['CmContact'][_0x2e5f('0x24')]()['then'](function(_0x6b3616){return BPromise[_0x2e5f('0x59')](_0x4ae44d['body'],function(_0x131aac){var _0x2960dc={'where':{'$or':[]},'defaults':_0x131aac,'fields':_[_0x2e5f('0x31')](_0x6b3616),'raw':!![]};if(_0x131aac['duplicates']){for(var _0x29bd52=0x0;_0x29bd52<_0x131aac[_0x2e5f('0x5a')][_0x2e5f('0x29')];_0x29bd52++){var _0xccf928={};_0xccf928[_0x131aac['duplicates'][_0x29bd52]]=_0x131aac[_0x131aac[_0x2e5f('0x5a')][_0x29bd52]];_0x2960dc[_0x2e5f('0x5b')][_0x2e5f('0x5c')]['push'](_0xccf928);}_0x2960dc[_0x2e5f('0x5b')][_0x2e5f('0x5d')]=_0x131aac[_0x2e5f('0x5d')];}return db[_0x2e5f('0x20')]['findOrCreate'](_0x2960dc)[_0x2e5f('0x5e')](function(_0x5d3f8a,_0x463321){if(_0x463321){if(_0x131aac[_0x2e5f('0x32')]('additionalPhones')){_0x15d6ca[_0x2e5f('0x5f')]({'contact':_0x5d3f8a,'additionalPhones':_0x131aac[_0x2e5f('0x58')]});}_0x6289fb++;}else{_0x30d2b2++;}})[_0x2e5f('0x23')](function(){_0x2aa641++;});});})[_0x2e5f('0x14')](function(_0x5b4f70){if(_0x5b4f70){if(_0x15d6ca[_0x2e5f('0x29')]>0x0){return new Promise(function(_0xd009a2){var _0x5de8f4=[];for(var _0x3b30ee=0x0;_0x3b30ee<_0x15d6ca[_0x2e5f('0x29')];_0x3b30ee++){_0x5de8f4[_0x2e5f('0x5f')](insertAdditionalPhones(_0x15d6ca[_0x3b30ee][_0x2e5f('0x60')],_0x15d6ca[_0x3b30ee][_0x2e5f('0x58')]));}Promise[_0x2e5f('0x61')](_0x5de8f4)[_0x2e5f('0x14')](function(){_0xd009a2(0x1);});})['then'](function(){return{'success':_0x6289fb,'failure':_0x2aa641,'duplicates':_0x30d2b2};});}else{return{'success':_0x6289fb,'failure':_0x2aa641,'duplicates':_0x30d2b2};}}})[_0x2e5f('0x14')](respondWithResult(_0x5de56e,0xc9))[_0x2e5f('0x23')](handleError(_0x5de56e,null));};exports[_0x2e5f('0x62')]=function(_0x10d5e0,_0x51c740){var _0x2f27d6;return db['CmContact'][_0x2e5f('0x24')]()['then'](function(_0x8374f){return db[_0x2e5f('0x20')][_0x2e5f('0x21')]({'where':{'id':_0x10d5e0[_0x2e5f('0x22')]['id']},'include':[{'model':db[_0x2e5f('0x63')],'as':_0x2e5f('0x64'),'attributes':['id',_0x2e5f('0x18'),'color'],'required':_0x10d5e0[_0x2e5f('0x1d')]['tag']?!![]:![]},{'model':db['CmContactHasItem'],'as':_0x2e5f('0x65'),'where':{'CmContactId':_0x10d5e0[_0x2e5f('0x22')]['id']},'required':![],'include':[{'model':db[_0x2e5f('0x66')],'as':'ItemType'}]}],'order':[db[_0x2e5f('0x67')][_0x2e5f('0x68')](_0x2e5f('0x69'))],'attributes':_['keys'](_0x8374f)});})[_0x2e5f('0x14')](function(_0x19ad95){if(!_['isNil'](_0x19ad95)){_0x2f27d6=_0x19ad95[_0x2e5f('0x35')]({'plain':!![]});var _0xeec750={'where':{'$and':[{'ListId':{'$ne':null}}]}};if(_0x19ad95&&_0x19ad95[_0x2e5f('0x5d')]){if(_0x19ad95['ListId']){_0xeec750[_0x2e5f('0x5b')]['$and'][_0x2e5f('0x5f')]({'ListId':{'$ne':_0x19ad95[_0x2e5f('0x5d')]}});}}return db[_0x2e5f('0x28')][_0x2e5f('0x1c')](_0xeec750);}})['then'](function(_0x43996e){if(!_[_0x2e5f('0x54')](_0x43996e)){return _[_0x2e5f('0x6a')](_0x2f27d6,_[_0x2e5f('0x6b')](_0x43996e,function(_0x3649fe){return util['format'](_0x2e5f('0x6c'),_0x3649fe['id']);}));}})['then'](handleEntityNotFound(_0x51c740,null))[_0x2e5f('0x14')](respondWithResult(_0x51c740,null))[_0x2e5f('0x23')](handleError(_0x51c740,null));};exports[_0x2e5f('0x3c')]=function(_0x23ab1b,_0x89470f){var _0x2b195d;if(_0x23ab1b[_0x2e5f('0x33')]['id']){delete _0x23ab1b[_0x2e5f('0x33')]['id'];}if(!_[_0x2e5f('0x54')](_0x23ab1b['body'][_0x2e5f('0x55')])){var _0x4f0d3d=_0x23ab1b[_0x2e5f('0x33')][_0x2e5f('0x55')];if(!_['isNil'](shared[_0x2e5f('0x56')][_0x4f0d3d]))_0x23ab1b[_0x2e5f('0x33')][_0x2e5f('0x57')]=shared[_0x2e5f('0x56')][_0x4f0d3d][_0x2e5f('0x57')];}return db[_0x2e5f('0x20')][_0x2e5f('0x21')]({'where':{'id':_0x23ab1b[_0x2e5f('0x22')]['id']}})['then'](handleEntityNotFound(_0x89470f,null))[_0x2e5f('0x14')](saveUpdates(_0x23ab1b[_0x2e5f('0x33')],null))['then'](function(_0x58c61b){_0x2b195d=_0x58c61b;var _0x24b226={'where':{'$and':[{'ListId':{'$ne':null}}]}};if(_0x58c61b&&_0x58c61b[_0x2e5f('0x5d')]){if(_0x58c61b['ListId']){_0x24b226[_0x2e5f('0x5b')][_0x2e5f('0x6d')][_0x2e5f('0x5f')]({'ListId':{'$ne':_0x58c61b[_0x2e5f('0x5d')]}});}}return db[_0x2e5f('0x28')]['findAll'](_0x24b226);})[_0x2e5f('0x14')](function(_0x55d55f){if(_0x55d55f){return _[_0x2e5f('0x6a')](_[_0x2e5f('0x6e')](_0x23ab1b[_0x2e5f('0x33')],function(_0x2825a2,_0x30ae1a){return _[_0x2e5f('0x6f')](_0x30ae1a,'cf_');}),_['map'](_0x55d55f,function(_0x2ef23a){return util[_0x2e5f('0x70')](_0x2e5f('0x6c'),_0x2ef23a['id']);}));}})['then'](function(_0x56b8e2){if(_0x56b8e2&&!_[_0x2e5f('0x71')](_0x56b8e2)){var _0x59873b=squel[_0x2e5f('0x3c')]()[_0x2e5f('0x72')](_0x2e5f('0x73'))[_0x2e5f('0x74')](_0x56b8e2)[_0x2e5f('0x5b')](_0x2e5f('0x75'),_0x23ab1b[_0x2e5f('0x22')]['id'])[_0x2e5f('0x76')]();return db[_0x2e5f('0x67')][_0x2e5f('0x1d')](_0x59873b[_0x2e5f('0x77')],{'replacements':_0x59873b[_0x2e5f('0x2e')]});}})[_0x2e5f('0x14')](function(){if(_0x23ab1b['body'][_0x2e5f('0x78')]&&_0x2b195d){return db['CmHopper']['update']({'phone':_0x23ab1b[_0x2e5f('0x33')][_0x2e5f('0x78')],'OrderBy':0x0},{'where':{'ContactId':_0x2b195d['id']}});}})[_0x2e5f('0x14')](function(){return _0x2b195d;})[_0x2e5f('0x14')](respondWithResult(_0x89470f,null))[_0x2e5f('0x23')](handleError(_0x89470f,null));};exports['getTags']=function(_0x518f57,_0x593263){var _0x289748={};var _0xf0eed1={};var _0x30c183;var _0xb5ed00;return db[_0x2e5f('0x20')][_0x2e5f('0x79')]({'where':{'id':_0x518f57['params']['id']}})['then'](handleEntityNotFound(_0x593263,null))['then'](function(_0xe14530){if(_0xe14530){_0x30c183=_0xe14530;_0xf0eed1[_0x2e5f('0x7a')]=_[_0x2e5f('0x31')](db[_0x2e5f('0x63')][_0x2e5f('0x7b')]);_0xf0eed1[_0x2e5f('0x1d')]=_[_0x2e5f('0x31')](_0x518f57[_0x2e5f('0x1d')]);_0xf0eed1['filters']=_[_0x2e5f('0x7c')](_0xf0eed1[_0x2e5f('0x7a')],_0xf0eed1[_0x2e5f('0x1d')]);_0x289748[_0x2e5f('0x7d')]=_[_0x2e5f('0x7c')](_0xf0eed1[_0x2e5f('0x7a')],qs[_0x2e5f('0x7e')](_0x518f57['query'][_0x2e5f('0x7e')]));_0x289748[_0x2e5f('0x7d')]=_0x289748[_0x2e5f('0x7d')]['length']?_0x289748[_0x2e5f('0x7d')]:_0xf0eed1[_0x2e5f('0x7a')];_0x289748[_0x2e5f('0x7f')]=qs[_0x2e5f('0x80')](_0x518f57[_0x2e5f('0x1d')][_0x2e5f('0x80')]);_0x289748['where']=qs[_0x2e5f('0x81')](_['pick'](_0x518f57[_0x2e5f('0x1d')],_0xf0eed1[_0x2e5f('0x81')]));if(_0x518f57[_0x2e5f('0x1d')][_0x2e5f('0x82')]){_0x289748[_0x2e5f('0x5b')]=_[_0x2e5f('0x83')](_0x289748['where'],{'$or':_[_0x2e5f('0x6b')](_0x289748['attributes'],function(_0x32ce0e){var _0x11a2fe={};_0x11a2fe[_0x32ce0e]={'$like':'%'+_0x518f57[_0x2e5f('0x1d')][_0x2e5f('0x82')]+'%'};return _0x11a2fe;})});}_0x289748=_[_0x2e5f('0x83')]({},_0x289748,_0x518f57[_0x2e5f('0x84')]);return _0x30c183['getTags'](_0x289748);}})[_0x2e5f('0x14')](function(_0x282dbb){if(_0x282dbb){_0xb5ed00=_0x282dbb[_0x2e5f('0x29')];if(!_0x518f57[_0x2e5f('0x1d')][_0x2e5f('0x32')](_0x2e5f('0x85'))){_0x289748[_0x2e5f('0x11')]=qs['limit'](_0x518f57[_0x2e5f('0x1d')]['limit']);_0x289748[_0x2e5f('0x86')]=qs[_0x2e5f('0x86')](_0x518f57[_0x2e5f('0x1d')]['offset']);}return _0x30c183['getTags'](_0x289748);}})[_0x2e5f('0x14')](function(_0x2b0e77){if(_0x2b0e77){return _0x2b0e77?{'count':_0xb5ed00,'rows':_0x2b0e77}:null;}})['then'](respondWithResult(_0x593263,null))[_0x2e5f('0x23')](handleError(_0x593263,null));};exports[_0x2e5f('0x87')]=function(_0x275109,_0x2f1ecb){if(_0x275109[_0x2e5f('0x33')]['id']){delete _0x275109[_0x2e5f('0x33')]['id'];}return db[_0x2e5f('0x20')][_0x2e5f('0x79')]({'where':{'id':_0x275109[_0x2e5f('0x22')]['id']}})[_0x2e5f('0x14')](handleEntityNotFound(_0x2f1ecb,null))[_0x2e5f('0x14')](function(_0x583adb){if(_0x583adb){return _0x583adb[_0x2e5f('0x87')](_0x275109[_0x2e5f('0x33')]['ids']||[]);}return null;})['then'](respondWithResult(_0x2f1ecb,null))['catch'](handleError(_0x2f1ecb,null));};exports[_0x2e5f('0x88')]=function(_0x1dcbc9,_0x1ea4dc){var _0x579274=[];_0x579274[_0x2e5f('0x5f')](addAdditionalPhones(_0x1dcbc9[_0x2e5f('0x33')]));Promise[_0x2e5f('0x61')](_0x579274)[_0x2e5f('0x14')](function(){_0x579274=[];_0x579274['push'](deleteCmHopperPhones(_0x1dcbc9[_0x2e5f('0x33')]['id']));_0x579274[_0x2e5f('0x5f')](addCmHopperPhones(_0x1dcbc9[_0x2e5f('0x33')]['id']));Promise[_0x2e5f('0x61')](_0x579274)[_0x2e5f('0x14')](function(){return[0x1];})[_0x2e5f('0x14')](respondWithResult(_0x1ea4dc,null));});};function addAdditionalPhones(_0x5bad98){var _0x496ff6;return new Promise(function(_0x2c97c3){return db[_0x2e5f('0x47')]['destroy']({'where':{'CmContactId':_0x5bad98['id']}})[_0x2e5f('0x14')](function(){db[_0x2e5f('0x66')][_0x2e5f('0x1c')]({'raw':!![],'attributes':['id',_0x2e5f('0x89')]})[_0x2e5f('0x14')](function(_0x400846){var _0x127de0=[];for(var _0x206569=0x0;_0x206569<_0x5bad98[_0x2e5f('0x8a')]['length'];_0x206569++){var _0xce3f4f=_0x5bad98['item_types']?_[_0x2e5f('0x54')](_0x5bad98[_0x2e5f('0x8b')][_0x206569])?'':_0x5bad98[_0x2e5f('0x8b')][_0x206569]:_0x5bad98[_0x2e5f('0x8a')][_0x206569][_0x2e5f('0x8c')]?_0x5bad98[_0x2e5f('0x8a')][_0x206569]['ItemTypeId']:'';var _0x10321e=_[_0x2e5f('0x54')](_0x5bad98[_0x2e5f('0x8a')][_0x206569][_0x2e5f('0x8d')])?'':_0x5bad98['items'][_0x206569][_0x2e5f('0x8d')];var _0x4743f1=_0xce3f4f+':'+_0x5bad98['items'][_0x206569][_0x2e5f('0x78')]+'ยง'+_0x10321e;if(_[_0x2e5f('0x54')](_0x496ff6))_0x496ff6=_0x4743f1;else _0x496ff6+=';'+_0x4743f1;var _0x116ba2=null;var _0x421df4=null;if(_0x5bad98[_0x2e5f('0x8b')]){if(!_['isNil'](_0x5bad98[_0x2e5f('0x8b')][_0x206569])){_0x421df4=_[_0x2e5f('0x21')](_0x400846,function(_0x572c5d){return _0x572c5d['id']===_0x5bad98[_0x2e5f('0x8b')][_0x206569];});if(!_[_0x2e5f('0x54')](_0x421df4)){_0x116ba2=_0x421df4[_0x2e5f('0x89')];}}}else{if(!_['isNil'](_0x5bad98['items'][_0x206569])){_0x421df4=_[_0x2e5f('0x21')](_0x400846,function(_0x47dd20){return _0x47dd20['id']===_0x5bad98[_0x2e5f('0x8a')][_0x206569][_0x2e5f('0x8c')];});if(!_['isNil'](_0x421df4)){_0x116ba2=_0x206569;}}}if(_[_0x2e5f('0x54')](_0x116ba2)){_0x116ba2=0x64;}_0x127de0[_0x2e5f('0x5f')](addAdditionalPhone(_0x5bad98['id'],_0x5bad98[_0x2e5f('0x8a')][_0x206569][_0x2e5f('0x78')],_0x5bad98[_0x2e5f('0x8b')]?_[_0x2e5f('0x54')](_0x5bad98['item_types'][_0x206569])?null:_0x5bad98['item_types'][_0x206569]:_0x5bad98[_0x2e5f('0x8a')][_0x206569][_0x2e5f('0x8c')]?_0x5bad98['items'][_0x206569][_0x2e5f('0x8c')]:null,_0x116ba2,_0x10321e));}Promise['all'](_0x127de0)['then'](function(){db[_0x2e5f('0x20')][_0x2e5f('0x3c')]({'AdditionalPhones':_0x496ff6},{'where':{'id':_0x5bad98['id']}})[_0x2e5f('0x14')](function(){_0x2c97c3(0x1);});});});});});}function addAdditionalPhone(_0xbbebcd,_0xa62ec8,_0x28dfc2,_0x4e87ec,_0xd10072){return db[_0x2e5f('0x47')]['find']({'where':{'CmContactId':_0xbbebcd,'item':_0xa62ec8}})[_0x2e5f('0x14')](function(_0x3c04e5){if(_0x3c04e5)logger[_0x2e5f('0x2f')](_0x2e5f('0x8e'),_0x3c04e5);else{db[_0x2e5f('0x47')][_0x2e5f('0x53')]({'CmContactId':_0xbbebcd,'item':_0xa62ec8,'ItemTypeId':_0x28dfc2,'OrderBy':_0x4e87ec,'ItemClass':_0x2e5f('0x8f'),'description':_0xd10072});}});}function deleteCmHopperPhones(_0x25b0b8){return new Promise(function(_0x53f966){return db[_0x2e5f('0x90')][_0x2e5f('0x1c')]({'raw':!![],'attributes':['id'],'where':{'ContactId':_0x25b0b8}})['then'](function(_0x24b759){db[_0x2e5f('0x91')][_0x2e5f('0x1f')]({'where':{'CmHopperId':{'$in':_[_0x2e5f('0x6b')](_0x24b759,'id')}}});})['then'](function(){_0x53f966(0x1);});});}function addCmHopperPhones(_0x2e5fe4){return new Promise(function(_0x6fda9e){return db['CmHopper'][_0x2e5f('0x1c')]({'raw':!![],'attributes':['id'],'where':{'ContactId':_0x2e5fe4}})[_0x2e5f('0x14')](function(_0x5bc249){var _0x4aaae2=[];_['map'](_0x5bc249,function(_0x57ced0){_0x4aaae2['push'](createCmHopperPhone(_0x2e5fe4,_0x57ced0['id']));});Promise[_0x2e5f('0x61')](_0x4aaae2)[_0x2e5f('0x14')](function(){_0x6fda9e(0x1);});});});}function createCmHopperPhone(_0x201c33,_0x355f99){return new Promise(function(_0x5846b6){db[_0x2e5f('0x47')][_0x2e5f('0x1c')]({'raw':!![],'attributes':[_0x2e5f('0x92'),'OrderBy'],'where':{'CmContactId':_0x201c33,'ItemClass':_0x2e5f('0x8f')},'include':[{'model':db[_0x2e5f('0x66')],'attributes':[_0x2e5f('0x89')],'as':'ItemType'}],'order':[_0x2e5f('0x89'),db[_0x2e5f('0x67')][_0x2e5f('0x68')](_0x2e5f('0x93'))]})[_0x2e5f('0x14')](function(_0x59a88f){var _0x268ac7=0x1;var _0x22430e=_[_0x2e5f('0x6b')](_0x59a88f,function(_0x1c4c14){_0x1c4c14[_0x2e5f('0x94')]=_0x355f99;_0x1c4c14[_0x2e5f('0x78')]=_0x1c4c14[_0x2e5f('0x92')];_0x1c4c14[_0x2e5f('0x89')]=_0x268ac7;delete _0x1c4c14['ItemType.OrderBy'];_0x268ac7=_0x268ac7+0x1;return _0x1c4c14;});return db['CmHopperAdditionalPhone']['bulkCreate'](_0x22430e,{});})[_0x2e5f('0x14')](function(){_0x5846b6(0x1);});});}function insertAdditionalPhones(_0x23d684,_0x18485b){return new Promise(function(_0x49da8d){var _0x178e0c=[];for(var _0x5de013=0x0;_0x5de013<_0x18485b[_0x2e5f('0x29')];_0x5de013++){var _0x3789e1=_0x18485b[_0x5de013];_0x178e0c[_0x2e5f('0x5f')](parseContactItemType(_0x3789e1));}Promise['all'](_0x178e0c)[_0x2e5f('0x14')](function(){var _0x5cc01c={'id':_0x23d684['id'],'items':_0x18485b};return addAdditionalPhones(_0x5cc01c)[_0x2e5f('0x14')](function(){return addCmHopperPhones(_0x23d684['id']);});})[_0x2e5f('0x14')](function(){_0x49da8d(_0x23d684);});});}function parseContactItemType(_0x595a56){return new Promise(function(_0x1a224b){if(_0x595a56[_0x2e5f('0x32')](_0x2e5f('0x8c'))){_0x1a224b(_0x595a56);}else{return db['ContactItemType'][_0x2e5f('0x21')]({'where':{'name':_0x595a56[_0x2e5f('0x95')]}})[_0x2e5f('0x14')](function(_0x2f6c43){if(_[_0x2e5f('0x54')](_0x2f6c43))_0x595a56[_0x2e5f('0x8c')]=null;else _0x595a56[_0x2e5f('0x8c')]=_0x2f6c43['id'];_0x1a224b(_0x595a56);});}});}exports[_0x2e5f('0x96')]=function(_0x263655,_0x5d9d5a){return db['CmContactHasItem'][_0x2e5f('0x1c')]({'raw':!![],'where':{'CmContactId':_0x263655[_0x2e5f('0x22')]['id'],'ItemClass':_0x2e5f('0x8f')},'include':[{'model':db[_0x2e5f('0x66')],'as':_0x2e5f('0x95')}],'order':[[_0x2e5f('0x89')],[db[_0x2e5f('0x67')][_0x2e5f('0x68')](_0x2e5f('0x93'))]]})[_0x2e5f('0x14')](function(_0x5a0d6c){return _0x5a0d6c;})[_0x2e5f('0x14')](respondWithResult(_0x5d9d5a,null))[_0x2e5f('0x23')](handleError(_0x5d9d5a,null));};exports[_0x2e5f('0x97')]=function(_0x2632ef,_0x3b02c){return db[_0x2e5f('0x47')][_0x2e5f('0x1c')]({'raw':!![],'where':{'CmContactId':_0x2632ef[_0x2e5f('0x33')][_0x2e5f('0x98')]}})['then'](function(_0xc57a3a){var _0x3f9963=_[_0x2e5f('0x6b')](_0xc57a3a,function(_0x45d1b9){_0x45d1b9['CmContactId']=_0x2632ef[_0x2e5f('0x33')]['toContactId'];return _0x45d1b9;});return db[_0x2e5f('0x47')]['bulkCreate'](_0x3f9963,{});})[_0x2e5f('0x14')](function(){return addCmHopperPhones(_0x2632ef[_0x2e5f('0x33')][_0x2e5f('0x99')]);})['then'](function(){return['ok'];})[_0x2e5f('0x14')](respondWithResult(_0x3b02c,null))[_0x2e5f('0x23')](handleError(_0x3b02c,null));};exports[_0x2e5f('0x9a')]=function(_0x2c9e61,_0x348e73){var _0x1db485=[];_0x1db485[_0x2e5f('0x5f')](createCmHopperPhone(_0x2c9e61['body']['id'],_0x2c9e61[_0x2e5f('0x33')][_0x2e5f('0x9b')]));Promise['all'](_0x1db485)[_0x2e5f('0x14')](function(){return[0x1];})[_0x2e5f('0x14')](respondWithResult(_0x348e73,null));};exports[_0x2e5f('0x9c')]=function(_0x43ae75,_0x23c1e4){var _0x342196={'raw':![],'where':{}};var _0x49fa22={};var _0x37f8e2={'count':0x0,'rows':[]};return db[_0x2e5f('0x20')][_0x2e5f('0x79')]({'where':{'id':_0x43ae75[_0x2e5f('0x22')]['id']}})['then'](handleEntityNotFound(_0x23c1e4,null))[_0x2e5f('0x14')](function(_0x58f8c3){if(_0x58f8c3){_0x49fa22[_0x2e5f('0x7a')]=_[_0x2e5f('0x31')](db[_0x2e5f('0x90')][_0x2e5f('0x7b')]);_0x49fa22['query']=_['keys'](_0x43ae75[_0x2e5f('0x1d')]);_0x49fa22[_0x2e5f('0x81')]=_[_0x2e5f('0x7c')](_0x49fa22[_0x2e5f('0x7a')],_0x49fa22[_0x2e5f('0x1d')]);_0x342196['attributes']=_[_0x2e5f('0x7c')](_0x49fa22[_0x2e5f('0x7a')],qs[_0x2e5f('0x7e')](_0x43ae75[_0x2e5f('0x1d')][_0x2e5f('0x7e')]));_0x342196[_0x2e5f('0x7d')]=_0x342196[_0x2e5f('0x7d')]['length']?_0x342196[_0x2e5f('0x7d')]:_0x49fa22['model'];if(!_0x43ae75[_0x2e5f('0x1d')]['hasOwnProperty'](_0x2e5f('0x85'))){_0x342196['limit']=qs[_0x2e5f('0x11')](_0x43ae75[_0x2e5f('0x1d')][_0x2e5f('0x11')]);_0x342196[_0x2e5f('0x86')]=qs[_0x2e5f('0x86')](_0x43ae75[_0x2e5f('0x1d')][_0x2e5f('0x86')]);}_0x342196[_0x2e5f('0x7f')]=qs[_0x2e5f('0x80')](_0x43ae75[_0x2e5f('0x1d')][_0x2e5f('0x80')]);_0x342196[_0x2e5f('0x5b')]=qs[_0x2e5f('0x81')](_[_0x2e5f('0x9d')](_0x43ae75[_0x2e5f('0x1d')],_0x49fa22[_0x2e5f('0x81')]));_0x342196['where'][_0x2e5f('0x9e')]=_0x58f8c3['id'];if(_0x43ae75[_0x2e5f('0x1d')]['filter']){_0x342196[_0x2e5f('0x5b')]=_[_0x2e5f('0x83')](_0x342196[_0x2e5f('0x5b')],{'$or':_[_0x2e5f('0x6b')](_0x342196[_0x2e5f('0x7d')],function(_0x34f950){var _0x4b502f={};_0x4b502f[_0x34f950]={'$like':'%'+_0x43ae75[_0x2e5f('0x1d')][_0x2e5f('0x82')]+'%'};return _0x4b502f;})});}_0x342196=_[_0x2e5f('0x83')]({},_0x342196,_0x43ae75[_0x2e5f('0x84')]);return db[_0x2e5f('0x90')][_0x2e5f('0x12')]({'where':_0x342196['where']})['then'](function(_0x5683d4){_0x37f8e2[_0x2e5f('0x12')]=_0x5683d4;if(_0x43ae75[_0x2e5f('0x1d')][_0x2e5f('0x9f')]){_0x342196['include']=[{'all':!![]}];}return db[_0x2e5f('0x90')][_0x2e5f('0x1c')](_0x342196);})[_0x2e5f('0x14')](function(_0x5242e0){_0x37f8e2[_0x2e5f('0xa0')]=_0x5242e0;return _0x37f8e2;});}})['then'](respondWithFilteredResult(_0x23c1e4,_0x342196))[_0x2e5f('0x23')](handleError(_0x23c1e4,null));};exports[_0x2e5f('0xa1')]=function(_0x1b0c7c,_0x1263ee){var _0x42aa94={'raw':!![],'where':{}};var _0x310c87={};var _0x32d0a7={'count':0x0,'rows':[]};return db['CmContact'][_0x2e5f('0x79')]({'where':{'id':_0x1b0c7c[_0x2e5f('0x22')]['id']}})['then'](handleEntityNotFound(_0x1263ee,null))['then'](function(_0x7e8bfc){if(_0x7e8bfc){_0x310c87[_0x2e5f('0x7a')]=_[_0x2e5f('0x31')](db['CmHopperHistory'][_0x2e5f('0x7b')]);_0x310c87[_0x2e5f('0x1d')]=_[_0x2e5f('0x31')](_0x1b0c7c[_0x2e5f('0x1d')]);_0x310c87[_0x2e5f('0x81')]=_[_0x2e5f('0x7c')](_0x310c87[_0x2e5f('0x7a')],_0x310c87[_0x2e5f('0x1d')]);_0x42aa94[_0x2e5f('0x7d')]=_[_0x2e5f('0x7c')](_0x310c87['model'],qs['fields'](_0x1b0c7c['query']['fields']));_0x42aa94['attributes']=_0x42aa94[_0x2e5f('0x7d')][_0x2e5f('0x29')]?_0x42aa94[_0x2e5f('0x7d')]:_0x310c87[_0x2e5f('0x7a')];if(!_0x1b0c7c['query'][_0x2e5f('0x32')](_0x2e5f('0x85'))){_0x42aa94['limit']=qs['limit'](_0x1b0c7c['query']['limit']);_0x42aa94[_0x2e5f('0x86')]=qs[_0x2e5f('0x86')](_0x1b0c7c['query'][_0x2e5f('0x86')]);}_0x42aa94['order']=qs[_0x2e5f('0x80')](_0x1b0c7c[_0x2e5f('0x1d')][_0x2e5f('0x80')]);_0x42aa94[_0x2e5f('0x5b')]=qs[_0x2e5f('0x81')](_[_0x2e5f('0x9d')](_0x1b0c7c[_0x2e5f('0x1d')],_0x310c87[_0x2e5f('0x81')]));_0x42aa94[_0x2e5f('0x5b')][_0x2e5f('0x9e')]=_0x7e8bfc['id'];if(_0x1b0c7c['query'][_0x2e5f('0x82')]){_0x42aa94['where']=_['merge'](_0x42aa94['where'],{'$or':_[_0x2e5f('0x6b')](_0x42aa94[_0x2e5f('0x7d')],function(_0x28d848){var _0x4cfee3={};_0x4cfee3[_0x28d848]={'$like':'%'+_0x1b0c7c['query'][_0x2e5f('0x82')]+'%'};return _0x4cfee3;})});}_0x42aa94=_[_0x2e5f('0x83')]({},_0x42aa94,_0x1b0c7c[_0x2e5f('0x84')]);return db[_0x2e5f('0x48')][_0x2e5f('0x12')]({'where':_0x42aa94[_0x2e5f('0x5b')]})[_0x2e5f('0x14')](function(_0x50ea88){_0x32d0a7[_0x2e5f('0x12')]=_0x50ea88;if(_0x1b0c7c['query'][_0x2e5f('0x9f')]){_0x42aa94['include']=[{'all':!![]}];}return db[_0x2e5f('0x48')][_0x2e5f('0x1c')](_0x42aa94);})['then'](function(_0xf217a5){_0x32d0a7[_0x2e5f('0xa0')]=_0xf217a5;return _0x32d0a7;});}})['then'](respondWithFilteredResult(_0x1263ee,_0x42aa94))['catch'](handleError(_0x1263ee,null));};exports[_0x2e5f('0xa2')]=function(_0x13393c,_0x2bf8fa){var _0x35ae18={'raw':!![],'where':{}};var _0x3b6e2f={};var _0x272b85={'count':0x0,'rows':[]};return db[_0x2e5f('0x20')][_0x2e5f('0x79')]({'where':{'id':_0x13393c[_0x2e5f('0x22')]['id']}})[_0x2e5f('0x14')](handleEntityNotFound(_0x2bf8fa,null))[_0x2e5f('0x14')](function(_0x45deef){if(_0x45deef){_0x3b6e2f[_0x2e5f('0x7a')]=_[_0x2e5f('0x31')](db[_0x2e5f('0xa3')][_0x2e5f('0x7b')]);_0x3b6e2f[_0x2e5f('0x1d')]=_[_0x2e5f('0x31')](_0x13393c['query']);_0x3b6e2f[_0x2e5f('0x81')]=_[_0x2e5f('0x7c')](_0x3b6e2f[_0x2e5f('0x7a')],_0x3b6e2f[_0x2e5f('0x1d')]);_0x35ae18[_0x2e5f('0x7d')]=_[_0x2e5f('0x7c')](_0x3b6e2f['model'],qs['fields'](_0x13393c[_0x2e5f('0x1d')][_0x2e5f('0x7e')]));_0x35ae18['attributes']=_0x35ae18['attributes'][_0x2e5f('0x29')]?_0x35ae18[_0x2e5f('0x7d')]:_0x3b6e2f[_0x2e5f('0x7a')];if(!_0x13393c[_0x2e5f('0x1d')]['hasOwnProperty'](_0x2e5f('0x85'))){_0x35ae18[_0x2e5f('0x11')]=qs[_0x2e5f('0x11')](_0x13393c[_0x2e5f('0x1d')][_0x2e5f('0x11')]);_0x35ae18['offset']=qs['offset'](_0x13393c[_0x2e5f('0x1d')][_0x2e5f('0x86')]);}_0x35ae18[_0x2e5f('0x7f')]=qs[_0x2e5f('0x80')](_0x13393c[_0x2e5f('0x1d')][_0x2e5f('0x80')]);_0x35ae18[_0x2e5f('0x5b')]=qs[_0x2e5f('0x81')](_[_0x2e5f('0x9d')](_0x13393c[_0x2e5f('0x1d')],_0x3b6e2f[_0x2e5f('0x81')]));_0x35ae18[_0x2e5f('0x5b')]['ContactId']=_0x45deef['id'];if(_0x13393c[_0x2e5f('0x1d')][_0x2e5f('0x82')]){_0x35ae18[_0x2e5f('0x5b')]=_['merge'](_0x35ae18[_0x2e5f('0x5b')],{'$or':_[_0x2e5f('0x6b')](_0x35ae18[_0x2e5f('0x7d')],function(_0x212c2f){var _0x14c06b={};_0x14c06b[_0x212c2f]={'$like':'%'+_0x13393c[_0x2e5f('0x1d')]['filter']+'%'};return _0x14c06b;})});}_0x35ae18=_['merge']({},_0x35ae18,_0x13393c[_0x2e5f('0x84')]);return db['CmHopperFinal'][_0x2e5f('0x12')]({'where':_0x35ae18[_0x2e5f('0x5b')]})[_0x2e5f('0x14')](function(_0x47bdb1){_0x272b85[_0x2e5f('0x12')]=_0x47bdb1;if(_0x13393c[_0x2e5f('0x1d')][_0x2e5f('0x9f')]){_0x35ae18[_0x2e5f('0xa4')]=[{'all':!![]}];}return db['CmHopperFinal'][_0x2e5f('0x1c')](_0x35ae18);})[_0x2e5f('0x14')](function(_0x276bd4){_0x272b85[_0x2e5f('0xa0')]=_0x276bd4;return _0x272b85;});}})[_0x2e5f('0x14')](respondWithFilteredResult(_0x2bf8fa,_0x35ae18))[_0x2e5f('0x23')](handleError(_0x2bf8fa,null));};exports[_0x2e5f('0xa5')]=function(_0x34e4c6,_0x2aad86){var _0xc5f13c={'raw':!![],'where':{}};var _0x27760d={};var _0x4e2d84={'count':0x0,'rows':[]};return db[_0x2e5f('0x20')][_0x2e5f('0x79')]({'where':{'id':_0x34e4c6[_0x2e5f('0x22')]['id']}})[_0x2e5f('0x14')](handleEntityNotFound(_0x2aad86,null))[_0x2e5f('0x14')](function(_0x1f4558){if(_0x1f4558){_0x27760d[_0x2e5f('0x7a')]=_[_0x2e5f('0x31')](db[_0x2e5f('0x50')][_0x2e5f('0x7b')]);_0x27760d[_0x2e5f('0x1d')]=_[_0x2e5f('0x31')](_0x34e4c6[_0x2e5f('0x1d')]);_0x27760d[_0x2e5f('0x81')]=_[_0x2e5f('0x7c')](_0x27760d[_0x2e5f('0x7a')],_0x27760d['query']);_0xc5f13c[_0x2e5f('0x7d')]=_[_0x2e5f('0x7c')](_0x27760d[_0x2e5f('0x7a')],qs['fields'](_0x34e4c6['query'][_0x2e5f('0x7e')]));_0xc5f13c[_0x2e5f('0x7d')]=_0xc5f13c[_0x2e5f('0x7d')][_0x2e5f('0x29')]?_0xc5f13c[_0x2e5f('0x7d')]:_0x27760d[_0x2e5f('0x7a')];if(!_0x34e4c6[_0x2e5f('0x1d')]['hasOwnProperty'](_0x2e5f('0x85'))){_0xc5f13c[_0x2e5f('0x11')]=qs[_0x2e5f('0x11')](_0x34e4c6[_0x2e5f('0x1d')][_0x2e5f('0x11')]);_0xc5f13c[_0x2e5f('0x86')]=qs[_0x2e5f('0x86')](_0x34e4c6[_0x2e5f('0x1d')][_0x2e5f('0x86')]);}_0xc5f13c[_0x2e5f('0x7f')]=qs[_0x2e5f('0x80')](_0x34e4c6['query']['sort']);_0xc5f13c['where']=qs[_0x2e5f('0x81')](_[_0x2e5f('0x9d')](_0x34e4c6[_0x2e5f('0x1d')],_0x27760d[_0x2e5f('0x81')]));_0xc5f13c[_0x2e5f('0x5b')][_0x2e5f('0x9e')]=_0x1f4558['id'];if(_0x34e4c6[_0x2e5f('0x1d')][_0x2e5f('0x82')]){_0xc5f13c[_0x2e5f('0x5b')]=_[_0x2e5f('0x83')](_0xc5f13c['where'],{'$or':_[_0x2e5f('0x6b')](_0xc5f13c[_0x2e5f('0x7d')],function(_0x565a62){var _0x515105={};_0x515105[_0x565a62]={'$like':'%'+_0x34e4c6[_0x2e5f('0x1d')][_0x2e5f('0x82')]+'%'};return _0x515105;})});}_0xc5f13c=_[_0x2e5f('0x83')]({},_0xc5f13c,_0x34e4c6[_0x2e5f('0x84')]);return db['JscriptySessionReport']['count']({'where':_0xc5f13c['where']})[_0x2e5f('0x14')](function(_0x1ed3bf){_0x4e2d84['count']=_0x1ed3bf;if(_0x34e4c6[_0x2e5f('0x1d')][_0x2e5f('0x9f')]){_0xc5f13c[_0x2e5f('0xa4')]=[{'all':!![]}];}return db[_0x2e5f('0x50')][_0x2e5f('0x1c')](_0xc5f13c);})[_0x2e5f('0x14')](function(_0x40abd3){_0x4e2d84[_0x2e5f('0xa0')]=_0x40abd3;return _0x4e2d84;});}})[_0x2e5f('0x14')](respondWithFilteredResult(_0x2aad86,_0xc5f13c))[_0x2e5f('0x23')](handleError(_0x2aad86,null));};exports[_0x2e5f('0xa6')]=function(_0x87d8fa,_0x32266d){try{if(!_0x87d8fa[_0x2e5f('0x33')][_0x2e5f('0x5d')]){throw new Error(_0x2e5f('0xa7'));}if(!_0x87d8fa['body'][_0x2e5f('0xa8')]){throw new Error(_0x2e5f('0xa9'));}if(!_0x87d8fa['body'][_0x2e5f('0xaa')]){throw new Error(_0x2e5f('0xab'));}if(!_0x87d8fa[_0x2e5f('0x33')]['socket_timestamp']){throw new Error(_0x2e5f('0xac'));}var _0x7fab2c=_0x87d8fa[_0x2e5f('0x33')][_0x2e5f('0xa8')][_0x2e5f('0xad')](',');var _0x174aff=_0x87d8fa[_0x2e5f('0x33')][_0x2e5f('0xaa')]['split'](',');if(!_0x7fab2c[_0x2e5f('0x29')]||!_0x174aff['length']||_0x7fab2c[_0x2e5f('0x29')]!==_0x174aff[_0x2e5f('0x29')]){throw new Error(_0x2e5f('0xae'));}_0x87d8fa[_0x2e5f('0x33')][_0x2e5f('0x7e')]=_[_0x2e5f('0xaf')](_0x7fab2c,_0x174aff);if(!_0x87d8fa[_0x2e5f('0x33')]['fields'][_0x2e5f('0x78')]){throw new Error('No\x20phone\x20column\x20specified');}if(!_0x87d8fa['body'][_0x2e5f('0x7e')][_0x2e5f('0xb0')]){throw new Error('No\x20firstName\x20column\x20specified');}var _0x505857=path[_0x2e5f('0x39')](config[_0x2e5f('0xb1')],_0x2e5f('0xb2'),_0x87d8fa[_0x2e5f('0xb3')][_0x2e5f('0xb4')]);fs['chmodSync'](_0x505857,parseInt(_0x2e5f('0xb5'),0x8));var _0x5d3cb7=require(_0x2e5f('0xb6'))[_0x2e5f('0xb7')](path[_0x2e5f('0x39')](__dirname,_0x2e5f('0xb8')),[_0x505857,_0x87d8fa[_0x2e5f('0x33')][_0x2e5f('0xa8')],_0x87d8fa[_0x2e5f('0x33')][_0x2e5f('0xaa')],_0x87d8fa[_0x2e5f('0x33')][_0x2e5f('0x5d')],_0x87d8fa['body']['CompanyId'],_0x87d8fa[_0x2e5f('0x33')]['duplicates'],_0x87d8fa[_0x2e5f('0x33')][_0x2e5f('0xb9')]]);return _0x32266d['status'](0xc8)[_0x2e5f('0xba')]({'message':'File\x20uploaded\x20correctly!','pid':_0x5d3cb7[_0x2e5f('0xbb')]});}catch(_0x550ba4){return _0x32266d[_0x2e5f('0xf')](0x1f4)['send'](_0x550ba4);}};exports[_0x2e5f('0xbc')]=function(_0x278654,_0x151029){var _0x4d8d86=fs[_0x2e5f('0xbd')](_0x278654['file'][_0x2e5f('0xbe')]);Papa[_0x2e5f('0xbf')](_0x4d8d86,{'header':!![],'skipEmptyLines':!![],'preview':0x1,'complete':function(_0x83bbd6){return _0x151029['status'](0xc8)[_0x2e5f('0xba')]({'file':_0x278654[_0x2e5f('0xb3')],'fields':_0x83bbd6[_0x2e5f('0xc0')]['fields']});}});};exports['import']=function(_0x48153f,_0x215640){return db[_0x2e5f('0xc1')][_0x2e5f('0x1c')]({'raw':!![],'attributes':['id'],'where':{'role':_0x2e5f('0xc2')}})[_0x2e5f('0x14')](function(_0x24c0ff){var _0x41a8d5=![];if(!_0x48153f['body'][_0x2e5f('0x5d')]){throw new Error(_0x2e5f('0xa7'));}if(!_0x48153f[_0x2e5f('0x33')]['binding']['phone']){throw new Error(_0x2e5f('0xc3'));}if(!_0x48153f[_0x2e5f('0x33')][_0x2e5f('0xc4')]['firstName']){throw new Error(_0x2e5f('0xc5'));}if(!_0x48153f[_0x2e5f('0x33')][_0x2e5f('0xb9')]){throw new Error(_0x2e5f('0xac'));}var _0x1ec52c=require(_0x2e5f('0xb6'))['fork'](path['join'](__dirname,_0x2e5f('0xc6')),[_0x48153f['params']['id'],JSON[_0x2e5f('0xc7')](_0x48153f[_0x2e5f('0x33')]),JSON[_0x2e5f('0xc7')](_0x24c0ff)]);_0x1ec52c['on'](_0x2e5f('0xc8'),function(){_0x41a8d5=!![];return _0x215640[_0x2e5f('0xf')](0xc8)[_0x2e5f('0xba')]({'message':'start\x20child\x20process\x20correctly!','pid':_0x1ec52c['pid']});});_0x1ec52c['on'](_0x2e5f('0xc9'),function(_0xf07070){if(_0xf07070&&!_0x41a8d5){return _0x215640[_0x2e5f('0xf')](0x1f4)[_0x2e5f('0xba')]({'message':'error\x20child\x20process','pid':_0x1ec52c[_0x2e5f('0xbb')]});}});})['catch'](handleError(_0x215640,null));};exports[_0x2e5f('0xca')]=function(_0x39c825,_0x44ab0c){return db[_0x2e5f('0xc1')][_0x2e5f('0x1c')]({'raw':!![],'attributes':['id'],'where':{'role':_0x2e5f('0xc2')}})['then'](function(_0x5466b7){var _0x6bcb7d=![];if(!_0x39c825[_0x2e5f('0x33')][_0x2e5f('0x5d')]){throw new Error(_0x2e5f('0xa7'));}if(!_0x39c825[_0x2e5f('0x33')]['binding']['phone']){throw new Error(_0x2e5f('0xc3'));}if(!_0x39c825[_0x2e5f('0x33')]['binding'][_0x2e5f('0xb0')]){throw new Error(_0x2e5f('0xc5'));}if(!_0x39c825[_0x2e5f('0x33')][_0x2e5f('0xb9')]){throw new Error('Unable\x20to\x20synchronize\x20socket,\x20no\x20timestamp\x20passed');}var _0x2bf851=require(_0x2e5f('0xb6'))['fork'](path[_0x2e5f('0x39')](__dirname,_0x2e5f('0xcb')),[_0x39c825[_0x2e5f('0x22')]['id'],JSON[_0x2e5f('0xc7')](_0x39c825[_0x2e5f('0x33')]),JSON[_0x2e5f('0xc7')](_0x5466b7)]);_0x2bf851['on']('message',function(){_0x6bcb7d=!![];return _0x44ab0c[_0x2e5f('0xf')](0xc8)[_0x2e5f('0xba')]({'message':'start\x20child\x20process\x20correctly!','pid':_0x2bf851[_0x2e5f('0xbb')]});});_0x2bf851['on'](_0x2e5f('0xc9'),function(_0x4de9d2){if(_0x4de9d2&&!_0x6bcb7d){return _0x44ab0c[_0x2e5f('0xf')](0x1f4)[_0x2e5f('0xba')]({'message':'error\x20child\x20process','pid':_0x2bf851['pid']});}});})[_0x2e5f('0x23')](handleError(_0x44ab0c,null));};exports[_0x2e5f('0xcc')]=function(_0x18ba5f,_0x2dafbc){var _0xc917c=[_0x2e5f('0xcd'),_0x2e5f('0xce'),_0x2e5f('0xcf'),_0x2e5f('0xd0'),_0x2e5f('0xd1'),_0x2e5f('0xd2'),'voice'];var _0xc79ce3={'offset':0x0,'order':qs[_0x2e5f('0x80')](_0x2e5f('0xd3'))},_0x44be17={'count':0x0,'rows':[]};Promise[_0x2e5f('0xd4')]()[_0x2e5f('0x14')](function(){if(_0x18ba5f['query']['channel']){if(!_['includes'](_0xc917c,_0x18ba5f[_0x2e5f('0x1d')][_0x2e5f('0xd5')][_0x2e5f('0xd6')]())){throw new Error(_0x2e5f('0xd7'));}_0xc917c=[_0x18ba5f[_0x2e5f('0x1d')][_0x2e5f('0xd5')][_0x2e5f('0xd6')]()];}if(_0x18ba5f[_0x2e5f('0x1d')][_0x2e5f('0xd8')]){try{var _0x1c4873=JSON[_0x2e5f('0xbf')](_0x18ba5f[_0x2e5f('0x1d')][_0x2e5f('0xd8')]);if(!moment(_0x1c4873[_0x2e5f('0x34')])[_0x2e5f('0xd9')]()){throw new Error(_0x2e5f('0xda'));}if(!moment(_0x1c4873['to'])['isValid']()){throw new Error('Invalid\x20date\x20for\x20range\x20to\x20filter');}}catch(_0x2fc1b5){throw new Error(_0x2e5f('0xdb'));}}if(!_0x18ba5f[_0x2e5f('0x1d')][_0x2e5f('0x32')](_0x2e5f('0x85'))){_0xc79ce3['limit']=qs[_0x2e5f('0x11')](_0x18ba5f['query'][_0x2e5f('0x11')]||0xa);_0xc79ce3[_0x2e5f('0x86')]=qs['offset'](_0x18ba5f[_0x2e5f('0x1d')][_0x2e5f('0x86')]);}var _0x3e8856=_0xc917c[_0x2e5f('0x6b')](function(_0x354ce8){if(_0x354ce8===_0x2e5f('0xdc')){var _0x311124={'attributes':['id','uniqueid',_0x2e5f('0x2d'),_0x2e5f('0xdd'),_0x2e5f('0xde'),_0x2e5f('0xdf'),_0x2e5f('0xe0'),'endtime',_0x2e5f('0xe1'),_0x2e5f('0xe2'),'createdAt',_0x2e5f('0xe3'),_0x2e5f('0xe4'),'userThirdDisposition',_0x2e5f('0xe5')],'where':{'ContactId':_0x18ba5f[_0x2e5f('0x22')]['id']},'include':[{'model':db[_0x2e5f('0xc1')],'as':_0x2e5f('0xc1'),'attributes':['id',_0x2e5f('0x18'),'fullname',_0x2e5f('0x2b')]}],'order':[[_0x2e5f('0xe6'),'DESC']]};if(_0x18ba5f[_0x2e5f('0x1d')][_0x2e5f('0xd8')]){_0x311124[_0x2e5f('0x5b')]['createdAt']={'$gte':_0x1c4873['from'],'$lte':_0x1c4873['to']};}return db['VoiceCallReport'][_0x2e5f('0xe7')](_0x311124)[_0x2e5f('0x14')](function(_0x732259){_0x44be17[_0x2e5f('0x12')]+=_0x732259[_0x2e5f('0x12')];return _[_0x2e5f('0x6b')](_0x732259[_0x2e5f('0xa0')],function(_0x545dea){var _0x4cb946=_0x545dea[_0x2e5f('0x35')]({'plain':!![]});_0x4cb946[_0x2e5f('0xd5')]=_0x354ce8;if(_0x4cb946['User']){_0x4cb946[_0x2e5f('0xc1')]={'id':_0x4cb946[_0x2e5f('0xc1')]['id'],'name':_0x4cb946[_0x2e5f('0xc1')][_0x2e5f('0x18')],'fullname':_0x4cb946[_0x2e5f('0xc1')]['fullname'],'alias':_0x4cb946['User'][_0x2e5f('0x2b')]};}return _0x4cb946;});});}else{var _0x5ed8d7=_[_0x2e5f('0xe8')](_0x354ce8)+(_0x354ce8===_0x2e5f('0xce')?_0x2e5f('0xe9'):_0x2e5f('0xea'));var _0x27eaf8={'attributes':['id',_0x2e5f('0xeb'),'closedAt',_0x2e5f('0xe6'),_0x2e5f('0xe2'),_0x2e5f('0xec'),'secondDisposition',_0x2e5f('0xed'),'UserId',_0x5ed8d7+'Id'],'where':{'ContactId':_0x18ba5f[_0x2e5f('0x22')]['id']},'include':[{'model':db[_0x5ed8d7],'as':_0x2e5f('0xea'),'attributes':['id','name',_0x2e5f('0xee')]},{'model':db[_0x2e5f('0xc1')],'as':_0x2e5f('0xef'),'attributes':['id',_0x2e5f('0x18'),_0x2e5f('0xf0')]},{'model':db[_0x2e5f('0x63')],'as':_0x2e5f('0x64'),'attributes':['id',_0x2e5f('0x18'),_0x2e5f('0xf1')],'through':{'attributes':[]}}],'order':[[_0x2e5f('0xe6'),_0x2e5f('0xf2')]]};if(_0x18ba5f['query'][_0x2e5f('0xd8')]){_0x27eaf8[_0x2e5f('0x5b')][_0x2e5f('0xe6')]={'$gte':_0x1c4873[_0x2e5f('0x34')],'$lte':_0x1c4873['to']};}switch(_0x354ce8){case'chat':_0x27eaf8[_0x2e5f('0x7d')]['push'](_0x2e5f('0xf3'),'customerIp',_0x2e5f('0xf4'),_0x2e5f('0xf5'),_0x2e5f('0xf6'),_0x2e5f('0xf7'),_0x2e5f('0xf8'),'ratingValue',_0x2e5f('0xf9'));break;case'mail':_0x27eaf8[_0x2e5f('0x7d')][_0x2e5f('0x5f')]('subject',_0x2e5f('0xfa'));break;case _0x2e5f('0xd0'):_0x27eaf8[_0x2e5f('0x7d')][_0x2e5f('0x5f')]('externalUrl','threadId');break;}return db[_[_0x2e5f('0xe8')](_0x354ce8)+_0x2e5f('0xfb')][_0x2e5f('0xe7')](_0x27eaf8)[_0x2e5f('0x14')](function(_0x3e806a){_0x44be17[_0x2e5f('0x12')]+=_0x3e806a['count'];return _[_0x2e5f('0x6b')](_0x3e806a[_0x2e5f('0xa0')],function(_0x106685){var _0x3a7887=_0x106685[_0x2e5f('0x35')]({'plain':!![]});_0x3a7887[_0x2e5f('0xd5')]=_0x354ce8;if(_0x3a7887[_0x2e5f('0xef')]){_0x3a7887['Owner']={'id':_0x3a7887[_0x2e5f('0xef')]['id'],'name':_0x3a7887[_0x2e5f('0xef')][_0x2e5f('0x18')],'fullname':_0x3a7887[_0x2e5f('0xef')]['fullname']};}return _0x3a7887;});});}});return Promise[_0x2e5f('0x61')](_0x3e8856);})[_0x2e5f('0x14')](function(_0x36dc04){return _(_0x36dc04)[_0x2e5f('0xfc')]()[_0x2e5f('0xfd')]('createdAt')[_0x2e5f('0xfe')]()[_0x2e5f('0xff')]();})[_0x2e5f('0x14')](function(_0x381cfa){_0x44be17[_0x2e5f('0xa0')]=_0xc79ce3[_0x2e5f('0x11')]?_0x381cfa['slice'](_0xc79ce3[_0x2e5f('0x86')],_0xc79ce3['offset']+_0xc79ce3[_0x2e5f('0x11')]):_0x381cfa;return _0x44be17;})['then'](respondWithFilteredResult(_0x2dafbc,_0xc79ce3))[_0x2e5f('0x23')](handleError(_0x2dafbc,null));};
\ No newline at end of file