Built motion from commit 9d1906d1.|2.5.40
[motion2.git] / server / api / mailInteraction / mailInteraction.controller.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
13 // * The SOFTWARE PRODUCT is protected by copyright laws and international *
14 // * copyright treaties, as well as other intellectual property laws and   *
15 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                         *
16 // *                                                                       *
17 // *************************************************************************
18 var _0xc1fc=['search','sqlOperator','conditions','value','`\x20=\x200','having','operator','$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','buildExpression','text','start','end','union','User','CONCAT_WS(\x27\x20\x27,\x20o.name,\x20o.fullname)\x20LIKE\x20?','find','some','compact','isEmpty','i.MailAccountId\x20IN\x20?','concat','createdAt','parse','$gte','$lte','i.createdAt\x20BETWEEN\x20?\x20AND\x20?','null','\x20IS\x20NULL','\x20=\x20?','read','`unreadMessages`\x20=\x200','`unreadMessages`\x20>\x200','tag','isArray','CONCAT(\x27,\x27,\x20`TagIds`,\x20\x27,\x27)\x20LIKE\x20?','filter','replace','isNumeric','i.id\x20LIKE\x20?','c.email\x20LIKE\x20?','MATCH\x20(me.plainBody,\x20me.subject)\x20AGAINST\x20(?\x20IN\x20BOOLEAN\x20MODE)','group','i.id','Sequelize','QueryTypes','SELECT','SUM(me.read\x20=\x200\x20AND\x20me.direction\x20=\x20\x27in\x27)','unreadMessages','contactName','DESC','resolve','i.MailAccountId\x20IS\x20NOT\x20NULL','user','role','agent','getMailAccounts','i.MailAccountId\x20IS\x20NULL','MailAccountId','sequelize','toString','keyBy','merge','a.key','Account.key','a.mandatoryDisposition','Account.mandatoryDisposition','CASE\x20WHEN\x20i.to\x20IS\x20NOT\x20NULL\x20AND\x20i.to\x20<>\x20\x27\x27\x20AND\x20i.to\x20NOT\x20LIKE\x20(\x27%\x27\x20+\x20a.email\x20+\x20\x27%\x27)\x20THEN\x20SUBSTRING_INDEX(i.to,\x20\x27<\x27,\x201)\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','i.createdAt','i.updatedAt','i.closed','i.closedAt','i.attach','i.lastMsgAt','i.lastMsgDirection','i.disposition','i.secondDisposition','i.thirdDisposition','i.to','i.ContactId','i.MailAccountId','i.UserId','c.firstName','Contact.firstName','c.lastName','Contact.lastName','Contact.email','c.phone','Contact.phone','c.fax','Contact.fax','o.fullname','Owner.fullname','o.internal','Owner.internal','GROUP_CONCAT(DISTINCT\x20t.id)','groupBy','MailInteractionId','Setting','enableEmailPreview','rows','show','params','includeAll','include','options','create','body','describe','ids','omit','pick','YYYY-MM-DD\x20HH:mm:ss','inlineCss','true','setTags','spread','Tag','findAll','mailInteractionTags:save','removeTags','download','unix','server','files','tmp','join','attachments','format','transcript-%d-%s.zip','Attachment','Attachments','Messages','bcc','mkdirSync','subject','headers','Bcc','basename','readFileSync','build','writeFileSync','message%d.eml','unlinkSync','rimraf','zip-dir','bluebird','util','path','lodash','squel','juice','ioredis','../../components/parsers/qs','api','../../config/environment','../../mysqldb','html-entities','redis','socket.io-emitter','./mailInteraction.socket','register','sendStatus','status','json','offset','undefined','limit','count','Content-Range','update','destroy','then','stack','name','send','Users','map','fullname','TagIds','Tags','split','forEach','push','MailMessage','findOne','-id','plainBody','lastMsgText','trimStart','catch','waiting','talking','total','closed','UserId','answered','index','MailInteraction','rawAttributes','type','key','model','keys','filters','intersection','attributes','fields','query','length','hasOwnProperty','nolimit','order','sort','where','select','field','color','tools_tags','u.id','u.fullname','ui.MailInteractionId','from','user_has_mail_interactions','left_join','users','u.id\x20=\x20ui.UserId','mail_interactions','cm_contacts','c.id\x20=\x20i.ContactId\x20AND\x20c.deletedAt\x20IS\x20NULL','o.id\x20=\x20i.UserId','mail_accounts','a.id\x20=\x20i.MailAccountId','mail_messages','me.MailInteractionId\x20=\x20i.id','mail_interaction_has_tags','it.MailInteractionId\x20=\x20i.id','expr','parseSearch'];(function(_0x594e06,_0x27a143){var _0x4c9d4b=function(_0x48ae24){while(--_0x48ae24){_0x594e06['push'](_0x594e06['shift']());}};_0x4c9d4b(++_0x27a143);}(_0xc1fc,0x93));var _0xcc1f=function(_0x5cbe45,_0x43a958){_0x5cbe45=_0x5cbe45-0x0;var _0x2e64ab=_0xc1fc[_0x5cbe45];return _0x2e64ab;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0xcc1f('0x0'));var zipdir=require(_0xcc1f('0x1'));var moment=require('moment');var BPromise=require(_0xcc1f('0x2'));var util=require(_0xcc1f('0x3'));var path=require(_0xcc1f('0x4'));var fs=require('fs');var _=require(_0xcc1f('0x5'));var squel=require(_0xcc1f('0x6'));var juice=require(_0xcc1f('0x7'));var Redis=require(_0xcc1f('0x8'));var qs=require(_0xcc1f('0x9'));var as=require('../../components/parsers/advancedSearch');var logger=require('../../config/logger')(_0xcc1f('0xa'));var config=require(_0xcc1f('0xb'));var db=require(_0xcc1f('0xc'))['db'];var htmlEntities=require(_0xcc1f('0xd'));config[_0xcc1f('0xe')]=_['defaults'](config['redis'],{'host':'localhost','port':0x18eb});var socket=require(_0xcc1f('0xf'))(new Redis(config[_0xcc1f('0xe')]));require(_0xcc1f('0x10'))[_0xcc1f('0x11')](socket);function respondWithStatusCode(_0x3a2625,_0x2f435a){_0x2f435a=_0x2f435a||0xcc;return function(_0x2aa49d){if(_0x2aa49d){return _0x3a2625[_0xcc1f('0x12')](_0x2f435a);}return _0x3a2625[_0xcc1f('0x13')](_0x2f435a)['end']();};}function respondWithResult(_0x232b09,_0x36dd19){_0x36dd19=_0x36dd19||0xc8;return function(_0x1807b0){if(_0x1807b0){return _0x232b09[_0xcc1f('0x13')](_0x36dd19)[_0xcc1f('0x14')](_0x1807b0);}};}function respondWithFilteredResult(_0x38d746,_0x2f237b){return function(_0x4a9723){if(_0x4a9723){var _0xf0ba72=typeof _0x2f237b[_0xcc1f('0x15')]===_0xcc1f('0x16')&&typeof _0x2f237b[_0xcc1f('0x17')]===_0xcc1f('0x16');var _0x307249=_0x4a9723[_0xcc1f('0x18')];var _0xde5222=_0xf0ba72?0x0:_0x2f237b[_0xcc1f('0x15')];var _0x7bad52=_0xf0ba72?_0x4a9723['count']:_0x2f237b['offset']+_0x2f237b[_0xcc1f('0x17')];var _0x10648f;if(_0x7bad52>=_0x307249){_0x7bad52=_0x307249;_0x10648f=0xc8;}else{_0x10648f=0xce;}_0x38d746[_0xcc1f('0x13')](_0x10648f);return _0x38d746['set'](_0xcc1f('0x19'),_0xde5222+'-'+_0x7bad52+'/'+_0x307249)['json'](_0x4a9723);}return null;};}function saveUpdates(_0x50c6ab){return function(_0xecece8){if(_0xecece8){return _0xecece8[_0xcc1f('0x1a')](_0x50c6ab)['then'](function(_0x1a17e8){return _0x1a17e8;});}return null;};}function removeEntity(_0x3a3a43){return function(_0x218066){if(_0x218066){return _0x218066[_0xcc1f('0x1b')]()[_0xcc1f('0x1c')](function(){_0x3a3a43[_0xcc1f('0x13')](0xcc)['end']();});}};}function handleEntityNotFound(_0x289c8){return function(_0x54b934){if(!_0x54b934){_0x289c8[_0xcc1f('0x12')](0x194);}return _0x54b934;};}function handleError(_0x310c2e,_0x1a00d4){_0x1a00d4=_0x1a00d4||0x1f4;return function(_0xde8dfe){logger['error'](_0xde8dfe[_0xcc1f('0x1d')]);if(_0xde8dfe[_0xcc1f('0x1e')]){delete _0xde8dfe[_0xcc1f('0x1e')];}_0x310c2e[_0xcc1f('0x13')](_0x1a00d4)[_0xcc1f('0x1f')](_0xde8dfe);};}function getInteractionUsers(_0x16ec06,_0x1f04c1){return new BPromise(function(_0x4e9cdb,_0x1939aa){try{if(_0x1f04c1[_0x16ec06['id']]){_0x16ec06[_0xcc1f('0x20')]=_[_0xcc1f('0x21')](_0x1f04c1[_0x16ec06['id']],function(_0x30a6fc){return{'id':_0x30a6fc['id'],'fullname':_0x30a6fc[_0xcc1f('0x22')]};});}}catch(_0x3d6c06){_0x1939aa(_0x3d6c06);}_0x4e9cdb(_0x16ec06);});}function getInteractionTags(_0x1d4739,_0x160d78){return new BPromise(function(_0x5457a3,_0x4461d5){try{if(_0x1d4739[_0xcc1f('0x23')]){_0x1d4739[_0xcc1f('0x24')]=[];_0x1d4739[_0xcc1f('0x23')][_0xcc1f('0x25')](',')[_0xcc1f('0x26')](function(_0x506d47){_0x1d4739[_0xcc1f('0x24')][_0xcc1f('0x27')](_0x160d78[_0x506d47]);});}delete _0x1d4739['TagIds'];}catch(_0x3bd35c){_0x4461d5(_0x3bd35c);}_0x5457a3(_0x1d4739);});}function getLastMessageText(_0x5055c3){return new BPromise(function(_0x78c04f,_0xf573ba){return db[_0xcc1f('0x28')][_0xcc1f('0x29')]({'where':{'$and':[{'MailInteractionId':_0x5055c3['id']},{'$or':[{'direction':'in'},{'$and':[{'direction':'out'},{'secret':![]},{'UserId':{'$ne':null}}]}]}]},'attributes':['plainBody'],'order':_0xcc1f('0x2a'),'raw':!![]})[_0xcc1f('0x1c')](function(_0x5e377f){if(_0x5e377f&&_0x5e377f[_0xcc1f('0x2b')]){_0x5055c3[_0xcc1f('0x2c')]=_[_0xcc1f('0x2d')](_0x5e377f[_0xcc1f('0x2b')]);}_0x78c04f(_0x5055c3);})['catch'](function(_0x329a71){_0xf573ba(_0x329a71);});});}function updateMailInteraction(_0x4370ad,_0x17cda4,_0x4bdff5,_0x15c647){return new BPromise(function(_0x393ba7,_0x677677){return getInteractionUsers(_0x4370ad,_0x4bdff5)[_0xcc1f('0x1c')](function(_0x2e0db2){return getInteractionTags(_0x2e0db2,_0x17cda4);})[_0xcc1f('0x1c')](function(_0x19f03b){return getStateInteraction(_0x19f03b);})[_0xcc1f('0x1c')](function(_0x4d4f25){if(_0x15c647){_0x393ba7(getLastMessageText(_0x4d4f25));}else{_0x393ba7(_0x4d4f25);}})[_0xcc1f('0x2e')](function(_0x38e866){_0x677677(_0x38e866);});});}function getStateInteraction(_0x56606f){return new BPromise(function(_0x2a5646){_0x56606f[_0xcc1f('0x2f')]=0x0;_0x56606f[_0xcc1f('0x30')]=0x0;_0x56606f['answered']=0x0;_0x56606f['unmanaged']=0x0;_0x56606f[_0xcc1f('0x31')]=0x0;if(!_0x56606f[_0xcc1f('0x32')]&&!_0x56606f[_0xcc1f('0x33')]){_0x56606f['waiting']+=0x1;}if(!_0x56606f[_0xcc1f('0x32')]&&_0x56606f[_0xcc1f('0x33')]){_0x56606f[_0xcc1f('0x30')]+=0x1;if(_0x56606f[_0xcc1f('0x2f')]){_0x56606f[_0xcc1f('0x2f')]-=0x1;}}if(_0x56606f[_0xcc1f('0x32')]&&_0x56606f[_0xcc1f('0x33')]){_0x56606f[_0xcc1f('0x34')]+=0x1;if(_0x56606f[_0xcc1f('0x30')]){_0x56606f[_0xcc1f('0x30')]-=0x1;}}if(_0x56606f[_0xcc1f('0x32')]&&!_0x56606f['UserId']){_0x56606f['unmanaged']+=0x1;if(_0x56606f['waiting']){_0x56606f[_0xcc1f('0x2f')]-=0x1;}}_0x56606f[_0xcc1f('0x31')]+=0x1;_0x2a5646(_0x56606f);});}exports[_0xcc1f('0x35')]=function(_0x332139,_0x43d933){var _0x3d0c4f={},_0x25a287={},_0x1dd624={'count':0x0,'rows':[]};var _0x6337d8=_[_0xcc1f('0x21')](db[_0xcc1f('0x36')][_0xcc1f('0x37')],function(_0x416146){return{'name':_0x416146['fieldName'],'type':_0x416146[_0xcc1f('0x38')][_0xcc1f('0x39')]};});_0x25a287[_0xcc1f('0x3a')]=_[_0xcc1f('0x21')](_0x6337d8,'name');_0x25a287['query']=_[_0xcc1f('0x3b')](_0x332139['query']);_0x25a287[_0xcc1f('0x3c')]=_[_0xcc1f('0x3d')](_0x25a287[_0xcc1f('0x3a')],_0x25a287['query']);_0x3d0c4f[_0xcc1f('0x3e')]=_[_0xcc1f('0x3d')](_0x25a287['model'],qs[_0xcc1f('0x3f')](_0x332139[_0xcc1f('0x40')]['fields']));_0x3d0c4f['attributes']=_0x3d0c4f[_0xcc1f('0x3e')][_0xcc1f('0x41')]?_0x3d0c4f['attributes']:_0x25a287[_0xcc1f('0x3a')];if(!_0x332139[_0xcc1f('0x40')][_0xcc1f('0x42')](_0xcc1f('0x43'))){_0x3d0c4f[_0xcc1f('0x17')]=qs['limit'](_0x332139['query'][_0xcc1f('0x17')]);_0x3d0c4f[_0xcc1f('0x15')]=qs[_0xcc1f('0x15')](_0x332139[_0xcc1f('0x40')][_0xcc1f('0x15')]);}_0x3d0c4f[_0xcc1f('0x44')]=qs['sort'](_0x332139[_0xcc1f('0x40')][_0xcc1f('0x45')]);_0x3d0c4f[_0xcc1f('0x46')]=qs[_0xcc1f('0x3c')](_['pick'](_0x332139[_0xcc1f('0x40')],_0x25a287['filters']),_0x6337d8);var _0x15aadd=[];var _0x396859=squel[_0xcc1f('0x47')]()['field']('id')[_0xcc1f('0x48')](_0xcc1f('0x1e'))[_0xcc1f('0x48')](_0xcc1f('0x49'))['from'](_0xcc1f('0x4a'));var _0x781a9b=squel['select']()['field'](_0xcc1f('0x4b'))[_0xcc1f('0x48')](_0xcc1f('0x4c'))['field'](_0xcc1f('0x4d'))[_0xcc1f('0x4e')](_0xcc1f('0x4f'),'ui')[_0xcc1f('0x50')](_0xcc1f('0x51'),'u',_0xcc1f('0x52'));var _0x4efa0b=squel[_0xcc1f('0x47')]()['from'](_0xcc1f('0x53'),'i')[_0xcc1f('0x50')](_0xcc1f('0x54'),'c',_0xcc1f('0x55'))['left_join'](_0xcc1f('0x51'),'o',_0xcc1f('0x56'))[_0xcc1f('0x50')](_0xcc1f('0x57'),'a',_0xcc1f('0x58'))[_0xcc1f('0x50')](_0xcc1f('0x59'),'me',_0xcc1f('0x5a'))[_0xcc1f('0x50')](_0xcc1f('0x5b'),'it',_0xcc1f('0x5c'))[_0xcc1f('0x50')]('tools_tags','t','t.id\x20=\x20it.TagId');var _0x3b6d1e=squel[_0xcc1f('0x5d')]();var _0x5694a4=[];var _0x53aaff=squel[_0xcc1f('0x5d')]();var _0x3f9b1a;if(_0x332139[_0xcc1f('0x40')]['search']){_0x3f9b1a=as[_0xcc1f('0x5e')](_0x332139[_0xcc1f('0x40')][_0xcc1f('0x5f')]);var _0x30405b=_0x3f9b1a[_0xcc1f('0x60')];for(var _0x57807a=0x0;_0x57807a<_0x3f9b1a['conditions'][_0xcc1f('0x41')];_0x57807a++){var _0x34f763=_0x3f9b1a[_0xcc1f('0x61')][_0x57807a];var _0x3bc7f8='i';var _0x37e2ab=_['find'](_0x6337d8,[_0xcc1f('0x1e'),_0x34f763[_0xcc1f('0x48')]]);if(!_0x37e2ab){switch(_0x34f763[_0xcc1f('0x48')]){case'unreadMessages':if(_0x34f763[_0xcc1f('0x62')]==0x1){_0x4efa0b['having']('`'+_0x34f763[_0xcc1f('0x48')]+_0xcc1f('0x63'));}else{_0x4efa0b[_0xcc1f('0x64')]('`'+_0x34f763[_0xcc1f('0x48')]+'`\x20>\x200');}break;case'Contact':if(_0x34f763[_0xcc1f('0x65')]===_0xcc1f('0x66')){if(_0x34f763[_0xcc1f('0x62')][_0xcc1f('0x25')]('\x20')[_0xcc1f('0x41')]>0x1){_0x3b6d1e[_0x30405b](_0xcc1f('0x67'),qs[_0xcc1f('0x68')](_0x34f763['value']),null);}else{var _0x3d14db='%'+_0x34f763[_0xcc1f('0x62')]+'%';_0x3b6d1e[_0x30405b](_0xcc1f('0x69'),_0x3d14db,_0x3d14db,_0x3d14db);}}else{_0x37e2ab=_['find'](_0x6337d8,[_0xcc1f('0x1e'),_0xcc1f('0x6a')]);_0x34f763[_0xcc1f('0x48')]=_0xcc1f('0x6a');_0x42beeb=as[_0xcc1f('0x6b')](_0x3bc7f8,_0x37e2ab[_0xcc1f('0x38')],_0x34f763);_0x3b6d1e[_0x30405b](_0x42beeb[_0xcc1f('0x6c')],_0x42beeb[_0xcc1f('0x62')][_0xcc1f('0x6d')],_0x42beeb[_0xcc1f('0x62')][_0xcc1f('0x6e')]);}break;case'Tag':var _0x3865f5=_0x34f763[_0xcc1f('0x62')][_0xcc1f('0x25')](',')['map'](function(_0x3bc54d){return Number(_0x3bc54d);});_0x3865f5['forEach'](function(_0x2b1aad){_0x53aaff['or']('CONCAT(\x27,\x27,\x20`TagIds`,\x20\x27,\x27)\x20LIKE\x20?','%,'+_0x2b1aad+',%');});_0x5694a4=_[_0xcc1f('0x6f')](_0x5694a4,_0x3865f5);break;case _0xcc1f('0x70'):if(_0x34f763[_0xcc1f('0x65')]===_0xcc1f('0x66')){_0x3b6d1e[_0x30405b](_0xcc1f('0x71'),'%'+_0x34f763[_0xcc1f('0x62')]+'%',null);}else{_0x37e2ab=_[_0xcc1f('0x72')](_0x6337d8,[_0xcc1f('0x1e'),_0xcc1f('0x33')]);_0x34f763[_0xcc1f('0x48')]=_0xcc1f('0x33');_0x42beeb=as[_0xcc1f('0x6b')](_0x3bc7f8,_0x37e2ab[_0xcc1f('0x38')],_0x34f763);_0x3b6d1e[_0x30405b](_0x42beeb['text'],_0x42beeb[_0xcc1f('0x62')][_0xcc1f('0x6d')],_0x42beeb[_0xcc1f('0x62')]['end']);}break;case _0xcc1f('0x2b'):_0x42beeb=as[_0xcc1f('0x6b')]('me',null,_0x34f763);_0x3b6d1e[_0x30405b](_0x42beeb[_0xcc1f('0x6c')],_0x42beeb[_0xcc1f('0x62')][_0xcc1f('0x6d')],_0x42beeb[_0xcc1f('0x62')][_0xcc1f('0x6e')]);break;}}else{var _0x42beeb=as[_0xcc1f('0x6b')](_0x3bc7f8,_0x37e2ab[_0xcc1f('0x38')],_0x34f763);_0x3b6d1e[_0x30405b](_0x42beeb[_0xcc1f('0x6c')],_0x42beeb[_0xcc1f('0x62')][_0xcc1f('0x6d')],_0x42beeb['value'][_0xcc1f('0x6e')]);}}}else{var _0x413fbd=_(_0x332139[_0xcc1f('0x40')])['keys']()[_0xcc1f('0x21')](function(_0xdbfb33){return _[_0xcc1f('0x73')](_0x6337d8,[_0xcc1f('0x1e'),_0xdbfb33])?_0xdbfb33:undefined;})[_0xcc1f('0x74')]()[_0xcc1f('0x62')]();if(!_[_0xcc1f('0x75')](_0x413fbd)){_0x413fbd[_0xcc1f('0x26')](function(_0xe06531){if(_0xe06531==='MailAccountId'){_0x4efa0b[_0xcc1f('0x46')](_0xcc1f('0x76'),[][_0xcc1f('0x77')](_0x332139[_0xcc1f('0x40')][_0xe06531]));}else if(_0xe06531===_0xcc1f('0x78')){var _0x10bc01=JSON[_0xcc1f('0x79')](_0x332139[_0xcc1f('0x40')][_0xe06531])[_0xcc1f('0x7a')];var _0x24ea6d=JSON[_0xcc1f('0x79')](_0x332139[_0xcc1f('0x40')][_0xe06531])[_0xcc1f('0x7b')];_0x4efa0b[_0xcc1f('0x46')](_0xcc1f('0x7c'),_0x10bc01,_0x24ea6d);}else{if(_0x332139[_0xcc1f('0x40')][_0xe06531]===_0xcc1f('0x7d')){_0x4efa0b[_0xcc1f('0x46')]('i.'+_0xe06531+_0xcc1f('0x7e'));}else{_0x4efa0b[_0xcc1f('0x46')]('i.'+_0xe06531+_0xcc1f('0x7f'),_0x332139['query'][_0xe06531]);}}});}if(_0x332139['query']['read']){if(_0x332139[_0xcc1f('0x40')][_0xcc1f('0x80')]==0x1){_0x4efa0b[_0xcc1f('0x64')](_0xcc1f('0x81'));}else{_0x4efa0b[_0xcc1f('0x64')](_0xcc1f('0x82'));}}if(_0x332139[_0xcc1f('0x40')][_0xcc1f('0x83')]){_0x5694a4=_[_0xcc1f('0x84')](_0x332139[_0xcc1f('0x40')][_0xcc1f('0x83')])?_0x332139[_0xcc1f('0x40')][_0xcc1f('0x83')]:new Array(_0x332139[_0xcc1f('0x40')][_0xcc1f('0x83')]);_0x5694a4[_0xcc1f('0x26')](function(_0x189edf){_0x53aaff['or'](_0xcc1f('0x85'),'%,'+_0x189edf+',%');});}if(_0x332139[_0xcc1f('0x40')][_0xcc1f('0x86')]){var _0x1a4982=_0x332139[_0xcc1f('0x40')][_0xcc1f('0x86')]['replace']('\x5c','\x5c\x5c')[_0xcc1f('0x87')](/'/g,'\x27\x27');if(qs[_0xcc1f('0x88')](_0x1a4982)){_0x3b6d1e['or'](_0xcc1f('0x89'),_0x1a4982+'%');}else if(qs['isEmail'](_0x1a4982)){_0x3b6d1e['or'](_0xcc1f('0x8a'),_0x1a4982+'%');}else{_0x3b6d1e['or']('MATCH\x20(i.to,\x20i.subject)\x20AGAINST\x20(?\x20IN\x20BOOLEAN\x20MODE)',qs[_0xcc1f('0x68')](_0x1a4982))['or'](_0xcc1f('0x8b'),qs[_0xcc1f('0x68')](_0x1a4982));}}}_0x4efa0b['where'](_0x3b6d1e);_0x4efa0b[_0xcc1f('0x8c')](_0xcc1f('0x8d'));var _0x1b5d94={'type':db[_0xcc1f('0x8e')][_0xcc1f('0x8f')][_0xcc1f('0x90')],'raw':!![]};var _0x296bbe=_0x4efa0b['clone']();_0x296bbe[_0xcc1f('0x48')]('i.id');_0x296bbe[_0xcc1f('0x48')](_0xcc1f('0x91'),_0xcc1f('0x92'));if(_0x3d0c4f[_0xcc1f('0x44')]){_0x3d0c4f[_0xcc1f('0x44')][_0xcc1f('0x26')](function(_0x5b2f81){var _0x19fd95=_0x5b2f81[0x0]===_0xcc1f('0x93')?_0x5b2f81[0x0]:'i.'+_0x5b2f81[0x0];_0x4efa0b[_0xcc1f('0x44')](_0x19fd95,_0x5b2f81[0x1]===_0xcc1f('0x94')?![]:!![]);});}if(!_[_0xcc1f('0x75')](_0x5694a4)){_0x4efa0b[_0xcc1f('0x64')](_0x53aaff);_0x296bbe['where']('t.id\x20IN\x20?',_0x5694a4);}BPromise[_0xcc1f('0x95')]()[_0xcc1f('0x1c')](function(){if(!_0x3f9b1a){if(_0x332139[_0xcc1f('0x40')]['MailAccountId'])return;_0x296bbe[_0xcc1f('0x46')](_0xcc1f('0x96'));_0x4efa0b[_0xcc1f('0x46')]('i.MailAccountId\x20IS\x20NOT\x20NULL');return;}if(_0x332139[_0xcc1f('0x97')][_0xcc1f('0x98')]!==_0xcc1f('0x99'))return;return _0x332139[_0xcc1f('0x97')][_0xcc1f('0x9a')]({'attributes':['id'],'raw':!![]})['then'](function(_0x4414f7){if(_[_0xcc1f('0x75')](_0x4414f7)){_0x296bbe[_0xcc1f('0x46')](_0xcc1f('0x9b'));_0x4efa0b[_0xcc1f('0x46')]('i.MailAccountId\x20IS\x20NULL');}else{_0x296bbe[_0xcc1f('0x46')]('i.MailAccountId\x20IN\x20?',_[_0xcc1f('0x21')](_0x4414f7,'id'));_0x4efa0b['where'](_0xcc1f('0x76'),_[_0xcc1f('0x21')](_0x4414f7,'id'));}});})[_0xcc1f('0x1c')](function(){if(_0x332139[_0xcc1f('0x97')][_0xcc1f('0x98')]===_0xcc1f('0x99')&&!_0x3f9b1a&&!_0x332139[_0xcc1f('0x40')][_0xcc1f('0x9c')])return[];return db[_0xcc1f('0x9d')][_0xcc1f('0x40')](_0x296bbe[_0xcc1f('0x9e')](),_0x1b5d94);})[_0xcc1f('0x1c')](function(_0x543d27){_0x1dd624[_0xcc1f('0x18')]=_0x543d27['length'];if(_0x1dd624[_0xcc1f('0x18')]===0x0)return[];return db[_0xcc1f('0x9d')][_0xcc1f('0x40')](_0x396859[_0xcc1f('0x9e')](),_0x1b5d94)[_0xcc1f('0x1c')](function(_0x255427){_0x15aadd=_[_0xcc1f('0x9f')](_0x255427,'id');_0x1b5d94=_[_0xcc1f('0xa0')](_0x1b5d94,{'model':db[_0xcc1f('0x36')],'mapToModel':!![],'raw':!![],'nest':!![]});if(_0x332139[_0xcc1f('0x40')]['fields']){_0x3d0c4f[_0xcc1f('0x3e')][_0xcc1f('0x26')](function(_0x38ad77){_0x4efa0b['field']('i.'+_0x38ad77);});}else{_0x4efa0b[_0xcc1f('0x48')](_0xcc1f('0x91'),'unreadMessages');_0x4efa0b[_0xcc1f('0x48')](_0xcc1f('0xa1'),_0xcc1f('0xa2'));_0x4efa0b[_0xcc1f('0x48')](_0xcc1f('0xa3'),_0xcc1f('0xa4'));_0x4efa0b[_0xcc1f('0x48')](_0xcc1f('0xa5'),'contactName');_0x4efa0b['field'](_0xcc1f('0x8d'));_0x4efa0b[_0xcc1f('0x48')](_0xcc1f('0xa6'));_0x4efa0b[_0xcc1f('0x48')](_0xcc1f('0xa7'));_0x4efa0b[_0xcc1f('0x48')](_0xcc1f('0xa8'));_0x4efa0b[_0xcc1f('0x48')](_0xcc1f('0xa9'));_0x4efa0b[_0xcc1f('0x48')](_0xcc1f('0xaa'));_0x4efa0b[_0xcc1f('0x48')](_0xcc1f('0xab'));_0x4efa0b[_0xcc1f('0x48')](_0xcc1f('0xac'));_0x4efa0b[_0xcc1f('0x48')]('i.subject');_0x4efa0b['field'](_0xcc1f('0xad'));_0x4efa0b[_0xcc1f('0x48')](_0xcc1f('0xae'));_0x4efa0b[_0xcc1f('0x48')](_0xcc1f('0xaf'));_0x4efa0b[_0xcc1f('0x48')]('i.substatus');_0x4efa0b[_0xcc1f('0x48')](_0xcc1f('0xb0'));_0x4efa0b[_0xcc1f('0x48')](_0xcc1f('0xb1'));_0x4efa0b[_0xcc1f('0x48')](_0xcc1f('0xb2'));_0x4efa0b['field'](_0xcc1f('0xb3'));_0x4efa0b['field'](_0xcc1f('0xb4'),_0xcc1f('0xb5'));_0x4efa0b[_0xcc1f('0x48')](_0xcc1f('0xb6'),_0xcc1f('0xb7'));_0x4efa0b[_0xcc1f('0x48')]('c.email',_0xcc1f('0xb8'));_0x4efa0b['field'](_0xcc1f('0xb9'),_0xcc1f('0xba'));_0x4efa0b[_0xcc1f('0x48')]('c.mobile','Contact.mobile');_0x4efa0b[_0xcc1f('0x48')](_0xcc1f('0xbb'),_0xcc1f('0xbc'));_0x4efa0b[_0xcc1f('0x48')](_0xcc1f('0xbd'),_0xcc1f('0xbe'));_0x4efa0b[_0xcc1f('0x48')](_0xcc1f('0xbf'),_0xcc1f('0xc0'));_0x4efa0b['field'](_0xcc1f('0xc1'),_0xcc1f('0x23'));}if(_0x3d0c4f[_0xcc1f('0x17')])_0x4efa0b[_0xcc1f('0x17')](_0x3d0c4f['limit']);if(_0x3d0c4f['offset'])_0x4efa0b[_0xcc1f('0x15')](_0x3d0c4f[_0xcc1f('0x15')]);return db[_0xcc1f('0x9d')]['query'](_0x4efa0b[_0xcc1f('0x9e')](),_0x1b5d94);})['then'](function(_0x3c7fc1){if(_0x3c7fc1['length']>0x0)_0x781a9b[_0xcc1f('0x46')]('ui.MailInteractionId\x20IN\x20?',_[_0xcc1f('0x21')](_0x3c7fc1,'id'));return db[_0xcc1f('0x9d')]['query'](_0x781a9b[_0xcc1f('0x9e')](),_0x1b5d94)[_0xcc1f('0x1c')](function(_0x2ec0c4){var _0x586c9b=_[_0xcc1f('0xc2')](_0x2ec0c4,_0xcc1f('0xc3'));var _0x20f8df=[];return db[_0xcc1f('0xc4')][_0xcc1f('0x29')]({'attributes':[_0xcc1f('0xc5')],'raw':!![]})[_0xcc1f('0x1c')](function(_0x1b6ad1){var _0x4c5101=_0x1b6ad1[_0xcc1f('0xc5')];_0x3c7fc1[_0xcc1f('0x26')](function(_0x4dd7ae){_0x20f8df['push'](updateMailInteraction(_0x4dd7ae,_0x15aadd,_0x586c9b,_0x4c5101));});return BPromise['all'](_0x20f8df);});});});})[_0xcc1f('0x1c')](function(_0x15f140){_0x1dd624[_0xcc1f('0xc6')]=_0x15f140;return _0x1dd624;})[_0xcc1f('0x1c')](respondWithFilteredResult(_0x43d933,_0x3d0c4f))[_0xcc1f('0x2e')](handleError(_0x43d933,null));};exports[_0xcc1f('0xc7')]=function(_0x380510,_0x1690d2){var _0x2c182f={'raw':![],'where':{'id':_0x380510[_0xcc1f('0xc8')]['id']}},_0x33fc70={};_0x33fc70[_0xcc1f('0x3a')]=_[_0xcc1f('0x3b')](db[_0xcc1f('0x36')][_0xcc1f('0x37')]);_0x33fc70[_0xcc1f('0x40')]=_['keys'](_0x380510['query']);_0x33fc70[_0xcc1f('0x3c')]=_['intersection'](_0x33fc70[_0xcc1f('0x3a')],_0x33fc70[_0xcc1f('0x40')]);_0x2c182f['attributes']=_['intersection'](_0x33fc70[_0xcc1f('0x3a')],qs[_0xcc1f('0x3f')](_0x380510[_0xcc1f('0x40')][_0xcc1f('0x3f')]));_0x2c182f[_0xcc1f('0x3e')]=_0x2c182f[_0xcc1f('0x3e')][_0xcc1f('0x41')]?_0x2c182f[_0xcc1f('0x3e')]:_0x33fc70['model'];if(_0x380510[_0xcc1f('0x40')][_0xcc1f('0xc9')]){_0x2c182f[_0xcc1f('0xca')]=[{'all':!![]}];}_0x2c182f=_[_0xcc1f('0xa0')]({},_0x2c182f,_0x380510[_0xcc1f('0xcb')]);return db[_0xcc1f('0x36')]['find'](_0x2c182f)[_0xcc1f('0x1c')](handleEntityNotFound(_0x1690d2,null))[_0xcc1f('0x1c')](respondWithResult(_0x1690d2,null))[_0xcc1f('0x2e')](handleError(_0x1690d2,null));};exports[_0xcc1f('0xcc')]=function(_0x41865f,_0x1c6ed6){return db['MailInteraction']['create'](_0x41865f[_0xcc1f('0xcd')],{})['then'](respondWithResult(_0x1c6ed6,0xc9))[_0xcc1f('0x2e')](handleError(_0x1c6ed6,null));};exports[_0xcc1f('0x1a')]=function(_0x3ae767,_0x574b24){if(_0x3ae767[_0xcc1f('0xcd')]['id']){delete _0x3ae767[_0xcc1f('0xcd')]['id'];}return db[_0xcc1f('0x36')][_0xcc1f('0x72')]({'where':{'id':_0x3ae767[_0xcc1f('0xc8')]['id']}})['then'](handleEntityNotFound(_0x574b24,null))[_0xcc1f('0x1c')](saveUpdates(_0x3ae767[_0xcc1f('0xcd')],null))[_0xcc1f('0x1c')](respondWithResult(_0x574b24,null))[_0xcc1f('0x2e')](handleError(_0x574b24,null));};exports[_0xcc1f('0x1b')]=function(_0x1526cd,_0x52260b){return db[_0xcc1f('0x36')][_0xcc1f('0x72')]({'where':{'id':_0x1526cd[_0xcc1f('0xc8')]['id']}})[_0xcc1f('0x1c')](handleEntityNotFound(_0x52260b,null))[_0xcc1f('0x1c')](removeEntity(_0x52260b,null))[_0xcc1f('0x2e')](handleError(_0x52260b,null));};exports[_0xcc1f('0xce')]=function(_0x2ecada,_0x38e663){return db[_0xcc1f('0x36')][_0xcc1f('0xce')]()['then'](respondWithResult(_0x38e663,null))['catch'](handleError(_0x38e663,null));};exports['addMessage']=function(_0x49b721,_0x3d1377){return db['MailMessage']['find']({'where':{'id':_0x49b721[_0xcc1f('0xc8')]['id']}})[_0xcc1f('0x1c')](handleEntityNotFound(_0x3d1377,null))['then'](function(_0x504ead){if(_0x504ead){return _0x504ead['addMessage'](_0x49b721[_0xcc1f('0xcd')][_0xcc1f('0xcf')],_[_0xcc1f('0xd0')](_0x49b721[_0xcc1f('0xcd')],[_0xcc1f('0xcf'),'id'])||{});}})[_0xcc1f('0x1c')](respondWithResult(_0x3d1377,null))[_0xcc1f('0x2e')](handleError(_0x3d1377,null));};exports['getMessages']=function(_0x1b0597,_0x2bb6c1){var _0x330103={'raw':![],'where':{}};var _0x279fd5={};var _0x2a5012={'count':0x0,'rows':[]};return db[_0xcc1f('0x36')]['findOne']({'where':{'id':_0x1b0597[_0xcc1f('0xc8')]['id']}})['then'](handleEntityNotFound(_0x2bb6c1,null))[_0xcc1f('0x1c')](function(_0x3e2447){if(_0x3e2447){_0x279fd5['model']=_[_0xcc1f('0x3b')](db[_0xcc1f('0x28')][_0xcc1f('0x37')]);_0x279fd5[_0xcc1f('0x40')]=_[_0xcc1f('0x3b')](_0x1b0597[_0xcc1f('0x40')]);_0x279fd5[_0xcc1f('0x3c')]=_[_0xcc1f('0x3d')](_0x279fd5[_0xcc1f('0x3a')],_0x279fd5[_0xcc1f('0x40')]);_0x330103[_0xcc1f('0x3e')]=_[_0xcc1f('0x3d')](_0x279fd5[_0xcc1f('0x3a')],qs[_0xcc1f('0x3f')](_0x1b0597[_0xcc1f('0x40')]['fields']));_0x330103['attributes']=_0x330103[_0xcc1f('0x3e')][_0xcc1f('0x41')]?_0x330103[_0xcc1f('0x3e')]:_0x279fd5['model'];if(!_0x1b0597[_0xcc1f('0x40')][_0xcc1f('0x42')](_0xcc1f('0x43'))){_0x330103['limit']=qs[_0xcc1f('0x17')](_0x1b0597['query']['limit']);_0x330103['offset']=qs[_0xcc1f('0x15')](_0x1b0597[_0xcc1f('0x40')][_0xcc1f('0x15')]);}_0x330103[_0xcc1f('0x44')]=qs[_0xcc1f('0x45')](_0x1b0597[_0xcc1f('0x40')]['sort']);_0x330103['where']=qs[_0xcc1f('0x3c')](_[_0xcc1f('0xd1')](_0x1b0597[_0xcc1f('0x40')],_0x279fd5[_0xcc1f('0x3c')]));_0x330103[_0xcc1f('0x46')][_0xcc1f('0xc3')]=_0x3e2447['id'];if(_0x1b0597['query']['filter']){_0x330103[_0xcc1f('0x46')]=_[_0xcc1f('0xa0')](_0x330103[_0xcc1f('0x46')],{'$or':_[_0xcc1f('0x21')](_0x330103[_0xcc1f('0x3e')],function(_0x587378){var _0x753027={};_0x753027[_0x587378]={'$like':'%'+_0x1b0597['query'][_0xcc1f('0x86')]+'%'};return _0x753027;})});}if(_0x1b0597[_0xcc1f('0x40')]['$gte']){var _0x2da010=_0x1b0597[_0xcc1f('0x40')]['$gte'][_0xcc1f('0x25')](',');var _0x222f59={};_0x222f59[_0x2da010[0x0]]={'$gte':moment(_0x2da010[0x1])['format'](_0xcc1f('0xd2'))};_0x330103[_0xcc1f('0x46')]=_[_0xcc1f('0xa0')](_0x330103[_0xcc1f('0x46')],_0x222f59);}_0x330103=_['merge']({},_0x330103,_0x1b0597[_0xcc1f('0xcb')]);return db[_0xcc1f('0x28')][_0xcc1f('0x18')]({'where':_0x330103[_0xcc1f('0x46')]})[_0xcc1f('0x1c')](function(_0x48ce43){_0x2a5012[_0xcc1f('0x18')]=_0x48ce43;if(_0x1b0597['query']['includeAll']){_0x330103[_0xcc1f('0xca')]=[{'all':!![]}];}return db['MailMessage']['findAll'](_0x330103);})['then'](function(_0x58bf8f){if(_0x1b0597[_0xcc1f('0x40')][_0xcc1f('0xd3')]===_0xcc1f('0xd4')){for(var _0x32688d=0x0;_0x32688d<_0x58bf8f[_0xcc1f('0x41')];_0x32688d++){_0x58bf8f[_0x32688d]['body']=juice(_0x58bf8f[_0x32688d][_0xcc1f('0xcd')]);}}_0x2a5012['rows']=_0x58bf8f;return _0x2a5012;});}})[_0xcc1f('0x1c')](respondWithFilteredResult(_0x2bb6c1,_0x330103))['catch'](handleError(_0x2bb6c1,null));};exports['addTags']=function(_0x5a6f1c,_0x25ab3d){return db[_0xcc1f('0x36')][_0xcc1f('0x72')]({'where':{'id':_0x5a6f1c[_0xcc1f('0xc8')]['id']}})[_0xcc1f('0x1c')](handleEntityNotFound(_0x25ab3d,null))[_0xcc1f('0x1c')](function(_0x9269da){if(_0x9269da){return _0x9269da[_0xcc1f('0xd5')](_0x5a6f1c[_0xcc1f('0xcd')]['ids'],_[_0xcc1f('0xd0')](_0x5a6f1c['body'],[_0xcc1f('0xcf'),'id'])||{})[_0xcc1f('0xd6')](function(){return db[_0xcc1f('0xd7')][_0xcc1f('0xd8')]({'attributes':['id','name',_0xcc1f('0x49')],'where':{'id':_0x5a6f1c[_0xcc1f('0xcd')]['ids']}});})['then'](function(_0x2f2323){socket['emit'](_0xcc1f('0xd9'),{'id':Number(_0x5a6f1c[_0xcc1f('0xc8')]['id']),'tags':_0x2f2323||[]});return{'id':Number(_0x5a6f1c[_0xcc1f('0xc8')]['id']),'tags':_0x2f2323||[]};});}})[_0xcc1f('0x1c')](respondWithResult(_0x25ab3d,null))[_0xcc1f('0x2e')](handleError(_0x25ab3d,null));};exports[_0xcc1f('0xda')]=function(_0x3c8bae,_0x1c1129){return db[_0xcc1f('0x36')]['find']({'where':{'id':_0x3c8bae[_0xcc1f('0xc8')]['id']}})[_0xcc1f('0x1c')](handleEntityNotFound(_0x1c1129,null))['then'](function(_0x5074ca){if(_0x5074ca){return _0x5074ca['removeTags'](_0x3c8bae[_0xcc1f('0x40')][_0xcc1f('0xcf')]);}})[_0xcc1f('0x1c')](respondWithStatusCode(_0x1c1129,null))[_0xcc1f('0x2e')](handleError(_0x1c1129,null));};exports[_0xcc1f('0xdb')]=function(_0x2c29c7,_0x3e4e97){var _0x263e1f=moment()[_0xcc1f('0xdc')]()[_0xcc1f('0x9e')]();var _0xb9e91=path['join'](config['root'],_0xcc1f('0xdd'),_0xcc1f('0xde'),_0xcc1f('0xdf'));var _0x60e381=path[_0xcc1f('0xe0')](config['root'],'server',_0xcc1f('0xde'),_0xcc1f('0xe1'));var _0x3cf918=path[_0xcc1f('0xe0')](_0xb9e91,_0x263e1f);var _0x92cbcb=util[_0xcc1f('0xe2')](_0xcc1f('0xe3'),_0x2c29c7[_0xcc1f('0xc8')]['id'],_0x263e1f);var _0x3114e0=path[_0xcc1f('0xe0')](_0xb9e91,_0x92cbcb);var _0x1b378c=[];if(_0x2c29c7[_0xcc1f('0x40')][_0xcc1f('0xe1')]){_0x1b378c[_0xcc1f('0x27')]({'model':db[_0xcc1f('0xe4')],'as':_0xcc1f('0xe5'),'raw':!![]});}var _0x12886d=[{'model':db[_0xcc1f('0x28')],'as':_0xcc1f('0xe6'),'attributes':['id','body',_0xcc1f('0x4e'),'to','cc',_0xcc1f('0xe7'),'subject',_0xcc1f('0x78')],'where':{'secret':![]},'order':qs['sort']('id'),'include':_0x1b378c}];return db['MailInteraction'][_0xcc1f('0x72')]({'where':{'id':_0x2c29c7[_0xcc1f('0xc8')]['id']},'include':_0x12886d})[_0xcc1f('0x1c')](handleEntityNotFound(_0x3e4e97,null))[_0xcc1f('0x1c')](function(_0x376449){if(_0x376449&&_0x376449[_0xcc1f('0xe6')]){var _0x1be5af=_0x376449['get']({'plain':!![]});fs[_0xcc1f('0xe8')](_0x3cf918);return BPromise['each'](_0x1be5af[_0xcc1f('0xe6')],function(_0x5d6e10,_0x4d1c33){var _0x3c08f3={'from':_0x5d6e10['from'],'to':_0x5d6e10['to'],'subject':_0x5d6e10[_0xcc1f('0xe9')],'html':htmlEntities['decode'](_0x5d6e10[_0xcc1f('0xcd')]),'headers':{'Date':moment(_0x5d6e10[_0xcc1f('0x78')])[_0xcc1f('0xe2')]('ddd,\x20DD\x20MMM\x20YYYY\x20HH:mm:ss\x20ZZ')},'attachments':[]};if(_0x5d6e10['cc']){_0x3c08f3[_0xcc1f('0xea')]['Cc']=_0x5d6e10['cc'];}if(_0x5d6e10[_0xcc1f('0xe7')]){_0x3c08f3[_0xcc1f('0xea')][_0xcc1f('0xeb')]=_0x5d6e10[_0xcc1f('0xe7')];}return new BPromise(function(_0x1df8de,_0x18f123){if(_0x5d6e10[_0xcc1f('0xe5')]){for(var _0xbadc5e=0x0;_0xbadc5e<_0x5d6e10[_0xcc1f('0xe5')][_0xcc1f('0x41')];_0xbadc5e++){var _0x4e44d0=_0x5d6e10[_0xcc1f('0xe5')][_0xbadc5e];var _0x17e4f6=path[_0xcc1f('0xe0')](_0x60e381,_0x4e44d0[_0xcc1f('0xec')]);if(fs['existsSync'](_0x17e4f6)){_0x3c08f3[_0xcc1f('0xe1')]['push']({'name':_0x4e44d0[_0xcc1f('0x1e')],'contentType':_0x4e44d0[_0xcc1f('0x38')],'data':fs[_0xcc1f('0xed')](_0x17e4f6)});}}}emlformat[_0xcc1f('0xee')](_0x3c08f3,function(_0x202287,_0x5bb731){if(_0x202287)return _0x18f123(_0x202287);fs[_0xcc1f('0xef')](path[_0xcc1f('0xe0')](_0x3cf918,util[_0xcc1f('0xe2')](_0xcc1f('0xf0'),_0x4d1c33)),_0x5bb731);return _0x1df8de(_0x5bb731);});});})['then'](function(){return new BPromise(function(_0x10cf98,_0x461bc4){zipdir(_0x3cf918,{'saveTo':_0x3114e0},function(_0x424bd7,_0x3ad369){if(_0x424bd7)return _0x461bc4(_0x424bd7);return _0x10cf98(_0x3ad369);});})[_0xcc1f('0x1c')](function(){return new BPromise(function(_0x2eb9cb,_0x28190){rimraf(_0x3cf918,function(_0x1ed0ac){if(_0x1ed0ac)_0x28190(_0x1ed0ac);return _0x2eb9cb();});});})[_0xcc1f('0x1c')](function(){return _0x3e4e97[_0xcc1f('0xdb')](_0x3114e0,_0x92cbcb,function(_0x40baab){if(!_0x40baab)fs[_0xcc1f('0xf1')](_0x3114e0);});});});}else{return _0x3e4e97[_0xcc1f('0x12')](0xc8);}})[_0xcc1f('0x2e')](handleError(_0x3e4e97,null));};