Built motion from commit da617fac.|2.6.6
[motion2.git] / server / api / whatsappInteraction / whatsappInteraction.controller.js
index d91ed9d..4ebb251 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xe9d4=['whatsapp_interaction_has_tags','it.WhatsappInteractionId\x20=\x20i.id','tools_tags','t.id\x20=\x20it.TagId','expr','search','parseSearch','sqlOperator','length','find','having','`\x20=\x200','`\x20>\x200','Contact','value','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','start','Tag','CONCAT(\x27,\x27,\x20`TagIds`,\x20\x27,\x27)\x20LIKE\x20?','User','operator','$substring','UserId','buildExpression','text','WhatsappAccountId','concat','parse','$gte','$lte','i.createdAt\x20BETWEEN\x20?\x20AND\x20?','null','\x20=\x20?','read','`unreadMessages`\x20=\x200','`unreadMessages`\x20>\x200','tag','isArray','filter','replace','isNumeric','i.id\x20LIKE\x20?','i.phone\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','SELECT','SUM(me.read\x20=\x200\x20AND\x20me.direction\x20=\x20\x27in\x27)','contactName','DESC','t.id\x20IN\x20?','journey','i.WhatsappAccountId\x20IS\x20NOT\x20NULL','user','isEmpty','i.WhatsappAccountId\x20IS\x20NULL','role','agent','sequelize','count','keyBy','merge','WhatsappInteraction','a.key','Account.mandatoryDisposition','i.*','Contact.firstName','Contact.lastName','c.email','c.mobile','Contact.mobile','c.fax','o.fullname','Owner.fullname','Owner.internal','toString','ui.WhatsappInteractionId\x20IN\x20?','groupBy','WhatsappInteractionId','all','show','params','includeAll','options','create','body','update','describe','addMessage','ids','getMessages','findOne','format','WhatsappMessage','findAll','rows','addTags','setTags','spread','whatsappInteractionTags:save','removeTags','download','unix','server','files','tmp','join','root','attachments','CmContact','firstName','lastName','Attachment','Messages','createdAt','direction','WhatsappAccount','Account','Owner','get','40px','<div\x20class=\x22header\x22>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<h5>Interaction\x20Transcript</h5>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20</div>','30px','%s\x20#%d','Whatsapp','YYYY-MM-DD','N.A.','YYYY-MM-DD\x20HH:mm:ss','closed','closedAt','disposition','basename','pipe','createWriteStream','secret','renderFile','views','downloadInteraction.html','toFile','.pdf','log','unlinkSync','html-pdf','eml-format','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','ejs','lodash','squel','crypto','jsforce','to-csv','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/license/util','../../mysqldb','redis','defaults','localhost','socket.io-emitter','./whatsappInteraction.socket','sendStatus','status','end','offset','limit','Content-Range','json','save','then','destroy','name','send','fullname','TagIds','Tags','split','forEach','push','catch','index','map','rawAttributes','fieldName','type','key','model','query','keys','filters','intersection','fields','attributes','nolimit','order','sort','where','pick','select','field','color','u.id','u.fullname','ui.WhatsappInteractionId','from','user_has_whatsapp_interactions','left_join','users','u.id\x20=\x20ui.UserId','whatsapp_interactions','cm_contacts','c.id\x20=\x20i.ContactId\x20AND\x20c.deletedAt\x20IS\x20NULL','o.id\x20=\x20i.UserId','whatsapp_accounts','a.id\x20=\x20i.WhatsappAccountId','whatsapp_messages'];(function(_0x39b362,_0x58cc41){var _0x357203=function(_0x9d467b){while(--_0x9d467b){_0x39b362['push'](_0x39b362['shift']());}};_0x357203(++_0x58cc41);}(_0xe9d4,0x94));var _0x4e9d=function(_0x27b118,_0xd7cdcf){_0x27b118=_0x27b118-0x0;var _0x3152af=_0xe9d4[_0x27b118];return _0x3152af;};'use strict';var pdf=require(_0x4e9d('0x0'));var emlformat=require(_0x4e9d('0x1'));var rimraf=require('rimraf');var zipdir=require(_0x4e9d('0x2'));var jsonpatch=require(_0x4e9d('0x3'));var rp=require(_0x4e9d('0x4'));var moment=require(_0x4e9d('0x5'));var BPromise=require(_0x4e9d('0x6'));var Mustache=require(_0x4e9d('0x7'));var util=require(_0x4e9d('0x8'));var path=require(_0x4e9d('0x9'));var sox=require(_0x4e9d('0xa'));var csv=require('to-csv');var ejs=require(_0x4e9d('0xb'));var fs=require('fs');var _=require(_0x4e9d('0xc'));var squel=require(_0x4e9d('0xd'));var crypto=require(_0x4e9d('0xe'));var jsforce=require(_0x4e9d('0xf'));var deskjs=require('desk.js');var toCsv=require(_0x4e9d('0x10'));var querystring=require('querystring');var Papa=require(_0x4e9d('0x11'));var Redis=require(_0x4e9d('0x12'));var authService=require(_0x4e9d('0x13'));var qs=require(_0x4e9d('0x14'));var as=require(_0x4e9d('0x15'));var hardwareService=require(_0x4e9d('0x16'));var logger=require(_0x4e9d('0x17'))(_0x4e9d('0x18'));var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require(_0x4e9d('0x19'));var db=require(_0x4e9d('0x1a'))['db'];config[_0x4e9d('0x1b')]=_[_0x4e9d('0x1c')](config[_0x4e9d('0x1b')],{'host':_0x4e9d('0x1d'),'port':0x18eb});var socket=require(_0x4e9d('0x1e'))(new Redis(config[_0x4e9d('0x1b')]));require(_0x4e9d('0x1f'))['register'](socket);function respondWithStatusCode(_0x4df733,_0x540e61){_0x540e61=_0x540e61||0xcc;return function(_0x1c8948){if(_0x1c8948){return _0x4df733[_0x4e9d('0x20')](_0x540e61);}return _0x4df733[_0x4e9d('0x21')](_0x540e61)[_0x4e9d('0x22')]();};}function respondWithResult(_0x5d7e68,_0x4baf41){_0x4baf41=_0x4baf41||0xc8;return function(_0x19b6e3){if(_0x19b6e3){return _0x5d7e68[_0x4e9d('0x21')](_0x4baf41)['json'](_0x19b6e3);}};}function respondWithFilteredResult(_0x3a8cb1,_0x1bae75){return function(_0xb10a96){if(_0xb10a96){var _0x3b0226=_0xb10a96['count'],_0x1aed45=_0x1bae75[_0x4e9d('0x23')],_0x3986a0=_0x1bae75[_0x4e9d('0x23')]+_0x1bae75[_0x4e9d('0x24')],_0x3cc533;if(_0x3986a0>=_0x3b0226){_0x3986a0=_0x3b0226;_0x3cc533=0xc8;}else{_0x3cc533=0xce;}_0x3a8cb1[_0x4e9d('0x21')](_0x3cc533);return _0x3a8cb1['set'](_0x4e9d('0x25'),_0x1aed45+'-'+_0x3986a0+'/'+_0x3b0226)[_0x4e9d('0x26')](_0xb10a96);}return null;};}function patchUpdates(_0xfc5f50){return function(_0x93b9a5){try{jsonpatch['apply'](_0x93b9a5,_0xfc5f50,!![]);}catch(_0x3c0cc7){return BPromise['reject'](_0x3c0cc7);}return _0x93b9a5[_0x4e9d('0x27')]();};}function saveUpdates(_0x22a0d5,_0x15def5){return function(_0x409bc4){if(_0x409bc4){return _0x409bc4['update'](_0x22a0d5)[_0x4e9d('0x28')](function(_0x2c151d){return _0x2c151d;});}return null;};}function removeEntity(_0x10a3e4,_0x3a0d73){return function(_0x5df99e){if(_0x5df99e){return _0x5df99e[_0x4e9d('0x29')]()['then'](function(){_0x10a3e4[_0x4e9d('0x21')](0xcc)[_0x4e9d('0x22')]();});}};}function handleEntityNotFound(_0x52eaeb,_0x346db1){return function(_0x4cb393){if(!_0x4cb393){_0x52eaeb[_0x4e9d('0x20')](0x194);}return _0x4cb393;};}function handleError(_0x3a1ebb,_0x1da256){_0x1da256=_0x1da256||0x1f4;return function(_0x424eca){logger['error'](_0x424eca['stack']);if(_0x424eca[_0x4e9d('0x2a')]){delete _0x424eca['name'];}_0x3a1ebb['status'](_0x1da256)[_0x4e9d('0x2b')](_0x424eca);};}function getInteractionUsers(_0x50602f,_0x5a50ec){return new BPromise(function(_0x4c47ad,_0x5830f8){try{if(_0x5a50ec[_0x50602f['id']]){_0x50602f['Users']=_['map'](_0x5a50ec[_0x50602f['id']],function(_0x41fa71){return{'id':_0x41fa71['id'],'fullname':_0x41fa71[_0x4e9d('0x2c')]};});}}catch(_0x43bd55){_0x5830f8(_0x43bd55);}_0x4c47ad(_0x50602f);});}function getInteractionTags(_0x4ea315,_0x492df5){return new BPromise(function(_0x4c6da0,_0x451a2e){try{if(_0x4ea315[_0x4e9d('0x2d')]){_0x4ea315[_0x4e9d('0x2e')]=[];_0x4ea315[_0x4e9d('0x2d')][_0x4e9d('0x2f')](',')[_0x4e9d('0x30')](function(_0x3f4529){_0x4ea315[_0x4e9d('0x2e')][_0x4e9d('0x31')](_0x492df5[_0x3f4529]);});}delete _0x4ea315['TagIds'];}catch(_0x3edcae){_0x451a2e(_0x3edcae);}_0x4c6da0(_0x4ea315);});}function updateWhatsappInteraction(_0x2355bf,_0x3dd09e,_0x3eb694){return new BPromise(function(_0x2ddf12,_0x4ad5ae){return getInteractionUsers(_0x2355bf,_0x3eb694)[_0x4e9d('0x28')](function(_0x3be911){return getInteractionTags(_0x3be911,_0x3dd09e);})[_0x4e9d('0x28')](function(_0x19c8d5){_0x2ddf12(_0x19c8d5);})[_0x4e9d('0x32')](function(_0x59750b){_0x4ad5ae(_0x59750b);});});}exports[_0x4e9d('0x33')]=function(_0x2cf4f,_0x3864e8){var _0x39e72b={},_0x27dea6={},_0x5b1db4={'count':0x0,'rows':[]};var _0x28bb7c=_[_0x4e9d('0x34')](db['WhatsappInteraction'][_0x4e9d('0x35')],function(_0xa0fe31){return{'name':_0xa0fe31[_0x4e9d('0x36')],'type':_0xa0fe31[_0x4e9d('0x37')][_0x4e9d('0x38')]};});_0x27dea6[_0x4e9d('0x39')]=_[_0x4e9d('0x34')](_0x28bb7c,_0x4e9d('0x2a'));_0x27dea6[_0x4e9d('0x3a')]=_[_0x4e9d('0x3b')](_0x2cf4f[_0x4e9d('0x3a')]);_0x27dea6[_0x4e9d('0x3c')]=_['intersection'](_0x27dea6[_0x4e9d('0x39')],_0x27dea6[_0x4e9d('0x3a')]);_0x39e72b['attributes']=_[_0x4e9d('0x3d')](_0x27dea6[_0x4e9d('0x39')],qs['fields'](_0x2cf4f[_0x4e9d('0x3a')][_0x4e9d('0x3e')]));_0x39e72b['attributes']=_0x39e72b[_0x4e9d('0x3f')]['length']?_0x39e72b[_0x4e9d('0x3f')]:_0x27dea6[_0x4e9d('0x39')];if(!_0x2cf4f[_0x4e9d('0x3a')]['hasOwnProperty'](_0x4e9d('0x40'))){_0x39e72b[_0x4e9d('0x24')]=qs[_0x4e9d('0x24')](_0x2cf4f[_0x4e9d('0x3a')][_0x4e9d('0x24')]);_0x39e72b[_0x4e9d('0x23')]=qs[_0x4e9d('0x23')](_0x2cf4f[_0x4e9d('0x3a')][_0x4e9d('0x23')]);}_0x39e72b[_0x4e9d('0x41')]=qs[_0x4e9d('0x42')](_0x2cf4f[_0x4e9d('0x3a')][_0x4e9d('0x42')]);_0x39e72b[_0x4e9d('0x43')]=qs[_0x4e9d('0x3c')](_[_0x4e9d('0x44')](_0x2cf4f[_0x4e9d('0x3a')],_0x27dea6[_0x4e9d('0x3c')]),_0x28bb7c);var _0x268caf=[];var _0x4a60d5=squel[_0x4e9d('0x45')]()[_0x4e9d('0x46')]('id')['field'](_0x4e9d('0x2a'))['field'](_0x4e9d('0x47'))['from']('tools_tags');var _0x4463a3=squel[_0x4e9d('0x45')]()[_0x4e9d('0x46')](_0x4e9d('0x48'))[_0x4e9d('0x46')](_0x4e9d('0x49'))[_0x4e9d('0x46')](_0x4e9d('0x4a'))[_0x4e9d('0x4b')](_0x4e9d('0x4c'),'ui')[_0x4e9d('0x4d')](_0x4e9d('0x4e'),'u',_0x4e9d('0x4f'));var _0x57f956=squel[_0x4e9d('0x45')]()[_0x4e9d('0x4b')](_0x4e9d('0x50'),'i')['left_join'](_0x4e9d('0x51'),'c',_0x4e9d('0x52'))[_0x4e9d('0x4d')]('users','o',_0x4e9d('0x53'))[_0x4e9d('0x4d')](_0x4e9d('0x54'),'a',_0x4e9d('0x55'))[_0x4e9d('0x4d')](_0x4e9d('0x56'),'me','me.WhatsappInteractionId\x20=\x20i.id')[_0x4e9d('0x4d')](_0x4e9d('0x57'),'it',_0x4e9d('0x58'))[_0x4e9d('0x4d')](_0x4e9d('0x59'),'t',_0x4e9d('0x5a'));var _0x4e095a=squel['expr']();var _0x2f617b=[];var _0x98aaff=squel[_0x4e9d('0x5b')]();var _0x4e6038;if(_0x2cf4f[_0x4e9d('0x3a')][_0x4e9d('0x5c')]){_0x4e6038=as[_0x4e9d('0x5d')](_0x2cf4f[_0x4e9d('0x3a')]['search']);var _0x1ae754=_0x4e6038[_0x4e9d('0x5e')];for(var _0x2fbaf8=0x0;_0x2fbaf8<_0x4e6038['conditions'][_0x4e9d('0x5f')];_0x2fbaf8++){var _0x367d0d=_0x4e6038['conditions'][_0x2fbaf8];var _0x3c117e='i';var _0x343aa4=_[_0x4e9d('0x60')](_0x28bb7c,['name',_0x367d0d['field']]);if(!_0x343aa4){switch(_0x367d0d[_0x4e9d('0x46')]){case'unreadMessages':if(_0x367d0d['value']==0x1){_0x57f956[_0x4e9d('0x61')]('`'+_0x367d0d[_0x4e9d('0x46')]+_0x4e9d('0x62'));}else{_0x57f956[_0x4e9d('0x61')]('`'+_0x367d0d[_0x4e9d('0x46')]+_0x4e9d('0x63'));}break;case _0x4e9d('0x64'):if(_0x367d0d['operator']==='$substring'){if(_0x367d0d[_0x4e9d('0x65')]['split']('\x20')[_0x4e9d('0x5f')]>0x1){_0x4e095a[_0x1ae754](_0x4e9d('0x66'),qs[_0x4e9d('0x67')](_0x367d0d[_0x4e9d('0x65')]),null);}else{var _0x51a357='%'+_0x367d0d[_0x4e9d('0x65')]+'%';_0x4e095a[_0x1ae754](_0x4e9d('0x68'),_0x51a357,_0x51a357,_0x51a357);}}else{_0x343aa4=_['find'](_0x28bb7c,[_0x4e9d('0x2a'),_0x4e9d('0x69')]);_0x367d0d[_0x4e9d('0x46')]=_0x4e9d('0x69');_0x4ab4b6=as['buildExpression'](_0x3c117e,_0x343aa4[_0x4e9d('0x37')],_0x367d0d);_0x4e095a[_0x1ae754](_0x4ab4b6['text'],_0x4ab4b6[_0x4e9d('0x65')][_0x4e9d('0x6a')],_0x4ab4b6[_0x4e9d('0x65')][_0x4e9d('0x22')]);}break;case _0x4e9d('0x6b'):var _0x59b498=_0x367d0d[_0x4e9d('0x65')][_0x4e9d('0x2f')](',')['map'](function(_0x12350b){return Number(_0x12350b);});_0x59b498[_0x4e9d('0x30')](function(_0xc50d93){_0x98aaff['or'](_0x4e9d('0x6c'),'%,'+_0xc50d93+',%');});_0x2f617b=_['union'](_0x2f617b,_0x59b498);break;case _0x4e9d('0x6d'):if(_0x367d0d[_0x4e9d('0x6e')]===_0x4e9d('0x6f')){_0x4e095a[_0x1ae754]('CONCAT_WS(\x27\x20\x27,\x20o.name,\x20o.fullname)\x20LIKE\x20?','%'+_0x367d0d[_0x4e9d('0x65')]+'%',null);}else{_0x343aa4=_[_0x4e9d('0x60')](_0x28bb7c,[_0x4e9d('0x2a'),'UserId']);_0x367d0d['field']=_0x4e9d('0x70');_0x4ab4b6=as[_0x4e9d('0x71')](_0x3c117e,_0x343aa4[_0x4e9d('0x37')],_0x367d0d);_0x4e095a[_0x1ae754](_0x4ab4b6[_0x4e9d('0x72')],_0x4ab4b6[_0x4e9d('0x65')][_0x4e9d('0x6a')],_0x4ab4b6[_0x4e9d('0x65')]['end']);}break;case'body':_0x4ab4b6=as['buildExpression']('me',null,_0x367d0d);_0x4e095a[_0x1ae754](_0x4ab4b6[_0x4e9d('0x72')],_0x4ab4b6[_0x4e9d('0x65')][_0x4e9d('0x6a')],_0x4ab4b6['value'][_0x4e9d('0x22')]);break;}}else{var _0x4ab4b6=as[_0x4e9d('0x71')](_0x3c117e,_0x343aa4[_0x4e9d('0x37')],_0x367d0d);_0x4e095a[_0x1ae754](_0x4ab4b6[_0x4e9d('0x72')],_0x4ab4b6['value'][_0x4e9d('0x6a')],_0x4ab4b6[_0x4e9d('0x65')][_0x4e9d('0x22')]);}}}else{var _0x30efa2=_(_0x2cf4f[_0x4e9d('0x3a')])[_0x4e9d('0x3b')]()['map'](function(_0x4f3807){return _['some'](_0x28bb7c,[_0x4e9d('0x2a'),_0x4f3807])?_0x4f3807:undefined;})['compact']()[_0x4e9d('0x65')]();if(!_['isEmpty'](_0x30efa2)){_0x30efa2[_0x4e9d('0x30')](function(_0x287a9e){if(_0x287a9e===_0x4e9d('0x73')){_0x57f956[_0x4e9d('0x43')]('i.WhatsappAccountId\x20IN\x20?',[][_0x4e9d('0x74')](_0x2cf4f['query'][_0x287a9e]));}else if(_0x287a9e==='createdAt'){var _0x3f3b16=JSON[_0x4e9d('0x75')](_0x2cf4f['query'][_0x287a9e])[_0x4e9d('0x76')];var _0x5c1094=JSON[_0x4e9d('0x75')](_0x2cf4f[_0x4e9d('0x3a')][_0x287a9e])[_0x4e9d('0x77')];_0x57f956['where'](_0x4e9d('0x78'),_0x3f3b16,_0x5c1094);}else{if(_0x2cf4f['query'][_0x287a9e]===_0x4e9d('0x79')){_0x57f956['where']('i.'+_0x287a9e+'\x20IS\x20NULL');}else{_0x57f956[_0x4e9d('0x43')]('i.'+_0x287a9e+_0x4e9d('0x7a'),_0x2cf4f[_0x4e9d('0x3a')][_0x287a9e]);}}});}if(_0x2cf4f['query'][_0x4e9d('0x7b')]){if(_0x2cf4f['query']['read']==0x1){_0x57f956[_0x4e9d('0x61')](_0x4e9d('0x7c'));}else{_0x57f956['having'](_0x4e9d('0x7d'));}}if(_0x2cf4f[_0x4e9d('0x3a')][_0x4e9d('0x7e')]){_0x2f617b=_[_0x4e9d('0x7f')](_0x2cf4f['query'][_0x4e9d('0x7e')])?_0x2cf4f[_0x4e9d('0x3a')]['tag']:new Array(_0x2cf4f[_0x4e9d('0x3a')][_0x4e9d('0x7e')]);_0x2f617b[_0x4e9d('0x30')](function(_0xf46b38){_0x98aaff['or']('CONCAT(\x27,\x27,\x20`TagIds`,\x20\x27,\x27)\x20LIKE\x20?','%,'+_0xf46b38+',%');});}if(_0x2cf4f[_0x4e9d('0x3a')][_0x4e9d('0x80')]){var _0x391dc4=_0x2cf4f[_0x4e9d('0x3a')][_0x4e9d('0x80')][_0x4e9d('0x81')]('\x5c','\x5c\x5c')['replace'](/'/g,'\x27\x27');if(qs[_0x4e9d('0x82')](_0x391dc4)){_0x4e095a['or'](_0x4e9d('0x83'),_0x391dc4+'%')['or'](_0x4e9d('0x84'),_0x391dc4+'%');}else{_0x4e095a['or'](_0x4e9d('0x85'),qs[_0x4e9d('0x67')](_0x391dc4))['or'](_0x4e9d('0x86'),_0x391dc4+'%');}}}_0x57f956[_0x4e9d('0x43')](_0x4e095a);_0x57f956[_0x4e9d('0x87')](_0x4e9d('0x88'));var _0x526844={'type':db[_0x4e9d('0x89')][_0x4e9d('0x8a')][_0x4e9d('0x8b')],'raw':!![]};var _0x1cf688=_0x57f956['clone']();_0x1cf688[_0x4e9d('0x46')](_0x4e9d('0x88'));_0x1cf688['field'](_0x4e9d('0x8c'),'unreadMessages');if(_0x39e72b['order']){_0x39e72b[_0x4e9d('0x41')][_0x4e9d('0x30')](function(_0x4bc909){var _0x5d79e2=_0x4bc909[0x0]===_0x4e9d('0x8d')?_0x4bc909[0x0]:'i.'+_0x4bc909[0x0];_0x57f956[_0x4e9d('0x41')](_0x5d79e2,_0x4bc909[0x1]===_0x4e9d('0x8e')?![]:!![]);});}if(!_['isEmpty'](_0x2f617b)){_0x57f956[_0x4e9d('0x61')](_0x98aaff);_0x1cf688[_0x4e9d('0x43')](_0x4e9d('0x8f'),_0x2f617b);}BPromise['resolve']()['then'](function(){if(!_0x4e6038){if(_0x2cf4f[_0x4e9d('0x3a')][_0x4e9d('0x73')]||_0x2cf4f[_0x4e9d('0x3a')][_0x4e9d('0x90')])return;_0x1cf688[_0x4e9d('0x43')]('i.WhatsappAccountId\x20IS\x20NOT\x20NULL');_0x57f956[_0x4e9d('0x43')](_0x4e9d('0x91'));return;}if(_0x2cf4f[_0x4e9d('0x92')]['role']!=='agent')return;return _0x2cf4f[_0x4e9d('0x92')]['getWhatsappAccounts']({'attributes':['id'],'raw':!![]})[_0x4e9d('0x28')](function(_0x1288d3){if(_[_0x4e9d('0x93')](_0x1288d3)){_0x1cf688[_0x4e9d('0x43')](_0x4e9d('0x94'));_0x57f956['where']('i.WhatsappAccountId\x20IS\x20NULL');}else{_0x1cf688[_0x4e9d('0x43')]('i.WhatsappAccountId\x20IN\x20?',_[_0x4e9d('0x34')](_0x1288d3,'id'));_0x57f956['where']('i.WhatsappAccountId\x20IN\x20?',_[_0x4e9d('0x34')](_0x1288d3,'id'));}});})[_0x4e9d('0x28')](function(){if(_0x2cf4f['user'][_0x4e9d('0x95')]===_0x4e9d('0x96')&&!_0x4e6038&&!_0x2cf4f[_0x4e9d('0x3a')][_0x4e9d('0x73')])return[];return db[_0x4e9d('0x97')][_0x4e9d('0x3a')](_0x1cf688['toString'](),_0x526844);})[_0x4e9d('0x28')](function(_0x261a89){_0x5b1db4[_0x4e9d('0x98')]=_0x261a89[_0x4e9d('0x5f')];if(_0x5b1db4[_0x4e9d('0x98')]===0x0)return[];return db['sequelize']['query'](_0x4a60d5['toString'](),_0x526844)['then'](function(_0x453b79){_0x268caf=_[_0x4e9d('0x99')](_0x453b79,'id');_0x526844=_[_0x4e9d('0x9a')](_0x526844,{'model':db[_0x4e9d('0x9b')],'mapToModel':!![],'raw':!![],'nest':!![]});if(_0x2cf4f['query'][_0x4e9d('0x3e')]){_0x39e72b[_0x4e9d('0x3f')]['forEach'](function(_0x409924){_0x57f956[_0x4e9d('0x46')]('i.'+_0x409924);});}else{_0x57f956[_0x4e9d('0x46')](_0x4e9d('0x8c'),'unreadMessages');_0x57f956[_0x4e9d('0x46')](_0x4e9d('0x9c'),'Account.key');_0x57f956[_0x4e9d('0x46')]('a.mandatoryDisposition',_0x4e9d('0x9d'));_0x57f956['field']('CASE\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',_0x4e9d('0x8d'));_0x57f956[_0x4e9d('0x46')](_0x4e9d('0x9e'));_0x57f956[_0x4e9d('0x46')]('c.firstName',_0x4e9d('0x9f'));_0x57f956[_0x4e9d('0x46')]('c.lastName',_0x4e9d('0xa0'));_0x57f956['field'](_0x4e9d('0xa1'),'Contact.email');_0x57f956[_0x4e9d('0x46')]('c.phone','Contact.phone');_0x57f956[_0x4e9d('0x46')](_0x4e9d('0xa2'),_0x4e9d('0xa3'));_0x57f956[_0x4e9d('0x46')](_0x4e9d('0xa4'),'Contact.fax');_0x57f956[_0x4e9d('0x46')](_0x4e9d('0xa5'),_0x4e9d('0xa6'));_0x57f956[_0x4e9d('0x46')]('o.internal',_0x4e9d('0xa7'));_0x57f956['field']('GROUP_CONCAT(DISTINCT\x20t.id)',_0x4e9d('0x2d'));}if(_0x39e72b[_0x4e9d('0x24')])_0x57f956[_0x4e9d('0x24')](_0x39e72b[_0x4e9d('0x24')]);if(_0x39e72b[_0x4e9d('0x23')])_0x57f956[_0x4e9d('0x23')](_0x39e72b[_0x4e9d('0x23')]);return db[_0x4e9d('0x97')][_0x4e9d('0x3a')](_0x57f956[_0x4e9d('0xa8')](),_0x526844);})[_0x4e9d('0x28')](function(_0x34000e){_0x4463a3[_0x4e9d('0x43')](_0x4e9d('0xa9'),_[_0x4e9d('0x34')](_0x34000e,'id'));return db[_0x4e9d('0x97')][_0x4e9d('0x3a')](_0x4463a3[_0x4e9d('0xa8')](),_0x526844)[_0x4e9d('0x28')](function(_0x361fa7){var _0x2fec07=_[_0x4e9d('0xaa')](_0x361fa7,_0x4e9d('0xab'));var _0x4c5a05=[];_0x34000e[_0x4e9d('0x30')](function(_0x19ae33){_0x4c5a05[_0x4e9d('0x31')](updateWhatsappInteraction(_0x19ae33,_0x268caf,_0x2fec07));});return BPromise[_0x4e9d('0xac')](_0x4c5a05);});});})['then'](function(_0x1275d9){_0x5b1db4['rows']=_0x1275d9;return _0x5b1db4;})[_0x4e9d('0x28')](respondWithFilteredResult(_0x3864e8,_0x39e72b))[_0x4e9d('0x32')](handleError(_0x3864e8,null));};exports[_0x4e9d('0xad')]=function(_0x520549,_0x545a60){var _0x485a9c={'raw':![],'where':{'id':_0x520549[_0x4e9d('0xae')]['id']}},_0x289e65={};_0x289e65[_0x4e9d('0x39')]=_[_0x4e9d('0x3b')](db[_0x4e9d('0x9b')][_0x4e9d('0x35')]);_0x289e65['query']=_[_0x4e9d('0x3b')](_0x520549[_0x4e9d('0x3a')]);_0x289e65[_0x4e9d('0x3c')]=_[_0x4e9d('0x3d')](_0x289e65[_0x4e9d('0x39')],_0x289e65[_0x4e9d('0x3a')]);_0x485a9c[_0x4e9d('0x3f')]=_[_0x4e9d('0x3d')](_0x289e65['model'],qs['fields'](_0x520549['query'][_0x4e9d('0x3e')]));_0x485a9c[_0x4e9d('0x3f')]=_0x485a9c[_0x4e9d('0x3f')]['length']?_0x485a9c[_0x4e9d('0x3f')]:_0x289e65[_0x4e9d('0x39')];if(_0x520549['query'][_0x4e9d('0xaf')]){_0x485a9c['include']=[{'all':!![]}];}_0x485a9c=_['merge']({},_0x485a9c,_0x520549[_0x4e9d('0xb0')]);return db[_0x4e9d('0x9b')][_0x4e9d('0x60')](_0x485a9c)[_0x4e9d('0x28')](handleEntityNotFound(_0x545a60,null))[_0x4e9d('0x28')](respondWithResult(_0x545a60,null))['catch'](handleError(_0x545a60,null));};exports[_0x4e9d('0xb1')]=function(_0x47eeb1,_0x154ff9){return db[_0x4e9d('0x9b')][_0x4e9d('0xb1')](_0x47eeb1[_0x4e9d('0xb2')],{})[_0x4e9d('0x28')](respondWithResult(_0x154ff9,0xc9))[_0x4e9d('0x32')](handleError(_0x154ff9,null));};exports[_0x4e9d('0xb3')]=function(_0x57a306,_0x225f42){if(_0x57a306[_0x4e9d('0xb2')]['id']){delete _0x57a306[_0x4e9d('0xb2')]['id'];}return db[_0x4e9d('0x9b')][_0x4e9d('0x60')]({'where':{'id':_0x57a306[_0x4e9d('0xae')]['id']}})[_0x4e9d('0x28')](handleEntityNotFound(_0x225f42,null))[_0x4e9d('0x28')](saveUpdates(_0x57a306['body'],null))[_0x4e9d('0x28')](respondWithResult(_0x225f42,null))[_0x4e9d('0x32')](handleError(_0x225f42,null));};exports['destroy']=function(_0xc6dbbb,_0x4493f1){return db[_0x4e9d('0x9b')][_0x4e9d('0x60')]({'where':{'id':_0xc6dbbb[_0x4e9d('0xae')]['id']}})[_0x4e9d('0x28')](handleEntityNotFound(_0x4493f1,null))[_0x4e9d('0x28')](removeEntity(_0x4493f1,null))[_0x4e9d('0x32')](handleError(_0x4493f1,null));};exports[_0x4e9d('0xb4')]=function(_0xab9b9f,_0x44fd6a){return db[_0x4e9d('0x9b')][_0x4e9d('0xb4')]()['then'](respondWithResult(_0x44fd6a,null))['catch'](handleError(_0x44fd6a,null));};exports[_0x4e9d('0xb5')]=function(_0x5880d2,_0x489b9c,_0x1ff7b9){return db['WhatsappMessage'][_0x4e9d('0x60')]({'where':{'id':_0x5880d2[_0x4e9d('0xae')]['id']}})['then'](handleEntityNotFound(_0x489b9c,null))[_0x4e9d('0x28')](function(_0x51a4a0){if(_0x51a4a0){return _0x51a4a0['addMessage'](_0x5880d2[_0x4e9d('0xb2')]['ids'],_['omit'](_0x5880d2[_0x4e9d('0xb2')],[_0x4e9d('0xb6'),'id'])||{});}})[_0x4e9d('0x28')](respondWithResult(_0x489b9c,null))[_0x4e9d('0x32')](handleError(_0x489b9c,null));};exports[_0x4e9d('0xb7')]=function(_0x1f157a,_0x2aad2f,_0xb067ea){var _0x33d01c={'raw':![],'where':{}};var _0x1e8475={};var _0x31b873={'count':0x0,'rows':[]};return db[_0x4e9d('0x9b')][_0x4e9d('0xb8')]({'where':{'id':_0x1f157a[_0x4e9d('0xae')]['id']}})[_0x4e9d('0x28')](handleEntityNotFound(_0x2aad2f,null))[_0x4e9d('0x28')](function(_0x3799cc){if(_0x3799cc){_0x1e8475[_0x4e9d('0x39')]=_['keys'](db['WhatsappMessage'][_0x4e9d('0x35')]);_0x1e8475[_0x4e9d('0x3a')]=_[_0x4e9d('0x3b')](_0x1f157a[_0x4e9d('0x3a')]);_0x1e8475[_0x4e9d('0x3c')]=_['intersection'](_0x1e8475['model'],_0x1e8475[_0x4e9d('0x3a')]);_0x33d01c[_0x4e9d('0x3f')]=_[_0x4e9d('0x3d')](_0x1e8475['model'],qs[_0x4e9d('0x3e')](_0x1f157a[_0x4e9d('0x3a')][_0x4e9d('0x3e')]));_0x33d01c[_0x4e9d('0x3f')]=_0x33d01c[_0x4e9d('0x3f')][_0x4e9d('0x5f')]?_0x33d01c[_0x4e9d('0x3f')]:_0x1e8475[_0x4e9d('0x39')];if(!_0x1f157a['query']['hasOwnProperty'](_0x4e9d('0x40'))){_0x33d01c[_0x4e9d('0x24')]=qs[_0x4e9d('0x24')](_0x1f157a['query']['limit']);_0x33d01c[_0x4e9d('0x23')]=qs[_0x4e9d('0x23')](_0x1f157a[_0x4e9d('0x3a')][_0x4e9d('0x23')]);}_0x33d01c[_0x4e9d('0x41')]=qs['sort'](_0x1f157a['query']['sort']);_0x33d01c[_0x4e9d('0x43')]=qs[_0x4e9d('0x3c')](_['pick'](_0x1f157a['query'],_0x1e8475['filters']));_0x33d01c[_0x4e9d('0x43')][_0x4e9d('0xab')]=_0x3799cc['id'];if(_0x1f157a['query'][_0x4e9d('0x80')]){_0x33d01c[_0x4e9d('0x43')]=_[_0x4e9d('0x9a')](_0x33d01c[_0x4e9d('0x43')],{'$or':_[_0x4e9d('0x34')](_0x33d01c['attributes'],function(_0x51008e){var _0x31e743={};_0x31e743[_0x51008e]={'$like':'%'+_0x1f157a['query'][_0x4e9d('0x80')]+'%'};return _0x31e743;})});}if(_0x1f157a[_0x4e9d('0x3a')][_0x4e9d('0x76')]){var _0x5c0202=_0x1f157a[_0x4e9d('0x3a')][_0x4e9d('0x76')][_0x4e9d('0x2f')](',');var _0x7712da={};_0x7712da[_0x5c0202[0x0]]={'$gte':moment(_0x5c0202[0x1])[_0x4e9d('0xb9')]('YYYY-MM-DD\x20HH:mm:ss')};_0x33d01c['where']=_[_0x4e9d('0x9a')](_0x33d01c['where'],_0x7712da);}_0x33d01c=_[_0x4e9d('0x9a')]({},_0x33d01c,_0x1f157a[_0x4e9d('0xb0')]);return db['WhatsappMessage'][_0x4e9d('0x98')]({'where':_0x33d01c[_0x4e9d('0x43')]})[_0x4e9d('0x28')](function(_0x98b84){_0x31b873[_0x4e9d('0x98')]=_0x98b84;if(_0x1f157a['query']['includeAll']){_0x33d01c['include']=[{'all':!![]}];}return db[_0x4e9d('0xba')][_0x4e9d('0xbb')](_0x33d01c);})[_0x4e9d('0x28')](function(_0x584004){_0x31b873[_0x4e9d('0xbc')]=_0x584004;return _0x31b873;});}})[_0x4e9d('0x28')](respondWithFilteredResult(_0x2aad2f,_0x33d01c))[_0x4e9d('0x32')](handleError(_0x2aad2f,null));};exports[_0x4e9d('0xbd')]=function(_0x32822a,_0x17e996,_0x5015ae){return db[_0x4e9d('0x9b')]['find']({'where':{'id':_0x32822a[_0x4e9d('0xae')]['id']}})[_0x4e9d('0x28')](handleEntityNotFound(_0x17e996,null))[_0x4e9d('0x28')](function(_0x406a2c){if(_0x406a2c){return _0x406a2c[_0x4e9d('0xbe')](_0x32822a['body'][_0x4e9d('0xb6')],_['omit'](_0x32822a[_0x4e9d('0xb2')],[_0x4e9d('0xb6'),'id'])||{})[_0x4e9d('0xbf')](function(){return db['Tag']['findAll']({'attributes':['id',_0x4e9d('0x2a'),_0x4e9d('0x47')],'where':{'id':_0x32822a[_0x4e9d('0xb2')][_0x4e9d('0xb6')]}});})[_0x4e9d('0x28')](function(_0x246a43){socket['emit'](_0x4e9d('0xc0'),{'id':Number(_0x32822a[_0x4e9d('0xae')]['id']),'tags':_0x246a43||[]});return{'id':Number(_0x32822a[_0x4e9d('0xae')]['id']),'tags':_0x246a43||[]};});}})[_0x4e9d('0x28')](respondWithResult(_0x17e996,null))[_0x4e9d('0x32')](handleError(_0x17e996,null));};exports[_0x4e9d('0xc1')]=function(_0x4f0333,_0x2ea1bf,_0x34fbea){return db['WhatsappInteraction']['find']({'where':{'id':_0x4f0333['params']['id']}})[_0x4e9d('0x28')](handleEntityNotFound(_0x2ea1bf,null))[_0x4e9d('0x28')](function(_0x59df7a){if(_0x59df7a){return _0x59df7a['removeTags'](_0x4f0333[_0x4e9d('0x3a')]['ids']);}})[_0x4e9d('0x28')](respondWithStatusCode(_0x2ea1bf,null))['catch'](handleError(_0x2ea1bf,null));};exports[_0x4e9d('0xc2')]=function(_0x34c555,_0x43ab70){var _0x1d9b5e=moment()[_0x4e9d('0xc3')]()[_0x4e9d('0xa8')]();var _0x49bba6=path['join'](config['root'],_0x4e9d('0xc4'),_0x4e9d('0xc5'),_0x4e9d('0xc6'));var _0x11c7e5=path[_0x4e9d('0xc7')](config[_0x4e9d('0xc8')],_0x4e9d('0xc4'),_0x4e9d('0xc5'),_0x4e9d('0xc9'));var _0x5f0679=path[_0x4e9d('0xc7')](_0x49bba6,_0x1d9b5e);var _0x3e90bd=util[_0x4e9d('0xb9')]('transcript-%d-%s.zip',_0x34c555[_0x4e9d('0xae')]['id'],_0x1d9b5e);var _0x3220fc=path[_0x4e9d('0xc7')](_0x49bba6,_0x3e90bd);var _0x2a4e3c=[];_0x2a4e3c[_0x4e9d('0x31')]({'model':db[_0x4e9d('0x6d')],'as':_0x4e9d('0x6d'),'attributes':['id','fullname'],'raw':!![]});_0x2a4e3c[_0x4e9d('0x31')]({'model':db[_0x4e9d('0xca')],'as':_0x4e9d('0x64'),'attributes':['id',_0x4e9d('0xcb'),_0x4e9d('0xcc')],'raw':!![]});if(_0x34c555[_0x4e9d('0x3a')][_0x4e9d('0xc9')]){_0x2a4e3c['push']({'model':db[_0x4e9d('0xcd')],'as':_0x4e9d('0xcd'),'raw':!![]});}var _0x4afa37=[{'model':db[_0x4e9d('0xba')],'as':_0x4e9d('0xce'),'attributes':['id',_0x4e9d('0xb2'),_0x4e9d('0xcf'),_0x4e9d('0xd0'),'secret',_0x4e9d('0x7b')],'include':_0x2a4e3c}];_0x4afa37[_0x4e9d('0x31')]({'model':db[_0x4e9d('0xd1')],'as':_0x4e9d('0xd2'),'attributes':['id','name']});_0x4afa37['push']({'model':db['User'],'as':_0x4e9d('0xd3'),'attributes':['id',_0x4e9d('0x2c')]});return db[_0x4e9d('0x9b')][_0x4e9d('0x60')]({'where':{'id':_0x34c555[_0x4e9d('0xae')]['id']},'include':_0x4afa37})[_0x4e9d('0x28')](handleEntityNotFound(_0x43ab70,null))[_0x4e9d('0x28')](function(_0x1abc56){if(_0x1abc56){var _0x1c8f8a=_0x1abc56[_0x4e9d('0xd4')]({'plain':!![]});fs['mkdirSync'](_0x5f0679);var _0x2f0970={'format':'A4','border':'10px','header':{'height':_0x4e9d('0xd5'),'contents':{'first':_0x4e9d('0xd6')}},'footer':{'height':_0x4e9d('0xd7'),'contents':{'default':util['format']('<hr\x20class=\x22separator\x22/>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<div\x20class=\x22footer\x22>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<div\x20class=\x22left\x22>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<span>%s</span>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20</div>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<div\x20class=\x22center\x22>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<span>{{page}}/{{pages}}</span>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20</div>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<div\x20class=\x22right\x22>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<span>%s</span>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20</div>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20</div>',util[_0x4e9d('0xb9')](_0x4e9d('0xd8'),_0x4e9d('0xd9'),_0x1c8f8a['id']),moment()[_0x4e9d('0xb9')](_0x4e9d('0xda'))['toString']())}}};var _0x1e043a={'channel':'Whatsapp','account':_0x1c8f8a[_0x4e9d('0xd2')]['name'],'agent':_0x1c8f8a[_0x4e9d('0xd3')]?_0x1c8f8a[_0x4e9d('0xd3')][_0x4e9d('0x2c')]:_0x4e9d('0xdb'),'createdAt':moment(_0x1c8f8a[_0x4e9d('0xcf')])[_0x4e9d('0xb9')](_0x4e9d('0xdc'))[_0x4e9d('0xa8')](),'closedAt':_0x1c8f8a[_0x4e9d('0xdd')]?moment(_0x1c8f8a[_0x4e9d('0xde')])['format'](_0x4e9d('0xdc'))['toString']():'','disposition':_0x1c8f8a[_0x4e9d('0xdf')],'messages':_(_0x1c8f8a[_0x4e9d('0xce')])[_0x4e9d('0x80')]({'secret':![]})[_0x4e9d('0x34')](function(_0x4cc6d4){if(_0x4cc6d4[_0x4e9d('0xcd')]){var _0xf807be=path[_0x4e9d('0xc7')](_0x11c7e5,_0x4cc6d4[_0x4e9d('0xcd')][_0x4e9d('0xe0')]);if(fs['existsSync'](_0xf807be)){fs['createReadStream'](_0xf807be)[_0x4e9d('0xe1')](fs[_0x4e9d('0xe2')](path[_0x4e9d('0xc7')](_0x5f0679,_0x4cc6d4[_0x4e9d('0xcd')][_0x4e9d('0xe0')])));}}return{'date':moment(_0x4cc6d4[_0x4e9d('0xcf')])[_0x4e9d('0xb9')](_0x4e9d('0xdc'))[_0x4e9d('0xa8')](),'sender':_0x4cc6d4[_0x4e9d('0xd0')]==='out'?_0x4cc6d4[_0x4e9d('0x6d')]?_0x4cc6d4[_0x4e9d('0x6d')][_0x4e9d('0x2c')]:'System':_0x4cc6d4[_0x4e9d('0x64')][_0x4e9d('0xcb')]+(_0x4cc6d4[_0x4e9d('0x64')][_0x4e9d('0xcc')]?'\x20'+_0x4cc6d4[_0x4e9d('0x64')]['lastName']:''),'body':_0x4cc6d4['Attachment']?_0x4cc6d4['Attachment'][_0x4e9d('0xe0')]:_0x4cc6d4[_0x4e9d('0xb2')],'direction':_0x4cc6d4[_0x4e9d('0xd0')]==='out'?'A':'C','secret':_0x4cc6d4[_0x4e9d('0xe3')],'read':_0x4cc6d4[_0x4e9d('0x7b')],'attachment':_0x4cc6d4[_0x4e9d('0xcd')]};})['value']()};return ejs[_0x4e9d('0xe4')](path[_0x4e9d('0xc7')](config[_0x4e9d('0xc8')],_0x4e9d('0xc4'),_0x4e9d('0xe5'),_0x4e9d('0xe6')),{'interaction':_0x1e043a})[_0x4e9d('0x28')](function(_0x2615b4){return new BPromise(function(_0x1ef8b8,_0xb70514){pdf[_0x4e9d('0xb1')](_0x2615b4,_0x2f0970)[_0x4e9d('0xe7')](path[_0x4e9d('0xc7')](_0x5f0679,'transcript-'+_0x1c8f8a['id']+'-'+_0x1d9b5e+_0x4e9d('0xe8')),function(_0x467ad1,_0x3a03ec){if(_0x467ad1)return _0xb70514(_0x467ad1);_0x1ef8b8(_0x3a03ec);});});})[_0x4e9d('0x28')](function(){return new BPromise(function(_0x40f510,_0x18246a){zipdir(_0x5f0679,{'saveTo':_0x3220fc},function(_0x89642,_0x424251){if(_0x89642)return _0x18246a(_0x89642);return _0x40f510(_0x424251);});})[_0x4e9d('0x28')](function(){return new BPromise(function(_0x56c679,_0x100d09){rimraf(_0x5f0679,function(_0xe55401){if(_0xe55401)_0x100d09(_0xe55401);return _0x56c679();});});})[_0x4e9d('0x28')](function(){return _0x43ab70[_0x4e9d('0xc2')](_0x3220fc,_0x3e90bd,function(_0x2d6ee7){if(_0x2d6ee7){console[_0x4e9d('0xe9')]('err',_0x2d6ee7);}else{fs[_0x4e9d('0xea')](_0x3220fc);}});});});}else{return _0x43ab70['sendStatus'](0xc8);}})[_0x4e9d('0x32')](handleError(_0x43ab70,null));};
\ No newline at end of file
+var _0xf7f5=['../../components/export/pdf','api','../../config/environment','../../mysqldb','defaults','redis','localhost','socket.io-emitter','./whatsappInteraction.socket','register','sendStatus','status','json','offset','undefined','limit','count','Content-Range','destroy','then','end','error','name','send','index','map','rawAttributes','fieldName','type','key','getOptions','findAll','whatsapp','query','catch','params','model','keys','WhatsappInteraction','filters','intersection','attributes','fields','length','merge','options','create','body','update','find','describe','addMessage','WhatsappMessage','omit','ids','getMessages','findOne','hasOwnProperty','nolimit','sort','where','pick','WhatsappInteractionId','filter','$gte','YYYY-MM-DD\x20HH:mm:ss','includeAll','include','rows','setTags','spread','Tag','emit','whatsappInteractionTags:save','removeTags','download','toString','join','root','server','files','tmp','push','User','fullname','CmContact','Contact','firstName','attachments','Attachment','Messages','createdAt','direction','secret','Account','get','Whatsapp','Owner','format','closed','closedAt','disposition','existsSync','createWriteStream','basename','out','System','lastName','value','renderFile','downloadInteraction.ejs','transcript-','createPdfFromHTML','log','err','unlinkSync','rimraf','zip-dir','moment','bluebird','util','path','ejs','lodash','../../components/interaction/service','../../components/parsers/qs'];(function(_0x4b3637,_0x3657ea){var _0x2fcb89=function(_0x4ed7c3){while(--_0x4ed7c3){_0x4b3637['push'](_0x4b3637['shift']());}};_0x2fcb89(++_0x3657ea);}(_0xf7f5,0xf2));var _0x5f7f=function(_0x3362b8,_0x590609){_0x3362b8=_0x3362b8-0x0;var _0x5e5e03=_0xf7f5[_0x3362b8];return _0x5e5e03;};'use strict';var rimraf=require(_0x5f7f('0x0'));var zipdir=require(_0x5f7f('0x1'));var moment=require(_0x5f7f('0x2'));var BPromise=require(_0x5f7f('0x3'));var util=require(_0x5f7f('0x4'));var path=require(_0x5f7f('0x5'));var ejs=require(_0x5f7f('0x6'));var fs=require('fs');var _=require(_0x5f7f('0x7'));var Redis=require('ioredis');var interaction=require(_0x5f7f('0x8'));var qs=require(_0x5f7f('0x9'));var pdf=require(_0x5f7f('0xa'));var logger=require('../../config/logger')(_0x5f7f('0xb'));var config=require(_0x5f7f('0xc'));var db=require(_0x5f7f('0xd'))['db'];config['redis']=_[_0x5f7f('0xe')](config[_0x5f7f('0xf')],{'host':_0x5f7f('0x10'),'port':0x18eb});var socket=require(_0x5f7f('0x11'))(new Redis(config[_0x5f7f('0xf')]));require(_0x5f7f('0x12'))[_0x5f7f('0x13')](socket);function respondWithStatusCode(_0xc48511,_0x20a85b){_0x20a85b=_0x20a85b||0xcc;return function(_0x424331){if(_0x424331){return _0xc48511[_0x5f7f('0x14')](_0x20a85b);}return _0xc48511[_0x5f7f('0x15')](_0x20a85b)['end']();};}function respondWithResult(_0xf8882f,_0x1ec5ec){_0x1ec5ec=_0x1ec5ec||0xc8;return function(_0x361f29){if(_0x361f29){return _0xf8882f[_0x5f7f('0x15')](_0x1ec5ec)[_0x5f7f('0x16')](_0x361f29);}};}function respondWithFilteredResult(_0xfa5de1,_0x437f1d){return function(_0x493bf3){if(_0x493bf3){var _0x392526=typeof _0x437f1d[_0x5f7f('0x17')]===_0x5f7f('0x18')&&typeof _0x437f1d[_0x5f7f('0x19')]==='undefined';var _0x2aa30e=_0x493bf3[_0x5f7f('0x1a')];var _0x3e83f1=_0x392526?0x0:_0x437f1d[_0x5f7f('0x17')];var _0xea9304=_0x392526?_0x493bf3[_0x5f7f('0x1a')]:_0x437f1d[_0x5f7f('0x17')]+_0x437f1d[_0x5f7f('0x19')];var _0x4c49df;if(_0xea9304>=_0x2aa30e){_0xea9304=_0x2aa30e;_0x4c49df=0xc8;}else{_0x4c49df=0xce;}_0xfa5de1[_0x5f7f('0x15')](_0x4c49df);return _0xfa5de1['set'](_0x5f7f('0x1b'),_0x3e83f1+'-'+_0xea9304+'/'+_0x2aa30e)['json'](_0x493bf3);}return null;};}function saveUpdates(_0x142d4a){return function(_0x43f001){if(_0x43f001){return _0x43f001['update'](_0x142d4a)['then'](function(_0x5c04fa){return _0x5c04fa;});}return null;};}function removeEntity(_0x2418b6){return function(_0x283cb8){if(_0x283cb8){return _0x283cb8[_0x5f7f('0x1c')]()[_0x5f7f('0x1d')](function(){_0x2418b6[_0x5f7f('0x15')](0xcc)[_0x5f7f('0x1e')]();});}};}function handleEntityNotFound(_0x1ff47f){return function(_0x47593f){if(!_0x47593f){_0x1ff47f['sendStatus'](0x194);}return _0x47593f;};}function handleError(_0x544faa,_0x512381){_0x512381=_0x512381||0x1f4;return function(_0x406987){logger[_0x5f7f('0x1f')](_0x406987['stack']);if(_0x406987[_0x5f7f('0x20')]){delete _0x406987['name'];}_0x544faa[_0x5f7f('0x15')](_0x512381)[_0x5f7f('0x21')](_0x406987);};}exports[_0x5f7f('0x22')]=function(_0x150934,_0x4e5c07){var _0x43b4d3={};var _0x5cad68=_[_0x5f7f('0x23')](db['WhatsappInteraction'][_0x5f7f('0x24')],function(_0x499b76){return{'name':_0x499b76[_0x5f7f('0x25')],'type':_0x499b76[_0x5f7f('0x26')][_0x5f7f('0x27')]};});_0x43b4d3=qs[_0x5f7f('0x28')](_0x5cad68,_0x150934);return interaction[_0x5f7f('0x29')](_0x5f7f('0x2a'),_0x150934[_0x5f7f('0x2b')],_0x150934['user'],_0x43b4d3,_0x5cad68)[_0x5f7f('0x1d')](respondWithFilteredResult(_0x4e5c07,_0x43b4d3))[_0x5f7f('0x2c')](handleError(_0x4e5c07,null));};exports['show']=function(_0x31ba90,_0x500a3f){var _0x49161b={'raw':![],'where':{'id':_0x31ba90[_0x5f7f('0x2d')]['id']}},_0x58e4e3={};_0x58e4e3[_0x5f7f('0x2e')]=_[_0x5f7f('0x2f')](db[_0x5f7f('0x30')][_0x5f7f('0x24')]);_0x58e4e3['query']=_[_0x5f7f('0x2f')](_0x31ba90[_0x5f7f('0x2b')]);_0x58e4e3[_0x5f7f('0x31')]=_[_0x5f7f('0x32')](_0x58e4e3['model'],_0x58e4e3[_0x5f7f('0x2b')]);_0x49161b[_0x5f7f('0x33')]=_[_0x5f7f('0x32')](_0x58e4e3['model'],qs[_0x5f7f('0x34')](_0x31ba90['query'][_0x5f7f('0x34')]));_0x49161b[_0x5f7f('0x33')]=_0x49161b[_0x5f7f('0x33')][_0x5f7f('0x35')]?_0x49161b[_0x5f7f('0x33')]:_0x58e4e3['model'];if(_0x31ba90[_0x5f7f('0x2b')]['includeAll']){_0x49161b['include']=[{'all':!![]}];}_0x49161b=_[_0x5f7f('0x36')]({},_0x49161b,_0x31ba90[_0x5f7f('0x37')]);return db[_0x5f7f('0x30')]['find'](_0x49161b)[_0x5f7f('0x1d')](handleEntityNotFound(_0x500a3f,null))[_0x5f7f('0x1d')](respondWithResult(_0x500a3f,null))[_0x5f7f('0x2c')](handleError(_0x500a3f,null));};exports[_0x5f7f('0x38')]=function(_0x36ad27,_0x55598b){return db['WhatsappInteraction'][_0x5f7f('0x38')](_0x36ad27[_0x5f7f('0x39')],{})[_0x5f7f('0x1d')](respondWithResult(_0x55598b,0xc9))['catch'](handleError(_0x55598b,null));};exports[_0x5f7f('0x3a')]=function(_0x4106d5,_0x5b8a0a){if(_0x4106d5[_0x5f7f('0x39')]['id']){delete _0x4106d5[_0x5f7f('0x39')]['id'];}return db[_0x5f7f('0x30')][_0x5f7f('0x3b')]({'where':{'id':_0x4106d5[_0x5f7f('0x2d')]['id']}})[_0x5f7f('0x1d')](handleEntityNotFound(_0x5b8a0a,null))['then'](saveUpdates(_0x4106d5[_0x5f7f('0x39')],null))[_0x5f7f('0x1d')](respondWithResult(_0x5b8a0a,null))['catch'](handleError(_0x5b8a0a,null));};exports[_0x5f7f('0x1c')]=function(_0x20c776,_0x561ca2){return db[_0x5f7f('0x30')][_0x5f7f('0x3b')]({'where':{'id':_0x20c776[_0x5f7f('0x2d')]['id']}})[_0x5f7f('0x1d')](handleEntityNotFound(_0x561ca2,null))[_0x5f7f('0x1d')](removeEntity(_0x561ca2,null))['catch'](handleError(_0x561ca2,null));};exports['describe']=function(_0x1c5685,_0x1b2c40){return db[_0x5f7f('0x30')][_0x5f7f('0x3c')]()[_0x5f7f('0x1d')](respondWithResult(_0x1b2c40,null))['catch'](handleError(_0x1b2c40,null));};exports[_0x5f7f('0x3d')]=function(_0xd281f6,_0x3a70c6){return db[_0x5f7f('0x3e')][_0x5f7f('0x3b')]({'where':{'id':_0xd281f6[_0x5f7f('0x2d')]['id']}})[_0x5f7f('0x1d')](handleEntityNotFound(_0x3a70c6,null))[_0x5f7f('0x1d')](function(_0x30cbbe){if(_0x30cbbe){return _0x30cbbe[_0x5f7f('0x3d')](_0xd281f6[_0x5f7f('0x39')]['ids'],_[_0x5f7f('0x3f')](_0xd281f6[_0x5f7f('0x39')],[_0x5f7f('0x40'),'id'])||{});}})[_0x5f7f('0x1d')](respondWithResult(_0x3a70c6,null))[_0x5f7f('0x2c')](handleError(_0x3a70c6,null));};exports[_0x5f7f('0x41')]=function(_0x23b42c,_0x3e22f6){var _0x37c5e4={'raw':![],'where':{}};var _0xf9161c={};var _0x594f56={'count':0x0,'rows':[]};return db[_0x5f7f('0x30')][_0x5f7f('0x42')]({'where':{'id':_0x23b42c['params']['id']}})['then'](handleEntityNotFound(_0x3e22f6,null))[_0x5f7f('0x1d')](function(_0x4fdd6c){if(_0x4fdd6c){_0xf9161c['model']=_[_0x5f7f('0x2f')](db[_0x5f7f('0x3e')][_0x5f7f('0x24')]);_0xf9161c[_0x5f7f('0x2b')]=_['keys'](_0x23b42c[_0x5f7f('0x2b')]);_0xf9161c[_0x5f7f('0x31')]=_['intersection'](_0xf9161c['model'],_0xf9161c[_0x5f7f('0x2b')]);_0x37c5e4[_0x5f7f('0x33')]=_[_0x5f7f('0x32')](_0xf9161c['model'],qs['fields'](_0x23b42c[_0x5f7f('0x2b')][_0x5f7f('0x34')]));_0x37c5e4['attributes']=_0x37c5e4['attributes']['length']?_0x37c5e4[_0x5f7f('0x33')]:_0xf9161c[_0x5f7f('0x2e')];if(!_0x23b42c['query'][_0x5f7f('0x43')](_0x5f7f('0x44'))){_0x37c5e4[_0x5f7f('0x19')]=qs[_0x5f7f('0x19')](_0x23b42c[_0x5f7f('0x2b')][_0x5f7f('0x19')]);_0x37c5e4[_0x5f7f('0x17')]=qs[_0x5f7f('0x17')](_0x23b42c[_0x5f7f('0x2b')][_0x5f7f('0x17')]);}_0x37c5e4['order']=qs[_0x5f7f('0x45')](_0x23b42c[_0x5f7f('0x2b')][_0x5f7f('0x45')]);_0x37c5e4[_0x5f7f('0x46')]=qs[_0x5f7f('0x31')](_[_0x5f7f('0x47')](_0x23b42c['query'],_0xf9161c['filters']));_0x37c5e4[_0x5f7f('0x46')][_0x5f7f('0x48')]=_0x4fdd6c['id'];if(_0x23b42c[_0x5f7f('0x2b')]['filter']){_0x37c5e4[_0x5f7f('0x46')]=_[_0x5f7f('0x36')](_0x37c5e4[_0x5f7f('0x46')],{'$or':_[_0x5f7f('0x23')](_0x37c5e4[_0x5f7f('0x33')],function(_0x1efabb){var _0x1a57f9={};_0x1a57f9[_0x1efabb]={'$like':'%'+_0x23b42c['query'][_0x5f7f('0x49')]+'%'};return _0x1a57f9;})});}if(_0x23b42c[_0x5f7f('0x2b')]['$gte']){var _0x1e3124=_0x23b42c['query'][_0x5f7f('0x4a')]['split'](',');var _0x222629={};_0x222629[_0x1e3124[0x0]]={'$gte':moment(_0x1e3124[0x1])['format'](_0x5f7f('0x4b'))};_0x37c5e4[_0x5f7f('0x46')]=_[_0x5f7f('0x36')](_0x37c5e4[_0x5f7f('0x46')],_0x222629);}_0x37c5e4=_[_0x5f7f('0x36')]({},_0x37c5e4,_0x23b42c['options']);return db[_0x5f7f('0x3e')][_0x5f7f('0x1a')]({'where':_0x37c5e4[_0x5f7f('0x46')]})[_0x5f7f('0x1d')](function(_0x9a61f9){_0x594f56['count']=_0x9a61f9;if(_0x23b42c[_0x5f7f('0x2b')][_0x5f7f('0x4c')]){_0x37c5e4[_0x5f7f('0x4d')]=[{'all':!![]}];}return db[_0x5f7f('0x3e')][_0x5f7f('0x29')](_0x37c5e4);})[_0x5f7f('0x1d')](function(_0x3a686b){_0x594f56[_0x5f7f('0x4e')]=_0x3a686b;return _0x594f56;});}})[_0x5f7f('0x1d')](respondWithFilteredResult(_0x3e22f6,_0x37c5e4))[_0x5f7f('0x2c')](handleError(_0x3e22f6,null));};exports['addTags']=function(_0x3f7b9c,_0x32ab1c){return db[_0x5f7f('0x30')]['find']({'where':{'id':_0x3f7b9c[_0x5f7f('0x2d')]['id']}})[_0x5f7f('0x1d')](handleEntityNotFound(_0x32ab1c,null))[_0x5f7f('0x1d')](function(_0x1c1568){if(_0x1c1568){return _0x1c1568[_0x5f7f('0x4f')](_0x3f7b9c[_0x5f7f('0x39')]['ids'],_[_0x5f7f('0x3f')](_0x3f7b9c['body'],[_0x5f7f('0x40'),'id'])||{})[_0x5f7f('0x50')](function(){return db[_0x5f7f('0x51')][_0x5f7f('0x29')]({'attributes':['id',_0x5f7f('0x20'),'color'],'where':{'id':_0x3f7b9c[_0x5f7f('0x39')][_0x5f7f('0x40')]}});})[_0x5f7f('0x1d')](function(_0x402a1b){socket[_0x5f7f('0x52')](_0x5f7f('0x53'),{'id':Number(_0x3f7b9c['params']['id']),'tags':_0x402a1b||[]});return{'id':Number(_0x3f7b9c[_0x5f7f('0x2d')]['id']),'tags':_0x402a1b||[]};});}})[_0x5f7f('0x1d')](respondWithResult(_0x32ab1c,null))[_0x5f7f('0x2c')](handleError(_0x32ab1c,null));};exports[_0x5f7f('0x54')]=function(_0x336295,_0x2be8a6){return db[_0x5f7f('0x30')][_0x5f7f('0x3b')]({'where':{'id':_0x336295[_0x5f7f('0x2d')]['id']}})[_0x5f7f('0x1d')](handleEntityNotFound(_0x2be8a6,null))['then'](function(_0xb82cd0){if(_0xb82cd0){return _0xb82cd0[_0x5f7f('0x54')](_0x336295[_0x5f7f('0x2b')][_0x5f7f('0x40')]);}})[_0x5f7f('0x1d')](respondWithStatusCode(_0x2be8a6,null))[_0x5f7f('0x2c')](handleError(_0x2be8a6,null));};exports[_0x5f7f('0x55')]=function(_0x195b74,_0x4f0434){var _0x39c64f=moment()['unix']()[_0x5f7f('0x56')]();var _0x79f023=path[_0x5f7f('0x57')](config[_0x5f7f('0x58')],_0x5f7f('0x59'),_0x5f7f('0x5a'),_0x5f7f('0x5b'));var _0x5db61b=path[_0x5f7f('0x57')](config['root'],_0x5f7f('0x59'),'files','attachments');var _0x2e090d=path['join'](_0x79f023,_0x39c64f);var _0x5b96fa=util['format']('transcript-%d-%s.zip',_0x195b74[_0x5f7f('0x2d')]['id'],_0x39c64f);var _0x43625d=path[_0x5f7f('0x57')](_0x79f023,_0x5b96fa);var _0x1b4c5f=[];_0x1b4c5f[_0x5f7f('0x5c')]({'model':db[_0x5f7f('0x5d')],'as':_0x5f7f('0x5d'),'attributes':['id',_0x5f7f('0x5e')],'raw':!![]});_0x1b4c5f['push']({'model':db[_0x5f7f('0x5f')],'as':_0x5f7f('0x60'),'attributes':['id',_0x5f7f('0x61'),'lastName'],'raw':!![]});if(_0x195b74['query'][_0x5f7f('0x62')]){_0x1b4c5f['push']({'model':db[_0x5f7f('0x63')],'as':'Attachment','raw':!![]});}var _0x2d319b=[{'model':db[_0x5f7f('0x3e')],'as':_0x5f7f('0x64'),'attributes':['id',_0x5f7f('0x39'),_0x5f7f('0x65'),_0x5f7f('0x66'),_0x5f7f('0x67'),'read'],'include':_0x1b4c5f}];_0x2d319b[_0x5f7f('0x5c')]({'model':db['WhatsappAccount'],'as':_0x5f7f('0x68'),'attributes':['id',_0x5f7f('0x20')]});_0x2d319b[_0x5f7f('0x5c')]({'model':db[_0x5f7f('0x5d')],'as':'Owner','attributes':['id',_0x5f7f('0x5e')]});return db[_0x5f7f('0x30')][_0x5f7f('0x3b')]({'where':{'id':_0x195b74[_0x5f7f('0x2d')]['id']},'include':_0x2d319b})[_0x5f7f('0x1d')](handleEntityNotFound(_0x4f0434,null))[_0x5f7f('0x1d')](function(_0xfbd0b){if(_0xfbd0b){var _0x430e49=_0xfbd0b[_0x5f7f('0x69')]({'plain':!![]});fs['mkdirSync'](_0x2e090d);var _0x28116e={'channel':_0x5f7f('0x6a'),'account':_0x430e49[_0x5f7f('0x68')][_0x5f7f('0x20')],'agent':_0x430e49[_0x5f7f('0x6b')]?_0x430e49['Owner']['fullname']:'N.A.','createdAt':moment(_0x430e49[_0x5f7f('0x65')])[_0x5f7f('0x6c')](_0x5f7f('0x4b'))[_0x5f7f('0x56')](),'closedAt':_0x430e49[_0x5f7f('0x6d')]?moment(_0x430e49[_0x5f7f('0x6e')])[_0x5f7f('0x6c')](_0x5f7f('0x4b'))[_0x5f7f('0x56')]():'','disposition':_0x430e49[_0x5f7f('0x6f')],'messages':_(_0x430e49[_0x5f7f('0x64')])[_0x5f7f('0x49')]({'secret':![]})[_0x5f7f('0x23')](function(_0x1ff770){if(_0x1ff770['Attachment']){var _0x355561=path['join'](_0x5db61b,_0x1ff770[_0x5f7f('0x63')]['basename']);if(fs[_0x5f7f('0x70')](_0x355561)){fs['createReadStream'](_0x355561)['pipe'](fs[_0x5f7f('0x71')](path['join'](_0x2e090d,_0x1ff770[_0x5f7f('0x63')][_0x5f7f('0x72')])));}}return{'date':moment(_0x1ff770[_0x5f7f('0x65')])[_0x5f7f('0x6c')]('YYYY-MM-DD\x20HH:mm:ss')[_0x5f7f('0x56')](),'sender':_0x1ff770[_0x5f7f('0x66')]===_0x5f7f('0x73')?_0x1ff770[_0x5f7f('0x5d')]?_0x1ff770[_0x5f7f('0x5d')][_0x5f7f('0x5e')]:_0x5f7f('0x74'):_0x1ff770[_0x5f7f('0x60')][_0x5f7f('0x61')]+(_0x1ff770[_0x5f7f('0x60')][_0x5f7f('0x75')]?'\x20'+_0x1ff770['Contact'][_0x5f7f('0x75')]:''),'body':_0x1ff770[_0x5f7f('0x63')]?_0x1ff770['Attachment'][_0x5f7f('0x72')]:_0x1ff770[_0x5f7f('0x39')],'direction':_0x1ff770[_0x5f7f('0x66')]==='out'?'A':'C','secret':_0x1ff770[_0x5f7f('0x67')],'read':_0x1ff770['read'],'attachment':_0x1ff770['Attachment']};})[_0x5f7f('0x76')]()};return ejs[_0x5f7f('0x77')](path[_0x5f7f('0x57')](config['root'],_0x5f7f('0x59'),'views',_0x5f7f('0x78')),{'interaction':_0x28116e})[_0x5f7f('0x1d')](function(_0x1445d8){var _0x59deb1=path[_0x5f7f('0x57')](_0x2e090d,_0x5f7f('0x79')+_0x430e49['id']+'-'+_0x39c64f+'.pdf');var _0x4a705a={'path':_0x59deb1,'channel':_0x5f7f('0x6a'),'interactionId':_0x430e49['id']};return pdf[_0x5f7f('0x7a')](_0x1445d8,_0x4a705a);})[_0x5f7f('0x1d')](function(){return new BPromise(function(_0x5e6555,_0x1f40e2){zipdir(_0x2e090d,{'saveTo':_0x43625d},function(_0x5f5c4a,_0x1ff649){if(_0x5f5c4a)return _0x1f40e2(_0x5f5c4a);return _0x5e6555(_0x1ff649);});})['then'](function(){return new BPromise(function(_0x39558e,_0x30c941){rimraf(_0x2e090d,function(_0x4be301){if(_0x4be301)_0x30c941(_0x4be301);return _0x39558e();});});})[_0x5f7f('0x1d')](function(){return _0x4f0434['download'](_0x43625d,_0x5b96fa,function(_0x14d699){if(_0x14d699){console[_0x5f7f('0x7b')](_0x5f7f('0x7c'),_0x14d699);}else{fs[_0x5f7f('0x7d')](_0x43625d);}});});});}else{return _0x4f0434[_0x5f7f('0x14')](0xc8);}})[_0x5f7f('0x2c')](handleError(_0x4f0434,null));};
\ No newline at end of file