Built motion from commit (unavailable).|2.5.23
[motion2.git] / server / api / cmContact / cmContact.controller.js
index 50f9220..a86f732 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xe1d1=['fork','../../components/import/cm/csv','CompanyId','socket_timestamp','File\x20uploaded\x20correctly!','pid','upload','createReadStream','parse','meta','import','User','agent','binding','No\x20firstName\x20column\x20specified','../../components/import/cm/csv2','stringify','message','start\x20child\x20process\x20correctly!','exit','error\x20child\x20process','html-pdf','eml-format','rimraf','zip-dir','request-promise','moment','bluebird','mustache','path','to-csv','ejs','lodash','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','defaults','redis','./cmContact.socket','register','sendStatus','status','end','json','count','offset','limit','set','Content-Range','apply','reject','save','update','then','destroy','error','name','send','CmContact','describe','keys','length','cf_','CmCustomField','findOne','trimStart','all','fieldType','type','model','query','filters','intersection','attributes','fields','hasOwnProperty','nolimit','where','field','color','from','tools_tags','cm_contacts','left_join','cm_user_has_contacts','uc.CmContactId\x20=\x20c.id','cm_contact_has_tags','t.id\x20=\x20ct.TagId','c.deletedAt\x20IS\x20NULL','expr','search','parseSearch','sqlOperator','conditions','Tag','value','split','forEach','CONCAT(\x27,\x27,\x20`TagIds`,\x20\x27,\x27)\x20LIKE\x20?','uc.UserId\x20=\x20?','datetime','castTo','buildExpression','text','start','map','isNil','Contact','ListId','c.ListId\x20IN\x20?','concat','CONCAT_WS(\x27\x20\x27,\x20c.firstName,\x20c.lastName,\x20c.email)\x20LIKE\x20?','\x20=\x20?','tag','isArray','filter','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.mobile\x20LIKE\x20?','c.fax\x20LIKE\x20?','isEmail','c.email\x20LIKE\x20?','c.firstName\x20LIKE\x20?','c.lastName\x20LIKE\x20?','group','c.id','Sequelize','QueryTypes','SELECT','clone','order','having','t.id\x20IN\x20?','resolve','some','user','getLists','c.ListId\x20IS\x20NULL','sequelize','toString','keyBy','merge','c.firstName','c.lastName','c.phone','c.mobile','c.email','c.deletedAt','GROUP_CONCAT(DISTINCT\x20t.id)','TagIds','Tags','rows','catch','find','params','tags','startsWith','columnName','findAll','displayName','alias','custom','values','body','get','join','info','CmHopper','[CmContact][merge][destroy][CmHopper],\x20%s','CmHopperBlack','[CmContact][merge][destroy][CmHopperBlack],\x20%s','create','ChatInteraction','ChatMessage','ChatOfflineMessage','MailInteraction','MailMessage','SmsInteraction','SmsMessage','FaxInteraction','FaxMessage','OpenchannelInteraction','OpenchannelMessage','CmHopperFinal','CmHopperHistory','ReportAgentPreview','VoiceCallReport','ChatQueueReport','FaxQueueReport','MailQueueReport','OpenchannelQueueReport','SmsQueueReport','JscriptySessionReport','bulkCreate','each','duplicates','$or','push','findOrCreate','spread','$and','omit','format','cf_%d','isEmpty','table','setFields','id\x20=\x20?','toParam','phone','getTags','rawAttributes','sort','pick','options','setTags','ids','getHoppers','ContactId','includeAll','include','getJscriptySessions','uploadCsv','binding_keys','No\x20association\x20keys\x20specified!','binding_values','No\x20association\x20values\x20specified!','Unable\x20to\x20synchronize\x20socket,\x20no\x20timestamp\x20passed','Incorrect\x20binding\x20parameters\x20passed!','zipObject','firstName','root','server/files/tmp','file','filename','chmodSync','child_process'];(function(_0x263a2f,_0x1e81e3){var _0x8020e8=function(_0x39f91a){while(--_0x39f91a){_0x263a2f['push'](_0x263a2f['shift']());}};_0x8020e8(++_0x1e81e3);}(_0xe1d1,0x10f));var _0x1e1d=function(_0x1b6186,_0x1ec7f2){_0x1b6186=_0x1b6186-0x0;var _0x186121=_0xe1d1[_0x1b6186];return _0x186121;};'use strict';var pdf=require(_0x1e1d('0x0'));var emlformat=require(_0x1e1d('0x1'));var rimraf=require(_0x1e1d('0x2'));var zipdir=require(_0x1e1d('0x3'));var jsonpatch=require('fast-json-patch');var rp=require(_0x1e1d('0x4'));var moment=require(_0x1e1d('0x5'));var BPromise=require(_0x1e1d('0x6'));var Mustache=require(_0x1e1d('0x7'));var util=require('util');var path=require(_0x1e1d('0x8'));var sox=require('sox');var csv=require(_0x1e1d('0x9'));var ejs=require(_0x1e1d('0xa'));var fs=require('fs');var _=require(_0x1e1d('0xb'));var squel=require('squel');var crypto=require(_0x1e1d('0xc'));var jsforce=require(_0x1e1d('0xd'));var deskjs=require(_0x1e1d('0xe'));var toCsv=require(_0x1e1d('0x9'));var querystring=require(_0x1e1d('0xf'));var Papa=require(_0x1e1d('0x10'));var Redis=require(_0x1e1d('0x11'));var authService=require('../../components/auth/service');var qs=require(_0x1e1d('0x12'));var as=require(_0x1e1d('0x13'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x1e1d('0x14'))(_0x1e1d('0x15'));var utils=require(_0x1e1d('0x16'));var config=require(_0x1e1d('0x17'));var licenseUtil=require(_0x1e1d('0x18'));var db=require(_0x1e1d('0x19'))['db'];config['redis']=_[_0x1e1d('0x1a')](config['redis'],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x1e1d('0x1b')]));require(_0x1e1d('0x1c'))[_0x1e1d('0x1d')](socket);function respondWithStatusCode(_0x207808,_0x650034){_0x650034=_0x650034||0xcc;return function(_0x3e6fb1){if(_0x3e6fb1){return _0x207808[_0x1e1d('0x1e')](_0x650034);}return _0x207808[_0x1e1d('0x1f')](_0x650034)[_0x1e1d('0x20')]();};}function respondWithResult(_0x5c1e28,_0x381fc2){_0x381fc2=_0x381fc2||0xc8;return function(_0x47c3d5){if(_0x47c3d5){return _0x5c1e28[_0x1e1d('0x1f')](_0x381fc2)[_0x1e1d('0x21')](_0x47c3d5);}};}function respondWithFilteredResult(_0x5c9a04,_0x42d785){return function(_0xab31a9){if(_0xab31a9){var _0x22ed47=_0xab31a9[_0x1e1d('0x22')],_0x3c16d9=_0x42d785[_0x1e1d('0x23')],_0x34cde2=_0x42d785['offset']+_0x42d785[_0x1e1d('0x24')],_0x375a07;if(_0x34cde2>=_0x22ed47){_0x34cde2=_0x22ed47;_0x375a07=0xc8;}else{_0x375a07=0xce;}_0x5c9a04[_0x1e1d('0x1f')](_0x375a07);return _0x5c9a04[_0x1e1d('0x25')](_0x1e1d('0x26'),_0x3c16d9+'-'+_0x34cde2+'/'+_0x22ed47)[_0x1e1d('0x21')](_0xab31a9);}return null;};}function patchUpdates(_0x1dd8c5){return function(_0x138fe1){try{jsonpatch[_0x1e1d('0x27')](_0x138fe1,_0x1dd8c5,!![]);}catch(_0x59fa42){return BPromise[_0x1e1d('0x28')](_0x59fa42);}return _0x138fe1[_0x1e1d('0x29')]();};}function saveUpdates(_0x4681a1,_0x54215e){return function(_0x3682cb){if(_0x3682cb){return _0x3682cb[_0x1e1d('0x2a')](_0x4681a1)[_0x1e1d('0x2b')](function(_0x474999){return _0x474999;});}return null;};}function removeEntity(_0x4c9780,_0x206d5a){return function(_0x35f9df){if(_0x35f9df){return _0x35f9df[_0x1e1d('0x2c')]()[_0x1e1d('0x2b')](function(){_0x4c9780['status'](0xcc)[_0x1e1d('0x20')]();});}};}function handleEntityNotFound(_0x182048,_0x5cab21){return function(_0x79b54d){if(!_0x79b54d){_0x182048[_0x1e1d('0x1e')](0x194);}return _0x79b54d;};}function handleError(_0xd67ea4,_0x5452b0){_0x5452b0=_0x5452b0||0x1f4;return function(_0x18ffa4){logger[_0x1e1d('0x2d')](_0x18ffa4['stack']);if(_0x18ffa4['name']){delete _0x18ffa4[_0x1e1d('0x2e')];}_0xd67ea4[_0x1e1d('0x1f')](_0x5452b0)[_0x1e1d('0x2f')](_0x18ffa4);};}exports['index']=function(_0x4c268d,_0x43f8d6){var _0x5ed3b0={},_0x50a31f={},_0x166dc3={'count':0x0,'rows':[]};return db[_0x1e1d('0x30')][_0x1e1d('0x31')]()['then'](function(_0x4bce08){var _0xa895d5=[];for(var _0x244eb0=0x0;_0x244eb0<Object[_0x1e1d('0x32')](_0x4bce08)[_0x1e1d('0x33')];_0x244eb0++){var _0x4940a2=Object[_0x1e1d('0x32')](_0x4bce08)[_0x244eb0];if(_['startsWith'](_0x4940a2,_0x1e1d('0x34'))){_0xa895d5['push'](db[_0x1e1d('0x35')][_0x1e1d('0x36')]({'where':{'id':_[_0x1e1d('0x37')](_0x4940a2,_0x1e1d('0x34'))},'raw':!![]}));}}return BPromise[_0x1e1d('0x38')](_0xa895d5)[_0x1e1d('0x2b')](function(_0x1446c3){for(var _0x34ab1e=0x0;_0x34ab1e<_0x1446c3['length'];_0x34ab1e++){if(_0x1446c3[_0x34ab1e]){var _0x6e2ff8=_0x1e1d('0x34')+_0x1446c3[_0x34ab1e]['id'];var _0x243bfe=_0x4bce08[_0x6e2ff8];_0x243bfe[_0x1e1d('0x39')]=_0x1446c3[_0x34ab1e][_0x1e1d('0x3a')];}}return _0x4bce08;});})['then'](function(_0x1f2c8c){_0x50a31f[_0x1e1d('0x3b')]=_[_0x1e1d('0x32')](_0x1f2c8c);_0x50a31f[_0x1e1d('0x3c')]=_[_0x1e1d('0x32')](_0x4c268d[_0x1e1d('0x3c')]);_0x50a31f[_0x1e1d('0x3d')]=_[_0x1e1d('0x3e')](_0x50a31f[_0x1e1d('0x3b')],_0x50a31f[_0x1e1d('0x3c')]);_0x5ed3b0[_0x1e1d('0x3f')]=_[_0x1e1d('0x3e')](_0x50a31f['model'],qs['fields'](_0x4c268d[_0x1e1d('0x3c')][_0x1e1d('0x40')]));_0x5ed3b0[_0x1e1d('0x3f')]=_0x5ed3b0[_0x1e1d('0x3f')][_0x1e1d('0x33')]?_0x5ed3b0[_0x1e1d('0x3f')]:_0x50a31f[_0x1e1d('0x3b')];if(!_0x4c268d[_0x1e1d('0x3c')][_0x1e1d('0x41')](_0x1e1d('0x42'))){_0x5ed3b0['limit']=qs[_0x1e1d('0x24')](_0x4c268d['query']['limit']);_0x5ed3b0[_0x1e1d('0x23')]=qs[_0x1e1d('0x23')](_0x4c268d[_0x1e1d('0x3c')][_0x1e1d('0x23')]);}_0x5ed3b0['order']=qs['sort'](_0x4c268d[_0x1e1d('0x3c')]['sort']);_0x5ed3b0[_0x1e1d('0x43')]=qs[_0x1e1d('0x3d')](_['pick'](_0x4c268d[_0x1e1d('0x3c')],_0x50a31f[_0x1e1d('0x3d')]),_0x1f2c8c);var _0x2decbd=[];var _0x31355f=squel['select']()['field']('id')[_0x1e1d('0x44')](_0x1e1d('0x2e'))[_0x1e1d('0x44')](_0x1e1d('0x45'))[_0x1e1d('0x46')](_0x1e1d('0x47'));var _0x4ff187=squel['select']()[_0x1e1d('0x46')](_0x1e1d('0x48'),'c')[_0x1e1d('0x49')](_0x1e1d('0x4a'),'uc',_0x1e1d('0x4b'))[_0x1e1d('0x49')](_0x1e1d('0x4c'),'ct','ct.CmContactId\x20=\x20c.id')[_0x1e1d('0x49')](_0x1e1d('0x47'),'t',_0x1e1d('0x4d'))[_0x1e1d('0x43')](_0x1e1d('0x4e'));var _0x912c61=squel[_0x1e1d('0x4f')]();var _0x58a67c=[];var _0x8c89eb=squel[_0x1e1d('0x4f')]();var _0x6e6b7e;if(_0x4c268d[_0x1e1d('0x3c')][_0x1e1d('0x50')]){_0x6e6b7e=as[_0x1e1d('0x51')](_0x4c268d['query'][_0x1e1d('0x50')]);var _0x55adb7=_0x6e6b7e[_0x1e1d('0x52')];for(var _0x35e825=0x0;_0x35e825<_0x6e6b7e[_0x1e1d('0x53')][_0x1e1d('0x33')];_0x35e825++){var _0x2cd759=_0x6e6b7e[_0x1e1d('0x53')][_0x35e825];var _0x1f7190='c';var _0x1e2199=_(_0x1f2c8c)[_0x1e1d('0x32')]()['find'](function(_0x1bc5f9){return _0x1bc5f9===_0x2cd759[_0x1e1d('0x44')];});if(_0x1e2199)_0x1e2199=_0x1f2c8c[_0x2cd759['field']];if(!_0x1e2199){if(_0x2cd759[_0x1e1d('0x44')]===_0x1e1d('0x54')){var _0x1a03e9=_0x2cd759[_0x1e1d('0x55')][_0x1e1d('0x56')](',')['map'](function(_0x4ecea5){return Number(_0x4ecea5);});_0x1a03e9[_0x1e1d('0x57')](function(_0x34cba2){_0x8c89eb['or'](_0x1e1d('0x58'),'%,'+_0x34cba2+',%');});_0x58a67c=_['union'](_0x58a67c,_0x1a03e9);}else if(_0x2cd759[_0x1e1d('0x44')]==='User'){_0x912c61['and'](_0x1e1d('0x59'),_0x2cd759[_0x1e1d('0x55')]);}}else{if(_0x2cd759['field']==='dateOfBirth'||_0x1e2199['fieldType']===_0x1e1d('0x5a'))_0x2cd759[_0x1e1d('0x5b')]='DATE';var _0x151909=as[_0x1e1d('0x5c')](_0x1f7190,_0x1e2199[_0x1e1d('0x3a')],_0x2cd759);_0x912c61[_0x55adb7](_0x151909[_0x1e1d('0x5d')],_0x151909[_0x1e1d('0x55')][_0x1e1d('0x5e')],_0x151909['value']['end']);}}}else{var _0x216327=_(Object['keys'](_0x4c268d['query']))[_0x1e1d('0x5f')](function(_0x57ace2){return _0x1f2c8c[_0x1e1d('0x41')](_0x57ace2)?_0x57ace2:undefined;})['filter'](function(_0x446348){return!_[_0x1e1d('0x60')](_0x446348);})[_0x1e1d('0x55')]();if(_0x4c268d[_0x1e1d('0x3c')][_0x1e1d('0x61')])_0x216327['push'](_0x1e1d('0x61'));if(!_['isEmpty'](_0x216327)){_0x216327[_0x1e1d('0x57')](function(_0x4088b7){if(_0x4088b7===_0x1e1d('0x62')){_0x4ff187[_0x1e1d('0x43')](_0x1e1d('0x63'),[][_0x1e1d('0x64')](_0x4c268d['query'][_0x4088b7]));}else if(_0x4088b7===_0x1e1d('0x61')){var _0x2de141='%'+_0x4c268d['query'][_0x4088b7]+'%';_0x4ff187[_0x1e1d('0x43')](_0x1e1d('0x65'),_0x2de141);}else{_0x4ff187[_0x1e1d('0x43')]('c.'+_0x4088b7+_0x1e1d('0x66'),_0x4c268d[_0x1e1d('0x3c')][_0x4088b7]);}});}if(_0x4c268d[_0x1e1d('0x3c')][_0x1e1d('0x67')]){_0x58a67c=_[_0x1e1d('0x68')](_0x4c268d[_0x1e1d('0x3c')][_0x1e1d('0x67')])?_0x4c268d[_0x1e1d('0x3c')][_0x1e1d('0x67')]:new Array(_0x4c268d['query'][_0x1e1d('0x67')]);_0x58a67c[_0x1e1d('0x57')](function(_0x499801){_0x8c89eb['or'](_0x1e1d('0x58'),'%,'+_0x499801+',%');});}if(_0x4c268d['query'][_0x1e1d('0x69')]){var _0x20bf0e=_0x4c268d[_0x1e1d('0x3c')]['filter'][_0x1e1d('0x6a')]('\x5c','\x5c\x5c')[_0x1e1d('0x6a')](/'/g,'\x27\x27');if(_0x20bf0e[_0x1e1d('0x56')]('\x20')['length']>0x1){_0x912c61['or'](_0x1e1d('0x6b'),qs[_0x1e1d('0x6c')](_0x20bf0e),null);}else{if(qs['isNumeric'](_0x20bf0e)){_0x912c61['or'](_0x1e1d('0x6d'),_0x20bf0e+'%');_0x912c61['or']('c.phone\x20LIKE\x20?',_0x20bf0e+'%');_0x912c61['or'](_0x1e1d('0x6e'),_0x20bf0e+'%');_0x912c61['or'](_0x1e1d('0x6f'),_0x20bf0e+'%');}else if(qs[_0x1e1d('0x70')](_0x20bf0e)){_0x912c61['or'](_0x1e1d('0x71'),_0x20bf0e+'%');}else{_0x912c61['or'](_0x1e1d('0x72'),'%'+_0x20bf0e+'%');_0x912c61['or'](_0x1e1d('0x73'),'%'+_0x20bf0e+'%');_0x912c61['or'](_0x1e1d('0x71'),'%'+_0x20bf0e+'%');}}}}_0x4ff187[_0x1e1d('0x43')](_0x912c61);_0x4ff187[_0x1e1d('0x74')](_0x1e1d('0x75'));var _0x9b8f86={'type':db[_0x1e1d('0x76')][_0x1e1d('0x77')][_0x1e1d('0x78')],'raw':!![]};var _0x185050=_0x4ff187[_0x1e1d('0x79')]()['field'](_0x1e1d('0x75'));if(_0x5ed3b0[_0x1e1d('0x7a')]){_0x5ed3b0[_0x1e1d('0x7a')]['forEach'](function(_0x386e18){_0x4ff187[_0x1e1d('0x7a')]('c.'+_0x386e18[0x0],_0x386e18[0x1]==='DESC'?![]:!![]);});}if(!_['isEmpty'](_0x58a67c)){_0x4ff187[_0x1e1d('0x7b')](_0x8c89eb);_0x185050['where'](_0x1e1d('0x7c'),_0x58a67c);}BPromise[_0x1e1d('0x7d')]()['then'](function(){if(_0x6e6b7e&&!_[_0x1e1d('0x7e')](_0x6e6b7e[_0x1e1d('0x53')],[_0x1e1d('0x44'),'User'])){return _0x4c268d[_0x1e1d('0x7f')][_0x1e1d('0x80')]({'attributes':['id'],'raw':!![]})[_0x1e1d('0x2b')](function(_0x5f1885){if(_['isEmpty'](_0x5f1885)){_0x185050['where'](_0x1e1d('0x81'));_0x4ff187[_0x1e1d('0x43')](_0x1e1d('0x81'));}else{_0x185050[_0x1e1d('0x43')](_0x1e1d('0x63'),_['map'](_0x5f1885,'id'));_0x4ff187['where'](_0x1e1d('0x63'),_[_0x1e1d('0x5f')](_0x5f1885,'id'));}});}else{return;}})[_0x1e1d('0x2b')](function(){db[_0x1e1d('0x82')][_0x1e1d('0x3c')](_0x185050[_0x1e1d('0x83')](),_0x9b8f86)['then'](function(_0x382d22){_0x166dc3[_0x1e1d('0x22')]=_0x382d22['length'];if(_0x166dc3[_0x1e1d('0x22')]===0x0)return[];return db[_0x1e1d('0x82')][_0x1e1d('0x3c')](_0x31355f[_0x1e1d('0x83')](),_0x9b8f86);})[_0x1e1d('0x2b')](function(_0x2626e1){_0x2decbd=_[_0x1e1d('0x84')](_0x2626e1,'id');_0x9b8f86=_[_0x1e1d('0x85')](_0x9b8f86,{'model':db[_0x1e1d('0x30')],'mapToModel':!![],'raw':!![],'nest':!![]});if(_0x4c268d[_0x1e1d('0x3c')]['fields']){_0x5ed3b0[_0x1e1d('0x3f')][_0x1e1d('0x57')](function(_0x445d57){_0x4ff187[_0x1e1d('0x44')]('c.'+_0x445d57);});}else{_0x4ff187['field']('c.id');_0x4ff187[_0x1e1d('0x44')](_0x1e1d('0x86'));_0x4ff187[_0x1e1d('0x44')](_0x1e1d('0x87'));_0x4ff187[_0x1e1d('0x44')](_0x1e1d('0x88'));_0x4ff187['field'](_0x1e1d('0x89'));_0x4ff187[_0x1e1d('0x44')]('c.fax');_0x4ff187[_0x1e1d('0x44')](_0x1e1d('0x8a'));_0x4ff187[_0x1e1d('0x44')]('c.ListId');_0x4ff187['field'](_0x1e1d('0x8b'));_0x4ff187[_0x1e1d('0x44')](_0x1e1d('0x8c'),_0x1e1d('0x8d'));}if(_0x5ed3b0[_0x1e1d('0x24')])_0x4ff187[_0x1e1d('0x24')](_0x5ed3b0[_0x1e1d('0x24')]);if(_0x5ed3b0[_0x1e1d('0x23')])_0x4ff187[_0x1e1d('0x23')](_0x5ed3b0['offset']);return db[_0x1e1d('0x82')]['query'](_0x4ff187[_0x1e1d('0x83')](),_0x9b8f86);})[_0x1e1d('0x2b')](function(_0x373532){_0x373532['forEach'](function(_0x49a857){if(_0x49a857['TagIds']){_0x49a857['Tags']=[];_0x49a857['TagIds'][_0x1e1d('0x56')](',')[_0x1e1d('0x57')](function(_0x54d4cc){_0x49a857[_0x1e1d('0x8e')]['push'](_0x2decbd[_0x54d4cc]);});}delete _0x49a857['TagIds'];});_0x166dc3[_0x1e1d('0x8f')]=_0x373532;return _0x166dc3;})[_0x1e1d('0x2b')](respondWithFilteredResult(_0x43f8d6,_0x5ed3b0));});})[_0x1e1d('0x90')](handleError(_0x43f8d6,null));};exports[_0x1e1d('0x2c')]=function(_0x495e2f,_0x47b748){return db[_0x1e1d('0x30')][_0x1e1d('0x91')]({'where':{'id':_0x495e2f[_0x1e1d('0x92')]['id']}})[_0x1e1d('0x2b')](handleEntityNotFound(_0x47b748,null))[_0x1e1d('0x2b')](removeEntity(_0x47b748,null))[_0x1e1d('0x90')](handleError(_0x47b748,null));};exports['describe']=function(_0x128dee,_0x3da4ba){return db[_0x1e1d('0x30')][_0x1e1d('0x31')]()[_0x1e1d('0x2b')](function(_0xb6bb6c){delete _0xb6bb6c[_0x1e1d('0x93')];for(var _0x147ea1=0x0;_0x147ea1<Object[_0x1e1d('0x32')](_0xb6bb6c)[_0x1e1d('0x33')];_0x147ea1++){var _0x2f5877=Object[_0x1e1d('0x32')](_0xb6bb6c)[_0x147ea1];if(!_[_0x1e1d('0x94')](_0x2f5877,'cf_')){_0xb6bb6c[_0x2f5877][_0x1e1d('0x95')]=_0x2f5877;_0xb6bb6c[_0x2f5877]['displayName']=_0x2f5877;}}return _0xb6bb6c;})[_0x1e1d('0x2b')](function(_0x522b2b){var _0x50a473={'where':{'$or':[{'ListId':_0x128dee[_0x1e1d('0x3c')]['id']},{'ListId':null}]},'raw':!![]};return db[_0x1e1d('0x35')][_0x1e1d('0x96')](_0x50a473)[_0x1e1d('0x2b')](function(_0x206b88){for(var _0x50d7da=0x0;_0x50d7da<_0x206b88['length'];_0x50d7da++){var _0x3eeb55=_0x1e1d('0x34')+_0x206b88[_0x50d7da]['id'];_0x522b2b[_0x3eeb55]['columnName']=_0x3eeb55;_0x522b2b[_0x3eeb55][_0x1e1d('0x97')]=_0x206b88[_0x50d7da][_0x1e1d('0x98')];_0x522b2b[_0x3eeb55][_0x1e1d('0x99')]={'type':_0x206b88[_0x50d7da]['type'],'values':_0x206b88[_0x50d7da][_0x1e1d('0x9a')]};}Object[_0x1e1d('0x32')](_0x522b2b)[_0x1e1d('0x57')](function(_0x40c658){if(!_0x522b2b[_0x40c658]['hasOwnProperty'](_0x1e1d('0x95'))){delete _0x522b2b[_0x40c658];}});return _0x522b2b;});})[_0x1e1d('0x2b')](respondWithResult(_0x3da4ba,null))[_0x1e1d('0x90')](handleError(_0x3da4ba,null));};exports[_0x1e1d('0x85')]=function(_0x13051d,_0x22b59a){var _0x1dcaec;var _0x3f5ee6;var _0x199ab7;if(_0x13051d[_0x1e1d('0x9b')]['id']){delete _0x13051d[_0x1e1d('0x9b')]['id'];}return db[_0x1e1d('0x30')]['findAll']({'where':{'id':[_0x13051d[_0x1e1d('0x9b')]['to'],_0x13051d['body']['from']]}})[_0x1e1d('0x2b')](function(_0x98819d){if(_0x98819d){if(_0x98819d['length']!==0x2){return null;}_0x98819d[0x0]=_0x98819d[0x0][_0x1e1d('0x9c')]({'plain':!![]});_0x98819d[0x1]=_0x98819d[0x1]['get']({'plain':!![]});delete _0x98819d[0x0]['id'];delete _0x98819d[0x1]['id'];return _['mergeWith'](_0x98819d[0x0],_0x98819d[0x1],function(_0x4e96b7,_0x41e2f8){if(Array['isArray'](_0x41e2f8)&&!_0x41e2f8[_0x1e1d('0x33')]){return _0x4e96b7;}else if(!_0x41e2f8){return _0x4e96b7;}});}})[_0x1e1d('0x2b')](handleEntityNotFound(_0x22b59a,null))[_0x1e1d('0x2b')](function(_0x4e4326){if(_0x4e4326){if(_0x4e4326[_0x1e1d('0x93')]&&_[_0x1e1d('0x68')](_0x4e4326['tags'])){_0x4e4326[_0x1e1d('0x93')]=_0x4e4326['tags'][_0x1e1d('0x9d')]();}logger[_0x1e1d('0x9e')]('[CmContact][merge]\x20to\x20%s\x20from\x20%s',_0x13051d['body']['to'],_0x13051d[_0x1e1d('0x9b')]['from']);return db[_0x1e1d('0x9f')][_0x1e1d('0x2c')]({'where':{'ContactId':[_0x13051d[_0x1e1d('0x9b')]['to'],_0x13051d[_0x1e1d('0x9b')][_0x1e1d('0x46')]]}})[_0x1e1d('0x2b')](function(_0x33bc11){logger[_0x1e1d('0x9e')](_0x1e1d('0xa0'),_0x33bc11);return db[_0x1e1d('0xa1')][_0x1e1d('0x2c')]({'where':{'ContactId':[_0x13051d[_0x1e1d('0x9b')]['to'],_0x13051d[_0x1e1d('0x9b')][_0x1e1d('0x46')]]}})['then'](function(_0x288f14){logger[_0x1e1d('0x9e')](_0x1e1d('0xa2'),_0x288f14);return db['CmContact'][_0x1e1d('0xa3')](_0x4e4326);});});}})['then'](function(_0x44d587){if(_0x44d587){_0x1dcaec=_0x44d587;_0x3f5ee6={'ContactId':_0x1dcaec['id']};_0x199ab7={'where':{'ContactId':[_0x13051d[_0x1e1d('0x9b')]['to'],_0x13051d[_0x1e1d('0x9b')][_0x1e1d('0x46')]]}};return db[_0x1e1d('0xa4')][_0x1e1d('0x2a')](_0x3f5ee6,_0x199ab7);}})[_0x1e1d('0x2b')](function(){if(_0x1dcaec){return db[_0x1e1d('0xa5')][_0x1e1d('0x2a')](_0x3f5ee6,_0x199ab7);}})['then'](function(){if(_0x1dcaec){return db[_0x1e1d('0xa6')][_0x1e1d('0x2a')](_0x3f5ee6,_0x199ab7);}})['then'](function(){if(_0x1dcaec){return db[_0x1e1d('0xa7')][_0x1e1d('0x2a')](_0x3f5ee6,_0x199ab7);}})['then'](function(){if(_0x1dcaec){return db[_0x1e1d('0xa8')][_0x1e1d('0x2a')](_0x3f5ee6,_0x199ab7);}})[_0x1e1d('0x2b')](function(){if(_0x1dcaec){return db[_0x1e1d('0xa7')][_0x1e1d('0x2a')](_0x3f5ee6,_0x199ab7);}})[_0x1e1d('0x2b')](function(){if(_0x1dcaec){return db[_0x1e1d('0xa8')][_0x1e1d('0x2a')](_0x3f5ee6,_0x199ab7);}})[_0x1e1d('0x2b')](function(){if(_0x1dcaec){return db[_0x1e1d('0xa9')][_0x1e1d('0x2a')](_0x3f5ee6,_0x199ab7);}})[_0x1e1d('0x2b')](function(){if(_0x1dcaec){return db[_0x1e1d('0xaa')]['update'](_0x3f5ee6,_0x199ab7);}})['then'](function(){if(_0x1dcaec){return db[_0x1e1d('0xab')][_0x1e1d('0x2a')](_0x3f5ee6,_0x199ab7);}})[_0x1e1d('0x2b')](function(){if(_0x1dcaec){return db[_0x1e1d('0xac')]['update'](_0x3f5ee6,_0x199ab7);}})[_0x1e1d('0x2b')](function(){if(_0x1dcaec){return db[_0x1e1d('0xad')]['update'](_0x3f5ee6,_0x199ab7);}})[_0x1e1d('0x2b')](function(){if(_0x1dcaec){return db[_0x1e1d('0xae')][_0x1e1d('0x2a')](_0x3f5ee6,_0x199ab7);}})['then'](function(){if(_0x1dcaec){return db[_0x1e1d('0xaf')][_0x1e1d('0x2a')](_0x3f5ee6,_0x199ab7);}})['then'](function(){if(_0x1dcaec){return db[_0x1e1d('0xb0')][_0x1e1d('0x2a')](_0x3f5ee6,_0x199ab7);}})[_0x1e1d('0x2b')](function(){if(_0x1dcaec){return db[_0x1e1d('0xb1')]['update'](_0x3f5ee6,_0x199ab7);}})['then'](function(){if(_0x1dcaec){return db[_0x1e1d('0xb2')]['update'](_0x3f5ee6,_0x199ab7);}})['then'](function(){if(_0x1dcaec){return db[_0x1e1d('0xb3')][_0x1e1d('0x2a')](_0x3f5ee6,_0x199ab7);}})[_0x1e1d('0x2b')](function(){if(_0x1dcaec){return db[_0x1e1d('0xb4')][_0x1e1d('0x2a')](_0x3f5ee6,_0x199ab7);}})[_0x1e1d('0x2b')](function(){if(_0x1dcaec){return db[_0x1e1d('0xb5')][_0x1e1d('0x2a')](_0x3f5ee6,_0x199ab7);}})[_0x1e1d('0x2b')](function(){if(_0x1dcaec){return db[_0x1e1d('0xb6')]['update'](_0x3f5ee6,_0x199ab7);}})[_0x1e1d('0x2b')](function(){if(_0x1dcaec){return db[_0x1e1d('0xb7')][_0x1e1d('0x2a')](_0x3f5ee6,_0x199ab7);}})[_0x1e1d('0x2b')](function(){if(_0x1dcaec){return db[_0x1e1d('0xb8')]['update'](_0x3f5ee6,_0x199ab7);}})[_0x1e1d('0x2b')](function(){if(_0x1dcaec){return db['CmContact'][_0x1e1d('0x2c')]({'where':{'id':[_0x13051d[_0x1e1d('0x9b')]['to'],_0x13051d[_0x1e1d('0x9b')][_0x1e1d('0x46')]]}});}})[_0x1e1d('0x2b')](function(){if(_0x1dcaec){return _0x1dcaec;}})['then'](respondWithResult(_0x22b59a,null))[_0x1e1d('0x90')](handleError(_0x22b59a,null));};exports[_0x1e1d('0xa3')]=function(_0x17be8e,_0xa139e2){return db[_0x1e1d('0x30')]['describe']()[_0x1e1d('0x2b')](function(_0x4dfffe){if(_0x17be8e[_0x1e1d('0x9b')][_0x1e1d('0x93')]&&_['isArray'](_0x17be8e['body']['tags'])){if(_0x17be8e[_0x1e1d('0x9b')][_0x1e1d('0x93')][_0x1e1d('0x33')]){_0x17be8e[_0x1e1d('0x9b')][_0x1e1d('0x93')]=_0x17be8e[_0x1e1d('0x9b')][_0x1e1d('0x93')]['join'](';')+';';}else{_0x17be8e[_0x1e1d('0x9b')][_0x1e1d('0x93')]=null;}}else{_0x17be8e['body']['tags']=null;}return db[_0x1e1d('0x30')]['create'](_0x17be8e[_0x1e1d('0x9b')],{'fields':_[_0x1e1d('0x32')](_0x4dfffe),'raw':!![]});})[_0x1e1d('0x2b')](respondWithResult(_0xa139e2,0xc9))['catch'](handleError(_0xa139e2,null));};exports[_0x1e1d('0xb9')]=function(_0x5758e4,_0x3eea5f){var _0x480720=[];var _0x45f2fe=0x0;var _0x55d275=0x0;var _0x161895=0x0;return db[_0x1e1d('0x30')][_0x1e1d('0x31')]()[_0x1e1d('0x2b')](function(_0x5b577a){return BPromise[_0x1e1d('0xba')](_0x5758e4['body'],function(_0x1a97cf){var _0x3d3b55={'where':{'$or':[]},'defaults':_0x1a97cf,'fields':_['keys'](_0x5b577a),'raw':!![]};if(_0x1a97cf['duplicates']){for(var _0x23ef40=0x0;_0x23ef40<_0x1a97cf[_0x1e1d('0xbb')][_0x1e1d('0x33')];_0x23ef40++){var _0x387d0d={};_0x387d0d[_0x1a97cf[_0x1e1d('0xbb')][_0x23ef40]]=_0x1a97cf[_0x1a97cf['duplicates'][_0x23ef40]];_0x3d3b55[_0x1e1d('0x43')][_0x1e1d('0xbc')][_0x1e1d('0xbd')](_0x387d0d);}_0x3d3b55['where'][_0x1e1d('0x62')]=_0x1a97cf[_0x1e1d('0x62')];}return db['CmContact'][_0x1e1d('0xbe')](_0x3d3b55)[_0x1e1d('0xbf')](function(_0x221420,_0x427ed3){if(_0x427ed3){_0x45f2fe++;}else{_0x161895++;}})[_0x1e1d('0x90')](function(_0x1ca18d){console[_0x1e1d('0x2d')](_0x1ca18d);_0x55d275++;});});})[_0x1e1d('0x2b')](function(_0x41e401){if(_0x41e401){return{'success':_0x45f2fe,'failure':_0x55d275,'duplicates':_0x161895};}})[_0x1e1d('0x2b')](respondWithResult(_0x3eea5f,0xc9))[_0x1e1d('0x90')](handleError(_0x3eea5f,null));};exports['show']=function(_0x4a6ed6,_0x4cf9db,_0x4034f2){var _0x534aae;return db[_0x1e1d('0x30')]['describe']()[_0x1e1d('0x2b')](function(_0x539f8f){return db['CmContact'][_0x1e1d('0x91')]({'where':{'id':_0x4a6ed6['params']['id']},'include':[{'model':db[_0x1e1d('0x54')],'as':_0x1e1d('0x8e'),'attributes':['id',_0x1e1d('0x2e'),_0x1e1d('0x45')],'required':_0x4a6ed6[_0x1e1d('0x3c')][_0x1e1d('0x67')]?!![]:![]}],'attributes':_['keys'](_0x539f8f)});})[_0x1e1d('0x2b')](function(_0x59f5cb){_0x534aae=_0x59f5cb[_0x1e1d('0x9c')]({'plain':!![]});var _0xf1765d={'where':{'$and':[{'ListId':{'$ne':null}}]}};if(_0x59f5cb&&_0x59f5cb[_0x1e1d('0x62')]){if(_0x59f5cb['ListId']){_0xf1765d['where'][_0x1e1d('0xc0')][_0x1e1d('0xbd')]({'ListId':{'$ne':_0x59f5cb[_0x1e1d('0x62')]}});}}return db[_0x1e1d('0x35')][_0x1e1d('0x96')](_0xf1765d);})[_0x1e1d('0x2b')](function(_0x31486d){return _[_0x1e1d('0xc1')](_0x534aae,_[_0x1e1d('0x5f')](_0x31486d,function(_0x54b1ea){return util[_0x1e1d('0xc2')](_0x1e1d('0xc3'),_0x54b1ea['id']);}));})[_0x1e1d('0x2b')](handleEntityNotFound(_0x4cf9db,null))[_0x1e1d('0x2b')](respondWithResult(_0x4cf9db,null))[_0x1e1d('0x90')](handleError(_0x4cf9db,null));};exports['update']=function(_0x1e17b7,_0x30b0ae){var _0x808264;if(_0x1e17b7[_0x1e1d('0x9b')]['id']){delete _0x1e17b7[_0x1e1d('0x9b')]['id'];}return db[_0x1e1d('0x30')][_0x1e1d('0x91')]({'where':{'id':_0x1e17b7['params']['id']}})[_0x1e1d('0x2b')](handleEntityNotFound(_0x30b0ae,null))[_0x1e1d('0x2b')](saveUpdates(_0x1e17b7[_0x1e1d('0x9b')],null))['then'](function(_0xcce81c){_0x808264=_0xcce81c;var _0x4c45c0={'where':{'$and':[{'ListId':{'$ne':null}}]}};if(_0xcce81c&&_0xcce81c[_0x1e1d('0x62')]){if(_0xcce81c[_0x1e1d('0x62')]){_0x4c45c0[_0x1e1d('0x43')][_0x1e1d('0xc0')][_0x1e1d('0xbd')]({'ListId':{'$ne':_0xcce81c[_0x1e1d('0x62')]}});}}return db[_0x1e1d('0x35')]['findAll'](_0x4c45c0);})[_0x1e1d('0x2b')](function(_0x123596){if(_0x123596){return _[_0x1e1d('0xc1')](_['pickBy'](_0x1e17b7[_0x1e1d('0x9b')],function(_0x491b75,_0x2a0702){return _['startsWith'](_0x2a0702,'cf_');}),_['map'](_0x123596,function(_0x9f4d97){return util[_0x1e1d('0xc2')](_0x1e1d('0xc3'),_0x9f4d97['id']);}));}})[_0x1e1d('0x2b')](function(_0x5cc9dd){if(_0x5cc9dd&&!_[_0x1e1d('0xc4')](_0x5cc9dd)){var _0x24c0d6=squel[_0x1e1d('0x2a')]()[_0x1e1d('0xc5')]('cm_contacts')[_0x1e1d('0xc6')](_0x5cc9dd)['where'](_0x1e1d('0xc7'),_0x1e17b7[_0x1e1d('0x92')]['id'])[_0x1e1d('0xc8')]();return db[_0x1e1d('0x82')][_0x1e1d('0x3c')](_0x24c0d6[_0x1e1d('0x5d')],{'replacements':_0x24c0d6[_0x1e1d('0x9a')]});}})[_0x1e1d('0x2b')](function(){if(_0x1e17b7[_0x1e1d('0x9b')][_0x1e1d('0xc9')]&&_0x808264){return db[_0x1e1d('0x9f')][_0x1e1d('0x2a')]({'phone':_0x1e17b7['body'][_0x1e1d('0xc9')]},{'where':{'ContactId':_0x808264['id']}});}})[_0x1e1d('0x2b')](function(){return _0x808264;})[_0x1e1d('0x2b')](respondWithResult(_0x30b0ae,null))['catch'](handleError(_0x30b0ae,null));};exports[_0x1e1d('0xca')]=function(_0xdc337c,_0x291c42,_0x3af645){var _0x528ba1={};var _0x497535={};var _0x37dca8;var _0xb04d5;return db[_0x1e1d('0x30')][_0x1e1d('0x36')]({'where':{'id':_0xdc337c[_0x1e1d('0x92')]['id']}})[_0x1e1d('0x2b')](handleEntityNotFound(_0x291c42,null))[_0x1e1d('0x2b')](function(_0x5dcb74){if(_0x5dcb74){_0x37dca8=_0x5dcb74;_0x497535[_0x1e1d('0x3b')]=_[_0x1e1d('0x32')](db[_0x1e1d('0x54')][_0x1e1d('0xcb')]);_0x497535[_0x1e1d('0x3c')]=_['keys'](_0xdc337c[_0x1e1d('0x3c')]);_0x497535[_0x1e1d('0x3d')]=_[_0x1e1d('0x3e')](_0x497535[_0x1e1d('0x3b')],_0x497535[_0x1e1d('0x3c')]);_0x528ba1[_0x1e1d('0x3f')]=_[_0x1e1d('0x3e')](_0x497535[_0x1e1d('0x3b')],qs[_0x1e1d('0x40')](_0xdc337c[_0x1e1d('0x3c')]['fields']));_0x528ba1['attributes']=_0x528ba1[_0x1e1d('0x3f')]['length']?_0x528ba1[_0x1e1d('0x3f')]:_0x497535[_0x1e1d('0x3b')];_0x528ba1[_0x1e1d('0x7a')]=qs[_0x1e1d('0xcc')](_0xdc337c[_0x1e1d('0x3c')][_0x1e1d('0xcc')]);_0x528ba1[_0x1e1d('0x43')]=qs[_0x1e1d('0x3d')](_[_0x1e1d('0xcd')](_0xdc337c[_0x1e1d('0x3c')],_0x497535[_0x1e1d('0x3d')]));if(_0xdc337c[_0x1e1d('0x3c')][_0x1e1d('0x69')]){_0x528ba1[_0x1e1d('0x43')]=_[_0x1e1d('0x85')](_0x528ba1[_0x1e1d('0x43')],{'$or':_[_0x1e1d('0x5f')](_0x528ba1['attributes'],function(_0x39fb27){var _0x4dd68c={};_0x4dd68c[_0x39fb27]={'$like':'%'+_0xdc337c[_0x1e1d('0x3c')][_0x1e1d('0x69')]+'%'};return _0x4dd68c;})});}_0x528ba1=_[_0x1e1d('0x85')]({},_0x528ba1,_0xdc337c[_0x1e1d('0xce')]);return _0x37dca8[_0x1e1d('0xca')](_0x528ba1);}})['then'](function(_0x35e0b0){if(_0x35e0b0){_0xb04d5=_0x35e0b0[_0x1e1d('0x33')];if(!_0xdc337c[_0x1e1d('0x3c')][_0x1e1d('0x41')]('nolimit')){_0x528ba1[_0x1e1d('0x24')]=qs[_0x1e1d('0x24')](_0xdc337c['query'][_0x1e1d('0x24')]);_0x528ba1['offset']=qs[_0x1e1d('0x23')](_0xdc337c[_0x1e1d('0x3c')][_0x1e1d('0x23')]);}return _0x37dca8['getTags'](_0x528ba1);}})['then'](function(_0x16db10){if(_0x16db10){return _0x16db10?{'count':_0xb04d5,'rows':_0x16db10}:null;}})['then'](respondWithResult(_0x291c42,null))[_0x1e1d('0x90')](handleError(_0x291c42,null));};exports[_0x1e1d('0xcf')]=function(_0x3efd70,_0x9b7d84,_0x3a3419){if(_0x3efd70[_0x1e1d('0x9b')]['id']){delete _0x3efd70['body']['id'];}return db[_0x1e1d('0x30')][_0x1e1d('0x36')]({'where':{'id':_0x3efd70['params']['id']}})[_0x1e1d('0x2b')](handleEntityNotFound(_0x9b7d84,null))[_0x1e1d('0x2b')](function(_0xd29074){if(_0xd29074){return _0xd29074['setTags'](_0x3efd70[_0x1e1d('0x9b')][_0x1e1d('0xd0')]||[]);}return null;})[_0x1e1d('0x2b')](respondWithResult(_0x9b7d84,null))['catch'](handleError(_0x9b7d84,null));};exports[_0x1e1d('0xd1')]=function(_0x183e83,_0x18f349,_0x7a2079){var _0x16fb7a={'raw':![],'where':{}};var _0x26a838={};var _0x422310={'count':0x0,'rows':[]};return db[_0x1e1d('0x30')][_0x1e1d('0x36')]({'where':{'id':_0x183e83['params']['id']}})[_0x1e1d('0x2b')](handleEntityNotFound(_0x18f349,null))['then'](function(_0x2667e9){if(_0x2667e9){_0x26a838[_0x1e1d('0x3b')]=_[_0x1e1d('0x32')](db[_0x1e1d('0x9f')][_0x1e1d('0xcb')]);_0x26a838[_0x1e1d('0x3c')]=_['keys'](_0x183e83[_0x1e1d('0x3c')]);_0x26a838['filters']=_[_0x1e1d('0x3e')](_0x26a838['model'],_0x26a838['query']);_0x16fb7a[_0x1e1d('0x3f')]=_[_0x1e1d('0x3e')](_0x26a838[_0x1e1d('0x3b')],qs['fields'](_0x183e83[_0x1e1d('0x3c')][_0x1e1d('0x40')]));_0x16fb7a['attributes']=_0x16fb7a[_0x1e1d('0x3f')][_0x1e1d('0x33')]?_0x16fb7a[_0x1e1d('0x3f')]:_0x26a838['model'];if(!_0x183e83[_0x1e1d('0x3c')][_0x1e1d('0x41')](_0x1e1d('0x42'))){_0x16fb7a[_0x1e1d('0x24')]=qs[_0x1e1d('0x24')](_0x183e83['query'][_0x1e1d('0x24')]);_0x16fb7a[_0x1e1d('0x23')]=qs['offset'](_0x183e83[_0x1e1d('0x3c')][_0x1e1d('0x23')]);}_0x16fb7a['order']=qs[_0x1e1d('0xcc')](_0x183e83[_0x1e1d('0x3c')][_0x1e1d('0xcc')]);_0x16fb7a['where']=qs[_0x1e1d('0x3d')](_[_0x1e1d('0xcd')](_0x183e83[_0x1e1d('0x3c')],_0x26a838[_0x1e1d('0x3d')]));_0x16fb7a[_0x1e1d('0x43')][_0x1e1d('0xd2')]=_0x2667e9['id'];if(_0x183e83[_0x1e1d('0x3c')][_0x1e1d('0x69')]){_0x16fb7a[_0x1e1d('0x43')]=_[_0x1e1d('0x85')](_0x16fb7a[_0x1e1d('0x43')],{'$or':_['map'](_0x16fb7a[_0x1e1d('0x3f')],function(_0x81498){var _0x4ba7a8={};_0x4ba7a8[_0x81498]={'$like':'%'+_0x183e83[_0x1e1d('0x3c')]['filter']+'%'};return _0x4ba7a8;})});}_0x16fb7a=_[_0x1e1d('0x85')]({},_0x16fb7a,_0x183e83[_0x1e1d('0xce')]);return db[_0x1e1d('0x9f')]['count']({'where':_0x16fb7a[_0x1e1d('0x43')]})['then'](function(_0x480590){_0x422310[_0x1e1d('0x22')]=_0x480590;if(_0x183e83[_0x1e1d('0x3c')][_0x1e1d('0xd3')]){_0x16fb7a['include']=[{'all':!![]}];}return db[_0x1e1d('0x9f')][_0x1e1d('0x96')](_0x16fb7a);})[_0x1e1d('0x2b')](function(_0x214880){_0x422310['rows']=_0x214880;return _0x422310;});}})['then'](respondWithFilteredResult(_0x18f349,_0x16fb7a))[_0x1e1d('0x90')](handleError(_0x18f349,null));};exports['getHopperHistories']=function(_0x298552,_0x2bdddf,_0x4b00d7){var _0x8445b5={'raw':!![],'where':{}};var _0x135aa6={};var _0x3b009f={'count':0x0,'rows':[]};return db['CmContact']['findOne']({'where':{'id':_0x298552[_0x1e1d('0x92')]['id']}})[_0x1e1d('0x2b')](handleEntityNotFound(_0x2bdddf,null))[_0x1e1d('0x2b')](function(_0x69a540){if(_0x69a540){_0x135aa6[_0x1e1d('0x3b')]=_['keys'](db[_0x1e1d('0xb0')][_0x1e1d('0xcb')]);_0x135aa6[_0x1e1d('0x3c')]=_['keys'](_0x298552['query']);_0x135aa6[_0x1e1d('0x3d')]=_[_0x1e1d('0x3e')](_0x135aa6['model'],_0x135aa6[_0x1e1d('0x3c')]);_0x8445b5[_0x1e1d('0x3f')]=_[_0x1e1d('0x3e')](_0x135aa6[_0x1e1d('0x3b')],qs['fields'](_0x298552['query'][_0x1e1d('0x40')]));_0x8445b5[_0x1e1d('0x3f')]=_0x8445b5[_0x1e1d('0x3f')]['length']?_0x8445b5[_0x1e1d('0x3f')]:_0x135aa6[_0x1e1d('0x3b')];if(!_0x298552[_0x1e1d('0x3c')]['hasOwnProperty']('nolimit')){_0x8445b5[_0x1e1d('0x24')]=qs['limit'](_0x298552[_0x1e1d('0x3c')][_0x1e1d('0x24')]);_0x8445b5[_0x1e1d('0x23')]=qs[_0x1e1d('0x23')](_0x298552[_0x1e1d('0x3c')][_0x1e1d('0x23')]);}_0x8445b5[_0x1e1d('0x7a')]=qs[_0x1e1d('0xcc')](_0x298552[_0x1e1d('0x3c')][_0x1e1d('0xcc')]);_0x8445b5[_0x1e1d('0x43')]=qs[_0x1e1d('0x3d')](_[_0x1e1d('0xcd')](_0x298552[_0x1e1d('0x3c')],_0x135aa6[_0x1e1d('0x3d')]));_0x8445b5[_0x1e1d('0x43')][_0x1e1d('0xd2')]=_0x69a540['id'];if(_0x298552['query'][_0x1e1d('0x69')]){_0x8445b5[_0x1e1d('0x43')]=_['merge'](_0x8445b5[_0x1e1d('0x43')],{'$or':_[_0x1e1d('0x5f')](_0x8445b5[_0x1e1d('0x3f')],function(_0x932240){var _0x53edc3={};_0x53edc3[_0x932240]={'$like':'%'+_0x298552[_0x1e1d('0x3c')]['filter']+'%'};return _0x53edc3;})});}_0x8445b5=_[_0x1e1d('0x85')]({},_0x8445b5,_0x298552[_0x1e1d('0xce')]);return db[_0x1e1d('0xb0')][_0x1e1d('0x22')]({'where':_0x8445b5[_0x1e1d('0x43')]})[_0x1e1d('0x2b')](function(_0x1353d2){_0x3b009f[_0x1e1d('0x22')]=_0x1353d2;if(_0x298552['query']['includeAll']){_0x8445b5[_0x1e1d('0xd4')]=[{'all':!![]}];}return db['CmHopperHistory']['findAll'](_0x8445b5);})['then'](function(_0x3c6b02){_0x3b009f[_0x1e1d('0x8f')]=_0x3c6b02;return _0x3b009f;});}})[_0x1e1d('0x2b')](respondWithFilteredResult(_0x2bdddf,_0x8445b5))['catch'](handleError(_0x2bdddf,null));};exports['getHopperFinals']=function(_0x3947a3,_0x1f26b6,_0xa4f59){var _0x494833={'raw':!![],'where':{}};var _0x3aa068={};var _0x4cfefb={'count':0x0,'rows':[]};return db[_0x1e1d('0x30')][_0x1e1d('0x36')]({'where':{'id':_0x3947a3['params']['id']}})[_0x1e1d('0x2b')](handleEntityNotFound(_0x1f26b6,null))['then'](function(_0x5f2794){if(_0x5f2794){_0x3aa068[_0x1e1d('0x3b')]=_['keys'](db[_0x1e1d('0xaf')][_0x1e1d('0xcb')]);_0x3aa068[_0x1e1d('0x3c')]=_[_0x1e1d('0x32')](_0x3947a3[_0x1e1d('0x3c')]);_0x3aa068[_0x1e1d('0x3d')]=_[_0x1e1d('0x3e')](_0x3aa068[_0x1e1d('0x3b')],_0x3aa068['query']);_0x494833[_0x1e1d('0x3f')]=_[_0x1e1d('0x3e')](_0x3aa068[_0x1e1d('0x3b')],qs[_0x1e1d('0x40')](_0x3947a3[_0x1e1d('0x3c')][_0x1e1d('0x40')]));_0x494833[_0x1e1d('0x3f')]=_0x494833['attributes'][_0x1e1d('0x33')]?_0x494833[_0x1e1d('0x3f')]:_0x3aa068[_0x1e1d('0x3b')];if(!_0x3947a3[_0x1e1d('0x3c')][_0x1e1d('0x41')](_0x1e1d('0x42'))){_0x494833[_0x1e1d('0x24')]=qs[_0x1e1d('0x24')](_0x3947a3[_0x1e1d('0x3c')][_0x1e1d('0x24')]);_0x494833[_0x1e1d('0x23')]=qs[_0x1e1d('0x23')](_0x3947a3[_0x1e1d('0x3c')]['offset']);}_0x494833[_0x1e1d('0x7a')]=qs[_0x1e1d('0xcc')](_0x3947a3['query'][_0x1e1d('0xcc')]);_0x494833['where']=qs['filters'](_[_0x1e1d('0xcd')](_0x3947a3[_0x1e1d('0x3c')],_0x3aa068[_0x1e1d('0x3d')]));_0x494833[_0x1e1d('0x43')][_0x1e1d('0xd2')]=_0x5f2794['id'];if(_0x3947a3[_0x1e1d('0x3c')][_0x1e1d('0x69')]){_0x494833[_0x1e1d('0x43')]=_[_0x1e1d('0x85')](_0x494833[_0x1e1d('0x43')],{'$or':_['map'](_0x494833[_0x1e1d('0x3f')],function(_0x2ef0c4){var _0x19f71d={};_0x19f71d[_0x2ef0c4]={'$like':'%'+_0x3947a3[_0x1e1d('0x3c')][_0x1e1d('0x69')]+'%'};return _0x19f71d;})});}_0x494833=_['merge']({},_0x494833,_0x3947a3['options']);return db[_0x1e1d('0xaf')][_0x1e1d('0x22')]({'where':_0x494833[_0x1e1d('0x43')]})[_0x1e1d('0x2b')](function(_0x2973b3){_0x4cfefb[_0x1e1d('0x22')]=_0x2973b3;if(_0x3947a3[_0x1e1d('0x3c')][_0x1e1d('0xd3')]){_0x494833['include']=[{'all':!![]}];}return db[_0x1e1d('0xaf')][_0x1e1d('0x96')](_0x494833);})[_0x1e1d('0x2b')](function(_0x3297d8){_0x4cfefb[_0x1e1d('0x8f')]=_0x3297d8;return _0x4cfefb;});}})[_0x1e1d('0x2b')](respondWithFilteredResult(_0x1f26b6,_0x494833))[_0x1e1d('0x90')](handleError(_0x1f26b6,null));};exports[_0x1e1d('0xd5')]=function(_0x5d09ee,_0x41c2cd,_0x4d8d37){var _0x37b1f6={'raw':!![],'where':{}};var _0x2f8525={};var _0x2b1ce0={'count':0x0,'rows':[]};return db[_0x1e1d('0x30')]['findOne']({'where':{'id':_0x5d09ee[_0x1e1d('0x92')]['id']}})[_0x1e1d('0x2b')](handleEntityNotFound(_0x41c2cd,null))[_0x1e1d('0x2b')](function(_0x5b1dbf){if(_0x5b1dbf){_0x2f8525['model']=_[_0x1e1d('0x32')](db['JscriptySessionReport']['rawAttributes']);_0x2f8525['query']=_[_0x1e1d('0x32')](_0x5d09ee[_0x1e1d('0x3c')]);_0x2f8525['filters']=_[_0x1e1d('0x3e')](_0x2f8525[_0x1e1d('0x3b')],_0x2f8525[_0x1e1d('0x3c')]);_0x37b1f6[_0x1e1d('0x3f')]=_[_0x1e1d('0x3e')](_0x2f8525['model'],qs[_0x1e1d('0x40')](_0x5d09ee['query'][_0x1e1d('0x40')]));_0x37b1f6[_0x1e1d('0x3f')]=_0x37b1f6[_0x1e1d('0x3f')][_0x1e1d('0x33')]?_0x37b1f6[_0x1e1d('0x3f')]:_0x2f8525[_0x1e1d('0x3b')];if(!_0x5d09ee[_0x1e1d('0x3c')][_0x1e1d('0x41')]('nolimit')){_0x37b1f6[_0x1e1d('0x24')]=qs[_0x1e1d('0x24')](_0x5d09ee[_0x1e1d('0x3c')][_0x1e1d('0x24')]);_0x37b1f6[_0x1e1d('0x23')]=qs[_0x1e1d('0x23')](_0x5d09ee['query']['offset']);}_0x37b1f6[_0x1e1d('0x7a')]=qs[_0x1e1d('0xcc')](_0x5d09ee[_0x1e1d('0x3c')][_0x1e1d('0xcc')]);_0x37b1f6[_0x1e1d('0x43')]=qs['filters'](_[_0x1e1d('0xcd')](_0x5d09ee[_0x1e1d('0x3c')],_0x2f8525[_0x1e1d('0x3d')]));_0x37b1f6[_0x1e1d('0x43')][_0x1e1d('0xd2')]=_0x5b1dbf['id'];if(_0x5d09ee[_0x1e1d('0x3c')]['filter']){_0x37b1f6[_0x1e1d('0x43')]=_[_0x1e1d('0x85')](_0x37b1f6['where'],{'$or':_['map'](_0x37b1f6[_0x1e1d('0x3f')],function(_0x3a99cb){var _0x46e888={};_0x46e888[_0x3a99cb]={'$like':'%'+_0x5d09ee[_0x1e1d('0x3c')]['filter']+'%'};return _0x46e888;})});}_0x37b1f6=_[_0x1e1d('0x85')]({},_0x37b1f6,_0x5d09ee[_0x1e1d('0xce')]);return db['JscriptySessionReport'][_0x1e1d('0x22')]({'where':_0x37b1f6[_0x1e1d('0x43')]})['then'](function(_0x30a4a2){_0x2b1ce0[_0x1e1d('0x22')]=_0x30a4a2;if(_0x5d09ee[_0x1e1d('0x3c')][_0x1e1d('0xd3')]){_0x37b1f6['include']=[{'all':!![]}];}return db[_0x1e1d('0xb8')][_0x1e1d('0x96')](_0x37b1f6);})['then'](function(_0x5ff477){_0x2b1ce0[_0x1e1d('0x8f')]=_0x5ff477;return _0x2b1ce0;});}})[_0x1e1d('0x2b')](respondWithFilteredResult(_0x41c2cd,_0x37b1f6))['catch'](handleError(_0x41c2cd,null));};exports[_0x1e1d('0xd6')]=function(_0x7c4378,_0x4de5bd,_0x1520df){try{if(!_0x7c4378[_0x1e1d('0x9b')]['ListId']){throw new Error('No\x20ListId\x20specified');}if(!_0x7c4378[_0x1e1d('0x9b')][_0x1e1d('0xd7')]){throw new Error(_0x1e1d('0xd8'));}if(!_0x7c4378[_0x1e1d('0x9b')][_0x1e1d('0xd9')]){throw new Error(_0x1e1d('0xda'));}if(!_0x7c4378[_0x1e1d('0x9b')]['socket_timestamp']){throw new Error(_0x1e1d('0xdb'));}var _0x2ede9b=_0x7c4378[_0x1e1d('0x9b')][_0x1e1d('0xd7')]['split'](',');var _0x231ed=_0x7c4378['body'][_0x1e1d('0xd9')][_0x1e1d('0x56')](',');if(!_0x2ede9b['length']||!_0x231ed[_0x1e1d('0x33')]||_0x2ede9b[_0x1e1d('0x33')]!==_0x231ed[_0x1e1d('0x33')]){throw new Error(_0x1e1d('0xdc'));}_0x7c4378[_0x1e1d('0x9b')][_0x1e1d('0x40')]=_[_0x1e1d('0xdd')](_0x2ede9b,_0x231ed);if(!_0x7c4378[_0x1e1d('0x9b')][_0x1e1d('0x40')][_0x1e1d('0xc9')]){throw new Error('No\x20phone\x20column\x20specified');}if(!_0x7c4378[_0x1e1d('0x9b')][_0x1e1d('0x40')][_0x1e1d('0xde')]){throw new Error('No\x20firstName\x20column\x20specified');}var _0x3a8cc3=path['join'](config[_0x1e1d('0xdf')],_0x1e1d('0xe0'),_0x7c4378[_0x1e1d('0xe1')][_0x1e1d('0xe2')]);fs[_0x1e1d('0xe3')](_0x3a8cc3,parseInt('0777',0x8));var _0x5e61c0=require(_0x1e1d('0xe4'))[_0x1e1d('0xe5')](path[_0x1e1d('0x9d')](__dirname,_0x1e1d('0xe6')),[_0x3a8cc3,_0x7c4378['body']['binding_keys'],_0x7c4378[_0x1e1d('0x9b')][_0x1e1d('0xd9')],_0x7c4378['body'][_0x1e1d('0x62')],_0x7c4378[_0x1e1d('0x9b')][_0x1e1d('0xe7')],_0x7c4378[_0x1e1d('0x9b')][_0x1e1d('0xbb')],_0x7c4378[_0x1e1d('0x9b')][_0x1e1d('0xe8')]]);return _0x4de5bd[_0x1e1d('0x1f')](0xc8)[_0x1e1d('0x21')]({'message':_0x1e1d('0xe9'),'pid':_0x5e61c0[_0x1e1d('0xea')]});}catch(_0x1a5bba){return _0x4de5bd['status'](0x1f4)[_0x1e1d('0x2f')](_0x1a5bba);}};exports[_0x1e1d('0xeb')]=function(_0x4136ae,_0x1d27a8,_0x1f9f5e){var _0x1222d5=fs[_0x1e1d('0xec')](_0x4136ae[_0x1e1d('0xe1')]['path']);Papa[_0x1e1d('0xed')](_0x1222d5,{'header':!![],'skipEmptyLines':!![],'preview':0x1,'complete':function(_0x4cd97f){return _0x1d27a8['status'](0xc8)[_0x1e1d('0x21')]({'file':_0x4136ae[_0x1e1d('0xe1')],'fields':_0x4cd97f[_0x1e1d('0xee')][_0x1e1d('0x40')]});}});};exports[_0x1e1d('0xef')]=function(_0x5d67c3,_0x14053a,_0x3596cf){return db[_0x1e1d('0xf0')][_0x1e1d('0x96')]({'raw':!![],'attributes':['id'],'where':{'role':_0x1e1d('0xf1')}})[_0x1e1d('0x2b')](function(_0x3c5395){var _0x28d6ec=![];if(!_0x5d67c3[_0x1e1d('0x9b')][_0x1e1d('0x62')]){throw new Error('No\x20ListId\x20specified');}if(!_0x5d67c3[_0x1e1d('0x9b')][_0x1e1d('0xf2')][_0x1e1d('0xc9')]){throw new Error('No\x20phone\x20column\x20specified');}if(!_0x5d67c3[_0x1e1d('0x9b')][_0x1e1d('0xf2')][_0x1e1d('0xde')]){throw new Error(_0x1e1d('0xf3'));}if(!_0x5d67c3['body'][_0x1e1d('0xe8')]){throw new Error(_0x1e1d('0xdb'));}var _0x32cbc5=require(_0x1e1d('0xe4'))[_0x1e1d('0xe5')](path[_0x1e1d('0x9d')](__dirname,_0x1e1d('0xf4')),[_0x5d67c3[_0x1e1d('0x92')]['id'],JSON[_0x1e1d('0xf5')](_0x5d67c3[_0x1e1d('0x9b')]),JSON['stringify'](_0x3c5395)]);_0x32cbc5['on'](_0x1e1d('0xf6'),function(_0x5d87c0){_0x28d6ec=!![];return _0x14053a[_0x1e1d('0x1f')](0xc8)[_0x1e1d('0x21')]({'message':_0x1e1d('0xf7'),'pid':_0x32cbc5[_0x1e1d('0xea')]});});_0x32cbc5['on'](_0x1e1d('0xf8'),function(_0x1dd0c1){if(_0x1dd0c1&&!_0x28d6ec){return _0x14053a[_0x1e1d('0x1f')](0x1f4)[_0x1e1d('0x21')]({'message':_0x1e1d('0xf9'),'pid':_0x32cbc5[_0x1e1d('0xea')]});}});})['catch'](handleError(_0x14053a,null));};
\ No newline at end of file
+var _0xdb4b=['search','sqlOperator','conditions','find','Tag','split','map','User','and','uc.UserId\x20=\x20?','value','dateOfBirth','datetime','castTo','DATE','buildExpression','text','start','filter','isNil','Contact','push','isEmpty','forEach','c.ListId\x20IN\x20?','concat','\x20=\x20?','tag','isArray','CONCAT(\x27,\x27,\x20`TagIds`,\x20\x27,\x27)\x20LIKE\x20?','MATCH\x20(c.firstName,\x20c.lastName,\x20c.phone,\x20c.mobile,\x20c.fax,\x20c.email)\x20AGAINST\x20(?\x20IN\x20BOOLEAN\x20MODE)','getFullTextValue','isNumeric','c.id\x20LIKE\x20?','c.mobile\x20LIKE\x20?','isEmail','c.email\x20LIKE\x20?','c.firstName\x20LIKE\x20?','c.lastName\x20LIKE\x20?','c.id','QueryTypes','SELECT','order','DESC','t.id\x20IN\x20?','resolve','user','some','getLists','c.ListId\x20IS\x20NULL','ListId','sequelize','toString','count','keyBy','merge','c.firstName','c.mobile','c.fax','c.ListId','c.createdAt','c.deletedAt','GROUP_CONCAT(DISTINCT\x20t.id)','TagIds','Tags','rows','catch','params','columnName','displayName','findAll','custom','values','body','get','mergeWith','tags','info','[CmContact][merge]\x20to\x20%s\x20from\x20%s','CmHopper','[CmContact][merge][destroy][CmHopper],\x20%s','CmHopperBlack','destroy','[CmContact][merge][destroy][CmHopperBlack],\x20%s','create','ChatInteraction','update','ChatMessage','MailInteraction','MailMessage','SmsInteraction','SmsMessage','FaxMessage','OpenchannelMessage','CmHopperFinal','CmHopperHistory','ReportAgentPreview','VoiceCallReport','ChatQueueReport','FaxQueueReport','MailQueueReport','WhatsappInteraction','WhatsappMessage','join','bulkCreate','each','duplicates','$or','findOrCreate','spread','show','$and','omit','format','cf_%d','pickBy','table','id\x20=\x20?','phone','getTags','findOne','rawAttributes','options','setTags','getHoppers','ContactId','includeAll','include','getHopperHistories','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','binding_values','zipObject','No\x20phone\x20column\x20specified','firstName','No\x20firstName\x20column\x20specified','root','server/files/tmp','filename','chmodSync','0777','child_process','fork','CompanyId','File\x20uploaded\x20correctly!','send','upload','createReadStream','file','meta','agent','binding','../../components/import/cm/csv2','stringify','message','start\x20child\x20process\x20correctly!','pid','error\x20child\x20process','getJourney','sms','openchannel','fax','whatsapp','voice','-createdAt','includes','channel','toLowerCase','parse','isValid','destination','callerid','starttime','endtime','duration','note','userDisposition','userThirdDisposition','alias','createdAt','findAndCountAll','fullname','startCase','chat','Website','Account','closed','closedAt','disposition','secondDisposition','UserId','Owner','range','browserName','customerPort','deviceModel','ratingMessage','ratingType','ratingValue','mail','subject','externalUrl','threadId','Interaction','flatten','sortBy','reverse','slice','eml-format','zip-dir','fast-json-patch','request-promise','moment','mustache','util','path','sox','to-csv','ejs','lodash','jsforce','desk.js','querystring','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','localhost','socket.io-emitter','./cmContact.socket','register','sendStatus','end','status','json','offset','limit','set','Content-Range','reject','save','then','error','stack','name','index','CmContact','describe','keys','length','startsWith','CmCustomField','trimStart','cf_','all','fieldType','type','model','query','filters','intersection','attributes','fields','hasOwnProperty','nolimit','sort','where','pick','select','field','color','from','tools_tags','cm_contacts','left_join','cm_user_has_contacts','uc.CmContactId\x20=\x20c.id','cm_contact_has_tags','ct.CmContactId\x20=\x20c.id'];(function(_0x174218,_0x208955){var _0x4bd4db=function(_0x3f8298){while(--_0x3f8298){_0x174218['push'](_0x174218['shift']());}};_0x4bd4db(++_0x208955);}(_0xdb4b,0xd7));var _0xbdb4=function(_0x22d300,_0x23c213){_0x22d300=_0x22d300-0x0;var _0x4d2a92=_0xdb4b[_0x22d300];return _0x4d2a92;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0xbdb4('0x0'));var rimraf=require('rimraf');var zipdir=require(_0xbdb4('0x1'));var jsonpatch=require(_0xbdb4('0x2'));var rp=require(_0xbdb4('0x3'));var moment=require(_0xbdb4('0x4'));var BPromise=require('bluebird');var Mustache=require(_0xbdb4('0x5'));var util=require(_0xbdb4('0x6'));var path=require(_0xbdb4('0x7'));var sox=require(_0xbdb4('0x8'));var csv=require(_0xbdb4('0x9'));var ejs=require(_0xbdb4('0xa'));var fs=require('fs');var _=require(_0xbdb4('0xb'));var squel=require('squel');var crypto=require('crypto');var jsforce=require(_0xbdb4('0xc'));var deskjs=require(_0xbdb4('0xd'));var toCsv=require(_0xbdb4('0x9'));var querystring=require(_0xbdb4('0xe'));var Papa=require('papaparse');var Redis=require(_0xbdb4('0xf'));var authService=require('../../components/auth/service');var qs=require(_0xbdb4('0x10'));var as=require(_0xbdb4('0x11'));var hardwareService=require(_0xbdb4('0x12'));var logger=require('../../config/logger')('api');var utils=require(_0xbdb4('0x13'));var config=require(_0xbdb4('0x14'));var licenseUtil=require(_0xbdb4('0x15'));var db=require(_0xbdb4('0x16'))['db'];config['redis']=_['defaults'](config[_0xbdb4('0x17')],{'host':_0xbdb4('0x18'),'port':0x18eb});var socket=require(_0xbdb4('0x19'))(new Redis(config[_0xbdb4('0x17')]));require(_0xbdb4('0x1a'))[_0xbdb4('0x1b')](socket);function respondWithStatusCode(_0x4a2ae3,_0x4a49ad){_0x4a49ad=_0x4a49ad||0xcc;return function(_0x2e953a){if(_0x2e953a){return _0x4a2ae3[_0xbdb4('0x1c')](_0x4a49ad);}return _0x4a2ae3['status'](_0x4a49ad)[_0xbdb4('0x1d')]();};}function respondWithResult(_0x19a69b,_0x554c91){_0x554c91=_0x554c91||0xc8;return function(_0x5984a9){if(_0x5984a9){return _0x19a69b[_0xbdb4('0x1e')](_0x554c91)[_0xbdb4('0x1f')](_0x5984a9);}};}function respondWithFilteredResult(_0x52c7ca,_0x4538cc){return function(_0x113471){if(_0x113471){var _0x4a180b=_0x113471['count'],_0x2ca1d5=_0x4538cc['offset'],_0x1e5d10=_0x4538cc[_0xbdb4('0x20')]+_0x4538cc[_0xbdb4('0x21')],_0x373078;if(_0x1e5d10>=_0x4a180b){_0x1e5d10=_0x4a180b;_0x373078=0xc8;}else{_0x373078=0xce;}_0x52c7ca['status'](_0x373078);return _0x52c7ca[_0xbdb4('0x22')](_0xbdb4('0x23'),_0x2ca1d5+'-'+_0x1e5d10+'/'+_0x4a180b)[_0xbdb4('0x1f')](_0x113471);}return null;};}function patchUpdates(_0x4f89ce){return function(_0x1bbabc){try{jsonpatch['apply'](_0x1bbabc,_0x4f89ce,!![]);}catch(_0xc8d47c){return BPromise[_0xbdb4('0x24')](_0xc8d47c);}return _0x1bbabc[_0xbdb4('0x25')]();};}function saveUpdates(_0x2320e9,_0x2eab45){return function(_0x250ade){if(_0x250ade){return _0x250ade['update'](_0x2320e9)[_0xbdb4('0x26')](function(_0x18b284){return _0x18b284;});}return null;};}function removeEntity(_0x2ea4f4,_0x18bec7){return function(_0x6ac75a){if(_0x6ac75a){return _0x6ac75a['destroy']()[_0xbdb4('0x26')](function(){_0x2ea4f4[_0xbdb4('0x1e')](0xcc)[_0xbdb4('0x1d')]();});}};}function handleEntityNotFound(_0x5b46a1,_0x59b289){return function(_0x1ab9b1){if(!_0x1ab9b1){_0x5b46a1[_0xbdb4('0x1c')](0x194);}return _0x1ab9b1;};}function handleError(_0x3b3e0b,_0x2e0e42){_0x2e0e42=_0x2e0e42||0x1f4;return function(_0x1403e2){logger[_0xbdb4('0x27')](_0x1403e2[_0xbdb4('0x28')]);if(_0x1403e2[_0xbdb4('0x29')]){delete _0x1403e2[_0xbdb4('0x29')];}_0x3b3e0b[_0xbdb4('0x1e')](_0x2e0e42)['send'](_0x1403e2);};}exports[_0xbdb4('0x2a')]=function(_0x11a783,_0x1246a7){var _0x1e7b00={},_0x4572e8={},_0x5c0c73={'count':0x0,'rows':[]};return db[_0xbdb4('0x2b')][_0xbdb4('0x2c')]()[_0xbdb4('0x26')](function(_0x464fe2){var _0x1ca755=[];for(var _0x466308=0x0;_0x466308<Object[_0xbdb4('0x2d')](_0x464fe2)[_0xbdb4('0x2e')];_0x466308++){var _0x5ae8e4=Object[_0xbdb4('0x2d')](_0x464fe2)[_0x466308];if(_[_0xbdb4('0x2f')](_0x5ae8e4,'cf_')){_0x1ca755['push'](db[_0xbdb4('0x30')]['findOne']({'where':{'id':_[_0xbdb4('0x31')](_0x5ae8e4,_0xbdb4('0x32'))},'raw':!![]}));}}return BPromise[_0xbdb4('0x33')](_0x1ca755)[_0xbdb4('0x26')](function(_0x543923){for(var _0x4b4bd6=0x0;_0x4b4bd6<_0x543923[_0xbdb4('0x2e')];_0x4b4bd6++){if(_0x543923[_0x4b4bd6]){var _0x477c59=_0xbdb4('0x32')+_0x543923[_0x4b4bd6]['id'];var _0x1cbd44=_0x464fe2[_0x477c59];_0x1cbd44[_0xbdb4('0x34')]=_0x543923[_0x4b4bd6][_0xbdb4('0x35')];}}return _0x464fe2;});})[_0xbdb4('0x26')](function(_0x17a9e7){_0x4572e8[_0xbdb4('0x36')]=_[_0xbdb4('0x2d')](_0x17a9e7);_0x4572e8[_0xbdb4('0x37')]=_['keys'](_0x11a783[_0xbdb4('0x37')]);_0x4572e8[_0xbdb4('0x38')]=_[_0xbdb4('0x39')](_0x4572e8[_0xbdb4('0x36')],_0x4572e8['query']);_0x1e7b00[_0xbdb4('0x3a')]=_[_0xbdb4('0x39')](_0x4572e8[_0xbdb4('0x36')],qs[_0xbdb4('0x3b')](_0x11a783[_0xbdb4('0x37')][_0xbdb4('0x3b')]));_0x1e7b00[_0xbdb4('0x3a')]=_0x1e7b00[_0xbdb4('0x3a')][_0xbdb4('0x2e')]?_0x1e7b00[_0xbdb4('0x3a')]:_0x4572e8['model'];if(!_0x11a783[_0xbdb4('0x37')][_0xbdb4('0x3c')](_0xbdb4('0x3d'))){_0x1e7b00['limit']=qs[_0xbdb4('0x21')](_0x11a783[_0xbdb4('0x37')][_0xbdb4('0x21')]);_0x1e7b00[_0xbdb4('0x20')]=qs['offset'](_0x11a783[_0xbdb4('0x37')]['offset']);}_0x1e7b00['order']=qs[_0xbdb4('0x3e')](_0x11a783[_0xbdb4('0x37')]['sort']);_0x1e7b00[_0xbdb4('0x3f')]=qs[_0xbdb4('0x38')](_[_0xbdb4('0x40')](_0x11a783[_0xbdb4('0x37')],_0x4572e8[_0xbdb4('0x38')]),_0x17a9e7);var _0x14b1cc=[];var _0x4cb799=squel[_0xbdb4('0x41')]()['field']('id')['field'](_0xbdb4('0x29'))[_0xbdb4('0x42')](_0xbdb4('0x43'))[_0xbdb4('0x44')](_0xbdb4('0x45'));var _0x45b9db=squel[_0xbdb4('0x41')]()[_0xbdb4('0x44')](_0xbdb4('0x46'),'c')[_0xbdb4('0x47')](_0xbdb4('0x48'),'uc',_0xbdb4('0x49'))[_0xbdb4('0x47')](_0xbdb4('0x4a'),'ct',_0xbdb4('0x4b'))['left_join'](_0xbdb4('0x45'),'t','t.id\x20=\x20ct.TagId')[_0xbdb4('0x3f')]('c.deletedAt\x20IS\x20NULL');var _0x4c5784=squel['expr']();var _0x5980c8=[];var _0x7e05ab=squel['expr']();var _0x2e5a12;if(_0x11a783[_0xbdb4('0x37')][_0xbdb4('0x4c')]){_0x2e5a12=as['parseSearch'](_0x11a783[_0xbdb4('0x37')][_0xbdb4('0x4c')]);var _0x23ba91=_0x2e5a12[_0xbdb4('0x4d')];for(var _0x1abf16=0x0;_0x1abf16<_0x2e5a12[_0xbdb4('0x4e')][_0xbdb4('0x2e')];_0x1abf16++){var _0x127e3a=_0x2e5a12['conditions'][_0x1abf16];var _0x4611d1='c';var _0x2f074e=_(_0x17a9e7)[_0xbdb4('0x2d')]()[_0xbdb4('0x4f')](function(_0x54ff45){return _0x54ff45===_0x127e3a[_0xbdb4('0x42')];});if(_0x2f074e)_0x2f074e=_0x17a9e7[_0x127e3a[_0xbdb4('0x42')]];if(!_0x2f074e){if(_0x127e3a[_0xbdb4('0x42')]===_0xbdb4('0x50')){var _0x26daa0=_0x127e3a['value'][_0xbdb4('0x51')](',')[_0xbdb4('0x52')](function(_0x58a0ef){return Number(_0x58a0ef);});_0x26daa0['forEach'](function(_0x86ef21){_0x7e05ab['or']('CONCAT(\x27,\x27,\x20`TagIds`,\x20\x27,\x27)\x20LIKE\x20?','%,'+_0x86ef21+',%');});_0x5980c8=_['union'](_0x5980c8,_0x26daa0);}else if(_0x127e3a[_0xbdb4('0x42')]===_0xbdb4('0x53')){_0x4c5784[_0xbdb4('0x54')](_0xbdb4('0x55'),_0x127e3a[_0xbdb4('0x56')]);}}else{if(_0x127e3a[_0xbdb4('0x42')]===_0xbdb4('0x57')||_0x2f074e[_0xbdb4('0x34')]===_0xbdb4('0x58'))_0x127e3a[_0xbdb4('0x59')]=_0xbdb4('0x5a');var _0x38a441=as[_0xbdb4('0x5b')](_0x4611d1,_0x2f074e['type'],_0x127e3a);_0x4c5784[_0x23ba91](_0x38a441[_0xbdb4('0x5c')],_0x38a441['value'][_0xbdb4('0x5d')],_0x38a441[_0xbdb4('0x56')][_0xbdb4('0x1d')]);}}}else{var _0x375163=_(Object[_0xbdb4('0x2d')](_0x11a783[_0xbdb4('0x37')]))['map'](function(_0x4e85bd){return _0x17a9e7[_0xbdb4('0x3c')](_0x4e85bd)?_0x4e85bd:undefined;})[_0xbdb4('0x5e')](function(_0xc169d5){return!_[_0xbdb4('0x5f')](_0xc169d5);})[_0xbdb4('0x56')]();if(_0x11a783[_0xbdb4('0x37')][_0xbdb4('0x60')])_0x375163[_0xbdb4('0x61')](_0xbdb4('0x60'));if(!_[_0xbdb4('0x62')](_0x375163)){_0x375163[_0xbdb4('0x63')](function(_0x3ff304){if(_0x3ff304==='ListId'){_0x45b9db[_0xbdb4('0x3f')](_0xbdb4('0x64'),[][_0xbdb4('0x65')](_0x11a783['query'][_0x3ff304]));}else if(_0x3ff304==='Contact'){var _0x267cb8='%'+_0x11a783[_0xbdb4('0x37')][_0x3ff304]+'%';_0x45b9db['where']('CONCAT_WS(\x27\x20\x27,\x20c.firstName,\x20c.lastName,\x20c.email)\x20LIKE\x20?',_0x267cb8);}else{_0x45b9db[_0xbdb4('0x3f')]('c.'+_0x3ff304+_0xbdb4('0x66'),_0x11a783['query'][_0x3ff304]);}});}if(_0x11a783[_0xbdb4('0x37')][_0xbdb4('0x67')]){_0x5980c8=_[_0xbdb4('0x68')](_0x11a783['query']['tag'])?_0x11a783[_0xbdb4('0x37')][_0xbdb4('0x67')]:new Array(_0x11a783[_0xbdb4('0x37')][_0xbdb4('0x67')]);_0x5980c8[_0xbdb4('0x63')](function(_0xd9fad7){_0x7e05ab['or'](_0xbdb4('0x69'),'%,'+_0xd9fad7+',%');});}if(_0x11a783['query']['filter']){var _0x14ecad=_0x11a783['query'][_0xbdb4('0x5e')]['replace']('\x5c','\x5c\x5c')['replace'](/'/g,'\x27\x27');if(_0x14ecad['split']('\x20')[_0xbdb4('0x2e')]>0x1){_0x4c5784['or'](_0xbdb4('0x6a'),qs[_0xbdb4('0x6b')](_0x14ecad),null);}else{if(qs[_0xbdb4('0x6c')](_0x14ecad)){_0x4c5784['or'](_0xbdb4('0x6d'),_0x14ecad+'%');_0x4c5784['or']('c.phone\x20LIKE\x20?',_0x14ecad+'%');_0x4c5784['or'](_0xbdb4('0x6e'),_0x14ecad+'%');_0x4c5784['or']('c.fax\x20LIKE\x20?',_0x14ecad+'%');}else if(qs[_0xbdb4('0x6f')](_0x14ecad)){_0x4c5784['or'](_0xbdb4('0x70'),_0x14ecad+'%');}else{_0x4c5784['or'](_0xbdb4('0x71'),'%'+_0x14ecad+'%');_0x4c5784['or'](_0xbdb4('0x72'),'%'+_0x14ecad+'%');_0x4c5784['or'](_0xbdb4('0x70'),'%'+_0x14ecad+'%');}}}}_0x45b9db[_0xbdb4('0x3f')](_0x4c5784);_0x45b9db['group'](_0xbdb4('0x73'));var _0x3b0c54={'type':db['Sequelize'][_0xbdb4('0x74')][_0xbdb4('0x75')],'raw':!![]};var _0x1a5919=_0x45b9db['clone']()[_0xbdb4('0x42')]('c.id');if(_0x1e7b00[_0xbdb4('0x76')]){_0x1e7b00[_0xbdb4('0x76')][_0xbdb4('0x63')](function(_0xe863b8){_0x45b9db['order']('c.'+_0xe863b8[0x0],_0xe863b8[0x1]===_0xbdb4('0x77')?![]:!![]);});}if(!_['isEmpty'](_0x5980c8)){_0x45b9db['having'](_0x7e05ab);_0x1a5919[_0xbdb4('0x3f')](_0xbdb4('0x78'),_0x5980c8);}BPromise[_0xbdb4('0x79')]()[_0xbdb4('0x26')](function(){if(!_0x2e5a12)return;if(_0x11a783[_0xbdb4('0x7a')]['role']!=='agent')return;if(!_[_0xbdb4('0x7b')](_0x2e5a12[_0xbdb4('0x4e')],[_0xbdb4('0x42'),'User'])){return _0x11a783[_0xbdb4('0x7a')][_0xbdb4('0x7c')]({'attributes':['id'],'raw':!![]})['then'](function(_0x31f569){if(_[_0xbdb4('0x62')](_0x31f569)){_0x1a5919[_0xbdb4('0x3f')](_0xbdb4('0x7d'));_0x45b9db[_0xbdb4('0x3f')](_0xbdb4('0x7d'));}else{_0x1a5919[_0xbdb4('0x3f')]('c.ListId\x20IN\x20?',_['map'](_0x31f569,'id'));_0x45b9db['where'](_0xbdb4('0x64'),_[_0xbdb4('0x52')](_0x31f569,'id'));}});}})[_0xbdb4('0x26')](function(){if(_0x11a783[_0xbdb4('0x7a')]['role']==='agent'&&!_0x2e5a12&&!_0x11a783[_0xbdb4('0x37')][_0xbdb4('0x7e')])return[];return db[_0xbdb4('0x7f')][_0xbdb4('0x37')](_0x1a5919[_0xbdb4('0x80')](),_0x3b0c54);})[_0xbdb4('0x26')](function(_0x513f4a){_0x5c0c73['count']=_0x513f4a[_0xbdb4('0x2e')];if(_0x5c0c73[_0xbdb4('0x81')]===0x0)return[];return db[_0xbdb4('0x7f')]['query'](_0x4cb799[_0xbdb4('0x80')](),_0x3b0c54)[_0xbdb4('0x26')](function(_0x43fc62){_0x14b1cc=_[_0xbdb4('0x82')](_0x43fc62,'id');_0x3b0c54=_[_0xbdb4('0x83')](_0x3b0c54,{'model':db[_0xbdb4('0x2b')],'mapToModel':!![],'raw':!![],'nest':!![]});if(_0x11a783[_0xbdb4('0x37')][_0xbdb4('0x3b')]){_0x1e7b00[_0xbdb4('0x3a')][_0xbdb4('0x63')](function(_0x4293db){_0x45b9db[_0xbdb4('0x42')]('c.'+_0x4293db);});}else{_0x45b9db[_0xbdb4('0x42')](_0xbdb4('0x73'));_0x45b9db[_0xbdb4('0x42')](_0xbdb4('0x84'));_0x45b9db[_0xbdb4('0x42')]('c.lastName');_0x45b9db['field']('c.phone');_0x45b9db[_0xbdb4('0x42')](_0xbdb4('0x85'));_0x45b9db[_0xbdb4('0x42')](_0xbdb4('0x86'));_0x45b9db[_0xbdb4('0x42')]('c.email');_0x45b9db['field'](_0xbdb4('0x87'));_0x45b9db[_0xbdb4('0x42')](_0xbdb4('0x88'));_0x45b9db[_0xbdb4('0x42')](_0xbdb4('0x89'));_0x45b9db[_0xbdb4('0x42')]('c.CompanyId');_0x45b9db['field'](_0xbdb4('0x8a'),_0xbdb4('0x8b'));}if(_0x1e7b00[_0xbdb4('0x21')])_0x45b9db[_0xbdb4('0x21')](_0x1e7b00['limit']);if(_0x1e7b00['offset'])_0x45b9db[_0xbdb4('0x20')](_0x1e7b00[_0xbdb4('0x20')]);return db[_0xbdb4('0x7f')][_0xbdb4('0x37')](_0x45b9db[_0xbdb4('0x80')](),_0x3b0c54);});})[_0xbdb4('0x26')](function(_0x1ce7bd){_0x1ce7bd[_0xbdb4('0x63')](function(_0xc2f277){if(_0xc2f277['TagIds']){_0xc2f277[_0xbdb4('0x8c')]=[];_0xc2f277['TagIds']['split'](',')['forEach'](function(_0x2d1146){_0xc2f277[_0xbdb4('0x8c')]['push'](_0x14b1cc[_0x2d1146]);});}delete _0xc2f277['TagIds'];});_0x5c0c73[_0xbdb4('0x8d')]=_0x1ce7bd;return _0x5c0c73;})[_0xbdb4('0x26')](respondWithFilteredResult(_0x1246a7,_0x1e7b00));})[_0xbdb4('0x8e')](handleError(_0x1246a7,null));};exports['destroy']=function(_0x1f4ad1,_0x5eb802){return db[_0xbdb4('0x2b')][_0xbdb4('0x4f')]({'where':{'id':_0x1f4ad1[_0xbdb4('0x8f')]['id']}})[_0xbdb4('0x26')](handleEntityNotFound(_0x5eb802,null))[_0xbdb4('0x26')](removeEntity(_0x5eb802,null))[_0xbdb4('0x8e')](handleError(_0x5eb802,null));};exports['describe']=function(_0x202bb3,_0x5e1864){return db[_0xbdb4('0x2b')][_0xbdb4('0x2c')]()[_0xbdb4('0x26')](function(_0x1bac96){delete _0x1bac96['tags'];for(var _0x4b2602=0x0;_0x4b2602<Object['keys'](_0x1bac96)[_0xbdb4('0x2e')];_0x4b2602++){var _0x172718=Object[_0xbdb4('0x2d')](_0x1bac96)[_0x4b2602];if(!_[_0xbdb4('0x2f')](_0x172718,_0xbdb4('0x32'))){_0x1bac96[_0x172718][_0xbdb4('0x90')]=_0x172718;_0x1bac96[_0x172718][_0xbdb4('0x91')]=_0x172718;}}return _0x1bac96;})[_0xbdb4('0x26')](function(_0x19e166){var _0x37dc6f={'where':{'$or':[{'ListId':_0x202bb3['query']['id']},{'ListId':null}]},'raw':!![]};return db[_0xbdb4('0x30')][_0xbdb4('0x92')](_0x37dc6f)['then'](function(_0xbda65c){for(var _0x111237=0x0;_0x111237<_0xbda65c[_0xbdb4('0x2e')];_0x111237++){var _0x1adf27=_0xbdb4('0x32')+_0xbda65c[_0x111237]['id'];_0x19e166[_0x1adf27][_0xbdb4('0x90')]=_0x1adf27;_0x19e166[_0x1adf27][_0xbdb4('0x91')]=_0xbda65c[_0x111237]['alias'];_0x19e166[_0x1adf27][_0xbdb4('0x93')]={'type':_0xbda65c[_0x111237][_0xbdb4('0x35')],'values':_0xbda65c[_0x111237][_0xbdb4('0x94')]};}Object[_0xbdb4('0x2d')](_0x19e166)[_0xbdb4('0x63')](function(_0x50bbf3){if(!_0x19e166[_0x50bbf3][_0xbdb4('0x3c')](_0xbdb4('0x90'))){delete _0x19e166[_0x50bbf3];}});return _0x19e166;});})['then'](respondWithResult(_0x5e1864,null))[_0xbdb4('0x8e')](handleError(_0x5e1864,null));};exports[_0xbdb4('0x83')]=function(_0x2afa06,_0x513bfb){var _0x11b188;var _0x4f706a;var _0x3df83a;if(_0x2afa06['body']['id']){delete _0x2afa06['body']['id'];}return db[_0xbdb4('0x2b')][_0xbdb4('0x92')]({'where':{'id':[_0x2afa06['body']['to'],_0x2afa06[_0xbdb4('0x95')]['from']]}})[_0xbdb4('0x26')](function(_0x1294e9){if(_0x1294e9){if(_0x1294e9[_0xbdb4('0x2e')]!==0x2){return null;}_0x1294e9[0x0]=_0x1294e9[0x0][_0xbdb4('0x96')]({'plain':!![]});_0x1294e9[0x1]=_0x1294e9[0x1][_0xbdb4('0x96')]({'plain':!![]});delete _0x1294e9[0x0]['id'];delete _0x1294e9[0x1]['id'];return _[_0xbdb4('0x97')](_0x1294e9[0x0],_0x1294e9[0x1],function(_0x403d83,_0x15877d){if(Array['isArray'](_0x15877d)&&!_0x15877d['length']){return _0x403d83;}else if(!_0x15877d){return _0x403d83;}});}})[_0xbdb4('0x26')](handleEntityNotFound(_0x513bfb,null))[_0xbdb4('0x26')](function(_0x1e2abe){if(_0x1e2abe){if(_0x1e2abe['tags']&&_[_0xbdb4('0x68')](_0x1e2abe['tags'])){_0x1e2abe['tags']=_0x1e2abe[_0xbdb4('0x98')]['join']();}logger[_0xbdb4('0x99')](_0xbdb4('0x9a'),_0x2afa06['body']['to'],_0x2afa06[_0xbdb4('0x95')][_0xbdb4('0x44')]);return db[_0xbdb4('0x9b')]['destroy']({'where':{'ContactId':[_0x2afa06[_0xbdb4('0x95')]['to'],_0x2afa06[_0xbdb4('0x95')][_0xbdb4('0x44')]]}})[_0xbdb4('0x26')](function(_0x255bf3){logger['info'](_0xbdb4('0x9c'),_0x255bf3);return db[_0xbdb4('0x9d')][_0xbdb4('0x9e')]({'where':{'ContactId':[_0x2afa06[_0xbdb4('0x95')]['to'],_0x2afa06[_0xbdb4('0x95')][_0xbdb4('0x44')]]}})[_0xbdb4('0x26')](function(_0x215a53){logger[_0xbdb4('0x99')](_0xbdb4('0x9f'),_0x215a53);return db[_0xbdb4('0x2b')][_0xbdb4('0xa0')](_0x1e2abe);});});}})[_0xbdb4('0x26')](function(_0x459d30){if(_0x459d30){_0x11b188=_0x459d30;_0x4f706a={'ContactId':_0x11b188['id']};_0x3df83a={'where':{'ContactId':[_0x2afa06[_0xbdb4('0x95')]['to'],_0x2afa06[_0xbdb4('0x95')]['from']]}};return db[_0xbdb4('0xa1')][_0xbdb4('0xa2')](_0x4f706a,_0x3df83a);}})['then'](function(){if(_0x11b188){return db[_0xbdb4('0xa3')][_0xbdb4('0xa2')](_0x4f706a,_0x3df83a);}})[_0xbdb4('0x26')](function(){if(_0x11b188){return db['ChatOfflineMessage'][_0xbdb4('0xa2')](_0x4f706a,_0x3df83a);}})[_0xbdb4('0x26')](function(){if(_0x11b188){return db[_0xbdb4('0xa4')][_0xbdb4('0xa2')](_0x4f706a,_0x3df83a);}})[_0xbdb4('0x26')](function(){if(_0x11b188){return db[_0xbdb4('0xa5')]['update'](_0x4f706a,_0x3df83a);}})[_0xbdb4('0x26')](function(){if(_0x11b188){return db['MailInteraction'][_0xbdb4('0xa2')](_0x4f706a,_0x3df83a);}})['then'](function(){if(_0x11b188){return db[_0xbdb4('0xa5')][_0xbdb4('0xa2')](_0x4f706a,_0x3df83a);}})[_0xbdb4('0x26')](function(){if(_0x11b188){return db[_0xbdb4('0xa6')][_0xbdb4('0xa2')](_0x4f706a,_0x3df83a);}})[_0xbdb4('0x26')](function(){if(_0x11b188){return db[_0xbdb4('0xa7')][_0xbdb4('0xa2')](_0x4f706a,_0x3df83a);}})[_0xbdb4('0x26')](function(){if(_0x11b188){return db['FaxInteraction'][_0xbdb4('0xa2')](_0x4f706a,_0x3df83a);}})[_0xbdb4('0x26')](function(){if(_0x11b188){return db[_0xbdb4('0xa8')][_0xbdb4('0xa2')](_0x4f706a,_0x3df83a);}})[_0xbdb4('0x26')](function(){if(_0x11b188){return db['OpenchannelInteraction'][_0xbdb4('0xa2')](_0x4f706a,_0x3df83a);}})['then'](function(){if(_0x11b188){return db[_0xbdb4('0xa9')][_0xbdb4('0xa2')](_0x4f706a,_0x3df83a);}})[_0xbdb4('0x26')](function(){if(_0x11b188){return db[_0xbdb4('0xaa')][_0xbdb4('0xa2')](_0x4f706a,_0x3df83a);}})[_0xbdb4('0x26')](function(){if(_0x11b188){return db[_0xbdb4('0xab')][_0xbdb4('0xa2')](_0x4f706a,_0x3df83a);}})[_0xbdb4('0x26')](function(){if(_0x11b188){return db[_0xbdb4('0xac')][_0xbdb4('0xa2')](_0x4f706a,_0x3df83a);}})[_0xbdb4('0x26')](function(){if(_0x11b188){return db[_0xbdb4('0xad')]['update'](_0x4f706a,_0x3df83a);}})[_0xbdb4('0x26')](function(){if(_0x11b188){return db[_0xbdb4('0xae')][_0xbdb4('0xa2')](_0x4f706a,_0x3df83a);}})[_0xbdb4('0x26')](function(){if(_0x11b188){return db[_0xbdb4('0xaf')][_0xbdb4('0xa2')](_0x4f706a,_0x3df83a);}})[_0xbdb4('0x26')](function(){if(_0x11b188){return db[_0xbdb4('0xb0')][_0xbdb4('0xa2')](_0x4f706a,_0x3df83a);}})[_0xbdb4('0x26')](function(){if(_0x11b188){return db['OpenchannelQueueReport']['update'](_0x4f706a,_0x3df83a);}})[_0xbdb4('0x26')](function(){if(_0x11b188){return db['SmsQueueReport'][_0xbdb4('0xa2')](_0x4f706a,_0x3df83a);}})[_0xbdb4('0x26')](function(){if(_0x11b188){return db['JscriptySessionReport'][_0xbdb4('0xa2')](_0x4f706a,_0x3df83a);}})[_0xbdb4('0x26')](function(){if(_0x11b188){return db[_0xbdb4('0xb1')][_0xbdb4('0xa2')](_0x4f706a,_0x3df83a);}})[_0xbdb4('0x26')](function(){if(_0x11b188){return db[_0xbdb4('0xb2')][_0xbdb4('0xa2')](_0x4f706a,_0x3df83a);}})[_0xbdb4('0x26')](function(){if(_0x11b188){return db['WhatsappQueueReport'][_0xbdb4('0xa2')](_0x4f706a,_0x3df83a);}})[_0xbdb4('0x26')](function(){if(_0x11b188){return db[_0xbdb4('0x2b')]['destroy']({'where':{'id':[_0x2afa06[_0xbdb4('0x95')]['to'],_0x2afa06[_0xbdb4('0x95')][_0xbdb4('0x44')]]}});}})['then'](function(){if(_0x11b188){return _0x11b188;}})[_0xbdb4('0x26')](respondWithResult(_0x513bfb,null))[_0xbdb4('0x8e')](handleError(_0x513bfb,null));};exports[_0xbdb4('0xa0')]=function(_0x28e8b8,_0x472ee5){return db[_0xbdb4('0x2b')][_0xbdb4('0x2c')]()[_0xbdb4('0x26')](function(_0x4f85ca){if(_0x28e8b8[_0xbdb4('0x95')][_0xbdb4('0x98')]&&_['isArray'](_0x28e8b8[_0xbdb4('0x95')][_0xbdb4('0x98')])){if(_0x28e8b8[_0xbdb4('0x95')][_0xbdb4('0x98')][_0xbdb4('0x2e')]){_0x28e8b8[_0xbdb4('0x95')][_0xbdb4('0x98')]=_0x28e8b8['body']['tags'][_0xbdb4('0xb3')](';')+';';}else{_0x28e8b8[_0xbdb4('0x95')]['tags']=null;}}else{_0x28e8b8[_0xbdb4('0x95')]['tags']=null;}return db['CmContact'][_0xbdb4('0xa0')](_0x28e8b8['body'],{'fields':_[_0xbdb4('0x2d')](_0x4f85ca),'raw':!![]});})[_0xbdb4('0x26')](respondWithResult(_0x472ee5,0xc9))[_0xbdb4('0x8e')](handleError(_0x472ee5,null));};exports[_0xbdb4('0xb4')]=function(_0x55d065,_0x4fe187){var _0x4aaa17=[];var _0x1f969a=0x0;var _0x13e561=0x0;var _0x57c13c=0x0;return db[_0xbdb4('0x2b')][_0xbdb4('0x2c')]()[_0xbdb4('0x26')](function(_0x134bbe){return BPromise[_0xbdb4('0xb5')](_0x55d065[_0xbdb4('0x95')],function(_0x2126c1){var _0x5b3915={'where':{'$or':[]},'defaults':_0x2126c1,'fields':_['keys'](_0x134bbe),'raw':!![]};if(_0x2126c1[_0xbdb4('0xb6')]){for(var _0x5a4658=0x0;_0x5a4658<_0x2126c1[_0xbdb4('0xb6')][_0xbdb4('0x2e')];_0x5a4658++){var _0x207547={};_0x207547[_0x2126c1[_0xbdb4('0xb6')][_0x5a4658]]=_0x2126c1[_0x2126c1[_0xbdb4('0xb6')][_0x5a4658]];_0x5b3915['where'][_0xbdb4('0xb7')]['push'](_0x207547);}_0x5b3915[_0xbdb4('0x3f')][_0xbdb4('0x7e')]=_0x2126c1[_0xbdb4('0x7e')];}return db[_0xbdb4('0x2b')][_0xbdb4('0xb8')](_0x5b3915)[_0xbdb4('0xb9')](function(_0x319558,_0x47a0c0){if(_0x47a0c0){_0x1f969a++;}else{_0x57c13c++;}})[_0xbdb4('0x8e')](function(_0x28b355){console[_0xbdb4('0x27')](_0x28b355);_0x13e561++;});});})[_0xbdb4('0x26')](function(_0x21771d){if(_0x21771d){return{'success':_0x1f969a,'failure':_0x13e561,'duplicates':_0x57c13c};}})['then'](respondWithResult(_0x4fe187,0xc9))[_0xbdb4('0x8e')](handleError(_0x4fe187,null));};exports[_0xbdb4('0xba')]=function(_0x21cf56,_0x3158f2,_0x5d9b67){var _0xb508f2;return db[_0xbdb4('0x2b')][_0xbdb4('0x2c')]()[_0xbdb4('0x26')](function(_0x8be74e){return db['CmContact'][_0xbdb4('0x4f')]({'where':{'id':_0x21cf56[_0xbdb4('0x8f')]['id']},'include':[{'model':db[_0xbdb4('0x50')],'as':_0xbdb4('0x8c'),'attributes':['id',_0xbdb4('0x29'),_0xbdb4('0x43')],'required':_0x21cf56[_0xbdb4('0x37')][_0xbdb4('0x67')]?!![]:![]}],'attributes':_['keys'](_0x8be74e)});})[_0xbdb4('0x26')](function(_0x2371f4){_0xb508f2=_0x2371f4['get']({'plain':!![]});var _0x507da8={'where':{'$and':[{'ListId':{'$ne':null}}]}};if(_0x2371f4&&_0x2371f4[_0xbdb4('0x7e')]){if(_0x2371f4[_0xbdb4('0x7e')]){_0x507da8['where'][_0xbdb4('0xbb')][_0xbdb4('0x61')]({'ListId':{'$ne':_0x2371f4[_0xbdb4('0x7e')]}});}}return db['CmCustomField']['findAll'](_0x507da8);})[_0xbdb4('0x26')](function(_0x52a964){return _[_0xbdb4('0xbc')](_0xb508f2,_[_0xbdb4('0x52')](_0x52a964,function(_0x5095de){return util[_0xbdb4('0xbd')](_0xbdb4('0xbe'),_0x5095de['id']);}));})[_0xbdb4('0x26')](handleEntityNotFound(_0x3158f2,null))[_0xbdb4('0x26')](respondWithResult(_0x3158f2,null))[_0xbdb4('0x8e')](handleError(_0x3158f2,null));};exports['update']=function(_0x5930a5,_0x2fe1b4){var _0x59d179;if(_0x5930a5[_0xbdb4('0x95')]['id']){delete _0x5930a5[_0xbdb4('0x95')]['id'];}return db[_0xbdb4('0x2b')][_0xbdb4('0x4f')]({'where':{'id':_0x5930a5['params']['id']}})[_0xbdb4('0x26')](handleEntityNotFound(_0x2fe1b4,null))[_0xbdb4('0x26')](saveUpdates(_0x5930a5['body'],null))[_0xbdb4('0x26')](function(_0x69d1bd){_0x59d179=_0x69d1bd;var _0xbd4b53={'where':{'$and':[{'ListId':{'$ne':null}}]}};if(_0x69d1bd&&_0x69d1bd[_0xbdb4('0x7e')]){if(_0x69d1bd[_0xbdb4('0x7e')]){_0xbd4b53[_0xbdb4('0x3f')]['$and']['push']({'ListId':{'$ne':_0x69d1bd[_0xbdb4('0x7e')]}});}}return db[_0xbdb4('0x30')][_0xbdb4('0x92')](_0xbd4b53);})[_0xbdb4('0x26')](function(_0x51fbb1){if(_0x51fbb1){return _['omit'](_[_0xbdb4('0xbf')](_0x5930a5['body'],function(_0x25accf,_0x4e075c){return _['startsWith'](_0x4e075c,_0xbdb4('0x32'));}),_[_0xbdb4('0x52')](_0x51fbb1,function(_0xaa171){return util['format']('cf_%d',_0xaa171['id']);}));}})[_0xbdb4('0x26')](function(_0x423dd7){if(_0x423dd7&&!_[_0xbdb4('0x62')](_0x423dd7)){var _0x533bce=squel[_0xbdb4('0xa2')]()[_0xbdb4('0xc0')](_0xbdb4('0x46'))['setFields'](_0x423dd7)[_0xbdb4('0x3f')](_0xbdb4('0xc1'),_0x5930a5[_0xbdb4('0x8f')]['id'])['toParam']();return db[_0xbdb4('0x7f')]['query'](_0x533bce['text'],{'replacements':_0x533bce['values']});}})[_0xbdb4('0x26')](function(){if(_0x5930a5['body'][_0xbdb4('0xc2')]&&_0x59d179){return db[_0xbdb4('0x9b')][_0xbdb4('0xa2')]({'phone':_0x5930a5['body'][_0xbdb4('0xc2')]},{'where':{'ContactId':_0x59d179['id']}});}})['then'](function(){return _0x59d179;})[_0xbdb4('0x26')](respondWithResult(_0x2fe1b4,null))['catch'](handleError(_0x2fe1b4,null));};exports[_0xbdb4('0xc3')]=function(_0x3282f7,_0x2035cb,_0x20e2eb){var _0x41d462={};var _0x53f2ed={};var _0x4557b0;var _0x2cb3c4;return db[_0xbdb4('0x2b')][_0xbdb4('0xc4')]({'where':{'id':_0x3282f7[_0xbdb4('0x8f')]['id']}})[_0xbdb4('0x26')](handleEntityNotFound(_0x2035cb,null))[_0xbdb4('0x26')](function(_0x39bbaa){if(_0x39bbaa){_0x4557b0=_0x39bbaa;_0x53f2ed[_0xbdb4('0x36')]=_[_0xbdb4('0x2d')](db[_0xbdb4('0x50')][_0xbdb4('0xc5')]);_0x53f2ed[_0xbdb4('0x37')]=_[_0xbdb4('0x2d')](_0x3282f7[_0xbdb4('0x37')]);_0x53f2ed['filters']=_[_0xbdb4('0x39')](_0x53f2ed[_0xbdb4('0x36')],_0x53f2ed[_0xbdb4('0x37')]);_0x41d462[_0xbdb4('0x3a')]=_['intersection'](_0x53f2ed[_0xbdb4('0x36')],qs['fields'](_0x3282f7['query'][_0xbdb4('0x3b')]));_0x41d462[_0xbdb4('0x3a')]=_0x41d462[_0xbdb4('0x3a')][_0xbdb4('0x2e')]?_0x41d462[_0xbdb4('0x3a')]:_0x53f2ed[_0xbdb4('0x36')];_0x41d462['order']=qs['sort'](_0x3282f7[_0xbdb4('0x37')][_0xbdb4('0x3e')]);_0x41d462[_0xbdb4('0x3f')]=qs[_0xbdb4('0x38')](_['pick'](_0x3282f7[_0xbdb4('0x37')],_0x53f2ed[_0xbdb4('0x38')]));if(_0x3282f7[_0xbdb4('0x37')]['filter']){_0x41d462[_0xbdb4('0x3f')]=_[_0xbdb4('0x83')](_0x41d462[_0xbdb4('0x3f')],{'$or':_[_0xbdb4('0x52')](_0x41d462[_0xbdb4('0x3a')],function(_0x1ed127){var _0x29dc5f={};_0x29dc5f[_0x1ed127]={'$like':'%'+_0x3282f7[_0xbdb4('0x37')][_0xbdb4('0x5e')]+'%'};return _0x29dc5f;})});}_0x41d462=_['merge']({},_0x41d462,_0x3282f7[_0xbdb4('0xc6')]);return _0x4557b0[_0xbdb4('0xc3')](_0x41d462);}})[_0xbdb4('0x26')](function(_0x46107d){if(_0x46107d){_0x2cb3c4=_0x46107d[_0xbdb4('0x2e')];if(!_0x3282f7[_0xbdb4('0x37')][_0xbdb4('0x3c')]('nolimit')){_0x41d462[_0xbdb4('0x21')]=qs[_0xbdb4('0x21')](_0x3282f7[_0xbdb4('0x37')]['limit']);_0x41d462[_0xbdb4('0x20')]=qs[_0xbdb4('0x20')](_0x3282f7['query'][_0xbdb4('0x20')]);}return _0x4557b0[_0xbdb4('0xc3')](_0x41d462);}})[_0xbdb4('0x26')](function(_0x21aceb){if(_0x21aceb){return _0x21aceb?{'count':_0x2cb3c4,'rows':_0x21aceb}:null;}})[_0xbdb4('0x26')](respondWithResult(_0x2035cb,null))[_0xbdb4('0x8e')](handleError(_0x2035cb,null));};exports[_0xbdb4('0xc7')]=function(_0x878ce0,_0x19d874,_0x38f92e){if(_0x878ce0[_0xbdb4('0x95')]['id']){delete _0x878ce0[_0xbdb4('0x95')]['id'];}return db[_0xbdb4('0x2b')][_0xbdb4('0xc4')]({'where':{'id':_0x878ce0[_0xbdb4('0x8f')]['id']}})[_0xbdb4('0x26')](handleEntityNotFound(_0x19d874,null))[_0xbdb4('0x26')](function(_0xf94a96){if(_0xf94a96){return _0xf94a96[_0xbdb4('0xc7')](_0x878ce0[_0xbdb4('0x95')]['ids']||[]);}return null;})[_0xbdb4('0x26')](respondWithResult(_0x19d874,null))[_0xbdb4('0x8e')](handleError(_0x19d874,null));};exports[_0xbdb4('0xc8')]=function(_0x380b6d,_0x1b8612,_0x43c0a0){var _0xc78f99={'raw':![],'where':{}};var _0x192c22={};var _0x524962={'count':0x0,'rows':[]};return db['CmContact'][_0xbdb4('0xc4')]({'where':{'id':_0x380b6d[_0xbdb4('0x8f')]['id']}})[_0xbdb4('0x26')](handleEntityNotFound(_0x1b8612,null))['then'](function(_0x181c2b){if(_0x181c2b){_0x192c22['model']=_[_0xbdb4('0x2d')](db[_0xbdb4('0x9b')][_0xbdb4('0xc5')]);_0x192c22[_0xbdb4('0x37')]=_['keys'](_0x380b6d[_0xbdb4('0x37')]);_0x192c22[_0xbdb4('0x38')]=_[_0xbdb4('0x39')](_0x192c22[_0xbdb4('0x36')],_0x192c22[_0xbdb4('0x37')]);_0xc78f99[_0xbdb4('0x3a')]=_[_0xbdb4('0x39')](_0x192c22['model'],qs[_0xbdb4('0x3b')](_0x380b6d[_0xbdb4('0x37')][_0xbdb4('0x3b')]));_0xc78f99[_0xbdb4('0x3a')]=_0xc78f99[_0xbdb4('0x3a')][_0xbdb4('0x2e')]?_0xc78f99[_0xbdb4('0x3a')]:_0x192c22['model'];if(!_0x380b6d[_0xbdb4('0x37')]['hasOwnProperty']('nolimit')){_0xc78f99[_0xbdb4('0x21')]=qs['limit'](_0x380b6d[_0xbdb4('0x37')][_0xbdb4('0x21')]);_0xc78f99[_0xbdb4('0x20')]=qs['offset'](_0x380b6d['query'][_0xbdb4('0x20')]);}_0xc78f99[_0xbdb4('0x76')]=qs[_0xbdb4('0x3e')](_0x380b6d[_0xbdb4('0x37')]['sort']);_0xc78f99[_0xbdb4('0x3f')]=qs[_0xbdb4('0x38')](_[_0xbdb4('0x40')](_0x380b6d[_0xbdb4('0x37')],_0x192c22['filters']));_0xc78f99[_0xbdb4('0x3f')][_0xbdb4('0xc9')]=_0x181c2b['id'];if(_0x380b6d[_0xbdb4('0x37')][_0xbdb4('0x5e')]){_0xc78f99[_0xbdb4('0x3f')]=_['merge'](_0xc78f99['where'],{'$or':_[_0xbdb4('0x52')](_0xc78f99[_0xbdb4('0x3a')],function(_0x1bcf71){var _0x49501a={};_0x49501a[_0x1bcf71]={'$like':'%'+_0x380b6d[_0xbdb4('0x37')][_0xbdb4('0x5e')]+'%'};return _0x49501a;})});}_0xc78f99=_['merge']({},_0xc78f99,_0x380b6d[_0xbdb4('0xc6')]);return db[_0xbdb4('0x9b')]['count']({'where':_0xc78f99[_0xbdb4('0x3f')]})[_0xbdb4('0x26')](function(_0x29d22c){_0x524962[_0xbdb4('0x81')]=_0x29d22c;if(_0x380b6d[_0xbdb4('0x37')][_0xbdb4('0xca')]){_0xc78f99[_0xbdb4('0xcb')]=[{'all':!![]}];}return db[_0xbdb4('0x9b')][_0xbdb4('0x92')](_0xc78f99);})['then'](function(_0x56ba29){_0x524962[_0xbdb4('0x8d')]=_0x56ba29;return _0x524962;});}})[_0xbdb4('0x26')](respondWithFilteredResult(_0x1b8612,_0xc78f99))['catch'](handleError(_0x1b8612,null));};exports[_0xbdb4('0xcc')]=function(_0x2706fa,_0x55e732,_0x45f9ca){var _0x3da0b6={'raw':!![],'where':{}};var _0x52f7b2={};var _0x2856ef={'count':0x0,'rows':[]};return db[_0xbdb4('0x2b')][_0xbdb4('0xc4')]({'where':{'id':_0x2706fa[_0xbdb4('0x8f')]['id']}})[_0xbdb4('0x26')](handleEntityNotFound(_0x55e732,null))['then'](function(_0x117a77){if(_0x117a77){_0x52f7b2[_0xbdb4('0x36')]=_[_0xbdb4('0x2d')](db[_0xbdb4('0xab')][_0xbdb4('0xc5')]);_0x52f7b2[_0xbdb4('0x37')]=_[_0xbdb4('0x2d')](_0x2706fa[_0xbdb4('0x37')]);_0x52f7b2[_0xbdb4('0x38')]=_[_0xbdb4('0x39')](_0x52f7b2[_0xbdb4('0x36')],_0x52f7b2[_0xbdb4('0x37')]);_0x3da0b6[_0xbdb4('0x3a')]=_[_0xbdb4('0x39')](_0x52f7b2['model'],qs[_0xbdb4('0x3b')](_0x2706fa['query'][_0xbdb4('0x3b')]));_0x3da0b6[_0xbdb4('0x3a')]=_0x3da0b6[_0xbdb4('0x3a')][_0xbdb4('0x2e')]?_0x3da0b6[_0xbdb4('0x3a')]:_0x52f7b2[_0xbdb4('0x36')];if(!_0x2706fa['query'][_0xbdb4('0x3c')](_0xbdb4('0x3d'))){_0x3da0b6[_0xbdb4('0x21')]=qs['limit'](_0x2706fa[_0xbdb4('0x37')][_0xbdb4('0x21')]);_0x3da0b6[_0xbdb4('0x20')]=qs[_0xbdb4('0x20')](_0x2706fa[_0xbdb4('0x37')][_0xbdb4('0x20')]);}_0x3da0b6[_0xbdb4('0x76')]=qs['sort'](_0x2706fa[_0xbdb4('0x37')][_0xbdb4('0x3e')]);_0x3da0b6[_0xbdb4('0x3f')]=qs[_0xbdb4('0x38')](_[_0xbdb4('0x40')](_0x2706fa['query'],_0x52f7b2['filters']));_0x3da0b6[_0xbdb4('0x3f')][_0xbdb4('0xc9')]=_0x117a77['id'];if(_0x2706fa['query'][_0xbdb4('0x5e')]){_0x3da0b6[_0xbdb4('0x3f')]=_[_0xbdb4('0x83')](_0x3da0b6['where'],{'$or':_[_0xbdb4('0x52')](_0x3da0b6[_0xbdb4('0x3a')],function(_0x544a53){var _0x16e6b6={};_0x16e6b6[_0x544a53]={'$like':'%'+_0x2706fa[_0xbdb4('0x37')]['filter']+'%'};return _0x16e6b6;})});}_0x3da0b6=_['merge']({},_0x3da0b6,_0x2706fa[_0xbdb4('0xc6')]);return db[_0xbdb4('0xab')]['count']({'where':_0x3da0b6[_0xbdb4('0x3f')]})[_0xbdb4('0x26')](function(_0x215916){_0x2856ef[_0xbdb4('0x81')]=_0x215916;if(_0x2706fa[_0xbdb4('0x37')][_0xbdb4('0xca')]){_0x3da0b6[_0xbdb4('0xcb')]=[{'all':!![]}];}return db[_0xbdb4('0xab')]['findAll'](_0x3da0b6);})[_0xbdb4('0x26')](function(_0x4c2ee7){_0x2856ef[_0xbdb4('0x8d')]=_0x4c2ee7;return _0x2856ef;});}})[_0xbdb4('0x26')](respondWithFilteredResult(_0x55e732,_0x3da0b6))['catch'](handleError(_0x55e732,null));};exports['getHopperFinals']=function(_0x14cb74,_0x38c0a7,_0x301ea8){var _0x9dc07a={'raw':!![],'where':{}};var _0x482544={};var _0x2c101b={'count':0x0,'rows':[]};return db[_0xbdb4('0x2b')][_0xbdb4('0xc4')]({'where':{'id':_0x14cb74[_0xbdb4('0x8f')]['id']}})[_0xbdb4('0x26')](handleEntityNotFound(_0x38c0a7,null))[_0xbdb4('0x26')](function(_0x50ca46){if(_0x50ca46){_0x482544['model']=_[_0xbdb4('0x2d')](db[_0xbdb4('0xaa')][_0xbdb4('0xc5')]);_0x482544[_0xbdb4('0x37')]=_[_0xbdb4('0x2d')](_0x14cb74[_0xbdb4('0x37')]);_0x482544['filters']=_[_0xbdb4('0x39')](_0x482544['model'],_0x482544[_0xbdb4('0x37')]);_0x9dc07a[_0xbdb4('0x3a')]=_['intersection'](_0x482544[_0xbdb4('0x36')],qs[_0xbdb4('0x3b')](_0x14cb74[_0xbdb4('0x37')]['fields']));_0x9dc07a['attributes']=_0x9dc07a[_0xbdb4('0x3a')][_0xbdb4('0x2e')]?_0x9dc07a[_0xbdb4('0x3a')]:_0x482544[_0xbdb4('0x36')];if(!_0x14cb74[_0xbdb4('0x37')][_0xbdb4('0x3c')](_0xbdb4('0x3d'))){_0x9dc07a[_0xbdb4('0x21')]=qs['limit'](_0x14cb74[_0xbdb4('0x37')][_0xbdb4('0x21')]);_0x9dc07a['offset']=qs[_0xbdb4('0x20')](_0x14cb74[_0xbdb4('0x37')][_0xbdb4('0x20')]);}_0x9dc07a['order']=qs[_0xbdb4('0x3e')](_0x14cb74[_0xbdb4('0x37')][_0xbdb4('0x3e')]);_0x9dc07a['where']=qs[_0xbdb4('0x38')](_[_0xbdb4('0x40')](_0x14cb74[_0xbdb4('0x37')],_0x482544['filters']));_0x9dc07a[_0xbdb4('0x3f')]['ContactId']=_0x50ca46['id'];if(_0x14cb74[_0xbdb4('0x37')][_0xbdb4('0x5e')]){_0x9dc07a[_0xbdb4('0x3f')]=_[_0xbdb4('0x83')](_0x9dc07a[_0xbdb4('0x3f')],{'$or':_[_0xbdb4('0x52')](_0x9dc07a['attributes'],function(_0x3e07cb){var _0x43b339={};_0x43b339[_0x3e07cb]={'$like':'%'+_0x14cb74[_0xbdb4('0x37')][_0xbdb4('0x5e')]+'%'};return _0x43b339;})});}_0x9dc07a=_[_0xbdb4('0x83')]({},_0x9dc07a,_0x14cb74['options']);return db['CmHopperFinal'][_0xbdb4('0x81')]({'where':_0x9dc07a[_0xbdb4('0x3f')]})[_0xbdb4('0x26')](function(_0x6027dd){_0x2c101b[_0xbdb4('0x81')]=_0x6027dd;if(_0x14cb74[_0xbdb4('0x37')][_0xbdb4('0xca')]){_0x9dc07a['include']=[{'all':!![]}];}return db['CmHopperFinal']['findAll'](_0x9dc07a);})['then'](function(_0x2a2408){_0x2c101b[_0xbdb4('0x8d')]=_0x2a2408;return _0x2c101b;});}})[_0xbdb4('0x26')](respondWithFilteredResult(_0x38c0a7,_0x9dc07a))[_0xbdb4('0x8e')](handleError(_0x38c0a7,null));};exports[_0xbdb4('0xcd')]=function(_0x4db034,_0x13cb19,_0x2e26cd){var _0x8d2028={'raw':!![],'where':{}};var _0x2781fb={};var _0x58a684={'count':0x0,'rows':[]};return db[_0xbdb4('0x2b')][_0xbdb4('0xc4')]({'where':{'id':_0x4db034['params']['id']}})['then'](handleEntityNotFound(_0x13cb19,null))[_0xbdb4('0x26')](function(_0x220468){if(_0x220468){_0x2781fb[_0xbdb4('0x36')]=_[_0xbdb4('0x2d')](db[_0xbdb4('0xce')][_0xbdb4('0xc5')]);_0x2781fb['query']=_[_0xbdb4('0x2d')](_0x4db034['query']);_0x2781fb['filters']=_['intersection'](_0x2781fb[_0xbdb4('0x36')],_0x2781fb[_0xbdb4('0x37')]);_0x8d2028[_0xbdb4('0x3a')]=_[_0xbdb4('0x39')](_0x2781fb[_0xbdb4('0x36')],qs[_0xbdb4('0x3b')](_0x4db034[_0xbdb4('0x37')][_0xbdb4('0x3b')]));_0x8d2028[_0xbdb4('0x3a')]=_0x8d2028[_0xbdb4('0x3a')][_0xbdb4('0x2e')]?_0x8d2028[_0xbdb4('0x3a')]:_0x2781fb[_0xbdb4('0x36')];if(!_0x4db034[_0xbdb4('0x37')][_0xbdb4('0x3c')](_0xbdb4('0x3d'))){_0x8d2028[_0xbdb4('0x21')]=qs['limit'](_0x4db034[_0xbdb4('0x37')][_0xbdb4('0x21')]);_0x8d2028[_0xbdb4('0x20')]=qs[_0xbdb4('0x20')](_0x4db034['query'][_0xbdb4('0x20')]);}_0x8d2028[_0xbdb4('0x76')]=qs['sort'](_0x4db034[_0xbdb4('0x37')][_0xbdb4('0x3e')]);_0x8d2028[_0xbdb4('0x3f')]=qs['filters'](_['pick'](_0x4db034['query'],_0x2781fb[_0xbdb4('0x38')]));_0x8d2028[_0xbdb4('0x3f')][_0xbdb4('0xc9')]=_0x220468['id'];if(_0x4db034[_0xbdb4('0x37')][_0xbdb4('0x5e')]){_0x8d2028['where']=_['merge'](_0x8d2028[_0xbdb4('0x3f')],{'$or':_[_0xbdb4('0x52')](_0x8d2028[_0xbdb4('0x3a')],function(_0x58369e){var _0x108375={};_0x108375[_0x58369e]={'$like':'%'+_0x4db034[_0xbdb4('0x37')]['filter']+'%'};return _0x108375;})});}_0x8d2028=_['merge']({},_0x8d2028,_0x4db034[_0xbdb4('0xc6')]);return db['JscriptySessionReport']['count']({'where':_0x8d2028[_0xbdb4('0x3f')]})['then'](function(_0x40d87e){_0x58a684[_0xbdb4('0x81')]=_0x40d87e;if(_0x4db034[_0xbdb4('0x37')][_0xbdb4('0xca')]){_0x8d2028['include']=[{'all':!![]}];}return db[_0xbdb4('0xce')][_0xbdb4('0x92')](_0x8d2028);})['then'](function(_0x16d02b){_0x58a684['rows']=_0x16d02b;return _0x58a684;});}})[_0xbdb4('0x26')](respondWithFilteredResult(_0x13cb19,_0x8d2028))[_0xbdb4('0x8e')](handleError(_0x13cb19,null));};exports[_0xbdb4('0xcf')]=function(_0x3f8470,_0x543c3f,_0x2f0bd8){try{if(!_0x3f8470['body']['ListId']){throw new Error(_0xbdb4('0xd0'));}if(!_0x3f8470[_0xbdb4('0x95')][_0xbdb4('0xd1')]){throw new Error(_0xbdb4('0xd2'));}if(!_0x3f8470[_0xbdb4('0x95')]['binding_values']){throw new Error(_0xbdb4('0xd3'));}if(!_0x3f8470[_0xbdb4('0x95')][_0xbdb4('0xd4')]){throw new Error(_0xbdb4('0xd5'));}var _0x4eb0d5=_0x3f8470['body']['binding_keys'][_0xbdb4('0x51')](',');var _0x5a99bb=_0x3f8470['body'][_0xbdb4('0xd6')][_0xbdb4('0x51')](',');if(!_0x4eb0d5[_0xbdb4('0x2e')]||!_0x5a99bb[_0xbdb4('0x2e')]||_0x4eb0d5[_0xbdb4('0x2e')]!==_0x5a99bb[_0xbdb4('0x2e')]){throw new Error('Incorrect\x20binding\x20parameters\x20passed!');}_0x3f8470[_0xbdb4('0x95')][_0xbdb4('0x3b')]=_[_0xbdb4('0xd7')](_0x4eb0d5,_0x5a99bb);if(!_0x3f8470['body']['fields']['phone']){throw new Error(_0xbdb4('0xd8'));}if(!_0x3f8470[_0xbdb4('0x95')][_0xbdb4('0x3b')][_0xbdb4('0xd9')]){throw new Error(_0xbdb4('0xda'));}var _0x4094e7=path[_0xbdb4('0xb3')](config[_0xbdb4('0xdb')],_0xbdb4('0xdc'),_0x3f8470['file'][_0xbdb4('0xdd')]);fs[_0xbdb4('0xde')](_0x4094e7,parseInt(_0xbdb4('0xdf'),0x8));var _0x74bf9a=require(_0xbdb4('0xe0'))[_0xbdb4('0xe1')](path[_0xbdb4('0xb3')](__dirname,'../../components/import/cm/csv'),[_0x4094e7,_0x3f8470[_0xbdb4('0x95')][_0xbdb4('0xd1')],_0x3f8470[_0xbdb4('0x95')][_0xbdb4('0xd6')],_0x3f8470[_0xbdb4('0x95')]['ListId'],_0x3f8470[_0xbdb4('0x95')][_0xbdb4('0xe2')],_0x3f8470['body']['duplicates'],_0x3f8470[_0xbdb4('0x95')][_0xbdb4('0xd4')]]);return _0x543c3f['status'](0xc8)[_0xbdb4('0x1f')]({'message':_0xbdb4('0xe3'),'pid':_0x74bf9a['pid']});}catch(_0x1355d0){return _0x543c3f[_0xbdb4('0x1e')](0x1f4)[_0xbdb4('0xe4')](_0x1355d0);}};exports[_0xbdb4('0xe5')]=function(_0x5e33da,_0x154831,_0x4e90d){var _0x458e00=fs[_0xbdb4('0xe6')](_0x5e33da[_0xbdb4('0xe7')][_0xbdb4('0x7')]);Papa['parse'](_0x458e00,{'header':!![],'skipEmptyLines':!![],'preview':0x1,'complete':function(_0x40cb55){return _0x154831[_0xbdb4('0x1e')](0xc8)['json']({'file':_0x5e33da[_0xbdb4('0xe7')],'fields':_0x40cb55[_0xbdb4('0xe8')][_0xbdb4('0x3b')]});}});};exports['import']=function(_0x1b1426,_0x4d2cbb,_0x58c5ec){return db['User']['findAll']({'raw':!![],'attributes':['id'],'where':{'role':_0xbdb4('0xe9')}})[_0xbdb4('0x26')](function(_0x3c3aa5){var _0x2f45dd=![];if(!_0x1b1426[_0xbdb4('0x95')][_0xbdb4('0x7e')]){throw new Error(_0xbdb4('0xd0'));}if(!_0x1b1426[_0xbdb4('0x95')][_0xbdb4('0xea')][_0xbdb4('0xc2')]){throw new Error(_0xbdb4('0xd8'));}if(!_0x1b1426[_0xbdb4('0x95')][_0xbdb4('0xea')]['firstName']){throw new Error(_0xbdb4('0xda'));}if(!_0x1b1426['body'][_0xbdb4('0xd4')]){throw new Error(_0xbdb4('0xd5'));}var _0x280065=require(_0xbdb4('0xe0'))[_0xbdb4('0xe1')](path['join'](__dirname,_0xbdb4('0xeb')),[_0x1b1426[_0xbdb4('0x8f')]['id'],JSON[_0xbdb4('0xec')](_0x1b1426[_0xbdb4('0x95')]),JSON[_0xbdb4('0xec')](_0x3c3aa5)]);_0x280065['on'](_0xbdb4('0xed'),function(_0x555303){_0x2f45dd=!![];return _0x4d2cbb[_0xbdb4('0x1e')](0xc8)[_0xbdb4('0x1f')]({'message':_0xbdb4('0xee'),'pid':_0x280065[_0xbdb4('0xef')]});});_0x280065['on']('exit',function(_0x5c5596){if(_0x5c5596&&!_0x2f45dd){return _0x4d2cbb['status'](0x1f4)['json']({'message':_0xbdb4('0xf0'),'pid':_0x280065[_0xbdb4('0xef')]});}});})['catch'](handleError(_0x4d2cbb,null));};exports[_0xbdb4('0xf1')]=function(_0x4a0607,_0x4d2dc4){var _0x1a4d43=['mail','chat',_0xbdb4('0xf2'),_0xbdb4('0xf3'),_0xbdb4('0xf4'),_0xbdb4('0xf5'),_0xbdb4('0xf6')];var _0x43e0f9={'offset':0x0,'order':qs[_0xbdb4('0x3e')](_0xbdb4('0xf7'))},_0x162e70={'count':0x0,'rows':[]};Promise[_0xbdb4('0x79')]()[_0xbdb4('0x26')](function(){if(_0x4a0607[_0xbdb4('0x37')]['channel']){if(!_[_0xbdb4('0xf8')](_0x1a4d43,_0x4a0607['query'][_0xbdb4('0xf9')]['toLowerCase']())){throw new Error('Invalid\x20channel');}_0x1a4d43=[_0x4a0607['query'][_0xbdb4('0xf9')][_0xbdb4('0xfa')]()];}if(_0x4a0607[_0xbdb4('0x37')]['range']){try{var _0x4ba77c=JSON[_0xbdb4('0xfb')](_0x4a0607[_0xbdb4('0x37')]['range']);if(!moment(_0x4ba77c[_0xbdb4('0x44')])[_0xbdb4('0xfc')]()){throw new Error('Invalid\x20date\x20for\x20range\x20from\x20filter');}if(!moment(_0x4ba77c['to'])[_0xbdb4('0xfc')]()){throw new Error('Invalid\x20date\x20for\x20range\x20to\x20filter');}}catch(_0xf7f67f){throw new Error('Invalid\x20createdAt\x20filter');}}if(!_0x4a0607[_0xbdb4('0x37')][_0xbdb4('0x3c')](_0xbdb4('0x3d'))){_0x43e0f9[_0xbdb4('0x21')]=qs[_0xbdb4('0x21')](_0x4a0607[_0xbdb4('0x37')][_0xbdb4('0x21')]||0xa);_0x43e0f9[_0xbdb4('0x20')]=qs[_0xbdb4('0x20')](_0x4a0607[_0xbdb4('0x37')]['offset']);}var _0x45c047=_0x1a4d43[_0xbdb4('0x52')](function(_0x451ca5){if(_0x451ca5===_0xbdb4('0xf6')){var _0x28cc47={'attributes':['id','uniqueid',_0xbdb4('0x35'),'source',_0xbdb4('0xfd'),_0xbdb4('0xfe'),_0xbdb4('0xff'),_0xbdb4('0x100'),_0xbdb4('0x101'),_0xbdb4('0x102'),'createdAt',_0xbdb4('0x103'),'userSecondDisposition',_0xbdb4('0x104')],'where':{'ContactId':_0x4a0607['params']['id']},'include':[{'model':db[_0xbdb4('0x53')],'as':_0xbdb4('0x53'),'attributes':['id',_0xbdb4('0x29'),'fullname',_0xbdb4('0x105')]}],'order':[[_0xbdb4('0x106'),'DESC']]};if(_0x4a0607[_0xbdb4('0x37')]['range']){_0x28cc47['where'][_0xbdb4('0x106')]={'$gte':_0x4ba77c[_0xbdb4('0x44')],'$lte':_0x4ba77c['to']};}return db[_0xbdb4('0xad')][_0xbdb4('0x107')](_0x28cc47)['then'](function(_0x18b2bb){_0x162e70['count']+=_0x18b2bb[_0xbdb4('0x81')];return _[_0xbdb4('0x52')](_0x18b2bb[_0xbdb4('0x8d')],function(_0x491cc){var _0x505b3c=_0x491cc[_0xbdb4('0x96')]({'plain':!![]});_0x505b3c[_0xbdb4('0xf9')]=_0x451ca5;if(_0x505b3c[_0xbdb4('0x53')]){_0x505b3c[_0xbdb4('0x53')]={'id':_0x505b3c[_0xbdb4('0x53')]['id'],'name':_0x505b3c[_0xbdb4('0x53')][_0xbdb4('0x29')],'fullname':_0x505b3c[_0xbdb4('0x53')][_0xbdb4('0x108')],'alias':_0x505b3c[_0xbdb4('0x53')][_0xbdb4('0x105')]};}return _0x505b3c;});});}else{var _0x590026=_[_0xbdb4('0x109')](_0x451ca5)+(_0x451ca5===_0xbdb4('0x10a')?_0xbdb4('0x10b'):_0xbdb4('0x10c'));var _0x34db4d={'attributes':['id',_0xbdb4('0x10d'),_0xbdb4('0x10e'),_0xbdb4('0x106'),_0xbdb4('0x102'),_0xbdb4('0x10f'),_0xbdb4('0x110'),'thirdDisposition',_0xbdb4('0x111'),_0x590026+'Id'],'where':{'ContactId':_0x4a0607[_0xbdb4('0x8f')]['id']},'include':[{'model':db[_0x590026],'as':_0xbdb4('0x10c'),'attributes':['id',_0xbdb4('0x29'),'key']},{'model':db[_0xbdb4('0x53')],'as':_0xbdb4('0x112'),'attributes':['id',_0xbdb4('0x29'),_0xbdb4('0x108')]},{'model':db[_0xbdb4('0x50')],'as':_0xbdb4('0x8c'),'attributes':['id',_0xbdb4('0x29'),_0xbdb4('0x43')],'through':{'attributes':[]}}],'order':[['createdAt',_0xbdb4('0x77')]]};if(_0x4a0607[_0xbdb4('0x37')][_0xbdb4('0x113')]){_0x34db4d['where'][_0xbdb4('0x106')]={'$gte':_0x4ba77c[_0xbdb4('0x44')],'$lte':_0x4ba77c['to']};}switch(_0x451ca5){case _0xbdb4('0x10a'):_0x34db4d[_0xbdb4('0x3a')]['push'](_0xbdb4('0x114'),'customerIp',_0xbdb4('0x115'),_0xbdb4('0x116'),'osName',_0xbdb4('0x117'),_0xbdb4('0x118'),_0xbdb4('0x119'),'referer');break;case _0xbdb4('0x11a'):_0x34db4d[_0xbdb4('0x3a')][_0xbdb4('0x61')](_0xbdb4('0x11b'),'substatus');break;case'openchannel':_0x34db4d[_0xbdb4('0x3a')][_0xbdb4('0x61')](_0xbdb4('0x11c'),_0xbdb4('0x11d'));break;}return db[_[_0xbdb4('0x109')](_0x451ca5)+_0xbdb4('0x11e')][_0xbdb4('0x107')](_0x34db4d)['then'](function(_0x237768){_0x162e70[_0xbdb4('0x81')]+=_0x237768[_0xbdb4('0x81')];return _[_0xbdb4('0x52')](_0x237768[_0xbdb4('0x8d')],function(_0x239267){var _0x4f9baf=_0x239267['get']({'plain':!![]});_0x4f9baf[_0xbdb4('0xf9')]=_0x451ca5;if(_0x4f9baf[_0xbdb4('0x112')]){_0x4f9baf[_0xbdb4('0x112')]={'id':_0x4f9baf['Owner']['id'],'name':_0x4f9baf[_0xbdb4('0x112')][_0xbdb4('0x29')],'fullname':_0x4f9baf[_0xbdb4('0x112')]['fullname']};}return _0x4f9baf;});});}});return Promise[_0xbdb4('0x33')](_0x45c047);})[_0xbdb4('0x26')](function(_0x78bdbf){return _(_0x78bdbf)[_0xbdb4('0x11f')]()[_0xbdb4('0x120')](_0xbdb4('0x106'))[_0xbdb4('0x121')]()[_0xbdb4('0x56')]();})[_0xbdb4('0x26')](function(_0x25c38c){_0x162e70[_0xbdb4('0x8d')]=_0x43e0f9[_0xbdb4('0x21')]?_0x25c38c[_0xbdb4('0x122')](_0x43e0f9[_0xbdb4('0x20')],_0x43e0f9[_0xbdb4('0x20')]+_0x43e0f9['limit']):_0x25c38c;return _0x162e70;})[_0xbdb4('0x26')](respondWithFilteredResult(_0x4d2dc4,_0x43e0f9))['catch'](handleError(_0x4d2dc4,null));};
\ No newline at end of file