Built motion from commit 14588770.|2.5.38
[motion2.git] / server / api / faxInteraction / faxInteraction.controller.js
index 9dfdda7..7663a15 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x8875=['u.id','u.fullname','ui.FaxInteractionId','user_has_fax_interactions','left_join','users','fax_interactions','cm_contacts','c.id\x20=\x20i.ContactId\x20AND\x20c.deletedAt\x20IS\x20NULL','o.id\x20=\x20i.UserId','fax_accounts','a.id\x20=\x20i.FaxAccountId','fax_messages','fax_interaction_has_tags','it.FaxInteractionId\x20=\x20i.id','t.id\x20=\x20it.TagId','expr','search','parseSearch','sqlOperator','conditions','find','value','`\x20=\x200','`\x20>\x200','Contact','operator','getFullTextValue','ContactId','text','start','Tag','CONCAT(\x27,\x27,\x20`TagIds`,\x20\x27,\x27)\x20LIKE\x20?','User','$substring','UserId','buildExpression','compact','isEmpty','FaxAccountId','where','$gte','parse','$lte','i.createdAt\x20BETWEEN\x20?\x20AND\x20?','null','\x20IS\x20NULL','\x20=\x20?','read','having','`unreadMessages`\x20=\x200','tag','isArray','filter','replace','isNumeric','i.id\x20LIKE\x20?','i.fax\x20LIKE\x20?','group','Sequelize','QueryTypes','SELECT','i.id','SUM(me.read\x20=\x200\x20AND\x20me.direction\x20=\x20\x27in\x27)','unreadMessages','contactName','DESC','t.id\x20IN\x20?','resolve','i.FaxAccountId\x20IS\x20NOT\x20NULL','user','agent','getFaxAccounts','i.FaxAccountId\x20IS\x20NULL','i.FaxAccountId\x20IN\x20?','sequelize','toString','keyBy','merge','Account.key','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.*','c.firstName','Contact.firstName','c.lastName','Contact.email','c.phone','Contact.phone','c.fax','Owner.fullname','Owner.internal','GROUP_CONCAT(DISTINCT\x20t.id)','ui.FaxInteractionId\x20IN\x20?','groupBy','FaxInteractionId','all','rows','catch','show','params','includeAll','include','options','create','body','describe','addMessage','FaxMessage','omit','ids','findOne','format','findAll','addTags','setTags','spread','color','emit','faxInteractionTags:save','removeTags','join','root','server','files','tmp','transcript-%d-%s.zip','Attachment','Messages','createdAt','get','existsSync','createReadStream','pipe','basename','download','err','unlinkSync','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','sox','fs-extra','lodash','squel','crypto','desk.js','to-csv','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../mysqldb','redis','defaults','socket.io-emitter','./faxInteraction.socket','sendStatus','status','end','json','offset','undefined','limit','count','Content-Range','apply','reject','save','update','destroy','then','error','stack','name','send','Users','TagIds','Tags','forEach','push','index','map','FaxInteraction','rawAttributes','fieldName','type','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','pick','select','field','from','tools_tags'];(function(_0x437a30,_0x4f2e8d){var _0xfee7c8=function(_0x274198){while(--_0x274198){_0x437a30['push'](_0x437a30['shift']());}};_0xfee7c8(++_0x4f2e8d);}(_0x8875,0x161));var _0x5887=function(_0x28171a,_0x5f33a4){_0x28171a=_0x28171a-0x0;var _0x2518d3=_0x8875[_0x28171a];return _0x2518d3;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x5887('0x0'));var zipdir=require(_0x5887('0x1'));var jsonpatch=require(_0x5887('0x2'));var rp=require(_0x5887('0x3'));var moment=require(_0x5887('0x4'));var BPromise=require(_0x5887('0x5'));var Mustache=require(_0x5887('0x6'));var util=require(_0x5887('0x7'));var path=require('path');var sox=require(_0x5887('0x8'));var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x5887('0x9'));var _=require(_0x5887('0xa'));var squel=require(_0x5887('0xb'));var crypto=require(_0x5887('0xc'));var jsforce=require('jsforce');var deskjs=require(_0x5887('0xd'));var toCsv=require(_0x5887('0xe'));var querystring=require(_0x5887('0xf'));var Papa=require(_0x5887('0x10'));var Redis=require(_0x5887('0x11'));var authService=require(_0x5887('0x12'));var qs=require(_0x5887('0x13'));var as=require(_0x5887('0x14'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x5887('0x15'))(_0x5887('0x16'));var utils=require(_0x5887('0x17'));var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require(_0x5887('0x18'))['db'];config[_0x5887('0x19')]=_[_0x5887('0x1a')](config[_0x5887('0x19')],{'host':'localhost','port':0x18eb});var socket=require(_0x5887('0x1b'))(new Redis(config[_0x5887('0x19')]));require(_0x5887('0x1c'))['register'](socket);function respondWithStatusCode(_0x447152,_0x425d2b){_0x425d2b=_0x425d2b||0xcc;return function(_0x1cbdc4){if(_0x1cbdc4){return _0x447152[_0x5887('0x1d')](_0x425d2b);}return _0x447152[_0x5887('0x1e')](_0x425d2b)[_0x5887('0x1f')]();};}function respondWithResult(_0x194307,_0x347b42){_0x347b42=_0x347b42||0xc8;return function(_0x1cb878){if(_0x1cb878){return _0x194307[_0x5887('0x1e')](_0x347b42)[_0x5887('0x20')](_0x1cb878);}};}function respondWithFilteredResult(_0x307e8a,_0x12ffb6){return function(_0x4538f1){if(_0x4538f1){var _0x4e17a9=typeof _0x12ffb6[_0x5887('0x21')]===_0x5887('0x22')&&typeof _0x12ffb6[_0x5887('0x23')]===_0x5887('0x22');var _0x2d8445=_0x4538f1[_0x5887('0x24')];var _0x130757=_0x4e17a9?0x0:_0x12ffb6[_0x5887('0x21')];var _0x1684cc=_0x4e17a9?_0x4538f1[_0x5887('0x24')]:_0x12ffb6[_0x5887('0x21')]+_0x12ffb6[_0x5887('0x23')];var _0x385503;if(_0x1684cc>=_0x2d8445){_0x1684cc=_0x2d8445;_0x385503=0xc8;}else{_0x385503=0xce;}_0x307e8a[_0x5887('0x1e')](_0x385503);return _0x307e8a['set'](_0x5887('0x25'),_0x130757+'-'+_0x1684cc+'/'+_0x2d8445)[_0x5887('0x20')](_0x4538f1);}return null;};}function patchUpdates(_0x18acb7){return function(_0x840108){try{jsonpatch[_0x5887('0x26')](_0x840108,_0x18acb7,!![]);}catch(_0x14ab72){return BPromise[_0x5887('0x27')](_0x14ab72);}return _0x840108[_0x5887('0x28')]();};}function saveUpdates(_0x5196b4,_0x3988fd){return function(_0x4ec831){if(_0x4ec831){return _0x4ec831[_0x5887('0x29')](_0x5196b4)['then'](function(_0x4d8bb9){return _0x4d8bb9;});}return null;};}function removeEntity(_0x32df22,_0x2ca65e){return function(_0x2fefd6){if(_0x2fefd6){return _0x2fefd6[_0x5887('0x2a')]()[_0x5887('0x2b')](function(){_0x32df22[_0x5887('0x1e')](0xcc)[_0x5887('0x1f')]();});}};}function handleEntityNotFound(_0x4cd56c,_0x5bf995){return function(_0x4e6bac){if(!_0x4e6bac){_0x4cd56c[_0x5887('0x1d')](0x194);}return _0x4e6bac;};}function handleError(_0x4925ae,_0x3978fe){_0x3978fe=_0x3978fe||0x1f4;return function(_0x37b6f9){logger[_0x5887('0x2c')](_0x37b6f9[_0x5887('0x2d')]);if(_0x37b6f9[_0x5887('0x2e')]){delete _0x37b6f9[_0x5887('0x2e')];}_0x4925ae[_0x5887('0x1e')](_0x3978fe)[_0x5887('0x2f')](_0x37b6f9);};}function getInteractionUsers(_0x4c2cea,_0x55c9c5){return new BPromise(function(_0x24c2cc,_0x1817d7){try{if(_0x55c9c5[_0x4c2cea['id']]){_0x4c2cea[_0x5887('0x30')]=_['map'](_0x55c9c5[_0x4c2cea['id']],function(_0xf683f2){return{'id':_0xf683f2['id'],'fullname':_0xf683f2['fullname']};});}}catch(_0x7b7718){_0x1817d7(_0x7b7718);}_0x24c2cc(_0x4c2cea);});}function getInteractionTags(_0xb93789,_0x56fb19){return new BPromise(function(_0x3ebaec,_0x32d524){try{if(_0xb93789[_0x5887('0x31')]){_0xb93789[_0x5887('0x32')]=[];_0xb93789['TagIds']['split'](',')[_0x5887('0x33')](function(_0x23ed98){_0xb93789[_0x5887('0x32')][_0x5887('0x34')](_0x56fb19[_0x23ed98]);});}delete _0xb93789[_0x5887('0x31')];}catch(_0x437910){_0x32d524(_0x437910);}_0x3ebaec(_0xb93789);});}function updateFaxInteraction(_0x244ace,_0x518e8f,_0x401a09){return new BPromise(function(_0x370fa5,_0x58c1ae){return getInteractionUsers(_0x244ace,_0x401a09)[_0x5887('0x2b')](function(_0x24e276){return getInteractionTags(_0x24e276,_0x518e8f);})[_0x5887('0x2b')](function(_0xc05015){_0x370fa5(_0xc05015);})['catch'](function(_0x4e669d){_0x58c1ae(_0x4e669d);});});}exports[_0x5887('0x35')]=function(_0x35bfea,_0x45657d){var _0x28b73b={},_0x182168={},_0x1a236f={'count':0x0,'rows':[]};var _0x2473ab=_[_0x5887('0x36')](db[_0x5887('0x37')][_0x5887('0x38')],function(_0x891657){return{'name':_0x891657[_0x5887('0x39')],'type':_0x891657[_0x5887('0x3a')][_0x5887('0x3b')]};});_0x182168[_0x5887('0x3c')]=_['map'](_0x2473ab,_0x5887('0x2e'));_0x182168[_0x5887('0x3d')]=_[_0x5887('0x3e')](_0x35bfea['query']);_0x182168[_0x5887('0x3f')]=_[_0x5887('0x40')](_0x182168[_0x5887('0x3c')],_0x182168[_0x5887('0x3d')]);_0x28b73b[_0x5887('0x41')]=_['intersection'](_0x182168['model'],qs[_0x5887('0x42')](_0x35bfea['query'][_0x5887('0x42')]));_0x28b73b[_0x5887('0x41')]=_0x28b73b[_0x5887('0x41')][_0x5887('0x43')]?_0x28b73b[_0x5887('0x41')]:_0x182168[_0x5887('0x3c')];if(!_0x35bfea[_0x5887('0x3d')][_0x5887('0x44')](_0x5887('0x45'))){_0x28b73b[_0x5887('0x23')]=qs[_0x5887('0x23')](_0x35bfea[_0x5887('0x3d')][_0x5887('0x23')]);_0x28b73b[_0x5887('0x21')]=qs[_0x5887('0x21')](_0x35bfea[_0x5887('0x3d')][_0x5887('0x21')]);}_0x28b73b[_0x5887('0x46')]=qs[_0x5887('0x47')](_0x35bfea[_0x5887('0x3d')][_0x5887('0x47')]);_0x28b73b['where']=qs[_0x5887('0x3f')](_[_0x5887('0x48')](_0x35bfea[_0x5887('0x3d')],_0x182168[_0x5887('0x3f')]),_0x2473ab);var _0x5596ab=[];var _0x50e94a=squel[_0x5887('0x49')]()['field']('id')[_0x5887('0x4a')]('name')[_0x5887('0x4a')]('color')[_0x5887('0x4b')](_0x5887('0x4c'));var _0x3cf8d5=squel[_0x5887('0x49')]()[_0x5887('0x4a')](_0x5887('0x4d'))[_0x5887('0x4a')](_0x5887('0x4e'))['field'](_0x5887('0x4f'))[_0x5887('0x4b')](_0x5887('0x50'),'ui')[_0x5887('0x51')](_0x5887('0x52'),'u','u.id\x20=\x20ui.UserId');var _0x487948=squel['select']()[_0x5887('0x4b')](_0x5887('0x53'),'i')[_0x5887('0x51')](_0x5887('0x54'),'c',_0x5887('0x55'))[_0x5887('0x51')](_0x5887('0x52'),'o',_0x5887('0x56'))[_0x5887('0x51')](_0x5887('0x57'),'a',_0x5887('0x58'))['left_join'](_0x5887('0x59'),'me','me.FaxInteractionId\x20=\x20i.id')[_0x5887('0x51')](_0x5887('0x5a'),'it',_0x5887('0x5b'))[_0x5887('0x51')](_0x5887('0x4c'),'t',_0x5887('0x5c'));var _0x447d85=squel[_0x5887('0x5d')]();var _0x4b66ea=[];var _0x43e4c1=squel[_0x5887('0x5d')]();var _0x4aa380;if(_0x35bfea[_0x5887('0x3d')][_0x5887('0x5e')]){_0x4aa380=as[_0x5887('0x5f')](_0x35bfea[_0x5887('0x3d')][_0x5887('0x5e')]);var _0x3f8913=_0x4aa380[_0x5887('0x60')];for(var _0x27261b=0x0;_0x27261b<_0x4aa380[_0x5887('0x61')][_0x5887('0x43')];_0x27261b++){var _0x1969e9=_0x4aa380['conditions'][_0x27261b];var _0x14b145='i';var _0x4f32ea=_[_0x5887('0x62')](_0x2473ab,[_0x5887('0x2e'),_0x1969e9[_0x5887('0x4a')]]);if(!_0x4f32ea){switch(_0x1969e9[_0x5887('0x4a')]){case'unreadMessages':if(_0x1969e9[_0x5887('0x63')]==0x1){_0x487948['having']('`'+_0x1969e9['field']+_0x5887('0x64'));}else{_0x487948['having']('`'+_0x1969e9['field']+_0x5887('0x65'));}break;case _0x5887('0x66'):if(_0x1969e9[_0x5887('0x67')]==='$substring'){if(_0x1969e9['value']['split']('\x20')[_0x5887('0x43')]>0x1){_0x447d85[_0x3f8913]('MATCH\x20(c.firstName,\x20c.lastName,\x20c.phone,\x20c.mobile,\x20c.fax,\x20c.email)\x20AGAINST\x20(?\x20IN\x20BOOLEAN\x20MODE)',qs[_0x5887('0x68')](_0x1969e9[_0x5887('0x63')]),null);}else{var _0x387053='%'+_0x1969e9[_0x5887('0x63')]+'%';_0x447d85[_0x3f8913]('c.firstName\x20LIKE\x20?\x20OR\x20c.lastName\x20LIKE\x20?\x20OR\x20c.email\x20LIKE\x20?',_0x387053,_0x387053,_0x387053);}}else{_0x4f32ea=_[_0x5887('0x62')](_0x2473ab,[_0x5887('0x2e'),_0x5887('0x69')]);_0x1969e9[_0x5887('0x4a')]=_0x5887('0x69');_0x2804ca=as['buildExpression'](_0x14b145,_0x4f32ea['type'],_0x1969e9);_0x447d85[_0x3f8913](_0x2804ca[_0x5887('0x6a')],_0x2804ca[_0x5887('0x63')][_0x5887('0x6b')],_0x2804ca[_0x5887('0x63')][_0x5887('0x1f')]);}break;case _0x5887('0x6c'):var _0x22e134=_0x1969e9[_0x5887('0x63')]['split'](',')['map'](function(_0x10ef07){return Number(_0x10ef07);});_0x22e134[_0x5887('0x33')](function(_0x4a4567){_0x43e4c1['or'](_0x5887('0x6d'),'%,'+_0x4a4567+',%');});_0x4b66ea=_['union'](_0x4b66ea,_0x22e134);break;case _0x5887('0x6e'):if(_0x1969e9[_0x5887('0x67')]===_0x5887('0x6f')){_0x447d85[_0x3f8913]('CONCAT_WS(\x27\x20\x27,\x20o.name,\x20o.fullname)\x20LIKE\x20?','%'+_0x1969e9[_0x5887('0x63')]+'%',null);}else{_0x4f32ea=_[_0x5887('0x62')](_0x2473ab,[_0x5887('0x2e'),_0x5887('0x70')]);_0x1969e9[_0x5887('0x4a')]=_0x5887('0x70');_0x2804ca=as['buildExpression'](_0x14b145,_0x4f32ea['type'],_0x1969e9);_0x447d85[_0x3f8913](_0x2804ca[_0x5887('0x6a')],_0x2804ca['value']['start'],_0x2804ca['value'][_0x5887('0x1f')]);}break;case'body':_0x2804ca=as[_0x5887('0x71')]('me',null,_0x1969e9);_0x447d85[_0x3f8913](_0x2804ca['text'],_0x2804ca[_0x5887('0x63')][_0x5887('0x6b')],_0x2804ca['value'][_0x5887('0x1f')]);break;}}else{var _0x2804ca=as[_0x5887('0x71')](_0x14b145,_0x4f32ea[_0x5887('0x3a')],_0x1969e9);_0x447d85[_0x3f8913](_0x2804ca[_0x5887('0x6a')],_0x2804ca[_0x5887('0x63')][_0x5887('0x6b')],_0x2804ca[_0x5887('0x63')][_0x5887('0x1f')]);}}}else{var _0x23562c=_(_0x35bfea[_0x5887('0x3d')])[_0x5887('0x3e')]()[_0x5887('0x36')](function(_0x2f3063){return _['some'](_0x2473ab,[_0x5887('0x2e'),_0x2f3063])?_0x2f3063:undefined;})[_0x5887('0x72')]()[_0x5887('0x63')]();if(!_[_0x5887('0x73')](_0x23562c)){_0x23562c[_0x5887('0x33')](function(_0x2263c6){if(_0x2263c6===_0x5887('0x74')){_0x487948[_0x5887('0x75')]('i.FaxAccountId\x20IN\x20?',[]['concat'](_0x35bfea[_0x5887('0x3d')][_0x2263c6]));}else if(_0x2263c6==='createdAt'){var _0x1e5557=JSON['parse'](_0x35bfea[_0x5887('0x3d')][_0x2263c6])[_0x5887('0x76')];var _0x197f8f=JSON[_0x5887('0x77')](_0x35bfea[_0x5887('0x3d')][_0x2263c6])[_0x5887('0x78')];_0x487948['where'](_0x5887('0x79'),_0x1e5557,_0x197f8f);}else{if(_0x35bfea[_0x5887('0x3d')][_0x2263c6]===_0x5887('0x7a')){_0x487948['where']('i.'+_0x2263c6+_0x5887('0x7b'));}else{_0x487948[_0x5887('0x75')]('i.'+_0x2263c6+_0x5887('0x7c'),_0x35bfea[_0x5887('0x3d')][_0x2263c6]);}}});}if(_0x35bfea[_0x5887('0x3d')][_0x5887('0x7d')]){if(_0x35bfea[_0x5887('0x3d')]['read']==0x1){_0x487948[_0x5887('0x7e')](_0x5887('0x7f'));}else{_0x487948[_0x5887('0x7e')]('`unreadMessages`\x20>\x200');}}if(_0x35bfea[_0x5887('0x3d')][_0x5887('0x80')]){_0x4b66ea=_[_0x5887('0x81')](_0x35bfea[_0x5887('0x3d')]['tag'])?_0x35bfea['query']['tag']:new Array(_0x35bfea[_0x5887('0x3d')]['tag']);_0x4b66ea[_0x5887('0x33')](function(_0x5430f5){_0x43e4c1['or']('CONCAT(\x27,\x27,\x20`TagIds`,\x20\x27,\x27)\x20LIKE\x20?','%,'+_0x5430f5+',%');});}if(_0x35bfea[_0x5887('0x3d')][_0x5887('0x82')]){var _0x277705=_0x35bfea['query'][_0x5887('0x82')][_0x5887('0x83')]('\x5c','\x5c\x5c')[_0x5887('0x83')](/'/g,'\x27\x27');if(qs[_0x5887('0x84')](_0x277705)){_0x447d85['or'](_0x5887('0x85'),_0x277705+'%')['or'](_0x5887('0x86'),_0x277705+'%');}_0x447d85['or']('CONCAT(c.firstName,\x20\x27\x20\x27,\x20c.lastName)\x20LIKE\x20?',_0x277705+'%');}}_0x487948['where'](_0x447d85);_0x487948[_0x5887('0x87')]('i.id');var _0x460d52={'type':db[_0x5887('0x88')][_0x5887('0x89')][_0x5887('0x8a')],'raw':!![]};var _0x33712d=_0x487948['clone']();_0x33712d[_0x5887('0x4a')](_0x5887('0x8b'));_0x33712d['field'](_0x5887('0x8c'),_0x5887('0x8d'));if(_0x28b73b['order']){_0x28b73b[_0x5887('0x46')][_0x5887('0x33')](function(_0x70a648){var _0x26980=_0x70a648[0x0]===_0x5887('0x8e')?_0x70a648[0x0]:'i.'+_0x70a648[0x0];_0x487948[_0x5887('0x46')](_0x26980,_0x70a648[0x1]===_0x5887('0x8f')?![]:!![]);});}if(!_[_0x5887('0x73')](_0x4b66ea)){_0x487948[_0x5887('0x7e')](_0x43e4c1);_0x33712d[_0x5887('0x75')](_0x5887('0x90'),_0x4b66ea);}BPromise[_0x5887('0x91')]()['then'](function(){if(!_0x4aa380){if(_0x35bfea['query'][_0x5887('0x74')])return;_0x33712d[_0x5887('0x75')](_0x5887('0x92'));_0x487948['where'](_0x5887('0x92'));return;}if(_0x35bfea[_0x5887('0x93')]['role']!==_0x5887('0x94'))return;return _0x35bfea[_0x5887('0x93')][_0x5887('0x95')]({'attributes':['id'],'raw':!![]})[_0x5887('0x2b')](function(_0x260010){if(_[_0x5887('0x73')](_0x260010)){_0x33712d[_0x5887('0x75')](_0x5887('0x96'));_0x487948['where'](_0x5887('0x96'));}else{_0x33712d['where']('i.FaxAccountId\x20IN\x20?',_[_0x5887('0x36')](_0x260010,'id'));_0x487948['where'](_0x5887('0x97'),_[_0x5887('0x36')](_0x260010,'id'));}});})[_0x5887('0x2b')](function(){if(_0x35bfea[_0x5887('0x93')]['role']===_0x5887('0x94')&&!_0x4aa380&&!_0x35bfea[_0x5887('0x3d')][_0x5887('0x74')])return[];return db[_0x5887('0x98')][_0x5887('0x3d')](_0x33712d[_0x5887('0x99')](),_0x460d52);})['then'](function(_0x4088c7){_0x1a236f[_0x5887('0x24')]=_0x4088c7['length'];if(_0x1a236f['count']===0x0)return[];return db[_0x5887('0x98')][_0x5887('0x3d')](_0x50e94a[_0x5887('0x99')](),_0x460d52)[_0x5887('0x2b')](function(_0x2c0724){_0x5596ab=_[_0x5887('0x9a')](_0x2c0724,'id');_0x460d52=_[_0x5887('0x9b')](_0x460d52,{'model':db['FaxInteraction'],'mapToModel':!![],'raw':!![],'nest':!![]});if(_0x35bfea[_0x5887('0x3d')][_0x5887('0x42')]){_0x28b73b[_0x5887('0x41')]['forEach'](function(_0x4bc665){_0x487948['field']('i.'+_0x4bc665);});}else{_0x487948['field'](_0x5887('0x8c'),'unreadMessages');_0x487948['field']('a.key',_0x5887('0x9c'));_0x487948[_0x5887('0x4a')]('a.mandatoryDisposition',_0x5887('0x9d'));_0x487948[_0x5887('0x4a')](_0x5887('0x9e'),_0x5887('0x8e'));_0x487948[_0x5887('0x4a')](_0x5887('0x9f'));_0x487948[_0x5887('0x4a')](_0x5887('0xa0'),_0x5887('0xa1'));_0x487948[_0x5887('0x4a')](_0x5887('0xa2'),'Contact.lastName');_0x487948[_0x5887('0x4a')]('c.email',_0x5887('0xa3'));_0x487948[_0x5887('0x4a')](_0x5887('0xa4'),_0x5887('0xa5'));_0x487948[_0x5887('0x4a')]('c.mobile','Contact.mobile');_0x487948[_0x5887('0x4a')](_0x5887('0xa6'),'Contact.fax');_0x487948[_0x5887('0x4a')]('o.fullname',_0x5887('0xa7'));_0x487948[_0x5887('0x4a')]('o.internal',_0x5887('0xa8'));_0x487948[_0x5887('0x4a')](_0x5887('0xa9'),_0x5887('0x31'));}if(_0x28b73b[_0x5887('0x23')])_0x487948[_0x5887('0x23')](_0x28b73b[_0x5887('0x23')]);if(_0x28b73b[_0x5887('0x21')])_0x487948['offset'](_0x28b73b['offset']);return db[_0x5887('0x98')]['query'](_0x487948[_0x5887('0x99')](),_0x460d52);})[_0x5887('0x2b')](function(_0x53443f){if(_0x53443f[_0x5887('0x43')]>0x0)_0x3cf8d5[_0x5887('0x75')](_0x5887('0xaa'),_[_0x5887('0x36')](_0x53443f,'id'));return db[_0x5887('0x98')]['query'](_0x3cf8d5[_0x5887('0x99')](),_0x460d52)[_0x5887('0x2b')](function(_0x2ba2b3){var _0x4126c8=_[_0x5887('0xab')](_0x2ba2b3,_0x5887('0xac'));var _0x4ab856=[];_0x53443f[_0x5887('0x33')](function(_0x497b95){_0x4ab856[_0x5887('0x34')](updateFaxInteraction(_0x497b95,_0x5596ab,_0x4126c8));});return BPromise[_0x5887('0xad')](_0x4ab856);});});})[_0x5887('0x2b')](function(_0x7d16b){_0x1a236f[_0x5887('0xae')]=_0x7d16b;return _0x1a236f;})[_0x5887('0x2b')](respondWithFilteredResult(_0x45657d,_0x28b73b))[_0x5887('0xaf')](handleError(_0x45657d,null));};exports[_0x5887('0xb0')]=function(_0x10ab2b,_0x39d9a3){var _0x1b4383={'raw':![],'where':{'id':_0x10ab2b[_0x5887('0xb1')]['id']}},_0x743007={};_0x743007[_0x5887('0x3c')]=_[_0x5887('0x3e')](db['FaxInteraction']['rawAttributes']);_0x743007[_0x5887('0x3d')]=_[_0x5887('0x3e')](_0x10ab2b[_0x5887('0x3d')]);_0x743007[_0x5887('0x3f')]=_[_0x5887('0x40')](_0x743007[_0x5887('0x3c')],_0x743007['query']);_0x1b4383['attributes']=_[_0x5887('0x40')](_0x743007[_0x5887('0x3c')],qs[_0x5887('0x42')](_0x10ab2b[_0x5887('0x3d')][_0x5887('0x42')]));_0x1b4383['attributes']=_0x1b4383[_0x5887('0x41')][_0x5887('0x43')]?_0x1b4383['attributes']:_0x743007[_0x5887('0x3c')];if(_0x10ab2b[_0x5887('0x3d')][_0x5887('0xb2')]){_0x1b4383[_0x5887('0xb3')]=[{'all':!![]}];}_0x1b4383=_[_0x5887('0x9b')]({},_0x1b4383,_0x10ab2b[_0x5887('0xb4')]);return db[_0x5887('0x37')][_0x5887('0x62')](_0x1b4383)[_0x5887('0x2b')](handleEntityNotFound(_0x39d9a3,null))[_0x5887('0x2b')](respondWithResult(_0x39d9a3,null))[_0x5887('0xaf')](handleError(_0x39d9a3,null));};exports[_0x5887('0xb5')]=function(_0x48a508,_0x537adb){return db[_0x5887('0x37')][_0x5887('0xb5')](_0x48a508['body'],{})[_0x5887('0x2b')](respondWithResult(_0x537adb,0xc9))['catch'](handleError(_0x537adb,null));};exports[_0x5887('0x29')]=function(_0x3f1f38,_0x4dafe4){if(_0x3f1f38[_0x5887('0xb6')]['id']){delete _0x3f1f38[_0x5887('0xb6')]['id'];}return db[_0x5887('0x37')][_0x5887('0x62')]({'where':{'id':_0x3f1f38[_0x5887('0xb1')]['id']}})[_0x5887('0x2b')](handleEntityNotFound(_0x4dafe4,null))[_0x5887('0x2b')](saveUpdates(_0x3f1f38[_0x5887('0xb6')],null))[_0x5887('0x2b')](respondWithResult(_0x4dafe4,null))[_0x5887('0xaf')](handleError(_0x4dafe4,null));};exports['destroy']=function(_0x45b5d3,_0xa207e3){return db[_0x5887('0x37')]['find']({'where':{'id':_0x45b5d3[_0x5887('0xb1')]['id']}})[_0x5887('0x2b')](handleEntityNotFound(_0xa207e3,null))[_0x5887('0x2b')](removeEntity(_0xa207e3,null))[_0x5887('0xaf')](handleError(_0xa207e3,null));};exports[_0x5887('0xb7')]=function(_0x5f2319,_0xd12dc5){return db['FaxInteraction'][_0x5887('0xb7')]()['then'](respondWithResult(_0xd12dc5,null))['catch'](handleError(_0xd12dc5,null));};exports[_0x5887('0xb8')]=function(_0x50c101,_0xc9c4cd,_0x107973){return db[_0x5887('0xb9')][_0x5887('0x62')]({'where':{'id':_0x50c101[_0x5887('0xb1')]['id']}})[_0x5887('0x2b')](handleEntityNotFound(_0xc9c4cd,null))[_0x5887('0x2b')](function(_0x44632f){if(_0x44632f){return _0x44632f['addMessage'](_0x50c101['body']['ids'],_[_0x5887('0xba')](_0x50c101[_0x5887('0xb6')],[_0x5887('0xbb'),'id'])||{});}})[_0x5887('0x2b')](respondWithResult(_0xc9c4cd,null))['catch'](handleError(_0xc9c4cd,null));};exports['getMessages']=function(_0x27f77d,_0x2870c9,_0xd3c1ef){var _0x4ca510={'raw':![],'where':{}};var _0x589181={};var _0x2c7eb3={'count':0x0,'rows':[]};return db[_0x5887('0x37')][_0x5887('0xbc')]({'where':{'id':_0x27f77d[_0x5887('0xb1')]['id']}})['then'](handleEntityNotFound(_0x2870c9,null))['then'](function(_0x53413d){if(_0x53413d){_0x589181[_0x5887('0x3c')]=_[_0x5887('0x3e')](db[_0x5887('0xb9')]['rawAttributes']);_0x589181['query']=_['keys'](_0x27f77d[_0x5887('0x3d')]);_0x589181[_0x5887('0x3f')]=_[_0x5887('0x40')](_0x589181[_0x5887('0x3c')],_0x589181['query']);_0x4ca510['attributes']=_[_0x5887('0x40')](_0x589181[_0x5887('0x3c')],qs[_0x5887('0x42')](_0x27f77d[_0x5887('0x3d')]['fields']));_0x4ca510['attributes']=_0x4ca510['attributes'][_0x5887('0x43')]?_0x4ca510[_0x5887('0x41')]:_0x589181[_0x5887('0x3c')];if(!_0x27f77d[_0x5887('0x3d')][_0x5887('0x44')](_0x5887('0x45'))){_0x4ca510[_0x5887('0x23')]=qs['limit'](_0x27f77d[_0x5887('0x3d')][_0x5887('0x23')]);_0x4ca510['offset']=qs[_0x5887('0x21')](_0x27f77d[_0x5887('0x3d')]['offset']);}_0x4ca510['order']=qs[_0x5887('0x47')](_0x27f77d['query'][_0x5887('0x47')]);_0x4ca510[_0x5887('0x75')]=qs['filters'](_[_0x5887('0x48')](_0x27f77d['query'],_0x589181[_0x5887('0x3f')]));_0x4ca510[_0x5887('0x75')][_0x5887('0xac')]=_0x53413d['id'];if(_0x27f77d[_0x5887('0x3d')]['filter']){_0x4ca510[_0x5887('0x75')]=_[_0x5887('0x9b')](_0x4ca510[_0x5887('0x75')],{'$or':_[_0x5887('0x36')](_0x4ca510[_0x5887('0x41')],function(_0x5a4eb){var _0x30bad1={};_0x30bad1[_0x5a4eb]={'$like':'%'+_0x27f77d[_0x5887('0x3d')]['filter']+'%'};return _0x30bad1;})});}if(_0x27f77d['query']['$gte']){var _0x3cf12f=_0x27f77d[_0x5887('0x3d')][_0x5887('0x76')]['split'](',');var _0x5c1e04={};_0x5c1e04[_0x3cf12f[0x0]]={'$gte':moment(_0x3cf12f[0x1])[_0x5887('0xbd')]('YYYY-MM-DD\x20HH:mm:ss')};_0x4ca510[_0x5887('0x75')]=_[_0x5887('0x9b')](_0x4ca510[_0x5887('0x75')],_0x5c1e04);}_0x4ca510=_[_0x5887('0x9b')]({},_0x4ca510,_0x27f77d[_0x5887('0xb4')]);return db[_0x5887('0xb9')]['count']({'where':_0x4ca510['where']})[_0x5887('0x2b')](function(_0x4b0ff4){_0x2c7eb3['count']=_0x4b0ff4;if(_0x27f77d[_0x5887('0x3d')]['includeAll']){_0x4ca510['include']=[{'all':!![]}];}return db[_0x5887('0xb9')][_0x5887('0xbe')](_0x4ca510);})[_0x5887('0x2b')](function(_0x55e1ba){_0x2c7eb3['rows']=_0x55e1ba;return _0x2c7eb3;});}})['then'](respondWithFilteredResult(_0x2870c9,_0x4ca510))[_0x5887('0xaf')](handleError(_0x2870c9,null));};exports[_0x5887('0xbf')]=function(_0x836df,_0x34a1a7,_0x47f9cf){return db['FaxInteraction'][_0x5887('0x62')]({'where':{'id':_0x836df[_0x5887('0xb1')]['id']}})[_0x5887('0x2b')](handleEntityNotFound(_0x34a1a7,null))['then'](function(_0x329452){if(_0x329452){return _0x329452[_0x5887('0xc0')](_0x836df['body'][_0x5887('0xbb')],_[_0x5887('0xba')](_0x836df[_0x5887('0xb6')],[_0x5887('0xbb'),'id'])||{})[_0x5887('0xc1')](function(){return db[_0x5887('0x6c')][_0x5887('0xbe')]({'attributes':['id',_0x5887('0x2e'),_0x5887('0xc2')],'where':{'id':_0x836df['body'][_0x5887('0xbb')]}});})['then'](function(_0x162bf0){socket[_0x5887('0xc3')](_0x5887('0xc4'),{'id':Number(_0x836df[_0x5887('0xb1')]['id']),'tags':_0x162bf0||[]});return{'id':Number(_0x836df[_0x5887('0xb1')]['id']),'tags':_0x162bf0||[]};});}})[_0x5887('0x2b')](respondWithResult(_0x34a1a7,null))[_0x5887('0xaf')](handleError(_0x34a1a7,null));};exports[_0x5887('0xc5')]=function(_0x1f8ec1,_0x468bbb,_0x4e84db){return db[_0x5887('0x37')][_0x5887('0x62')]({'where':{'id':_0x1f8ec1[_0x5887('0xb1')]['id']}})[_0x5887('0x2b')](handleEntityNotFound(_0x468bbb,null))['then'](function(_0x445c2b){if(_0x445c2b){return _0x445c2b[_0x5887('0xc5')](_0x1f8ec1[_0x5887('0x3d')][_0x5887('0xbb')]);}})[_0x5887('0x2b')](respondWithStatusCode(_0x468bbb,null))['catch'](handleError(_0x468bbb,null));};exports['download']=function(_0x2e10d2,_0x51e323){var _0x48d8c6=moment()['unix']()[_0x5887('0x99')]();var _0x361d1f=path[_0x5887('0xc6')](config[_0x5887('0xc7')],_0x5887('0xc8'),_0x5887('0xc9'),_0x5887('0xca'));var _0x120a25=path[_0x5887('0xc6')](config[_0x5887('0xc7')],_0x5887('0xc8'),'files','attachments');var _0x42abb6=path[_0x5887('0xc6')](_0x361d1f,_0x48d8c6);var _0x2f0763=util['format'](_0x5887('0xcb'),_0x2e10d2[_0x5887('0xb1')]['id'],_0x48d8c6);var _0x508f37=path['join'](_0x361d1f,_0x2f0763);var _0x3ff739=[];_0x3ff739[_0x5887('0x34')]({'model':db[_0x5887('0xcc')],'as':_0x5887('0xcc'),'raw':!![]});var _0x1ff72f=[{'model':db[_0x5887('0xb9')],'as':_0x5887('0xcd'),'attributes':['id',_0x5887('0xb6'),_0x5887('0xce')],'include':_0x3ff739}];return db[_0x5887('0x37')][_0x5887('0x62')]({'where':{'id':_0x2e10d2[_0x5887('0xb1')]['id']},'include':_0x1ff72f})[_0x5887('0x2b')](handleEntityNotFound(_0x51e323,null))[_0x5887('0x2b')](function(_0xe9824f){if(_0xe9824f&&_0xe9824f[_0x5887('0xcd')]){var _0x3ae705=_0xe9824f[_0x5887('0xcf')]({'plain':!![]});fs['mkdirSync'](_0x42abb6);for(var _0x1e60da=0x0;_0x1e60da<_0x3ae705[_0x5887('0xcd')][_0x5887('0x43')];_0x1e60da++){var _0x302560=_0x3ae705['Messages'][_0x1e60da][_0x5887('0xcc')];if(_0x302560){var _0x497119=path[_0x5887('0xc6')](_0x120a25,_0x302560['basename']);if(fs[_0x5887('0xd0')](_0x497119)){fs[_0x5887('0xd1')](_0x497119)[_0x5887('0xd2')](fs['createWriteStream'](path[_0x5887('0xc6')](_0x42abb6,_0x302560[_0x5887('0xd3')])));}}}return BPromise[_0x5887('0x91')]()[_0x5887('0x2b')](function(){return new BPromise(function(_0x1fa64a,_0x51b6a6){zipdir(_0x42abb6,{'saveTo':_0x508f37},function(_0x563e0f,_0x1be91e){if(_0x563e0f)return _0x51b6a6(_0x563e0f);return _0x1fa64a(_0x1be91e);});})[_0x5887('0x2b')](function(){return new BPromise(function(_0x457083,_0x106879){rimraf(_0x42abb6,function(_0xd0cda9){if(_0xd0cda9)_0x106879(_0xd0cda9);return _0x457083();});});})['then'](function(){return _0x51e323[_0x5887('0xd4')](_0x508f37,_0x2f0763,function(_0x4f4c90){if(_0x4f4c90){console['log'](_0x5887('0xd5'),_0x4f4c90);}else{fs[_0x5887('0xd6')](_0x508f37);}});});});}else{return _0x51e323['sendStatus'](0xc8);}})[_0x5887('0xaf')](handleError(_0x51e323,null));};
\ No newline at end of file
+var _0x962f=['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','ContactId','buildExpression','text','start','CONCAT(\x27,\x27,\x20`TagIds`,\x20\x27,\x27)\x20LIKE\x20?','CONCAT_WS(\x27\x20\x27,\x20o.name,\x20o.fullname)\x20LIKE\x20?','UserId','body','some','isEmpty','FaxAccountId','concat','createdAt','$gte','parse','i.createdAt\x20BETWEEN\x20?\x20AND\x20?','\x20IS\x20NULL','\x20=\x20?','read','`unreadMessages`\x20>\x200','tag','isArray','replace','isNumeric','i.fax\x20LIKE\x20?','i.id','Sequelize','QueryTypes','clone','contactName','t.id\x20IN\x20?','i.FaxAccountId\x20IS\x20NOT\x20NULL','user','role','agent','getFaxAccounts','i.FaxAccountId\x20IS\x20NULL','i.FaxAccountId\x20IN\x20?','sequelize','toString','keyBy','merge','a.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','o.fullname','Owner.internal','GROUP_CONCAT(DISTINCT\x20t.id)','ui.FaxInteractionId\x20IN\x20?','groupBy','all','catch','show','params','rawAttributes','include','options','create','describe','addMessage','FaxMessage','ids','omit','getMessages','findOne','filter','format','YYYY-MM-DD\x20HH:mm:ss','rows','Tag','findAll','emit','removeTags','unix','join','root','server','files','tmp','transcript-%d-%s.zip','Attachment','Messages','get','mkdirSync','basename','existsSync','createReadStream','createWriteStream','resolve','download','log','unlinkSync','zip-dir','fast-json-patch','request-promise','mustache','util','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','papaparse','ioredis','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../config/license/util','redis','defaults','localhost','socket.io-emitter','./faxInteraction.socket','register','status','offset','undefined','limit','count','apply','reject','save','then','destroy','end','sendStatus','error','stack','send','Users','map','Tags','TagIds','split','forEach','push','index','FaxInteraction','fieldName','type','model','name','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','select','field','color','from','tools_tags','u.fullname','ui.FaxInteractionId','user_has_fax_interactions','left_join','users','cm_contacts','c.id\x20=\x20i.ContactId\x20AND\x20c.deletedAt\x20IS\x20NULL','o.id\x20=\x20i.UserId','fax_accounts','fax_messages','me.FaxInteractionId\x20=\x20i.id','fax_interaction_has_tags','it.FaxInteractionId\x20=\x20i.id','expr','parseSearch','search','sqlOperator','conditions','find'];(function(_0x321bb2,_0x202794){var _0x9c12ed=function(_0x263dd3){while(--_0x263dd3){_0x321bb2['push'](_0x321bb2['shift']());}};_0x9c12ed(++_0x202794);}(_0x962f,0x73));var _0xf962=function(_0x20a584,_0xe384a5){_0x20a584=_0x20a584-0x0;var _0x4b41a8=_0x962f[_0x20a584];return _0x4b41a8;};'use strict';var emlformat=require('eml-format');var rimraf=require('rimraf');var zipdir=require(_0xf962('0x0'));var jsonpatch=require(_0xf962('0x1'));var rp=require(_0xf962('0x2'));var moment=require('moment');var BPromise=require('bluebird');var Mustache=require(_0xf962('0x3'));var util=require(_0xf962('0x4'));var path=require('path');var sox=require(_0xf962('0x5'));var csv=require(_0xf962('0x6'));var ejs=require(_0xf962('0x7'));var fs=require('fs');var fs_extra=require(_0xf962('0x8'));var _=require(_0xf962('0x9'));var squel=require(_0xf962('0xa'));var crypto=require(_0xf962('0xb'));var jsforce=require(_0xf962('0xc'));var deskjs=require(_0xf962('0xd'));var toCsv=require(_0xf962('0x6'));var querystring=require('querystring');var Papa=require(_0xf962('0xe'));var Redis=require(_0xf962('0xf'));var authService=require('../../components/auth/service');var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xf962('0x10'));var logger=require(_0xf962('0x11'))('api');var utils=require(_0xf962('0x12'));var config=require(_0xf962('0x13'));var licenseUtil=require(_0xf962('0x14'));var db=require('../../mysqldb')['db'];config[_0xf962('0x15')]=_[_0xf962('0x16')](config[_0xf962('0x15')],{'host':_0xf962('0x17'),'port':0x18eb});var socket=require(_0xf962('0x18'))(new Redis(config[_0xf962('0x15')]));require(_0xf962('0x19'))[_0xf962('0x1a')](socket);function respondWithStatusCode(_0x2ed4c4,_0x4a0a77){_0x4a0a77=_0x4a0a77||0xcc;return function(_0x2c871e){if(_0x2c871e){return _0x2ed4c4['sendStatus'](_0x4a0a77);}return _0x2ed4c4['status'](_0x4a0a77)['end']();};}function respondWithResult(_0x3a3f13,_0x16f655){_0x16f655=_0x16f655||0xc8;return function(_0x58f8a3){if(_0x58f8a3){return _0x3a3f13[_0xf962('0x1b')](_0x16f655)['json'](_0x58f8a3);}};}function respondWithFilteredResult(_0x33855e,_0x5ec9e2){return function(_0x24d461){if(_0x24d461){var _0x32860a=typeof _0x5ec9e2[_0xf962('0x1c')]===_0xf962('0x1d')&&typeof _0x5ec9e2[_0xf962('0x1e')]==='undefined';var _0x115548=_0x24d461['count'];var _0x2619d7=_0x32860a?0x0:_0x5ec9e2[_0xf962('0x1c')];var _0x4bad28=_0x32860a?_0x24d461[_0xf962('0x1f')]:_0x5ec9e2['offset']+_0x5ec9e2[_0xf962('0x1e')];var _0x4cc1b2;if(_0x4bad28>=_0x115548){_0x4bad28=_0x115548;_0x4cc1b2=0xc8;}else{_0x4cc1b2=0xce;}_0x33855e[_0xf962('0x1b')](_0x4cc1b2);return _0x33855e['set']('Content-Range',_0x2619d7+'-'+_0x4bad28+'/'+_0x115548)['json'](_0x24d461);}return null;};}function patchUpdates(_0x499739){return function(_0x2116af){try{jsonpatch[_0xf962('0x20')](_0x2116af,_0x499739,!![]);}catch(_0x1d7c93){return BPromise[_0xf962('0x21')](_0x1d7c93);}return _0x2116af[_0xf962('0x22')]();};}function saveUpdates(_0x26437f,_0x308bd2){return function(_0x2fa579){if(_0x2fa579){return _0x2fa579['update'](_0x26437f)[_0xf962('0x23')](function(_0x570114){return _0x570114;});}return null;};}function removeEntity(_0x3f67de,_0x3457be){return function(_0x4fec8f){if(_0x4fec8f){return _0x4fec8f[_0xf962('0x24')]()['then'](function(){_0x3f67de[_0xf962('0x1b')](0xcc)[_0xf962('0x25')]();});}};}function handleEntityNotFound(_0x1776f3,_0x248f9e){return function(_0x5612e4){if(!_0x5612e4){_0x1776f3[_0xf962('0x26')](0x194);}return _0x5612e4;};}function handleError(_0x50d7bc,_0x588372){_0x588372=_0x588372||0x1f4;return function(_0x5e8273){logger[_0xf962('0x27')](_0x5e8273[_0xf962('0x28')]);if(_0x5e8273['name']){delete _0x5e8273['name'];}_0x50d7bc[_0xf962('0x1b')](_0x588372)[_0xf962('0x29')](_0x5e8273);};}function getInteractionUsers(_0x33da6c,_0x361a2f){return new BPromise(function(_0x428943,_0x5090e5){try{if(_0x361a2f[_0x33da6c['id']]){_0x33da6c[_0xf962('0x2a')]=_[_0xf962('0x2b')](_0x361a2f[_0x33da6c['id']],function(_0x9c1776){return{'id':_0x9c1776['id'],'fullname':_0x9c1776['fullname']};});}}catch(_0x1e98a7){_0x5090e5(_0x1e98a7);}_0x428943(_0x33da6c);});}function getInteractionTags(_0x523471,_0x5d649b){return new BPromise(function(_0x3be4b4,_0x331619){try{if(_0x523471['TagIds']){_0x523471[_0xf962('0x2c')]=[];_0x523471[_0xf962('0x2d')][_0xf962('0x2e')](',')[_0xf962('0x2f')](function(_0x52061a){_0x523471['Tags'][_0xf962('0x30')](_0x5d649b[_0x52061a]);});}delete _0x523471[_0xf962('0x2d')];}catch(_0x2c4587){_0x331619(_0x2c4587);}_0x3be4b4(_0x523471);});}function updateFaxInteraction(_0x5c5479,_0xc573db,_0xd7140b){return new BPromise(function(_0x4339ef,_0x157a24){return getInteractionUsers(_0x5c5479,_0xd7140b)[_0xf962('0x23')](function(_0x3cf2f4){return getInteractionTags(_0x3cf2f4,_0xc573db);})[_0xf962('0x23')](function(_0x346877){_0x4339ef(_0x346877);})['catch'](function(_0x5c9f8b){_0x157a24(_0x5c9f8b);});});}exports[_0xf962('0x31')]=function(_0x2dd276,_0x372c22){var _0x18176e={},_0x3757b5={},_0x30f4fe={'count':0x0,'rows':[]};var _0x104531=_['map'](db[_0xf962('0x32')]['rawAttributes'],function(_0x4d5c6e){return{'name':_0x4d5c6e[_0xf962('0x33')],'type':_0x4d5c6e[_0xf962('0x34')]['key']};});_0x3757b5[_0xf962('0x35')]=_[_0xf962('0x2b')](_0x104531,_0xf962('0x36'));_0x3757b5[_0xf962('0x37')]=_[_0xf962('0x38')](_0x2dd276['query']);_0x3757b5[_0xf962('0x39')]=_[_0xf962('0x3a')](_0x3757b5[_0xf962('0x35')],_0x3757b5['query']);_0x18176e[_0xf962('0x3b')]=_['intersection'](_0x3757b5[_0xf962('0x35')],qs[_0xf962('0x3c')](_0x2dd276[_0xf962('0x37')][_0xf962('0x3c')]));_0x18176e['attributes']=_0x18176e[_0xf962('0x3b')][_0xf962('0x3d')]?_0x18176e[_0xf962('0x3b')]:_0x3757b5[_0xf962('0x35')];if(!_0x2dd276[_0xf962('0x37')][_0xf962('0x3e')](_0xf962('0x3f'))){_0x18176e['limit']=qs[_0xf962('0x1e')](_0x2dd276[_0xf962('0x37')]['limit']);_0x18176e['offset']=qs[_0xf962('0x1c')](_0x2dd276[_0xf962('0x37')]['offset']);}_0x18176e[_0xf962('0x40')]=qs[_0xf962('0x41')](_0x2dd276[_0xf962('0x37')][_0xf962('0x41')]);_0x18176e[_0xf962('0x42')]=qs['filters'](_[_0xf962('0x43')](_0x2dd276[_0xf962('0x37')],_0x3757b5[_0xf962('0x39')]),_0x104531);var _0x283a0d=[];var _0x38caab=squel[_0xf962('0x44')]()[_0xf962('0x45')]('id')['field'](_0xf962('0x36'))['field'](_0xf962('0x46'))[_0xf962('0x47')](_0xf962('0x48'));var _0x2ae374=squel['select']()[_0xf962('0x45')]('u.id')[_0xf962('0x45')](_0xf962('0x49'))[_0xf962('0x45')](_0xf962('0x4a'))[_0xf962('0x47')](_0xf962('0x4b'),'ui')[_0xf962('0x4c')](_0xf962('0x4d'),'u','u.id\x20=\x20ui.UserId');var _0x2291ee=squel['select']()[_0xf962('0x47')]('fax_interactions','i')[_0xf962('0x4c')](_0xf962('0x4e'),'c',_0xf962('0x4f'))['left_join'](_0xf962('0x4d'),'o',_0xf962('0x50'))[_0xf962('0x4c')](_0xf962('0x51'),'a','a.id\x20=\x20i.FaxAccountId')['left_join'](_0xf962('0x52'),'me',_0xf962('0x53'))[_0xf962('0x4c')](_0xf962('0x54'),'it',_0xf962('0x55'))['left_join'](_0xf962('0x48'),'t','t.id\x20=\x20it.TagId');var _0x418d9b=squel[_0xf962('0x56')]();var _0x255d13=[];var _0x4e17fc=squel[_0xf962('0x56')]();var _0x3510ca;if(_0x2dd276[_0xf962('0x37')]['search']){_0x3510ca=as[_0xf962('0x57')](_0x2dd276[_0xf962('0x37')][_0xf962('0x58')]);var _0x163b1b=_0x3510ca[_0xf962('0x59')];for(var _0x2c623d=0x0;_0x2c623d<_0x3510ca[_0xf962('0x5a')][_0xf962('0x3d')];_0x2c623d++){var _0x376460=_0x3510ca['conditions'][_0x2c623d];var _0x5576b7='i';var _0x4e424a=_[_0xf962('0x5b')](_0x104531,['name',_0x376460[_0xf962('0x45')]]);if(!_0x4e424a){switch(_0x376460[_0xf962('0x45')]){case _0xf962('0x5c'):if(_0x376460[_0xf962('0x5d')]==0x1){_0x2291ee[_0xf962('0x5e')]('`'+_0x376460[_0xf962('0x45')]+_0xf962('0x5f'));}else{_0x2291ee[_0xf962('0x5e')]('`'+_0x376460[_0xf962('0x45')]+_0xf962('0x60'));}break;case _0xf962('0x61'):if(_0x376460[_0xf962('0x62')]===_0xf962('0x63')){if(_0x376460[_0xf962('0x5d')]['split']('\x20')['length']>0x1){_0x418d9b[_0x163b1b](_0xf962('0x64'),qs[_0xf962('0x65')](_0x376460['value']),null);}else{var _0x1363e2='%'+_0x376460[_0xf962('0x5d')]+'%';_0x418d9b[_0x163b1b]('c.firstName\x20LIKE\x20?\x20OR\x20c.lastName\x20LIKE\x20?\x20OR\x20c.email\x20LIKE\x20?',_0x1363e2,_0x1363e2,_0x1363e2);}}else{_0x4e424a=_[_0xf962('0x5b')](_0x104531,[_0xf962('0x36'),_0xf962('0x66')]);_0x376460[_0xf962('0x45')]=_0xf962('0x66');_0x63bd41=as[_0xf962('0x67')](_0x5576b7,_0x4e424a[_0xf962('0x34')],_0x376460);_0x418d9b[_0x163b1b](_0x63bd41[_0xf962('0x68')],_0x63bd41['value'][_0xf962('0x69')],_0x63bd41[_0xf962('0x5d')][_0xf962('0x25')]);}break;case'Tag':var _0x1656fc=_0x376460[_0xf962('0x5d')][_0xf962('0x2e')](',')['map'](function(_0x2c960d){return Number(_0x2c960d);});_0x1656fc['forEach'](function(_0x564d5f){_0x4e17fc['or'](_0xf962('0x6a'),'%,'+_0x564d5f+',%');});_0x255d13=_['union'](_0x255d13,_0x1656fc);break;case'User':if(_0x376460['operator']===_0xf962('0x63')){_0x418d9b[_0x163b1b](_0xf962('0x6b'),'%'+_0x376460[_0xf962('0x5d')]+'%',null);}else{_0x4e424a=_[_0xf962('0x5b')](_0x104531,[_0xf962('0x36'),_0xf962('0x6c')]);_0x376460['field']=_0xf962('0x6c');_0x63bd41=as['buildExpression'](_0x5576b7,_0x4e424a[_0xf962('0x34')],_0x376460);_0x418d9b[_0x163b1b](_0x63bd41[_0xf962('0x68')],_0x63bd41[_0xf962('0x5d')][_0xf962('0x69')],_0x63bd41[_0xf962('0x5d')][_0xf962('0x25')]);}break;case _0xf962('0x6d'):_0x63bd41=as[_0xf962('0x67')]('me',null,_0x376460);_0x418d9b[_0x163b1b](_0x63bd41[_0xf962('0x68')],_0x63bd41[_0xf962('0x5d')][_0xf962('0x69')],_0x63bd41[_0xf962('0x5d')]['end']);break;}}else{var _0x63bd41=as['buildExpression'](_0x5576b7,_0x4e424a[_0xf962('0x34')],_0x376460);_0x418d9b[_0x163b1b](_0x63bd41[_0xf962('0x68')],_0x63bd41['value'][_0xf962('0x69')],_0x63bd41[_0xf962('0x5d')][_0xf962('0x25')]);}}}else{var _0x2fca04=_(_0x2dd276[_0xf962('0x37')])[_0xf962('0x38')]()[_0xf962('0x2b')](function(_0x15eeb3){return _[_0xf962('0x6e')](_0x104531,[_0xf962('0x36'),_0x15eeb3])?_0x15eeb3:undefined;})['compact']()[_0xf962('0x5d')]();if(!_[_0xf962('0x6f')](_0x2fca04)){_0x2fca04[_0xf962('0x2f')](function(_0x17db4d){if(_0x17db4d===_0xf962('0x70')){_0x2291ee[_0xf962('0x42')]('i.FaxAccountId\x20IN\x20?',[][_0xf962('0x71')](_0x2dd276[_0xf962('0x37')][_0x17db4d]));}else if(_0x17db4d===_0xf962('0x72')){var _0xf5703d=JSON['parse'](_0x2dd276['query'][_0x17db4d])[_0xf962('0x73')];var _0x187ef3=JSON[_0xf962('0x74')](_0x2dd276[_0xf962('0x37')][_0x17db4d])['$lte'];_0x2291ee[_0xf962('0x42')](_0xf962('0x75'),_0xf5703d,_0x187ef3);}else{if(_0x2dd276[_0xf962('0x37')][_0x17db4d]==='null'){_0x2291ee[_0xf962('0x42')]('i.'+_0x17db4d+_0xf962('0x76'));}else{_0x2291ee[_0xf962('0x42')]('i.'+_0x17db4d+_0xf962('0x77'),_0x2dd276[_0xf962('0x37')][_0x17db4d]);}}});}if(_0x2dd276[_0xf962('0x37')][_0xf962('0x78')]){if(_0x2dd276['query'][_0xf962('0x78')]==0x1){_0x2291ee[_0xf962('0x5e')]('`unreadMessages`\x20=\x200');}else{_0x2291ee[_0xf962('0x5e')](_0xf962('0x79'));}}if(_0x2dd276[_0xf962('0x37')][_0xf962('0x7a')]){_0x255d13=_[_0xf962('0x7b')](_0x2dd276[_0xf962('0x37')]['tag'])?_0x2dd276[_0xf962('0x37')][_0xf962('0x7a')]:new Array(_0x2dd276['query'][_0xf962('0x7a')]);_0x255d13[_0xf962('0x2f')](function(_0xe11d3e){_0x4e17fc['or']('CONCAT(\x27,\x27,\x20`TagIds`,\x20\x27,\x27)\x20LIKE\x20?','%,'+_0xe11d3e+',%');});}if(_0x2dd276[_0xf962('0x37')]['filter']){var _0x8a0564=_0x2dd276[_0xf962('0x37')]['filter'][_0xf962('0x7c')]('\x5c','\x5c\x5c')[_0xf962('0x7c')](/'/g,'\x27\x27');if(qs[_0xf962('0x7d')](_0x8a0564)){_0x418d9b['or']('i.id\x20LIKE\x20?',_0x8a0564+'%')['or'](_0xf962('0x7e'),_0x8a0564+'%');}_0x418d9b['or']('CONCAT(c.firstName,\x20\x27\x20\x27,\x20c.lastName)\x20LIKE\x20?',_0x8a0564+'%');}}_0x2291ee[_0xf962('0x42')](_0x418d9b);_0x2291ee['group'](_0xf962('0x7f'));var _0x130b12={'type':db[_0xf962('0x80')][_0xf962('0x81')]['SELECT'],'raw':!![]};var _0x29c0f3=_0x2291ee[_0xf962('0x82')]();_0x29c0f3[_0xf962('0x45')](_0xf962('0x7f'));_0x29c0f3[_0xf962('0x45')]('SUM(me.read\x20=\x200\x20AND\x20me.direction\x20=\x20\x27in\x27)',_0xf962('0x5c'));if(_0x18176e[_0xf962('0x40')]){_0x18176e[_0xf962('0x40')][_0xf962('0x2f')](function(_0x282f1b){var _0x37f4b7=_0x282f1b[0x0]===_0xf962('0x83')?_0x282f1b[0x0]:'i.'+_0x282f1b[0x0];_0x2291ee[_0xf962('0x40')](_0x37f4b7,_0x282f1b[0x1]==='DESC'?![]:!![]);});}if(!_[_0xf962('0x6f')](_0x255d13)){_0x2291ee[_0xf962('0x5e')](_0x4e17fc);_0x29c0f3[_0xf962('0x42')](_0xf962('0x84'),_0x255d13);}BPromise['resolve']()[_0xf962('0x23')](function(){if(!_0x3510ca){if(_0x2dd276[_0xf962('0x37')][_0xf962('0x70')])return;_0x29c0f3[_0xf962('0x42')]('i.FaxAccountId\x20IS\x20NOT\x20NULL');_0x2291ee[_0xf962('0x42')](_0xf962('0x85'));return;}if(_0x2dd276[_0xf962('0x86')][_0xf962('0x87')]!==_0xf962('0x88'))return;return _0x2dd276[_0xf962('0x86')][_0xf962('0x89')]({'attributes':['id'],'raw':!![]})['then'](function(_0x535ba9){if(_['isEmpty'](_0x535ba9)){_0x29c0f3['where'](_0xf962('0x8a'));_0x2291ee[_0xf962('0x42')]('i.FaxAccountId\x20IS\x20NULL');}else{_0x29c0f3[_0xf962('0x42')](_0xf962('0x8b'),_[_0xf962('0x2b')](_0x535ba9,'id'));_0x2291ee[_0xf962('0x42')]('i.FaxAccountId\x20IN\x20?',_[_0xf962('0x2b')](_0x535ba9,'id'));}});})[_0xf962('0x23')](function(){if(_0x2dd276[_0xf962('0x86')][_0xf962('0x87')]===_0xf962('0x88')&&!_0x3510ca&&!_0x2dd276[_0xf962('0x37')][_0xf962('0x70')])return[];return db[_0xf962('0x8c')][_0xf962('0x37')](_0x29c0f3[_0xf962('0x8d')](),_0x130b12);})['then'](function(_0x4019ec){_0x30f4fe[_0xf962('0x1f')]=_0x4019ec['length'];if(_0x30f4fe[_0xf962('0x1f')]===0x0)return[];return db[_0xf962('0x8c')][_0xf962('0x37')](_0x38caab[_0xf962('0x8d')](),_0x130b12)[_0xf962('0x23')](function(_0x1cfa6d){_0x283a0d=_[_0xf962('0x8e')](_0x1cfa6d,'id');_0x130b12=_[_0xf962('0x8f')](_0x130b12,{'model':db[_0xf962('0x32')],'mapToModel':!![],'raw':!![],'nest':!![]});if(_0x2dd276[_0xf962('0x37')]['fields']){_0x18176e['attributes']['forEach'](function(_0x14845e){_0x2291ee[_0xf962('0x45')]('i.'+_0x14845e);});}else{_0x2291ee[_0xf962('0x45')]('SUM(me.read\x20=\x200\x20AND\x20me.direction\x20=\x20\x27in\x27)',_0xf962('0x5c'));_0x2291ee['field'](_0xf962('0x90'),'Account.key');_0x2291ee[_0xf962('0x45')](_0xf962('0x91'),_0xf962('0x92'));_0x2291ee[_0xf962('0x45')](_0xf962('0x93'),_0xf962('0x83'));_0x2291ee[_0xf962('0x45')](_0xf962('0x94'));_0x2291ee[_0xf962('0x45')]('c.firstName',_0xf962('0x95'));_0x2291ee[_0xf962('0x45')](_0xf962('0x96'),_0xf962('0x97'));_0x2291ee[_0xf962('0x45')](_0xf962('0x98'),_0xf962('0x99'));_0x2291ee[_0xf962('0x45')](_0xf962('0x9a'),_0xf962('0x9b'));_0x2291ee[_0xf962('0x45')](_0xf962('0x9c'),_0xf962('0x9d'));_0x2291ee[_0xf962('0x45')](_0xf962('0x9e'),_0xf962('0x9f'));_0x2291ee[_0xf962('0x45')](_0xf962('0xa0'),'Owner.fullname');_0x2291ee[_0xf962('0x45')]('o.internal',_0xf962('0xa1'));_0x2291ee[_0xf962('0x45')](_0xf962('0xa2'),_0xf962('0x2d'));}if(_0x18176e[_0xf962('0x1e')])_0x2291ee[_0xf962('0x1e')](_0x18176e[_0xf962('0x1e')]);if(_0x18176e[_0xf962('0x1c')])_0x2291ee[_0xf962('0x1c')](_0x18176e['offset']);return db[_0xf962('0x8c')][_0xf962('0x37')](_0x2291ee[_0xf962('0x8d')](),_0x130b12);})[_0xf962('0x23')](function(_0x4cbeb5){if(_0x4cbeb5[_0xf962('0x3d')]>0x0)_0x2ae374[_0xf962('0x42')](_0xf962('0xa3'),_[_0xf962('0x2b')](_0x4cbeb5,'id'));return db[_0xf962('0x8c')][_0xf962('0x37')](_0x2ae374['toString'](),_0x130b12)[_0xf962('0x23')](function(_0x171a6a){var _0x397576=_[_0xf962('0xa4')](_0x171a6a,'FaxInteractionId');var _0x4d942e=[];_0x4cbeb5[_0xf962('0x2f')](function(_0xfc146d){_0x4d942e[_0xf962('0x30')](updateFaxInteraction(_0xfc146d,_0x283a0d,_0x397576));});return BPromise[_0xf962('0xa5')](_0x4d942e);});});})[_0xf962('0x23')](function(_0x23c72e){_0x30f4fe['rows']=_0x23c72e;return _0x30f4fe;})[_0xf962('0x23')](respondWithFilteredResult(_0x372c22,_0x18176e))[_0xf962('0xa6')](handleError(_0x372c22,null));};exports[_0xf962('0xa7')]=function(_0x404b6d,_0x4202b6){var _0x2e51ea={'raw':![],'where':{'id':_0x404b6d[_0xf962('0xa8')]['id']}},_0xd8ed15={};_0xd8ed15[_0xf962('0x35')]=_[_0xf962('0x38')](db[_0xf962('0x32')][_0xf962('0xa9')]);_0xd8ed15[_0xf962('0x37')]=_[_0xf962('0x38')](_0x404b6d[_0xf962('0x37')]);_0xd8ed15[_0xf962('0x39')]=_[_0xf962('0x3a')](_0xd8ed15[_0xf962('0x35')],_0xd8ed15[_0xf962('0x37')]);_0x2e51ea[_0xf962('0x3b')]=_[_0xf962('0x3a')](_0xd8ed15['model'],qs[_0xf962('0x3c')](_0x404b6d['query']['fields']));_0x2e51ea[_0xf962('0x3b')]=_0x2e51ea[_0xf962('0x3b')]['length']?_0x2e51ea['attributes']:_0xd8ed15[_0xf962('0x35')];if(_0x404b6d[_0xf962('0x37')]['includeAll']){_0x2e51ea[_0xf962('0xaa')]=[{'all':!![]}];}_0x2e51ea=_[_0xf962('0x8f')]({},_0x2e51ea,_0x404b6d[_0xf962('0xab')]);return db[_0xf962('0x32')]['find'](_0x2e51ea)[_0xf962('0x23')](handleEntityNotFound(_0x4202b6,null))[_0xf962('0x23')](respondWithResult(_0x4202b6,null))[_0xf962('0xa6')](handleError(_0x4202b6,null));};exports[_0xf962('0xac')]=function(_0x1a97f6,_0x1ea6d8){return db[_0xf962('0x32')][_0xf962('0xac')](_0x1a97f6[_0xf962('0x6d')],{})[_0xf962('0x23')](respondWithResult(_0x1ea6d8,0xc9))['catch'](handleError(_0x1ea6d8,null));};exports['update']=function(_0x513316,_0xe67825){if(_0x513316['body']['id']){delete _0x513316[_0xf962('0x6d')]['id'];}return db[_0xf962('0x32')][_0xf962('0x5b')]({'where':{'id':_0x513316[_0xf962('0xa8')]['id']}})[_0xf962('0x23')](handleEntityNotFound(_0xe67825,null))['then'](saveUpdates(_0x513316[_0xf962('0x6d')],null))[_0xf962('0x23')](respondWithResult(_0xe67825,null))[_0xf962('0xa6')](handleError(_0xe67825,null));};exports[_0xf962('0x24')]=function(_0x228a1b,_0x18b9ef){return db['FaxInteraction'][_0xf962('0x5b')]({'where':{'id':_0x228a1b['params']['id']}})['then'](handleEntityNotFound(_0x18b9ef,null))[_0xf962('0x23')](removeEntity(_0x18b9ef,null))[_0xf962('0xa6')](handleError(_0x18b9ef,null));};exports[_0xf962('0xad')]=function(_0xad5ba,_0x2fe753){return db[_0xf962('0x32')]['describe']()['then'](respondWithResult(_0x2fe753,null))[_0xf962('0xa6')](handleError(_0x2fe753,null));};exports[_0xf962('0xae')]=function(_0x1bce43,_0x3fe03e,_0x37a2c1){return db[_0xf962('0xaf')][_0xf962('0x5b')]({'where':{'id':_0x1bce43['params']['id']}})[_0xf962('0x23')](handleEntityNotFound(_0x3fe03e,null))['then'](function(_0x154434){if(_0x154434){return _0x154434[_0xf962('0xae')](_0x1bce43[_0xf962('0x6d')][_0xf962('0xb0')],_[_0xf962('0xb1')](_0x1bce43[_0xf962('0x6d')],['ids','id'])||{});}})['then'](respondWithResult(_0x3fe03e,null))[_0xf962('0xa6')](handleError(_0x3fe03e,null));};exports[_0xf962('0xb2')]=function(_0x1d9f4d,_0x371f4f,_0x556f0c){var _0x374e68={'raw':![],'where':{}};var _0xef8922={};var _0x2ae8d8={'count':0x0,'rows':[]};return db[_0xf962('0x32')][_0xf962('0xb3')]({'where':{'id':_0x1d9f4d[_0xf962('0xa8')]['id']}})[_0xf962('0x23')](handleEntityNotFound(_0x371f4f,null))['then'](function(_0x3bc7ea){if(_0x3bc7ea){_0xef8922['model']=_[_0xf962('0x38')](db['FaxMessage'][_0xf962('0xa9')]);_0xef8922[_0xf962('0x37')]=_['keys'](_0x1d9f4d[_0xf962('0x37')]);_0xef8922[_0xf962('0x39')]=_[_0xf962('0x3a')](_0xef8922[_0xf962('0x35')],_0xef8922['query']);_0x374e68['attributes']=_[_0xf962('0x3a')](_0xef8922[_0xf962('0x35')],qs[_0xf962('0x3c')](_0x1d9f4d[_0xf962('0x37')][_0xf962('0x3c')]));_0x374e68['attributes']=_0x374e68[_0xf962('0x3b')][_0xf962('0x3d')]?_0x374e68[_0xf962('0x3b')]:_0xef8922['model'];if(!_0x1d9f4d[_0xf962('0x37')]['hasOwnProperty']('nolimit')){_0x374e68['limit']=qs['limit'](_0x1d9f4d['query']['limit']);_0x374e68['offset']=qs[_0xf962('0x1c')](_0x1d9f4d[_0xf962('0x37')]['offset']);}_0x374e68[_0xf962('0x40')]=qs[_0xf962('0x41')](_0x1d9f4d[_0xf962('0x37')][_0xf962('0x41')]);_0x374e68[_0xf962('0x42')]=qs[_0xf962('0x39')](_['pick'](_0x1d9f4d[_0xf962('0x37')],_0xef8922[_0xf962('0x39')]));_0x374e68[_0xf962('0x42')]['FaxInteractionId']=_0x3bc7ea['id'];if(_0x1d9f4d['query'][_0xf962('0xb4')]){_0x374e68[_0xf962('0x42')]=_[_0xf962('0x8f')](_0x374e68[_0xf962('0x42')],{'$or':_[_0xf962('0x2b')](_0x374e68[_0xf962('0x3b')],function(_0xfcfc8){var _0x3e2a40={};_0x3e2a40[_0xfcfc8]={'$like':'%'+_0x1d9f4d[_0xf962('0x37')]['filter']+'%'};return _0x3e2a40;})});}if(_0x1d9f4d['query']['$gte']){var _0x122d06=_0x1d9f4d['query'][_0xf962('0x73')][_0xf962('0x2e')](',');var _0x413352={};_0x413352[_0x122d06[0x0]]={'$gte':moment(_0x122d06[0x1])[_0xf962('0xb5')](_0xf962('0xb6'))};_0x374e68[_0xf962('0x42')]=_['merge'](_0x374e68[_0xf962('0x42')],_0x413352);}_0x374e68=_[_0xf962('0x8f')]({},_0x374e68,_0x1d9f4d[_0xf962('0xab')]);return db['FaxMessage']['count']({'where':_0x374e68[_0xf962('0x42')]})['then'](function(_0x379ef3){_0x2ae8d8[_0xf962('0x1f')]=_0x379ef3;if(_0x1d9f4d[_0xf962('0x37')]['includeAll']){_0x374e68[_0xf962('0xaa')]=[{'all':!![]}];}return db[_0xf962('0xaf')]['findAll'](_0x374e68);})['then'](function(_0x5d3fcf){_0x2ae8d8[_0xf962('0xb7')]=_0x5d3fcf;return _0x2ae8d8;});}})['then'](respondWithFilteredResult(_0x371f4f,_0x374e68))[_0xf962('0xa6')](handleError(_0x371f4f,null));};exports['addTags']=function(_0x14be3e,_0x4d221b,_0x5ee300){return db[_0xf962('0x32')][_0xf962('0x5b')]({'where':{'id':_0x14be3e['params']['id']}})['then'](handleEntityNotFound(_0x4d221b,null))[_0xf962('0x23')](function(_0x3b0a31){if(_0x3b0a31){return _0x3b0a31['setTags'](_0x14be3e[_0xf962('0x6d')][_0xf962('0xb0')],_['omit'](_0x14be3e['body'],[_0xf962('0xb0'),'id'])||{})['spread'](function(){return db[_0xf962('0xb8')][_0xf962('0xb9')]({'attributes':['id',_0xf962('0x36'),_0xf962('0x46')],'where':{'id':_0x14be3e[_0xf962('0x6d')]['ids']}});})[_0xf962('0x23')](function(_0x5598c5){socket[_0xf962('0xba')]('faxInteractionTags:save',{'id':Number(_0x14be3e['params']['id']),'tags':_0x5598c5||[]});return{'id':Number(_0x14be3e[_0xf962('0xa8')]['id']),'tags':_0x5598c5||[]};});}})[_0xf962('0x23')](respondWithResult(_0x4d221b,null))[_0xf962('0xa6')](handleError(_0x4d221b,null));};exports['removeTags']=function(_0x1f2ed9,_0x117fdc,_0x4e8640){return db[_0xf962('0x32')][_0xf962('0x5b')]({'where':{'id':_0x1f2ed9['params']['id']}})['then'](handleEntityNotFound(_0x117fdc,null))[_0xf962('0x23')](function(_0x5d3fd4){if(_0x5d3fd4){return _0x5d3fd4[_0xf962('0xbb')](_0x1f2ed9[_0xf962('0x37')][_0xf962('0xb0')]);}})[_0xf962('0x23')](respondWithStatusCode(_0x117fdc,null))[_0xf962('0xa6')](handleError(_0x117fdc,null));};exports['download']=function(_0x12fd63,_0x3bd340){var _0x2fb7ce=moment()[_0xf962('0xbc')]()[_0xf962('0x8d')]();var _0x2b942b=path[_0xf962('0xbd')](config[_0xf962('0xbe')],_0xf962('0xbf'),_0xf962('0xc0'),_0xf962('0xc1'));var _0x44a52a=path['join'](config['root'],_0xf962('0xbf'),_0xf962('0xc0'),'attachments');var _0x1795f7=path[_0xf962('0xbd')](_0x2b942b,_0x2fb7ce);var _0x3f3c67=util['format'](_0xf962('0xc2'),_0x12fd63[_0xf962('0xa8')]['id'],_0x2fb7ce);var _0x59ce8b=path['join'](_0x2b942b,_0x3f3c67);var _0x5b4181=[];_0x5b4181[_0xf962('0x30')]({'model':db['Attachment'],'as':_0xf962('0xc3'),'raw':!![]});var _0x4bac66=[{'model':db['FaxMessage'],'as':_0xf962('0xc4'),'attributes':['id','body','createdAt'],'include':_0x5b4181}];return db[_0xf962('0x32')][_0xf962('0x5b')]({'where':{'id':_0x12fd63[_0xf962('0xa8')]['id']},'include':_0x4bac66})[_0xf962('0x23')](handleEntityNotFound(_0x3bd340,null))[_0xf962('0x23')](function(_0x144d4d){if(_0x144d4d&&_0x144d4d['Messages']){var _0x5a4e0a=_0x144d4d[_0xf962('0xc5')]({'plain':!![]});fs[_0xf962('0xc6')](_0x1795f7);for(var _0x421dfc=0x0;_0x421dfc<_0x5a4e0a[_0xf962('0xc4')][_0xf962('0x3d')];_0x421dfc++){var _0x27be08=_0x5a4e0a['Messages'][_0x421dfc][_0xf962('0xc3')];if(_0x27be08){var _0x2657ff=path[_0xf962('0xbd')](_0x44a52a,_0x27be08[_0xf962('0xc7')]);if(fs[_0xf962('0xc8')](_0x2657ff)){fs[_0xf962('0xc9')](_0x2657ff)['pipe'](fs[_0xf962('0xca')](path[_0xf962('0xbd')](_0x1795f7,_0x27be08[_0xf962('0xc7')])));}}}return BPromise[_0xf962('0xcb')]()[_0xf962('0x23')](function(){return new BPromise(function(_0x37b855,_0x3a2802){zipdir(_0x1795f7,{'saveTo':_0x59ce8b},function(_0x3e077d,_0xbcce93){if(_0x3e077d)return _0x3a2802(_0x3e077d);return _0x37b855(_0xbcce93);});})['then'](function(){return new BPromise(function(_0x323358,_0x5a9d7f){rimraf(_0x1795f7,function(_0xd4482e){if(_0xd4482e)_0x5a9d7f(_0xd4482e);return _0x323358();});});})[_0xf962('0x23')](function(){return _0x3bd340[_0xf962('0xcc')](_0x59ce8b,_0x3f3c67,function(_0x196442){if(_0x196442){console[_0xf962('0xcd')]('err',_0x196442);}else{fs[_0xf962('0xce')](_0x59ce8b);}});});});}else{return _0x3bd340[_0xf962('0x26')](0xc8);}})[_0xf962('0xa6')](handleError(_0x3bd340,null));};
\ No newline at end of file