Built motion from commit (unavailable).|2.5.0
[motion2.git] / server / api / faxInteraction / faxInteraction.controller.js
index 00181af..4f4c635 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xadc9=['isNumeric','i.id\x20LIKE\x20?','i.fax\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)','DESC','resolve','i.FaxAccountId\x20IS\x20NOT\x20NULL','user','i.FaxAccountId\x20IS\x20NULL','sequelize','count','toString','keyBy','a.key','a.mandatoryDisposition','i.*','c.firstName','Contact.firstName','c.lastName','Contact.lastName','Contact.phone','c.mobile','Contact.mobile','Contact.fax','o.fullname','Owner.fullname','o.internal','Owner.internal','GROUP_CONCAT(DISTINCT\x20t.id)','ui.FaxInteractionId\x20IN\x20?','FaxInteractionId','all','rows','show','includeAll','merge','options','find','create','params','destroy','describe','FaxMessage','addMessage','ids','omit','getMessages','findOne','nolimit','YYYY-MM-DD\x20HH:mm:ss','include','findAll','setTags','spread','color','emit','faxInteractionTags:save','removeTags','download','unix','join','root','server','files','attachments','format','transcript-%d-%s.zip','Attachment','Messages','createdAt','basename','existsSync','createReadStream','pipe','createWriteStream','log','err','unlinkSync','sendStatus','html-pdf','eml-format','rimraf','zip-dir','request-promise','mustache','util','path','sox','to-csv','lodash','crypto','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/logger','../../config/utils','../../config/environment','../../mysqldb','redis','localhost','socket.io-emitter','./faxInteraction.socket','status','json','limit','set','Content-Range','reject','save','update','then','end','stack','name','Users','map','fullname','Tags','split','forEach','push','TagIds','catch','FaxInteraction','rawAttributes','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','offset','order','sort','where','pick','select','field','from','tools_tags','u.id','u.fullname','ui.FaxInteractionId','user_has_fax_interactions','left_join','u.id\x20=\x20ui.UserId','fax_interactions','cm_contacts','c.id\x20=\x20i.ContactId\x20AND\x20c.deletedAt\x20IS\x20NULL','users','o.id\x20=\x20i.UserId','a.id\x20=\x20i.FaxAccountId','fax_messages','me.FaxInteractionId\x20=\x20i.id','fax_interaction_has_tags','it.FaxInteractionId\x20=\x20i.id','t.id\x20=\x20it.TagId','expr','search','sqlOperator','conditions','unreadMessages','value','having','`\x20=\x200','`\x20>\x200','Contact','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','type','text','Tag','CONCAT(\x27,\x27,\x20`TagIds`,\x20\x27,\x27)\x20LIKE\x20?','union','User','body','start','some','isEmpty','FaxAccountId','i.FaxAccountId\x20IN\x20?','concat','parse','$gte','i.createdAt\x20BETWEEN\x20?\x20AND\x20?','null','\x20IS\x20NULL','read','`unreadMessages`\x20=\x200','`unreadMessages`\x20>\x200','tag','isArray','filter','replace'];(function(_0x1cafd7,_0x34e7e1){var _0x96f4d4=function(_0x4f9538){while(--_0x4f9538){_0x1cafd7['push'](_0x1cafd7['shift']());}};_0x96f4d4(++_0x34e7e1);}(_0xadc9,0x12a));var _0x9adc=function(_0x46e9f0,_0x41091a){_0x46e9f0=_0x46e9f0-0x0;var _0x115380=_0xadc9[_0x46e9f0];return _0x115380;};'use strict';var pdf=require(_0x9adc('0x0'));var emlformat=require(_0x9adc('0x1'));var rimraf=require(_0x9adc('0x2'));var zipdir=require(_0x9adc('0x3'));var jsonpatch=require('fast-json-patch');var rp=require(_0x9adc('0x4'));var moment=require('moment');var BPromise=require('bluebird');var Mustache=require(_0x9adc('0x5'));var util=require(_0x9adc('0x6'));var path=require(_0x9adc('0x7'));var sox=require(_0x9adc('0x8'));var csv=require(_0x9adc('0x9'));var ejs=require('ejs');var fs=require('fs');var _=require(_0x9adc('0xa'));var squel=require('squel');var crypto=require(_0x9adc('0xb'));var jsforce=require('jsforce');var deskjs=require('desk.js');var toCsv=require(_0x9adc('0x9'));var querystring=require(_0x9adc('0xc'));var Papa=require(_0x9adc('0xd'));var Redis=require(_0x9adc('0xe'));var authService=require(_0x9adc('0xf'));var qs=require('../../components/parsers/qs');var as=require(_0x9adc('0x10'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x9adc('0x11'))('api');var utils=require(_0x9adc('0x12'));var config=require(_0x9adc('0x13'));var db=require(_0x9adc('0x14'))['db'];config[_0x9adc('0x15')]=_['defaults'](config[_0x9adc('0x15')],{'host':_0x9adc('0x16'),'port':0x18eb});var socket=require(_0x9adc('0x17'))(new Redis(config['redis']));require(_0x9adc('0x18'))['register'](socket);function respondWithStatusCode(_0x3072f8,_0x2a7225){_0x2a7225=_0x2a7225||0xcc;return function(_0x1264a7){if(_0x1264a7){return _0x3072f8['sendStatus'](_0x2a7225);}return _0x3072f8[_0x9adc('0x19')](_0x2a7225)['end']();};}function respondWithResult(_0x18b96c,_0xadf8c2){_0xadf8c2=_0xadf8c2||0xc8;return function(_0x556ff6){if(_0x556ff6){return _0x18b96c[_0x9adc('0x19')](_0xadf8c2)[_0x9adc('0x1a')](_0x556ff6);}};}function respondWithFilteredResult(_0x1e1056,_0xc21bca){return function(_0x41726e){if(_0x41726e){var _0x4e8747=_0x41726e['count'],_0x1ead12=_0xc21bca['offset'],_0x8ba066=_0xc21bca['offset']+_0xc21bca[_0x9adc('0x1b')],_0x50440a;if(_0x8ba066>=_0x4e8747){_0x8ba066=_0x4e8747;_0x50440a=0xc8;}else{_0x50440a=0xce;}_0x1e1056[_0x9adc('0x19')](_0x50440a);return _0x1e1056[_0x9adc('0x1c')](_0x9adc('0x1d'),_0x1ead12+'-'+_0x8ba066+'/'+_0x4e8747)['json'](_0x41726e);}return null;};}function patchUpdates(_0x31b5ae){return function(_0x35752a){try{jsonpatch['apply'](_0x35752a,_0x31b5ae,!![]);}catch(_0x1da797){return BPromise[_0x9adc('0x1e')](_0x1da797);}return _0x35752a[_0x9adc('0x1f')]();};}function saveUpdates(_0x49a04e,_0x406c0d){return function(_0x1f21bc){if(_0x1f21bc){return _0x1f21bc[_0x9adc('0x20')](_0x49a04e)[_0x9adc('0x21')](function(_0x164fff){return _0x164fff;});}return null;};}function removeEntity(_0x489217,_0x281aea){return function(_0x1912d3){if(_0x1912d3){return _0x1912d3['destroy']()[_0x9adc('0x21')](function(){_0x489217[_0x9adc('0x19')](0xcc)[_0x9adc('0x22')]();});}};}function handleEntityNotFound(_0x61885b,_0x69ba17){return function(_0x2831ee){if(!_0x2831ee){_0x61885b['sendStatus'](0x194);}return _0x2831ee;};}function handleError(_0x1e6779,_0xe9bb88){_0xe9bb88=_0xe9bb88||0x1f4;return function(_0x244a1d){logger['error'](_0x244a1d[_0x9adc('0x23')]);if(_0x244a1d[_0x9adc('0x24')]){delete _0x244a1d[_0x9adc('0x24')];}_0x1e6779[_0x9adc('0x19')](_0xe9bb88)['send'](_0x244a1d);};}function getInteractionUsers(_0xeb5f13,_0x470744){return new BPromise(function(_0x3e72cf,_0x43b5f2){try{if(_0x470744[_0xeb5f13['id']]){_0xeb5f13[_0x9adc('0x25')]=_[_0x9adc('0x26')](_0x470744[_0xeb5f13['id']],function(_0x13c512){return{'id':_0x13c512['id'],'fullname':_0x13c512[_0x9adc('0x27')]};});}}catch(_0x22db36){_0x43b5f2(_0x22db36);}_0x3e72cf(_0xeb5f13);});}function getInteractionTags(_0x1ceb4f,_0x57789e){return new BPromise(function(_0x43d2d6,_0x479352){try{if(_0x1ceb4f['TagIds']){_0x1ceb4f[_0x9adc('0x28')]=[];_0x1ceb4f['TagIds'][_0x9adc('0x29')](',')[_0x9adc('0x2a')](function(_0x286258){_0x1ceb4f[_0x9adc('0x28')][_0x9adc('0x2b')](_0x57789e[_0x286258]);});}delete _0x1ceb4f[_0x9adc('0x2c')];}catch(_0x1ad660){_0x479352(_0x1ad660);}_0x43d2d6(_0x1ceb4f);});}function updateFaxInteraction(_0x4095c5,_0x91df8f,_0x5ccd90){return new BPromise(function(_0x34d0f3,_0x28fa8d){return getInteractionUsers(_0x4095c5,_0x5ccd90)[_0x9adc('0x21')](function(_0x1efbaf){return getInteractionTags(_0x1efbaf,_0x91df8f);})['then'](function(_0x398d18){_0x34d0f3(_0x398d18);})[_0x9adc('0x2d')](function(_0x5dd079){_0x28fa8d(_0x5dd079);});});}exports['index']=function(_0x39894d,_0x27d906){var _0x52a7ac={},_0x39cd96={},_0x20c568={'count':0x0,'rows':[]};var _0x3f41bb=_[_0x9adc('0x26')](db[_0x9adc('0x2e')][_0x9adc('0x2f')],function(_0x12d67f){return{'name':_0x12d67f['fieldName'],'type':_0x12d67f['type'][_0x9adc('0x30')]};});_0x39cd96[_0x9adc('0x31')]=_[_0x9adc('0x26')](_0x3f41bb,_0x9adc('0x24'));_0x39cd96[_0x9adc('0x32')]=_[_0x9adc('0x33')](_0x39894d[_0x9adc('0x32')]);_0x39cd96[_0x9adc('0x34')]=_[_0x9adc('0x35')](_0x39cd96[_0x9adc('0x31')],_0x39cd96['query']);_0x52a7ac[_0x9adc('0x36')]=_[_0x9adc('0x35')](_0x39cd96[_0x9adc('0x31')],qs[_0x9adc('0x37')](_0x39894d[_0x9adc('0x32')][_0x9adc('0x37')]));_0x52a7ac['attributes']=_0x52a7ac[_0x9adc('0x36')][_0x9adc('0x38')]?_0x52a7ac['attributes']:_0x39cd96[_0x9adc('0x31')];if(!_0x39894d[_0x9adc('0x32')][_0x9adc('0x39')]('nolimit')){_0x52a7ac[_0x9adc('0x1b')]=qs[_0x9adc('0x1b')](_0x39894d[_0x9adc('0x32')]['limit']);_0x52a7ac[_0x9adc('0x3a')]=qs[_0x9adc('0x3a')](_0x39894d[_0x9adc('0x32')][_0x9adc('0x3a')]);}_0x52a7ac[_0x9adc('0x3b')]=qs[_0x9adc('0x3c')](_0x39894d[_0x9adc('0x32')]['sort']);_0x52a7ac[_0x9adc('0x3d')]=qs[_0x9adc('0x34')](_[_0x9adc('0x3e')](_0x39894d[_0x9adc('0x32')],_0x39cd96[_0x9adc('0x34')]));var _0x41c892=[];var _0x5ed810=squel[_0x9adc('0x3f')]()['field']('id')[_0x9adc('0x40')](_0x9adc('0x24'))['field']('color')[_0x9adc('0x41')](_0x9adc('0x42'));var _0x12af87=squel[_0x9adc('0x3f')]()[_0x9adc('0x40')](_0x9adc('0x43'))[_0x9adc('0x40')](_0x9adc('0x44'))[_0x9adc('0x40')](_0x9adc('0x45'))[_0x9adc('0x41')](_0x9adc('0x46'),'ui')[_0x9adc('0x47')]('users','u',_0x9adc('0x48'));var _0x116428=squel[_0x9adc('0x3f')]()[_0x9adc('0x41')](_0x9adc('0x49'),'i')[_0x9adc('0x47')](_0x9adc('0x4a'),'c',_0x9adc('0x4b'))['left_join'](_0x9adc('0x4c'),'o',_0x9adc('0x4d'))[_0x9adc('0x47')]('fax_accounts','a',_0x9adc('0x4e'))['left_join'](_0x9adc('0x4f'),'me',_0x9adc('0x50'))[_0x9adc('0x47')](_0x9adc('0x51'),'it',_0x9adc('0x52'))[_0x9adc('0x47')](_0x9adc('0x42'),'t',_0x9adc('0x53'));var _0xc0d9a=squel['expr']();var _0x14f7f5=[];var _0x49de8b=squel[_0x9adc('0x54')]();var _0x3f7f6e;if(_0x39894d[_0x9adc('0x32')][_0x9adc('0x55')]){_0x3f7f6e=as['parseSearch'](_0x39894d[_0x9adc('0x32')][_0x9adc('0x55')]);var _0x35824a=_0x3f7f6e[_0x9adc('0x56')];for(var _0x4f7fde=0x0;_0x4f7fde<_0x3f7f6e[_0x9adc('0x57')][_0x9adc('0x38')];_0x4f7fde++){var _0x5580f6=_0x3f7f6e[_0x9adc('0x57')][_0x4f7fde];var _0x44375b='i';var _0x38229b=_['find'](_0x3f41bb,[_0x9adc('0x24'),_0x5580f6[_0x9adc('0x40')]]);if(!_0x38229b){switch(_0x5580f6[_0x9adc('0x40')]){case _0x9adc('0x58'):if(_0x5580f6[_0x9adc('0x59')]==0x1){_0x116428[_0x9adc('0x5a')]('`'+_0x5580f6[_0x9adc('0x40')]+_0x9adc('0x5b'));}else{_0x116428[_0x9adc('0x5a')]('`'+_0x5580f6[_0x9adc('0x40')]+_0x9adc('0x5c'));}break;case _0x9adc('0x5d'):if(_0x5580f6[_0x9adc('0x5e')]===_0x9adc('0x5f')){if(_0x5580f6['value'][_0x9adc('0x29')]('\x20')['length']>0x1){_0xc0d9a[_0x35824a](_0x9adc('0x60'),qs[_0x9adc('0x61')](_0x5580f6['value']),null);}else{var _0x2646d9='%'+_0x5580f6[_0x9adc('0x59')]+'%';_0xc0d9a[_0x35824a](_0x9adc('0x62'),_0x2646d9,_0x2646d9,_0x2646d9);}}else{_0x38229b=_['find'](_0x3f41bb,['name','ContactId']);_0x5580f6['field']=_0x9adc('0x63');_0x46100f=as[_0x9adc('0x64')](_0x44375b,_0x38229b[_0x9adc('0x65')],_0x5580f6);_0xc0d9a[_0x35824a](_0x46100f[_0x9adc('0x66')],_0x46100f[_0x9adc('0x59')]['start'],_0x46100f[_0x9adc('0x59')][_0x9adc('0x22')]);}break;case _0x9adc('0x67'):var _0x3f7bdc=_0x5580f6[_0x9adc('0x59')]['split'](',')[_0x9adc('0x26')](function(_0x2e5aee){return Number(_0x2e5aee);});_0x3f7bdc['forEach'](function(_0x1d4957){_0x49de8b['or'](_0x9adc('0x68'),'%,'+_0x1d4957+',%');});_0x14f7f5=_[_0x9adc('0x69')](_0x14f7f5,_0x3f7bdc);break;case _0x9adc('0x6a'):if(_0x5580f6[_0x9adc('0x5e')]==='$substring'){_0xc0d9a[_0x35824a]('CONCAT_WS(\x27\x20\x27,\x20o.name,\x20o.fullname)\x20LIKE\x20?','%'+_0x5580f6[_0x9adc('0x59')]+'%',null);}else{_0x38229b=_['find'](_0x3f41bb,['name','UserId']);_0x5580f6['field']='UserId';_0x46100f=as[_0x9adc('0x64')](_0x44375b,_0x38229b[_0x9adc('0x65')],_0x5580f6);_0xc0d9a[_0x35824a](_0x46100f[_0x9adc('0x66')],_0x46100f[_0x9adc('0x59')]['start'],_0x46100f[_0x9adc('0x59')][_0x9adc('0x22')]);}break;case _0x9adc('0x6b'):_0x46100f=as['buildExpression']('me',null,_0x5580f6);_0xc0d9a[_0x35824a](_0x46100f[_0x9adc('0x66')],_0x46100f[_0x9adc('0x59')]['start'],_0x46100f[_0x9adc('0x59')]['end']);break;}}else{var _0x46100f=as['buildExpression'](_0x44375b,_0x38229b[_0x9adc('0x65')],_0x5580f6);_0xc0d9a[_0x35824a](_0x46100f[_0x9adc('0x66')],_0x46100f[_0x9adc('0x59')][_0x9adc('0x6c')],_0x46100f[_0x9adc('0x59')]['end']);}}}else{var _0x241cde=_(_0x39894d[_0x9adc('0x32')])[_0x9adc('0x33')]()[_0x9adc('0x26')](function(_0x5a563c){return _[_0x9adc('0x6d')](_0x3f41bb,[_0x9adc('0x24'),_0x5a563c])?_0x5a563c:undefined;})['compact']()[_0x9adc('0x59')]();if(!_[_0x9adc('0x6e')](_0x241cde)){_0x241cde[_0x9adc('0x2a')](function(_0x47fd75){if(_0x47fd75===_0x9adc('0x6f')){_0x116428[_0x9adc('0x3d')](_0x9adc('0x70'),[][_0x9adc('0x71')](_0x39894d['query'][_0x47fd75]));}else if(_0x47fd75==='createdAt'){var _0x2c0845=JSON[_0x9adc('0x72')](_0x39894d[_0x9adc('0x32')][_0x47fd75])[_0x9adc('0x73')];var _0x2aa754=JSON[_0x9adc('0x72')](_0x39894d[_0x9adc('0x32')][_0x47fd75])['$lte'];_0x116428['where'](_0x9adc('0x74'),_0x2c0845,_0x2aa754);}else{if(_0x39894d[_0x9adc('0x32')][_0x47fd75]===_0x9adc('0x75')){_0x116428[_0x9adc('0x3d')]('i.'+_0x47fd75+_0x9adc('0x76'));}else{_0x116428[_0x9adc('0x3d')]('i.'+_0x47fd75+'\x20=\x20?',_0x39894d[_0x9adc('0x32')][_0x47fd75]);}}});}if(_0x39894d[_0x9adc('0x32')][_0x9adc('0x77')]){if(_0x39894d[_0x9adc('0x32')][_0x9adc('0x77')]==0x1){_0x116428[_0x9adc('0x5a')](_0x9adc('0x78'));}else{_0x116428[_0x9adc('0x5a')](_0x9adc('0x79'));}}if(_0x39894d[_0x9adc('0x32')][_0x9adc('0x7a')]){_0x14f7f5=_[_0x9adc('0x7b')](_0x39894d[_0x9adc('0x32')]['tag'])?_0x39894d[_0x9adc('0x32')][_0x9adc('0x7a')]:new Array(_0x39894d[_0x9adc('0x32')][_0x9adc('0x7a')]);_0x14f7f5['forEach'](function(_0x278736){_0x49de8b['or'](_0x9adc('0x68'),'%,'+_0x278736+',%');});}if(_0x39894d[_0x9adc('0x32')][_0x9adc('0x7c')]){var _0x9c206=_0x39894d[_0x9adc('0x32')][_0x9adc('0x7c')]['replace']('\x5c','\x5c\x5c')[_0x9adc('0x7d')]('\x27\x27','\x27\x27\x27\x27');if(qs[_0x9adc('0x7e')](_0x9c206)){_0xc0d9a['or'](_0x9adc('0x7f'),_0x9c206+'%')['or'](_0x9adc('0x80'),_0x9c206+'%');}_0xc0d9a['or'](_0x9adc('0x81'),_0x9c206+'%');}}_0x116428[_0x9adc('0x3d')](_0xc0d9a);_0x116428[_0x9adc('0x82')](_0x9adc('0x83'));var _0x97aa21={'type':db[_0x9adc('0x84')][_0x9adc('0x85')][_0x9adc('0x86')],'raw':!![]};var _0x17b59b=_0x116428[_0x9adc('0x87')]();_0x17b59b[_0x9adc('0x40')](_0x9adc('0x83'));_0x17b59b[_0x9adc('0x40')](_0x9adc('0x88'),'unreadMessages');if(_0x52a7ac[_0x9adc('0x3b')]){_0x52a7ac[_0x9adc('0x3b')][_0x9adc('0x2a')](function(_0x7f8da4){_0x116428[_0x9adc('0x3b')]('i.'+_0x7f8da4[0x0],_0x7f8da4[0x1]===_0x9adc('0x89')?![]:!![]);});}if(!_['isEmpty'](_0x14f7f5)){_0x116428[_0x9adc('0x5a')](_0x49de8b);_0x17b59b[_0x9adc('0x3d')]('t.id\x20IN\x20?',_0x14f7f5);}BPromise[_0x9adc('0x8a')]()[_0x9adc('0x21')](function(){if(!_0x3f7f6e){if(_0x39894d[_0x9adc('0x32')][_0x9adc('0x6f')]||_0x39894d[_0x9adc('0x32')]['journey'])return;_0x17b59b['where'](_0x9adc('0x8b'));_0x116428[_0x9adc('0x3d')]('i.FaxAccountId\x20IS\x20NOT\x20NULL');return;}return _0x39894d[_0x9adc('0x8c')]['getFaxAccounts']({'attributes':['id'],'raw':!![]})[_0x9adc('0x21')](function(_0x140d26){if(_[_0x9adc('0x6e')](_0x140d26)){_0x17b59b[_0x9adc('0x3d')](_0x9adc('0x8d'));_0x116428[_0x9adc('0x3d')](_0x9adc('0x8d'));}else{_0x17b59b[_0x9adc('0x3d')](_0x9adc('0x70'),_[_0x9adc('0x26')](_0x140d26,'id'));_0x116428[_0x9adc('0x3d')](_0x9adc('0x70'),_['map'](_0x140d26,'id'));}});})[_0x9adc('0x21')](function(){db[_0x9adc('0x8e')][_0x9adc('0x32')](_0x17b59b['toString'](),_0x97aa21)['then'](function(_0x1981f0){_0x20c568[_0x9adc('0x8f')]=_0x1981f0[_0x9adc('0x38')];if(_0x20c568[_0x9adc('0x8f')]===0x0)return[];return db[_0x9adc('0x8e')][_0x9adc('0x32')](_0x5ed810[_0x9adc('0x90')](),_0x97aa21)['then'](function(_0x2f3520){_0x41c892=_[_0x9adc('0x91')](_0x2f3520,'id');_0x97aa21=_['merge'](_0x97aa21,{'model':db[_0x9adc('0x2e')],'mapToModel':!![],'raw':!![],'nest':!![]});if(_0x39894d[_0x9adc('0x32')]['fields']){_0x52a7ac[_0x9adc('0x36')][_0x9adc('0x2a')](function(_0x29a192){_0x116428[_0x9adc('0x40')]('i.'+_0x29a192);});}else{_0x116428['field']('SUM(me.read\x20=\x200\x20AND\x20me.direction\x20=\x20\x27in\x27)',_0x9adc('0x58'));_0x116428[_0x9adc('0x40')](_0x9adc('0x92'),'Account.key');_0x116428['field'](_0x9adc('0x93'),'Account.mandatoryDisposition');_0x116428['field'](_0x9adc('0x94'));_0x116428[_0x9adc('0x40')](_0x9adc('0x95'),_0x9adc('0x96'));_0x116428['field'](_0x9adc('0x97'),_0x9adc('0x98'));_0x116428[_0x9adc('0x40')]('c.email','Contact.email');_0x116428['field']('c.phone',_0x9adc('0x99'));_0x116428['field'](_0x9adc('0x9a'),_0x9adc('0x9b'));_0x116428['field']('c.fax',_0x9adc('0x9c'));_0x116428[_0x9adc('0x40')](_0x9adc('0x9d'),_0x9adc('0x9e'));_0x116428[_0x9adc('0x40')](_0x9adc('0x9f'),_0x9adc('0xa0'));_0x116428[_0x9adc('0x40')](_0x9adc('0xa1'),_0x9adc('0x2c'));}_0x116428['limit'](_0x52a7ac[_0x9adc('0x1b')]);_0x116428[_0x9adc('0x3a')](_0x52a7ac['offset']);return db[_0x9adc('0x8e')][_0x9adc('0x32')](_0x116428[_0x9adc('0x90')](),_0x97aa21);})[_0x9adc('0x21')](function(_0x35d6bc){_0x12af87[_0x9adc('0x3d')](_0x9adc('0xa2'),_[_0x9adc('0x26')](_0x35d6bc,'id'));return db[_0x9adc('0x8e')][_0x9adc('0x32')](_0x12af87[_0x9adc('0x90')](),_0x97aa21)[_0x9adc('0x21')](function(_0xc2f6a1){var _0x564f4c=_['groupBy'](_0xc2f6a1,_0x9adc('0xa3'));var _0x211c24=[];_0x35d6bc[_0x9adc('0x2a')](function(_0x338bd7){_0x211c24[_0x9adc('0x2b')](updateFaxInteraction(_0x338bd7,_0x41c892,_0x564f4c));});return BPromise[_0x9adc('0xa4')](_0x211c24);});});})[_0x9adc('0x21')](function(_0x1da4d4){_0x20c568[_0x9adc('0xa5')]=_0x1da4d4;return _0x20c568;})[_0x9adc('0x21')](respondWithFilteredResult(_0x27d906,_0x52a7ac));})[_0x9adc('0x2d')](handleError(_0x27d906,null));};exports[_0x9adc('0xa6')]=function(_0x11b488,_0x5c1531){var _0x148da8={'raw':![],'where':{'id':_0x11b488['params']['id']}},_0x4ac6b1={};_0x4ac6b1['model']=_[_0x9adc('0x33')](db['FaxInteraction'][_0x9adc('0x2f')]);_0x4ac6b1[_0x9adc('0x32')]=_['keys'](_0x11b488[_0x9adc('0x32')]);_0x4ac6b1[_0x9adc('0x34')]=_['intersection'](_0x4ac6b1['model'],_0x4ac6b1[_0x9adc('0x32')]);_0x148da8['attributes']=_[_0x9adc('0x35')](_0x4ac6b1[_0x9adc('0x31')],qs[_0x9adc('0x37')](_0x11b488[_0x9adc('0x32')][_0x9adc('0x37')]));_0x148da8[_0x9adc('0x36')]=_0x148da8[_0x9adc('0x36')][_0x9adc('0x38')]?_0x148da8[_0x9adc('0x36')]:_0x4ac6b1[_0x9adc('0x31')];if(_0x11b488[_0x9adc('0x32')][_0x9adc('0xa7')]){_0x148da8['include']=[{'all':!![]}];}_0x148da8=_[_0x9adc('0xa8')]({},_0x148da8,_0x11b488[_0x9adc('0xa9')]);return db['FaxInteraction'][_0x9adc('0xaa')](_0x148da8)[_0x9adc('0x21')](handleEntityNotFound(_0x5c1531,null))[_0x9adc('0x21')](respondWithResult(_0x5c1531,null))[_0x9adc('0x2d')](handleError(_0x5c1531,null));};exports[_0x9adc('0xab')]=function(_0x40fa15,_0x338e03){return db['FaxInteraction'][_0x9adc('0xab')](_0x40fa15['body'],{})[_0x9adc('0x21')](respondWithResult(_0x338e03,0xc9))[_0x9adc('0x2d')](handleError(_0x338e03,null));};exports[_0x9adc('0x20')]=function(_0x4f01e3,_0x5d4186){if(_0x4f01e3['body']['id']){delete _0x4f01e3[_0x9adc('0x6b')]['id'];}return db[_0x9adc('0x2e')][_0x9adc('0xaa')]({'where':{'id':_0x4f01e3[_0x9adc('0xac')]['id']}})[_0x9adc('0x21')](handleEntityNotFound(_0x5d4186,null))[_0x9adc('0x21')](saveUpdates(_0x4f01e3['body'],null))[_0x9adc('0x21')](respondWithResult(_0x5d4186,null))['catch'](handleError(_0x5d4186,null));};exports[_0x9adc('0xad')]=function(_0x475b02,_0x35b511){return db[_0x9adc('0x2e')]['find']({'where':{'id':_0x475b02[_0x9adc('0xac')]['id']}})['then'](handleEntityNotFound(_0x35b511,null))[_0x9adc('0x21')](removeEntity(_0x35b511,null))[_0x9adc('0x2d')](handleError(_0x35b511,null));};exports['describe']=function(_0x339adc,_0x35db4a){return db[_0x9adc('0x2e')][_0x9adc('0xae')]()['then'](respondWithResult(_0x35db4a,null))[_0x9adc('0x2d')](handleError(_0x35db4a,null));};exports['addMessage']=function(_0x2cbcf2,_0x1fbfc2,_0xe63f8a){return db[_0x9adc('0xaf')][_0x9adc('0xaa')]({'where':{'id':_0x2cbcf2[_0x9adc('0xac')]['id']}})['then'](handleEntityNotFound(_0x1fbfc2,null))[_0x9adc('0x21')](function(_0x4dd088){if(_0x4dd088){return _0x4dd088[_0x9adc('0xb0')](_0x2cbcf2['body'][_0x9adc('0xb1')],_[_0x9adc('0xb2')](_0x2cbcf2[_0x9adc('0x6b')],[_0x9adc('0xb1'),'id'])||{});}})[_0x9adc('0x21')](respondWithResult(_0x1fbfc2,null))[_0x9adc('0x2d')](handleError(_0x1fbfc2,null));};exports[_0x9adc('0xb3')]=function(_0x5f57ec,_0x2e6372,_0x3cd521){var _0x20e511={'raw':![],'where':{}};var _0x32fc82={};var _0xc6a2bc={'count':0x0,'rows':[]};return db[_0x9adc('0x2e')][_0x9adc('0xb4')]({'where':{'id':_0x5f57ec['params']['id']}})[_0x9adc('0x21')](handleEntityNotFound(_0x2e6372,null))[_0x9adc('0x21')](function(_0x1a3a3d){if(_0x1a3a3d){_0x32fc82['model']=_[_0x9adc('0x33')](db['FaxMessage']['rawAttributes']);_0x32fc82[_0x9adc('0x32')]=_['keys'](_0x5f57ec[_0x9adc('0x32')]);_0x32fc82[_0x9adc('0x34')]=_[_0x9adc('0x35')](_0x32fc82[_0x9adc('0x31')],_0x32fc82[_0x9adc('0x32')]);_0x20e511[_0x9adc('0x36')]=_[_0x9adc('0x35')](_0x32fc82[_0x9adc('0x31')],qs[_0x9adc('0x37')](_0x5f57ec[_0x9adc('0x32')][_0x9adc('0x37')]));_0x20e511['attributes']=_0x20e511[_0x9adc('0x36')][_0x9adc('0x38')]?_0x20e511[_0x9adc('0x36')]:_0x32fc82[_0x9adc('0x31')];if(!_0x5f57ec[_0x9adc('0x32')][_0x9adc('0x39')](_0x9adc('0xb5'))){_0x20e511[_0x9adc('0x1b')]=qs[_0x9adc('0x1b')](_0x5f57ec[_0x9adc('0x32')][_0x9adc('0x1b')]);_0x20e511[_0x9adc('0x3a')]=qs[_0x9adc('0x3a')](_0x5f57ec['query']['offset']);}_0x20e511[_0x9adc('0x3b')]=qs[_0x9adc('0x3c')](_0x5f57ec[_0x9adc('0x32')][_0x9adc('0x3c')]);_0x20e511[_0x9adc('0x3d')]=qs['filters'](_['pick'](_0x5f57ec[_0x9adc('0x32')],_0x32fc82[_0x9adc('0x34')]));_0x20e511[_0x9adc('0x3d')][_0x9adc('0xa3')]=_0x1a3a3d['id'];if(_0x5f57ec[_0x9adc('0x32')]['filter']){_0x20e511[_0x9adc('0x3d')]=_['merge'](_0x20e511['where'],{'$or':_[_0x9adc('0x26')](_0x20e511[_0x9adc('0x36')],function(_0x4fe018){var _0x50d8ef={};_0x50d8ef[_0x4fe018]={'$like':'%'+_0x5f57ec[_0x9adc('0x32')][_0x9adc('0x7c')]+'%'};return _0x50d8ef;})});}if(_0x5f57ec[_0x9adc('0x32')][_0x9adc('0x73')]){var _0x5312b0=_0x5f57ec[_0x9adc('0x32')]['$gte'][_0x9adc('0x29')](',');var _0x5a3ea2={};_0x5a3ea2[_0x5312b0[0x0]]={'$gte':moment(_0x5312b0[0x1])['format'](_0x9adc('0xb6'))};_0x20e511[_0x9adc('0x3d')]=_[_0x9adc('0xa8')](_0x20e511['where'],_0x5a3ea2);}_0x20e511=_[_0x9adc('0xa8')]({},_0x20e511,_0x5f57ec[_0x9adc('0xa9')]);return db[_0x9adc('0xaf')][_0x9adc('0x8f')]({'where':_0x20e511[_0x9adc('0x3d')]})['then'](function(_0x26b5eb){_0xc6a2bc[_0x9adc('0x8f')]=_0x26b5eb;if(_0x5f57ec[_0x9adc('0x32')][_0x9adc('0xa7')]){_0x20e511[_0x9adc('0xb7')]=[{'all':!![]}];}return db[_0x9adc('0xaf')][_0x9adc('0xb8')](_0x20e511);})[_0x9adc('0x21')](function(_0x5db283){_0xc6a2bc[_0x9adc('0xa5')]=_0x5db283;return _0xc6a2bc;});}})['then'](respondWithFilteredResult(_0x2e6372,_0x20e511))['catch'](handleError(_0x2e6372,null));};exports['addTags']=function(_0x4680f6,_0x492762,_0x4a463e){return db[_0x9adc('0x2e')][_0x9adc('0xaa')]({'where':{'id':_0x4680f6[_0x9adc('0xac')]['id']}})[_0x9adc('0x21')](handleEntityNotFound(_0x492762,null))[_0x9adc('0x21')](function(_0x21e007){if(_0x21e007){return _0x21e007[_0x9adc('0xb9')](_0x4680f6[_0x9adc('0x6b')][_0x9adc('0xb1')],_[_0x9adc('0xb2')](_0x4680f6['body'],[_0x9adc('0xb1'),'id'])||{})[_0x9adc('0xba')](function(){return db['Tag']['findAll']({'attributes':['id',_0x9adc('0x24'),_0x9adc('0xbb')],'where':{'id':_0x4680f6[_0x9adc('0x6b')]['ids']}});})[_0x9adc('0x21')](function(_0x349865){socket[_0x9adc('0xbc')](_0x9adc('0xbd'),{'id':Number(_0x4680f6['params']['id']),'tags':_0x349865||[]});return{'id':Number(_0x4680f6[_0x9adc('0xac')]['id']),'tags':_0x349865||[]};});}})['then'](respondWithResult(_0x492762,null))[_0x9adc('0x2d')](handleError(_0x492762,null));};exports[_0x9adc('0xbe')]=function(_0x14735a,_0x396231,_0x3f9b42){return db[_0x9adc('0x2e')][_0x9adc('0xaa')]({'where':{'id':_0x14735a['params']['id']}})[_0x9adc('0x21')](handleEntityNotFound(_0x396231,null))[_0x9adc('0x21')](function(_0x3dceea){if(_0x3dceea){return _0x3dceea[_0x9adc('0xbe')](_0x14735a[_0x9adc('0x32')][_0x9adc('0xb1')]);}})['then'](respondWithStatusCode(_0x396231,null))['catch'](handleError(_0x396231,null));};exports[_0x9adc('0xbf')]=function(_0xd753bd,_0x2fee9b){var _0x1d52c0=moment()[_0x9adc('0xc0')]()[_0x9adc('0x90')]();var _0x366bef=path[_0x9adc('0xc1')](config[_0x9adc('0xc2')],_0x9adc('0xc3'),_0x9adc('0xc4'),'tmp');var _0xf1a168=path[_0x9adc('0xc1')](config[_0x9adc('0xc2')],_0x9adc('0xc3'),_0x9adc('0xc4'),_0x9adc('0xc5'));var _0x5be0b6=path[_0x9adc('0xc1')](_0x366bef,_0x1d52c0);var _0x51b379=util[_0x9adc('0xc6')](_0x9adc('0xc7'),_0xd753bd[_0x9adc('0xac')]['id'],_0x1d52c0);var _0x52e7d8=path['join'](_0x366bef,_0x51b379);var _0x4e19c6=[];_0x4e19c6['push']({'model':db[_0x9adc('0xc8')],'as':_0x9adc('0xc8'),'raw':!![]});var _0x2688eb=[{'model':db[_0x9adc('0xaf')],'as':_0x9adc('0xc9'),'attributes':['id',_0x9adc('0x6b'),_0x9adc('0xca')],'include':_0x4e19c6}];return db['FaxInteraction']['find']({'where':{'id':_0xd753bd[_0x9adc('0xac')]['id']},'include':_0x2688eb})[_0x9adc('0x21')](handleEntityNotFound(_0x2fee9b,null))[_0x9adc('0x21')](function(_0x177d17){if(_0x177d17&&_0x177d17[_0x9adc('0xc9')]){var _0xa17bae=_0x177d17['get']({'plain':!![]});fs['mkdirSync'](_0x5be0b6);for(var _0x1d5d45=0x0;_0x1d5d45<_0xa17bae[_0x9adc('0xc9')][_0x9adc('0x38')];_0x1d5d45++){var _0x34999d=_0xa17bae['Messages'][_0x1d5d45][_0x9adc('0xc8')];if(_0x34999d){var _0x16cc14=path[_0x9adc('0xc1')](_0xf1a168,_0x34999d[_0x9adc('0xcb')]);if(fs[_0x9adc('0xcc')](_0x16cc14)){fs[_0x9adc('0xcd')](_0x16cc14)[_0x9adc('0xce')](fs[_0x9adc('0xcf')](path[_0x9adc('0xc1')](_0x5be0b6,_0x34999d['basename'])));}}}return BPromise[_0x9adc('0x8a')]()[_0x9adc('0x21')](function(){return new BPromise(function(_0x2a7271,_0x4a9554){zipdir(_0x5be0b6,{'saveTo':_0x52e7d8},function(_0x2408e2,_0x596fa6){if(_0x2408e2)return _0x4a9554(_0x2408e2);return _0x2a7271(_0x596fa6);});})[_0x9adc('0x21')](function(){return new BPromise(function(_0x53352e,_0x124567){rimraf(_0x5be0b6,function(_0x57d701){if(_0x57d701)_0x124567(_0x57d701);return _0x53352e();});});})['then'](function(){return _0x2fee9b['download'](_0x52e7d8,_0x51b379,function(_0x5472fd){if(_0x5472fd){console[_0x9adc('0xd0')](_0x9adc('0xd1'),_0x5472fd);}else{fs[_0x9adc('0xd2')](_0x52e7d8);}});});});}else{return _0x2fee9b[_0x9adc('0xd3')](0xc8);}})[_0x9adc('0x2d')](handleError(_0x2fee9b,null));};
\ No newline at end of file
+var _0x1a6e=['sox','ejs','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/environment','../../mysqldb','redis','defaults','localhost','socket.io-emitter','./faxInteraction.socket','sendStatus','status','end','json','count','offset','limit','set','Content-Range','apply','reject','update','then','destroy','error','stack','name','send','Users','map','fullname','TagIds','split','forEach','Tags','push','index','FaxInteraction','fieldName','key','keys','query','filters','model','attributes','intersection','length','hasOwnProperty','nolimit','order','sort','where','pick','select','field','color','from','tools_tags','u.id','u.fullname','ui.FaxInteractionId','left_join','users','fax_interactions','cm_contacts','c.id\x20=\x20i.ContactId\x20AND\x20c.deletedAt\x20IS\x20NULL','fax_accounts','a.id\x20=\x20i.FaxAccountId','fax_messages','me.FaxInteractionId\x20=\x20i.id','it.FaxInteractionId\x20=\x20i.id','t.id\x20=\x20it.TagId','expr','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','ContactId','buildExpression','type','text','start','Tag','CONCAT(\x27,\x27,\x20`TagIds`,\x20\x27,\x27)\x20LIKE\x20?','union','User','operator','UserId','body','isEmpty','FaxAccountId','i.FaxAccountId\x20IN\x20?','createdAt','parse','$gte','$lte','i.createdAt\x20BETWEEN\x20?\x20AND\x20?','null','\x20IS\x20NULL','\x20=\x20?','read','`unreadMessages`\x20>\x200','tag','isArray','filter','replace','\x27\x27\x27\x27','isNumeric','i.id\x20LIKE\x20?','i.fax\x20LIKE\x20?','CONCAT(c.firstName,\x20\x27\x20\x27,\x20c.lastName)\x20LIKE\x20?','i.id','QueryTypes','clone','unreadMessages','DESC','t.id\x20IN\x20?','resolve','journey','i.FaxAccountId\x20IS\x20NOT\x20NULL','user','i.FaxAccountId\x20IS\x20NULL','sequelize','toString','keyBy','merge','fields','SUM(me.read\x20=\x200\x20AND\x20me.direction\x20=\x20\x27in\x27)','a.key','Account.key','a.mandatoryDisposition','Account.mandatoryDisposition','i.*','Contact.firstName','c.lastName','c.email','c.phone','c.mobile','Contact.mobile','Contact.fax','o.fullname','Owner.fullname','GROUP_CONCAT(DISTINCT\x20t.id)','ui.FaxInteractionId\x20IN\x20?','groupBy','FaxInteractionId','rows','catch','params','rawAttributes','includeAll','include','options','describe','addMessage','ids','omit','findOne','FaxMessage','YYYY-MM-DD\x20HH:mm:ss','findAll','addTags','removeTags','download','unix','root','files','join','server','attachments','format','transcript-%d-%s.zip','Messages','mkdirSync','basename','createReadStream','createWriteStream','err','zip-dir','fast-json-patch','request-promise','moment','mustache','util','path'];(function(_0x2e4576,_0x348ac1){var _0x84ebf9=function(_0x248089){while(--_0x248089){_0x2e4576['push'](_0x2e4576['shift']());}};_0x84ebf9(++_0x348ac1);}(_0x1a6e,0x193));var _0xe1a6=function(_0xda6d0f,_0x35e271){_0xda6d0f=_0xda6d0f-0x0;var _0x244540=_0x1a6e[_0xda6d0f];return _0x244540;};'use strict';var pdf=require('html-pdf');var emlformat=require('eml-format');var rimraf=require('rimraf');var zipdir=require(_0xe1a6('0x0'));var jsonpatch=require(_0xe1a6('0x1'));var rp=require(_0xe1a6('0x2'));var moment=require(_0xe1a6('0x3'));var BPromise=require('bluebird');var Mustache=require(_0xe1a6('0x4'));var util=require(_0xe1a6('0x5'));var path=require(_0xe1a6('0x6'));var sox=require(_0xe1a6('0x7'));var csv=require('to-csv');var ejs=require(_0xe1a6('0x8'));var fs=require('fs');var _=require('lodash');var squel=require(_0xe1a6('0x9'));var crypto=require(_0xe1a6('0xa'));var jsforce=require(_0xe1a6('0xb'));var deskjs=require(_0xe1a6('0xc'));var toCsv=require('to-csv');var querystring=require(_0xe1a6('0xd'));var Papa=require(_0xe1a6('0xe'));var Redis=require(_0xe1a6('0xf'));var authService=require(_0xe1a6('0x10'));var qs=require(_0xe1a6('0x11'));var as=require(_0xe1a6('0x12'));var hardwareService=require(_0xe1a6('0x13'));var logger=require('../../config/logger')(_0xe1a6('0x14'));var utils=require('../../config/utils');var config=require(_0xe1a6('0x15'));var db=require(_0xe1a6('0x16'))['db'];config[_0xe1a6('0x17')]=_[_0xe1a6('0x18')](config[_0xe1a6('0x17')],{'host':_0xe1a6('0x19'),'port':0x18eb});var socket=require(_0xe1a6('0x1a'))(new Redis(config['redis']));require(_0xe1a6('0x1b'))['register'](socket);function respondWithStatusCode(_0x2a0670,_0x4ef256){_0x4ef256=_0x4ef256||0xcc;return function(_0x18b820){if(_0x18b820){return _0x2a0670[_0xe1a6('0x1c')](_0x4ef256);}return _0x2a0670[_0xe1a6('0x1d')](_0x4ef256)[_0xe1a6('0x1e')]();};}function respondWithResult(_0x5279a8,_0x35f6e2){_0x35f6e2=_0x35f6e2||0xc8;return function(_0x537bc5){if(_0x537bc5){return _0x5279a8[_0xe1a6('0x1d')](_0x35f6e2)[_0xe1a6('0x1f')](_0x537bc5);}};}function respondWithFilteredResult(_0xe197f5,_0x2bbe01){return function(_0x2eb5b2){if(_0x2eb5b2){var _0x2a9de7=_0x2eb5b2[_0xe1a6('0x20')],_0x5ba228=_0x2bbe01[_0xe1a6('0x21')],_0x5a898e=_0x2bbe01[_0xe1a6('0x21')]+_0x2bbe01[_0xe1a6('0x22')],_0x320456;if(_0x5a898e>=_0x2a9de7){_0x5a898e=_0x2a9de7;_0x320456=0xc8;}else{_0x320456=0xce;}_0xe197f5[_0xe1a6('0x1d')](_0x320456);return _0xe197f5[_0xe1a6('0x23')](_0xe1a6('0x24'),_0x5ba228+'-'+_0x5a898e+'/'+_0x2a9de7)['json'](_0x2eb5b2);}return null;};}function patchUpdates(_0x2fd577){return function(_0x3e2595){try{jsonpatch[_0xe1a6('0x25')](_0x3e2595,_0x2fd577,!![]);}catch(_0x1d3930){return BPromise[_0xe1a6('0x26')](_0x1d3930);}return _0x3e2595['save']();};}function saveUpdates(_0x58b859,_0x4d14f1){return function(_0x541368){if(_0x541368){return _0x541368[_0xe1a6('0x27')](_0x58b859)[_0xe1a6('0x28')](function(_0x547635){return _0x547635;});}return null;};}function removeEntity(_0x22b24e,_0x40bae0){return function(_0x392242){if(_0x392242){return _0x392242[_0xe1a6('0x29')]()[_0xe1a6('0x28')](function(){_0x22b24e[_0xe1a6('0x1d')](0xcc)[_0xe1a6('0x1e')]();});}};}function handleEntityNotFound(_0x24a4f5,_0x25bc53){return function(_0x4305ec){if(!_0x4305ec){_0x24a4f5[_0xe1a6('0x1c')](0x194);}return _0x4305ec;};}function handleError(_0x2c282d,_0xba56df){_0xba56df=_0xba56df||0x1f4;return function(_0xc33d9){logger[_0xe1a6('0x2a')](_0xc33d9[_0xe1a6('0x2b')]);if(_0xc33d9[_0xe1a6('0x2c')]){delete _0xc33d9[_0xe1a6('0x2c')];}_0x2c282d[_0xe1a6('0x1d')](_0xba56df)[_0xe1a6('0x2d')](_0xc33d9);};}function getInteractionUsers(_0x40f37a,_0x2dfeac){return new BPromise(function(_0x586d77,_0x12818e){try{if(_0x2dfeac[_0x40f37a['id']]){_0x40f37a[_0xe1a6('0x2e')]=_[_0xe1a6('0x2f')](_0x2dfeac[_0x40f37a['id']],function(_0x1c5f62){return{'id':_0x1c5f62['id'],'fullname':_0x1c5f62[_0xe1a6('0x30')]};});}}catch(_0x46347d){_0x12818e(_0x46347d);}_0x586d77(_0x40f37a);});}function getInteractionTags(_0x3fd900,_0x49fc8e){return new BPromise(function(_0x46dd6b,_0x1bd7b5){try{if(_0x3fd900[_0xe1a6('0x31')]){_0x3fd900['Tags']=[];_0x3fd900['TagIds'][_0xe1a6('0x32')](',')[_0xe1a6('0x33')](function(_0x3d57f7){_0x3fd900[_0xe1a6('0x34')][_0xe1a6('0x35')](_0x49fc8e[_0x3d57f7]);});}delete _0x3fd900[_0xe1a6('0x31')];}catch(_0x371320){_0x1bd7b5(_0x371320);}_0x46dd6b(_0x3fd900);});}function updateFaxInteraction(_0x3db2a0,_0x37785a,_0x53bf1b){return new BPromise(function(_0x19962b,_0x136f4b){return getInteractionUsers(_0x3db2a0,_0x53bf1b)[_0xe1a6('0x28')](function(_0x3115df){return getInteractionTags(_0x3115df,_0x37785a);})[_0xe1a6('0x28')](function(_0x2ebfe6){_0x19962b(_0x2ebfe6);})['catch'](function(_0x24dc54){_0x136f4b(_0x24dc54);});});}exports[_0xe1a6('0x36')]=function(_0x1ca367,_0x34a59e){var _0x11350a={},_0x5261c8={},_0x2beed0={'count':0x0,'rows':[]};var _0x58e833=_[_0xe1a6('0x2f')](db[_0xe1a6('0x37')]['rawAttributes'],function(_0xaead8f){return{'name':_0xaead8f[_0xe1a6('0x38')],'type':_0xaead8f['type'][_0xe1a6('0x39')]};});_0x5261c8['model']=_[_0xe1a6('0x2f')](_0x58e833,_0xe1a6('0x2c'));_0x5261c8['query']=_[_0xe1a6('0x3a')](_0x1ca367[_0xe1a6('0x3b')]);_0x5261c8[_0xe1a6('0x3c')]=_['intersection'](_0x5261c8[_0xe1a6('0x3d')],_0x5261c8[_0xe1a6('0x3b')]);_0x11350a[_0xe1a6('0x3e')]=_[_0xe1a6('0x3f')](_0x5261c8[_0xe1a6('0x3d')],qs['fields'](_0x1ca367[_0xe1a6('0x3b')]['fields']));_0x11350a['attributes']=_0x11350a[_0xe1a6('0x3e')][_0xe1a6('0x40')]?_0x11350a[_0xe1a6('0x3e')]:_0x5261c8[_0xe1a6('0x3d')];if(!_0x1ca367[_0xe1a6('0x3b')][_0xe1a6('0x41')](_0xe1a6('0x42'))){_0x11350a[_0xe1a6('0x22')]=qs[_0xe1a6('0x22')](_0x1ca367[_0xe1a6('0x3b')][_0xe1a6('0x22')]);_0x11350a[_0xe1a6('0x21')]=qs[_0xe1a6('0x21')](_0x1ca367['query'][_0xe1a6('0x21')]);}_0x11350a[_0xe1a6('0x43')]=qs[_0xe1a6('0x44')](_0x1ca367[_0xe1a6('0x3b')][_0xe1a6('0x44')]);_0x11350a[_0xe1a6('0x45')]=qs[_0xe1a6('0x3c')](_[_0xe1a6('0x46')](_0x1ca367['query'],_0x5261c8['filters']));var _0x384cde=[];var _0x112821=squel[_0xe1a6('0x47')]()[_0xe1a6('0x48')]('id')[_0xe1a6('0x48')](_0xe1a6('0x2c'))[_0xe1a6('0x48')](_0xe1a6('0x49'))[_0xe1a6('0x4a')](_0xe1a6('0x4b'));var _0xff4fa9=squel[_0xe1a6('0x47')]()[_0xe1a6('0x48')](_0xe1a6('0x4c'))[_0xe1a6('0x48')](_0xe1a6('0x4d'))[_0xe1a6('0x48')](_0xe1a6('0x4e'))['from']('user_has_fax_interactions','ui')[_0xe1a6('0x4f')](_0xe1a6('0x50'),'u','u.id\x20=\x20ui.UserId');var _0x2d3544=squel[_0xe1a6('0x47')]()['from'](_0xe1a6('0x51'),'i')[_0xe1a6('0x4f')](_0xe1a6('0x52'),'c',_0xe1a6('0x53'))['left_join'](_0xe1a6('0x50'),'o','o.id\x20=\x20i.UserId')['left_join'](_0xe1a6('0x54'),'a',_0xe1a6('0x55'))[_0xe1a6('0x4f')](_0xe1a6('0x56'),'me',_0xe1a6('0x57'))[_0xe1a6('0x4f')]('fax_interaction_has_tags','it',_0xe1a6('0x58'))[_0xe1a6('0x4f')](_0xe1a6('0x4b'),'t',_0xe1a6('0x59'));var _0x231f8b=squel[_0xe1a6('0x5a')]();var _0x281948=[];var _0x363ff6=squel[_0xe1a6('0x5a')]();var _0x492c87;if(_0x1ca367[_0xe1a6('0x3b')]['search']){_0x492c87=as[_0xe1a6('0x5b')](_0x1ca367[_0xe1a6('0x3b')][_0xe1a6('0x5c')]);var _0x369b12=_0x492c87[_0xe1a6('0x5d')];for(var _0x7d89eb=0x0;_0x7d89eb<_0x492c87[_0xe1a6('0x5e')][_0xe1a6('0x40')];_0x7d89eb++){var _0x2f544a=_0x492c87[_0xe1a6('0x5e')][_0x7d89eb];var _0x5ce466='i';var _0x3867af=_[_0xe1a6('0x5f')](_0x58e833,['name',_0x2f544a[_0xe1a6('0x48')]]);if(!_0x3867af){switch(_0x2f544a[_0xe1a6('0x48')]){case'unreadMessages':if(_0x2f544a[_0xe1a6('0x60')]==0x1){_0x2d3544[_0xe1a6('0x61')]('`'+_0x2f544a[_0xe1a6('0x48')]+_0xe1a6('0x62'));}else{_0x2d3544['having']('`'+_0x2f544a['field']+_0xe1a6('0x63'));}break;case _0xe1a6('0x64'):if(_0x2f544a['operator']===_0xe1a6('0x65')){if(_0x2f544a[_0xe1a6('0x60')][_0xe1a6('0x32')]('\x20')['length']>0x1){_0x231f8b[_0x369b12](_0xe1a6('0x66'),qs[_0xe1a6('0x67')](_0x2f544a['value']),null);}else{var _0x9e806d='%'+_0x2f544a['value']+'%';_0x231f8b[_0x369b12]('c.firstName\x20LIKE\x20?\x20OR\x20c.lastName\x20LIKE\x20?\x20OR\x20c.email\x20LIKE\x20?',_0x9e806d,_0x9e806d,_0x9e806d);}}else{_0x3867af=_[_0xe1a6('0x5f')](_0x58e833,[_0xe1a6('0x2c'),_0xe1a6('0x68')]);_0x2f544a['field']=_0xe1a6('0x68');_0x226369=as[_0xe1a6('0x69')](_0x5ce466,_0x3867af[_0xe1a6('0x6a')],_0x2f544a);_0x231f8b[_0x369b12](_0x226369[_0xe1a6('0x6b')],_0x226369[_0xe1a6('0x60')][_0xe1a6('0x6c')],_0x226369[_0xe1a6('0x60')][_0xe1a6('0x1e')]);}break;case _0xe1a6('0x6d'):var _0x395aad=_0x2f544a['value'][_0xe1a6('0x32')](',')[_0xe1a6('0x2f')](function(_0x26067b){return Number(_0x26067b);});_0x395aad[_0xe1a6('0x33')](function(_0x3c0f13){_0x363ff6['or'](_0xe1a6('0x6e'),'%,'+_0x3c0f13+',%');});_0x281948=_[_0xe1a6('0x6f')](_0x281948,_0x395aad);break;case _0xe1a6('0x70'):if(_0x2f544a[_0xe1a6('0x71')]===_0xe1a6('0x65')){_0x231f8b[_0x369b12]('CONCAT_WS(\x27\x20\x27,\x20o.name,\x20o.fullname)\x20LIKE\x20?','%'+_0x2f544a[_0xe1a6('0x60')]+'%',null);}else{_0x3867af=_[_0xe1a6('0x5f')](_0x58e833,['name',_0xe1a6('0x72')]);_0x2f544a['field']='UserId';_0x226369=as[_0xe1a6('0x69')](_0x5ce466,_0x3867af[_0xe1a6('0x6a')],_0x2f544a);_0x231f8b[_0x369b12](_0x226369[_0xe1a6('0x6b')],_0x226369[_0xe1a6('0x60')][_0xe1a6('0x6c')],_0x226369['value']['end']);}break;case _0xe1a6('0x73'):_0x226369=as[_0xe1a6('0x69')]('me',null,_0x2f544a);_0x231f8b[_0x369b12](_0x226369[_0xe1a6('0x6b')],_0x226369['value'][_0xe1a6('0x6c')],_0x226369[_0xe1a6('0x60')]['end']);break;}}else{var _0x226369=as[_0xe1a6('0x69')](_0x5ce466,_0x3867af[_0xe1a6('0x6a')],_0x2f544a);_0x231f8b[_0x369b12](_0x226369[_0xe1a6('0x6b')],_0x226369[_0xe1a6('0x60')][_0xe1a6('0x6c')],_0x226369[_0xe1a6('0x60')][_0xe1a6('0x1e')]);}}}else{var _0xfe2710=_(_0x1ca367['query'])[_0xe1a6('0x3a')]()['map'](function(_0x103214){return _['some'](_0x58e833,[_0xe1a6('0x2c'),_0x103214])?_0x103214:undefined;})['compact']()[_0xe1a6('0x60')]();if(!_[_0xe1a6('0x74')](_0xfe2710)){_0xfe2710[_0xe1a6('0x33')](function(_0x437af4){if(_0x437af4===_0xe1a6('0x75')){_0x2d3544[_0xe1a6('0x45')](_0xe1a6('0x76'),[]['concat'](_0x1ca367[_0xe1a6('0x3b')][_0x437af4]));}else if(_0x437af4===_0xe1a6('0x77')){var _0x113430=JSON[_0xe1a6('0x78')](_0x1ca367[_0xe1a6('0x3b')][_0x437af4])[_0xe1a6('0x79')];var _0x127a9a=JSON[_0xe1a6('0x78')](_0x1ca367[_0xe1a6('0x3b')][_0x437af4])[_0xe1a6('0x7a')];_0x2d3544[_0xe1a6('0x45')](_0xe1a6('0x7b'),_0x113430,_0x127a9a);}else{if(_0x1ca367[_0xe1a6('0x3b')][_0x437af4]===_0xe1a6('0x7c')){_0x2d3544['where']('i.'+_0x437af4+_0xe1a6('0x7d'));}else{_0x2d3544[_0xe1a6('0x45')]('i.'+_0x437af4+_0xe1a6('0x7e'),_0x1ca367[_0xe1a6('0x3b')][_0x437af4]);}}});}if(_0x1ca367[_0xe1a6('0x3b')][_0xe1a6('0x7f')]){if(_0x1ca367['query'][_0xe1a6('0x7f')]==0x1){_0x2d3544[_0xe1a6('0x61')]('`unreadMessages`\x20=\x200');}else{_0x2d3544['having'](_0xe1a6('0x80'));}}if(_0x1ca367[_0xe1a6('0x3b')][_0xe1a6('0x81')]){_0x281948=_[_0xe1a6('0x82')](_0x1ca367[_0xe1a6('0x3b')][_0xe1a6('0x81')])?_0x1ca367['query'][_0xe1a6('0x81')]:new Array(_0x1ca367[_0xe1a6('0x3b')][_0xe1a6('0x81')]);_0x281948['forEach'](function(_0x2cae14){_0x363ff6['or'](_0xe1a6('0x6e'),'%,'+_0x2cae14+',%');});}if(_0x1ca367[_0xe1a6('0x3b')][_0xe1a6('0x83')]){var _0x479f8d=_0x1ca367['query'][_0xe1a6('0x83')]['replace']('\x5c','\x5c\x5c')[_0xe1a6('0x84')]('\x27\x27',_0xe1a6('0x85'));if(qs[_0xe1a6('0x86')](_0x479f8d)){_0x231f8b['or'](_0xe1a6('0x87'),_0x479f8d+'%')['or'](_0xe1a6('0x88'),_0x479f8d+'%');}_0x231f8b['or'](_0xe1a6('0x89'),_0x479f8d+'%');}}_0x2d3544['where'](_0x231f8b);_0x2d3544['group'](_0xe1a6('0x8a'));var _0x3a7ff4={'type':db['Sequelize'][_0xe1a6('0x8b')]['SELECT'],'raw':!![]};var _0x52ff2e=_0x2d3544[_0xe1a6('0x8c')]();_0x52ff2e['field']('i.id');_0x52ff2e[_0xe1a6('0x48')]('SUM(me.read\x20=\x200\x20AND\x20me.direction\x20=\x20\x27in\x27)',_0xe1a6('0x8d'));if(_0x11350a[_0xe1a6('0x43')]){_0x11350a[_0xe1a6('0x43')]['forEach'](function(_0x29acb4){_0x2d3544[_0xe1a6('0x43')]('i.'+_0x29acb4[0x0],_0x29acb4[0x1]===_0xe1a6('0x8e')?![]:!![]);});}if(!_[_0xe1a6('0x74')](_0x281948)){_0x2d3544[_0xe1a6('0x61')](_0x363ff6);_0x52ff2e[_0xe1a6('0x45')](_0xe1a6('0x8f'),_0x281948);}BPromise[_0xe1a6('0x90')]()[_0xe1a6('0x28')](function(){if(!_0x492c87){if(_0x1ca367[_0xe1a6('0x3b')][_0xe1a6('0x75')]||_0x1ca367['query'][_0xe1a6('0x91')])return;_0x52ff2e['where'](_0xe1a6('0x92'));_0x2d3544[_0xe1a6('0x45')](_0xe1a6('0x92'));return;}return _0x1ca367[_0xe1a6('0x93')]['getFaxAccounts']({'attributes':['id'],'raw':!![]})[_0xe1a6('0x28')](function(_0x4fc312){if(_[_0xe1a6('0x74')](_0x4fc312)){_0x52ff2e[_0xe1a6('0x45')]('i.FaxAccountId\x20IS\x20NULL');_0x2d3544[_0xe1a6('0x45')](_0xe1a6('0x94'));}else{_0x52ff2e[_0xe1a6('0x45')](_0xe1a6('0x76'),_[_0xe1a6('0x2f')](_0x4fc312,'id'));_0x2d3544[_0xe1a6('0x45')](_0xe1a6('0x76'),_['map'](_0x4fc312,'id'));}});})[_0xe1a6('0x28')](function(){db[_0xe1a6('0x95')][_0xe1a6('0x3b')](_0x52ff2e[_0xe1a6('0x96')](),_0x3a7ff4)[_0xe1a6('0x28')](function(_0x7d03e3){_0x2beed0[_0xe1a6('0x20')]=_0x7d03e3[_0xe1a6('0x40')];if(_0x2beed0[_0xe1a6('0x20')]===0x0)return[];return db['sequelize'][_0xe1a6('0x3b')](_0x112821['toString'](),_0x3a7ff4)[_0xe1a6('0x28')](function(_0x5d02bb){_0x384cde=_[_0xe1a6('0x97')](_0x5d02bb,'id');_0x3a7ff4=_[_0xe1a6('0x98')](_0x3a7ff4,{'model':db[_0xe1a6('0x37')],'mapToModel':!![],'raw':!![],'nest':!![]});if(_0x1ca367['query'][_0xe1a6('0x99')]){_0x11350a[_0xe1a6('0x3e')]['forEach'](function(_0x2fc548){_0x2d3544[_0xe1a6('0x48')]('i.'+_0x2fc548);});}else{_0x2d3544[_0xe1a6('0x48')](_0xe1a6('0x9a'),_0xe1a6('0x8d'));_0x2d3544[_0xe1a6('0x48')](_0xe1a6('0x9b'),_0xe1a6('0x9c'));_0x2d3544[_0xe1a6('0x48')](_0xe1a6('0x9d'),_0xe1a6('0x9e'));_0x2d3544[_0xe1a6('0x48')](_0xe1a6('0x9f'));_0x2d3544[_0xe1a6('0x48')]('c.firstName',_0xe1a6('0xa0'));_0x2d3544['field'](_0xe1a6('0xa1'),'Contact.lastName');_0x2d3544['field'](_0xe1a6('0xa2'),'Contact.email');_0x2d3544[_0xe1a6('0x48')](_0xe1a6('0xa3'),'Contact.phone');_0x2d3544[_0xe1a6('0x48')](_0xe1a6('0xa4'),_0xe1a6('0xa5'));_0x2d3544['field']('c.fax',_0xe1a6('0xa6'));_0x2d3544[_0xe1a6('0x48')](_0xe1a6('0xa7'),_0xe1a6('0xa8'));_0x2d3544['field']('o.internal','Owner.internal');_0x2d3544[_0xe1a6('0x48')](_0xe1a6('0xa9'),_0xe1a6('0x31'));}_0x2d3544[_0xe1a6('0x22')](_0x11350a[_0xe1a6('0x22')]);_0x2d3544['offset'](_0x11350a[_0xe1a6('0x21')]);return db[_0xe1a6('0x95')][_0xe1a6('0x3b')](_0x2d3544[_0xe1a6('0x96')](),_0x3a7ff4);})['then'](function(_0x2f674f){_0xff4fa9[_0xe1a6('0x45')](_0xe1a6('0xaa'),_[_0xe1a6('0x2f')](_0x2f674f,'id'));return db[_0xe1a6('0x95')]['query'](_0xff4fa9[_0xe1a6('0x96')](),_0x3a7ff4)[_0xe1a6('0x28')](function(_0xfb1705){var _0x3e74a4=_[_0xe1a6('0xab')](_0xfb1705,_0xe1a6('0xac'));var _0x353487=[];_0x2f674f[_0xe1a6('0x33')](function(_0x66767){_0x353487[_0xe1a6('0x35')](updateFaxInteraction(_0x66767,_0x384cde,_0x3e74a4));});return BPromise['all'](_0x353487);});});})['then'](function(_0x3d7f0e){_0x2beed0[_0xe1a6('0xad')]=_0x3d7f0e;return _0x2beed0;})[_0xe1a6('0x28')](respondWithFilteredResult(_0x34a59e,_0x11350a));})[_0xe1a6('0xae')](handleError(_0x34a59e,null));};exports['show']=function(_0x45e016,_0x27c3c2){var _0x3bea45={'raw':![],'where':{'id':_0x45e016[_0xe1a6('0xaf')]['id']}},_0x17b7ee={};_0x17b7ee[_0xe1a6('0x3d')]=_[_0xe1a6('0x3a')](db['FaxInteraction'][_0xe1a6('0xb0')]);_0x17b7ee[_0xe1a6('0x3b')]=_[_0xe1a6('0x3a')](_0x45e016[_0xe1a6('0x3b')]);_0x17b7ee[_0xe1a6('0x3c')]=_[_0xe1a6('0x3f')](_0x17b7ee[_0xe1a6('0x3d')],_0x17b7ee[_0xe1a6('0x3b')]);_0x3bea45[_0xe1a6('0x3e')]=_[_0xe1a6('0x3f')](_0x17b7ee[_0xe1a6('0x3d')],qs[_0xe1a6('0x99')](_0x45e016[_0xe1a6('0x3b')]['fields']));_0x3bea45[_0xe1a6('0x3e')]=_0x3bea45['attributes'][_0xe1a6('0x40')]?_0x3bea45['attributes']:_0x17b7ee['model'];if(_0x45e016[_0xe1a6('0x3b')][_0xe1a6('0xb1')]){_0x3bea45[_0xe1a6('0xb2')]=[{'all':!![]}];}_0x3bea45=_[_0xe1a6('0x98')]({},_0x3bea45,_0x45e016[_0xe1a6('0xb3')]);return db[_0xe1a6('0x37')][_0xe1a6('0x5f')](_0x3bea45)[_0xe1a6('0x28')](handleEntityNotFound(_0x27c3c2,null))[_0xe1a6('0x28')](respondWithResult(_0x27c3c2,null))[_0xe1a6('0xae')](handleError(_0x27c3c2,null));};exports['create']=function(_0x446798,_0x1a7628){return db[_0xe1a6('0x37')]['create'](_0x446798[_0xe1a6('0x73')],{})[_0xe1a6('0x28')](respondWithResult(_0x1a7628,0xc9))[_0xe1a6('0xae')](handleError(_0x1a7628,null));};exports['update']=function(_0x5dadab,_0x172b8a){if(_0x5dadab[_0xe1a6('0x73')]['id']){delete _0x5dadab[_0xe1a6('0x73')]['id'];}return db[_0xe1a6('0x37')]['find']({'where':{'id':_0x5dadab[_0xe1a6('0xaf')]['id']}})['then'](handleEntityNotFound(_0x172b8a,null))[_0xe1a6('0x28')](saveUpdates(_0x5dadab[_0xe1a6('0x73')],null))[_0xe1a6('0x28')](respondWithResult(_0x172b8a,null))['catch'](handleError(_0x172b8a,null));};exports[_0xe1a6('0x29')]=function(_0x3b157c,_0xaede02){return db['FaxInteraction'][_0xe1a6('0x5f')]({'where':{'id':_0x3b157c[_0xe1a6('0xaf')]['id']}})[_0xe1a6('0x28')](handleEntityNotFound(_0xaede02,null))[_0xe1a6('0x28')](removeEntity(_0xaede02,null))[_0xe1a6('0xae')](handleError(_0xaede02,null));};exports['describe']=function(_0x5823cf,_0x229bbb){return db[_0xe1a6('0x37')][_0xe1a6('0xb4')]()['then'](respondWithResult(_0x229bbb,null))[_0xe1a6('0xae')](handleError(_0x229bbb,null));};exports[_0xe1a6('0xb5')]=function(_0x5b6bb5,_0x5c0796,_0x41b493){return db['FaxMessage'][_0xe1a6('0x5f')]({'where':{'id':_0x5b6bb5[_0xe1a6('0xaf')]['id']}})['then'](handleEntityNotFound(_0x5c0796,null))[_0xe1a6('0x28')](function(_0x54e5a3){if(_0x54e5a3){return _0x54e5a3['addMessage'](_0x5b6bb5[_0xe1a6('0x73')][_0xe1a6('0xb6')],_[_0xe1a6('0xb7')](_0x5b6bb5['body'],['ids','id'])||{});}})[_0xe1a6('0x28')](respondWithResult(_0x5c0796,null))[_0xe1a6('0xae')](handleError(_0x5c0796,null));};exports['getMessages']=function(_0x2384c7,_0x55845e,_0x5c0d1d){var _0x5e35f3={'raw':![],'where':{}};var _0x1e4dd8={};var _0x40dbb3={'count':0x0,'rows':[]};return db[_0xe1a6('0x37')][_0xe1a6('0xb8')]({'where':{'id':_0x2384c7['params']['id']}})[_0xe1a6('0x28')](handleEntityNotFound(_0x55845e,null))[_0xe1a6('0x28')](function(_0x2df0e4){if(_0x2df0e4){_0x1e4dd8[_0xe1a6('0x3d')]=_['keys'](db[_0xe1a6('0xb9')][_0xe1a6('0xb0')]);_0x1e4dd8['query']=_[_0xe1a6('0x3a')](_0x2384c7[_0xe1a6('0x3b')]);_0x1e4dd8['filters']=_[_0xe1a6('0x3f')](_0x1e4dd8[_0xe1a6('0x3d')],_0x1e4dd8[_0xe1a6('0x3b')]);_0x5e35f3[_0xe1a6('0x3e')]=_['intersection'](_0x1e4dd8[_0xe1a6('0x3d')],qs['fields'](_0x2384c7[_0xe1a6('0x3b')][_0xe1a6('0x99')]));_0x5e35f3[_0xe1a6('0x3e')]=_0x5e35f3['attributes'][_0xe1a6('0x40')]?_0x5e35f3[_0xe1a6('0x3e')]:_0x1e4dd8[_0xe1a6('0x3d')];if(!_0x2384c7[_0xe1a6('0x3b')][_0xe1a6('0x41')](_0xe1a6('0x42'))){_0x5e35f3[_0xe1a6('0x22')]=qs['limit'](_0x2384c7['query'][_0xe1a6('0x22')]);_0x5e35f3[_0xe1a6('0x21')]=qs[_0xe1a6('0x21')](_0x2384c7[_0xe1a6('0x3b')]['offset']);}_0x5e35f3[_0xe1a6('0x43')]=qs[_0xe1a6('0x44')](_0x2384c7[_0xe1a6('0x3b')][_0xe1a6('0x44')]);_0x5e35f3[_0xe1a6('0x45')]=qs[_0xe1a6('0x3c')](_[_0xe1a6('0x46')](_0x2384c7[_0xe1a6('0x3b')],_0x1e4dd8['filters']));_0x5e35f3[_0xe1a6('0x45')][_0xe1a6('0xac')]=_0x2df0e4['id'];if(_0x2384c7[_0xe1a6('0x3b')][_0xe1a6('0x83')]){_0x5e35f3['where']=_[_0xe1a6('0x98')](_0x5e35f3[_0xe1a6('0x45')],{'$or':_[_0xe1a6('0x2f')](_0x5e35f3[_0xe1a6('0x3e')],function(_0x18b47c){var _0x40bd36={};_0x40bd36[_0x18b47c]={'$like':'%'+_0x2384c7[_0xe1a6('0x3b')][_0xe1a6('0x83')]+'%'};return _0x40bd36;})});}if(_0x2384c7[_0xe1a6('0x3b')][_0xe1a6('0x79')]){var _0x3acdf8=_0x2384c7[_0xe1a6('0x3b')][_0xe1a6('0x79')][_0xe1a6('0x32')](',');var _0x4d2cdb={};_0x4d2cdb[_0x3acdf8[0x0]]={'$gte':moment(_0x3acdf8[0x1])['format'](_0xe1a6('0xba'))};_0x5e35f3[_0xe1a6('0x45')]=_[_0xe1a6('0x98')](_0x5e35f3[_0xe1a6('0x45')],_0x4d2cdb);}_0x5e35f3=_['merge']({},_0x5e35f3,_0x2384c7[_0xe1a6('0xb3')]);return db[_0xe1a6('0xb9')]['count']({'where':_0x5e35f3[_0xe1a6('0x45')]})[_0xe1a6('0x28')](function(_0x1676d0){_0x40dbb3[_0xe1a6('0x20')]=_0x1676d0;if(_0x2384c7[_0xe1a6('0x3b')][_0xe1a6('0xb1')]){_0x5e35f3[_0xe1a6('0xb2')]=[{'all':!![]}];}return db[_0xe1a6('0xb9')][_0xe1a6('0xbb')](_0x5e35f3);})[_0xe1a6('0x28')](function(_0x13f83b){_0x40dbb3[_0xe1a6('0xad')]=_0x13f83b;return _0x40dbb3;});}})['then'](respondWithFilteredResult(_0x55845e,_0x5e35f3))[_0xe1a6('0xae')](handleError(_0x55845e,null));};exports[_0xe1a6('0xbc')]=function(_0x5d570f,_0x3321f5,_0x5250b3){return db[_0xe1a6('0x37')][_0xe1a6('0x5f')]({'where':{'id':_0x5d570f[_0xe1a6('0xaf')]['id']}})[_0xe1a6('0x28')](handleEntityNotFound(_0x3321f5,null))[_0xe1a6('0x28')](function(_0x18e146){if(_0x18e146){return _0x18e146['setTags'](_0x5d570f['body'][_0xe1a6('0xb6')],_[_0xe1a6('0xb7')](_0x5d570f[_0xe1a6('0x73')],[_0xe1a6('0xb6'),'id'])||{})['spread'](function(){return db[_0xe1a6('0x6d')]['findAll']({'attributes':['id',_0xe1a6('0x2c'),_0xe1a6('0x49')],'where':{'id':_0x5d570f[_0xe1a6('0x73')][_0xe1a6('0xb6')]}});})[_0xe1a6('0x28')](function(_0x160dcc){socket['emit']('faxInteractionTags:save',{'id':Number(_0x5d570f[_0xe1a6('0xaf')]['id']),'tags':_0x160dcc||[]});return{'id':Number(_0x5d570f[_0xe1a6('0xaf')]['id']),'tags':_0x160dcc||[]};});}})['then'](respondWithResult(_0x3321f5,null))[_0xe1a6('0xae')](handleError(_0x3321f5,null));};exports[_0xe1a6('0xbd')]=function(_0x3108ea,_0x12f763,_0x3e1d7d){return db['FaxInteraction'][_0xe1a6('0x5f')]({'where':{'id':_0x3108ea[_0xe1a6('0xaf')]['id']}})[_0xe1a6('0x28')](handleEntityNotFound(_0x12f763,null))['then'](function(_0x57ed25){if(_0x57ed25){return _0x57ed25[_0xe1a6('0xbd')](_0x3108ea[_0xe1a6('0x3b')][_0xe1a6('0xb6')]);}})[_0xe1a6('0x28')](respondWithStatusCode(_0x12f763,null))['catch'](handleError(_0x12f763,null));};exports[_0xe1a6('0xbe')]=function(_0x11f58f,_0x1c6025){var _0x528fff=moment()[_0xe1a6('0xbf')]()[_0xe1a6('0x96')]();var _0x8be27a=path['join'](config[_0xe1a6('0xc0')],'server',_0xe1a6('0xc1'),'tmp');var _0x353706=path[_0xe1a6('0xc2')](config[_0xe1a6('0xc0')],_0xe1a6('0xc3'),_0xe1a6('0xc1'),_0xe1a6('0xc4'));var _0x23f224=path[_0xe1a6('0xc2')](_0x8be27a,_0x528fff);var _0x11ffe7=util[_0xe1a6('0xc5')](_0xe1a6('0xc6'),_0x11f58f['params']['id'],_0x528fff);var _0x126677=path['join'](_0x8be27a,_0x11ffe7);var _0x3aeb73=[];_0x3aeb73[_0xe1a6('0x35')]({'model':db['Attachment'],'as':'Attachment','raw':!![]});var _0x1a823a=[{'model':db['FaxMessage'],'as':_0xe1a6('0xc7'),'attributes':['id',_0xe1a6('0x73'),_0xe1a6('0x77')],'include':_0x3aeb73}];return db[_0xe1a6('0x37')][_0xe1a6('0x5f')]({'where':{'id':_0x11f58f[_0xe1a6('0xaf')]['id']},'include':_0x1a823a})['then'](handleEntityNotFound(_0x1c6025,null))['then'](function(_0x44374f){if(_0x44374f&&_0x44374f['Messages']){var _0x52f1c7=_0x44374f['get']({'plain':!![]});fs[_0xe1a6('0xc8')](_0x23f224);for(var _0x4249bc=0x0;_0x4249bc<_0x52f1c7[_0xe1a6('0xc7')][_0xe1a6('0x40')];_0x4249bc++){var _0x923191=_0x52f1c7[_0xe1a6('0xc7')][_0x4249bc]['Attachment'];if(_0x923191){var _0x35b68d=path['join'](_0x353706,_0x923191[_0xe1a6('0xc9')]);if(fs['existsSync'](_0x35b68d)){fs[_0xe1a6('0xca')](_0x35b68d)['pipe'](fs[_0xe1a6('0xcb')](path[_0xe1a6('0xc2')](_0x23f224,_0x923191[_0xe1a6('0xc9')])));}}}return BPromise[_0xe1a6('0x90')]()[_0xe1a6('0x28')](function(){return new BPromise(function(_0x249e74,_0x5f5811){zipdir(_0x23f224,{'saveTo':_0x126677},function(_0x5bc415,_0x2ac3a2){if(_0x5bc415)return _0x5f5811(_0x5bc415);return _0x249e74(_0x2ac3a2);});})[_0xe1a6('0x28')](function(){return new BPromise(function(_0x46dacb,_0x343078){rimraf(_0x23f224,function(_0x3dcf3f){if(_0x3dcf3f)_0x343078(_0x3dcf3f);return _0x46dacb();});});})[_0xe1a6('0x28')](function(){return _0x1c6025[_0xe1a6('0xbe')](_0x126677,_0x11ffe7,function(_0x428bf9){if(_0x428bf9){console['log'](_0xe1a6('0xcc'),_0x428bf9);}else{fs['unlinkSync'](_0x126677);}});});});}else{return _0x1c6025['sendStatus'](0xc8);}})['catch'](handleError(_0x1c6025,null));};
\ No newline at end of file