Built motion from commit (unavailable).|2.5.30
[motion2.git] / server / api / faxInteraction / faxInteraction.controller.js
index bf3f088..6097186 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x86f8=['include','create','describe','addMessage','FaxMessage','ids','omit','getMessages','params','hasOwnProperty','$gte','YYYY-MM-DD\x20HH:mm:ss','options','addTags','setTags','spread','findAll','emit','faxInteractionTags:save','removeTags','download','unix','files','tmp','server','attachments','transcript-%d-%s.zip','join','Attachment','Messages','get','mkdirSync','basename','existsSync','createReadStream','pipe','createWriteStream','log','err','html-pdf','eml-format','rimraf','zip-dir','request-promise','moment','bluebird','util','path','sox','lodash','squel','crypto','jsforce','desk.js','to-csv','querystring','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','localhost','./faxInteraction.socket','sendStatus','status','json','count','offset','set','Content-Range','apply','reject','update','destroy','then','error','stack','name','send','Users','map','fullname','TagIds','Tags','forEach','catch','index','FaxInteraction','rawAttributes','fieldName','model','keys','query','filters','intersection','attributes','fields','length','nolimit','limit','order','sort','where','pick','field','color','from','tools_tags','select','u.fullname','ui.FaxInteractionId','left_join','users','u.id\x20=\x20ui.UserId','fax_interactions','cm_contacts','c.id\x20=\x20i.ContactId\x20AND\x20c.deletedAt\x20IS\x20NULL','o.id\x20=\x20i.UserId','a.id\x20=\x20i.FaxAccountId','me.FaxInteractionId\x20=\x20i.id','fax_interaction_has_tags','expr','search','sqlOperator','conditions','unreadMessages','having','`\x20=\x200','`\x20>\x200','Contact','operator','value','split','MATCH\x20(c.firstName,\x20c.lastName,\x20c.phone,\x20c.mobile,\x20c.fax,\x20c.email)\x20AGAINST\x20(?\x20IN\x20BOOLEAN\x20MODE)','find','ContactId','text','start','end','Tag','CONCAT(\x27,\x27,\x20`TagIds`,\x20\x27,\x27)\x20LIKE\x20?','union','User','CONCAT_WS(\x27\x20\x27,\x20o.name,\x20o.fullname)\x20LIKE\x20?','UserId','buildExpression','type','body','compact','isEmpty','FaxAccountId','i.FaxAccountId\x20IN\x20?','concat','createdAt','parse','i.createdAt\x20BETWEEN\x20?\x20AND\x20?','\x20IS\x20NULL','\x20=\x20?','read','`unreadMessages`\x20=\x200','`unreadMessages`\x20>\x200','tag','isArray','filter','replace','i.id\x20LIKE\x20?','i.fax\x20LIKE\x20?','CONCAT(c.firstName,\x20\x27\x20\x27,\x20c.lastName)\x20LIKE\x20?','group','i.id','Sequelize','QueryTypes','SELECT','clone','DESC','t.id\x20IN\x20?','resolve','i.FaxAccountId\x20IS\x20NOT\x20NULL','role','agent','user','getFaxAccounts','i.FaxAccountId\x20IS\x20NULL','sequelize','toString','keyBy','merge','SUM(me.read\x20=\x200\x20AND\x20me.direction\x20=\x20\x27in\x27)','a.key','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','c.firstName','c.lastName','c.email','Contact.email','c.phone','Contact.phone','c.mobile','c.fax','o.fullname','Owner.fullname','Owner.internal','GROUP_CONCAT(DISTINCT\x20t.id)','ui.FaxInteractionId\x20IN\x20?','FaxInteractionId','push','all','show','includeAll'];(function(_0x3a2d39,_0x38be15){var _0x40b738=function(_0x56716c){while(--_0x56716c){_0x3a2d39['push'](_0x3a2d39['shift']());}};_0x40b738(++_0x38be15);}(_0x86f8,0x1d5));var _0x886f=function(_0x342700,_0x569f75){_0x342700=_0x342700-0x0;var _0x53406f=_0x86f8[_0x342700];return _0x53406f;};'use strict';var pdf=require(_0x886f('0x0'));var emlformat=require(_0x886f('0x1'));var rimraf=require(_0x886f('0x2'));var zipdir=require(_0x886f('0x3'));var jsonpatch=require('fast-json-patch');var rp=require(_0x886f('0x4'));var moment=require(_0x886f('0x5'));var BPromise=require(_0x886f('0x6'));var Mustache=require('mustache');var util=require(_0x886f('0x7'));var path=require(_0x886f('0x8'));var sox=require(_0x886f('0x9'));var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var _=require(_0x886f('0xa'));var squel=require(_0x886f('0xb'));var crypto=require(_0x886f('0xc'));var jsforce=require(_0x886f('0xd'));var deskjs=require(_0x886f('0xe'));var toCsv=require(_0x886f('0xf'));var querystring=require(_0x886f('0x10'));var Papa=require('papaparse');var Redis=require('ioredis');var authService=require(_0x886f('0x11'));var qs=require(_0x886f('0x12'));var as=require(_0x886f('0x13'));var hardwareService=require(_0x886f('0x14'));var logger=require(_0x886f('0x15'))(_0x886f('0x16'));var utils=require(_0x886f('0x17'));var config=require(_0x886f('0x18'));var licenseUtil=require(_0x886f('0x19'));var db=require(_0x886f('0x1a'))['db'];config[_0x886f('0x1b')]=_[_0x886f('0x1c')](config[_0x886f('0x1b')],{'host':_0x886f('0x1d'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require(_0x886f('0x1e'))['register'](socket);function respondWithStatusCode(_0x4cc033,_0x2d4e22){_0x2d4e22=_0x2d4e22||0xcc;return function(_0x2b9c9e){if(_0x2b9c9e){return _0x4cc033[_0x886f('0x1f')](_0x2d4e22);}return _0x4cc033[_0x886f('0x20')](_0x2d4e22)['end']();};}function respondWithResult(_0x315eda,_0x2e18f3){_0x2e18f3=_0x2e18f3||0xc8;return function(_0x336f54){if(_0x336f54){return _0x315eda[_0x886f('0x20')](_0x2e18f3)[_0x886f('0x21')](_0x336f54);}};}function respondWithFilteredResult(_0xfb8210,_0x2dd771){return function(_0xeab12a){if(_0xeab12a){var _0x58d238=_0xeab12a[_0x886f('0x22')],_0x259374=_0x2dd771[_0x886f('0x23')],_0x1be967=_0x2dd771['offset']+_0x2dd771['limit'],_0x39bffd;if(_0x1be967>=_0x58d238){_0x1be967=_0x58d238;_0x39bffd=0xc8;}else{_0x39bffd=0xce;}_0xfb8210[_0x886f('0x20')](_0x39bffd);return _0xfb8210[_0x886f('0x24')](_0x886f('0x25'),_0x259374+'-'+_0x1be967+'/'+_0x58d238)[_0x886f('0x21')](_0xeab12a);}return null;};}function patchUpdates(_0xd142f9){return function(_0x554e6d){try{jsonpatch[_0x886f('0x26')](_0x554e6d,_0xd142f9,!![]);}catch(_0x3d8b7a){return BPromise[_0x886f('0x27')](_0x3d8b7a);}return _0x554e6d['save']();};}function saveUpdates(_0x1f8306,_0x301a3e){return function(_0x369981){if(_0x369981){return _0x369981[_0x886f('0x28')](_0x1f8306)['then'](function(_0x1faeba){return _0x1faeba;});}return null;};}function removeEntity(_0x3c05f1,_0x5a0a73){return function(_0x463efe){if(_0x463efe){return _0x463efe[_0x886f('0x29')]()[_0x886f('0x2a')](function(){_0x3c05f1[_0x886f('0x20')](0xcc)['end']();});}};}function handleEntityNotFound(_0xab5777,_0xf5b5dd){return function(_0x4eae76){if(!_0x4eae76){_0xab5777['sendStatus'](0x194);}return _0x4eae76;};}function handleError(_0x48de59,_0xb091c){_0xb091c=_0xb091c||0x1f4;return function(_0x2f1fc7){logger[_0x886f('0x2b')](_0x2f1fc7[_0x886f('0x2c')]);if(_0x2f1fc7[_0x886f('0x2d')]){delete _0x2f1fc7['name'];}_0x48de59[_0x886f('0x20')](_0xb091c)[_0x886f('0x2e')](_0x2f1fc7);};}function getInteractionUsers(_0x393630,_0x520d75){return new BPromise(function(_0x521005,_0x22dc16){try{if(_0x520d75[_0x393630['id']]){_0x393630[_0x886f('0x2f')]=_[_0x886f('0x30')](_0x520d75[_0x393630['id']],function(_0x43916b){return{'id':_0x43916b['id'],'fullname':_0x43916b[_0x886f('0x31')]};});}}catch(_0x2d1dcd){_0x22dc16(_0x2d1dcd);}_0x521005(_0x393630);});}function getInteractionTags(_0x198796,_0x589ce2){return new BPromise(function(_0x1f2e55,_0x5b2ba4){try{if(_0x198796[_0x886f('0x32')]){_0x198796[_0x886f('0x33')]=[];_0x198796['TagIds']['split'](',')[_0x886f('0x34')](function(_0x3f9a6e){_0x198796['Tags']['push'](_0x589ce2[_0x3f9a6e]);});}delete _0x198796[_0x886f('0x32')];}catch(_0x9f2947){_0x5b2ba4(_0x9f2947);}_0x1f2e55(_0x198796);});}function updateFaxInteraction(_0x4d9ca2,_0x5000f2,_0x527332){return new BPromise(function(_0x41c08d,_0x595547){return getInteractionUsers(_0x4d9ca2,_0x527332)[_0x886f('0x2a')](function(_0x5f0c4a){return getInteractionTags(_0x5f0c4a,_0x5000f2);})['then'](function(_0x553bde){_0x41c08d(_0x553bde);})[_0x886f('0x35')](function(_0x5e5466){_0x595547(_0x5e5466);});});}exports[_0x886f('0x36')]=function(_0x4596ed,_0x4ac5c7){var _0x3bde54={},_0x19ce00={},_0x5a1ed7={'count':0x0,'rows':[]};var _0x5ee078=_[_0x886f('0x30')](db[_0x886f('0x37')][_0x886f('0x38')],function(_0x1a7e72){return{'name':_0x1a7e72[_0x886f('0x39')],'type':_0x1a7e72['type']['key']};});_0x19ce00[_0x886f('0x3a')]=_[_0x886f('0x30')](_0x5ee078,_0x886f('0x2d'));_0x19ce00['query']=_[_0x886f('0x3b')](_0x4596ed[_0x886f('0x3c')]);_0x19ce00[_0x886f('0x3d')]=_[_0x886f('0x3e')](_0x19ce00[_0x886f('0x3a')],_0x19ce00[_0x886f('0x3c')]);_0x3bde54[_0x886f('0x3f')]=_[_0x886f('0x3e')](_0x19ce00['model'],qs[_0x886f('0x40')](_0x4596ed[_0x886f('0x3c')][_0x886f('0x40')]));_0x3bde54[_0x886f('0x3f')]=_0x3bde54['attributes'][_0x886f('0x41')]?_0x3bde54[_0x886f('0x3f')]:_0x19ce00[_0x886f('0x3a')];if(!_0x4596ed[_0x886f('0x3c')]['hasOwnProperty'](_0x886f('0x42'))){_0x3bde54[_0x886f('0x43')]=qs[_0x886f('0x43')](_0x4596ed[_0x886f('0x3c')][_0x886f('0x43')]);_0x3bde54[_0x886f('0x23')]=qs[_0x886f('0x23')](_0x4596ed[_0x886f('0x3c')][_0x886f('0x23')]);}_0x3bde54[_0x886f('0x44')]=qs[_0x886f('0x45')](_0x4596ed[_0x886f('0x3c')][_0x886f('0x45')]);_0x3bde54[_0x886f('0x46')]=qs[_0x886f('0x3d')](_[_0x886f('0x47')](_0x4596ed[_0x886f('0x3c')],_0x19ce00[_0x886f('0x3d')]),_0x5ee078);var _0x4ecedc=[];var _0x292d85=squel['select']()['field']('id')[_0x886f('0x48')](_0x886f('0x2d'))[_0x886f('0x48')](_0x886f('0x49'))[_0x886f('0x4a')](_0x886f('0x4b'));var _0x53a1ef=squel[_0x886f('0x4c')]()['field']('u.id')[_0x886f('0x48')](_0x886f('0x4d'))[_0x886f('0x48')](_0x886f('0x4e'))['from']('user_has_fax_interactions','ui')[_0x886f('0x4f')](_0x886f('0x50'),'u',_0x886f('0x51'));var _0x330fd7=squel['select']()[_0x886f('0x4a')](_0x886f('0x52'),'i')[_0x886f('0x4f')](_0x886f('0x53'),'c',_0x886f('0x54'))[_0x886f('0x4f')]('users','o',_0x886f('0x55'))[_0x886f('0x4f')]('fax_accounts','a',_0x886f('0x56'))['left_join']('fax_messages','me',_0x886f('0x57'))['left_join'](_0x886f('0x58'),'it','it.FaxInteractionId\x20=\x20i.id')[_0x886f('0x4f')](_0x886f('0x4b'),'t','t.id\x20=\x20it.TagId');var _0x23d40b=squel[_0x886f('0x59')]();var _0xd76372=[];var _0x5ae0f5=squel[_0x886f('0x59')]();var _0x85800e;if(_0x4596ed[_0x886f('0x3c')][_0x886f('0x5a')]){_0x85800e=as['parseSearch'](_0x4596ed[_0x886f('0x3c')]['search']);var _0xc9e7b5=_0x85800e[_0x886f('0x5b')];for(var _0x56f2d4=0x0;_0x56f2d4<_0x85800e[_0x886f('0x5c')][_0x886f('0x41')];_0x56f2d4++){var _0x32f43f=_0x85800e[_0x886f('0x5c')][_0x56f2d4];var _0x2d271e='i';var _0x7ece87=_['find'](_0x5ee078,['name',_0x32f43f[_0x886f('0x48')]]);if(!_0x7ece87){switch(_0x32f43f[_0x886f('0x48')]){case _0x886f('0x5d'):if(_0x32f43f['value']==0x1){_0x330fd7[_0x886f('0x5e')]('`'+_0x32f43f['field']+_0x886f('0x5f'));}else{_0x330fd7[_0x886f('0x5e')]('`'+_0x32f43f[_0x886f('0x48')]+_0x886f('0x60'));}break;case _0x886f('0x61'):if(_0x32f43f[_0x886f('0x62')]==='$substring'){if(_0x32f43f[_0x886f('0x63')][_0x886f('0x64')]('\x20')[_0x886f('0x41')]>0x1){_0x23d40b[_0xc9e7b5](_0x886f('0x65'),qs['getFullTextValue'](_0x32f43f[_0x886f('0x63')]),null);}else{var _0x2c0fd3='%'+_0x32f43f[_0x886f('0x63')]+'%';_0x23d40b[_0xc9e7b5]('c.firstName\x20LIKE\x20?\x20OR\x20c.lastName\x20LIKE\x20?\x20OR\x20c.email\x20LIKE\x20?',_0x2c0fd3,_0x2c0fd3,_0x2c0fd3);}}else{_0x7ece87=_[_0x886f('0x66')](_0x5ee078,[_0x886f('0x2d'),_0x886f('0x67')]);_0x32f43f[_0x886f('0x48')]=_0x886f('0x67');_0x9c6f11=as['buildExpression'](_0x2d271e,_0x7ece87['type'],_0x32f43f);_0x23d40b[_0xc9e7b5](_0x9c6f11[_0x886f('0x68')],_0x9c6f11[_0x886f('0x63')][_0x886f('0x69')],_0x9c6f11['value'][_0x886f('0x6a')]);}break;case _0x886f('0x6b'):var _0x343f3a=_0x32f43f[_0x886f('0x63')][_0x886f('0x64')](',')['map'](function(_0x2dea33){return Number(_0x2dea33);});_0x343f3a[_0x886f('0x34')](function(_0x1d37db){_0x5ae0f5['or'](_0x886f('0x6c'),'%,'+_0x1d37db+',%');});_0xd76372=_[_0x886f('0x6d')](_0xd76372,_0x343f3a);break;case _0x886f('0x6e'):if(_0x32f43f[_0x886f('0x62')]==='$substring'){_0x23d40b[_0xc9e7b5](_0x886f('0x6f'),'%'+_0x32f43f[_0x886f('0x63')]+'%',null);}else{_0x7ece87=_[_0x886f('0x66')](_0x5ee078,['name',_0x886f('0x70')]);_0x32f43f['field']=_0x886f('0x70');_0x9c6f11=as[_0x886f('0x71')](_0x2d271e,_0x7ece87[_0x886f('0x72')],_0x32f43f);_0x23d40b[_0xc9e7b5](_0x9c6f11[_0x886f('0x68')],_0x9c6f11[_0x886f('0x63')][_0x886f('0x69')],_0x9c6f11[_0x886f('0x63')][_0x886f('0x6a')]);}break;case _0x886f('0x73'):_0x9c6f11=as[_0x886f('0x71')]('me',null,_0x32f43f);_0x23d40b[_0xc9e7b5](_0x9c6f11[_0x886f('0x68')],_0x9c6f11[_0x886f('0x63')]['start'],_0x9c6f11[_0x886f('0x63')]['end']);break;}}else{var _0x9c6f11=as['buildExpression'](_0x2d271e,_0x7ece87[_0x886f('0x72')],_0x32f43f);_0x23d40b[_0xc9e7b5](_0x9c6f11['text'],_0x9c6f11[_0x886f('0x63')][_0x886f('0x69')],_0x9c6f11[_0x886f('0x63')][_0x886f('0x6a')]);}}}else{var _0x458707=_(_0x4596ed[_0x886f('0x3c')])['keys']()['map'](function(_0xe30659){return _['some'](_0x5ee078,[_0x886f('0x2d'),_0xe30659])?_0xe30659:undefined;})[_0x886f('0x74')]()['value']();if(!_[_0x886f('0x75')](_0x458707)){_0x458707[_0x886f('0x34')](function(_0x23b43a){if(_0x23b43a===_0x886f('0x76')){_0x330fd7[_0x886f('0x46')](_0x886f('0x77'),[][_0x886f('0x78')](_0x4596ed['query'][_0x23b43a]));}else if(_0x23b43a===_0x886f('0x79')){var _0x3bda39=JSON[_0x886f('0x7a')](_0x4596ed[_0x886f('0x3c')][_0x23b43a])['$gte'];var _0x542b3e=JSON[_0x886f('0x7a')](_0x4596ed[_0x886f('0x3c')][_0x23b43a])['$lte'];_0x330fd7[_0x886f('0x46')](_0x886f('0x7b'),_0x3bda39,_0x542b3e);}else{if(_0x4596ed[_0x886f('0x3c')][_0x23b43a]==='null'){_0x330fd7[_0x886f('0x46')]('i.'+_0x23b43a+_0x886f('0x7c'));}else{_0x330fd7[_0x886f('0x46')]('i.'+_0x23b43a+_0x886f('0x7d'),_0x4596ed[_0x886f('0x3c')][_0x23b43a]);}}});}if(_0x4596ed['query'][_0x886f('0x7e')]){if(_0x4596ed[_0x886f('0x3c')][_0x886f('0x7e')]==0x1){_0x330fd7[_0x886f('0x5e')](_0x886f('0x7f'));}else{_0x330fd7[_0x886f('0x5e')](_0x886f('0x80'));}}if(_0x4596ed[_0x886f('0x3c')][_0x886f('0x81')]){_0xd76372=_[_0x886f('0x82')](_0x4596ed['query'][_0x886f('0x81')])?_0x4596ed['query']['tag']:new Array(_0x4596ed[_0x886f('0x3c')][_0x886f('0x81')]);_0xd76372['forEach'](function(_0xc4ace5){_0x5ae0f5['or']('CONCAT(\x27,\x27,\x20`TagIds`,\x20\x27,\x27)\x20LIKE\x20?','%,'+_0xc4ace5+',%');});}if(_0x4596ed[_0x886f('0x3c')][_0x886f('0x83')]){var _0x2f04e2=_0x4596ed[_0x886f('0x3c')][_0x886f('0x83')][_0x886f('0x84')]('\x5c','\x5c\x5c')[_0x886f('0x84')](/'/g,'\x27\x27');if(qs['isNumeric'](_0x2f04e2)){_0x23d40b['or'](_0x886f('0x85'),_0x2f04e2+'%')['or'](_0x886f('0x86'),_0x2f04e2+'%');}_0x23d40b['or'](_0x886f('0x87'),_0x2f04e2+'%');}}_0x330fd7[_0x886f('0x46')](_0x23d40b);_0x330fd7[_0x886f('0x88')](_0x886f('0x89'));var _0x2b8911={'type':db[_0x886f('0x8a')][_0x886f('0x8b')][_0x886f('0x8c')],'raw':!![]};var _0x1f0c8c=_0x330fd7[_0x886f('0x8d')]();_0x1f0c8c[_0x886f('0x48')](_0x886f('0x89'));_0x1f0c8c[_0x886f('0x48')]('SUM(me.read\x20=\x200\x20AND\x20me.direction\x20=\x20\x27in\x27)',_0x886f('0x5d'));if(_0x3bde54[_0x886f('0x44')]){_0x3bde54['order']['forEach'](function(_0x501215){var _0x3b69f4=_0x501215[0x0]==='contactName'?_0x501215[0x0]:'i.'+_0x501215[0x0];_0x330fd7[_0x886f('0x44')](_0x3b69f4,_0x501215[0x1]===_0x886f('0x8e')?![]:!![]);});}if(!_[_0x886f('0x75')](_0xd76372)){_0x330fd7[_0x886f('0x5e')](_0x5ae0f5);_0x1f0c8c['where'](_0x886f('0x8f'),_0xd76372);}BPromise[_0x886f('0x90')]()['then'](function(){if(!_0x85800e){if(_0x4596ed[_0x886f('0x3c')]['FaxAccountId'])return;_0x1f0c8c['where'](_0x886f('0x91'));_0x330fd7[_0x886f('0x46')]('i.FaxAccountId\x20IS\x20NOT\x20NULL');return;}if(_0x4596ed['user'][_0x886f('0x92')]!==_0x886f('0x93'))return;return _0x4596ed[_0x886f('0x94')][_0x886f('0x95')]({'attributes':['id'],'raw':!![]})[_0x886f('0x2a')](function(_0x3a99d1){if(_[_0x886f('0x75')](_0x3a99d1)){_0x1f0c8c[_0x886f('0x46')]('i.FaxAccountId\x20IS\x20NULL');_0x330fd7[_0x886f('0x46')](_0x886f('0x96'));}else{_0x1f0c8c[_0x886f('0x46')]('i.FaxAccountId\x20IN\x20?',_[_0x886f('0x30')](_0x3a99d1,'id'));_0x330fd7[_0x886f('0x46')](_0x886f('0x77'),_[_0x886f('0x30')](_0x3a99d1,'id'));}});})['then'](function(){if(_0x4596ed['user'][_0x886f('0x92')]===_0x886f('0x93')&&!_0x85800e&&!_0x4596ed[_0x886f('0x3c')][_0x886f('0x76')])return[];return db[_0x886f('0x97')]['query'](_0x1f0c8c[_0x886f('0x98')](),_0x2b8911);})[_0x886f('0x2a')](function(_0x15566a){_0x5a1ed7[_0x886f('0x22')]=_0x15566a[_0x886f('0x41')];if(_0x5a1ed7[_0x886f('0x22')]===0x0)return[];return db[_0x886f('0x97')]['query'](_0x292d85[_0x886f('0x98')](),_0x2b8911)['then'](function(_0x46c926){_0x4ecedc=_[_0x886f('0x99')](_0x46c926,'id');_0x2b8911=_[_0x886f('0x9a')](_0x2b8911,{'model':db[_0x886f('0x37')],'mapToModel':!![],'raw':!![],'nest':!![]});if(_0x4596ed[_0x886f('0x3c')][_0x886f('0x40')]){_0x3bde54[_0x886f('0x3f')]['forEach'](function(_0x269f73){_0x330fd7[_0x886f('0x48')]('i.'+_0x269f73);});}else{_0x330fd7[_0x886f('0x48')](_0x886f('0x9b'),_0x886f('0x5d'));_0x330fd7[_0x886f('0x48')](_0x886f('0x9c'),'Account.key');_0x330fd7[_0x886f('0x48')]('a.mandatoryDisposition','Account.mandatoryDisposition');_0x330fd7[_0x886f('0x48')](_0x886f('0x9d'),'contactName');_0x330fd7['field']('i.*');_0x330fd7[_0x886f('0x48')](_0x886f('0x9e'),'Contact.firstName');_0x330fd7[_0x886f('0x48')](_0x886f('0x9f'),'Contact.lastName');_0x330fd7[_0x886f('0x48')](_0x886f('0xa0'),_0x886f('0xa1'));_0x330fd7[_0x886f('0x48')](_0x886f('0xa2'),_0x886f('0xa3'));_0x330fd7[_0x886f('0x48')](_0x886f('0xa4'),'Contact.mobile');_0x330fd7['field'](_0x886f('0xa5'),'Contact.fax');_0x330fd7['field'](_0x886f('0xa6'),_0x886f('0xa7'));_0x330fd7[_0x886f('0x48')]('o.internal',_0x886f('0xa8'));_0x330fd7['field'](_0x886f('0xa9'),_0x886f('0x32'));}if(_0x3bde54[_0x886f('0x43')])_0x330fd7[_0x886f('0x43')](_0x3bde54[_0x886f('0x43')]);if(_0x3bde54[_0x886f('0x23')])_0x330fd7[_0x886f('0x23')](_0x3bde54['offset']);return db['sequelize'][_0x886f('0x3c')](_0x330fd7[_0x886f('0x98')](),_0x2b8911);})[_0x886f('0x2a')](function(_0x49b25b){_0x53a1ef['where'](_0x886f('0xaa'),_['map'](_0x49b25b,'id'));return db['sequelize'][_0x886f('0x3c')](_0x53a1ef['toString'](),_0x2b8911)[_0x886f('0x2a')](function(_0x26265d){var _0x57a11e=_['groupBy'](_0x26265d,_0x886f('0xab'));var _0x5e650b=[];_0x49b25b['forEach'](function(_0xed7048){_0x5e650b[_0x886f('0xac')](updateFaxInteraction(_0xed7048,_0x4ecedc,_0x57a11e));});return BPromise[_0x886f('0xad')](_0x5e650b);});});})[_0x886f('0x2a')](function(_0xcd7adc){_0x5a1ed7['rows']=_0xcd7adc;return _0x5a1ed7;})['then'](respondWithFilteredResult(_0x4ac5c7,_0x3bde54))[_0x886f('0x35')](handleError(_0x4ac5c7,null));};exports[_0x886f('0xae')]=function(_0x52d0fb,_0x402a90){var _0xd18c5f={'raw':![],'where':{'id':_0x52d0fb['params']['id']}},_0x11a822={};_0x11a822[_0x886f('0x3a')]=_[_0x886f('0x3b')](db[_0x886f('0x37')][_0x886f('0x38')]);_0x11a822[_0x886f('0x3c')]=_[_0x886f('0x3b')](_0x52d0fb[_0x886f('0x3c')]);_0x11a822['filters']=_[_0x886f('0x3e')](_0x11a822[_0x886f('0x3a')],_0x11a822[_0x886f('0x3c')]);_0xd18c5f[_0x886f('0x3f')]=_['intersection'](_0x11a822[_0x886f('0x3a')],qs['fields'](_0x52d0fb[_0x886f('0x3c')][_0x886f('0x40')]));_0xd18c5f[_0x886f('0x3f')]=_0xd18c5f[_0x886f('0x3f')][_0x886f('0x41')]?_0xd18c5f[_0x886f('0x3f')]:_0x11a822[_0x886f('0x3a')];if(_0x52d0fb[_0x886f('0x3c')][_0x886f('0xaf')]){_0xd18c5f[_0x886f('0xb0')]=[{'all':!![]}];}_0xd18c5f=_[_0x886f('0x9a')]({},_0xd18c5f,_0x52d0fb['options']);return db['FaxInteraction'][_0x886f('0x66')](_0xd18c5f)[_0x886f('0x2a')](handleEntityNotFound(_0x402a90,null))[_0x886f('0x2a')](respondWithResult(_0x402a90,null))['catch'](handleError(_0x402a90,null));};exports[_0x886f('0xb1')]=function(_0x5b295a,_0x208596){return db[_0x886f('0x37')][_0x886f('0xb1')](_0x5b295a[_0x886f('0x73')],{})[_0x886f('0x2a')](respondWithResult(_0x208596,0xc9))[_0x886f('0x35')](handleError(_0x208596,null));};exports[_0x886f('0x28')]=function(_0x28922e,_0x847bde){if(_0x28922e[_0x886f('0x73')]['id']){delete _0x28922e[_0x886f('0x73')]['id'];}return db[_0x886f('0x37')]['find']({'where':{'id':_0x28922e['params']['id']}})[_0x886f('0x2a')](handleEntityNotFound(_0x847bde,null))['then'](saveUpdates(_0x28922e[_0x886f('0x73')],null))['then'](respondWithResult(_0x847bde,null))[_0x886f('0x35')](handleError(_0x847bde,null));};exports['destroy']=function(_0x3b6ae3,_0x209c87){return db[_0x886f('0x37')][_0x886f('0x66')]({'where':{'id':_0x3b6ae3['params']['id']}})[_0x886f('0x2a')](handleEntityNotFound(_0x209c87,null))[_0x886f('0x2a')](removeEntity(_0x209c87,null))[_0x886f('0x35')](handleError(_0x209c87,null));};exports[_0x886f('0xb2')]=function(_0x5ee0f5,_0x367e19){return db[_0x886f('0x37')][_0x886f('0xb2')]()[_0x886f('0x2a')](respondWithResult(_0x367e19,null))[_0x886f('0x35')](handleError(_0x367e19,null));};exports[_0x886f('0xb3')]=function(_0x37e051,_0x83b6c9,_0x107607){return db[_0x886f('0xb4')][_0x886f('0x66')]({'where':{'id':_0x37e051['params']['id']}})[_0x886f('0x2a')](handleEntityNotFound(_0x83b6c9,null))[_0x886f('0x2a')](function(_0x4971a1){if(_0x4971a1){return _0x4971a1[_0x886f('0xb3')](_0x37e051[_0x886f('0x73')][_0x886f('0xb5')],_[_0x886f('0xb6')](_0x37e051['body'],['ids','id'])||{});}})[_0x886f('0x2a')](respondWithResult(_0x83b6c9,null))[_0x886f('0x35')](handleError(_0x83b6c9,null));};exports[_0x886f('0xb7')]=function(_0x2b0913,_0x1d695a,_0x3af3c6){var _0x206b45={'raw':![],'where':{}};var _0x47e901={};var _0x4b5319={'count':0x0,'rows':[]};return db['FaxInteraction']['findOne']({'where':{'id':_0x2b0913[_0x886f('0xb8')]['id']}})['then'](handleEntityNotFound(_0x1d695a,null))['then'](function(_0x537b2d){if(_0x537b2d){_0x47e901['model']=_[_0x886f('0x3b')](db[_0x886f('0xb4')]['rawAttributes']);_0x47e901[_0x886f('0x3c')]=_['keys'](_0x2b0913[_0x886f('0x3c')]);_0x47e901[_0x886f('0x3d')]=_[_0x886f('0x3e')](_0x47e901[_0x886f('0x3a')],_0x47e901[_0x886f('0x3c')]);_0x206b45[_0x886f('0x3f')]=_[_0x886f('0x3e')](_0x47e901[_0x886f('0x3a')],qs['fields'](_0x2b0913[_0x886f('0x3c')][_0x886f('0x40')]));_0x206b45[_0x886f('0x3f')]=_0x206b45['attributes'][_0x886f('0x41')]?_0x206b45[_0x886f('0x3f')]:_0x47e901[_0x886f('0x3a')];if(!_0x2b0913['query'][_0x886f('0xb9')](_0x886f('0x42'))){_0x206b45['limit']=qs[_0x886f('0x43')](_0x2b0913['query'][_0x886f('0x43')]);_0x206b45[_0x886f('0x23')]=qs[_0x886f('0x23')](_0x2b0913[_0x886f('0x3c')][_0x886f('0x23')]);}_0x206b45[_0x886f('0x44')]=qs[_0x886f('0x45')](_0x2b0913['query']['sort']);_0x206b45[_0x886f('0x46')]=qs[_0x886f('0x3d')](_['pick'](_0x2b0913[_0x886f('0x3c')],_0x47e901['filters']));_0x206b45[_0x886f('0x46')]['FaxInteractionId']=_0x537b2d['id'];if(_0x2b0913[_0x886f('0x3c')][_0x886f('0x83')]){_0x206b45[_0x886f('0x46')]=_[_0x886f('0x9a')](_0x206b45[_0x886f('0x46')],{'$or':_['map'](_0x206b45[_0x886f('0x3f')],function(_0xb42119){var _0x30d72e={};_0x30d72e[_0xb42119]={'$like':'%'+_0x2b0913[_0x886f('0x3c')]['filter']+'%'};return _0x30d72e;})});}if(_0x2b0913[_0x886f('0x3c')][_0x886f('0xba')]){var _0xc54e55=_0x2b0913['query'][_0x886f('0xba')][_0x886f('0x64')](',');var _0x51340f={};_0x51340f[_0xc54e55[0x0]]={'$gte':moment(_0xc54e55[0x1])['format'](_0x886f('0xbb'))};_0x206b45[_0x886f('0x46')]=_['merge'](_0x206b45[_0x886f('0x46')],_0x51340f);}_0x206b45=_[_0x886f('0x9a')]({},_0x206b45,_0x2b0913[_0x886f('0xbc')]);return db[_0x886f('0xb4')][_0x886f('0x22')]({'where':_0x206b45[_0x886f('0x46')]})['then'](function(_0x13cf54){_0x4b5319[_0x886f('0x22')]=_0x13cf54;if(_0x2b0913[_0x886f('0x3c')][_0x886f('0xaf')]){_0x206b45[_0x886f('0xb0')]=[{'all':!![]}];}return db[_0x886f('0xb4')]['findAll'](_0x206b45);})[_0x886f('0x2a')](function(_0x4323e4){_0x4b5319['rows']=_0x4323e4;return _0x4b5319;});}})['then'](respondWithFilteredResult(_0x1d695a,_0x206b45))['catch'](handleError(_0x1d695a,null));};exports[_0x886f('0xbd')]=function(_0x2462ef,_0x2b0dfe,_0x1d876d){return db[_0x886f('0x37')][_0x886f('0x66')]({'where':{'id':_0x2462ef[_0x886f('0xb8')]['id']}})[_0x886f('0x2a')](handleEntityNotFound(_0x2b0dfe,null))[_0x886f('0x2a')](function(_0x270873){if(_0x270873){return _0x270873[_0x886f('0xbe')](_0x2462ef[_0x886f('0x73')][_0x886f('0xb5')],_[_0x886f('0xb6')](_0x2462ef[_0x886f('0x73')],[_0x886f('0xb5'),'id'])||{})[_0x886f('0xbf')](function(){return db[_0x886f('0x6b')][_0x886f('0xc0')]({'attributes':['id','name',_0x886f('0x49')],'where':{'id':_0x2462ef[_0x886f('0x73')][_0x886f('0xb5')]}});})['then'](function(_0x108d53){socket[_0x886f('0xc1')](_0x886f('0xc2'),{'id':Number(_0x2462ef[_0x886f('0xb8')]['id']),'tags':_0x108d53||[]});return{'id':Number(_0x2462ef[_0x886f('0xb8')]['id']),'tags':_0x108d53||[]};});}})[_0x886f('0x2a')](respondWithResult(_0x2b0dfe,null))[_0x886f('0x35')](handleError(_0x2b0dfe,null));};exports[_0x886f('0xc3')]=function(_0x160d47,_0x38b606,_0x43293c){return db[_0x886f('0x37')][_0x886f('0x66')]({'where':{'id':_0x160d47[_0x886f('0xb8')]['id']}})[_0x886f('0x2a')](handleEntityNotFound(_0x38b606,null))[_0x886f('0x2a')](function(_0x4d0092){if(_0x4d0092){return _0x4d0092['removeTags'](_0x160d47['query'][_0x886f('0xb5')]);}})[_0x886f('0x2a')](respondWithStatusCode(_0x38b606,null))[_0x886f('0x35')](handleError(_0x38b606,null));};exports[_0x886f('0xc4')]=function(_0x403635,_0x4f0810){var _0x54447f=moment()[_0x886f('0xc5')]()['toString']();var _0x2f9f1e=path['join'](config['root'],'server',_0x886f('0xc6'),_0x886f('0xc7'));var _0x23417a=path['join'](config['root'],_0x886f('0xc8'),_0x886f('0xc6'),_0x886f('0xc9'));var _0x4be668=path['join'](_0x2f9f1e,_0x54447f);var _0x325042=util['format'](_0x886f('0xca'),_0x403635['params']['id'],_0x54447f);var _0x34e684=path[_0x886f('0xcb')](_0x2f9f1e,_0x325042);var _0x422089=[];_0x422089[_0x886f('0xac')]({'model':db[_0x886f('0xcc')],'as':_0x886f('0xcc'),'raw':!![]});var _0x29f2c1=[{'model':db[_0x886f('0xb4')],'as':_0x886f('0xcd'),'attributes':['id',_0x886f('0x73'),_0x886f('0x79')],'include':_0x422089}];return db['FaxInteraction'][_0x886f('0x66')]({'where':{'id':_0x403635[_0x886f('0xb8')]['id']},'include':_0x29f2c1})[_0x886f('0x2a')](handleEntityNotFound(_0x4f0810,null))[_0x886f('0x2a')](function(_0x441e69){if(_0x441e69&&_0x441e69['Messages']){var _0x3dc8e2=_0x441e69[_0x886f('0xce')]({'plain':!![]});fs[_0x886f('0xcf')](_0x4be668);for(var _0x551c5d=0x0;_0x551c5d<_0x3dc8e2[_0x886f('0xcd')][_0x886f('0x41')];_0x551c5d++){var _0x4421db=_0x3dc8e2[_0x886f('0xcd')][_0x551c5d]['Attachment'];if(_0x4421db){var _0x215e91=path[_0x886f('0xcb')](_0x23417a,_0x4421db[_0x886f('0xd0')]);if(fs[_0x886f('0xd1')](_0x215e91)){fs[_0x886f('0xd2')](_0x215e91)[_0x886f('0xd3')](fs[_0x886f('0xd4')](path[_0x886f('0xcb')](_0x4be668,_0x4421db[_0x886f('0xd0')])));}}}return BPromise[_0x886f('0x90')]()['then'](function(){return new BPromise(function(_0x2c3c17,_0xd879b3){zipdir(_0x4be668,{'saveTo':_0x34e684},function(_0x4b8c0e,_0x1b6604){if(_0x4b8c0e)return _0xd879b3(_0x4b8c0e);return _0x2c3c17(_0x1b6604);});})[_0x886f('0x2a')](function(){return new BPromise(function(_0x57b408,_0x53ff5f){rimraf(_0x4be668,function(_0x42cea0){if(_0x42cea0)_0x53ff5f(_0x42cea0);return _0x57b408();});});})[_0x886f('0x2a')](function(){return _0x4f0810[_0x886f('0xc4')](_0x34e684,_0x325042,function(_0x1a9cbb){if(_0x1a9cbb){console[_0x886f('0xd5')](_0x886f('0xd6'),_0x1a9cbb);}else{fs['unlinkSync'](_0x34e684);}});});});}else{return _0x4f0810[_0x886f('0x1f')](0xc8);}})[_0x886f('0x35')](handleError(_0x4f0810,null));};
\ No newline at end of file
+var _0x4a1e=['hasOwnProperty','nolimit','sort','where','pick','select','field','tools_tags','u.fullname','ui.FaxInteractionId','from','user_has_fax_interactions','left_join','users','u.id\x20=\x20ui.UserId','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','me.FaxInteractionId\x20=\x20i.id','fax_interaction_has_tags','it.FaxInteractionId\x20=\x20i.id','t.id\x20=\x20it.TagId','expr','search','parseSearch','sqlOperator','conditions','find','value','having','`\x20=\x200','`\x20>\x200','Contact','MATCH\x20(c.firstName,\x20c.lastName,\x20c.phone,\x20c.mobile,\x20c.fax,\x20c.email)\x20AGAINST\x20(?\x20IN\x20BOOLEAN\x20MODE)','getFullTextValue','ContactId','buildExpression','text','Tag','CONCAT(\x27,\x27,\x20`TagIds`,\x20\x27,\x27)\x20LIKE\x20?','union','User','$substring','CONCAT_WS(\x27\x20\x27,\x20o.name,\x20o.fullname)\x20LIKE\x20?','UserId','start','body','keys','some','compact','isEmpty','FaxAccountId','concat','createdAt','parse','$gte','$lte','i.createdAt\x20BETWEEN\x20?\x20AND\x20?','null','\x20IS\x20NULL','read','`unreadMessages`\x20=\x200','`unreadMessages`\x20>\x200','tag','isArray','filter','replace','i.id\x20LIKE\x20?','CONCAT(c.firstName,\x20\x27\x20\x27,\x20c.lastName)\x20LIKE\x20?','group','i.id','Sequelize','SELECT','SUM(me.read\x20=\x200\x20AND\x20me.direction\x20=\x20\x27in\x27)','order','DESC','t.id\x20IN\x20?','resolve','i.FaxAccountId\x20IS\x20NOT\x20NULL','role','agent','user','getFaxAccounts','i.FaxAccountId\x20IS\x20NULL','i.FaxAccountId\x20IN\x20?','sequelize','toString','keyBy','merge','unreadMessages','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','contactName','i.*','c.firstName','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.fullname','Owner.internal','ui.FaxInteractionId\x20IN\x20?','groupBy','rows','show','params','attributes','includeAll','include','options','create','describe','addMessage','ids','omit','findOne','FaxInteractionId','format','YYYY-MM-DD\x20HH:mm:ss','FaxMessage','findAll','addTags','setTags','spread','color','emit','removeTags','unix','join','root','server','files','tmp','attachments','Attachment','Messages','mkdirSync','basename','existsSync','download','log','err','unlinkSync','eml-format','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','sox','to-csv','ejs','fs-extra','squel','crypto','jsforce','desk.js','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/environment','../../config/license/util','../../mysqldb','localhost','socket.io-emitter','redis','./faxInteraction.socket','register','sendStatus','status','offset','limit','undefined','count','set','reject','save','then','destroy','end','error','stack','name','send','map','fullname','Tags','split','forEach','push','TagIds','catch','index','FaxInteraction','fieldName','type','key','model','query','filters','intersection','fields','length'];(function(_0xc43d8a,_0x9cbaaf){var _0x4d0a5c=function(_0x40c1e3){while(--_0x40c1e3){_0xc43d8a['push'](_0xc43d8a['shift']());}};_0x4d0a5c(++_0x9cbaaf);}(_0x4a1e,0x9a));var _0xe4a1=function(_0x92c450,_0x41f1e3){_0x92c450=_0x92c450-0x0;var _0x2a9599=_0x4a1e[_0x92c450];return _0x2a9599;};'use strict';var emlformat=require(_0xe4a1('0x0'));var rimraf=require('rimraf');var zipdir=require(_0xe4a1('0x1'));var jsonpatch=require(_0xe4a1('0x2'));var rp=require(_0xe4a1('0x3'));var moment=require(_0xe4a1('0x4'));var BPromise=require(_0xe4a1('0x5'));var Mustache=require(_0xe4a1('0x6'));var util=require(_0xe4a1('0x7'));var path=require('path');var sox=require(_0xe4a1('0x8'));var csv=require(_0xe4a1('0x9'));var ejs=require(_0xe4a1('0xa'));var fs=require('fs');var fs_extra=require(_0xe4a1('0xb'));var _=require('lodash');var squel=require(_0xe4a1('0xc'));var crypto=require(_0xe4a1('0xd'));var jsforce=require(_0xe4a1('0xe'));var deskjs=require(_0xe4a1('0xf'));var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0xe4a1('0x10'));var Redis=require(_0xe4a1('0x11'));var authService=require(_0xe4a1('0x12'));var qs=require(_0xe4a1('0x13'));var as=require(_0xe4a1('0x14'));var hardwareService=require(_0xe4a1('0x15'));var logger=require(_0xe4a1('0x16'))(_0xe4a1('0x17'));var utils=require('../../config/utils');var config=require(_0xe4a1('0x18'));var licenseUtil=require(_0xe4a1('0x19'));var db=require(_0xe4a1('0x1a'))['db'];config['redis']=_['defaults'](config['redis'],{'host':_0xe4a1('0x1b'),'port':0x18eb});var socket=require(_0xe4a1('0x1c'))(new Redis(config[_0xe4a1('0x1d')]));require(_0xe4a1('0x1e'))[_0xe4a1('0x1f')](socket);function respondWithStatusCode(_0x439975,_0xf19702){_0xf19702=_0xf19702||0xcc;return function(_0x2726f3){if(_0x2726f3){return _0x439975[_0xe4a1('0x20')](_0xf19702);}return _0x439975['status'](_0xf19702)['end']();};}function respondWithResult(_0x161f02,_0x502d3b){_0x502d3b=_0x502d3b||0xc8;return function(_0x74a304){if(_0x74a304){return _0x161f02[_0xe4a1('0x21')](_0x502d3b)['json'](_0x74a304);}};}function respondWithFilteredResult(_0x8d7319,_0x57cd2f){return function(_0x45defc){if(_0x45defc){var _0xfa8195=typeof _0x57cd2f[_0xe4a1('0x22')]==='undefined'&&typeof _0x57cd2f[_0xe4a1('0x23')]===_0xe4a1('0x24');var _0x4c9cd2=_0x45defc[_0xe4a1('0x25')];var _0x584a64=_0xfa8195?0x0:_0x57cd2f[_0xe4a1('0x22')];var _0x1a9db9=_0xfa8195?_0x45defc[_0xe4a1('0x25')]:_0x57cd2f[_0xe4a1('0x22')]+_0x57cd2f[_0xe4a1('0x23')];var _0x2359fc;if(_0x1a9db9>=_0x4c9cd2){_0x1a9db9=_0x4c9cd2;_0x2359fc=0xc8;}else{_0x2359fc=0xce;}_0x8d7319[_0xe4a1('0x21')](_0x2359fc);return _0x8d7319[_0xe4a1('0x26')]('Content-Range',_0x584a64+'-'+_0x1a9db9+'/'+_0x4c9cd2)['json'](_0x45defc);}return null;};}function patchUpdates(_0x2a8c36){return function(_0x12186a){try{jsonpatch['apply'](_0x12186a,_0x2a8c36,!![]);}catch(_0x1ee95c){return BPromise[_0xe4a1('0x27')](_0x1ee95c);}return _0x12186a[_0xe4a1('0x28')]();};}function saveUpdates(_0x429221,_0x40c2e1){return function(_0x46b495){if(_0x46b495){return _0x46b495['update'](_0x429221)[_0xe4a1('0x29')](function(_0x9edbb0){return _0x9edbb0;});}return null;};}function removeEntity(_0x19445e,_0x33b80d){return function(_0x15b7ef){if(_0x15b7ef){return _0x15b7ef[_0xe4a1('0x2a')]()[_0xe4a1('0x29')](function(){_0x19445e['status'](0xcc)[_0xe4a1('0x2b')]();});}};}function handleEntityNotFound(_0x147796,_0x42aee3){return function(_0x53cd1e){if(!_0x53cd1e){_0x147796[_0xe4a1('0x20')](0x194);}return _0x53cd1e;};}function handleError(_0x47a428,_0x45b25c){_0x45b25c=_0x45b25c||0x1f4;return function(_0x129cfa){logger[_0xe4a1('0x2c')](_0x129cfa[_0xe4a1('0x2d')]);if(_0x129cfa[_0xe4a1('0x2e')]){delete _0x129cfa[_0xe4a1('0x2e')];}_0x47a428['status'](_0x45b25c)[_0xe4a1('0x2f')](_0x129cfa);};}function getInteractionUsers(_0x5cf00f,_0x2428e6){return new BPromise(function(_0x3cc0b4,_0x3373d6){try{if(_0x2428e6[_0x5cf00f['id']]){_0x5cf00f['Users']=_[_0xe4a1('0x30')](_0x2428e6[_0x5cf00f['id']],function(_0x47e724){return{'id':_0x47e724['id'],'fullname':_0x47e724[_0xe4a1('0x31')]};});}}catch(_0x283490){_0x3373d6(_0x283490);}_0x3cc0b4(_0x5cf00f);});}function getInteractionTags(_0x3af55f,_0x34005f){return new BPromise(function(_0x5974b5,_0x587058){try{if(_0x3af55f['TagIds']){_0x3af55f[_0xe4a1('0x32')]=[];_0x3af55f['TagIds'][_0xe4a1('0x33')](',')[_0xe4a1('0x34')](function(_0xa3eb0d){_0x3af55f[_0xe4a1('0x32')][_0xe4a1('0x35')](_0x34005f[_0xa3eb0d]);});}delete _0x3af55f[_0xe4a1('0x36')];}catch(_0x31a624){_0x587058(_0x31a624);}_0x5974b5(_0x3af55f);});}function updateFaxInteraction(_0x4b1b6c,_0x583b96,_0x5e86d9){return new BPromise(function(_0x5de187,_0x5bf461){return getInteractionUsers(_0x4b1b6c,_0x5e86d9)[_0xe4a1('0x29')](function(_0x34ebfa){return getInteractionTags(_0x34ebfa,_0x583b96);})['then'](function(_0x226df3){_0x5de187(_0x226df3);})[_0xe4a1('0x37')](function(_0x571362){_0x5bf461(_0x571362);});});}exports[_0xe4a1('0x38')]=function(_0x2f40df,_0x368fb4){var _0x5e1e8a={},_0x49468d={},_0x1e7a80={'count':0x0,'rows':[]};var _0x3c9f4a=_['map'](db[_0xe4a1('0x39')]['rawAttributes'],function(_0x1fb8bd){return{'name':_0x1fb8bd[_0xe4a1('0x3a')],'type':_0x1fb8bd[_0xe4a1('0x3b')][_0xe4a1('0x3c')]};});_0x49468d[_0xe4a1('0x3d')]=_[_0xe4a1('0x30')](_0x3c9f4a,_0xe4a1('0x2e'));_0x49468d[_0xe4a1('0x3e')]=_['keys'](_0x2f40df[_0xe4a1('0x3e')]);_0x49468d[_0xe4a1('0x3f')]=_[_0xe4a1('0x40')](_0x49468d[_0xe4a1('0x3d')],_0x49468d['query']);_0x5e1e8a['attributes']=_['intersection'](_0x49468d[_0xe4a1('0x3d')],qs['fields'](_0x2f40df[_0xe4a1('0x3e')][_0xe4a1('0x41')]));_0x5e1e8a['attributes']=_0x5e1e8a['attributes'][_0xe4a1('0x42')]?_0x5e1e8a['attributes']:_0x49468d[_0xe4a1('0x3d')];if(!_0x2f40df[_0xe4a1('0x3e')][_0xe4a1('0x43')](_0xe4a1('0x44'))){_0x5e1e8a[_0xe4a1('0x23')]=qs['limit'](_0x2f40df[_0xe4a1('0x3e')][_0xe4a1('0x23')]);_0x5e1e8a[_0xe4a1('0x22')]=qs['offset'](_0x2f40df['query'][_0xe4a1('0x22')]);}_0x5e1e8a['order']=qs[_0xe4a1('0x45')](_0x2f40df[_0xe4a1('0x3e')]['sort']);_0x5e1e8a[_0xe4a1('0x46')]=qs[_0xe4a1('0x3f')](_[_0xe4a1('0x47')](_0x2f40df[_0xe4a1('0x3e')],_0x49468d['filters']),_0x3c9f4a);var _0x161767=[];var _0xacb02f=squel[_0xe4a1('0x48')]()[_0xe4a1('0x49')]('id')[_0xe4a1('0x49')](_0xe4a1('0x2e'))[_0xe4a1('0x49')]('color')['from'](_0xe4a1('0x4a'));var _0x23ae74=squel[_0xe4a1('0x48')]()[_0xe4a1('0x49')]('u.id')[_0xe4a1('0x49')](_0xe4a1('0x4b'))[_0xe4a1('0x49')](_0xe4a1('0x4c'))[_0xe4a1('0x4d')](_0xe4a1('0x4e'),'ui')[_0xe4a1('0x4f')](_0xe4a1('0x50'),'u',_0xe4a1('0x51'));var _0x3784be=squel[_0xe4a1('0x48')]()[_0xe4a1('0x4d')](_0xe4a1('0x52'),'i')[_0xe4a1('0x4f')](_0xe4a1('0x53'),'c',_0xe4a1('0x54'))[_0xe4a1('0x4f')](_0xe4a1('0x50'),'o',_0xe4a1('0x55'))[_0xe4a1('0x4f')](_0xe4a1('0x56'),'a',_0xe4a1('0x57'))[_0xe4a1('0x4f')]('fax_messages','me',_0xe4a1('0x58'))[_0xe4a1('0x4f')](_0xe4a1('0x59'),'it',_0xe4a1('0x5a'))['left_join'](_0xe4a1('0x4a'),'t',_0xe4a1('0x5b'));var _0x4c1faf=squel[_0xe4a1('0x5c')]();var _0x65cf87=[];var _0x559e90=squel[_0xe4a1('0x5c')]();var _0x17f9c8;if(_0x2f40df[_0xe4a1('0x3e')][_0xe4a1('0x5d')]){_0x17f9c8=as[_0xe4a1('0x5e')](_0x2f40df[_0xe4a1('0x3e')][_0xe4a1('0x5d')]);var _0xa5c168=_0x17f9c8[_0xe4a1('0x5f')];for(var _0x28ea72=0x0;_0x28ea72<_0x17f9c8[_0xe4a1('0x60')][_0xe4a1('0x42')];_0x28ea72++){var _0x4b2f04=_0x17f9c8[_0xe4a1('0x60')][_0x28ea72];var _0x4895e8='i';var _0x2a74e7=_[_0xe4a1('0x61')](_0x3c9f4a,[_0xe4a1('0x2e'),_0x4b2f04[_0xe4a1('0x49')]]);if(!_0x2a74e7){switch(_0x4b2f04[_0xe4a1('0x49')]){case'unreadMessages':if(_0x4b2f04[_0xe4a1('0x62')]==0x1){_0x3784be[_0xe4a1('0x63')]('`'+_0x4b2f04['field']+_0xe4a1('0x64'));}else{_0x3784be[_0xe4a1('0x63')]('`'+_0x4b2f04[_0xe4a1('0x49')]+_0xe4a1('0x65'));}break;case _0xe4a1('0x66'):if(_0x4b2f04['operator']==='$substring'){if(_0x4b2f04[_0xe4a1('0x62')][_0xe4a1('0x33')]('\x20')[_0xe4a1('0x42')]>0x1){_0x4c1faf[_0xa5c168](_0xe4a1('0x67'),qs[_0xe4a1('0x68')](_0x4b2f04['value']),null);}else{var _0x1b15a9='%'+_0x4b2f04[_0xe4a1('0x62')]+'%';_0x4c1faf[_0xa5c168]('c.firstName\x20LIKE\x20?\x20OR\x20c.lastName\x20LIKE\x20?\x20OR\x20c.email\x20LIKE\x20?',_0x1b15a9,_0x1b15a9,_0x1b15a9);}}else{_0x2a74e7=_[_0xe4a1('0x61')](_0x3c9f4a,[_0xe4a1('0x2e'),_0xe4a1('0x69')]);_0x4b2f04[_0xe4a1('0x49')]='ContactId';_0x1721a6=as[_0xe4a1('0x6a')](_0x4895e8,_0x2a74e7['type'],_0x4b2f04);_0x4c1faf[_0xa5c168](_0x1721a6[_0xe4a1('0x6b')],_0x1721a6[_0xe4a1('0x62')]['start'],_0x1721a6[_0xe4a1('0x62')][_0xe4a1('0x2b')]);}break;case _0xe4a1('0x6c'):var _0x53fddf=_0x4b2f04[_0xe4a1('0x62')][_0xe4a1('0x33')](',')[_0xe4a1('0x30')](function(_0x8fd979){return Number(_0x8fd979);});_0x53fddf[_0xe4a1('0x34')](function(_0x43159b){_0x559e90['or'](_0xe4a1('0x6d'),'%,'+_0x43159b+',%');});_0x65cf87=_[_0xe4a1('0x6e')](_0x65cf87,_0x53fddf);break;case _0xe4a1('0x6f'):if(_0x4b2f04['operator']===_0xe4a1('0x70')){_0x4c1faf[_0xa5c168](_0xe4a1('0x71'),'%'+_0x4b2f04[_0xe4a1('0x62')]+'%',null);}else{_0x2a74e7=_[_0xe4a1('0x61')](_0x3c9f4a,['name','UserId']);_0x4b2f04[_0xe4a1('0x49')]=_0xe4a1('0x72');_0x1721a6=as[_0xe4a1('0x6a')](_0x4895e8,_0x2a74e7['type'],_0x4b2f04);_0x4c1faf[_0xa5c168](_0x1721a6[_0xe4a1('0x6b')],_0x1721a6[_0xe4a1('0x62')][_0xe4a1('0x73')],_0x1721a6[_0xe4a1('0x62')][_0xe4a1('0x2b')]);}break;case _0xe4a1('0x74'):_0x1721a6=as[_0xe4a1('0x6a')]('me',null,_0x4b2f04);_0x4c1faf[_0xa5c168](_0x1721a6[_0xe4a1('0x6b')],_0x1721a6['value'][_0xe4a1('0x73')],_0x1721a6[_0xe4a1('0x62')]['end']);break;}}else{var _0x1721a6=as[_0xe4a1('0x6a')](_0x4895e8,_0x2a74e7[_0xe4a1('0x3b')],_0x4b2f04);_0x4c1faf[_0xa5c168](_0x1721a6[_0xe4a1('0x6b')],_0x1721a6[_0xe4a1('0x62')][_0xe4a1('0x73')],_0x1721a6[_0xe4a1('0x62')][_0xe4a1('0x2b')]);}}}else{var _0x21ad38=_(_0x2f40df[_0xe4a1('0x3e')])[_0xe4a1('0x75')]()[_0xe4a1('0x30')](function(_0x381440){return _[_0xe4a1('0x76')](_0x3c9f4a,[_0xe4a1('0x2e'),_0x381440])?_0x381440:undefined;})[_0xe4a1('0x77')]()['value']();if(!_[_0xe4a1('0x78')](_0x21ad38)){_0x21ad38[_0xe4a1('0x34')](function(_0x5c25b8){if(_0x5c25b8===_0xe4a1('0x79')){_0x3784be[_0xe4a1('0x46')]('i.FaxAccountId\x20IN\x20?',[][_0xe4a1('0x7a')](_0x2f40df[_0xe4a1('0x3e')][_0x5c25b8]));}else if(_0x5c25b8===_0xe4a1('0x7b')){var _0x527fa8=JSON[_0xe4a1('0x7c')](_0x2f40df[_0xe4a1('0x3e')][_0x5c25b8])[_0xe4a1('0x7d')];var _0x3134f4=JSON['parse'](_0x2f40df['query'][_0x5c25b8])[_0xe4a1('0x7e')];_0x3784be[_0xe4a1('0x46')](_0xe4a1('0x7f'),_0x527fa8,_0x3134f4);}else{if(_0x2f40df[_0xe4a1('0x3e')][_0x5c25b8]===_0xe4a1('0x80')){_0x3784be[_0xe4a1('0x46')]('i.'+_0x5c25b8+_0xe4a1('0x81'));}else{_0x3784be[_0xe4a1('0x46')]('i.'+_0x5c25b8+'\x20=\x20?',_0x2f40df[_0xe4a1('0x3e')][_0x5c25b8]);}}});}if(_0x2f40df[_0xe4a1('0x3e')][_0xe4a1('0x82')]){if(_0x2f40df['query'][_0xe4a1('0x82')]==0x1){_0x3784be['having'](_0xe4a1('0x83'));}else{_0x3784be[_0xe4a1('0x63')](_0xe4a1('0x84'));}}if(_0x2f40df[_0xe4a1('0x3e')][_0xe4a1('0x85')]){_0x65cf87=_[_0xe4a1('0x86')](_0x2f40df[_0xe4a1('0x3e')][_0xe4a1('0x85')])?_0x2f40df[_0xe4a1('0x3e')][_0xe4a1('0x85')]:new Array(_0x2f40df[_0xe4a1('0x3e')][_0xe4a1('0x85')]);_0x65cf87['forEach'](function(_0x232977){_0x559e90['or'](_0xe4a1('0x6d'),'%,'+_0x232977+',%');});}if(_0x2f40df[_0xe4a1('0x3e')][_0xe4a1('0x87')]){var _0x5f4eb1=_0x2f40df[_0xe4a1('0x3e')]['filter']['replace']('\x5c','\x5c\x5c')[_0xe4a1('0x88')](/'/g,'\x27\x27');if(qs['isNumeric'](_0x5f4eb1)){_0x4c1faf['or'](_0xe4a1('0x89'),_0x5f4eb1+'%')['or']('i.fax\x20LIKE\x20?',_0x5f4eb1+'%');}_0x4c1faf['or'](_0xe4a1('0x8a'),_0x5f4eb1+'%');}}_0x3784be[_0xe4a1('0x46')](_0x4c1faf);_0x3784be[_0xe4a1('0x8b')](_0xe4a1('0x8c'));var _0x4d3972={'type':db[_0xe4a1('0x8d')]['QueryTypes'][_0xe4a1('0x8e')],'raw':!![]};var _0x4aeba9=_0x3784be['clone']();_0x4aeba9[_0xe4a1('0x49')]('i.id');_0x4aeba9[_0xe4a1('0x49')](_0xe4a1('0x8f'),'unreadMessages');if(_0x5e1e8a[_0xe4a1('0x90')]){_0x5e1e8a['order']['forEach'](function(_0x5e2908){var _0x597e48=_0x5e2908[0x0]==='contactName'?_0x5e2908[0x0]:'i.'+_0x5e2908[0x0];_0x3784be[_0xe4a1('0x90')](_0x597e48,_0x5e2908[0x1]===_0xe4a1('0x91')?![]:!![]);});}if(!_[_0xe4a1('0x78')](_0x65cf87)){_0x3784be['having'](_0x559e90);_0x4aeba9[_0xe4a1('0x46')](_0xe4a1('0x92'),_0x65cf87);}BPromise[_0xe4a1('0x93')]()[_0xe4a1('0x29')](function(){if(!_0x17f9c8){if(_0x2f40df[_0xe4a1('0x3e')]['FaxAccountId'])return;_0x4aeba9[_0xe4a1('0x46')](_0xe4a1('0x94'));_0x3784be[_0xe4a1('0x46')](_0xe4a1('0x94'));return;}if(_0x2f40df['user'][_0xe4a1('0x95')]!==_0xe4a1('0x96'))return;return _0x2f40df[_0xe4a1('0x97')][_0xe4a1('0x98')]({'attributes':['id'],'raw':!![]})[_0xe4a1('0x29')](function(_0x2a74fd){if(_[_0xe4a1('0x78')](_0x2a74fd)){_0x4aeba9[_0xe4a1('0x46')](_0xe4a1('0x99'));_0x3784be['where'](_0xe4a1('0x99'));}else{_0x4aeba9['where']('i.FaxAccountId\x20IN\x20?',_[_0xe4a1('0x30')](_0x2a74fd,'id'));_0x3784be[_0xe4a1('0x46')](_0xe4a1('0x9a'),_['map'](_0x2a74fd,'id'));}});})[_0xe4a1('0x29')](function(){if(_0x2f40df[_0xe4a1('0x97')][_0xe4a1('0x95')]===_0xe4a1('0x96')&&!_0x17f9c8&&!_0x2f40df['query']['FaxAccountId'])return[];return db[_0xe4a1('0x9b')][_0xe4a1('0x3e')](_0x4aeba9[_0xe4a1('0x9c')](),_0x4d3972);})[_0xe4a1('0x29')](function(_0xa13273){_0x1e7a80[_0xe4a1('0x25')]=_0xa13273[_0xe4a1('0x42')];if(_0x1e7a80['count']===0x0)return[];return db[_0xe4a1('0x9b')][_0xe4a1('0x3e')](_0xacb02f[_0xe4a1('0x9c')](),_0x4d3972)[_0xe4a1('0x29')](function(_0x34d41f){_0x161767=_[_0xe4a1('0x9d')](_0x34d41f,'id');_0x4d3972=_[_0xe4a1('0x9e')](_0x4d3972,{'model':db[_0xe4a1('0x39')],'mapToModel':!![],'raw':!![],'nest':!![]});if(_0x2f40df[_0xe4a1('0x3e')][_0xe4a1('0x41')]){_0x5e1e8a['attributes'][_0xe4a1('0x34')](function(_0x1eb0ed){_0x3784be[_0xe4a1('0x49')]('i.'+_0x1eb0ed);});}else{_0x3784be['field'](_0xe4a1('0x8f'),_0xe4a1('0x9f'));_0x3784be['field']('a.key','Account.key');_0x3784be[_0xe4a1('0x49')]('a.mandatoryDisposition',_0xe4a1('0xa0'));_0x3784be['field'](_0xe4a1('0xa1'),_0xe4a1('0xa2'));_0x3784be[_0xe4a1('0x49')](_0xe4a1('0xa3'));_0x3784be[_0xe4a1('0x49')](_0xe4a1('0xa4'),_0xe4a1('0xa5'));_0x3784be[_0xe4a1('0x49')](_0xe4a1('0xa6'),_0xe4a1('0xa7'));_0x3784be['field'](_0xe4a1('0xa8'),_0xe4a1('0xa9'));_0x3784be[_0xe4a1('0x49')](_0xe4a1('0xaa'),_0xe4a1('0xab'));_0x3784be['field'](_0xe4a1('0xac'),_0xe4a1('0xad'));_0x3784be[_0xe4a1('0x49')](_0xe4a1('0xae'),_0xe4a1('0xaf'));_0x3784be[_0xe4a1('0x49')](_0xe4a1('0xb0'),_0xe4a1('0xb1'));_0x3784be[_0xe4a1('0x49')]('o.internal',_0xe4a1('0xb2'));_0x3784be[_0xe4a1('0x49')]('GROUP_CONCAT(DISTINCT\x20t.id)',_0xe4a1('0x36'));}if(_0x5e1e8a[_0xe4a1('0x23')])_0x3784be[_0xe4a1('0x23')](_0x5e1e8a[_0xe4a1('0x23')]);if(_0x5e1e8a['offset'])_0x3784be[_0xe4a1('0x22')](_0x5e1e8a[_0xe4a1('0x22')]);return db[_0xe4a1('0x9b')]['query'](_0x3784be['toString'](),_0x4d3972);})['then'](function(_0x337249){if(_0x337249[_0xe4a1('0x42')]>0x0)_0x23ae74['where'](_0xe4a1('0xb3'),_[_0xe4a1('0x30')](_0x337249,'id'));return db['sequelize'][_0xe4a1('0x3e')](_0x23ae74[_0xe4a1('0x9c')](),_0x4d3972)[_0xe4a1('0x29')](function(_0x13ba8a){var _0x1aa4d9=_[_0xe4a1('0xb4')](_0x13ba8a,'FaxInteractionId');var _0x187a30=[];_0x337249[_0xe4a1('0x34')](function(_0xb69b3d){_0x187a30['push'](updateFaxInteraction(_0xb69b3d,_0x161767,_0x1aa4d9));});return BPromise['all'](_0x187a30);});});})['then'](function(_0xd87839){_0x1e7a80[_0xe4a1('0xb5')]=_0xd87839;return _0x1e7a80;})[_0xe4a1('0x29')](respondWithFilteredResult(_0x368fb4,_0x5e1e8a))['catch'](handleError(_0x368fb4,null));};exports[_0xe4a1('0xb6')]=function(_0x266664,_0x196eb6){var _0x18b184={'raw':![],'where':{'id':_0x266664[_0xe4a1('0xb7')]['id']}},_0x3befc9={};_0x3befc9[_0xe4a1('0x3d')]=_[_0xe4a1('0x75')](db[_0xe4a1('0x39')]['rawAttributes']);_0x3befc9[_0xe4a1('0x3e')]=_['keys'](_0x266664[_0xe4a1('0x3e')]);_0x3befc9['filters']=_['intersection'](_0x3befc9[_0xe4a1('0x3d')],_0x3befc9[_0xe4a1('0x3e')]);_0x18b184['attributes']=_[_0xe4a1('0x40')](_0x3befc9['model'],qs[_0xe4a1('0x41')](_0x266664[_0xe4a1('0x3e')][_0xe4a1('0x41')]));_0x18b184[_0xe4a1('0xb8')]=_0x18b184[_0xe4a1('0xb8')][_0xe4a1('0x42')]?_0x18b184[_0xe4a1('0xb8')]:_0x3befc9[_0xe4a1('0x3d')];if(_0x266664[_0xe4a1('0x3e')][_0xe4a1('0xb9')]){_0x18b184[_0xe4a1('0xba')]=[{'all':!![]}];}_0x18b184=_[_0xe4a1('0x9e')]({},_0x18b184,_0x266664[_0xe4a1('0xbb')]);return db['FaxInteraction'][_0xe4a1('0x61')](_0x18b184)[_0xe4a1('0x29')](handleEntityNotFound(_0x196eb6,null))[_0xe4a1('0x29')](respondWithResult(_0x196eb6,null))[_0xe4a1('0x37')](handleError(_0x196eb6,null));};exports[_0xe4a1('0xbc')]=function(_0x53c4e6,_0x2a2f08){return db[_0xe4a1('0x39')][_0xe4a1('0xbc')](_0x53c4e6[_0xe4a1('0x74')],{})['then'](respondWithResult(_0x2a2f08,0xc9))[_0xe4a1('0x37')](handleError(_0x2a2f08,null));};exports['update']=function(_0x387d1e,_0x1558b8){if(_0x387d1e[_0xe4a1('0x74')]['id']){delete _0x387d1e[_0xe4a1('0x74')]['id'];}return db['FaxInteraction']['find']({'where':{'id':_0x387d1e['params']['id']}})[_0xe4a1('0x29')](handleEntityNotFound(_0x1558b8,null))[_0xe4a1('0x29')](saveUpdates(_0x387d1e[_0xe4a1('0x74')],null))[_0xe4a1('0x29')](respondWithResult(_0x1558b8,null))[_0xe4a1('0x37')](handleError(_0x1558b8,null));};exports[_0xe4a1('0x2a')]=function(_0x41cead,_0x53a41f){return db[_0xe4a1('0x39')]['find']({'where':{'id':_0x41cead[_0xe4a1('0xb7')]['id']}})[_0xe4a1('0x29')](handleEntityNotFound(_0x53a41f,null))[_0xe4a1('0x29')](removeEntity(_0x53a41f,null))[_0xe4a1('0x37')](handleError(_0x53a41f,null));};exports[_0xe4a1('0xbd')]=function(_0x43ff19,_0x23a65e){return db[_0xe4a1('0x39')][_0xe4a1('0xbd')]()['then'](respondWithResult(_0x23a65e,null))[_0xe4a1('0x37')](handleError(_0x23a65e,null));};exports[_0xe4a1('0xbe')]=function(_0x5f4798,_0xf15e0a,_0x27a27d){return db['FaxMessage'][_0xe4a1('0x61')]({'where':{'id':_0x5f4798[_0xe4a1('0xb7')]['id']}})[_0xe4a1('0x29')](handleEntityNotFound(_0xf15e0a,null))[_0xe4a1('0x29')](function(_0x55e700){if(_0x55e700){return _0x55e700[_0xe4a1('0xbe')](_0x5f4798[_0xe4a1('0x74')][_0xe4a1('0xbf')],_[_0xe4a1('0xc0')](_0x5f4798[_0xe4a1('0x74')],[_0xe4a1('0xbf'),'id'])||{});}})[_0xe4a1('0x29')](respondWithResult(_0xf15e0a,null))['catch'](handleError(_0xf15e0a,null));};exports['getMessages']=function(_0x384810,_0x277242,_0x354c28){var _0x53707e={'raw':![],'where':{}};var _0x28b052={};var _0x58f05b={'count':0x0,'rows':[]};return db[_0xe4a1('0x39')][_0xe4a1('0xc1')]({'where':{'id':_0x384810['params']['id']}})[_0xe4a1('0x29')](handleEntityNotFound(_0x277242,null))[_0xe4a1('0x29')](function(_0x1bfd33){if(_0x1bfd33){_0x28b052['model']=_[_0xe4a1('0x75')](db['FaxMessage']['rawAttributes']);_0x28b052[_0xe4a1('0x3e')]=_['keys'](_0x384810[_0xe4a1('0x3e')]);_0x28b052[_0xe4a1('0x3f')]=_[_0xe4a1('0x40')](_0x28b052[_0xe4a1('0x3d')],_0x28b052[_0xe4a1('0x3e')]);_0x53707e[_0xe4a1('0xb8')]=_[_0xe4a1('0x40')](_0x28b052['model'],qs[_0xe4a1('0x41')](_0x384810[_0xe4a1('0x3e')][_0xe4a1('0x41')]));_0x53707e[_0xe4a1('0xb8')]=_0x53707e[_0xe4a1('0xb8')][_0xe4a1('0x42')]?_0x53707e['attributes']:_0x28b052[_0xe4a1('0x3d')];if(!_0x384810[_0xe4a1('0x3e')][_0xe4a1('0x43')](_0xe4a1('0x44'))){_0x53707e['limit']=qs['limit'](_0x384810[_0xe4a1('0x3e')][_0xe4a1('0x23')]);_0x53707e[_0xe4a1('0x22')]=qs[_0xe4a1('0x22')](_0x384810[_0xe4a1('0x3e')]['offset']);}_0x53707e[_0xe4a1('0x90')]=qs[_0xe4a1('0x45')](_0x384810['query'][_0xe4a1('0x45')]);_0x53707e[_0xe4a1('0x46')]=qs[_0xe4a1('0x3f')](_[_0xe4a1('0x47')](_0x384810[_0xe4a1('0x3e')],_0x28b052[_0xe4a1('0x3f')]));_0x53707e[_0xe4a1('0x46')][_0xe4a1('0xc2')]=_0x1bfd33['id'];if(_0x384810[_0xe4a1('0x3e')][_0xe4a1('0x87')]){_0x53707e[_0xe4a1('0x46')]=_[_0xe4a1('0x9e')](_0x53707e[_0xe4a1('0x46')],{'$or':_['map'](_0x53707e[_0xe4a1('0xb8')],function(_0x4a14ea){var _0x47783e={};_0x47783e[_0x4a14ea]={'$like':'%'+_0x384810['query'][_0xe4a1('0x87')]+'%'};return _0x47783e;})});}if(_0x384810['query'][_0xe4a1('0x7d')]){var _0x47251a=_0x384810['query'][_0xe4a1('0x7d')][_0xe4a1('0x33')](',');var _0x18e0e5={};_0x18e0e5[_0x47251a[0x0]]={'$gte':moment(_0x47251a[0x1])[_0xe4a1('0xc3')](_0xe4a1('0xc4'))};_0x53707e[_0xe4a1('0x46')]=_[_0xe4a1('0x9e')](_0x53707e['where'],_0x18e0e5);}_0x53707e=_['merge']({},_0x53707e,_0x384810[_0xe4a1('0xbb')]);return db[_0xe4a1('0xc5')][_0xe4a1('0x25')]({'where':_0x53707e[_0xe4a1('0x46')]})[_0xe4a1('0x29')](function(_0x53f1e6){_0x58f05b['count']=_0x53f1e6;if(_0x384810[_0xe4a1('0x3e')]['includeAll']){_0x53707e[_0xe4a1('0xba')]=[{'all':!![]}];}return db[_0xe4a1('0xc5')][_0xe4a1('0xc6')](_0x53707e);})['then'](function(_0x1f89a6){_0x58f05b[_0xe4a1('0xb5')]=_0x1f89a6;return _0x58f05b;});}})[_0xe4a1('0x29')](respondWithFilteredResult(_0x277242,_0x53707e))[_0xe4a1('0x37')](handleError(_0x277242,null));};exports[_0xe4a1('0xc7')]=function(_0x2662c6,_0x4c42c7,_0x508c11){return db[_0xe4a1('0x39')][_0xe4a1('0x61')]({'where':{'id':_0x2662c6[_0xe4a1('0xb7')]['id']}})[_0xe4a1('0x29')](handleEntityNotFound(_0x4c42c7,null))[_0xe4a1('0x29')](function(_0x2e9485){if(_0x2e9485){return _0x2e9485[_0xe4a1('0xc8')](_0x2662c6[_0xe4a1('0x74')][_0xe4a1('0xbf')],_[_0xe4a1('0xc0')](_0x2662c6[_0xe4a1('0x74')],[_0xe4a1('0xbf'),'id'])||{})[_0xe4a1('0xc9')](function(){return db['Tag']['findAll']({'attributes':['id',_0xe4a1('0x2e'),_0xe4a1('0xca')],'where':{'id':_0x2662c6['body']['ids']}});})[_0xe4a1('0x29')](function(_0x262605){socket[_0xe4a1('0xcb')]('faxInteractionTags:save',{'id':Number(_0x2662c6[_0xe4a1('0xb7')]['id']),'tags':_0x262605||[]});return{'id':Number(_0x2662c6[_0xe4a1('0xb7')]['id']),'tags':_0x262605||[]};});}})[_0xe4a1('0x29')](respondWithResult(_0x4c42c7,null))[_0xe4a1('0x37')](handleError(_0x4c42c7,null));};exports['removeTags']=function(_0x516c57,_0x363c76,_0x2900f5){return db['FaxInteraction'][_0xe4a1('0x61')]({'where':{'id':_0x516c57[_0xe4a1('0xb7')]['id']}})[_0xe4a1('0x29')](handleEntityNotFound(_0x363c76,null))[_0xe4a1('0x29')](function(_0x1e268e){if(_0x1e268e){return _0x1e268e[_0xe4a1('0xcc')](_0x516c57['query'][_0xe4a1('0xbf')]);}})['then'](respondWithStatusCode(_0x363c76,null))[_0xe4a1('0x37')](handleError(_0x363c76,null));};exports['download']=function(_0x3449da,_0x591d1b){var _0x50483e=moment()[_0xe4a1('0xcd')]()[_0xe4a1('0x9c')]();var _0xf64de1=path[_0xe4a1('0xce')](config[_0xe4a1('0xcf')],_0xe4a1('0xd0'),_0xe4a1('0xd1'),_0xe4a1('0xd2'));var _0x14763e=path[_0xe4a1('0xce')](config[_0xe4a1('0xcf')],_0xe4a1('0xd0'),_0xe4a1('0xd1'),_0xe4a1('0xd3'));var _0x15eee5=path[_0xe4a1('0xce')](_0xf64de1,_0x50483e);var _0x5396f2=util['format']('transcript-%d-%s.zip',_0x3449da['params']['id'],_0x50483e);var _0xa7b74e=path[_0xe4a1('0xce')](_0xf64de1,_0x5396f2);var _0x6648d1=[];_0x6648d1[_0xe4a1('0x35')]({'model':db[_0xe4a1('0xd4')],'as':_0xe4a1('0xd4'),'raw':!![]});var _0x502b92=[{'model':db[_0xe4a1('0xc5')],'as':_0xe4a1('0xd5'),'attributes':['id',_0xe4a1('0x74'),_0xe4a1('0x7b')],'include':_0x6648d1}];return db[_0xe4a1('0x39')][_0xe4a1('0x61')]({'where':{'id':_0x3449da[_0xe4a1('0xb7')]['id']},'include':_0x502b92})[_0xe4a1('0x29')](handleEntityNotFound(_0x591d1b,null))[_0xe4a1('0x29')](function(_0x1c457c){if(_0x1c457c&&_0x1c457c['Messages']){var _0xa1489f=_0x1c457c['get']({'plain':!![]});fs[_0xe4a1('0xd6')](_0x15eee5);for(var _0x5ae1f6=0x0;_0x5ae1f6<_0xa1489f[_0xe4a1('0xd5')][_0xe4a1('0x42')];_0x5ae1f6++){var _0x44769f=_0xa1489f[_0xe4a1('0xd5')][_0x5ae1f6][_0xe4a1('0xd4')];if(_0x44769f){var _0x5adb68=path[_0xe4a1('0xce')](_0x14763e,_0x44769f[_0xe4a1('0xd7')]);if(fs[_0xe4a1('0xd8')](_0x5adb68)){fs['createReadStream'](_0x5adb68)['pipe'](fs['createWriteStream'](path[_0xe4a1('0xce')](_0x15eee5,_0x44769f[_0xe4a1('0xd7')])));}}}return BPromise[_0xe4a1('0x93')]()[_0xe4a1('0x29')](function(){return new BPromise(function(_0x362034,_0xff0d28){zipdir(_0x15eee5,{'saveTo':_0xa7b74e},function(_0x19b9a9,_0xc5841c){if(_0x19b9a9)return _0xff0d28(_0x19b9a9);return _0x362034(_0xc5841c);});})[_0xe4a1('0x29')](function(){return new BPromise(function(_0x4e8190,_0x25eaef){rimraf(_0x15eee5,function(_0x491109){if(_0x491109)_0x25eaef(_0x491109);return _0x4e8190();});});})[_0xe4a1('0x29')](function(){return _0x591d1b[_0xe4a1('0xd9')](_0xa7b74e,_0x5396f2,function(_0x5b097d){if(_0x5b097d){console[_0xe4a1('0xda')](_0xe4a1('0xdb'),_0x5b097d);}else{fs[_0xe4a1('0xdc')](_0xa7b74e);}});});});}else{return _0x591d1b['sendStatus'](0xc8);}})[_0xe4a1('0x37')](handleError(_0x591d1b,null));};
\ No newline at end of file