Built motion from commit (unavailable).|2.5.20
[motion2.git] / server / api / faxInteraction / faxInteraction.controller.js
index 1de4057..37c1580 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x57f8=['crypto','desk.js','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','redis','localhost','socket.io-emitter','./faxInteraction.socket','sendStatus','end','status','json','count','offset','limit','set','Content-Range','apply','reject','then','destroy','error','name','send','Users','map','fullname','TagIds','Tags','forEach','push','catch','type','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','select','field','from','u.id','u.fullname','ui.FaxInteractionId','user_has_fax_interactions','left_join','cm_contacts','c.id\x20=\x20i.ContactId\x20AND\x20c.deletedAt\x20IS\x20NULL','users','o.id\x20=\x20i.UserId','fax_accounts','fax_messages','me.FaxInteractionId\x20=\x20i.id','it.FaxInteractionId\x20=\x20i.id','tools_tags','t.id\x20=\x20it.TagId','parseSearch','search','sqlOperator','conditions','unreadMessages','value','having','`\x20>\x200','Contact','operator','$substring','split','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','Tag','CONCAT(\x27,\x27,\x20`TagIds`,\x20\x27,\x27)\x20LIKE\x20?','union','User','find','UserId','body','some','isEmpty','FaxAccountId','i.FaxAccountId\x20IN\x20?','concat','parse','$gte','$lte','i.createdAt\x20BETWEEN\x20?\x20AND\x20?','null','\x20IS\x20NULL','\x20=\x20?','read','`unreadMessages`\x20>\x200','tag','filter','replace','\x27\x27\x27\x27','isNumeric','i.id\x20LIKE\x20?','i.fax\x20LIKE\x20?','group','i.id','QueryTypes','clone','SUM(me.read\x20=\x200\x20AND\x20me.direction\x20=\x20\x27in\x27)','DESC','t.id\x20IN\x20?','resolve','journey','i.FaxAccountId\x20IS\x20NOT\x20NULL','user','getFaxAccounts','i.FaxAccountId\x20IS\x20NULL','sequelize','toString','keyBy','FaxInteraction','Account.key','a.mandatoryDisposition','Account.mandatoryDisposition','i.*','c.firstName','Contact.firstName','c.phone','Contact.phone','c.mobile','Contact.mobile','c.fax','Contact.fax','o.fullname','Owner.fullname','o.internal','Owner.internal','GROUP_CONCAT(DISTINCT\x20t.id)','groupBy','FaxInteractionId','rows','rawAttributes','includeAll','merge','create','update','params','describe','addMessage','FaxMessage','ids','omit','YYYY-MM-DD\x20HH:mm:ss','options','findAll','addTags','setTags','spread','color','faxInteractionTags:save','removeTags','unix','join','root','server','files','tmp','format','transcript-%d-%s.zip','Attachment','Messages','get','basename','existsSync','createReadStream','pipe','createWriteStream','download','err','unlinkSync','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','lodash','squel'];(function(_0x3a308f,_0x3b39b5){var _0x1eaf93=function(_0x48501c){while(--_0x48501c){_0x3a308f['push'](_0x3a308f['shift']());}};_0x1eaf93(++_0x3b39b5);}(_0x57f8,0x198));var _0x857f=function(_0x6f2ce5,_0x4231eb){_0x6f2ce5=_0x6f2ce5-0x0;var _0x28a54a=_0x57f8[_0x6f2ce5];return _0x28a54a;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0x857f('0x0'));var rimraf=require(_0x857f('0x1'));var zipdir=require(_0x857f('0x2'));var jsonpatch=require(_0x857f('0x3'));var rp=require(_0x857f('0x4'));var moment=require(_0x857f('0x5'));var BPromise=require(_0x857f('0x6'));var Mustache=require(_0x857f('0x7'));var util=require(_0x857f('0x8'));var path=require(_0x857f('0x9'));var sox=require(_0x857f('0xa'));var csv=require(_0x857f('0xb'));var ejs=require('ejs');var fs=require('fs');var _=require(_0x857f('0xc'));var squel=require(_0x857f('0xd'));var crypto=require(_0x857f('0xe'));var jsforce=require('jsforce');var deskjs=require(_0x857f('0xf'));var toCsv=require(_0x857f('0xb'));var querystring=require(_0x857f('0x10'));var Papa=require('papaparse');var Redis=require(_0x857f('0x11'));var authService=require(_0x857f('0x12'));var qs=require(_0x857f('0x13'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x857f('0x14'));var logger=require(_0x857f('0x15'))(_0x857f('0x16'));var utils=require(_0x857f('0x17'));var config=require(_0x857f('0x18'));var db=require(_0x857f('0x19'))['db'];config[_0x857f('0x1a')]=_['defaults'](config[_0x857f('0x1a')],{'host':_0x857f('0x1b'),'port':0x18eb});var socket=require(_0x857f('0x1c'))(new Redis(config[_0x857f('0x1a')]));require(_0x857f('0x1d'))['register'](socket);function respondWithStatusCode(_0x4bc590,_0x3b09d9){_0x3b09d9=_0x3b09d9||0xcc;return function(_0x5f27b2){if(_0x5f27b2){return _0x4bc590[_0x857f('0x1e')](_0x3b09d9);}return _0x4bc590['status'](_0x3b09d9)[_0x857f('0x1f')]();};}function respondWithResult(_0x134a4f,_0x5c3a69){_0x5c3a69=_0x5c3a69||0xc8;return function(_0x27e8f1){if(_0x27e8f1){return _0x134a4f[_0x857f('0x20')](_0x5c3a69)[_0x857f('0x21')](_0x27e8f1);}};}function respondWithFilteredResult(_0x10b547,_0x279e74){return function(_0x38a3c2){if(_0x38a3c2){var _0x1a9ef8=_0x38a3c2[_0x857f('0x22')],_0x429e23=_0x279e74['offset'],_0x1014ca=_0x279e74[_0x857f('0x23')]+_0x279e74[_0x857f('0x24')],_0x38a242;if(_0x1014ca>=_0x1a9ef8){_0x1014ca=_0x1a9ef8;_0x38a242=0xc8;}else{_0x38a242=0xce;}_0x10b547['status'](_0x38a242);return _0x10b547[_0x857f('0x25')](_0x857f('0x26'),_0x429e23+'-'+_0x1014ca+'/'+_0x1a9ef8)[_0x857f('0x21')](_0x38a3c2);}return null;};}function patchUpdates(_0x484035){return function(_0x57fa8b){try{jsonpatch[_0x857f('0x27')](_0x57fa8b,_0x484035,!![]);}catch(_0x8f278){return BPromise[_0x857f('0x28')](_0x8f278);}return _0x57fa8b['save']();};}function saveUpdates(_0x118237,_0x17a98e){return function(_0xdf8ac3){if(_0xdf8ac3){return _0xdf8ac3['update'](_0x118237)[_0x857f('0x29')](function(_0x14a8ce){return _0x14a8ce;});}return null;};}function removeEntity(_0x50bfb7,_0x3bc543){return function(_0x1a651f){if(_0x1a651f){return _0x1a651f[_0x857f('0x2a')]()[_0x857f('0x29')](function(){_0x50bfb7[_0x857f('0x20')](0xcc)[_0x857f('0x1f')]();});}};}function handleEntityNotFound(_0x233a68,_0x2a89ba){return function(_0x181a9e){if(!_0x181a9e){_0x233a68[_0x857f('0x1e')](0x194);}return _0x181a9e;};}function handleError(_0x72f0aa,_0x4782ab){_0x4782ab=_0x4782ab||0x1f4;return function(_0x250731){logger[_0x857f('0x2b')](_0x250731['stack']);if(_0x250731[_0x857f('0x2c')]){delete _0x250731[_0x857f('0x2c')];}_0x72f0aa[_0x857f('0x20')](_0x4782ab)[_0x857f('0x2d')](_0x250731);};}function getInteractionUsers(_0x58c2de,_0x40c306){return new BPromise(function(_0x57ceaa,_0x1b405a){try{if(_0x40c306[_0x58c2de['id']]){_0x58c2de[_0x857f('0x2e')]=_[_0x857f('0x2f')](_0x40c306[_0x58c2de['id']],function(_0x2ab814){return{'id':_0x2ab814['id'],'fullname':_0x2ab814[_0x857f('0x30')]};});}}catch(_0x464e8f){_0x1b405a(_0x464e8f);}_0x57ceaa(_0x58c2de);});}function getInteractionTags(_0x1c4fff,_0xe79241){return new BPromise(function(_0x17e7b6,_0x41f832){try{if(_0x1c4fff[_0x857f('0x31')]){_0x1c4fff[_0x857f('0x32')]=[];_0x1c4fff[_0x857f('0x31')]['split'](',')[_0x857f('0x33')](function(_0x24d370){_0x1c4fff['Tags'][_0x857f('0x34')](_0xe79241[_0x24d370]);});}delete _0x1c4fff[_0x857f('0x31')];}catch(_0x537ba1){_0x41f832(_0x537ba1);}_0x17e7b6(_0x1c4fff);});}function updateFaxInteraction(_0x2262c6,_0x3ee1f7,_0x4c9157){return new BPromise(function(_0x109f76,_0x3c9c75){return getInteractionUsers(_0x2262c6,_0x4c9157)[_0x857f('0x29')](function(_0x2cc74e){return getInteractionTags(_0x2cc74e,_0x3ee1f7);})['then'](function(_0x596b2f){_0x109f76(_0x596b2f);})[_0x857f('0x35')](function(_0x385d7b){_0x3c9c75(_0x385d7b);});});}exports['index']=function(_0x26d2b5,_0x4d3a87){var _0x1ff000={},_0x365bc2={},_0x677deb={'count':0x0,'rows':[]};var _0x438ff1=_[_0x857f('0x2f')](db['FaxInteraction']['rawAttributes'],function(_0x10f99d){return{'name':_0x10f99d['fieldName'],'type':_0x10f99d[_0x857f('0x36')][_0x857f('0x37')]};});_0x365bc2[_0x857f('0x38')]=_['map'](_0x438ff1,_0x857f('0x2c'));_0x365bc2[_0x857f('0x39')]=_[_0x857f('0x3a')](_0x26d2b5[_0x857f('0x39')]);_0x365bc2[_0x857f('0x3b')]=_[_0x857f('0x3c')](_0x365bc2[_0x857f('0x38')],_0x365bc2['query']);_0x1ff000[_0x857f('0x3d')]=_[_0x857f('0x3c')](_0x365bc2[_0x857f('0x38')],qs[_0x857f('0x3e')](_0x26d2b5[_0x857f('0x39')][_0x857f('0x3e')]));_0x1ff000[_0x857f('0x3d')]=_0x1ff000['attributes'][_0x857f('0x3f')]?_0x1ff000[_0x857f('0x3d')]:_0x365bc2[_0x857f('0x38')];if(!_0x26d2b5[_0x857f('0x39')][_0x857f('0x40')](_0x857f('0x41'))){_0x1ff000['limit']=qs[_0x857f('0x24')](_0x26d2b5[_0x857f('0x39')][_0x857f('0x24')]);_0x1ff000[_0x857f('0x23')]=qs[_0x857f('0x23')](_0x26d2b5[_0x857f('0x39')][_0x857f('0x23')]);}_0x1ff000[_0x857f('0x42')]=qs['sort'](_0x26d2b5[_0x857f('0x39')][_0x857f('0x43')]);_0x1ff000[_0x857f('0x44')]=qs[_0x857f('0x3b')](_[_0x857f('0x45')](_0x26d2b5[_0x857f('0x39')],_0x365bc2[_0x857f('0x3b')]),_0x438ff1);var _0x42d922=[];var _0xb4d7c2=squel[_0x857f('0x46')]()[_0x857f('0x47')]('id')[_0x857f('0x47')](_0x857f('0x2c'))[_0x857f('0x47')]('color')[_0x857f('0x48')]('tools_tags');var _0x2ce1c0=squel[_0x857f('0x46')]()[_0x857f('0x47')](_0x857f('0x49'))[_0x857f('0x47')](_0x857f('0x4a'))[_0x857f('0x47')](_0x857f('0x4b'))[_0x857f('0x48')](_0x857f('0x4c'),'ui')[_0x857f('0x4d')]('users','u','u.id\x20=\x20ui.UserId');var _0x865fc2=squel['select']()[_0x857f('0x48')]('fax_interactions','i')[_0x857f('0x4d')](_0x857f('0x4e'),'c',_0x857f('0x4f'))[_0x857f('0x4d')](_0x857f('0x50'),'o',_0x857f('0x51'))[_0x857f('0x4d')](_0x857f('0x52'),'a','a.id\x20=\x20i.FaxAccountId')[_0x857f('0x4d')](_0x857f('0x53'),'me',_0x857f('0x54'))[_0x857f('0x4d')]('fax_interaction_has_tags','it',_0x857f('0x55'))[_0x857f('0x4d')](_0x857f('0x56'),'t',_0x857f('0x57'));var _0x67563=squel['expr']();var _0x3d28d9=[];var _0x3c1b39=squel['expr']();var _0xfd1679;if(_0x26d2b5[_0x857f('0x39')]['search']){_0xfd1679=as[_0x857f('0x58')](_0x26d2b5['query'][_0x857f('0x59')]);var _0x12b62c=_0xfd1679[_0x857f('0x5a')];for(var _0x2008d5=0x0;_0x2008d5<_0xfd1679[_0x857f('0x5b')][_0x857f('0x3f')];_0x2008d5++){var _0x256347=_0xfd1679[_0x857f('0x5b')][_0x2008d5];var _0x1ac191='i';var _0x6e39f4=_['find'](_0x438ff1,[_0x857f('0x2c'),_0x256347[_0x857f('0x47')]]);if(!_0x6e39f4){switch(_0x256347[_0x857f('0x47')]){case _0x857f('0x5c'):if(_0x256347[_0x857f('0x5d')]==0x1){_0x865fc2[_0x857f('0x5e')]('`'+_0x256347[_0x857f('0x47')]+'`\x20=\x200');}else{_0x865fc2[_0x857f('0x5e')]('`'+_0x256347[_0x857f('0x47')]+_0x857f('0x5f'));}break;case _0x857f('0x60'):if(_0x256347[_0x857f('0x61')]===_0x857f('0x62')){if(_0x256347['value'][_0x857f('0x63')]('\x20')[_0x857f('0x3f')]>0x1){_0x67563[_0x12b62c](_0x857f('0x64'),qs[_0x857f('0x65')](_0x256347[_0x857f('0x5d')]),null);}else{var _0x658eb0='%'+_0x256347[_0x857f('0x5d')]+'%';_0x67563[_0x12b62c](_0x857f('0x66'),_0x658eb0,_0x658eb0,_0x658eb0);}}else{_0x6e39f4=_['find'](_0x438ff1,['name',_0x857f('0x67')]);_0x256347[_0x857f('0x47')]=_0x857f('0x67');_0x36d746=as[_0x857f('0x68')](_0x1ac191,_0x6e39f4[_0x857f('0x36')],_0x256347);_0x67563[_0x12b62c](_0x36d746[_0x857f('0x69')],_0x36d746['value'][_0x857f('0x6a')],_0x36d746[_0x857f('0x5d')]['end']);}break;case _0x857f('0x6b'):var _0x5e3759=_0x256347[_0x857f('0x5d')][_0x857f('0x63')](',')['map'](function(_0x3f5a6e){return Number(_0x3f5a6e);});_0x5e3759[_0x857f('0x33')](function(_0x3520d3){_0x3c1b39['or'](_0x857f('0x6c'),'%,'+_0x3520d3+',%');});_0x3d28d9=_[_0x857f('0x6d')](_0x3d28d9,_0x5e3759);break;case _0x857f('0x6e'):if(_0x256347[_0x857f('0x61')]===_0x857f('0x62')){_0x67563[_0x12b62c]('CONCAT_WS(\x27\x20\x27,\x20o.name,\x20o.fullname)\x20LIKE\x20?','%'+_0x256347[_0x857f('0x5d')]+'%',null);}else{_0x6e39f4=_[_0x857f('0x6f')](_0x438ff1,[_0x857f('0x2c'),_0x857f('0x70')]);_0x256347[_0x857f('0x47')]=_0x857f('0x70');_0x36d746=as[_0x857f('0x68')](_0x1ac191,_0x6e39f4[_0x857f('0x36')],_0x256347);_0x67563[_0x12b62c](_0x36d746[_0x857f('0x69')],_0x36d746[_0x857f('0x5d')][_0x857f('0x6a')],_0x36d746['value'][_0x857f('0x1f')]);}break;case _0x857f('0x71'):_0x36d746=as[_0x857f('0x68')]('me',null,_0x256347);_0x67563[_0x12b62c](_0x36d746[_0x857f('0x69')],_0x36d746['value'][_0x857f('0x6a')],_0x36d746['value'][_0x857f('0x1f')]);break;}}else{var _0x36d746=as[_0x857f('0x68')](_0x1ac191,_0x6e39f4[_0x857f('0x36')],_0x256347);_0x67563[_0x12b62c](_0x36d746['text'],_0x36d746['value'][_0x857f('0x6a')],_0x36d746[_0x857f('0x5d')][_0x857f('0x1f')]);}}}else{var _0x49e7df=_(_0x26d2b5[_0x857f('0x39')])['keys']()[_0x857f('0x2f')](function(_0x1d6c1c){return _[_0x857f('0x72')](_0x438ff1,['name',_0x1d6c1c])?_0x1d6c1c:undefined;})['compact']()[_0x857f('0x5d')]();if(!_[_0x857f('0x73')](_0x49e7df)){_0x49e7df[_0x857f('0x33')](function(_0x570e3a){if(_0x570e3a===_0x857f('0x74')){_0x865fc2[_0x857f('0x44')](_0x857f('0x75'),[][_0x857f('0x76')](_0x26d2b5['query'][_0x570e3a]));}else if(_0x570e3a==='createdAt'){var _0x38c86b=JSON[_0x857f('0x77')](_0x26d2b5[_0x857f('0x39')][_0x570e3a])[_0x857f('0x78')];var _0x43ca9b=JSON[_0x857f('0x77')](_0x26d2b5['query'][_0x570e3a])[_0x857f('0x79')];_0x865fc2[_0x857f('0x44')](_0x857f('0x7a'),_0x38c86b,_0x43ca9b);}else{if(_0x26d2b5[_0x857f('0x39')][_0x570e3a]===_0x857f('0x7b')){_0x865fc2[_0x857f('0x44')]('i.'+_0x570e3a+_0x857f('0x7c'));}else{_0x865fc2[_0x857f('0x44')]('i.'+_0x570e3a+_0x857f('0x7d'),_0x26d2b5[_0x857f('0x39')][_0x570e3a]);}}});}if(_0x26d2b5['query'][_0x857f('0x7e')]){if(_0x26d2b5['query']['read']==0x1){_0x865fc2[_0x857f('0x5e')]('`unreadMessages`\x20=\x200');}else{_0x865fc2['having'](_0x857f('0x7f'));}}if(_0x26d2b5['query'][_0x857f('0x80')]){_0x3d28d9=_['isArray'](_0x26d2b5[_0x857f('0x39')][_0x857f('0x80')])?_0x26d2b5[_0x857f('0x39')][_0x857f('0x80')]:new Array(_0x26d2b5['query'][_0x857f('0x80')]);_0x3d28d9[_0x857f('0x33')](function(_0x3100aa){_0x3c1b39['or'](_0x857f('0x6c'),'%,'+_0x3100aa+',%');});}if(_0x26d2b5[_0x857f('0x39')][_0x857f('0x81')]){var _0x195760=_0x26d2b5['query']['filter'][_0x857f('0x82')]('\x5c','\x5c\x5c')[_0x857f('0x82')]('\x27\x27',_0x857f('0x83'));if(qs[_0x857f('0x84')](_0x195760)){_0x67563['or'](_0x857f('0x85'),_0x195760+'%')['or'](_0x857f('0x86'),_0x195760+'%');}_0x67563['or']('CONCAT(c.firstName,\x20\x27\x20\x27,\x20c.lastName)\x20LIKE\x20?',_0x195760+'%');}}_0x865fc2[_0x857f('0x44')](_0x67563);_0x865fc2[_0x857f('0x87')](_0x857f('0x88'));var _0x4fa8a8={'type':db['Sequelize'][_0x857f('0x89')]['SELECT'],'raw':!![]};var _0x4b07c5=_0x865fc2[_0x857f('0x8a')]();_0x4b07c5[_0x857f('0x47')]('i.id');_0x4b07c5[_0x857f('0x47')](_0x857f('0x8b'),'unreadMessages');if(_0x1ff000[_0x857f('0x42')]){_0x1ff000[_0x857f('0x42')][_0x857f('0x33')](function(_0x2398df){_0x865fc2[_0x857f('0x42')]('i.'+_0x2398df[0x0],_0x2398df[0x1]===_0x857f('0x8c')?![]:!![]);});}if(!_[_0x857f('0x73')](_0x3d28d9)){_0x865fc2[_0x857f('0x5e')](_0x3c1b39);_0x4b07c5[_0x857f('0x44')](_0x857f('0x8d'),_0x3d28d9);}BPromise[_0x857f('0x8e')]()[_0x857f('0x29')](function(){if(!_0xfd1679){if(_0x26d2b5['query']['FaxAccountId']||_0x26d2b5['query'][_0x857f('0x8f')])return;_0x4b07c5[_0x857f('0x44')](_0x857f('0x90'));_0x865fc2[_0x857f('0x44')](_0x857f('0x90'));return;}return _0x26d2b5[_0x857f('0x91')][_0x857f('0x92')]({'attributes':['id'],'raw':!![]})['then'](function(_0x40077e){if(_['isEmpty'](_0x40077e)){_0x4b07c5[_0x857f('0x44')]('i.FaxAccountId\x20IS\x20NULL');_0x865fc2['where'](_0x857f('0x93'));}else{_0x4b07c5['where'](_0x857f('0x75'),_[_0x857f('0x2f')](_0x40077e,'id'));_0x865fc2[_0x857f('0x44')]('i.FaxAccountId\x20IN\x20?',_[_0x857f('0x2f')](_0x40077e,'id'));}});})[_0x857f('0x29')](function(){db[_0x857f('0x94')][_0x857f('0x39')](_0x4b07c5[_0x857f('0x95')](),_0x4fa8a8)[_0x857f('0x29')](function(_0x11b818){_0x677deb[_0x857f('0x22')]=_0x11b818[_0x857f('0x3f')];if(_0x677deb['count']===0x0)return[];return db[_0x857f('0x94')][_0x857f('0x39')](_0xb4d7c2[_0x857f('0x95')](),_0x4fa8a8)[_0x857f('0x29')](function(_0x5d61f3){_0x42d922=_[_0x857f('0x96')](_0x5d61f3,'id');_0x4fa8a8=_['merge'](_0x4fa8a8,{'model':db[_0x857f('0x97')],'mapToModel':!![],'raw':!![],'nest':!![]});if(_0x26d2b5[_0x857f('0x39')][_0x857f('0x3e')]){_0x1ff000[_0x857f('0x3d')]['forEach'](function(_0x372df1){_0x865fc2['field']('i.'+_0x372df1);});}else{_0x865fc2['field'](_0x857f('0x8b'),_0x857f('0x5c'));_0x865fc2['field']('a.key',_0x857f('0x98'));_0x865fc2[_0x857f('0x47')](_0x857f('0x99'),_0x857f('0x9a'));_0x865fc2['field'](_0x857f('0x9b'));_0x865fc2[_0x857f('0x47')](_0x857f('0x9c'),_0x857f('0x9d'));_0x865fc2[_0x857f('0x47')]('c.lastName','Contact.lastName');_0x865fc2[_0x857f('0x47')]('c.email','Contact.email');_0x865fc2[_0x857f('0x47')](_0x857f('0x9e'),_0x857f('0x9f'));_0x865fc2[_0x857f('0x47')](_0x857f('0xa0'),_0x857f('0xa1'));_0x865fc2[_0x857f('0x47')](_0x857f('0xa2'),_0x857f('0xa3'));_0x865fc2[_0x857f('0x47')](_0x857f('0xa4'),_0x857f('0xa5'));_0x865fc2[_0x857f('0x47')](_0x857f('0xa6'),_0x857f('0xa7'));_0x865fc2[_0x857f('0x47')](_0x857f('0xa8'),_0x857f('0x31'));}if(_0x1ff000[_0x857f('0x24')])_0x865fc2[_0x857f('0x24')](_0x1ff000[_0x857f('0x24')]);if(_0x1ff000[_0x857f('0x23')])_0x865fc2['offset'](_0x1ff000['offset']);return db['sequelize'][_0x857f('0x39')](_0x865fc2[_0x857f('0x95')](),_0x4fa8a8);})['then'](function(_0x411fee){_0x2ce1c0[_0x857f('0x44')]('ui.FaxInteractionId\x20IN\x20?',_[_0x857f('0x2f')](_0x411fee,'id'));return db['sequelize'][_0x857f('0x39')](_0x2ce1c0['toString'](),_0x4fa8a8)[_0x857f('0x29')](function(_0x1e858f){var _0x429a2b=_[_0x857f('0xa9')](_0x1e858f,_0x857f('0xaa'));var _0x1b761b=[];_0x411fee[_0x857f('0x33')](function(_0x18a010){_0x1b761b[_0x857f('0x34')](updateFaxInteraction(_0x18a010,_0x42d922,_0x429a2b));});return BPromise['all'](_0x1b761b);});});})[_0x857f('0x29')](function(_0x5242d3){_0x677deb[_0x857f('0xab')]=_0x5242d3;return _0x677deb;})[_0x857f('0x29')](respondWithFilteredResult(_0x4d3a87,_0x1ff000));})['catch'](handleError(_0x4d3a87,null));};exports['show']=function(_0x4d9c25,_0x14ba78){var _0x3347ec={'raw':![],'where':{'id':_0x4d9c25['params']['id']}},_0x6ae65={};_0x6ae65[_0x857f('0x38')]=_['keys'](db[_0x857f('0x97')][_0x857f('0xac')]);_0x6ae65[_0x857f('0x39')]=_[_0x857f('0x3a')](_0x4d9c25['query']);_0x6ae65[_0x857f('0x3b')]=_[_0x857f('0x3c')](_0x6ae65['model'],_0x6ae65[_0x857f('0x39')]);_0x3347ec['attributes']=_[_0x857f('0x3c')](_0x6ae65[_0x857f('0x38')],qs[_0x857f('0x3e')](_0x4d9c25[_0x857f('0x39')][_0x857f('0x3e')]));_0x3347ec[_0x857f('0x3d')]=_0x3347ec[_0x857f('0x3d')][_0x857f('0x3f')]?_0x3347ec[_0x857f('0x3d')]:_0x6ae65['model'];if(_0x4d9c25[_0x857f('0x39')][_0x857f('0xad')]){_0x3347ec['include']=[{'all':!![]}];}_0x3347ec=_[_0x857f('0xae')]({},_0x3347ec,_0x4d9c25['options']);return db[_0x857f('0x97')]['find'](_0x3347ec)[_0x857f('0x29')](handleEntityNotFound(_0x14ba78,null))['then'](respondWithResult(_0x14ba78,null))[_0x857f('0x35')](handleError(_0x14ba78,null));};exports[_0x857f('0xaf')]=function(_0xcf40fe,_0xb1240d){return db[_0x857f('0x97')][_0x857f('0xaf')](_0xcf40fe['body'],{})[_0x857f('0x29')](respondWithResult(_0xb1240d,0xc9))['catch'](handleError(_0xb1240d,null));};exports[_0x857f('0xb0')]=function(_0x9ae2e6,_0x4906e6){if(_0x9ae2e6[_0x857f('0x71')]['id']){delete _0x9ae2e6[_0x857f('0x71')]['id'];}return db[_0x857f('0x97')]['find']({'where':{'id':_0x9ae2e6[_0x857f('0xb1')]['id']}})['then'](handleEntityNotFound(_0x4906e6,null))[_0x857f('0x29')](saveUpdates(_0x9ae2e6[_0x857f('0x71')],null))['then'](respondWithResult(_0x4906e6,null))[_0x857f('0x35')](handleError(_0x4906e6,null));};exports['destroy']=function(_0x2e349f,_0x333b8a){return db['FaxInteraction'][_0x857f('0x6f')]({'where':{'id':_0x2e349f[_0x857f('0xb1')]['id']}})[_0x857f('0x29')](handleEntityNotFound(_0x333b8a,null))['then'](removeEntity(_0x333b8a,null))[_0x857f('0x35')](handleError(_0x333b8a,null));};exports[_0x857f('0xb2')]=function(_0x42d10e,_0x1ea073){return db['FaxInteraction'][_0x857f('0xb2')]()[_0x857f('0x29')](respondWithResult(_0x1ea073,null))[_0x857f('0x35')](handleError(_0x1ea073,null));};exports[_0x857f('0xb3')]=function(_0x1ba225,_0x4f22d1,_0x5394a9){return db[_0x857f('0xb4')][_0x857f('0x6f')]({'where':{'id':_0x1ba225[_0x857f('0xb1')]['id']}})[_0x857f('0x29')](handleEntityNotFound(_0x4f22d1,null))[_0x857f('0x29')](function(_0x4f9468){if(_0x4f9468){return _0x4f9468['addMessage'](_0x1ba225[_0x857f('0x71')][_0x857f('0xb5')],_[_0x857f('0xb6')](_0x1ba225[_0x857f('0x71')],[_0x857f('0xb5'),'id'])||{});}})[_0x857f('0x29')](respondWithResult(_0x4f22d1,null))[_0x857f('0x35')](handleError(_0x4f22d1,null));};exports['getMessages']=function(_0x32f05c,_0x388d5c,_0x540d89){var _0xf69474={'raw':![],'where':{}};var _0x1d04e7={};var _0x548a34={'count':0x0,'rows':[]};return db[_0x857f('0x97')]['findOne']({'where':{'id':_0x32f05c[_0x857f('0xb1')]['id']}})[_0x857f('0x29')](handleEntityNotFound(_0x388d5c,null))[_0x857f('0x29')](function(_0x26f695){if(_0x26f695){_0x1d04e7[_0x857f('0x38')]=_['keys'](db[_0x857f('0xb4')][_0x857f('0xac')]);_0x1d04e7[_0x857f('0x39')]=_['keys'](_0x32f05c['query']);_0x1d04e7[_0x857f('0x3b')]=_[_0x857f('0x3c')](_0x1d04e7[_0x857f('0x38')],_0x1d04e7[_0x857f('0x39')]);_0xf69474[_0x857f('0x3d')]=_[_0x857f('0x3c')](_0x1d04e7['model'],qs['fields'](_0x32f05c['query']['fields']));_0xf69474[_0x857f('0x3d')]=_0xf69474[_0x857f('0x3d')][_0x857f('0x3f')]?_0xf69474[_0x857f('0x3d')]:_0x1d04e7[_0x857f('0x38')];if(!_0x32f05c[_0x857f('0x39')][_0x857f('0x40')]('nolimit')){_0xf69474[_0x857f('0x24')]=qs[_0x857f('0x24')](_0x32f05c[_0x857f('0x39')][_0x857f('0x24')]);_0xf69474['offset']=qs[_0x857f('0x23')](_0x32f05c[_0x857f('0x39')][_0x857f('0x23')]);}_0xf69474[_0x857f('0x42')]=qs[_0x857f('0x43')](_0x32f05c[_0x857f('0x39')][_0x857f('0x43')]);_0xf69474[_0x857f('0x44')]=qs['filters'](_[_0x857f('0x45')](_0x32f05c[_0x857f('0x39')],_0x1d04e7[_0x857f('0x3b')]));_0xf69474['where'][_0x857f('0xaa')]=_0x26f695['id'];if(_0x32f05c[_0x857f('0x39')][_0x857f('0x81')]){_0xf69474[_0x857f('0x44')]=_[_0x857f('0xae')](_0xf69474[_0x857f('0x44')],{'$or':_[_0x857f('0x2f')](_0xf69474[_0x857f('0x3d')],function(_0x5c5bf1){var _0x346906={};_0x346906[_0x5c5bf1]={'$like':'%'+_0x32f05c[_0x857f('0x39')]['filter']+'%'};return _0x346906;})});}if(_0x32f05c['query']['$gte']){var _0x2a43e2=_0x32f05c[_0x857f('0x39')][_0x857f('0x78')]['split'](',');var _0x3ca6b0={};_0x3ca6b0[_0x2a43e2[0x0]]={'$gte':moment(_0x2a43e2[0x1])['format'](_0x857f('0xb7'))};_0xf69474[_0x857f('0x44')]=_[_0x857f('0xae')](_0xf69474[_0x857f('0x44')],_0x3ca6b0);}_0xf69474=_[_0x857f('0xae')]({},_0xf69474,_0x32f05c[_0x857f('0xb8')]);return db['FaxMessage'][_0x857f('0x22')]({'where':_0xf69474[_0x857f('0x44')]})[_0x857f('0x29')](function(_0x1783d9){_0x548a34[_0x857f('0x22')]=_0x1783d9;if(_0x32f05c['query'][_0x857f('0xad')]){_0xf69474['include']=[{'all':!![]}];}return db[_0x857f('0xb4')][_0x857f('0xb9')](_0xf69474);})[_0x857f('0x29')](function(_0x2440f3){_0x548a34[_0x857f('0xab')]=_0x2440f3;return _0x548a34;});}})[_0x857f('0x29')](respondWithFilteredResult(_0x388d5c,_0xf69474))[_0x857f('0x35')](handleError(_0x388d5c,null));};exports[_0x857f('0xba')]=function(_0x16898b,_0x546e0e,_0x238041){return db[_0x857f('0x97')][_0x857f('0x6f')]({'where':{'id':_0x16898b[_0x857f('0xb1')]['id']}})[_0x857f('0x29')](handleEntityNotFound(_0x546e0e,null))['then'](function(_0x1df670){if(_0x1df670){return _0x1df670[_0x857f('0xbb')](_0x16898b[_0x857f('0x71')][_0x857f('0xb5')],_['omit'](_0x16898b[_0x857f('0x71')],[_0x857f('0xb5'),'id'])||{})[_0x857f('0xbc')](function(){return db['Tag'][_0x857f('0xb9')]({'attributes':['id',_0x857f('0x2c'),_0x857f('0xbd')],'where':{'id':_0x16898b[_0x857f('0x71')][_0x857f('0xb5')]}});})[_0x857f('0x29')](function(_0x178bfb){socket['emit'](_0x857f('0xbe'),{'id':Number(_0x16898b[_0x857f('0xb1')]['id']),'tags':_0x178bfb||[]});return{'id':Number(_0x16898b[_0x857f('0xb1')]['id']),'tags':_0x178bfb||[]};});}})[_0x857f('0x29')](respondWithResult(_0x546e0e,null))['catch'](handleError(_0x546e0e,null));};exports['removeTags']=function(_0x5e86c1,_0x58e14a,_0x2409b5){return db[_0x857f('0x97')]['find']({'where':{'id':_0x5e86c1[_0x857f('0xb1')]['id']}})[_0x857f('0x29')](handleEntityNotFound(_0x58e14a,null))[_0x857f('0x29')](function(_0x5c0183){if(_0x5c0183){return _0x5c0183[_0x857f('0xbf')](_0x5e86c1['query']['ids']);}})['then'](respondWithStatusCode(_0x58e14a,null))[_0x857f('0x35')](handleError(_0x58e14a,null));};exports['download']=function(_0x167f8a,_0x4c88a7){var _0x4b8b41=moment()[_0x857f('0xc0')]()[_0x857f('0x95')]();var _0x412ab5=path[_0x857f('0xc1')](config[_0x857f('0xc2')],_0x857f('0xc3'),_0x857f('0xc4'),_0x857f('0xc5'));var _0x4e40d7=path[_0x857f('0xc1')](config[_0x857f('0xc2')],_0x857f('0xc3'),_0x857f('0xc4'),'attachments');var _0x2fecee=path['join'](_0x412ab5,_0x4b8b41);var _0x38f34d=util[_0x857f('0xc6')](_0x857f('0xc7'),_0x167f8a[_0x857f('0xb1')]['id'],_0x4b8b41);var _0x4787e0=path[_0x857f('0xc1')](_0x412ab5,_0x38f34d);var _0xf9ccef=[];_0xf9ccef[_0x857f('0x34')]({'model':db[_0x857f('0xc8')],'as':_0x857f('0xc8'),'raw':!![]});var _0x4826a1=[{'model':db['FaxMessage'],'as':_0x857f('0xc9'),'attributes':['id',_0x857f('0x71'),'createdAt'],'include':_0xf9ccef}];return db[_0x857f('0x97')][_0x857f('0x6f')]({'where':{'id':_0x167f8a[_0x857f('0xb1')]['id']},'include':_0x4826a1})[_0x857f('0x29')](handleEntityNotFound(_0x4c88a7,null))[_0x857f('0x29')](function(_0x2fc56d){if(_0x2fc56d&&_0x2fc56d['Messages']){var _0x5724ef=_0x2fc56d[_0x857f('0xca')]({'plain':!![]});fs['mkdirSync'](_0x2fecee);for(var _0x49b297=0x0;_0x49b297<_0x5724ef['Messages'][_0x857f('0x3f')];_0x49b297++){var _0x54d2b7=_0x5724ef[_0x857f('0xc9')][_0x49b297][_0x857f('0xc8')];if(_0x54d2b7){var _0x6e9892=path[_0x857f('0xc1')](_0x4e40d7,_0x54d2b7[_0x857f('0xcb')]);if(fs[_0x857f('0xcc')](_0x6e9892)){fs[_0x857f('0xcd')](_0x6e9892)[_0x857f('0xce')](fs[_0x857f('0xcf')](path['join'](_0x2fecee,_0x54d2b7['basename'])));}}}return BPromise[_0x857f('0x8e')]()[_0x857f('0x29')](function(){return new BPromise(function(_0xfd5f8b,_0x188bb9){zipdir(_0x2fecee,{'saveTo':_0x4787e0},function(_0x5e3dca,_0x49e2ad){if(_0x5e3dca)return _0x188bb9(_0x5e3dca);return _0xfd5f8b(_0x49e2ad);});})[_0x857f('0x29')](function(){return new BPromise(function(_0x19e197,_0x502a32){rimraf(_0x2fecee,function(_0x401177){if(_0x401177)_0x502a32(_0x401177);return _0x19e197();});});})['then'](function(){return _0x4c88a7[_0x857f('0xd0')](_0x4787e0,_0x38f34d,function(_0x3ccb37){if(_0x3ccb37){console['log'](_0x857f('0xd1'),_0x3ccb37);}else{fs[_0x857f('0xd2')](_0x4787e0);}});});});}else{return _0x4c88a7['sendStatus'](0xc8);}})[_0x857f('0x35')](handleError(_0x4c88a7,null));};
\ No newline at end of file
+var _0x8bb8=['isEmpty','forEach','i.FaxAccountId\x20IN\x20?','concat','createdAt','parse','$lte','i.createdAt\x20BETWEEN\x20?\x20AND\x20?','null','\x20IS\x20NULL','\x20=\x20?','`unreadMessages`\x20>\x200','tag','isArray','filter','replace','isNumeric','i.id\x20LIKE\x20?','i.fax\x20LIKE\x20?','CONCAT(c.firstName,\x20\x27\x20\x27,\x20c.lastName)\x20LIKE\x20?','group','SELECT','clone','i.id','order','contactName','DESC','t.id\x20IN\x20?','resolve','FaxAccountId','i.FaxAccountId\x20IS\x20NOT\x20NULL','user','role','agent','getFaxAccounts','i.FaxAccountId\x20IS\x20NULL','sequelize','toString','merge','SUM(me.read\x20=\x200\x20AND\x20me.direction\x20=\x20\x27in\x27)','Account.key','a.mandatoryDisposition','Account.mandatoryDisposition','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','i.*','Contact.firstName','c.lastName','Contact.lastName','c.email','Contact.email','c.phone','Contact.phone','c.mobile','Contact.mobile','c.fax','Contact.fax','Owner.fullname','o.internal','Owner.internal','GROUP_CONCAT(DISTINCT\x20t.id)','ui.FaxInteractionId\x20IN\x20?','groupBy','FaxInteractionId','all','show','params','includeAll','options','describe','addMessage','FaxMessage','ids','omit','findOne','pick','$gte','format','YYYY-MM-DD\x20HH:mm:ss','include','findAll','addTags','spread','emit','faxInteractionTags:save','removeTags','download','root','server','files','tmp','join','transcript-%d-%s.zip','Attachment','Messages','get','mkdirSync','basename','existsSync','createReadStream','log','unlinkSync','eml-format','rimraf','zip-dir','fast-json-patch','bluebird','mustache','util','path','sox','to-csv','ejs','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','api','../../config/utils','../../config/license/util','../../mysqldb','redis','localhost','socket.io-emitter','./faxInteraction.socket','register','sendStatus','status','end','count','offset','limit','set','Content-Range','json','reject','save','update','then','destroy','error','stack','name','Users','fullname','TagIds','Tags','split','push','catch','FaxInteraction','rawAttributes','fieldName','type','map','query','keys','filters','attributes','intersection','model','fields','length','hasOwnProperty','nolimit','sort','where','select','field','color','tools_tags','u.id','u.fullname','from','user_has_fax_interactions','left_join','fax_interactions','cm_contacts','c.id\x20=\x20i.ContactId\x20AND\x20c.deletedAt\x20IS\x20NULL','users','o.id\x20=\x20i.UserId','fax_accounts','fax_messages','fax_interaction_has_tags','it.FaxInteractionId\x20=\x20i.id','expr','search','parseSearch','sqlOperator','conditions','find','unreadMessages','value','having','`\x20>\x200','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','CONCAT(\x27,\x27,\x20`TagIds`,\x20\x27,\x27)\x20LIKE\x20?','union','User','UserId','body','some','compact'];(function(_0x4f0667,_0x57729c){var _0x454f42=function(_0x582ac4){while(--_0x582ac4){_0x4f0667['push'](_0x4f0667['shift']());}};_0x454f42(++_0x57729c);}(_0x8bb8,0x13b));var _0x88bb=function(_0x1326ff,_0x1c6c99){_0x1326ff=_0x1326ff-0x0;var _0x1e1ad5=_0x8bb8[_0x1326ff];return _0x1e1ad5;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0x88bb('0x0'));var rimraf=require(_0x88bb('0x1'));var zipdir=require(_0x88bb('0x2'));var jsonpatch=require(_0x88bb('0x3'));var rp=require('request-promise');var moment=require('moment');var BPromise=require(_0x88bb('0x4'));var Mustache=require(_0x88bb('0x5'));var util=require(_0x88bb('0x6'));var path=require(_0x88bb('0x7'));var sox=require(_0x88bb('0x8'));var csv=require(_0x88bb('0x9'));var ejs=require(_0x88bb('0xa'));var fs=require('fs');var _=require(_0x88bb('0xb'));var squel=require(_0x88bb('0xc'));var crypto=require(_0x88bb('0xd'));var jsforce=require(_0x88bb('0xe'));var deskjs=require(_0x88bb('0xf'));var toCsv=require(_0x88bb('0x9'));var querystring=require(_0x88bb('0x10'));var Papa=require(_0x88bb('0x11'));var Redis=require(_0x88bb('0x12'));var authService=require('../../components/auth/service');var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')(_0x88bb('0x13'));var utils=require(_0x88bb('0x14'));var config=require('../../config/environment');var licenseUtil=require(_0x88bb('0x15'));var db=require(_0x88bb('0x16'))['db'];config['redis']=_['defaults'](config[_0x88bb('0x17')],{'host':_0x88bb('0x18'),'port':0x18eb});var socket=require(_0x88bb('0x19'))(new Redis(config[_0x88bb('0x17')]));require(_0x88bb('0x1a'))[_0x88bb('0x1b')](socket);function respondWithStatusCode(_0xed0063,_0x33ba3c){_0x33ba3c=_0x33ba3c||0xcc;return function(_0x3d0666){if(_0x3d0666){return _0xed0063[_0x88bb('0x1c')](_0x33ba3c);}return _0xed0063[_0x88bb('0x1d')](_0x33ba3c)[_0x88bb('0x1e')]();};}function respondWithResult(_0x284be0,_0x15c283){_0x15c283=_0x15c283||0xc8;return function(_0x4106d2){if(_0x4106d2){return _0x284be0[_0x88bb('0x1d')](_0x15c283)['json'](_0x4106d2);}};}function respondWithFilteredResult(_0x5413c2,_0x21ecc0){return function(_0x3f09d8){if(_0x3f09d8){var _0x5da9aa=_0x3f09d8[_0x88bb('0x1f')],_0x49d55d=_0x21ecc0['offset'],_0x419acf=_0x21ecc0[_0x88bb('0x20')]+_0x21ecc0[_0x88bb('0x21')],_0x4c261f;if(_0x419acf>=_0x5da9aa){_0x419acf=_0x5da9aa;_0x4c261f=0xc8;}else{_0x4c261f=0xce;}_0x5413c2[_0x88bb('0x1d')](_0x4c261f);return _0x5413c2[_0x88bb('0x22')](_0x88bb('0x23'),_0x49d55d+'-'+_0x419acf+'/'+_0x5da9aa)[_0x88bb('0x24')](_0x3f09d8);}return null;};}function patchUpdates(_0x1b5834){return function(_0x4950cd){try{jsonpatch['apply'](_0x4950cd,_0x1b5834,!![]);}catch(_0x2850ff){return BPromise[_0x88bb('0x25')](_0x2850ff);}return _0x4950cd[_0x88bb('0x26')]();};}function saveUpdates(_0x10718a,_0x151f18){return function(_0x38a9e3){if(_0x38a9e3){return _0x38a9e3[_0x88bb('0x27')](_0x10718a)[_0x88bb('0x28')](function(_0x1a5fe9){return _0x1a5fe9;});}return null;};}function removeEntity(_0x396f64,_0x2c377a){return function(_0x2046c4){if(_0x2046c4){return _0x2046c4[_0x88bb('0x29')]()[_0x88bb('0x28')](function(){_0x396f64[_0x88bb('0x1d')](0xcc)[_0x88bb('0x1e')]();});}};}function handleEntityNotFound(_0x32ef1c,_0x4f288c){return function(_0x55ef82){if(!_0x55ef82){_0x32ef1c[_0x88bb('0x1c')](0x194);}return _0x55ef82;};}function handleError(_0x12915e,_0x5aa715){_0x5aa715=_0x5aa715||0x1f4;return function(_0x4b67e2){logger[_0x88bb('0x2a')](_0x4b67e2[_0x88bb('0x2b')]);if(_0x4b67e2[_0x88bb('0x2c')]){delete _0x4b67e2[_0x88bb('0x2c')];}_0x12915e['status'](_0x5aa715)['send'](_0x4b67e2);};}function getInteractionUsers(_0x4a2c84,_0x1c5f04){return new BPromise(function(_0x408e5c,_0x5341f5){try{if(_0x1c5f04[_0x4a2c84['id']]){_0x4a2c84[_0x88bb('0x2d')]=_['map'](_0x1c5f04[_0x4a2c84['id']],function(_0xb27977){return{'id':_0xb27977['id'],'fullname':_0xb27977[_0x88bb('0x2e')]};});}}catch(_0x419975){_0x5341f5(_0x419975);}_0x408e5c(_0x4a2c84);});}function getInteractionTags(_0x347756,_0x1139f5){return new BPromise(function(_0x5a28cd,_0x1714f9){try{if(_0x347756[_0x88bb('0x2f')]){_0x347756[_0x88bb('0x30')]=[];_0x347756[_0x88bb('0x2f')][_0x88bb('0x31')](',')['forEach'](function(_0x53da39){_0x347756[_0x88bb('0x30')][_0x88bb('0x32')](_0x1139f5[_0x53da39]);});}delete _0x347756['TagIds'];}catch(_0x4912c8){_0x1714f9(_0x4912c8);}_0x5a28cd(_0x347756);});}function updateFaxInteraction(_0x54ad3d,_0x420157,_0x1c38c5){return new BPromise(function(_0x1f402e,_0x4946f6){return getInteractionUsers(_0x54ad3d,_0x1c38c5)[_0x88bb('0x28')](function(_0xc98c62){return getInteractionTags(_0xc98c62,_0x420157);})[_0x88bb('0x28')](function(_0x4394b0){_0x1f402e(_0x4394b0);})[_0x88bb('0x33')](function(_0x11f466){_0x4946f6(_0x11f466);});});}exports['index']=function(_0x3d6c34,_0x1b3d60){var _0x2cd05f={},_0x4b6409={},_0x5045b9={'count':0x0,'rows':[]};var _0x151ded=_['map'](db[_0x88bb('0x34')][_0x88bb('0x35')],function(_0x116597){return{'name':_0x116597[_0x88bb('0x36')],'type':_0x116597[_0x88bb('0x37')]['key']};});_0x4b6409['model']=_[_0x88bb('0x38')](_0x151ded,_0x88bb('0x2c'));_0x4b6409[_0x88bb('0x39')]=_[_0x88bb('0x3a')](_0x3d6c34[_0x88bb('0x39')]);_0x4b6409[_0x88bb('0x3b')]=_['intersection'](_0x4b6409['model'],_0x4b6409[_0x88bb('0x39')]);_0x2cd05f[_0x88bb('0x3c')]=_[_0x88bb('0x3d')](_0x4b6409[_0x88bb('0x3e')],qs[_0x88bb('0x3f')](_0x3d6c34[_0x88bb('0x39')][_0x88bb('0x3f')]));_0x2cd05f[_0x88bb('0x3c')]=_0x2cd05f[_0x88bb('0x3c')][_0x88bb('0x40')]?_0x2cd05f[_0x88bb('0x3c')]:_0x4b6409['model'];if(!_0x3d6c34[_0x88bb('0x39')][_0x88bb('0x41')](_0x88bb('0x42'))){_0x2cd05f[_0x88bb('0x21')]=qs[_0x88bb('0x21')](_0x3d6c34['query'][_0x88bb('0x21')]);_0x2cd05f[_0x88bb('0x20')]=qs[_0x88bb('0x20')](_0x3d6c34['query'][_0x88bb('0x20')]);}_0x2cd05f['order']=qs[_0x88bb('0x43')](_0x3d6c34[_0x88bb('0x39')]['sort']);_0x2cd05f[_0x88bb('0x44')]=qs['filters'](_['pick'](_0x3d6c34[_0x88bb('0x39')],_0x4b6409['filters']),_0x151ded);var _0x1348fd=[];var _0x4dcd72=squel[_0x88bb('0x45')]()[_0x88bb('0x46')]('id')['field'](_0x88bb('0x2c'))[_0x88bb('0x46')](_0x88bb('0x47'))['from'](_0x88bb('0x48'));var _0x1f35cb=squel[_0x88bb('0x45')]()[_0x88bb('0x46')](_0x88bb('0x49'))['field'](_0x88bb('0x4a'))[_0x88bb('0x46')]('ui.FaxInteractionId')[_0x88bb('0x4b')](_0x88bb('0x4c'),'ui')[_0x88bb('0x4d')]('users','u','u.id\x20=\x20ui.UserId');var _0x1eaf00=squel[_0x88bb('0x45')]()[_0x88bb('0x4b')](_0x88bb('0x4e'),'i')[_0x88bb('0x4d')](_0x88bb('0x4f'),'c',_0x88bb('0x50'))[_0x88bb('0x4d')](_0x88bb('0x51'),'o',_0x88bb('0x52'))[_0x88bb('0x4d')](_0x88bb('0x53'),'a','a.id\x20=\x20i.FaxAccountId')[_0x88bb('0x4d')](_0x88bb('0x54'),'me','me.FaxInteractionId\x20=\x20i.id')[_0x88bb('0x4d')](_0x88bb('0x55'),'it',_0x88bb('0x56'))[_0x88bb('0x4d')](_0x88bb('0x48'),'t','t.id\x20=\x20it.TagId');var _0x185f6c=squel[_0x88bb('0x57')]();var _0x3af552=[];var _0x172266=squel[_0x88bb('0x57')]();var _0x4c8054;if(_0x3d6c34[_0x88bb('0x39')][_0x88bb('0x58')]){_0x4c8054=as[_0x88bb('0x59')](_0x3d6c34[_0x88bb('0x39')][_0x88bb('0x58')]);var _0x34613a=_0x4c8054[_0x88bb('0x5a')];for(var _0x5b4daf=0x0;_0x5b4daf<_0x4c8054[_0x88bb('0x5b')]['length'];_0x5b4daf++){var _0x7c5d99=_0x4c8054[_0x88bb('0x5b')][_0x5b4daf];var _0x50b06e='i';var _0x19469e=_[_0x88bb('0x5c')](_0x151ded,[_0x88bb('0x2c'),_0x7c5d99[_0x88bb('0x46')]]);if(!_0x19469e){switch(_0x7c5d99[_0x88bb('0x46')]){case _0x88bb('0x5d'):if(_0x7c5d99[_0x88bb('0x5e')]==0x1){_0x1eaf00[_0x88bb('0x5f')]('`'+_0x7c5d99[_0x88bb('0x46')]+'`\x20=\x200');}else{_0x1eaf00[_0x88bb('0x5f')]('`'+_0x7c5d99[_0x88bb('0x46')]+_0x88bb('0x60'));}break;case'Contact':if(_0x7c5d99[_0x88bb('0x61')]===_0x88bb('0x62')){if(_0x7c5d99[_0x88bb('0x5e')]['split']('\x20')['length']>0x1){_0x185f6c[_0x34613a](_0x88bb('0x63'),qs[_0x88bb('0x64')](_0x7c5d99[_0x88bb('0x5e')]),null);}else{var _0x53bce1='%'+_0x7c5d99[_0x88bb('0x5e')]+'%';_0x185f6c[_0x34613a](_0x88bb('0x65'),_0x53bce1,_0x53bce1,_0x53bce1);}}else{_0x19469e=_[_0x88bb('0x5c')](_0x151ded,[_0x88bb('0x2c'),'ContactId']);_0x7c5d99[_0x88bb('0x46')]=_0x88bb('0x66');_0x44306a=as[_0x88bb('0x67')](_0x50b06e,_0x19469e['type'],_0x7c5d99);_0x185f6c[_0x34613a](_0x44306a[_0x88bb('0x68')],_0x44306a[_0x88bb('0x5e')][_0x88bb('0x69')],_0x44306a[_0x88bb('0x5e')][_0x88bb('0x1e')]);}break;case'Tag':var _0x23cda9=_0x7c5d99[_0x88bb('0x5e')][_0x88bb('0x31')](',')[_0x88bb('0x38')](function(_0xf4fd91){return Number(_0xf4fd91);});_0x23cda9['forEach'](function(_0x4a273d){_0x172266['or'](_0x88bb('0x6a'),'%,'+_0x4a273d+',%');});_0x3af552=_[_0x88bb('0x6b')](_0x3af552,_0x23cda9);break;case _0x88bb('0x6c'):if(_0x7c5d99[_0x88bb('0x61')]==='$substring'){_0x185f6c[_0x34613a]('CONCAT_WS(\x27\x20\x27,\x20o.name,\x20o.fullname)\x20LIKE\x20?','%'+_0x7c5d99['value']+'%',null);}else{_0x19469e=_[_0x88bb('0x5c')](_0x151ded,[_0x88bb('0x2c'),'UserId']);_0x7c5d99[_0x88bb('0x46')]=_0x88bb('0x6d');_0x44306a=as['buildExpression'](_0x50b06e,_0x19469e[_0x88bb('0x37')],_0x7c5d99);_0x185f6c[_0x34613a](_0x44306a['text'],_0x44306a['value'][_0x88bb('0x69')],_0x44306a[_0x88bb('0x5e')][_0x88bb('0x1e')]);}break;case _0x88bb('0x6e'):_0x44306a=as[_0x88bb('0x67')]('me',null,_0x7c5d99);_0x185f6c[_0x34613a](_0x44306a[_0x88bb('0x68')],_0x44306a[_0x88bb('0x5e')]['start'],_0x44306a[_0x88bb('0x5e')][_0x88bb('0x1e')]);break;}}else{var _0x44306a=as[_0x88bb('0x67')](_0x50b06e,_0x19469e[_0x88bb('0x37')],_0x7c5d99);_0x185f6c[_0x34613a](_0x44306a[_0x88bb('0x68')],_0x44306a[_0x88bb('0x5e')][_0x88bb('0x69')],_0x44306a[_0x88bb('0x5e')][_0x88bb('0x1e')]);}}}else{var _0x19e2c4=_(_0x3d6c34['query'])[_0x88bb('0x3a')]()[_0x88bb('0x38')](function(_0x50e6da){return _[_0x88bb('0x6f')](_0x151ded,['name',_0x50e6da])?_0x50e6da:undefined;})[_0x88bb('0x70')]()[_0x88bb('0x5e')]();if(!_[_0x88bb('0x71')](_0x19e2c4)){_0x19e2c4[_0x88bb('0x72')](function(_0x53b543){if(_0x53b543==='FaxAccountId'){_0x1eaf00[_0x88bb('0x44')](_0x88bb('0x73'),[][_0x88bb('0x74')](_0x3d6c34['query'][_0x53b543]));}else if(_0x53b543===_0x88bb('0x75')){var _0x2f2eb3=JSON[_0x88bb('0x76')](_0x3d6c34[_0x88bb('0x39')][_0x53b543])['$gte'];var _0x113935=JSON[_0x88bb('0x76')](_0x3d6c34[_0x88bb('0x39')][_0x53b543])[_0x88bb('0x77')];_0x1eaf00[_0x88bb('0x44')](_0x88bb('0x78'),_0x2f2eb3,_0x113935);}else{if(_0x3d6c34[_0x88bb('0x39')][_0x53b543]===_0x88bb('0x79')){_0x1eaf00['where']('i.'+_0x53b543+_0x88bb('0x7a'));}else{_0x1eaf00[_0x88bb('0x44')]('i.'+_0x53b543+_0x88bb('0x7b'),_0x3d6c34[_0x88bb('0x39')][_0x53b543]);}}});}if(_0x3d6c34[_0x88bb('0x39')]['read']){if(_0x3d6c34[_0x88bb('0x39')]['read']==0x1){_0x1eaf00[_0x88bb('0x5f')]('`unreadMessages`\x20=\x200');}else{_0x1eaf00['having'](_0x88bb('0x7c'));}}if(_0x3d6c34[_0x88bb('0x39')][_0x88bb('0x7d')]){_0x3af552=_[_0x88bb('0x7e')](_0x3d6c34[_0x88bb('0x39')][_0x88bb('0x7d')])?_0x3d6c34[_0x88bb('0x39')][_0x88bb('0x7d')]:new Array(_0x3d6c34[_0x88bb('0x39')][_0x88bb('0x7d')]);_0x3af552[_0x88bb('0x72')](function(_0x142a3e){_0x172266['or']('CONCAT(\x27,\x27,\x20`TagIds`,\x20\x27,\x27)\x20LIKE\x20?','%,'+_0x142a3e+',%');});}if(_0x3d6c34['query']['filter']){var _0x34237d=_0x3d6c34[_0x88bb('0x39')][_0x88bb('0x7f')][_0x88bb('0x80')]('\x5c','\x5c\x5c')[_0x88bb('0x80')](/'/g,'\x27\x27');if(qs[_0x88bb('0x81')](_0x34237d)){_0x185f6c['or'](_0x88bb('0x82'),_0x34237d+'%')['or'](_0x88bb('0x83'),_0x34237d+'%');}_0x185f6c['or'](_0x88bb('0x84'),_0x34237d+'%');}}_0x1eaf00[_0x88bb('0x44')](_0x185f6c);_0x1eaf00[_0x88bb('0x85')]('i.id');var _0x4c8036={'type':db['Sequelize']['QueryTypes'][_0x88bb('0x86')],'raw':!![]};var _0x47b1b6=_0x1eaf00[_0x88bb('0x87')]();_0x47b1b6[_0x88bb('0x46')](_0x88bb('0x88'));_0x47b1b6['field']('SUM(me.read\x20=\x200\x20AND\x20me.direction\x20=\x20\x27in\x27)','unreadMessages');if(_0x2cd05f[_0x88bb('0x89')]){_0x2cd05f[_0x88bb('0x89')][_0x88bb('0x72')](function(_0x26bff8){var _0x5878cd=_0x26bff8[0x0]===_0x88bb('0x8a')?_0x26bff8[0x0]:'i.'+_0x26bff8[0x0];_0x1eaf00[_0x88bb('0x89')](_0x5878cd,_0x26bff8[0x1]===_0x88bb('0x8b')?![]:!![]);});}if(!_['isEmpty'](_0x3af552)){_0x1eaf00[_0x88bb('0x5f')](_0x172266);_0x47b1b6[_0x88bb('0x44')](_0x88bb('0x8c'),_0x3af552);}BPromise[_0x88bb('0x8d')]()[_0x88bb('0x28')](function(){if(!_0x4c8054){if(_0x3d6c34[_0x88bb('0x39')][_0x88bb('0x8e')])return;_0x47b1b6[_0x88bb('0x44')](_0x88bb('0x8f'));_0x1eaf00['where'](_0x88bb('0x8f'));return;}if(_0x3d6c34[_0x88bb('0x90')][_0x88bb('0x91')]!==_0x88bb('0x92'))return;return _0x3d6c34[_0x88bb('0x90')][_0x88bb('0x93')]({'attributes':['id'],'raw':!![]})[_0x88bb('0x28')](function(_0x179a78){if(_[_0x88bb('0x71')](_0x179a78)){_0x47b1b6[_0x88bb('0x44')](_0x88bb('0x94'));_0x1eaf00[_0x88bb('0x44')]('i.FaxAccountId\x20IS\x20NULL');}else{_0x47b1b6[_0x88bb('0x44')](_0x88bb('0x73'),_[_0x88bb('0x38')](_0x179a78,'id'));_0x1eaf00['where'](_0x88bb('0x73'),_[_0x88bb('0x38')](_0x179a78,'id'));}});})[_0x88bb('0x28')](function(){if(_0x3d6c34[_0x88bb('0x90')][_0x88bb('0x91')]==='agent'&&!_0x4c8054&&!_0x3d6c34[_0x88bb('0x39')][_0x88bb('0x8e')])return[];return db[_0x88bb('0x95')]['query'](_0x47b1b6[_0x88bb('0x96')](),_0x4c8036);})[_0x88bb('0x28')](function(_0x55c63e){_0x5045b9['count']=_0x55c63e[_0x88bb('0x40')];if(_0x5045b9[_0x88bb('0x1f')]===0x0)return[];return db['sequelize'][_0x88bb('0x39')](_0x4dcd72[_0x88bb('0x96')](),_0x4c8036)['then'](function(_0x36b9da){_0x1348fd=_['keyBy'](_0x36b9da,'id');_0x4c8036=_[_0x88bb('0x97')](_0x4c8036,{'model':db[_0x88bb('0x34')],'mapToModel':!![],'raw':!![],'nest':!![]});if(_0x3d6c34[_0x88bb('0x39')][_0x88bb('0x3f')]){_0x2cd05f[_0x88bb('0x3c')][_0x88bb('0x72')](function(_0x27f3e9){_0x1eaf00[_0x88bb('0x46')]('i.'+_0x27f3e9);});}else{_0x1eaf00[_0x88bb('0x46')](_0x88bb('0x98'),'unreadMessages');_0x1eaf00['field']('a.key',_0x88bb('0x99'));_0x1eaf00[_0x88bb('0x46')](_0x88bb('0x9a'),_0x88bb('0x9b'));_0x1eaf00[_0x88bb('0x46')](_0x88bb('0x9c'),'contactName');_0x1eaf00[_0x88bb('0x46')](_0x88bb('0x9d'));_0x1eaf00['field']('c.firstName',_0x88bb('0x9e'));_0x1eaf00[_0x88bb('0x46')](_0x88bb('0x9f'),_0x88bb('0xa0'));_0x1eaf00[_0x88bb('0x46')](_0x88bb('0xa1'),_0x88bb('0xa2'));_0x1eaf00[_0x88bb('0x46')](_0x88bb('0xa3'),_0x88bb('0xa4'));_0x1eaf00[_0x88bb('0x46')](_0x88bb('0xa5'),_0x88bb('0xa6'));_0x1eaf00[_0x88bb('0x46')](_0x88bb('0xa7'),_0x88bb('0xa8'));_0x1eaf00[_0x88bb('0x46')]('o.fullname',_0x88bb('0xa9'));_0x1eaf00[_0x88bb('0x46')](_0x88bb('0xaa'),_0x88bb('0xab'));_0x1eaf00[_0x88bb('0x46')](_0x88bb('0xac'),'TagIds');}if(_0x2cd05f['limit'])_0x1eaf00[_0x88bb('0x21')](_0x2cd05f[_0x88bb('0x21')]);if(_0x2cd05f[_0x88bb('0x20')])_0x1eaf00['offset'](_0x2cd05f[_0x88bb('0x20')]);return db[_0x88bb('0x95')][_0x88bb('0x39')](_0x1eaf00[_0x88bb('0x96')](),_0x4c8036);})['then'](function(_0x4a2ca5){_0x1f35cb['where'](_0x88bb('0xad'),_['map'](_0x4a2ca5,'id'));return db[_0x88bb('0x95')][_0x88bb('0x39')](_0x1f35cb['toString'](),_0x4c8036)[_0x88bb('0x28')](function(_0x4415ff){var _0x11c437=_[_0x88bb('0xae')](_0x4415ff,_0x88bb('0xaf'));var _0x4ac851=[];_0x4a2ca5[_0x88bb('0x72')](function(_0xa384a0){_0x4ac851[_0x88bb('0x32')](updateFaxInteraction(_0xa384a0,_0x1348fd,_0x11c437));});return BPromise[_0x88bb('0xb0')](_0x4ac851);});});})[_0x88bb('0x28')](function(_0x30ef58){_0x5045b9['rows']=_0x30ef58;return _0x5045b9;})['then'](respondWithFilteredResult(_0x1b3d60,_0x2cd05f))['catch'](handleError(_0x1b3d60,null));};exports[_0x88bb('0xb1')]=function(_0x339ea4,_0x53f8d0){var _0x2090f3={'raw':![],'where':{'id':_0x339ea4[_0x88bb('0xb2')]['id']}},_0x2b82a4={};_0x2b82a4['model']=_[_0x88bb('0x3a')](db['FaxInteraction']['rawAttributes']);_0x2b82a4[_0x88bb('0x39')]=_[_0x88bb('0x3a')](_0x339ea4[_0x88bb('0x39')]);_0x2b82a4['filters']=_[_0x88bb('0x3d')](_0x2b82a4[_0x88bb('0x3e')],_0x2b82a4['query']);_0x2090f3[_0x88bb('0x3c')]=_[_0x88bb('0x3d')](_0x2b82a4[_0x88bb('0x3e')],qs['fields'](_0x339ea4[_0x88bb('0x39')]['fields']));_0x2090f3[_0x88bb('0x3c')]=_0x2090f3['attributes'][_0x88bb('0x40')]?_0x2090f3[_0x88bb('0x3c')]:_0x2b82a4[_0x88bb('0x3e')];if(_0x339ea4[_0x88bb('0x39')][_0x88bb('0xb3')]){_0x2090f3['include']=[{'all':!![]}];}_0x2090f3=_[_0x88bb('0x97')]({},_0x2090f3,_0x339ea4[_0x88bb('0xb4')]);return db[_0x88bb('0x34')][_0x88bb('0x5c')](_0x2090f3)['then'](handleEntityNotFound(_0x53f8d0,null))['then'](respondWithResult(_0x53f8d0,null))[_0x88bb('0x33')](handleError(_0x53f8d0,null));};exports['create']=function(_0x59b217,_0x50697e){return db['FaxInteraction']['create'](_0x59b217[_0x88bb('0x6e')],{})[_0x88bb('0x28')](respondWithResult(_0x50697e,0xc9))[_0x88bb('0x33')](handleError(_0x50697e,null));};exports[_0x88bb('0x27')]=function(_0x57502e,_0x591294){if(_0x57502e[_0x88bb('0x6e')]['id']){delete _0x57502e[_0x88bb('0x6e')]['id'];}return db[_0x88bb('0x34')]['find']({'where':{'id':_0x57502e[_0x88bb('0xb2')]['id']}})[_0x88bb('0x28')](handleEntityNotFound(_0x591294,null))[_0x88bb('0x28')](saveUpdates(_0x57502e[_0x88bb('0x6e')],null))[_0x88bb('0x28')](respondWithResult(_0x591294,null))[_0x88bb('0x33')](handleError(_0x591294,null));};exports[_0x88bb('0x29')]=function(_0x318f0e,_0x458223){return db['FaxInteraction'][_0x88bb('0x5c')]({'where':{'id':_0x318f0e[_0x88bb('0xb2')]['id']}})[_0x88bb('0x28')](handleEntityNotFound(_0x458223,null))['then'](removeEntity(_0x458223,null))[_0x88bb('0x33')](handleError(_0x458223,null));};exports[_0x88bb('0xb5')]=function(_0x88b300,_0x51a97f){return db[_0x88bb('0x34')][_0x88bb('0xb5')]()['then'](respondWithResult(_0x51a97f,null))[_0x88bb('0x33')](handleError(_0x51a97f,null));};exports[_0x88bb('0xb6')]=function(_0x23cd49,_0x4ae6be,_0x1749e5){return db[_0x88bb('0xb7')]['find']({'where':{'id':_0x23cd49[_0x88bb('0xb2')]['id']}})[_0x88bb('0x28')](handleEntityNotFound(_0x4ae6be,null))[_0x88bb('0x28')](function(_0x48518f){if(_0x48518f){return _0x48518f[_0x88bb('0xb6')](_0x23cd49[_0x88bb('0x6e')][_0x88bb('0xb8')],_[_0x88bb('0xb9')](_0x23cd49['body'],[_0x88bb('0xb8'),'id'])||{});}})[_0x88bb('0x28')](respondWithResult(_0x4ae6be,null))[_0x88bb('0x33')](handleError(_0x4ae6be,null));};exports['getMessages']=function(_0xa07a9,_0x524b04,_0x54fbbf){var _0x15e6d6={'raw':![],'where':{}};var _0x2dc711={};var _0x82bdf9={'count':0x0,'rows':[]};return db[_0x88bb('0x34')][_0x88bb('0xba')]({'where':{'id':_0xa07a9[_0x88bb('0xb2')]['id']}})[_0x88bb('0x28')](handleEntityNotFound(_0x524b04,null))[_0x88bb('0x28')](function(_0xd83a58){if(_0xd83a58){_0x2dc711[_0x88bb('0x3e')]=_[_0x88bb('0x3a')](db['FaxMessage']['rawAttributes']);_0x2dc711['query']=_[_0x88bb('0x3a')](_0xa07a9[_0x88bb('0x39')]);_0x2dc711[_0x88bb('0x3b')]=_[_0x88bb('0x3d')](_0x2dc711[_0x88bb('0x3e')],_0x2dc711[_0x88bb('0x39')]);_0x15e6d6[_0x88bb('0x3c')]=_[_0x88bb('0x3d')](_0x2dc711[_0x88bb('0x3e')],qs[_0x88bb('0x3f')](_0xa07a9['query'][_0x88bb('0x3f')]));_0x15e6d6[_0x88bb('0x3c')]=_0x15e6d6[_0x88bb('0x3c')][_0x88bb('0x40')]?_0x15e6d6[_0x88bb('0x3c')]:_0x2dc711[_0x88bb('0x3e')];if(!_0xa07a9[_0x88bb('0x39')][_0x88bb('0x41')](_0x88bb('0x42'))){_0x15e6d6['limit']=qs[_0x88bb('0x21')](_0xa07a9['query'][_0x88bb('0x21')]);_0x15e6d6[_0x88bb('0x20')]=qs[_0x88bb('0x20')](_0xa07a9[_0x88bb('0x39')][_0x88bb('0x20')]);}_0x15e6d6['order']=qs['sort'](_0xa07a9['query'][_0x88bb('0x43')]);_0x15e6d6[_0x88bb('0x44')]=qs[_0x88bb('0x3b')](_[_0x88bb('0xbb')](_0xa07a9[_0x88bb('0x39')],_0x2dc711['filters']));_0x15e6d6[_0x88bb('0x44')][_0x88bb('0xaf')]=_0xd83a58['id'];if(_0xa07a9[_0x88bb('0x39')][_0x88bb('0x7f')]){_0x15e6d6['where']=_[_0x88bb('0x97')](_0x15e6d6[_0x88bb('0x44')],{'$or':_[_0x88bb('0x38')](_0x15e6d6[_0x88bb('0x3c')],function(_0x538596){var _0xffcac5={};_0xffcac5[_0x538596]={'$like':'%'+_0xa07a9[_0x88bb('0x39')][_0x88bb('0x7f')]+'%'};return _0xffcac5;})});}if(_0xa07a9[_0x88bb('0x39')][_0x88bb('0xbc')]){var _0x28b174=_0xa07a9[_0x88bb('0x39')][_0x88bb('0xbc')][_0x88bb('0x31')](',');var _0x2b12c8={};_0x2b12c8[_0x28b174[0x0]]={'$gte':moment(_0x28b174[0x1])[_0x88bb('0xbd')](_0x88bb('0xbe'))};_0x15e6d6[_0x88bb('0x44')]=_[_0x88bb('0x97')](_0x15e6d6[_0x88bb('0x44')],_0x2b12c8);}_0x15e6d6=_[_0x88bb('0x97')]({},_0x15e6d6,_0xa07a9[_0x88bb('0xb4')]);return db['FaxMessage'][_0x88bb('0x1f')]({'where':_0x15e6d6[_0x88bb('0x44')]})[_0x88bb('0x28')](function(_0x2cc330){_0x82bdf9[_0x88bb('0x1f')]=_0x2cc330;if(_0xa07a9[_0x88bb('0x39')][_0x88bb('0xb3')]){_0x15e6d6[_0x88bb('0xbf')]=[{'all':!![]}];}return db[_0x88bb('0xb7')][_0x88bb('0xc0')](_0x15e6d6);})[_0x88bb('0x28')](function(_0x5b1df6){_0x82bdf9['rows']=_0x5b1df6;return _0x82bdf9;});}})['then'](respondWithFilteredResult(_0x524b04,_0x15e6d6))[_0x88bb('0x33')](handleError(_0x524b04,null));};exports[_0x88bb('0xc1')]=function(_0x26a9af,_0xb272e1,_0x43a3e4){return db['FaxInteraction'][_0x88bb('0x5c')]({'where':{'id':_0x26a9af[_0x88bb('0xb2')]['id']}})['then'](handleEntityNotFound(_0xb272e1,null))[_0x88bb('0x28')](function(_0x4f65db){if(_0x4f65db){return _0x4f65db['setTags'](_0x26a9af[_0x88bb('0x6e')][_0x88bb('0xb8')],_['omit'](_0x26a9af[_0x88bb('0x6e')],['ids','id'])||{})[_0x88bb('0xc2')](function(){return db['Tag'][_0x88bb('0xc0')]({'attributes':['id',_0x88bb('0x2c'),'color'],'where':{'id':_0x26a9af[_0x88bb('0x6e')]['ids']}});})[_0x88bb('0x28')](function(_0xbafd48){socket[_0x88bb('0xc3')](_0x88bb('0xc4'),{'id':Number(_0x26a9af['params']['id']),'tags':_0xbafd48||[]});return{'id':Number(_0x26a9af[_0x88bb('0xb2')]['id']),'tags':_0xbafd48||[]};});}})[_0x88bb('0x28')](respondWithResult(_0xb272e1,null))['catch'](handleError(_0xb272e1,null));};exports[_0x88bb('0xc5')]=function(_0xd67fae,_0x1d3c53,_0x47d8d5){return db['FaxInteraction']['find']({'where':{'id':_0xd67fae['params']['id']}})['then'](handleEntityNotFound(_0x1d3c53,null))[_0x88bb('0x28')](function(_0x4e629e){if(_0x4e629e){return _0x4e629e[_0x88bb('0xc5')](_0xd67fae['query'][_0x88bb('0xb8')]);}})['then'](respondWithStatusCode(_0x1d3c53,null))['catch'](handleError(_0x1d3c53,null));};exports[_0x88bb('0xc6')]=function(_0x17b2d2,_0x81368c){var _0x2d2d4c=moment()['unix']()[_0x88bb('0x96')]();var _0x431cc7=path['join'](config[_0x88bb('0xc7')],_0x88bb('0xc8'),_0x88bb('0xc9'),_0x88bb('0xca'));var _0x154015=path['join'](config[_0x88bb('0xc7')],_0x88bb('0xc8'),_0x88bb('0xc9'),'attachments');var _0x626c07=path[_0x88bb('0xcb')](_0x431cc7,_0x2d2d4c);var _0x4af717=util[_0x88bb('0xbd')](_0x88bb('0xcc'),_0x17b2d2[_0x88bb('0xb2')]['id'],_0x2d2d4c);var _0x1a591f=path[_0x88bb('0xcb')](_0x431cc7,_0x4af717);var _0x4e7f10=[];_0x4e7f10[_0x88bb('0x32')]({'model':db['Attachment'],'as':_0x88bb('0xcd'),'raw':!![]});var _0x3e4077=[{'model':db[_0x88bb('0xb7')],'as':_0x88bb('0xce'),'attributes':['id',_0x88bb('0x6e'),_0x88bb('0x75')],'include':_0x4e7f10}];return db['FaxInteraction']['find']({'where':{'id':_0x17b2d2['params']['id']},'include':_0x3e4077})['then'](handleEntityNotFound(_0x81368c,null))['then'](function(_0x4f33f0){if(_0x4f33f0&&_0x4f33f0[_0x88bb('0xce')]){var _0x405123=_0x4f33f0[_0x88bb('0xcf')]({'plain':!![]});fs[_0x88bb('0xd0')](_0x626c07);for(var _0x595488=0x0;_0x595488<_0x405123['Messages'][_0x88bb('0x40')];_0x595488++){var _0x35b087=_0x405123[_0x88bb('0xce')][_0x595488][_0x88bb('0xcd')];if(_0x35b087){var _0x365a51=path['join'](_0x154015,_0x35b087[_0x88bb('0xd1')]);if(fs[_0x88bb('0xd2')](_0x365a51)){fs[_0x88bb('0xd3')](_0x365a51)['pipe'](fs['createWriteStream'](path[_0x88bb('0xcb')](_0x626c07,_0x35b087[_0x88bb('0xd1')])));}}}return BPromise[_0x88bb('0x8d')]()[_0x88bb('0x28')](function(){return new BPromise(function(_0x1c4a66,_0x2578a6){zipdir(_0x626c07,{'saveTo':_0x1a591f},function(_0x31b2d1,_0x201ea1){if(_0x31b2d1)return _0x2578a6(_0x31b2d1);return _0x1c4a66(_0x201ea1);});})[_0x88bb('0x28')](function(){return new BPromise(function(_0x50f1fe,_0x86ed52){rimraf(_0x626c07,function(_0x293dbf){if(_0x293dbf)_0x86ed52(_0x293dbf);return _0x50f1fe();});});})[_0x88bb('0x28')](function(){return _0x81368c[_0x88bb('0xc6')](_0x1a591f,_0x4af717,function(_0x544a62){if(_0x544a62){console[_0x88bb('0xd4')]('err',_0x544a62);}else{fs[_0x88bb('0xd5')](_0x1a591f);}});});});}else{return _0x81368c['sendStatus'](0xc8);}})[_0x88bb('0x33')](handleError(_0x81368c,null));};
\ No newline at end of file