Built motion from commit ddca4d0d.|2.5.47
[motion2.git] / server / api / openchannelInteraction / openchannelInteraction.controller.js
index 4247b25..26458ac 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xf0db=['socket.io-emitter','./openchannelInteraction.socket','sendStatus','status','end','json','limit','undefined','count','offset','set','Content-Range','apply','reject','update','then','destroy','error','stack','name','send','Users','fullname','Tags','split','forEach','push','TagIds','waiting','answered','unmanaged','total','UserId','closed','talking','index','map','OpenchannelInteraction','rawAttributes','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','select','field','color','tools_tags','u.id','u.fullname','ui.OpenchannelInteractionId','from','user_has_openchannel_interactions','left_join','u.id\x20=\x20ui.UserId','cm_contacts','c.id\x20=\x20i.ContactId\x20AND\x20c.deletedAt\x20IS\x20NULL','users','o.id\x20=\x20i.UserId','openchannel_accounts','a.id\x20=\x20i.OpenchannelAccountId','me.OpenchannelInteractionId\x20=\x20i.id','it.OpenchannelInteractionId\x20=\x20i.id','t.id\x20=\x20it.TagId','parseSearch','search','sqlOperator','conditions','find','value','having','`\x20=\x200','`\x20>\x200','Contact','$substring','MATCH\x20(c.firstName,\x20c.lastName,\x20c.phone,\x20c.mobile,\x20c.fax,\x20c.email)\x20AGAINST\x20(?\x20IN\x20BOOLEAN\x20MODE)','getFullTextValue','c.firstName\x20LIKE\x20?\x20OR\x20c.lastName\x20LIKE\x20?\x20OR\x20c.email\x20LIKE\x20?','ContactId','type','start','CONCAT(\x27,\x27,\x20`TagIds`,\x20\x27,\x27)\x20LIKE\x20?','union','User','CONCAT_WS(\x27\x20\x27,\x20o.name,\x20o.fullname)\x20LIKE\x20?','buildExpression','text','some','compact','isEmpty','OpenchannelAccountId','i.OpenchannelAccountId\x20IN\x20?','createdAt','parse','$gte','$lte','i.createdAt\x20BETWEEN\x20?\x20AND\x20?','null','\x20IS\x20NULL','read','`unreadMessages`\x20=\x200','tag','filter','replace','isNumeric','i.id\x20LIKE\x20?','MATCH\x20(me.body)\x20AGAINST\x20(?\x20IN\x20BOOLEAN\x20MODE)','i.from\x20LIKE\x20?','CONCAT(c.firstName,\x20\x27\x20\x27,\x20c.lastName)\x20LIKE\x20?','group','i.id','Sequelize','QueryTypes','SELECT','clone','SUM(me.read\x20=\x200\x20AND\x20me.direction\x20=\x20\x27in\x27)','contactName','resolve','i.OpenchannelAccountId\x20IS\x20NOT\x20NULL','user','role','agent','getOpenchannelAccounts','i.OpenchannelAccountId\x20IS\x20NULL','sequelize','toString','unreadMessages','a.key','Account.key','Account.mandatoryDisposition','i.*','c.firstName','Contact.firstName','Contact.lastName','c.email','Contact.email','c.phone','c.mobile','Contact.mobile','c.fax','Owner.fullname','o.internal','Owner.internal','ui.OpenchannelInteractionId\x20IN\x20?','all','rows','show','params','includeAll','include','merge','options','create','catch','body','describe','addMessage','OpenchannelMessage','ids','findOne','OpenchannelInteractionId','format','YYYY-MM-DD\x20HH:mm:ss','addTags','setTags','omit','spread','Tag','findAll','emit','openchannelInteractionTags:save','removeTags','server','tmp','join','root','files','attachments','transcript-%d-%s.zip','CmContact','firstName','lastName','Attachment','Messages','direction','secret','OpenchannelAccount','Account','Owner','mkdirSync','N.A.','closedAt','disposition','threadId','Public','Private','basename','existsSync','createReadStream','pipe','createWriteStream','out','System','renderFile','views','downloadInteraction.ejs','transcript-','.pdf','Openchannel','log','unlinkSync','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','bluebird','sox','to-csv','ejs','fs-extra','lodash','crypto','desk.js','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../components/export/pdf','../../config/license/hardware','../../config/utils','../../config/license/util','../../mysqldb','redis','defaults'];(function(_0x2e9b4c,_0x1ed87b){var _0x2e5feb=function(_0x11a7cc){while(--_0x11a7cc){_0x2e9b4c['push'](_0x2e9b4c['shift']());}};_0x2e5feb(++_0x1ed87b);}(_0xf0db,0xdc));var _0xbf0d=function(_0x4cdb3b,_0x441f54){_0x4cdb3b=_0x4cdb3b-0x0;var _0x1e891b=_0xf0db[_0x4cdb3b];return _0x1e891b;};'use strict';var emlformat=require(_0xbf0d('0x0'));var rimraf=require(_0xbf0d('0x1'));var zipdir=require(_0xbf0d('0x2'));var jsonpatch=require(_0xbf0d('0x3'));var rp=require(_0xbf0d('0x4'));var moment=require('moment');var BPromise=require(_0xbf0d('0x5'));var Mustache=require('mustache');var util=require('util');var path=require('path');var sox=require(_0xbf0d('0x6'));var csv=require(_0xbf0d('0x7'));var ejs=require(_0xbf0d('0x8'));var fs=require('fs');var fs_extra=require(_0xbf0d('0x9'));var _=require(_0xbf0d('0xa'));var squel=require('squel');var crypto=require(_0xbf0d('0xb'));var jsforce=require('jsforce');var deskjs=require(_0xbf0d('0xc'));var toCsv=require(_0xbf0d('0x7'));var querystring=require(_0xbf0d('0xd'));var Papa=require('papaparse');var Redis=require(_0xbf0d('0xe'));var authService=require(_0xbf0d('0xf'));var qs=require(_0xbf0d('0x10'));var as=require(_0xbf0d('0x11'));var pdf=require(_0xbf0d('0x12'));var hardwareService=require(_0xbf0d('0x13'));var logger=require('../../config/logger')('api');var utils=require(_0xbf0d('0x14'));var config=require('../../config/environment');var licenseUtil=require(_0xbf0d('0x15'));var db=require(_0xbf0d('0x16'))['db'];config[_0xbf0d('0x17')]=_[_0xbf0d('0x18')](config[_0xbf0d('0x17')],{'host':'localhost','port':0x18eb});var socket=require(_0xbf0d('0x19'))(new Redis(config[_0xbf0d('0x17')]));require(_0xbf0d('0x1a'))['register'](socket);function respondWithStatusCode(_0x3adbc9,_0x3dd0a5){_0x3dd0a5=_0x3dd0a5||0xcc;return function(_0x2f4301){if(_0x2f4301){return _0x3adbc9[_0xbf0d('0x1b')](_0x3dd0a5);}return _0x3adbc9[_0xbf0d('0x1c')](_0x3dd0a5)[_0xbf0d('0x1d')]();};}function respondWithResult(_0x626c43,_0x52b23f){_0x52b23f=_0x52b23f||0xc8;return function(_0x287937){if(_0x287937){return _0x626c43['status'](_0x52b23f)[_0xbf0d('0x1e')](_0x287937);}};}function respondWithFilteredResult(_0x2509d3,_0x11f815){return function(_0x4adcda){if(_0x4adcda){var _0x431191=typeof _0x11f815['offset']==='undefined'&&typeof _0x11f815[_0xbf0d('0x1f')]===_0xbf0d('0x20');var _0x1f1879=_0x4adcda[_0xbf0d('0x21')];var _0x57b73c=_0x431191?0x0:_0x11f815[_0xbf0d('0x22')];var _0x47106f=_0x431191?_0x4adcda[_0xbf0d('0x21')]:_0x11f815['offset']+_0x11f815['limit'];var _0x3ba4c6;if(_0x47106f>=_0x1f1879){_0x47106f=_0x1f1879;_0x3ba4c6=0xc8;}else{_0x3ba4c6=0xce;}_0x2509d3[_0xbf0d('0x1c')](_0x3ba4c6);return _0x2509d3[_0xbf0d('0x23')](_0xbf0d('0x24'),_0x57b73c+'-'+_0x47106f+'/'+_0x1f1879)[_0xbf0d('0x1e')](_0x4adcda);}return null;};}function patchUpdates(_0x40533a){return function(_0x2416b3){try{jsonpatch[_0xbf0d('0x25')](_0x2416b3,_0x40533a,!![]);}catch(_0x58eeda){return BPromise[_0xbf0d('0x26')](_0x58eeda);}return _0x2416b3['save']();};}function saveUpdates(_0x46f6fc,_0x2d135d){return function(_0x7c1440){if(_0x7c1440){return _0x7c1440[_0xbf0d('0x27')](_0x46f6fc)[_0xbf0d('0x28')](function(_0xc51b4c){return _0xc51b4c;});}return null;};}function removeEntity(_0x29340b,_0x220a5e){return function(_0x4f59fb){if(_0x4f59fb){return _0x4f59fb[_0xbf0d('0x29')]()[_0xbf0d('0x28')](function(){_0x29340b['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x3d3a79,_0xf1d2f2){return function(_0x4905ae){if(!_0x4905ae){_0x3d3a79[_0xbf0d('0x1b')](0x194);}return _0x4905ae;};}function handleError(_0x1a425a,_0x25809c){_0x25809c=_0x25809c||0x1f4;return function(_0x4bfbfa){logger[_0xbf0d('0x2a')](_0x4bfbfa[_0xbf0d('0x2b')]);if(_0x4bfbfa[_0xbf0d('0x2c')]){delete _0x4bfbfa[_0xbf0d('0x2c')];}_0x1a425a[_0xbf0d('0x1c')](_0x25809c)[_0xbf0d('0x2d')](_0x4bfbfa);};}function getInteractionUsers(_0xe3f62b,_0x25e7ea){return new BPromise(function(_0x9ebd73,_0x347348){try{if(_0x25e7ea[_0xe3f62b['id']]){_0xe3f62b[_0xbf0d('0x2e')]=_['map'](_0x25e7ea[_0xe3f62b['id']],function(_0x4d60da){return{'id':_0x4d60da['id'],'fullname':_0x4d60da[_0xbf0d('0x2f')]};});}}catch(_0x518388){_0x347348(_0x518388);}_0x9ebd73(_0xe3f62b);});}function getInteractionTags(_0x50e767,_0x18676e){return new BPromise(function(_0x92b35e,_0x505b2d){try{if(_0x50e767['TagIds']){_0x50e767[_0xbf0d('0x30')]=[];_0x50e767['TagIds'][_0xbf0d('0x31')](',')[_0xbf0d('0x32')](function(_0x27f5bc){_0x50e767[_0xbf0d('0x30')][_0xbf0d('0x33')](_0x18676e[_0x27f5bc]);});}delete _0x50e767[_0xbf0d('0x34')];}catch(_0x37b6e0){_0x505b2d(_0x37b6e0);}_0x92b35e(_0x50e767);});}function updateOpenchannelInteraction(_0x46a15b,_0x452a07,_0x1959cf){return new BPromise(function(_0x1981eb,_0x4aa39a){return getInteractionUsers(_0x46a15b,_0x1959cf)['then'](function(_0xa8c7a8){return getInteractionTags(_0xa8c7a8,_0x452a07);})[_0xbf0d('0x28')](function(_0x2ba23e){return getStateInteraction(_0x2ba23e);})[_0xbf0d('0x28')](function(_0x5a3c5c){_0x1981eb(_0x5a3c5c);})['catch'](function(_0x237653){_0x4aa39a(_0x237653);});});}function getStateInteraction(_0x3ee6a8){return new BPromise(function(_0x14069c){_0x3ee6a8[_0xbf0d('0x35')]=0x0;_0x3ee6a8['talking']=0x0;_0x3ee6a8[_0xbf0d('0x36')]=0x0;_0x3ee6a8[_0xbf0d('0x37')]=0x0;_0x3ee6a8[_0xbf0d('0x38')]=0x0;if(!_0x3ee6a8['closed']&&!_0x3ee6a8[_0xbf0d('0x39')]){_0x3ee6a8[_0xbf0d('0x35')]+=0x1;}if(!_0x3ee6a8[_0xbf0d('0x3a')]&&_0x3ee6a8[_0xbf0d('0x39')]){_0x3ee6a8[_0xbf0d('0x3b')]+=0x1;if(_0x3ee6a8[_0xbf0d('0x35')]){_0x3ee6a8['waiting']-=0x1;}}if(_0x3ee6a8['closed']&&_0x3ee6a8[_0xbf0d('0x39')]){_0x3ee6a8[_0xbf0d('0x36')]+=0x1;if(_0x3ee6a8[_0xbf0d('0x3b')]){_0x3ee6a8['talking']-=0x1;}}if(_0x3ee6a8['closed']&&!_0x3ee6a8[_0xbf0d('0x39')]){_0x3ee6a8[_0xbf0d('0x37')]+=0x1;if(_0x3ee6a8[_0xbf0d('0x35')]){_0x3ee6a8[_0xbf0d('0x35')]-=0x1;}}_0x3ee6a8[_0xbf0d('0x38')]+=0x1;_0x14069c(_0x3ee6a8);});}exports[_0xbf0d('0x3c')]=function(_0x592f97,_0x430500){var _0x20fea1={},_0x580266={},_0x267e6f={'count':0x0,'rows':[]};var _0x1065a3=_[_0xbf0d('0x3d')](db[_0xbf0d('0x3e')][_0xbf0d('0x3f')],function(_0xeac6a1){return{'name':_0xeac6a1['fieldName'],'type':_0xeac6a1['type']['key']};});_0x580266[_0xbf0d('0x40')]=_['map'](_0x1065a3,_0xbf0d('0x2c'));_0x580266[_0xbf0d('0x41')]=_[_0xbf0d('0x42')](_0x592f97[_0xbf0d('0x41')]);_0x580266[_0xbf0d('0x43')]=_[_0xbf0d('0x44')](_0x580266[_0xbf0d('0x40')],_0x580266[_0xbf0d('0x41')]);_0x20fea1[_0xbf0d('0x45')]=_[_0xbf0d('0x44')](_0x580266['model'],qs[_0xbf0d('0x46')](_0x592f97[_0xbf0d('0x41')][_0xbf0d('0x46')]));_0x20fea1[_0xbf0d('0x45')]=_0x20fea1[_0xbf0d('0x45')][_0xbf0d('0x47')]?_0x20fea1['attributes']:_0x580266[_0xbf0d('0x40')];if(!_0x592f97[_0xbf0d('0x41')][_0xbf0d('0x48')](_0xbf0d('0x49'))){_0x20fea1['limit']=qs['limit'](_0x592f97[_0xbf0d('0x41')][_0xbf0d('0x1f')]);_0x20fea1[_0xbf0d('0x22')]=qs[_0xbf0d('0x22')](_0x592f97[_0xbf0d('0x41')]['offset']);}_0x20fea1[_0xbf0d('0x4a')]=qs[_0xbf0d('0x4b')](_0x592f97[_0xbf0d('0x41')][_0xbf0d('0x4b')]);_0x20fea1[_0xbf0d('0x4c')]=qs[_0xbf0d('0x43')](_[_0xbf0d('0x4d')](_0x592f97[_0xbf0d('0x41')],_0x580266[_0xbf0d('0x43')]),_0x1065a3);var _0x3f29dc=[];var _0x54605f=squel[_0xbf0d('0x4e')]()[_0xbf0d('0x4f')]('id')[_0xbf0d('0x4f')](_0xbf0d('0x2c'))[_0xbf0d('0x4f')](_0xbf0d('0x50'))['from'](_0xbf0d('0x51'));var _0x1accbc=squel[_0xbf0d('0x4e')]()['field'](_0xbf0d('0x52'))['field'](_0xbf0d('0x53'))[_0xbf0d('0x4f')](_0xbf0d('0x54'))[_0xbf0d('0x55')](_0xbf0d('0x56'),'ui')[_0xbf0d('0x57')]('users','u',_0xbf0d('0x58'));var _0x210eba=squel[_0xbf0d('0x4e')]()[_0xbf0d('0x55')]('openchannel_interactions','i')[_0xbf0d('0x57')](_0xbf0d('0x59'),'c',_0xbf0d('0x5a'))[_0xbf0d('0x57')](_0xbf0d('0x5b'),'o',_0xbf0d('0x5c'))[_0xbf0d('0x57')](_0xbf0d('0x5d'),'a',_0xbf0d('0x5e'))[_0xbf0d('0x57')]('openchannel_messages','me',_0xbf0d('0x5f'))['left_join']('openchannel_interaction_has_tags','it',_0xbf0d('0x60'))[_0xbf0d('0x57')](_0xbf0d('0x51'),'t',_0xbf0d('0x61'));var _0x398a4d=squel['expr']();var _0x42a2f8=[];var _0x42d34c=squel['expr']();var _0x196b05;if(_0x592f97[_0xbf0d('0x41')]['search']){_0x196b05=as[_0xbf0d('0x62')](_0x592f97[_0xbf0d('0x41')][_0xbf0d('0x63')]);var _0x5b24a3=_0x196b05[_0xbf0d('0x64')];for(var _0x1c06a8=0x0;_0x1c06a8<_0x196b05[_0xbf0d('0x65')][_0xbf0d('0x47')];_0x1c06a8++){var _0x5dba59=_0x196b05[_0xbf0d('0x65')][_0x1c06a8];var _0x4adc3f='i';var _0x14e6ae=_[_0xbf0d('0x66')](_0x1065a3,['name',_0x5dba59[_0xbf0d('0x4f')]]);if(!_0x14e6ae){switch(_0x5dba59[_0xbf0d('0x4f')]){case'unreadMessages':if(_0x5dba59[_0xbf0d('0x67')]==0x1){_0x210eba[_0xbf0d('0x68')]('`'+_0x5dba59[_0xbf0d('0x4f')]+_0xbf0d('0x69'));}else{_0x210eba[_0xbf0d('0x68')]('`'+_0x5dba59[_0xbf0d('0x4f')]+_0xbf0d('0x6a'));}break;case _0xbf0d('0x6b'):if(_0x5dba59['operator']===_0xbf0d('0x6c')){if(_0x5dba59[_0xbf0d('0x67')][_0xbf0d('0x31')]('\x20')['length']>0x1){_0x398a4d[_0x5b24a3](_0xbf0d('0x6d'),qs[_0xbf0d('0x6e')](_0x5dba59[_0xbf0d('0x67')]),null);}else{var _0x55ad99='%'+_0x5dba59[_0xbf0d('0x67')]+'%';_0x398a4d[_0x5b24a3](_0xbf0d('0x6f'),_0x55ad99,_0x55ad99,_0x55ad99);}}else{_0x14e6ae=_['find'](_0x1065a3,[_0xbf0d('0x2c'),_0xbf0d('0x70')]);_0x5dba59[_0xbf0d('0x4f')]='ContactId';_0x4db0e1=as['buildExpression'](_0x4adc3f,_0x14e6ae[_0xbf0d('0x71')],_0x5dba59);_0x398a4d[_0x5b24a3](_0x4db0e1['text'],_0x4db0e1[_0xbf0d('0x67')][_0xbf0d('0x72')],_0x4db0e1[_0xbf0d('0x67')][_0xbf0d('0x1d')]);}break;case'Tag':var _0x541791=_0x5dba59['value'][_0xbf0d('0x31')](',')[_0xbf0d('0x3d')](function(_0x1b4a86){return Number(_0x1b4a86);});_0x541791['forEach'](function(_0x3bb6a1){_0x42d34c['or'](_0xbf0d('0x73'),'%,'+_0x3bb6a1+',%');});_0x42a2f8=_[_0xbf0d('0x74')](_0x42a2f8,_0x541791);break;case _0xbf0d('0x75'):if(_0x5dba59['operator']==='$substring'){_0x398a4d[_0x5b24a3](_0xbf0d('0x76'),'%'+_0x5dba59[_0xbf0d('0x67')]+'%',null);}else{_0x14e6ae=_[_0xbf0d('0x66')](_0x1065a3,[_0xbf0d('0x2c'),_0xbf0d('0x39')]);_0x5dba59[_0xbf0d('0x4f')]=_0xbf0d('0x39');_0x4db0e1=as[_0xbf0d('0x77')](_0x4adc3f,_0x14e6ae[_0xbf0d('0x71')],_0x5dba59);_0x398a4d[_0x5b24a3](_0x4db0e1[_0xbf0d('0x78')],_0x4db0e1[_0xbf0d('0x67')][_0xbf0d('0x72')],_0x4db0e1[_0xbf0d('0x67')]['end']);}break;case'body':_0x4db0e1=as[_0xbf0d('0x77')]('me',null,_0x5dba59);_0x398a4d[_0x5b24a3](_0x4db0e1[_0xbf0d('0x78')],_0x4db0e1[_0xbf0d('0x67')][_0xbf0d('0x72')],_0x4db0e1[_0xbf0d('0x67')][_0xbf0d('0x1d')]);break;}}else{var _0x4db0e1=as[_0xbf0d('0x77')](_0x4adc3f,_0x14e6ae[_0xbf0d('0x71')],_0x5dba59);_0x398a4d[_0x5b24a3](_0x4db0e1[_0xbf0d('0x78')],_0x4db0e1[_0xbf0d('0x67')]['start'],_0x4db0e1[_0xbf0d('0x67')][_0xbf0d('0x1d')]);}}}else{var _0x5587c8=_(_0x592f97[_0xbf0d('0x41')])['keys']()[_0xbf0d('0x3d')](function(_0x5175a8){return _[_0xbf0d('0x79')](_0x1065a3,[_0xbf0d('0x2c'),_0x5175a8])?_0x5175a8:undefined;})[_0xbf0d('0x7a')]()[_0xbf0d('0x67')]();if(!_[_0xbf0d('0x7b')](_0x5587c8)){_0x5587c8[_0xbf0d('0x32')](function(_0x5a3603){if(_0x5a3603===_0xbf0d('0x7c')){_0x210eba[_0xbf0d('0x4c')](_0xbf0d('0x7d'),[]['concat'](_0x592f97[_0xbf0d('0x41')][_0x5a3603]));}else if(_0x5a3603===_0xbf0d('0x7e')){var _0x3fb8d9=JSON[_0xbf0d('0x7f')](_0x592f97[_0xbf0d('0x41')][_0x5a3603])[_0xbf0d('0x80')];var _0x123777=JSON[_0xbf0d('0x7f')](_0x592f97[_0xbf0d('0x41')][_0x5a3603])[_0xbf0d('0x81')];_0x210eba[_0xbf0d('0x4c')](_0xbf0d('0x82'),_0x3fb8d9,_0x123777);}else{if(_0x592f97[_0xbf0d('0x41')][_0x5a3603]===_0xbf0d('0x83')){_0x210eba['where']('i.'+_0x5a3603+_0xbf0d('0x84'));}else{_0x210eba[_0xbf0d('0x4c')]('i.'+_0x5a3603+'\x20=\x20?',_0x592f97[_0xbf0d('0x41')][_0x5a3603]);}}});}if(_0x592f97[_0xbf0d('0x41')]['read']){if(_0x592f97[_0xbf0d('0x41')][_0xbf0d('0x85')]==0x1){_0x210eba['having'](_0xbf0d('0x86'));}else{_0x210eba[_0xbf0d('0x68')]('`unreadMessages`\x20>\x200');}}if(_0x592f97[_0xbf0d('0x41')]['tag']){_0x42a2f8=_['isArray'](_0x592f97[_0xbf0d('0x41')][_0xbf0d('0x87')])?_0x592f97[_0xbf0d('0x41')][_0xbf0d('0x87')]:new Array(_0x592f97['query'][_0xbf0d('0x87')]);_0x42a2f8[_0xbf0d('0x32')](function(_0x5b7ffa){_0x42d34c['or']('CONCAT(\x27,\x27,\x20`TagIds`,\x20\x27,\x27)\x20LIKE\x20?','%,'+_0x5b7ffa+',%');});}if(_0x592f97[_0xbf0d('0x41')][_0xbf0d('0x88')]){var _0x1dfd2f=_0x592f97['query'][_0xbf0d('0x88')][_0xbf0d('0x89')]('\x5c','\x5c\x5c')[_0xbf0d('0x89')](/'/g,'\x27\x27');if(qs[_0xbf0d('0x8a')](_0x1dfd2f)){_0x398a4d['or'](_0xbf0d('0x8b'),_0x1dfd2f+'%');}else{_0x398a4d['or'](_0xbf0d('0x8c'),qs['getFullTextValue'](_0x1dfd2f))['or'](_0xbf0d('0x8d'),_0x1dfd2f+'%')['or'](_0xbf0d('0x8e'),_0x1dfd2f+'%');}}}_0x210eba[_0xbf0d('0x4c')](_0x398a4d);_0x210eba[_0xbf0d('0x8f')](_0xbf0d('0x90'));var _0x20c165={'type':db[_0xbf0d('0x91')][_0xbf0d('0x92')][_0xbf0d('0x93')],'raw':!![]};var _0x1547e4=_0x210eba[_0xbf0d('0x94')]();_0x1547e4[_0xbf0d('0x4f')](_0xbf0d('0x90'));_0x1547e4['field'](_0xbf0d('0x95'),'unreadMessages');if(_0x20fea1[_0xbf0d('0x4a')]){_0x20fea1['order'][_0xbf0d('0x32')](function(_0x170cc8){var _0x1ccad5=_0x170cc8[0x0]===_0xbf0d('0x96')?_0x170cc8[0x0]:'i.'+_0x170cc8[0x0];_0x210eba['order'](_0x1ccad5,_0x170cc8[0x1]==='DESC'?![]:!![]);});}if(!_[_0xbf0d('0x7b')](_0x42a2f8)){_0x210eba[_0xbf0d('0x68')](_0x42d34c);_0x1547e4['where']('t.id\x20IN\x20?',_0x42a2f8);}BPromise[_0xbf0d('0x97')]()[_0xbf0d('0x28')](function(){if(!_0x196b05){if(_0x592f97[_0xbf0d('0x41')][_0xbf0d('0x7c')])return;_0x1547e4[_0xbf0d('0x4c')](_0xbf0d('0x98'));_0x210eba[_0xbf0d('0x4c')](_0xbf0d('0x98'));return;}if(_0x592f97[_0xbf0d('0x99')][_0xbf0d('0x9a')]!==_0xbf0d('0x9b'))return;return _0x592f97[_0xbf0d('0x99')][_0xbf0d('0x9c')]({'attributes':['id'],'raw':!![]})[_0xbf0d('0x28')](function(_0x1a89c1){if(_[_0xbf0d('0x7b')](_0x1a89c1)){_0x1547e4['where'](_0xbf0d('0x9d'));_0x210eba[_0xbf0d('0x4c')]('i.OpenchannelAccountId\x20IS\x20NULL');}else{_0x1547e4[_0xbf0d('0x4c')](_0xbf0d('0x7d'),_['map'](_0x1a89c1,'id'));_0x210eba[_0xbf0d('0x4c')](_0xbf0d('0x7d'),_['map'](_0x1a89c1,'id'));}});})[_0xbf0d('0x28')](function(){if(_0x592f97[_0xbf0d('0x99')][_0xbf0d('0x9a')]===_0xbf0d('0x9b')&&!_0x196b05&&!_0x592f97[_0xbf0d('0x41')][_0xbf0d('0x7c')])return[];return db[_0xbf0d('0x9e')][_0xbf0d('0x41')](_0x1547e4[_0xbf0d('0x9f')](),_0x20c165);})[_0xbf0d('0x28')](function(_0x45ec56){_0x267e6f['count']=_0x45ec56[_0xbf0d('0x47')];if(_0x267e6f['count']===0x0)return[];return db[_0xbf0d('0x9e')][_0xbf0d('0x41')](_0x54605f[_0xbf0d('0x9f')](),_0x20c165)[_0xbf0d('0x28')](function(_0x507899){_0x3f29dc=_['keyBy'](_0x507899,'id');_0x20c165=_['merge'](_0x20c165,{'model':db[_0xbf0d('0x3e')],'mapToModel':!![],'raw':!![],'nest':!![]});if(_0x592f97['query']['fields']){_0x20fea1[_0xbf0d('0x45')][_0xbf0d('0x32')](function(_0x3308e9){_0x210eba[_0xbf0d('0x4f')]('i.'+_0x3308e9);});}else{_0x210eba['field'](_0xbf0d('0x95'),_0xbf0d('0xa0'));_0x210eba[_0xbf0d('0x4f')](_0xbf0d('0xa1'),_0xbf0d('0xa2'));_0x210eba[_0xbf0d('0x4f')]('a.mandatoryDisposition',_0xbf0d('0xa3'));_0x210eba[_0xbf0d('0x4f')]('CASE\x20WHEN\x20i.from\x20IS\x20NOT\x20NULL\x20AND\x20i.from\x20<>\x20\x27\x27\x20THEN\x20i.from\x20WHEN\x20(c.firstName\x20IS\x20NOT\x20NULL\x20AND\x20c.firstName\x20<>\x20\x27\x27)\x20OR\x20(c.lastName\x20IS\x20NOT\x20NULL\x20AND\x20c.lastName\x20<>\x20\x27\x27)\x20THEN\x20CONCAT(IFNULL(c.firstName,\x20\x27\x27),\x20\x27\x20\x27,\x20IFNULL(c.lastName,\x20\x27\x27))\x20ELSE\x20\x27Unknown\x27\x20END',_0xbf0d('0x96'));_0x210eba['field'](_0xbf0d('0xa4'));_0x210eba['field'](_0xbf0d('0xa5'),_0xbf0d('0xa6'));_0x210eba[_0xbf0d('0x4f')]('c.lastName',_0xbf0d('0xa7'));_0x210eba[_0xbf0d('0x4f')](_0xbf0d('0xa8'),_0xbf0d('0xa9'));_0x210eba[_0xbf0d('0x4f')](_0xbf0d('0xaa'),'Contact.phone');_0x210eba['field'](_0xbf0d('0xab'),_0xbf0d('0xac'));_0x210eba[_0xbf0d('0x4f')](_0xbf0d('0xad'),'Contact.fax');_0x210eba[_0xbf0d('0x4f')]('o.fullname',_0xbf0d('0xae'));_0x210eba['field'](_0xbf0d('0xaf'),_0xbf0d('0xb0'));_0x210eba[_0xbf0d('0x4f')]('GROUP_CONCAT(DISTINCT\x20t.id)',_0xbf0d('0x34'));}if(_0x20fea1[_0xbf0d('0x1f')])_0x210eba[_0xbf0d('0x1f')](_0x20fea1['limit']);if(_0x20fea1[_0xbf0d('0x22')])_0x210eba[_0xbf0d('0x22')](_0x20fea1[_0xbf0d('0x22')]);return db[_0xbf0d('0x9e')]['query'](_0x210eba[_0xbf0d('0x9f')](),_0x20c165);})[_0xbf0d('0x28')](function(_0xd2e5b5){if(_0xd2e5b5[_0xbf0d('0x47')]>0x0)_0x1accbc[_0xbf0d('0x4c')](_0xbf0d('0xb1'),_[_0xbf0d('0x3d')](_0xd2e5b5,'id'));return db['sequelize'][_0xbf0d('0x41')](_0x1accbc[_0xbf0d('0x9f')](),_0x20c165)[_0xbf0d('0x28')](function(_0x55610b){var _0x4cf6c4=_['groupBy'](_0x55610b,'OpenchannelInteractionId');var _0x46f5d4=[];_0xd2e5b5['forEach'](function(_0x593a9a){_0x46f5d4[_0xbf0d('0x33')](updateOpenchannelInteraction(_0x593a9a,_0x3f29dc,_0x4cf6c4));});return BPromise[_0xbf0d('0xb2')](_0x46f5d4);});});})[_0xbf0d('0x28')](function(_0x1e0986){_0x267e6f[_0xbf0d('0xb3')]=_0x1e0986;return _0x267e6f;})['then'](respondWithFilteredResult(_0x430500,_0x20fea1))['catch'](handleError(_0x430500,null));};exports[_0xbf0d('0xb4')]=function(_0x1a3e15,_0x19eca6){var _0x42a0cb={};if(_0x1a3e15[_0xbf0d('0x41')]['type']&&_0x1a3e15['query']['type']===_0xbf0d('0x55')){_0x42a0cb[_0xbf0d('0x55')]=_0x1a3e15[_0xbf0d('0xb5')]['id'];}else{_0x42a0cb['id']=_0x1a3e15[_0xbf0d('0xb5')]['id'];}var _0x69ba97={'raw':![],'where':_0x42a0cb},_0x2626c8={};_0x2626c8[_0xbf0d('0x40')]=_[_0xbf0d('0x42')](db[_0xbf0d('0x3e')][_0xbf0d('0x3f')]);_0x2626c8[_0xbf0d('0x41')]=_[_0xbf0d('0x42')](_0x1a3e15[_0xbf0d('0x41')]);_0x2626c8[_0xbf0d('0x43')]=_['intersection'](_0x2626c8[_0xbf0d('0x40')],_0x2626c8[_0xbf0d('0x41')]);_0x69ba97['attributes']=_[_0xbf0d('0x44')](_0x2626c8[_0xbf0d('0x40')],qs[_0xbf0d('0x46')](_0x1a3e15[_0xbf0d('0x41')]['fields']));_0x69ba97['attributes']=_0x69ba97['attributes'][_0xbf0d('0x47')]?_0x69ba97[_0xbf0d('0x45')]:_0x2626c8[_0xbf0d('0x40')];if(_0x1a3e15['query'][_0xbf0d('0xb6')]){_0x69ba97[_0xbf0d('0xb7')]=[{'all':!![]}];}_0x69ba97=_[_0xbf0d('0xb8')]({},_0x69ba97,_0x1a3e15[_0xbf0d('0xb9')]);return db[_0xbf0d('0x3e')][_0xbf0d('0x66')](_0x69ba97)['then'](handleEntityNotFound(_0x19eca6,null))[_0xbf0d('0x28')](respondWithResult(_0x19eca6,null))['catch'](handleError(_0x19eca6,null));};exports['create']=function(_0x299a7d,_0x50a8d8){return db[_0xbf0d('0x3e')][_0xbf0d('0xba')](_0x299a7d['body'],{})[_0xbf0d('0x28')](respondWithResult(_0x50a8d8,0xc9))[_0xbf0d('0xbb')](handleError(_0x50a8d8,null));};exports[_0xbf0d('0x27')]=function(_0x1b9450,_0x493e62){if(_0x1b9450[_0xbf0d('0xbc')]['id']){delete _0x1b9450[_0xbf0d('0xbc')]['id'];}return db[_0xbf0d('0x3e')][_0xbf0d('0x66')]({'where':{'id':_0x1b9450[_0xbf0d('0xb5')]['id']}})[_0xbf0d('0x28')](handleEntityNotFound(_0x493e62,null))[_0xbf0d('0x28')](saveUpdates(_0x1b9450[_0xbf0d('0xbc')],null))[_0xbf0d('0x28')](respondWithResult(_0x493e62,null))[_0xbf0d('0xbb')](handleError(_0x493e62,null));};exports[_0xbf0d('0x29')]=function(_0x1a0145,_0x23bb4e){return db[_0xbf0d('0x3e')]['find']({'where':{'id':_0x1a0145[_0xbf0d('0xb5')]['id']}})[_0xbf0d('0x28')](handleEntityNotFound(_0x23bb4e,null))[_0xbf0d('0x28')](removeEntity(_0x23bb4e,null))['catch'](handleError(_0x23bb4e,null));};exports[_0xbf0d('0xbd')]=function(_0x56d4d3,_0x2db920){return db['OpenchannelInteraction'][_0xbf0d('0xbd')]()[_0xbf0d('0x28')](respondWithResult(_0x2db920,null))['catch'](handleError(_0x2db920,null));};exports[_0xbf0d('0xbe')]=function(_0x4d28a4,_0x81a87e,_0x593bf3){return db[_0xbf0d('0xbf')][_0xbf0d('0x66')]({'where':{'id':_0x4d28a4['params']['id']}})[_0xbf0d('0x28')](handleEntityNotFound(_0x81a87e,null))[_0xbf0d('0x28')](function(_0x99c779){if(_0x99c779){return _0x99c779[_0xbf0d('0xbe')](_0x4d28a4[_0xbf0d('0xbc')][_0xbf0d('0xc0')],_['omit'](_0x4d28a4['body'],[_0xbf0d('0xc0'),'id'])||{});}})[_0xbf0d('0x28')](respondWithResult(_0x81a87e,null))[_0xbf0d('0xbb')](handleError(_0x81a87e,null));};exports['getMessages']=function(_0x4d03ec,_0x304e17,_0x31d5c8){var _0x14f46d={'raw':![],'where':{}};var _0x83dbf5={};var _0x33c081={'count':0x0,'rows':[]};return db[_0xbf0d('0x3e')][_0xbf0d('0xc1')]({'where':{'id':_0x4d03ec['params']['id']}})[_0xbf0d('0x28')](handleEntityNotFound(_0x304e17,null))['then'](function(_0x4ae54d){if(_0x4ae54d){_0x83dbf5[_0xbf0d('0x40')]=_[_0xbf0d('0x42')](db['OpenchannelMessage']['rawAttributes']);_0x83dbf5[_0xbf0d('0x41')]=_[_0xbf0d('0x42')](_0x4d03ec[_0xbf0d('0x41')]);_0x83dbf5[_0xbf0d('0x43')]=_[_0xbf0d('0x44')](_0x83dbf5[_0xbf0d('0x40')],_0x83dbf5[_0xbf0d('0x41')]);_0x14f46d[_0xbf0d('0x45')]=_['intersection'](_0x83dbf5[_0xbf0d('0x40')],qs[_0xbf0d('0x46')](_0x4d03ec[_0xbf0d('0x41')][_0xbf0d('0x46')]));_0x14f46d[_0xbf0d('0x45')]=_0x14f46d[_0xbf0d('0x45')][_0xbf0d('0x47')]?_0x14f46d[_0xbf0d('0x45')]:_0x83dbf5['model'];if(!_0x4d03ec[_0xbf0d('0x41')][_0xbf0d('0x48')]('nolimit')){_0x14f46d['limit']=qs[_0xbf0d('0x1f')](_0x4d03ec[_0xbf0d('0x41')][_0xbf0d('0x1f')]);_0x14f46d[_0xbf0d('0x22')]=qs['offset'](_0x4d03ec[_0xbf0d('0x41')][_0xbf0d('0x22')]);}_0x14f46d[_0xbf0d('0x4a')]=qs[_0xbf0d('0x4b')](_0x4d03ec[_0xbf0d('0x41')][_0xbf0d('0x4b')]);_0x14f46d[_0xbf0d('0x4c')]=qs[_0xbf0d('0x43')](_[_0xbf0d('0x4d')](_0x4d03ec[_0xbf0d('0x41')],_0x83dbf5['filters']));_0x14f46d[_0xbf0d('0x4c')][_0xbf0d('0xc2')]=_0x4ae54d['id'];if(_0x4d03ec[_0xbf0d('0x41')]['filter']){_0x14f46d[_0xbf0d('0x4c')]=_[_0xbf0d('0xb8')](_0x14f46d[_0xbf0d('0x4c')],{'$or':_[_0xbf0d('0x3d')](_0x14f46d[_0xbf0d('0x45')],function(_0x45def8){var _0x4a48e3={};_0x4a48e3[_0x45def8]={'$like':'%'+_0x4d03ec['query'][_0xbf0d('0x88')]+'%'};return _0x4a48e3;})});}if(_0x4d03ec[_0xbf0d('0x41')]['$gte']){var _0x467799=_0x4d03ec['query']['$gte']['split'](',');var _0x16d4ac={};_0x16d4ac[_0x467799[0x0]]={'$gte':moment(_0x467799[0x1])[_0xbf0d('0xc3')](_0xbf0d('0xc4'))};_0x14f46d[_0xbf0d('0x4c')]=_[_0xbf0d('0xb8')](_0x14f46d[_0xbf0d('0x4c')],_0x16d4ac);}_0x14f46d=_[_0xbf0d('0xb8')]({},_0x14f46d,_0x4d03ec[_0xbf0d('0xb9')]);return db['OpenchannelMessage'][_0xbf0d('0x21')]({'where':_0x14f46d[_0xbf0d('0x4c')]})['then'](function(_0x3d7e7b){_0x33c081[_0xbf0d('0x21')]=_0x3d7e7b;if(_0x4d03ec[_0xbf0d('0x41')][_0xbf0d('0xb6')]){_0x14f46d['include']=[{'all':!![]}];}return db[_0xbf0d('0xbf')]['findAll'](_0x14f46d);})[_0xbf0d('0x28')](function(_0x5dae71){_0x33c081[_0xbf0d('0xb3')]=_0x5dae71;return _0x33c081;});}})[_0xbf0d('0x28')](respondWithFilteredResult(_0x304e17,_0x14f46d))[_0xbf0d('0xbb')](handleError(_0x304e17,null));};exports[_0xbf0d('0xc5')]=function(_0x2c41ee,_0xea30bc,_0x1c5bdf){return db[_0xbf0d('0x3e')][_0xbf0d('0x66')]({'where':{'id':_0x2c41ee[_0xbf0d('0xb5')]['id']}})[_0xbf0d('0x28')](handleEntityNotFound(_0xea30bc,null))[_0xbf0d('0x28')](function(_0x4cc306){if(_0x4cc306){return _0x4cc306[_0xbf0d('0xc6')](_0x2c41ee[_0xbf0d('0xbc')][_0xbf0d('0xc0')],_[_0xbf0d('0xc7')](_0x2c41ee[_0xbf0d('0xbc')],[_0xbf0d('0xc0'),'id'])||{})[_0xbf0d('0xc8')](function(){return db[_0xbf0d('0xc9')][_0xbf0d('0xca')]({'attributes':['id',_0xbf0d('0x2c'),_0xbf0d('0x50')],'where':{'id':_0x2c41ee['body'][_0xbf0d('0xc0')]}});})[_0xbf0d('0x28')](function(_0x52f012){socket[_0xbf0d('0xcb')](_0xbf0d('0xcc'),{'id':Number(_0x2c41ee[_0xbf0d('0xb5')]['id']),'tags':_0x52f012||[]});return{'id':Number(_0x2c41ee[_0xbf0d('0xb5')]['id']),'tags':_0x52f012||[]};});}})[_0xbf0d('0x28')](respondWithResult(_0xea30bc,null))[_0xbf0d('0xbb')](handleError(_0xea30bc,null));};exports[_0xbf0d('0xcd')]=function(_0x4b2982,_0x5b5f41,_0x2fbb9b){return db[_0xbf0d('0x3e')][_0xbf0d('0x66')]({'where':{'id':_0x4b2982[_0xbf0d('0xb5')]['id']}})['then'](handleEntityNotFound(_0x5b5f41,null))[_0xbf0d('0x28')](function(_0x5c7189){if(_0x5c7189){return _0x5c7189['removeTags'](_0x4b2982['query']['ids']);}})['then'](respondWithStatusCode(_0x5b5f41,null))[_0xbf0d('0xbb')](handleError(_0x5b5f41,null));};exports['download']=function(_0x3b6a48,_0xcdf25a){var _0x1c2250=moment()['unix']()[_0xbf0d('0x9f')]();var _0x52f5b4=path['join'](config['root'],_0xbf0d('0xce'),'files',_0xbf0d('0xcf'));var _0x388bb2=path[_0xbf0d('0xd0')](config[_0xbf0d('0xd1')],'server',_0xbf0d('0xd2'),_0xbf0d('0xd3'));var _0x356c95=path[_0xbf0d('0xd0')](_0x52f5b4,_0x1c2250);var _0xa84f4=util[_0xbf0d('0xc3')](_0xbf0d('0xd4'),_0x3b6a48['params']['id'],_0x1c2250);var _0x3d26f5=path[_0xbf0d('0xd0')](_0x52f5b4,_0xa84f4);var _0xe4a56c=[];_0xe4a56c['push']({'model':db[_0xbf0d('0x75')],'as':'User','attributes':['id',_0xbf0d('0x2f')],'raw':!![]});_0xe4a56c['push']({'model':db[_0xbf0d('0xd5')],'as':_0xbf0d('0x6b'),'attributes':['id',_0xbf0d('0xd6'),_0xbf0d('0xd7')],'raw':!![]});if(_0x3b6a48[_0xbf0d('0x41')][_0xbf0d('0xd3')]){_0xe4a56c[_0xbf0d('0x33')]({'model':db[_0xbf0d('0xd8')],'as':_0xbf0d('0xd8'),'raw':!![]});}var _0x55e98f=[{'model':db['OpenchannelMessage'],'as':_0xbf0d('0xd9'),'attributes':['id','body',_0xbf0d('0x7e'),_0xbf0d('0xda'),_0xbf0d('0xdb'),_0xbf0d('0x85')],'include':_0xe4a56c}];_0x55e98f[_0xbf0d('0x33')]({'model':db[_0xbf0d('0xdc')],'as':_0xbf0d('0xdd'),'attributes':['id',_0xbf0d('0x2c')]});_0x55e98f[_0xbf0d('0x33')]({'model':db[_0xbf0d('0x75')],'as':_0xbf0d('0xde'),'attributes':['id','fullname']});return db[_0xbf0d('0x3e')]['find']({'where':{'id':_0x3b6a48[_0xbf0d('0xb5')]['id']},'include':_0x55e98f})[_0xbf0d('0x28')](handleEntityNotFound(_0xcdf25a,null))['then'](function(_0x4c7293){if(_0x4c7293){var _0x12d505=_0x4c7293['get']({'plain':!![]});fs[_0xbf0d('0xdf')](_0x356c95);var _0x5887de={'channel':'Openchannel','account':_0x12d505['Account'][_0xbf0d('0x2c')],'agent':_0x12d505[_0xbf0d('0xde')]?_0x12d505[_0xbf0d('0xde')]['fullname']:_0xbf0d('0xe0'),'createdAt':moment(_0x12d505[_0xbf0d('0x7e')])['format'](_0xbf0d('0xc4'))[_0xbf0d('0x9f')](),'closedAt':_0x12d505[_0xbf0d('0x3a')]?moment(_0x12d505[_0xbf0d('0xe1')])['format']('YYYY-MM-DD\x20HH:mm:ss')['toString']():'','disposition':_0x12d505[_0xbf0d('0xe2')],'visibility':_0x12d505[_0xbf0d('0xe3')]?_0xbf0d('0xe4'):_0xbf0d('0xe5'),'messages':_(_0x12d505[_0xbf0d('0xd9')])[_0xbf0d('0x88')]({'secret':![]})[_0xbf0d('0x3d')](function(_0x13ac25){if(_0x13ac25['Attachment']){var _0x5f438f=path[_0xbf0d('0xd0')](_0x388bb2,_0x13ac25[_0xbf0d('0xd8')][_0xbf0d('0xe6')]);if(fs[_0xbf0d('0xe7')](_0x5f438f)){fs[_0xbf0d('0xe8')](_0x5f438f)[_0xbf0d('0xe9')](fs[_0xbf0d('0xea')](path[_0xbf0d('0xd0')](_0x356c95,_0x13ac25[_0xbf0d('0xd8')][_0xbf0d('0xe6')])));}}return{'date':moment(_0x13ac25['createdAt'])['format'](_0xbf0d('0xc4'))['toString'](),'sender':_0x13ac25[_0xbf0d('0xda')]===_0xbf0d('0xeb')?_0x13ac25['User']?_0x13ac25[_0xbf0d('0x75')]['fullname']:_0xbf0d('0xec'):_0x13ac25[_0xbf0d('0x6b')][_0xbf0d('0xd6')]+(_0x13ac25[_0xbf0d('0x6b')]['lastName']?'\x20'+_0x13ac25['Contact'][_0xbf0d('0xd7')]:''),'body':_0x13ac25[_0xbf0d('0xd8')]?_0x13ac25['Attachment'][_0xbf0d('0xe6')]:_0x13ac25[_0xbf0d('0xbc')],'direction':_0x13ac25[_0xbf0d('0xda')]===_0xbf0d('0xeb')?'A':'C','secret':_0x13ac25['secret'],'read':_0x13ac25[_0xbf0d('0x85')],'attachment':_0x13ac25[_0xbf0d('0xd8')]};})[_0xbf0d('0x67')]()};return ejs[_0xbf0d('0xed')](path[_0xbf0d('0xd0')](config[_0xbf0d('0xd1')],'server',_0xbf0d('0xee'),_0xbf0d('0xef')),{'interaction':_0x5887de})['then'](function(_0x251c50){var _0x2349b6=path[_0xbf0d('0xd0')](_0x356c95,_0xbf0d('0xf0')+_0x12d505['id']+'-'+_0x1c2250+_0xbf0d('0xf1'));var _0x2cfb8a={'path':_0x2349b6,'channel':_0xbf0d('0xf2'),'interactionId':_0x12d505['id']};return pdf['createPdfFromHTML'](_0x251c50,_0x2cfb8a);})[_0xbf0d('0x28')](function(){return new BPromise(function(_0x1eb9fa,_0x54002){zipdir(_0x356c95,{'saveTo':_0x3d26f5},function(_0x1d83bc,_0x59183f){if(_0x1d83bc)return _0x54002(_0x1d83bc);return _0x1eb9fa(_0x59183f);});})['then'](function(){return new BPromise(function(_0xea2773,_0x4f152c){rimraf(_0x356c95,function(_0x51c675){if(_0x51c675)_0x4f152c(_0x51c675);return _0xea2773();});});})[_0xbf0d('0x28')](function(){return _0xcdf25a['download'](_0x3d26f5,_0xa84f4,function(_0xbbca38){if(_0xbbca38){console[_0xbf0d('0xf3')]('err',_0xbbca38);}else{fs[_0xbf0d('0xf4')](_0x3d26f5);}});});});}else{return _0xcdf25a[_0xbf0d('0x1b')](0xc8);}})[_0xbf0d('0xbb')](handleError(_0xcdf25a,null));};
\ No newline at end of file
+var _0xf6c2=['sqlOperator','conditions','unreadMessages','value','having','Contact','operator','$substring','MATCH\x20(c.firstName,\x20c.lastName,\x20c.phone,\x20c.mobile,\x20c.fax,\x20c.email)\x20AGAINST\x20(?\x20IN\x20BOOLEAN\x20MODE)','getFullTextValue','find','ContactId','buildExpression','type','text','start','Tag','forEach','CONCAT(\x27,\x27,\x20`TagIds`,\x20\x27,\x27)\x20LIKE\x20?','union','CONCAT_WS(\x27\x20\x27,\x20o.name,\x20o.fullname)\x20LIKE\x20?','body','isEmpty','OpenchannelAccountId','where','i.OpenchannelAccountId\x20IN\x20?','concat','parse','$gte','i.createdAt\x20BETWEEN\x20?\x20AND\x20?','null','read','`unreadMessages`\x20=\x200','`unreadMessages`\x20>\x200','tag','filter','replace','i.id\x20LIKE\x20?','MATCH\x20(me.body)\x20AGAINST\x20(?\x20IN\x20BOOLEAN\x20MODE)','CONCAT(c.firstName,\x20\x27\x20\x27,\x20c.lastName)\x20LIKE\x20?','group','i.id','Sequelize','QueryTypes','SUM(me.read\x20=\x200\x20AND\x20me.direction\x20=\x20\x27in\x27)','contactName','DESC','t.id\x20IN\x20?','resolve','i.OpenchannelAccountId\x20IS\x20NOT\x20NULL','role','agent','user','getOpenchannelAccounts','i.OpenchannelAccountId\x20IS\x20NULL','sequelize','toString','keyBy','merge','OpenchannelInteraction','a.key','a.mandatoryDisposition','Account.mandatoryDisposition','c.firstName','Contact.firstName','c.lastName','Contact.lastName','c.email','Contact.email','c.phone','c.mobile','Contact.mobile','Contact.fax','o.fullname','Owner.fullname','GROUP_CONCAT(DISTINCT\x20t.id)','ui.OpenchannelInteractionId\x20IN\x20?','groupBy','OpenchannelInteractionId','all','rows','show','params','includeAll','include','create','describe','addMessage','ids','omit','getMessages','OpenchannelMessage','nolimit','format','YYYY-MM-DD\x20HH:mm:ss','options','findAll','addTags','setTags','emit','removeTags','unix','join','root','server','files','tmp','transcript-%d-%s.zip','User','CmContact','firstName','lastName','attachments','Attachment','Messages','createdAt','secret','Account','Owner','mkdirSync','Openchannel','N.A.','closedAt','disposition','Public','basename','existsSync','createReadStream','createWriteStream','direction','out','renderFile','views','transcript-','.pdf','log','err','unlinkSync','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','bluebird','path','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/export/pdf','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/license/util','redis','localhost','socket.io-emitter','./openchannelInteraction.socket','register','sendStatus','status','undefined','limit','count','offset','set','json','apply','reject','save','update','then','destroy','end','stack','name','Users','fullname','TagIds','Tags','split','push','catch','waiting','talking','answered','unmanaged','total','closed','UserId','map','rawAttributes','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','order','sort','pick','select','field','color','from','tools_tags','u.id','u.fullname','ui.OpenchannelInteractionId','user_has_openchannel_interactions','left_join','u.id\x20=\x20ui.UserId','openchannel_interactions','cm_contacts','users','o.id\x20=\x20i.UserId','openchannel_accounts','a.id\x20=\x20i.OpenchannelAccountId','openchannel_messages','me.OpenchannelInteractionId\x20=\x20i.id','openchannel_interaction_has_tags','it.OpenchannelInteractionId\x20=\x20i.id','expr','search','parseSearch'];(function(_0x512980,_0x401e50){var _0x571f0a=function(_0x456237){while(--_0x456237){_0x512980['push'](_0x512980['shift']());}};_0x571f0a(++_0x401e50);}(_0xf6c2,0x179));var _0x2f6c=function(_0x432682,_0x253044){_0x432682=_0x432682-0x0;var _0x463d05=_0xf6c2[_0x432682];return _0x463d05;};'use strict';var emlformat=require(_0x2f6c('0x0'));var rimraf=require(_0x2f6c('0x1'));var zipdir=require(_0x2f6c('0x2'));var jsonpatch=require(_0x2f6c('0x3'));var rp=require(_0x2f6c('0x4'));var moment=require('moment');var BPromise=require(_0x2f6c('0x5'));var Mustache=require('mustache');var util=require('util');var path=require(_0x2f6c('0x6'));var sox=require(_0x2f6c('0x7'));var csv=require(_0x2f6c('0x8'));var ejs=require(_0x2f6c('0x9'));var fs=require('fs');var fs_extra=require(_0x2f6c('0xa'));var _=require(_0x2f6c('0xb'));var squel=require(_0x2f6c('0xc'));var crypto=require(_0x2f6c('0xd'));var jsforce=require(_0x2f6c('0xe'));var deskjs=require(_0x2f6c('0xf'));var toCsv=require(_0x2f6c('0x8'));var querystring=require(_0x2f6c('0x10'));var Papa=require(_0x2f6c('0x11'));var Redis=require(_0x2f6c('0x12'));var authService=require(_0x2f6c('0x13'));var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var pdf=require(_0x2f6c('0x14'));var hardwareService=require(_0x2f6c('0x15'));var logger=require(_0x2f6c('0x16'))(_0x2f6c('0x17'));var utils=require(_0x2f6c('0x18'));var config=require('../../config/environment');var licenseUtil=require(_0x2f6c('0x19'));var db=require('../../mysqldb')['db'];config[_0x2f6c('0x1a')]=_['defaults'](config[_0x2f6c('0x1a')],{'host':_0x2f6c('0x1b'),'port':0x18eb});var socket=require(_0x2f6c('0x1c'))(new Redis(config[_0x2f6c('0x1a')]));require(_0x2f6c('0x1d'))[_0x2f6c('0x1e')](socket);function respondWithStatusCode(_0x4844e5,_0x470ec8){_0x470ec8=_0x470ec8||0xcc;return function(_0x94ac93){if(_0x94ac93){return _0x4844e5[_0x2f6c('0x1f')](_0x470ec8);}return _0x4844e5[_0x2f6c('0x20')](_0x470ec8)['end']();};}function respondWithResult(_0x191cda,_0x32037c){_0x32037c=_0x32037c||0xc8;return function(_0x1e0c49){if(_0x1e0c49){return _0x191cda[_0x2f6c('0x20')](_0x32037c)['json'](_0x1e0c49);}};}function respondWithFilteredResult(_0x5bbe7b,_0x1080a1){return function(_0x39ad3e){if(_0x39ad3e){var _0x45d5d8=typeof _0x1080a1['offset']===_0x2f6c('0x21')&&typeof _0x1080a1[_0x2f6c('0x22')]===_0x2f6c('0x21');var _0x5a54a6=_0x39ad3e[_0x2f6c('0x23')];var _0x3b3fb4=_0x45d5d8?0x0:_0x1080a1[_0x2f6c('0x24')];var _0x1c1f65=_0x45d5d8?_0x39ad3e[_0x2f6c('0x23')]:_0x1080a1['offset']+_0x1080a1[_0x2f6c('0x22')];var _0x258435;if(_0x1c1f65>=_0x5a54a6){_0x1c1f65=_0x5a54a6;_0x258435=0xc8;}else{_0x258435=0xce;}_0x5bbe7b[_0x2f6c('0x20')](_0x258435);return _0x5bbe7b[_0x2f6c('0x25')]('Content-Range',_0x3b3fb4+'-'+_0x1c1f65+'/'+_0x5a54a6)[_0x2f6c('0x26')](_0x39ad3e);}return null;};}function patchUpdates(_0x1ef5a2){return function(_0x29a17d){try{jsonpatch[_0x2f6c('0x27')](_0x29a17d,_0x1ef5a2,!![]);}catch(_0x1fbf8f){return BPromise[_0x2f6c('0x28')](_0x1fbf8f);}return _0x29a17d[_0x2f6c('0x29')]();};}function saveUpdates(_0xd8eb38,_0x40728b){return function(_0x879dbc){if(_0x879dbc){return _0x879dbc[_0x2f6c('0x2a')](_0xd8eb38)[_0x2f6c('0x2b')](function(_0x693be6){return _0x693be6;});}return null;};}function removeEntity(_0x571c0d,_0x22cbe6){return function(_0x504d46){if(_0x504d46){return _0x504d46[_0x2f6c('0x2c')]()['then'](function(){_0x571c0d[_0x2f6c('0x20')](0xcc)[_0x2f6c('0x2d')]();});}};}function handleEntityNotFound(_0x470f2c,_0x3c88d9){return function(_0x155d88){if(!_0x155d88){_0x470f2c[_0x2f6c('0x1f')](0x194);}return _0x155d88;};}function handleError(_0xeb9ea4,_0x4db94c){_0x4db94c=_0x4db94c||0x1f4;return function(_0x3f0e91){logger['error'](_0x3f0e91[_0x2f6c('0x2e')]);if(_0x3f0e91[_0x2f6c('0x2f')]){delete _0x3f0e91[_0x2f6c('0x2f')];}_0xeb9ea4['status'](_0x4db94c)['send'](_0x3f0e91);};}function getInteractionUsers(_0x5dccf2,_0x4af65b){return new BPromise(function(_0x43d40a,_0x3bed2b){try{if(_0x4af65b[_0x5dccf2['id']]){_0x5dccf2[_0x2f6c('0x30')]=_['map'](_0x4af65b[_0x5dccf2['id']],function(_0x405737){return{'id':_0x405737['id'],'fullname':_0x405737[_0x2f6c('0x31')]};});}}catch(_0x379ecd){_0x3bed2b(_0x379ecd);}_0x43d40a(_0x5dccf2);});}function getInteractionTags(_0x15813e,_0x4635bd){return new BPromise(function(_0x2c28ef,_0x499a82){try{if(_0x15813e[_0x2f6c('0x32')]){_0x15813e[_0x2f6c('0x33')]=[];_0x15813e[_0x2f6c('0x32')][_0x2f6c('0x34')](',')['forEach'](function(_0x171733){_0x15813e[_0x2f6c('0x33')][_0x2f6c('0x35')](_0x4635bd[_0x171733]);});}delete _0x15813e['TagIds'];}catch(_0x362c8f){_0x499a82(_0x362c8f);}_0x2c28ef(_0x15813e);});}function updateOpenchannelInteraction(_0x1717bc,_0x55ac10,_0x1754fc){return new BPromise(function(_0x53d051,_0x3f11bf){return getInteractionUsers(_0x1717bc,_0x1754fc)['then'](function(_0x2b2786){return getInteractionTags(_0x2b2786,_0x55ac10);})['then'](function(_0x1dd28e){return getStateInteraction(_0x1dd28e);})[_0x2f6c('0x2b')](function(_0x3a9448){_0x53d051(_0x3a9448);})[_0x2f6c('0x36')](function(_0x7fd69c){_0x3f11bf(_0x7fd69c);});});}function getStateInteraction(_0x368b2d){return new BPromise(function(_0x368f78){_0x368b2d[_0x2f6c('0x37')]=0x0;_0x368b2d[_0x2f6c('0x38')]=0x0;_0x368b2d[_0x2f6c('0x39')]=0x0;_0x368b2d[_0x2f6c('0x3a')]=0x0;_0x368b2d[_0x2f6c('0x3b')]=0x0;if(!_0x368b2d[_0x2f6c('0x3c')]&&!_0x368b2d[_0x2f6c('0x3d')]){_0x368b2d[_0x2f6c('0x37')]+=0x1;}if(!_0x368b2d[_0x2f6c('0x3c')]&&_0x368b2d[_0x2f6c('0x3d')]){_0x368b2d[_0x2f6c('0x38')]+=0x1;if(_0x368b2d[_0x2f6c('0x37')]){_0x368b2d[_0x2f6c('0x37')]-=0x1;}}if(_0x368b2d[_0x2f6c('0x3c')]&&_0x368b2d[_0x2f6c('0x3d')]){_0x368b2d['answered']+=0x1;if(_0x368b2d[_0x2f6c('0x38')]){_0x368b2d['talking']-=0x1;}}if(_0x368b2d[_0x2f6c('0x3c')]&&!_0x368b2d[_0x2f6c('0x3d')]){_0x368b2d[_0x2f6c('0x3a')]+=0x1;if(_0x368b2d[_0x2f6c('0x37')]){_0x368b2d[_0x2f6c('0x37')]-=0x1;}}_0x368b2d[_0x2f6c('0x3b')]+=0x1;_0x368f78(_0x368b2d);});}exports['index']=function(_0x1b87a6,_0x2cceb8){var _0x4df462={},_0x4616cc={},_0x5e7a8a={'count':0x0,'rows':[]};var _0x3106bc=_[_0x2f6c('0x3e')](db['OpenchannelInteraction'][_0x2f6c('0x3f')],function(_0x214625){return{'name':_0x214625['fieldName'],'type':_0x214625['type'][_0x2f6c('0x40')]};});_0x4616cc[_0x2f6c('0x41')]=_['map'](_0x3106bc,_0x2f6c('0x2f'));_0x4616cc[_0x2f6c('0x42')]=_[_0x2f6c('0x43')](_0x1b87a6[_0x2f6c('0x42')]);_0x4616cc[_0x2f6c('0x44')]=_[_0x2f6c('0x45')](_0x4616cc[_0x2f6c('0x41')],_0x4616cc['query']);_0x4df462[_0x2f6c('0x46')]=_[_0x2f6c('0x45')](_0x4616cc[_0x2f6c('0x41')],qs[_0x2f6c('0x47')](_0x1b87a6[_0x2f6c('0x42')][_0x2f6c('0x47')]));_0x4df462[_0x2f6c('0x46')]=_0x4df462[_0x2f6c('0x46')][_0x2f6c('0x48')]?_0x4df462[_0x2f6c('0x46')]:_0x4616cc[_0x2f6c('0x41')];if(!_0x1b87a6[_0x2f6c('0x42')][_0x2f6c('0x49')]('nolimit')){_0x4df462[_0x2f6c('0x22')]=qs[_0x2f6c('0x22')](_0x1b87a6[_0x2f6c('0x42')]['limit']);_0x4df462[_0x2f6c('0x24')]=qs[_0x2f6c('0x24')](_0x1b87a6[_0x2f6c('0x42')][_0x2f6c('0x24')]);}_0x4df462[_0x2f6c('0x4a')]=qs[_0x2f6c('0x4b')](_0x1b87a6[_0x2f6c('0x42')][_0x2f6c('0x4b')]);_0x4df462['where']=qs['filters'](_[_0x2f6c('0x4c')](_0x1b87a6[_0x2f6c('0x42')],_0x4616cc[_0x2f6c('0x44')]),_0x3106bc);var _0x4512dd=[];var _0x3a4e2d=squel[_0x2f6c('0x4d')]()['field']('id')[_0x2f6c('0x4e')](_0x2f6c('0x2f'))[_0x2f6c('0x4e')](_0x2f6c('0x4f'))[_0x2f6c('0x50')](_0x2f6c('0x51'));var _0x4c2809=squel['select']()[_0x2f6c('0x4e')](_0x2f6c('0x52'))[_0x2f6c('0x4e')](_0x2f6c('0x53'))[_0x2f6c('0x4e')](_0x2f6c('0x54'))[_0x2f6c('0x50')](_0x2f6c('0x55'),'ui')[_0x2f6c('0x56')]('users','u',_0x2f6c('0x57'));var _0xafa840=squel[_0x2f6c('0x4d')]()[_0x2f6c('0x50')](_0x2f6c('0x58'),'i')[_0x2f6c('0x56')](_0x2f6c('0x59'),'c','c.id\x20=\x20i.ContactId\x20AND\x20c.deletedAt\x20IS\x20NULL')[_0x2f6c('0x56')](_0x2f6c('0x5a'),'o',_0x2f6c('0x5b'))[_0x2f6c('0x56')](_0x2f6c('0x5c'),'a',_0x2f6c('0x5d'))[_0x2f6c('0x56')](_0x2f6c('0x5e'),'me',_0x2f6c('0x5f'))[_0x2f6c('0x56')](_0x2f6c('0x60'),'it',_0x2f6c('0x61'))[_0x2f6c('0x56')]('tools_tags','t','t.id\x20=\x20it.TagId');var _0x401f42=squel['expr']();var _0x5bea1d=[];var _0x6bbde3=squel[_0x2f6c('0x62')]();var _0x91aca;if(_0x1b87a6[_0x2f6c('0x42')][_0x2f6c('0x63')]){_0x91aca=as[_0x2f6c('0x64')](_0x1b87a6[_0x2f6c('0x42')][_0x2f6c('0x63')]);var _0x4d3539=_0x91aca[_0x2f6c('0x65')];for(var _0x1d1976=0x0;_0x1d1976<_0x91aca[_0x2f6c('0x66')][_0x2f6c('0x48')];_0x1d1976++){var _0x2ebcad=_0x91aca['conditions'][_0x1d1976];var _0x10f813='i';var _0x13effa=_['find'](_0x3106bc,[_0x2f6c('0x2f'),_0x2ebcad[_0x2f6c('0x4e')]]);if(!_0x13effa){switch(_0x2ebcad['field']){case _0x2f6c('0x67'):if(_0x2ebcad[_0x2f6c('0x68')]==0x1){_0xafa840[_0x2f6c('0x69')]('`'+_0x2ebcad[_0x2f6c('0x4e')]+'`\x20=\x200');}else{_0xafa840[_0x2f6c('0x69')]('`'+_0x2ebcad['field']+'`\x20>\x200');}break;case _0x2f6c('0x6a'):if(_0x2ebcad[_0x2f6c('0x6b')]===_0x2f6c('0x6c')){if(_0x2ebcad[_0x2f6c('0x68')][_0x2f6c('0x34')]('\x20')[_0x2f6c('0x48')]>0x1){_0x401f42[_0x4d3539](_0x2f6c('0x6d'),qs[_0x2f6c('0x6e')](_0x2ebcad[_0x2f6c('0x68')]),null);}else{var _0xe0007e='%'+_0x2ebcad[_0x2f6c('0x68')]+'%';_0x401f42[_0x4d3539]('c.firstName\x20LIKE\x20?\x20OR\x20c.lastName\x20LIKE\x20?\x20OR\x20c.email\x20LIKE\x20?',_0xe0007e,_0xe0007e,_0xe0007e);}}else{_0x13effa=_[_0x2f6c('0x6f')](_0x3106bc,[_0x2f6c('0x2f'),_0x2f6c('0x70')]);_0x2ebcad[_0x2f6c('0x4e')]=_0x2f6c('0x70');_0x4e9c39=as[_0x2f6c('0x71')](_0x10f813,_0x13effa[_0x2f6c('0x72')],_0x2ebcad);_0x401f42[_0x4d3539](_0x4e9c39[_0x2f6c('0x73')],_0x4e9c39[_0x2f6c('0x68')][_0x2f6c('0x74')],_0x4e9c39[_0x2f6c('0x68')]['end']);}break;case _0x2f6c('0x75'):var _0x1afd16=_0x2ebcad[_0x2f6c('0x68')][_0x2f6c('0x34')](',')['map'](function(_0xcf50b3){return Number(_0xcf50b3);});_0x1afd16[_0x2f6c('0x76')](function(_0x5d4662){_0x6bbde3['or'](_0x2f6c('0x77'),'%,'+_0x5d4662+',%');});_0x5bea1d=_[_0x2f6c('0x78')](_0x5bea1d,_0x1afd16);break;case'User':if(_0x2ebcad['operator']===_0x2f6c('0x6c')){_0x401f42[_0x4d3539](_0x2f6c('0x79'),'%'+_0x2ebcad[_0x2f6c('0x68')]+'%',null);}else{_0x13effa=_[_0x2f6c('0x6f')](_0x3106bc,[_0x2f6c('0x2f'),'UserId']);_0x2ebcad['field']=_0x2f6c('0x3d');_0x4e9c39=as[_0x2f6c('0x71')](_0x10f813,_0x13effa[_0x2f6c('0x72')],_0x2ebcad);_0x401f42[_0x4d3539](_0x4e9c39[_0x2f6c('0x73')],_0x4e9c39[_0x2f6c('0x68')][_0x2f6c('0x74')],_0x4e9c39['value'][_0x2f6c('0x2d')]);}break;case _0x2f6c('0x7a'):_0x4e9c39=as['buildExpression']('me',null,_0x2ebcad);_0x401f42[_0x4d3539](_0x4e9c39[_0x2f6c('0x73')],_0x4e9c39[_0x2f6c('0x68')]['start'],_0x4e9c39[_0x2f6c('0x68')][_0x2f6c('0x2d')]);break;}}else{var _0x4e9c39=as[_0x2f6c('0x71')](_0x10f813,_0x13effa[_0x2f6c('0x72')],_0x2ebcad);_0x401f42[_0x4d3539](_0x4e9c39[_0x2f6c('0x73')],_0x4e9c39['value'][_0x2f6c('0x74')],_0x4e9c39['value']['end']);}}}else{var _0x48be44=_(_0x1b87a6[_0x2f6c('0x42')])[_0x2f6c('0x43')]()[_0x2f6c('0x3e')](function(_0x28fd95){return _['some'](_0x3106bc,[_0x2f6c('0x2f'),_0x28fd95])?_0x28fd95:undefined;})['compact']()[_0x2f6c('0x68')]();if(!_[_0x2f6c('0x7b')](_0x48be44)){_0x48be44[_0x2f6c('0x76')](function(_0x117025){if(_0x117025===_0x2f6c('0x7c')){_0xafa840[_0x2f6c('0x7d')](_0x2f6c('0x7e'),[][_0x2f6c('0x7f')](_0x1b87a6[_0x2f6c('0x42')][_0x117025]));}else if(_0x117025==='createdAt'){var _0x251d96=JSON[_0x2f6c('0x80')](_0x1b87a6[_0x2f6c('0x42')][_0x117025])[_0x2f6c('0x81')];var _0x53d370=JSON[_0x2f6c('0x80')](_0x1b87a6[_0x2f6c('0x42')][_0x117025])['$lte'];_0xafa840[_0x2f6c('0x7d')](_0x2f6c('0x82'),_0x251d96,_0x53d370);}else{if(_0x1b87a6[_0x2f6c('0x42')][_0x117025]===_0x2f6c('0x83')){_0xafa840[_0x2f6c('0x7d')]('i.'+_0x117025+'\x20IS\x20NULL');}else{_0xafa840['where']('i.'+_0x117025+'\x20=\x20?',_0x1b87a6['query'][_0x117025]);}}});}if(_0x1b87a6['query'][_0x2f6c('0x84')]){if(_0x1b87a6[_0x2f6c('0x42')][_0x2f6c('0x84')]==0x1){_0xafa840[_0x2f6c('0x69')](_0x2f6c('0x85'));}else{_0xafa840[_0x2f6c('0x69')](_0x2f6c('0x86'));}}if(_0x1b87a6[_0x2f6c('0x42')][_0x2f6c('0x87')]){_0x5bea1d=_['isArray'](_0x1b87a6[_0x2f6c('0x42')][_0x2f6c('0x87')])?_0x1b87a6[_0x2f6c('0x42')][_0x2f6c('0x87')]:new Array(_0x1b87a6[_0x2f6c('0x42')][_0x2f6c('0x87')]);_0x5bea1d[_0x2f6c('0x76')](function(_0x336971){_0x6bbde3['or'](_0x2f6c('0x77'),'%,'+_0x336971+',%');});}if(_0x1b87a6[_0x2f6c('0x42')][_0x2f6c('0x88')]){var _0x2e3227=_0x1b87a6[_0x2f6c('0x42')]['filter'][_0x2f6c('0x89')]('\x5c','\x5c\x5c')[_0x2f6c('0x89')](/'/g,'\x27\x27');if(qs['isNumeric'](_0x2e3227)){_0x401f42['or'](_0x2f6c('0x8a'),_0x2e3227+'%');}else{_0x401f42['or'](_0x2f6c('0x8b'),qs[_0x2f6c('0x6e')](_0x2e3227))['or']('i.from\x20LIKE\x20?',_0x2e3227+'%')['or'](_0x2f6c('0x8c'),_0x2e3227+'%');}}}_0xafa840[_0x2f6c('0x7d')](_0x401f42);_0xafa840[_0x2f6c('0x8d')](_0x2f6c('0x8e'));var _0x3fa5bb={'type':db[_0x2f6c('0x8f')][_0x2f6c('0x90')]['SELECT'],'raw':!![]};var _0x3426b4=_0xafa840['clone']();_0x3426b4[_0x2f6c('0x4e')]('i.id');_0x3426b4[_0x2f6c('0x4e')](_0x2f6c('0x91'),_0x2f6c('0x67'));if(_0x4df462[_0x2f6c('0x4a')]){_0x4df462[_0x2f6c('0x4a')][_0x2f6c('0x76')](function(_0x2f92ed){var _0x2d30fc=_0x2f92ed[0x0]===_0x2f6c('0x92')?_0x2f92ed[0x0]:'i.'+_0x2f92ed[0x0];_0xafa840[_0x2f6c('0x4a')](_0x2d30fc,_0x2f92ed[0x1]===_0x2f6c('0x93')?![]:!![]);});}if(!_[_0x2f6c('0x7b')](_0x5bea1d)){_0xafa840[_0x2f6c('0x69')](_0x6bbde3);_0x3426b4['where'](_0x2f6c('0x94'),_0x5bea1d);}BPromise[_0x2f6c('0x95')]()[_0x2f6c('0x2b')](function(){if(!_0x91aca){if(_0x1b87a6['query'][_0x2f6c('0x7c')])return;_0x3426b4[_0x2f6c('0x7d')](_0x2f6c('0x96'));_0xafa840['where']('i.OpenchannelAccountId\x20IS\x20NOT\x20NULL');return;}if(_0x1b87a6['user'][_0x2f6c('0x97')]!==_0x2f6c('0x98'))return;return _0x1b87a6[_0x2f6c('0x99')][_0x2f6c('0x9a')]({'attributes':['id'],'raw':!![]})['then'](function(_0x33eb79){if(_[_0x2f6c('0x7b')](_0x33eb79)){_0x3426b4[_0x2f6c('0x7d')](_0x2f6c('0x9b'));_0xafa840[_0x2f6c('0x7d')](_0x2f6c('0x9b'));}else{_0x3426b4[_0x2f6c('0x7d')]('i.OpenchannelAccountId\x20IN\x20?',_['map'](_0x33eb79,'id'));_0xafa840['where'](_0x2f6c('0x7e'),_['map'](_0x33eb79,'id'));}});})[_0x2f6c('0x2b')](function(){if(_0x1b87a6[_0x2f6c('0x99')][_0x2f6c('0x97')]===_0x2f6c('0x98')&&!_0x91aca&&!_0x1b87a6['query'][_0x2f6c('0x7c')])return[];return db[_0x2f6c('0x9c')]['query'](_0x3426b4['toString'](),_0x3fa5bb);})[_0x2f6c('0x2b')](function(_0x16dfdb){_0x5e7a8a[_0x2f6c('0x23')]=_0x16dfdb[_0x2f6c('0x48')];if(_0x5e7a8a[_0x2f6c('0x23')]===0x0)return[];return db[_0x2f6c('0x9c')][_0x2f6c('0x42')](_0x3a4e2d[_0x2f6c('0x9d')](),_0x3fa5bb)[_0x2f6c('0x2b')](function(_0x13c021){_0x4512dd=_[_0x2f6c('0x9e')](_0x13c021,'id');_0x3fa5bb=_[_0x2f6c('0x9f')](_0x3fa5bb,{'model':db[_0x2f6c('0xa0')],'mapToModel':!![],'raw':!![],'nest':!![]});if(_0x1b87a6[_0x2f6c('0x42')][_0x2f6c('0x47')]){_0x4df462['attributes'][_0x2f6c('0x76')](function(_0x195f12){_0xafa840[_0x2f6c('0x4e')]('i.'+_0x195f12);});}else{_0xafa840['field'](_0x2f6c('0x91'),_0x2f6c('0x67'));_0xafa840[_0x2f6c('0x4e')](_0x2f6c('0xa1'),'Account.key');_0xafa840[_0x2f6c('0x4e')](_0x2f6c('0xa2'),_0x2f6c('0xa3'));_0xafa840[_0x2f6c('0x4e')]('CASE\x20WHEN\x20i.from\x20IS\x20NOT\x20NULL\x20AND\x20i.from\x20<>\x20\x27\x27\x20THEN\x20i.from\x20WHEN\x20(c.firstName\x20IS\x20NOT\x20NULL\x20AND\x20c.firstName\x20<>\x20\x27\x27)\x20OR\x20(c.lastName\x20IS\x20NOT\x20NULL\x20AND\x20c.lastName\x20<>\x20\x27\x27)\x20THEN\x20CONCAT(IFNULL(c.firstName,\x20\x27\x27),\x20\x27\x20\x27,\x20IFNULL(c.lastName,\x20\x27\x27))\x20ELSE\x20\x27Unknown\x27\x20END',_0x2f6c('0x92'));_0xafa840['field']('i.*');_0xafa840['field'](_0x2f6c('0xa4'),_0x2f6c('0xa5'));_0xafa840['field'](_0x2f6c('0xa6'),_0x2f6c('0xa7'));_0xafa840[_0x2f6c('0x4e')](_0x2f6c('0xa8'),_0x2f6c('0xa9'));_0xafa840['field'](_0x2f6c('0xaa'),'Contact.phone');_0xafa840[_0x2f6c('0x4e')](_0x2f6c('0xab'),_0x2f6c('0xac'));_0xafa840[_0x2f6c('0x4e')]('c.fax',_0x2f6c('0xad'));_0xafa840['field'](_0x2f6c('0xae'),_0x2f6c('0xaf'));_0xafa840[_0x2f6c('0x4e')]('o.internal','Owner.internal');_0xafa840[_0x2f6c('0x4e')](_0x2f6c('0xb0'),'TagIds');}if(_0x4df462[_0x2f6c('0x22')])_0xafa840[_0x2f6c('0x22')](_0x4df462[_0x2f6c('0x22')]);if(_0x4df462[_0x2f6c('0x24')])_0xafa840[_0x2f6c('0x24')](_0x4df462['offset']);return db[_0x2f6c('0x9c')][_0x2f6c('0x42')](_0xafa840[_0x2f6c('0x9d')](),_0x3fa5bb);})['then'](function(_0x5ce185){if(_0x5ce185[_0x2f6c('0x48')]>0x0)_0x4c2809[_0x2f6c('0x7d')](_0x2f6c('0xb1'),_[_0x2f6c('0x3e')](_0x5ce185,'id'));return db['sequelize'][_0x2f6c('0x42')](_0x4c2809['toString'](),_0x3fa5bb)[_0x2f6c('0x2b')](function(_0x50435b){var _0xafaa9e=_[_0x2f6c('0xb2')](_0x50435b,_0x2f6c('0xb3'));var _0x137a4e=[];_0x5ce185['forEach'](function(_0x50d7c4){_0x137a4e[_0x2f6c('0x35')](updateOpenchannelInteraction(_0x50d7c4,_0x4512dd,_0xafaa9e));});return BPromise[_0x2f6c('0xb4')](_0x137a4e);});});})[_0x2f6c('0x2b')](function(_0x3261a5){_0x5e7a8a[_0x2f6c('0xb5')]=_0x3261a5;return _0x5e7a8a;})[_0x2f6c('0x2b')](respondWithFilteredResult(_0x2cceb8,_0x4df462))[_0x2f6c('0x36')](handleError(_0x2cceb8,null));};exports[_0x2f6c('0xb6')]=function(_0xd98583,_0x53f476){var _0x53ecbd={};if(_0xd98583[_0x2f6c('0x42')][_0x2f6c('0x72')]&&_0xd98583[_0x2f6c('0x42')]['type']===_0x2f6c('0x50')){_0x53ecbd[_0x2f6c('0x50')]=_0xd98583[_0x2f6c('0xb7')]['id'];}else{_0x53ecbd['id']=_0xd98583['params']['id'];}var _0x10c415={'raw':![],'where':_0x53ecbd},_0x4c77d3={};_0x4c77d3['model']=_[_0x2f6c('0x43')](db[_0x2f6c('0xa0')][_0x2f6c('0x3f')]);_0x4c77d3[_0x2f6c('0x42')]=_[_0x2f6c('0x43')](_0xd98583[_0x2f6c('0x42')]);_0x4c77d3[_0x2f6c('0x44')]=_[_0x2f6c('0x45')](_0x4c77d3[_0x2f6c('0x41')],_0x4c77d3[_0x2f6c('0x42')]);_0x10c415[_0x2f6c('0x46')]=_['intersection'](_0x4c77d3[_0x2f6c('0x41')],qs['fields'](_0xd98583[_0x2f6c('0x42')]['fields']));_0x10c415[_0x2f6c('0x46')]=_0x10c415[_0x2f6c('0x46')][_0x2f6c('0x48')]?_0x10c415[_0x2f6c('0x46')]:_0x4c77d3[_0x2f6c('0x41')];if(_0xd98583[_0x2f6c('0x42')][_0x2f6c('0xb8')]){_0x10c415[_0x2f6c('0xb9')]=[{'all':!![]}];}_0x10c415=_[_0x2f6c('0x9f')]({},_0x10c415,_0xd98583['options']);return db['OpenchannelInteraction']['find'](_0x10c415)[_0x2f6c('0x2b')](handleEntityNotFound(_0x53f476,null))[_0x2f6c('0x2b')](respondWithResult(_0x53f476,null))[_0x2f6c('0x36')](handleError(_0x53f476,null));};exports[_0x2f6c('0xba')]=function(_0x5c2725,_0x1fb5bc){return db['OpenchannelInteraction']['create'](_0x5c2725['body'],{})[_0x2f6c('0x2b')](respondWithResult(_0x1fb5bc,0xc9))['catch'](handleError(_0x1fb5bc,null));};exports[_0x2f6c('0x2a')]=function(_0xbf0431,_0x3a2be2){if(_0xbf0431['body']['id']){delete _0xbf0431[_0x2f6c('0x7a')]['id'];}return db[_0x2f6c('0xa0')][_0x2f6c('0x6f')]({'where':{'id':_0xbf0431[_0x2f6c('0xb7')]['id']}})['then'](handleEntityNotFound(_0x3a2be2,null))[_0x2f6c('0x2b')](saveUpdates(_0xbf0431['body'],null))[_0x2f6c('0x2b')](respondWithResult(_0x3a2be2,null))['catch'](handleError(_0x3a2be2,null));};exports[_0x2f6c('0x2c')]=function(_0x15228f,_0x3c0635){return db[_0x2f6c('0xa0')][_0x2f6c('0x6f')]({'where':{'id':_0x15228f[_0x2f6c('0xb7')]['id']}})[_0x2f6c('0x2b')](handleEntityNotFound(_0x3c0635,null))[_0x2f6c('0x2b')](removeEntity(_0x3c0635,null))[_0x2f6c('0x36')](handleError(_0x3c0635,null));};exports[_0x2f6c('0xbb')]=function(_0x4c90da,_0x2aac22){return db[_0x2f6c('0xa0')][_0x2f6c('0xbb')]()[_0x2f6c('0x2b')](respondWithResult(_0x2aac22,null))[_0x2f6c('0x36')](handleError(_0x2aac22,null));};exports[_0x2f6c('0xbc')]=function(_0x503e26,_0x12e48e,_0xd3d66b){return db['OpenchannelMessage'][_0x2f6c('0x6f')]({'where':{'id':_0x503e26[_0x2f6c('0xb7')]['id']}})['then'](handleEntityNotFound(_0x12e48e,null))[_0x2f6c('0x2b')](function(_0x3defcc){if(_0x3defcc){return _0x3defcc['addMessage'](_0x503e26[_0x2f6c('0x7a')][_0x2f6c('0xbd')],_[_0x2f6c('0xbe')](_0x503e26[_0x2f6c('0x7a')],[_0x2f6c('0xbd'),'id'])||{});}})[_0x2f6c('0x2b')](respondWithResult(_0x12e48e,null))[_0x2f6c('0x36')](handleError(_0x12e48e,null));};exports[_0x2f6c('0xbf')]=function(_0x38e4a0,_0x578ad9,_0x514e5e){var _0x59d11f={'raw':![],'where':{}};var _0x43831e={};var _0xf2cb76={'count':0x0,'rows':[]};return db['OpenchannelInteraction']['findOne']({'where':{'id':_0x38e4a0[_0x2f6c('0xb7')]['id']}})[_0x2f6c('0x2b')](handleEntityNotFound(_0x578ad9,null))[_0x2f6c('0x2b')](function(_0xc5bcf){if(_0xc5bcf){_0x43831e[_0x2f6c('0x41')]=_[_0x2f6c('0x43')](db[_0x2f6c('0xc0')][_0x2f6c('0x3f')]);_0x43831e[_0x2f6c('0x42')]=_['keys'](_0x38e4a0[_0x2f6c('0x42')]);_0x43831e[_0x2f6c('0x44')]=_[_0x2f6c('0x45')](_0x43831e[_0x2f6c('0x41')],_0x43831e[_0x2f6c('0x42')]);_0x59d11f[_0x2f6c('0x46')]=_[_0x2f6c('0x45')](_0x43831e['model'],qs[_0x2f6c('0x47')](_0x38e4a0[_0x2f6c('0x42')][_0x2f6c('0x47')]));_0x59d11f[_0x2f6c('0x46')]=_0x59d11f[_0x2f6c('0x46')][_0x2f6c('0x48')]?_0x59d11f[_0x2f6c('0x46')]:_0x43831e[_0x2f6c('0x41')];if(!_0x38e4a0[_0x2f6c('0x42')]['hasOwnProperty'](_0x2f6c('0xc1'))){_0x59d11f['limit']=qs[_0x2f6c('0x22')](_0x38e4a0['query'][_0x2f6c('0x22')]);_0x59d11f[_0x2f6c('0x24')]=qs[_0x2f6c('0x24')](_0x38e4a0[_0x2f6c('0x42')][_0x2f6c('0x24')]);}_0x59d11f['order']=qs[_0x2f6c('0x4b')](_0x38e4a0[_0x2f6c('0x42')][_0x2f6c('0x4b')]);_0x59d11f[_0x2f6c('0x7d')]=qs['filters'](_[_0x2f6c('0x4c')](_0x38e4a0[_0x2f6c('0x42')],_0x43831e[_0x2f6c('0x44')]));_0x59d11f[_0x2f6c('0x7d')][_0x2f6c('0xb3')]=_0xc5bcf['id'];if(_0x38e4a0[_0x2f6c('0x42')][_0x2f6c('0x88')]){_0x59d11f[_0x2f6c('0x7d')]=_['merge'](_0x59d11f[_0x2f6c('0x7d')],{'$or':_[_0x2f6c('0x3e')](_0x59d11f[_0x2f6c('0x46')],function(_0x37da11){var _0x46dd2b={};_0x46dd2b[_0x37da11]={'$like':'%'+_0x38e4a0['query'][_0x2f6c('0x88')]+'%'};return _0x46dd2b;})});}if(_0x38e4a0[_0x2f6c('0x42')][_0x2f6c('0x81')]){var _0x44caeb=_0x38e4a0[_0x2f6c('0x42')]['$gte']['split'](',');var _0x578516={};_0x578516[_0x44caeb[0x0]]={'$gte':moment(_0x44caeb[0x1])[_0x2f6c('0xc2')](_0x2f6c('0xc3'))};_0x59d11f[_0x2f6c('0x7d')]=_[_0x2f6c('0x9f')](_0x59d11f[_0x2f6c('0x7d')],_0x578516);}_0x59d11f=_['merge']({},_0x59d11f,_0x38e4a0[_0x2f6c('0xc4')]);return db[_0x2f6c('0xc0')][_0x2f6c('0x23')]({'where':_0x59d11f[_0x2f6c('0x7d')]})[_0x2f6c('0x2b')](function(_0x485851){_0xf2cb76[_0x2f6c('0x23')]=_0x485851;if(_0x38e4a0[_0x2f6c('0x42')][_0x2f6c('0xb8')]){_0x59d11f[_0x2f6c('0xb9')]=[{'all':!![]}];}return db[_0x2f6c('0xc0')][_0x2f6c('0xc5')](_0x59d11f);})[_0x2f6c('0x2b')](function(_0xcb2d7b){_0xf2cb76['rows']=_0xcb2d7b;return _0xf2cb76;});}})[_0x2f6c('0x2b')](respondWithFilteredResult(_0x578ad9,_0x59d11f))[_0x2f6c('0x36')](handleError(_0x578ad9,null));};exports[_0x2f6c('0xc6')]=function(_0x19eb14,_0x11f390,_0x3fd2f0){return db[_0x2f6c('0xa0')][_0x2f6c('0x6f')]({'where':{'id':_0x19eb14[_0x2f6c('0xb7')]['id']}})[_0x2f6c('0x2b')](handleEntityNotFound(_0x11f390,null))[_0x2f6c('0x2b')](function(_0x399531){if(_0x399531){return _0x399531[_0x2f6c('0xc7')](_0x19eb14[_0x2f6c('0x7a')][_0x2f6c('0xbd')],_[_0x2f6c('0xbe')](_0x19eb14[_0x2f6c('0x7a')],[_0x2f6c('0xbd'),'id'])||{})['spread'](function(){return db[_0x2f6c('0x75')][_0x2f6c('0xc5')]({'attributes':['id','name',_0x2f6c('0x4f')],'where':{'id':_0x19eb14[_0x2f6c('0x7a')]['ids']}});})[_0x2f6c('0x2b')](function(_0x473191){socket[_0x2f6c('0xc8')]('openchannelInteractionTags:save',{'id':Number(_0x19eb14[_0x2f6c('0xb7')]['id']),'tags':_0x473191||[]});return{'id':Number(_0x19eb14[_0x2f6c('0xb7')]['id']),'tags':_0x473191||[]};});}})['then'](respondWithResult(_0x11f390,null))[_0x2f6c('0x36')](handleError(_0x11f390,null));};exports[_0x2f6c('0xc9')]=function(_0x331985,_0x4ab55c,_0xf5c450){return db[_0x2f6c('0xa0')][_0x2f6c('0x6f')]({'where':{'id':_0x331985[_0x2f6c('0xb7')]['id']}})[_0x2f6c('0x2b')](handleEntityNotFound(_0x4ab55c,null))['then'](function(_0x36acf4){if(_0x36acf4){return _0x36acf4['removeTags'](_0x331985[_0x2f6c('0x42')][_0x2f6c('0xbd')]);}})[_0x2f6c('0x2b')](respondWithStatusCode(_0x4ab55c,null))[_0x2f6c('0x36')](handleError(_0x4ab55c,null));};exports['download']=function(_0x23d2c3,_0x1c9960){var _0x572c77=moment()[_0x2f6c('0xca')]()[_0x2f6c('0x9d')]();var _0x283857=path[_0x2f6c('0xcb')](config[_0x2f6c('0xcc')],_0x2f6c('0xcd'),_0x2f6c('0xce'),_0x2f6c('0xcf'));var _0x3f4099=path[_0x2f6c('0xcb')](config[_0x2f6c('0xcc')],_0x2f6c('0xcd'),'files','attachments');var _0x408d8f=path[_0x2f6c('0xcb')](_0x283857,_0x572c77);var _0x3d4572=util[_0x2f6c('0xc2')](_0x2f6c('0xd0'),_0x23d2c3['params']['id'],_0x572c77);var _0x3c06ed=path[_0x2f6c('0xcb')](_0x283857,_0x3d4572);var _0x3c95d8=[];_0x3c95d8[_0x2f6c('0x35')]({'model':db[_0x2f6c('0xd1')],'as':_0x2f6c('0xd1'),'attributes':['id',_0x2f6c('0x31')],'raw':!![]});_0x3c95d8[_0x2f6c('0x35')]({'model':db[_0x2f6c('0xd2')],'as':_0x2f6c('0x6a'),'attributes':['id',_0x2f6c('0xd3'),_0x2f6c('0xd4')],'raw':!![]});if(_0x23d2c3['query'][_0x2f6c('0xd5')]){_0x3c95d8[_0x2f6c('0x35')]({'model':db[_0x2f6c('0xd6')],'as':_0x2f6c('0xd6'),'raw':!![]});}var _0x491d0a=[{'model':db['OpenchannelMessage'],'as':_0x2f6c('0xd7'),'attributes':['id',_0x2f6c('0x7a'),_0x2f6c('0xd8'),'direction',_0x2f6c('0xd9'),_0x2f6c('0x84')],'include':_0x3c95d8}];_0x491d0a[_0x2f6c('0x35')]({'model':db['OpenchannelAccount'],'as':_0x2f6c('0xda'),'attributes':['id',_0x2f6c('0x2f')]});_0x491d0a[_0x2f6c('0x35')]({'model':db[_0x2f6c('0xd1')],'as':_0x2f6c('0xdb'),'attributes':['id',_0x2f6c('0x31')]});return db[_0x2f6c('0xa0')][_0x2f6c('0x6f')]({'where':{'id':_0x23d2c3[_0x2f6c('0xb7')]['id']},'include':_0x491d0a})[_0x2f6c('0x2b')](handleEntityNotFound(_0x1c9960,null))['then'](function(_0x5c5e74){if(_0x5c5e74){var _0x5d6bc3=_0x5c5e74['get']({'plain':!![]});fs[_0x2f6c('0xdc')](_0x408d8f);var _0x5b6057={'channel':_0x2f6c('0xdd'),'account':_0x5d6bc3[_0x2f6c('0xda')]['name'],'agent':_0x5d6bc3[_0x2f6c('0xdb')]?_0x5d6bc3['Owner'][_0x2f6c('0x31')]:_0x2f6c('0xde'),'createdAt':moment(_0x5d6bc3[_0x2f6c('0xd8')])[_0x2f6c('0xc2')]('YYYY-MM-DD\x20HH:mm:ss')[_0x2f6c('0x9d')](),'closedAt':_0x5d6bc3[_0x2f6c('0x3c')]?moment(_0x5d6bc3[_0x2f6c('0xdf')])[_0x2f6c('0xc2')](_0x2f6c('0xc3'))[_0x2f6c('0x9d')]():'','disposition':_0x5d6bc3[_0x2f6c('0xe0')],'visibility':_0x5d6bc3['threadId']?_0x2f6c('0xe1'):'Private','messages':_(_0x5d6bc3[_0x2f6c('0xd7')])[_0x2f6c('0x88')]({'secret':![]})[_0x2f6c('0x3e')](function(_0x30e3f8){if(_0x30e3f8['Attachment']){var _0x36a6db=path[_0x2f6c('0xcb')](_0x3f4099,_0x30e3f8[_0x2f6c('0xd6')][_0x2f6c('0xe2')]);if(fs[_0x2f6c('0xe3')](_0x36a6db)){fs[_0x2f6c('0xe4')](_0x36a6db)['pipe'](fs[_0x2f6c('0xe5')](path[_0x2f6c('0xcb')](_0x408d8f,_0x30e3f8[_0x2f6c('0xd6')][_0x2f6c('0xe2')])));}}return{'date':moment(_0x30e3f8[_0x2f6c('0xd8')])[_0x2f6c('0xc2')](_0x2f6c('0xc3'))['toString'](),'sender':_0x30e3f8[_0x2f6c('0xe6')]===_0x2f6c('0xe7')?_0x30e3f8[_0x2f6c('0xd1')]?_0x30e3f8[_0x2f6c('0xd1')]['fullname']:'System':_0x30e3f8[_0x2f6c('0x6a')]['firstName']+(_0x30e3f8[_0x2f6c('0x6a')][_0x2f6c('0xd4')]?'\x20'+_0x30e3f8[_0x2f6c('0x6a')][_0x2f6c('0xd4')]:''),'body':_0x30e3f8['Attachment']?_0x30e3f8[_0x2f6c('0xd6')][_0x2f6c('0xe2')]:_0x30e3f8[_0x2f6c('0x7a')],'direction':_0x30e3f8[_0x2f6c('0xe6')]==='out'?'A':'C','secret':_0x30e3f8[_0x2f6c('0xd9')],'read':_0x30e3f8['read'],'attachment':_0x30e3f8[_0x2f6c('0xd6')]};})[_0x2f6c('0x68')]()};return ejs[_0x2f6c('0xe8')](path['join'](config[_0x2f6c('0xcc')],'server',_0x2f6c('0xe9'),'downloadInteraction.ejs'),{'interaction':_0x5b6057})[_0x2f6c('0x2b')](function(_0xdcdd7c){var _0xd9bd76=path[_0x2f6c('0xcb')](_0x408d8f,_0x2f6c('0xea')+_0x5d6bc3['id']+'-'+_0x572c77+_0x2f6c('0xeb'));var _0x660df2={'path':_0xd9bd76,'channel':'Openchannel','interactionId':_0x5d6bc3['id']};return pdf['createPdfFromHTML'](_0xdcdd7c,_0x660df2);})[_0x2f6c('0x2b')](function(){return new BPromise(function(_0x4bd79c,_0x32217b){zipdir(_0x408d8f,{'saveTo':_0x3c06ed},function(_0x422160,_0x37be9d){if(_0x422160)return _0x32217b(_0x422160);return _0x4bd79c(_0x37be9d);});})[_0x2f6c('0x2b')](function(){return new BPromise(function(_0x1e11a8,_0x8125c3){rimraf(_0x408d8f,function(_0x454f98){if(_0x454f98)_0x8125c3(_0x454f98);return _0x1e11a8();});});})[_0x2f6c('0x2b')](function(){return _0x1c9960['download'](_0x3c06ed,_0x3d4572,function(_0x3d7786){if(_0x3d7786){console[_0x2f6c('0xec')](_0x2f6c('0xed'),_0x3d7786);}else{fs[_0x2f6c('0xee')](_0x3c06ed);}});});});}else{return _0x1c9960[_0x2f6c('0x1f')](0xc8);}})[_0x2f6c('0x36')](handleError(_0x1c9960,null));};
\ No newline at end of file