Built motion from commit f738f9592c388b9f9eb3948f400a5c9d717a3561. Version 3.0.0...
[motion-next.git] / server / api / faxInteraction / faxInteraction.controller.js
index 485658e..40c9404 100644 (file)
@@ -1 +1 @@
-const a236_0x3f0f=['Contact.mobile','User','start','color','o.internal','count','sequelize','keyBy','basename','squel','Contact.email','tag','Tags','nolimit','../../mysqldb','cm_contacts','`\x20>\x200','a.id\x20=\x20i.FaxAccountId','union','CONCAT(c.firstName,\x20\x27\x20\x27,\x20c.lastName)\x20LIKE\x20?','u.id','SELECT','attributes','transcript-%d-%s.zip','end','c.firstName\x20LIKE\x20?\x20OR\x20c.lastName\x20LIKE\x20?\x20OR\x20c.email\x20LIKE\x20?','FaxInteraction','FaxMessage','index','download','log','catch','Attachment','server','getMessages','send','tmp','c.lastName','fields','read','push','query','merge','mkdirSync','$substring','params','json','unix','split','addTags','Owner.internal','`\x20=\x200','Content-Range','then','operator','CONCAT(\x27,\x27,\x20`TagIds`,\x20\x27,\x27)\x20LIKE\x20?','update','sort','../../config/environment','moment','\x20=\x20?','filters','fax_interaction_has_tags','c.id\x20=\x20i.ContactId\x20AND\x20c.deletedAt\x20IS\x20NULL','files','Account.mandatoryDisposition','../../components/parsers/advancedSearch','i.FaxAccountId\x20IS\x20NULL','isArray','compact','group','SUM(me.read\x20=\x200\x20AND\x20me.direction\x20=\x20\x27in\x27)','create','limit','i.*','$gte','`unreadMessages`\x20=\x200','../../components/parsers/qs','addMessage','unreadMessages','c.firstName','c.phone','i.fax\x20LIKE\x20?','it.FaxInteractionId\x20=\x20i.id','Contact.fax','root','c.fax','tools_tags','err','MATCH\x20(c.firstName,\x20c.lastName,\x20c.phone,\x20c.mobile,\x20c.fax,\x20c.email)\x20AGAINST\x20(?\x20IN\x20BOOLEAN\x20MODE)','Tag','forEach','getFaxAccounts','rawAttributes','register','from','t.id\x20IN\x20?','findAll','destroy','user_has_fax_interactions','some','findOne','FaxInteractionId','Contact.firstName','fax_interactions','\x20IS\x20NULL','options','keys','Messages','journey','pipe','createWriteStream','having','search','`unreadMessages`\x20>\x200','get','resolve','i.id','setTags','where','removeTags','./faxInteraction.socket','i.createdAt\x20BETWEEN\x20?\x20AND\x20?','Contact.lastName','ContactId','key','t.id\x20=\x20it.TagId','filter','../../config/logger','TagIds','left_join','value','c.mobile','toString','createReadStream','faxInteractionTags:save','Contact','existsSync','find','show','u.id\x20=\x20ui.UserId','replace','field','a.mandatoryDisposition','all','i.id\x20LIKE\x20?','u.fullname','includeAll','Contact.phone','type','offset','i.FaxAccountId\x20IS\x20NOT\x20NULL','select','sendStatus','name','GROUP_CONCAT(DISTINCT\x20t.id)','length','model','set','describe','order','body','rows','../../rediscache','rimraf','intersection','error','pick','format','omit','path','status','buildExpression','FaxAccountId','map','fieldName','gte','i.FaxAccountId\x20IN\x20?','ui.FaxInteractionId\x20IN\x20?','null','c.email','users','util','join','user','createdAt','text','isEmpty','ui.FaxInteractionId','sqlOperator','ids','me.FaxInteractionId\x20=\x20i.id','concat'];(function(_0x1e6f9b,_0x219b66){const _0x3f0fd0=function(_0x4f7549){while(--_0x4f7549){_0x1e6f9b['push'](_0x1e6f9b['shift']());}};_0x3f0fd0(++_0x219b66);}(a236_0x3f0f,0x1d9));const a236_0x4f75=function(_0x1e6f9b,_0x219b66){_0x1e6f9b=_0x1e6f9b-0xd3;let _0x3f0fd0=a236_0x3f0f[_0x1e6f9b];return _0x3f0fd0;};const a236_0x4a0432=a236_0x4f75;'use strict';const rimraf=require(a236_0x4a0432(0x120)),zipdir=require('zip-dir'),moment=require(a236_0x4a0432(0x178)),util=require(a236_0x4a0432(0x132)),path=require(a236_0x4a0432(0x126)),fs=require('fs'),_=require('lodash'),squel=require(a236_0x4a0432(0x146)),{getSocket}=require(a236_0x4a0432(0x11f)),socket=getSocket(),qs=require(a236_0x4a0432(0x18a)),as=require(a236_0x4a0432(0x17f)),logger=require(a236_0x4a0432(0xfc))('api'),config=require(a236_0x4a0432(0x177)),{db}=require(a236_0x4a0432(0x14b)),{Op,QueryTypes}=require('sequelize');require(a236_0x4a0432(0xf5))[a236_0x4a0432(0xda)](socket);function respondWithStatusCode(_0x18fb3a,_0x1f6151){return _0x1f6151=_0x1f6151||0xcc,function(_0x296fff){const _0x305efe=a236_0x4f75;if(_0x296fff)return _0x18fb3a[_0x305efe(0x115)](_0x1f6151);return _0x18fb3a[_0x305efe(0x127)](_0x1f6151)[_0x305efe(0x155)]();};}function respondWithResult(_0x3725e5,_0x56646e){return _0x56646e=_0x56646e||0xc8,function(_0x3dd163){const _0x10718a=a236_0x4f75;if(_0x3dd163)return _0x3725e5[_0x10718a(0x127)](_0x56646e)[_0x10718a(0x16b)](_0x3dd163);};}function respondWithFilteredResult(_0x356e50,_0x397634){return function(_0x4ddb01){const _0x4c637f=a236_0x4f75;if(_0x4ddb01){const _0x561c7d=_0x4ddb01[_0x4c637f(0x142)],_0x43e7ef=_0x397634[_0x4c637f(0x112)];let _0x708dff=_0x397634[_0x4c637f(0x112)]+_0x397634[_0x4c637f(0x186)],_0x1f7f27;return _0x708dff>=_0x561c7d?(_0x708dff=_0x561c7d,_0x1f7f27=0xc8):_0x1f7f27=0xce,_0x356e50[_0x4c637f(0x127)](_0x1f7f27),_0x356e50[_0x4c637f(0x11a)](_0x4c637f(0x171),_0x43e7ef+'-'+_0x708dff+'/'+_0x561c7d)[_0x4c637f(0x16b)](_0x4ddb01);}return null;};}function saveUpdates(_0x68e137){return function(_0x583d8e){const _0x34beec=a236_0x4f75;if(_0x583d8e)return _0x583d8e[_0x34beec(0x175)](_0x68e137)['then'](function(_0x332b0e){return _0x332b0e;});return null;};}function removeEntity(_0x52a718){return function(_0x4d5122){const _0x16c355=a236_0x4f75;if(_0x4d5122)return _0x4d5122[_0x16c355(0xde)]()[_0x16c355(0x172)](function(){const _0x207d1a=_0x16c355;_0x52a718[_0x207d1a(0x127)](0xcc)[_0x207d1a(0x155)]();});};}function handleEntityNotFound(_0x5f18e9){return function(_0x3c910c){const _0x4fde82=a236_0x4f75;return!_0x3c910c&&_0x5f18e9[_0x4fde82(0x115)](0x194),_0x3c910c;};}function handleError(_0x15fc34,_0x1aea4e){return _0x1aea4e=_0x1aea4e||0x1f4,function(_0x11b9e5){const _0x45b9b5=a236_0x4f75;logger[_0x45b9b5(0x122)](_0x11b9e5['stack']),_0x11b9e5[_0x45b9b5(0x116)]&&delete _0x11b9e5[_0x45b9b5(0x116)],_0x15fc34['status'](_0x1aea4e)[_0x45b9b5(0x160)](_0x11b9e5);};}function getInteractionUsers(_0x3d4011,_0x5d1c3b){return new Promise(function(_0x1602e1,_0x5b3bc2){const _0x2e09b7=a236_0x4f75;try{_0x5d1c3b[_0x3d4011['id']]&&(_0x3d4011['Users']=_[_0x2e09b7(0x12a)](_0x5d1c3b[_0x3d4011['id']],function(_0x56e93b){return{'id':_0x56e93b['id'],'fullname':_0x56e93b['fullname']};}));}catch(_0x19ad39){_0x5b3bc2(_0x19ad39);}_0x1602e1(_0x3d4011);});}function getInteractionTags(_0x5d07e5,_0x47693b){return new Promise(function(_0x18a244,_0x10f328){const _0x178e41=a236_0x4f75;try{_0x5d07e5[_0x178e41(0xfd)]&&(_0x5d07e5[_0x178e41(0x149)]=[],_0x5d07e5['TagIds'][_0x178e41(0x16d)](',')[_0x178e41(0xd7)](function(_0x1b2e5f){_0x5d07e5['Tags']['push'](_0x47693b[_0x1b2e5f]);})),delete _0x5d07e5['TagIds'];}catch(_0x24b01b){_0x10f328(_0x24b01b);}_0x18a244(_0x5d07e5);});}function updateFaxInteraction(_0x361c11,_0x7c864f,_0x37daf3){return new Promise(function(_0x1fe602,_0x39975e){const _0x1f6adf=a236_0x4f75;return getInteractionUsers(_0x361c11,_0x37daf3)['then'](function(_0x16c31b){return getInteractionTags(_0x16c31b,_0x7c864f);})[_0x1f6adf(0x172)](function(_0x3e712a){_0x1fe602(_0x3e712a);})[_0x1f6adf(0x15c)](function(_0x254b87){_0x39975e(_0x254b87);});});}exports[a236_0x4a0432(0x159)]=function(_0x5445b0,_0x4852b7){const _0x57265f=a236_0x4a0432,_0x1ed0f2={},_0xbfa853={},_0x109014={'count':0x0,'rows':[]},_0xe910d9=_[_0x57265f(0x12a)](db['FaxInteraction']['rawAttributes'],function(_0x57917b){const _0x2053f3=_0x57265f;return{'name':_0x57917b[_0x2053f3(0x12b)],'type':_0x57917b[_0x2053f3(0x111)][_0x2053f3(0xf9)]};});_0xbfa853[_0x57265f(0x119)]=_['map'](_0xe910d9,_0x57265f(0x116)),_0xbfa853[_0x57265f(0x166)]=_[_0x57265f(0xe7)](_0x5445b0[_0x57265f(0x166)]),_0xbfa853['filters']=_[_0x57265f(0x121)](_0xbfa853[_0x57265f(0x119)],_0xbfa853[_0x57265f(0x166)]),_0x1ed0f2[_0x57265f(0x153)]=_[_0x57265f(0x121)](_0xbfa853[_0x57265f(0x119)],qs[_0x57265f(0x163)](_0x5445b0[_0x57265f(0x166)][_0x57265f(0x163)])),_0x1ed0f2[_0x57265f(0x153)]=_0x1ed0f2[_0x57265f(0x153)]['length']?_0x1ed0f2[_0x57265f(0x153)]:_0xbfa853[_0x57265f(0x119)];typeof _0x5445b0['query'][_0x57265f(0x14a)]==='undefined'&&(_0x1ed0f2[_0x57265f(0x186)]=qs[_0x57265f(0x186)](_0x5445b0['query'][_0x57265f(0x186)]),_0x1ed0f2['offset']=qs[_0x57265f(0x112)](_0x5445b0['query'][_0x57265f(0x112)]));_0x1ed0f2[_0x57265f(0x11c)]=qs['sort'](_0x5445b0[_0x57265f(0x166)][_0x57265f(0x176)]),_0x1ed0f2[_0x57265f(0xf3)]=qs[_0x57265f(0x17a)](_[_0x57265f(0x123)](_0x5445b0['query'],_0xbfa853[_0x57265f(0x17a)]),_0xe910d9);let _0x221248=[];const _0x2b0cc4=squel[_0x57265f(0x114)]()[_0x57265f(0x10a)]('id')['field'](_0x57265f(0x116))[_0x57265f(0x10a)](_0x57265f(0x140))[_0x57265f(0xdb)](_0x57265f(0xd3)),_0x219ab4=squel['select']()[_0x57265f(0x10a)](_0x57265f(0x151))[_0x57265f(0x10a)](_0x57265f(0x10e))[_0x57265f(0x10a)](_0x57265f(0x138))['from'](_0x57265f(0xdf),'ui')['left_join']('users','u',_0x57265f(0x108)),_0x44cb0d=squel['select']()['from'](_0x57265f(0xe4),'i')[_0x57265f(0xfe)](_0x57265f(0x14c),'c',_0x57265f(0x17c))[_0x57265f(0xfe)](_0x57265f(0x131),'o','o.id\x20=\x20i.UserId')[_0x57265f(0xfe)]('fax_accounts','a',_0x57265f(0x14e))[_0x57265f(0xfe)]('fax_messages','me',_0x57265f(0x13b))[_0x57265f(0xfe)](_0x57265f(0x17b),'it',_0x57265f(0x190))[_0x57265f(0xfe)](_0x57265f(0xd3),'t',_0x57265f(0xfa)),_0xf7d391=squel['expr']();let _0x232b4e=[];const _0x4cc765=squel['expr']();let _0x3b2543;if(_0x5445b0[_0x57265f(0x166)]['search']){_0x3b2543=as['parseSearch'](_0x5445b0[_0x57265f(0x166)][_0x57265f(0xed)]);const _0x4825f5=_0x3b2543[_0x57265f(0x139)];for(let _0x5aef9a=0x0;_0x5aef9a<_0x3b2543['conditions'][_0x57265f(0x118)];_0x5aef9a++){const _0x372334=_0x3b2543['conditions'][_0x5aef9a],_0x468100='i';let _0x3cdb21,_0x4e45f4=_[_0x57265f(0x106)](_0xe910d9,[_0x57265f(0x116),_0x372334['field']]);if(!_0x4e45f4)switch(_0x372334[_0x57265f(0x10a)]){case _0x57265f(0x18c):_0x372334[_0x57265f(0xff)]==0x1?_0x44cb0d['having']('`'+_0x372334['field']+_0x57265f(0x170)):_0x44cb0d[_0x57265f(0xec)]('`'+_0x372334[_0x57265f(0x10a)]+_0x57265f(0x14d));break;case _0x57265f(0x104):if(_0x372334['operator']===_0x57265f(0x169)){if(_0x372334[_0x57265f(0xff)][_0x57265f(0x16d)]('\x20')[_0x57265f(0x118)]>0x1)_0xf7d391[_0x4825f5](_0x57265f(0xd5),qs['getFullTextValue'](_0x372334[_0x57265f(0xff)]),null);else{const _0x592a88='%'+_0x372334[_0x57265f(0xff)]+'%';_0xf7d391[_0x4825f5](_0x57265f(0x156),_0x592a88,_0x592a88,_0x592a88);}}else _0x4e45f4=_[_0x57265f(0x106)](_0xe910d9,[_0x57265f(0x116),_0x57265f(0xf8)]),_0x372334[_0x57265f(0x10a)]=_0x57265f(0xf8),_0x3cdb21=as['buildExpression'](_0x468100,_0x4e45f4['type'],_0x372334),_0xf7d391[_0x4825f5](_0x3cdb21[_0x57265f(0x136)],_0x3cdb21[_0x57265f(0xff)][_0x57265f(0x13f)],_0x3cdb21[_0x57265f(0xff)][_0x57265f(0x155)]);break;case'Tag':{const _0x2ee7ba=_0x372334[_0x57265f(0xff)][_0x57265f(0x16d)](',')[_0x57265f(0x12a)](function(_0x473ed9){return Number(_0x473ed9);});_0x2ee7ba[_0x57265f(0xd7)](function(_0x3ee2a1){const _0x270aa3=_0x57265f;_0x4cc765['or'](_0x270aa3(0x174),'%,'+_0x3ee2a1+',%');}),_0x232b4e=_[_0x57265f(0x14f)](_0x232b4e,_0x2ee7ba);}break;case _0x57265f(0x13e):_0x372334[_0x57265f(0x173)]==='$substring'?_0xf7d391[_0x4825f5]('CONCAT_WS(\x27\x20\x27,\x20o.name,\x20o.fullname)\x20LIKE\x20?','%'+_0x372334[_0x57265f(0xff)]+'%',null):(_0x4e45f4=_[_0x57265f(0x106)](_0xe910d9,[_0x57265f(0x116),'UserId']),_0x372334[_0x57265f(0x10a)]='UserId',_0x3cdb21=as[_0x57265f(0x128)](_0x468100,_0x4e45f4['type'],_0x372334),_0xf7d391[_0x4825f5](_0x3cdb21[_0x57265f(0x136)],_0x3cdb21[_0x57265f(0xff)][_0x57265f(0x13f)],_0x3cdb21[_0x57265f(0xff)][_0x57265f(0x155)]));break;case _0x57265f(0x11d):_0x3cdb21=as['buildExpression']('me',null,_0x372334),_0xf7d391[_0x4825f5](_0x3cdb21[_0x57265f(0x136)],_0x3cdb21[_0x57265f(0xff)][_0x57265f(0x13f)],_0x3cdb21[_0x57265f(0xff)]['end']);break;}else _0x3cdb21=as[_0x57265f(0x128)](_0x468100,_0x4e45f4[_0x57265f(0x111)],_0x372334),_0xf7d391[_0x4825f5](_0x3cdb21[_0x57265f(0x136)],_0x3cdb21['value']['start'],_0x3cdb21[_0x57265f(0xff)]['end']);}}else{const _0x186520=_(_0x5445b0[_0x57265f(0x166)])['keys']()[_0x57265f(0x12a)](function(_0x32a8d1){const _0x3e521c=_0x57265f;return _[_0x3e521c(0xe0)](_0xe910d9,['name',_0x32a8d1])?_0x32a8d1:undefined;})[_0x57265f(0x182)]()[_0x57265f(0xff)]();!_[_0x57265f(0x137)](_0x186520)&&_0x186520[_0x57265f(0xd7)](function(_0x26445c){const _0x5b3911=_0x57265f;if(_0x26445c==='FaxAccountId')_0x44cb0d[_0x5b3911(0xf3)](_0x5b3911(0x12d),[][_0x5b3911(0x13c)](_0x5445b0['query'][_0x26445c]));else{if(_0x26445c===_0x5b3911(0x135)){const _0x21be8e=JSON['parse'](_0x5445b0[_0x5b3911(0x166)][_0x26445c])[_0x5b3911(0x188)],_0xaad766=JSON['parse'](_0x5445b0[_0x5b3911(0x166)][_0x26445c])['$lte'];_0x44cb0d[_0x5b3911(0xf3)](_0x5b3911(0xf6),_0x21be8e,_0xaad766);}else _0x5445b0[_0x5b3911(0x166)][_0x26445c]===_0x5b3911(0x12f)?_0x44cb0d['where']('i.'+_0x26445c+_0x5b3911(0xe5)):_0x44cb0d[_0x5b3911(0xf3)]('i.'+_0x26445c+_0x5b3911(0x179),_0x5445b0[_0x5b3911(0x166)][_0x26445c]);}});_0x5445b0[_0x57265f(0x166)][_0x57265f(0x164)]&&(_0x5445b0['query'][_0x57265f(0x164)]==0x1?_0x44cb0d[_0x57265f(0xec)](_0x57265f(0x189)):_0x44cb0d['having'](_0x57265f(0xee)));_0x5445b0[_0x57265f(0x166)]['tag']&&(_0x232b4e=_[_0x57265f(0x181)](_0x5445b0[_0x57265f(0x166)]['tag'])?_0x5445b0[_0x57265f(0x166)][_0x57265f(0x148)]:new Array(_0x5445b0['query'][_0x57265f(0x148)]),_0x232b4e['forEach'](function(_0x16df2c){_0x4cc765['or']('CONCAT(\x27,\x27,\x20`TagIds`,\x20\x27,\x27)\x20LIKE\x20?','%,'+_0x16df2c+',%');}));if(_0x5445b0[_0x57265f(0x166)][_0x57265f(0xfb)]){const _0x1d00b4=_0x5445b0[_0x57265f(0x166)]['filter'][_0x57265f(0x109)]('\x5c','\x5c\x5c')[_0x57265f(0x109)](/'/g,'\x27\x27');qs['isNumeric'](_0x1d00b4)&&_0xf7d391['or'](_0x57265f(0x10d),_0x1d00b4+'%')['or'](_0x57265f(0x18f),_0x1d00b4+'%'),_0xf7d391['or'](_0x57265f(0x150),_0x1d00b4+'%');}}_0x44cb0d['where'](_0xf7d391),_0x44cb0d[_0x57265f(0x183)](_0x57265f(0xf1));let _0x2ca420={'type':QueryTypes[_0x57265f(0x152)],'raw':!![]};const _0x45d083=_0x44cb0d['clone']();_0x45d083[_0x57265f(0x10a)](_0x57265f(0xf1)),_0x45d083['field'](_0x57265f(0x184),_0x57265f(0x18c)),_0x1ed0f2[_0x57265f(0x11c)]&&_0x1ed0f2[_0x57265f(0x11c)][_0x57265f(0xd7)](function(_0x2d016a){const _0x18327f=_0x57265f;_0x44cb0d[_0x18327f(0x11c)]('i.'+_0x2d016a[0x0],_0x2d016a[0x1]==='DESC'?![]:!![]);}),!_['isEmpty'](_0x232b4e)&&(_0x44cb0d['having'](_0x4cc765),_0x45d083[_0x57265f(0xf3)](_0x57265f(0xdc),_0x232b4e)),Promise[_0x57265f(0xf0)]()['then'](function(){const _0x267509=_0x57265f;if(!_0x3b2543){if(_0x5445b0['query'][_0x267509(0x129)]||_0x5445b0[_0x267509(0x166)][_0x267509(0xe9)])return;_0x45d083[_0x267509(0xf3)](_0x267509(0x113)),_0x44cb0d[_0x267509(0xf3)]('i.FaxAccountId\x20IS\x20NOT\x20NULL');return;}return _0x5445b0[_0x267509(0x134)][_0x267509(0xd8)]({'attributes':['id'],'raw':!![]})[_0x267509(0x172)](function(_0x191c1e){const _0x12c091=_0x267509;_[_0x12c091(0x137)](_0x191c1e)?(_0x45d083['where']('i.FaxAccountId\x20IS\x20NULL'),_0x44cb0d[_0x12c091(0xf3)](_0x12c091(0x180))):(_0x45d083[_0x12c091(0xf3)](_0x12c091(0x12d),_[_0x12c091(0x12a)](_0x191c1e,'id')),_0x44cb0d[_0x12c091(0xf3)](_0x12c091(0x12d),_[_0x12c091(0x12a)](_0x191c1e,'id')));});})[_0x57265f(0x172)](function(){const _0x5418c9=_0x57265f;db['sequelize']['query'](_0x45d083[_0x5418c9(0x101)](),_0x2ca420)[_0x5418c9(0x172)](function(_0x5a06bf){const _0x34a462=_0x5418c9;_0x109014[_0x34a462(0x142)]=_0x5a06bf[_0x34a462(0x118)];if(_0x109014['count']===0x0)return[];return db['sequelize'][_0x34a462(0x166)](_0x2b0cc4['toString'](),_0x2ca420)[_0x34a462(0x172)](function(_0x216428){const _0x442d8f=_0x34a462;_0x221248=_[_0x442d8f(0x144)](_0x216428,'id'),_0x2ca420=_['merge'](_0x2ca420,{'model':db[_0x442d8f(0x157)],'mapToModel':!![],'raw':!![],'nest':!![]});_0x5445b0[_0x442d8f(0x166)]['fields']?_0x1ed0f2[_0x442d8f(0x153)][_0x442d8f(0xd7)](function(_0x1d91c5){const _0x44d389=_0x442d8f;_0x44cb0d[_0x44d389(0x10a)]('i.'+_0x1d91c5);}):(_0x44cb0d[_0x442d8f(0x10a)](_0x442d8f(0x184),_0x442d8f(0x18c)),_0x44cb0d[_0x442d8f(0x10a)]('a.key','Account.key'),_0x44cb0d[_0x442d8f(0x10a)](_0x442d8f(0x10b),_0x442d8f(0x17e)),_0x44cb0d[_0x442d8f(0x10a)](_0x442d8f(0x187)),_0x44cb0d['field'](_0x442d8f(0x18d),_0x442d8f(0xe3)),_0x44cb0d[_0x442d8f(0x10a)](_0x442d8f(0x162),_0x442d8f(0xf7)),_0x44cb0d[_0x442d8f(0x10a)](_0x442d8f(0x130),_0x442d8f(0x147)),_0x44cb0d[_0x442d8f(0x10a)](_0x442d8f(0x18e),_0x442d8f(0x110)),_0x44cb0d[_0x442d8f(0x10a)](_0x442d8f(0x100),_0x442d8f(0x13d)),_0x44cb0d[_0x442d8f(0x10a)](_0x442d8f(0x193),_0x442d8f(0x191)),_0x44cb0d[_0x442d8f(0x10a)]('o.fullname','Owner.fullname'),_0x44cb0d[_0x442d8f(0x10a)](_0x442d8f(0x141),_0x442d8f(0x16f)),_0x44cb0d[_0x442d8f(0x10a)](_0x442d8f(0x117),_0x442d8f(0xfd)));if(_0x1ed0f2['limit'])_0x44cb0d[_0x442d8f(0x186)](_0x1ed0f2[_0x442d8f(0x186)]);if(_0x1ed0f2[_0x442d8f(0x112)])_0x44cb0d[_0x442d8f(0x112)](_0x1ed0f2[_0x442d8f(0x112)]);return db[_0x442d8f(0x143)][_0x442d8f(0x166)](_0x44cb0d['toString'](),_0x2ca420);})[_0x34a462(0x172)](function(_0x3833b8){const _0x17185f=_0x34a462;return _0x219ab4[_0x17185f(0xf3)](_0x17185f(0x12e),_['map'](_0x3833b8,'id')),db[_0x17185f(0x143)][_0x17185f(0x166)](_0x219ab4[_0x17185f(0x101)](),_0x2ca420)['then'](function(_0x43ed44){const _0x55eff8=_0x17185f,_0x21f429=_['groupBy'](_0x43ed44,'FaxInteractionId'),_0x29031a=[];return _0x3833b8[_0x55eff8(0xd7)](function(_0xa03dfe){const _0x8036ef=_0x55eff8;_0x29031a[_0x8036ef(0x165)](updateFaxInteraction(_0xa03dfe,_0x221248,_0x21f429));}),Promise[_0x55eff8(0x10c)](_0x29031a);});});})[_0x5418c9(0x172)](function(_0xd93896){const _0x1cc3aa=_0x5418c9;return _0x109014[_0x1cc3aa(0x11e)]=_0xd93896,_0x109014;})[_0x5418c9(0x172)](respondWithFilteredResult(_0x4852b7,_0x1ed0f2));})[_0x57265f(0x15c)](handleError(_0x4852b7,null));},exports[a236_0x4a0432(0x107)]=function(_0x58a180,_0x13ed56){const _0x4c2b5b=a236_0x4a0432;let _0x265c78={'raw':![],'where':{'id':_0x58a180[_0x4c2b5b(0x16a)]['id']}};const _0x1a8877={};return _0x1a8877[_0x4c2b5b(0x119)]=_[_0x4c2b5b(0xe7)](db[_0x4c2b5b(0x157)]['rawAttributes']),_0x1a8877[_0x4c2b5b(0x166)]=_[_0x4c2b5b(0xe7)](_0x58a180[_0x4c2b5b(0x166)]),_0x1a8877[_0x4c2b5b(0x17a)]=_[_0x4c2b5b(0x121)](_0x1a8877[_0x4c2b5b(0x119)],_0x1a8877['query']),_0x265c78[_0x4c2b5b(0x153)]=_[_0x4c2b5b(0x121)](_0x1a8877[_0x4c2b5b(0x119)],qs[_0x4c2b5b(0x163)](_0x58a180['query'][_0x4c2b5b(0x163)])),_0x265c78[_0x4c2b5b(0x153)]=_0x265c78['attributes'][_0x4c2b5b(0x118)]?_0x265c78[_0x4c2b5b(0x153)]:_0x1a8877[_0x4c2b5b(0x119)],_0x58a180[_0x4c2b5b(0x166)]['includeAll']&&(_0x265c78['include']=[{'all':!![]}]),_0x265c78=_[_0x4c2b5b(0x167)]({},_0x265c78,_0x58a180[_0x4c2b5b(0xe6)]),db[_0x4c2b5b(0x157)][_0x4c2b5b(0xe1)](_0x265c78)['then'](handleEntityNotFound(_0x13ed56,null))['then'](respondWithResult(_0x13ed56,null))[_0x4c2b5b(0x15c)](handleError(_0x13ed56,null));},exports[a236_0x4a0432(0x185)]=function(_0x39a2c8,_0x394fa3){const _0x2dd27a=a236_0x4a0432;return db[_0x2dd27a(0x157)][_0x2dd27a(0x185)](_0x39a2c8[_0x2dd27a(0x11d)],{})[_0x2dd27a(0x172)](respondWithResult(_0x394fa3,0xc9))[_0x2dd27a(0x15c)](handleError(_0x394fa3,null));},exports[a236_0x4a0432(0x175)]=function(_0x35a4c8,_0x292bfe){const _0x1c93c3=a236_0x4a0432;return _0x35a4c8[_0x1c93c3(0x11d)]['id']&&delete _0x35a4c8['body']['id'],db[_0x1c93c3(0x157)][_0x1c93c3(0xe1)]({'where':{'id':_0x35a4c8[_0x1c93c3(0x16a)]['id']}})[_0x1c93c3(0x172)](handleEntityNotFound(_0x292bfe,null))[_0x1c93c3(0x172)](saveUpdates(_0x35a4c8[_0x1c93c3(0x11d)],null))[_0x1c93c3(0x172)](respondWithResult(_0x292bfe,null))[_0x1c93c3(0x15c)](handleError(_0x292bfe,null));},exports[a236_0x4a0432(0xde)]=function(_0x422594,_0x276a0d){const _0x35af0d=a236_0x4a0432;return db[_0x35af0d(0x157)][_0x35af0d(0xe1)]({'where':{'id':_0x422594[_0x35af0d(0x16a)]['id']}})[_0x35af0d(0x172)](handleEntityNotFound(_0x276a0d,null))[_0x35af0d(0x172)](removeEntity(_0x276a0d,null))[_0x35af0d(0x15c)](handleError(_0x276a0d,null));},exports[a236_0x4a0432(0x11b)]=function(_0x566d86,_0xc9ad8c){const _0x4cccd9=a236_0x4a0432;return db[_0x4cccd9(0x157)][_0x4cccd9(0x11b)]()[_0x4cccd9(0x172)](respondWithResult(_0xc9ad8c,null))[_0x4cccd9(0x15c)](handleError(_0xc9ad8c,null));},exports[a236_0x4a0432(0x18b)]=function(_0x5aa698,_0x2bc863){const _0x214293=a236_0x4a0432;return db['FaxMessage'][_0x214293(0xe1)]({'where':{'id':_0x5aa698[_0x214293(0x16a)]['id']}})[_0x214293(0x172)](function(_0x5d6064){const _0x40c66b=_0x214293;if(_0x5d6064)return _0x5d6064[_0x40c66b(0x18b)](_0x5aa698[_0x40c66b(0x11d)][_0x40c66b(0x13a)],{'through':_['omit'](_0x5aa698[_0x40c66b(0x11d)],[_0x40c66b(0x13a),'id'])});})[_0x214293(0x172)](respondWithResult(_0x2bc863,null))['catch'](handleError(_0x2bc863,null));},exports[a236_0x4a0432(0x15f)]=function(_0x29935f,_0x1e9133){const _0x2593ed=a236_0x4a0432;let _0x4b1544={'raw':![],'where':{}};const _0x5cbf1c={},_0x1e72a6={'count':0x0,'rows':[]};return db[_0x2593ed(0x157)][_0x2593ed(0xe1)]({'where':{'id':_0x29935f[_0x2593ed(0x16a)]['id']}})[_0x2593ed(0x172)](handleEntityNotFound(_0x1e9133,null))[_0x2593ed(0x172)](function(_0x194105){const _0x1b8dd6=_0x2593ed;if(_0x194105){_0x5cbf1c[_0x1b8dd6(0x119)]=_[_0x1b8dd6(0xe7)](db[_0x1b8dd6(0x158)][_0x1b8dd6(0xd9)]),_0x5cbf1c[_0x1b8dd6(0x166)]=_[_0x1b8dd6(0xe7)](_0x29935f[_0x1b8dd6(0x166)]),_0x5cbf1c['filters']=_[_0x1b8dd6(0x121)](_0x5cbf1c[_0x1b8dd6(0x119)],_0x5cbf1c[_0x1b8dd6(0x166)]),_0x4b1544[_0x1b8dd6(0x153)]=_[_0x1b8dd6(0x121)](_0x5cbf1c[_0x1b8dd6(0x119)],qs['fields'](_0x29935f[_0x1b8dd6(0x166)][_0x1b8dd6(0x163)])),_0x4b1544['attributes']=_0x4b1544[_0x1b8dd6(0x153)][_0x1b8dd6(0x118)]?_0x4b1544[_0x1b8dd6(0x153)]:_0x5cbf1c['model'];typeof _0x29935f['query'][_0x1b8dd6(0x14a)]==='undefined'&&(_0x4b1544[_0x1b8dd6(0x186)]=qs[_0x1b8dd6(0x186)](_0x29935f[_0x1b8dd6(0x166)][_0x1b8dd6(0x186)]),_0x4b1544['offset']=qs['offset'](_0x29935f[_0x1b8dd6(0x166)][_0x1b8dd6(0x112)]));_0x4b1544[_0x1b8dd6(0x11c)]=qs[_0x1b8dd6(0x176)](_0x29935f[_0x1b8dd6(0x166)]['sort']),_0x4b1544[_0x1b8dd6(0xf3)]=qs[_0x1b8dd6(0x17a)](_[_0x1b8dd6(0x123)](_0x29935f[_0x1b8dd6(0x166)],_0x5cbf1c[_0x1b8dd6(0x17a)])),_0x4b1544[_0x1b8dd6(0xf3)][_0x1b8dd6(0xe2)]=_0x194105['id'];_0x29935f[_0x1b8dd6(0x166)][_0x1b8dd6(0xfb)]&&(_0x4b1544[_0x1b8dd6(0xf3)]=_[_0x1b8dd6(0x167)](_0x4b1544[_0x1b8dd6(0xf3)],{[Op['or']]:_[_0x1b8dd6(0x12a)](_0x4b1544['attributes'],function(_0x8cfa63){const _0x126ebc=_0x1b8dd6,_0x4e92e9={};return _0x4e92e9[_0x8cfa63]={[Op['like']]:'%'+_0x29935f[_0x126ebc(0x166)][_0x126ebc(0xfb)]+'%'},_0x4e92e9;})}));if(_0x29935f[_0x1b8dd6(0x166)][_0x1b8dd6(0x188)]){const _0x1a83f2=_0x29935f[_0x1b8dd6(0x166)][_0x1b8dd6(0x188)][_0x1b8dd6(0x16d)](','),_0x245c88={};_0x245c88[_0x1a83f2[0x0]]={[Op[_0x1b8dd6(0x12c)]]:moment(_0x1a83f2[0x1])[_0x1b8dd6(0x124)]('YYYY-MM-DD\x20HH:mm:ss')},_0x4b1544['where']=_['merge'](_0x4b1544['where'],_0x245c88);}return _0x4b1544=_[_0x1b8dd6(0x167)]({},_0x4b1544,_0x29935f[_0x1b8dd6(0xe6)]),db[_0x1b8dd6(0x158)][_0x1b8dd6(0x142)]({'where':_0x4b1544[_0x1b8dd6(0xf3)]})[_0x1b8dd6(0x172)](function(_0x51ff8b){const _0x17c696=_0x1b8dd6;return _0x1e72a6[_0x17c696(0x142)]=_0x51ff8b,_0x29935f[_0x17c696(0x166)][_0x17c696(0x10f)]&&(_0x4b1544['include']=[{'all':!![]}]),db[_0x17c696(0x158)][_0x17c696(0xdd)](_0x4b1544);})[_0x1b8dd6(0x172)](function(_0xc4a7a5){const _0x30d1ca=_0x1b8dd6;return _0x1e72a6[_0x30d1ca(0x11e)]=_0xc4a7a5,_0x1e72a6;});}})['then'](respondWithFilteredResult(_0x1e9133,_0x4b1544))['catch'](handleError(_0x1e9133,null));},exports[a236_0x4a0432(0x16e)]=function(_0x33401e,_0x4a3a1b){const _0x40616f=a236_0x4a0432;return db[_0x40616f(0x157)][_0x40616f(0xe1)]({'where':{'id':_0x33401e[_0x40616f(0x16a)]['id']}})[_0x40616f(0x172)](function(_0x3faa8f){const _0x42a469=_0x40616f;if(_0x3faa8f)return _0x3faa8f[_0x42a469(0xf2)](_0x33401e[_0x42a469(0x11d)][_0x42a469(0x13a)],{'through':_[_0x42a469(0x125)](_0x33401e[_0x42a469(0x11d)],[_0x42a469(0x13a),'id'])})['then'](function(){const _0x4ac73f=_0x42a469;return db[_0x4ac73f(0xd6)][_0x4ac73f(0xdd)]({'attributes':['id',_0x4ac73f(0x116),'color'],'where':{'id':_0x33401e['body']['ids']}});})[_0x42a469(0x172)](function(_0x304984){const _0x50cc88=_0x42a469;return socket['emit'](_0x50cc88(0x103),{'id':Number(_0x33401e['params']['id']),'tags':_0x304984||[]}),{'id':Number(_0x33401e['params']['id']),'tags':_0x304984||[]};});})['then'](respondWithResult(_0x4a3a1b,null))['catch'](handleError(_0x4a3a1b,null));},exports[a236_0x4a0432(0xf4)]=function(_0x39e160,_0x5bc7c2){const _0x391c4d=a236_0x4a0432;return db[_0x391c4d(0x157)][_0x391c4d(0xe1)]({'where':{'id':_0x39e160[_0x391c4d(0x16a)]['id']}})[_0x391c4d(0x172)](handleEntityNotFound(_0x5bc7c2,null))[_0x391c4d(0x172)](function(_0x94585a){const _0x78c53d=_0x391c4d;if(_0x94585a)return _0x94585a['removeTags'](_0x39e160[_0x78c53d(0x166)][_0x78c53d(0x13a)]);})[_0x391c4d(0x172)](respondWithStatusCode(_0x5bc7c2,null))['catch'](handleError(_0x5bc7c2,null));},exports['download']=function(_0x33769e,_0x360a59){const _0x232f29=a236_0x4a0432,_0x57d820=moment()[_0x232f29(0x16c)]()[_0x232f29(0x101)](),_0x1ecafb=path['join'](config[_0x232f29(0x192)],_0x232f29(0x17d),_0x232f29(0x161)),_0xdb4db0=path['join'](config['root'],_0x232f29(0x15e),_0x232f29(0x17d),'attachments'),_0x4d6027=path['join'](_0x1ecafb,_0x57d820),_0x13b89b=util['format'](_0x232f29(0x154),_0x33769e[_0x232f29(0x16a)]['id'],_0x57d820),_0x41f223=path['join'](_0x1ecafb,_0x13b89b),_0x2f2912=[];_0x2f2912['push']({'model':db[_0x232f29(0x15d)],'as':_0x232f29(0x15d),'raw':!![]});const _0xfd4b77=[{'model':db[_0x232f29(0x158)],'as':_0x232f29(0xe8),'attributes':['id',_0x232f29(0x11d),_0x232f29(0x135)],'include':_0x2f2912}];return db['FaxInteraction'][_0x232f29(0xe1)]({'where':{'id':_0x33769e['params']['id']},'include':_0xfd4b77})[_0x232f29(0x172)](handleEntityNotFound(_0x360a59,null))['then'](function(_0x4b7936){const _0x337d5c=_0x232f29;if(_0x4b7936&&_0x4b7936['Messages']){const _0x11625d=_0x4b7936[_0x337d5c(0xef)]({'plain':!![]});fs[_0x337d5c(0x168)](_0x4d6027);for(let _0x3df14a=0x0;_0x3df14a<_0x11625d['Messages'][_0x337d5c(0x118)];_0x3df14a++){const _0x14abf7=_0x11625d[_0x337d5c(0xe8)][_0x3df14a][_0x337d5c(0x15d)];if(_0x14abf7){const _0x29711d=path[_0x337d5c(0x133)](_0xdb4db0,_0x14abf7[_0x337d5c(0x145)]);fs[_0x337d5c(0x105)](_0x29711d)&&fs[_0x337d5c(0x102)](_0x29711d)[_0x337d5c(0xea)](fs[_0x337d5c(0xeb)](path['join'](_0x4d6027,_0x14abf7['basename'])));}}return Promise[_0x337d5c(0xf0)]()[_0x337d5c(0x172)](function(){const _0x4f846b=_0x337d5c;return new Promise(function(_0x248c0a,_0x3e9d29){zipdir(_0x4d6027,{'saveTo':_0x41f223},function(_0xf5fdfc,_0x17f441){if(_0xf5fdfc)return _0x3e9d29(_0xf5fdfc);return _0x248c0a(_0x17f441);});})[_0x4f846b(0x172)](function(){return new Promise(function(_0xa4e435,_0x4b5d55){rimraf(_0x4d6027,function(_0x3033ee){if(_0x3033ee)_0x4b5d55(_0x3033ee);return _0xa4e435();});});})[_0x4f846b(0x172)](function(){const _0x349b06=_0x4f846b;return _0x360a59[_0x349b06(0x15a)](_0x41f223,_0x13b89b,function(_0x4212d){const _0x6e8d5c=_0x349b06;_0x4212d?console[_0x6e8d5c(0x15b)](_0x6e8d5c(0xd4),_0x4212d):fs['unlinkSync'](_0x41f223);});});});}else return _0x360a59[_0x337d5c(0x115)](0xc8);})[_0x232f29(0x15c)](handleError(_0x360a59,null));};
\ No newline at end of file
+const a236_0x51c1=['then','i.*','keyBy','FaxInteraction','union','u.id\x20=\x20ui.UserId','faxInteractionTags:save','addTags','`unreadMessages`\x20>\x200','c.firstName\x20LIKE\x20?\x20OR\x20c.lastName\x20LIKE\x20?\x20OR\x20c.email\x20LIKE\x20?','../../config/logger','User','server','tag','user','TagIds','UserId','attributes','stack','\x20IS\x20NULL','value','files','params','merge','Content-Range','length','Contact.firstName','CONCAT(c.firstName,\x20\x27\x20\x27,\x20c.lastName)\x20LIKE\x20?','buildExpression','path','query','squel','format','describe','count','basename','Contact.fax','lodash','root','include','SUM(me.read\x20=\x200\x20AND\x20me.direction\x20=\x20\x27in\x27)','where','model','select','tmp','o.id\x20=\x20i.UserId','sendStatus','destroy','removeTags','a.key','t.id\x20=\x20it.TagId','Tags','i.FaxAccountId\x20IN\x20?','Tag','sqlOperator','Owner.fullname','conditions','forEach','clone','cm_contacts','map','isEmpty','parse','user_has_fax_interactions','util','mkdirSync','pick','read','contactName','from','omit','GROUP_CONCAT(DISTINCT\x20t.id)','body','c.phone','tools_tags','some','register','field','left_join','search','json','name','addMessage','createReadStream','fullname','$lte','includeAll','gte','ids','FaxInteractionId','groupBy','pipe','intersection','having','split','Owner.internal','concat','order','limit','../../mysqldb','keys','c.firstName','createdAt','Contact','status','findOne','CONCAT_WS(\x27\x20\x27,\x20o.name,\x20o.fullname)\x20LIKE\x20?','c.id\x20=\x20i.ContactId\x20AND\x20c.deletedAt\x20IS\x20NULL','Contact.phone','set','c.mobile','c.fax','Account.key','getFaxAccounts','SELECT','existsSync','u.id','fields','findAll','log','offset','create','setTags','`unreadMessages`\x20=\x200','i.id','end','Contact.lastName','me.FaxInteractionId\x20=\x20i.id','moment','sort','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','rows','MATCH\x20(c.firstName,\x20c.lastName,\x20c.phone,\x20c.mobile,\x20c.fax,\x20c.email)\x20AGAINST\x20(?\x20IN\x20BOOLEAN\x20MODE)','i.FaxAccountId\x20IS\x20NULL','like','undefined','rimraf','emit','send','index','i.id\x20LIKE\x20?','FaxMessage','options','nolimit','ui.FaxInteractionId','u.fullname','fax_interactions','isNumeric','parseSearch','catch','filter','unreadMessages','i.createdAt\x20BETWEEN\x20?\x20AND\x20?','Account.mandatoryDisposition','DESC','Users','c.lastName','a.mandatoryDisposition','CONCAT(\x27,\x27,\x20`TagIds`,\x20\x27,\x27)\x20LIKE\x20?','toString','error','rawAttributes','find','all','fax_interaction_has_tags','Messages','filters','getMessages','type','users','join','group','./faxInteraction.socket','unlinkSync','expr','fax_accounts','Attachment','FaxAccountId','color','createWriteStream','ContactId','text','YYYY-MM-DD\x20HH:mm:ss','$gte','i.fax\x20LIKE\x20?','i.FaxAccountId\x20IS\x20NOT\x20NULL','err','$substring','download','start','push','sequelize','update','unix'];(function(_0xa9f3a6,_0x54e12b){const _0x51c1cd=function(_0x35ce28){while(--_0x35ce28){_0xa9f3a6['push'](_0xa9f3a6['shift']());}};_0x51c1cd(++_0x54e12b);}(a236_0x51c1,0x1a6));const a236_0x35ce=function(_0xa9f3a6,_0x54e12b){_0xa9f3a6=_0xa9f3a6-0x1b8;let _0x51c1cd=a236_0x51c1[_0xa9f3a6];return _0x51c1cd;};const a236_0x1889ec=a236_0x35ce;'use strict';const rimraf=require(a236_0x1889ec(0x21e)),zipdir=require('zip-dir'),moment=require(a236_0x1889ec(0x216)),util=require(a236_0x1889ec(0x1d6)),path=require(a236_0x1889ec(0x275)),fs=require('fs'),_=require(a236_0x1889ec(0x1bb)),squel=require(a236_0x1889ec(0x277)),{getSocket}=require('../../rediscache'),socket=getSocket(),qs=require('../../components/parsers/qs'),as=require('../../components/parsers/advancedSearch'),logger=require(a236_0x1889ec(0x262))('api'),config=require('../../config/environment'),{db}=require(a236_0x1889ec(0x1f9)),{Op,QueryTypes}=require(a236_0x1889ec(0x255));require(a236_0x1889ec(0x242))[a236_0x1889ec(0x1e2)](socket);function respondWithStatusCode(_0x5a8735,_0xceed8a){return _0xceed8a=_0xceed8a||0xcc,function(_0x55b8df){const _0x57ae09=a236_0x35ce;if(_0x55b8df)return _0x5a8735[_0x57ae09(0x1c4)](_0xceed8a);return _0x5a8735[_0x57ae09(0x1fe)](_0xceed8a)['end']();};}function respondWithResult(_0x14b61a,_0x27dead){return _0x27dead=_0x27dead||0xc8,function(_0x5b68b8){const _0x52bf3e=a236_0x35ce;if(_0x5b68b8)return _0x14b61a['status'](_0x27dead)[_0x52bf3e(0x1e6)](_0x5b68b8);};}function respondWithFilteredResult(_0x26ab1e,_0x536905){return function(_0x391db9){const _0x1bf7a0=a236_0x35ce;if(_0x391db9){const _0x1e67d2=_0x391db9[_0x1bf7a0(0x1b8)],_0xa58aba=_0x536905[_0x1bf7a0(0x20e)];let _0x41c2c8=_0x536905[_0x1bf7a0(0x20e)]+_0x536905[_0x1bf7a0(0x1f8)],_0x2f7e0a;return _0x41c2c8>=_0x1e67d2?(_0x41c2c8=_0x1e67d2,_0x2f7e0a=0xc8):_0x2f7e0a=0xce,_0x26ab1e['status'](_0x2f7e0a),_0x26ab1e[_0x1bf7a0(0x203)](_0x1bf7a0(0x270),_0xa58aba+'-'+_0x41c2c8+'/'+_0x1e67d2)['json'](_0x391db9);}return null;};}function saveUpdates(_0x173fac){return function(_0x1d08c4){const _0x4d7644=a236_0x35ce;if(_0x1d08c4)return _0x1d08c4[_0x4d7644(0x256)](_0x173fac)[_0x4d7644(0x258)](function(_0x54be55){return _0x54be55;});return null;};}function removeEntity(_0x24b02e){return function(_0x2375bd){const _0x4eb5e6=a236_0x35ce;if(_0x2375bd)return _0x2375bd['destroy']()[_0x4eb5e6(0x258)](function(){const _0x4e8bd5=_0x4eb5e6;_0x24b02e[_0x4e8bd5(0x1fe)](0xcc)[_0x4e8bd5(0x213)]();});};}function handleEntityNotFound(_0x537695){return function(_0x1da9f9){const _0x32a832=a236_0x35ce;return!_0x1da9f9&&_0x537695[_0x32a832(0x1c4)](0x194),_0x1da9f9;};}function handleError(_0x1c7da8,_0x337283){return _0x337283=_0x337283||0x1f4,function(_0x46498d){const _0x53e7b7=a236_0x35ce;logger[_0x53e7b7(0x236)](_0x46498d[_0x53e7b7(0x26a)]),_0x46498d['name']&&delete _0x46498d['name'],_0x1c7da8[_0x53e7b7(0x1fe)](_0x337283)[_0x53e7b7(0x220)](_0x46498d);};}function getInteractionUsers(_0x393131,_0x3f214a){return new Promise(function(_0x542c7c,_0x37dd97){const _0xff50ca=a236_0x35ce;try{_0x3f214a[_0x393131['id']]&&(_0x393131[_0xff50ca(0x231)]=_[_0xff50ca(0x1d2)](_0x3f214a[_0x393131['id']],function(_0xeebdcb){const _0x120589=_0xff50ca;return{'id':_0xeebdcb['id'],'fullname':_0xeebdcb[_0x120589(0x1ea)]};}));}catch(_0x1ab0db){_0x37dd97(_0x1ab0db);}_0x542c7c(_0x393131);});}function getInteractionTags(_0x21d6d1,_0x3902bb){return new Promise(function(_0x1fbe22,_0x392552){const _0x22aeee=a236_0x35ce;try{_0x21d6d1[_0x22aeee(0x267)]&&(_0x21d6d1[_0x22aeee(0x1c9)]=[],_0x21d6d1['TagIds']['split'](',')[_0x22aeee(0x1cf)](function(_0x304bb4){const _0x255d1b=_0x22aeee;_0x21d6d1[_0x255d1b(0x1c9)][_0x255d1b(0x254)](_0x3902bb[_0x304bb4]);})),delete _0x21d6d1[_0x22aeee(0x267)];}catch(_0x5a5b2b){_0x392552(_0x5a5b2b);}_0x1fbe22(_0x21d6d1);});}function updateFaxInteraction(_0x2bd287,_0x47b996,_0x36a46d){return new Promise(function(_0x1e20a6,_0x1d47ea){const _0x61fa1e=a236_0x35ce;return getInteractionUsers(_0x2bd287,_0x36a46d)[_0x61fa1e(0x258)](function(_0x26f6da){return getInteractionTags(_0x26f6da,_0x47b996);})[_0x61fa1e(0x258)](function(_0x39fc7f){_0x1e20a6(_0x39fc7f);})[_0x61fa1e(0x22b)](function(_0x2b32fd){_0x1d47ea(_0x2b32fd);});});}exports[a236_0x1889ec(0x221)]=function(_0x1e9228,_0x929651){const _0x47d078=a236_0x1889ec,_0x4da129={},_0x1edf60={},_0x1af397={'count':0x0,'rows':[]},_0x1e7f2e=_['map'](db[_0x47d078(0x25b)][_0x47d078(0x237)],function(_0x748c39){return{'name':_0x748c39['fieldName'],'type':_0x748c39['type']['key']};});_0x1edf60[_0x47d078(0x1c0)]=_[_0x47d078(0x1d2)](_0x1e7f2e,_0x47d078(0x1e7)),_0x1edf60[_0x47d078(0x276)]=_[_0x47d078(0x1fa)](_0x1e9228[_0x47d078(0x276)]),_0x1edf60[_0x47d078(0x23c)]=_[_0x47d078(0x1f2)](_0x1edf60[_0x47d078(0x1c0)],_0x1edf60['query']),_0x4da129['attributes']=_[_0x47d078(0x1f2)](_0x1edf60['model'],qs[_0x47d078(0x20b)](_0x1e9228[_0x47d078(0x276)][_0x47d078(0x20b)])),_0x4da129[_0x47d078(0x269)]=_0x4da129[_0x47d078(0x269)][_0x47d078(0x271)]?_0x4da129[_0x47d078(0x269)]:_0x1edf60[_0x47d078(0x1c0)];typeof _0x1e9228[_0x47d078(0x276)][_0x47d078(0x225)]===_0x47d078(0x21d)&&(_0x4da129['limit']=qs[_0x47d078(0x1f8)](_0x1e9228[_0x47d078(0x276)][_0x47d078(0x1f8)]),_0x4da129[_0x47d078(0x20e)]=qs['offset'](_0x1e9228[_0x47d078(0x276)][_0x47d078(0x20e)]));_0x4da129['order']=qs['sort'](_0x1e9228[_0x47d078(0x276)][_0x47d078(0x217)]),_0x4da129[_0x47d078(0x1bf)]=qs[_0x47d078(0x23c)](_[_0x47d078(0x1d8)](_0x1e9228[_0x47d078(0x276)],_0x1edf60[_0x47d078(0x23c)]),_0x1e7f2e);let _0x5a4b32=[];const _0x43aa8d=squel['select']()['field']('id')['field'](_0x47d078(0x1e7))[_0x47d078(0x1e3)](_0x47d078(0x248))['from'](_0x47d078(0x1e0)),_0x35f580=squel[_0x47d078(0x1c1)]()[_0x47d078(0x1e3)](_0x47d078(0x20a))[_0x47d078(0x1e3)](_0x47d078(0x227))[_0x47d078(0x1e3)](_0x47d078(0x226))['from'](_0x47d078(0x1d5),'ui')['left_join'](_0x47d078(0x23f),'u',_0x47d078(0x25d)),_0x2c4120=squel[_0x47d078(0x1c1)]()[_0x47d078(0x1db)](_0x47d078(0x228),'i')['left_join'](_0x47d078(0x1d1),'c',_0x47d078(0x201))['left_join'](_0x47d078(0x23f),'o',_0x47d078(0x1c3))['left_join'](_0x47d078(0x245),'a','a.id\x20=\x20i.FaxAccountId')['left_join']('fax_messages','me',_0x47d078(0x215))[_0x47d078(0x1e4)](_0x47d078(0x23a),'it','it.FaxInteractionId\x20=\x20i.id')[_0x47d078(0x1e4)](_0x47d078(0x1e0),'t',_0x47d078(0x1c8)),_0x5c6def=squel[_0x47d078(0x244)]();let _0x3ed9ff=[];const _0x58b35d=squel['expr']();let _0xb45fb5;if(_0x1e9228[_0x47d078(0x276)][_0x47d078(0x1e5)]){_0xb45fb5=as[_0x47d078(0x22a)](_0x1e9228['query'][_0x47d078(0x1e5)]);const _0x4a19b8=_0xb45fb5[_0x47d078(0x1cc)];for(let _0x3a1e83=0x0;_0x3a1e83<_0xb45fb5[_0x47d078(0x1ce)][_0x47d078(0x271)];_0x3a1e83++){const _0x49080=_0xb45fb5['conditions'][_0x3a1e83],_0x3d6f3e='i';let _0x2173d8,_0x18cbf7=_['find'](_0x1e7f2e,[_0x47d078(0x1e7),_0x49080[_0x47d078(0x1e3)]]);if(!_0x18cbf7)switch(_0x49080[_0x47d078(0x1e3)]){case _0x47d078(0x22d):_0x49080[_0x47d078(0x26c)]==0x1?_0x2c4120[_0x47d078(0x1f3)]('`'+_0x49080[_0x47d078(0x1e3)]+'`\x20=\x200'):_0x2c4120[_0x47d078(0x1f3)]('`'+_0x49080[_0x47d078(0x1e3)]+'`\x20>\x200');break;case _0x47d078(0x1fd):if(_0x49080['operator']==='$substring'){if(_0x49080[_0x47d078(0x26c)][_0x47d078(0x1f4)]('\x20')['length']>0x1)_0x5c6def[_0x4a19b8](_0x47d078(0x21a),qs['getFullTextValue'](_0x49080['value']),null);else{const _0x3cc2ad='%'+_0x49080[_0x47d078(0x26c)]+'%';_0x5c6def[_0x4a19b8](_0x47d078(0x261),_0x3cc2ad,_0x3cc2ad,_0x3cc2ad);}}else _0x18cbf7=_['find'](_0x1e7f2e,['name',_0x47d078(0x24a)]),_0x49080[_0x47d078(0x1e3)]=_0x47d078(0x24a),_0x2173d8=as[_0x47d078(0x274)](_0x3d6f3e,_0x18cbf7['type'],_0x49080),_0x5c6def[_0x4a19b8](_0x2173d8[_0x47d078(0x24b)],_0x2173d8['value'][_0x47d078(0x253)],_0x2173d8[_0x47d078(0x26c)][_0x47d078(0x213)]);break;case _0x47d078(0x1cb):{const _0x2b346b=_0x49080[_0x47d078(0x26c)][_0x47d078(0x1f4)](',')[_0x47d078(0x1d2)](function(_0x5b9f72){return Number(_0x5b9f72);});_0x2b346b[_0x47d078(0x1cf)](function(_0x2b8d3d){const _0x5f0d30=_0x47d078;_0x58b35d['or'](_0x5f0d30(0x234),'%,'+_0x2b8d3d+',%');}),_0x3ed9ff=_[_0x47d078(0x25c)](_0x3ed9ff,_0x2b346b);}break;case _0x47d078(0x263):_0x49080['operator']===_0x47d078(0x251)?_0x5c6def[_0x4a19b8](_0x47d078(0x200),'%'+_0x49080[_0x47d078(0x26c)]+'%',null):(_0x18cbf7=_[_0x47d078(0x238)](_0x1e7f2e,[_0x47d078(0x1e7),_0x47d078(0x268)]),_0x49080[_0x47d078(0x1e3)]=_0x47d078(0x268),_0x2173d8=as[_0x47d078(0x274)](_0x3d6f3e,_0x18cbf7['type'],_0x49080),_0x5c6def[_0x4a19b8](_0x2173d8[_0x47d078(0x24b)],_0x2173d8['value'][_0x47d078(0x253)],_0x2173d8[_0x47d078(0x26c)]['end']));break;case _0x47d078(0x1de):_0x2173d8=as[_0x47d078(0x274)]('me',null,_0x49080),_0x5c6def[_0x4a19b8](_0x2173d8[_0x47d078(0x24b)],_0x2173d8[_0x47d078(0x26c)][_0x47d078(0x253)],_0x2173d8[_0x47d078(0x26c)][_0x47d078(0x213)]);break;}else _0x2173d8=as[_0x47d078(0x274)](_0x3d6f3e,_0x18cbf7[_0x47d078(0x23e)],_0x49080),_0x5c6def[_0x4a19b8](_0x2173d8['text'],_0x2173d8[_0x47d078(0x26c)][_0x47d078(0x253)],_0x2173d8[_0x47d078(0x26c)][_0x47d078(0x213)]);}}else{const _0x52f37d=_(_0x1e9228[_0x47d078(0x276)])['keys']()['map'](function(_0x914b9b){const _0x439285=_0x47d078;return _[_0x439285(0x1e1)](_0x1e7f2e,[_0x439285(0x1e7),_0x914b9b])?_0x914b9b:undefined;})['compact']()[_0x47d078(0x26c)]();!_[_0x47d078(0x1d3)](_0x52f37d)&&_0x52f37d[_0x47d078(0x1cf)](function(_0x25e2e1){const _0x12148c=_0x47d078;if(_0x25e2e1===_0x12148c(0x247))_0x2c4120[_0x12148c(0x1bf)]('i.FaxAccountId\x20IN\x20?',[][_0x12148c(0x1f6)](_0x1e9228['query'][_0x25e2e1]));else{if(_0x25e2e1==='createdAt'){const _0x4505a4=JSON[_0x12148c(0x1d4)](_0x1e9228[_0x12148c(0x276)][_0x25e2e1])[_0x12148c(0x24d)],_0x40b015=JSON[_0x12148c(0x1d4)](_0x1e9228[_0x12148c(0x276)][_0x25e2e1])[_0x12148c(0x1eb)];_0x2c4120['where'](_0x12148c(0x22e),_0x4505a4,_0x40b015);}else _0x1e9228[_0x12148c(0x276)][_0x25e2e1]==='null'?_0x2c4120[_0x12148c(0x1bf)]('i.'+_0x25e2e1+_0x12148c(0x26b)):_0x2c4120['where']('i.'+_0x25e2e1+'\x20=\x20?',_0x1e9228[_0x12148c(0x276)][_0x25e2e1]);}});_0x1e9228[_0x47d078(0x276)]['read']&&(_0x1e9228['query'][_0x47d078(0x1d9)]==0x1?_0x2c4120[_0x47d078(0x1f3)](_0x47d078(0x211)):_0x2c4120[_0x47d078(0x1f3)](_0x47d078(0x260)));_0x1e9228['query'][_0x47d078(0x265)]&&(_0x3ed9ff=_['isArray'](_0x1e9228[_0x47d078(0x276)][_0x47d078(0x265)])?_0x1e9228[_0x47d078(0x276)][_0x47d078(0x265)]:new Array(_0x1e9228[_0x47d078(0x276)][_0x47d078(0x265)]),_0x3ed9ff[_0x47d078(0x1cf)](function(_0x12a39d){const _0x5caa99=_0x47d078;_0x58b35d['or'](_0x5caa99(0x234),'%,'+_0x12a39d+',%');}));if(_0x1e9228['query'][_0x47d078(0x22c)]){const _0x62e204=_0x1e9228[_0x47d078(0x276)][_0x47d078(0x22c)]['replace']('\x5c','\x5c\x5c')['replace'](/'/g,'\x27\x27');qs[_0x47d078(0x229)](_0x62e204)&&_0x5c6def['or'](_0x47d078(0x222),_0x62e204+'%')['or'](_0x47d078(0x24e),_0x62e204+'%'),_0x5c6def['or'](_0x47d078(0x273),_0x62e204+'%');}}_0x2c4120['where'](_0x5c6def),_0x2c4120[_0x47d078(0x241)](_0x47d078(0x212));let _0x4dfabf={'type':QueryTypes[_0x47d078(0x208)],'raw':!![]};const _0x33b5da=_0x2c4120[_0x47d078(0x1d0)]();_0x33b5da['field'](_0x47d078(0x212)),_0x33b5da[_0x47d078(0x1e3)](_0x47d078(0x1be),_0x47d078(0x22d)),_0x4da129[_0x47d078(0x1f7)]&&_0x4da129[_0x47d078(0x1f7)][_0x47d078(0x1cf)](function(_0x5cb382){const _0x11455a=_0x47d078,_0x56c803=_0x5cb382[0x0]===_0x11455a(0x1da)?_0x5cb382[0x0]:'i.'+_0x5cb382[0x0];_0x2c4120[_0x11455a(0x1f7)](_0x56c803,_0x5cb382[0x1]===_0x11455a(0x230)?![]:!![]);}),!_[_0x47d078(0x1d3)](_0x3ed9ff)&&(_0x2c4120[_0x47d078(0x1f3)](_0x58b35d),_0x33b5da[_0x47d078(0x1bf)]('t.id\x20IN\x20?',_0x3ed9ff)),Promise['resolve']()[_0x47d078(0x258)](function(){const _0x552864=_0x47d078;if(!_0xb45fb5){if(_0x1e9228['query'][_0x552864(0x247)]||_0x1e9228[_0x552864(0x276)]['journey'])return;_0x33b5da[_0x552864(0x1bf)](_0x552864(0x24f)),_0x2c4120[_0x552864(0x1bf)](_0x552864(0x24f));return;}return _0x1e9228[_0x552864(0x266)][_0x552864(0x207)]({'attributes':['id'],'raw':!![]})[_0x552864(0x258)](function(_0x1c7a7e){const _0x4a16a6=_0x552864;_[_0x4a16a6(0x1d3)](_0x1c7a7e)?(_0x33b5da[_0x4a16a6(0x1bf)](_0x4a16a6(0x21b)),_0x2c4120[_0x4a16a6(0x1bf)](_0x4a16a6(0x21b))):(_0x33b5da[_0x4a16a6(0x1bf)](_0x4a16a6(0x1ca),_[_0x4a16a6(0x1d2)](_0x1c7a7e,'id')),_0x2c4120[_0x4a16a6(0x1bf)]('i.FaxAccountId\x20IN\x20?',_[_0x4a16a6(0x1d2)](_0x1c7a7e,'id')));});})[_0x47d078(0x258)](function(){const _0x12daf9=_0x47d078;db[_0x12daf9(0x255)][_0x12daf9(0x276)](_0x33b5da[_0x12daf9(0x235)](),_0x4dfabf)[_0x12daf9(0x258)](function(_0x42fa7b){const _0x6cca54=_0x12daf9;_0x1af397['count']=_0x42fa7b[_0x6cca54(0x271)];if(_0x1af397[_0x6cca54(0x1b8)]===0x0)return[];return db['sequelize'][_0x6cca54(0x276)](_0x43aa8d[_0x6cca54(0x235)](),_0x4dfabf)[_0x6cca54(0x258)](function(_0x438917){const _0x4715d4=_0x6cca54;_0x5a4b32=_[_0x4715d4(0x25a)](_0x438917,'id'),_0x4dfabf=_['merge'](_0x4dfabf,{'model':db[_0x4715d4(0x25b)],'mapToModel':!![],'raw':!![],'nest':!![]});_0x1e9228[_0x4715d4(0x276)][_0x4715d4(0x20b)]?_0x4da129['attributes'][_0x4715d4(0x1cf)](function(_0x5505c6){_0x2c4120['field']('i.'+_0x5505c6);}):(_0x2c4120[_0x4715d4(0x1e3)](_0x4715d4(0x1be),'unreadMessages'),_0x2c4120['field'](_0x4715d4(0x1c7),_0x4715d4(0x206)),_0x2c4120[_0x4715d4(0x1e3)](_0x4715d4(0x233),_0x4715d4(0x22f)),_0x2c4120[_0x4715d4(0x1e3)](_0x4715d4(0x218),_0x4715d4(0x1da)),_0x2c4120[_0x4715d4(0x1e3)](_0x4715d4(0x259)),_0x2c4120['field'](_0x4715d4(0x1fb),_0x4715d4(0x272)),_0x2c4120[_0x4715d4(0x1e3)](_0x4715d4(0x232),_0x4715d4(0x214)),_0x2c4120[_0x4715d4(0x1e3)]('c.email','Contact.email'),_0x2c4120[_0x4715d4(0x1e3)](_0x4715d4(0x1df),_0x4715d4(0x202)),_0x2c4120['field'](_0x4715d4(0x204),'Contact.mobile'),_0x2c4120[_0x4715d4(0x1e3)](_0x4715d4(0x205),_0x4715d4(0x1ba)),_0x2c4120['field']('o.fullname',_0x4715d4(0x1cd)),_0x2c4120[_0x4715d4(0x1e3)]('o.internal',_0x4715d4(0x1f5)),_0x2c4120[_0x4715d4(0x1e3)](_0x4715d4(0x1dd),'TagIds'));if(_0x4da129[_0x4715d4(0x1f8)])_0x2c4120['limit'](_0x4da129[_0x4715d4(0x1f8)]);if(_0x4da129[_0x4715d4(0x20e)])_0x2c4120['offset'](_0x4da129[_0x4715d4(0x20e)]);return db[_0x4715d4(0x255)][_0x4715d4(0x276)](_0x2c4120[_0x4715d4(0x235)](),_0x4dfabf);})[_0x6cca54(0x258)](function(_0xa68d92){const _0x3a90a2=_0x6cca54;return _0x35f580[_0x3a90a2(0x1bf)]('ui.FaxInteractionId\x20IN\x20?',_[_0x3a90a2(0x1d2)](_0xa68d92,'id')),db[_0x3a90a2(0x255)][_0x3a90a2(0x276)](_0x35f580[_0x3a90a2(0x235)](),_0x4dfabf)[_0x3a90a2(0x258)](function(_0x33fa96){const _0x41c8d2=_0x3a90a2,_0xe8e5f7=_[_0x41c8d2(0x1f0)](_0x33fa96,_0x41c8d2(0x1ef)),_0x307405=[];return _0xa68d92['forEach'](function(_0x140228){const _0xace3a5=_0x41c8d2;_0x307405[_0xace3a5(0x254)](updateFaxInteraction(_0x140228,_0x5a4b32,_0xe8e5f7));}),Promise[_0x41c8d2(0x239)](_0x307405);});});})[_0x12daf9(0x258)](function(_0x3e9ad1){const _0x52dfc1=_0x12daf9;return _0x1af397[_0x52dfc1(0x219)]=_0x3e9ad1,_0x1af397;})[_0x12daf9(0x258)](respondWithFilteredResult(_0x929651,_0x4da129));})[_0x47d078(0x22b)](handleError(_0x929651,null));},exports['show']=function(_0x2122e9,_0x2a89f4){const _0xdd0ce1=a236_0x1889ec;let _0x4197be={'raw':![],'where':{'id':_0x2122e9[_0xdd0ce1(0x26e)]['id']}};const _0x18dacd={};return _0x18dacd[_0xdd0ce1(0x1c0)]=_[_0xdd0ce1(0x1fa)](db[_0xdd0ce1(0x25b)][_0xdd0ce1(0x237)]),_0x18dacd[_0xdd0ce1(0x276)]=_[_0xdd0ce1(0x1fa)](_0x2122e9[_0xdd0ce1(0x276)]),_0x18dacd['filters']=_[_0xdd0ce1(0x1f2)](_0x18dacd[_0xdd0ce1(0x1c0)],_0x18dacd['query']),_0x4197be[_0xdd0ce1(0x269)]=_[_0xdd0ce1(0x1f2)](_0x18dacd[_0xdd0ce1(0x1c0)],qs[_0xdd0ce1(0x20b)](_0x2122e9[_0xdd0ce1(0x276)][_0xdd0ce1(0x20b)])),_0x4197be[_0xdd0ce1(0x269)]=_0x4197be[_0xdd0ce1(0x269)][_0xdd0ce1(0x271)]?_0x4197be[_0xdd0ce1(0x269)]:_0x18dacd[_0xdd0ce1(0x1c0)],_0x2122e9[_0xdd0ce1(0x276)][_0xdd0ce1(0x1ec)]&&(_0x4197be[_0xdd0ce1(0x1bd)]=[{'all':!![]}]),_0x4197be=_[_0xdd0ce1(0x26f)]({},_0x4197be,_0x2122e9['options']),db[_0xdd0ce1(0x25b)][_0xdd0ce1(0x1ff)](_0x4197be)[_0xdd0ce1(0x258)](handleEntityNotFound(_0x2a89f4,null))['then'](respondWithResult(_0x2a89f4,null))[_0xdd0ce1(0x22b)](handleError(_0x2a89f4,null));},exports[a236_0x1889ec(0x20f)]=function(_0x48f796,_0x1dc576){const _0x1d34c7=a236_0x1889ec;return db[_0x1d34c7(0x25b)]['create'](_0x48f796[_0x1d34c7(0x1de)],{})['then'](respondWithResult(_0x1dc576,0xc9))['catch'](handleError(_0x1dc576,null));},exports[a236_0x1889ec(0x256)]=function(_0x2454d1,_0x144425){const _0x3f6c42=a236_0x1889ec;return _0x2454d1[_0x3f6c42(0x1de)]['id']&&delete _0x2454d1[_0x3f6c42(0x1de)]['id'],db['FaxInteraction'][_0x3f6c42(0x1ff)]({'where':{'id':_0x2454d1[_0x3f6c42(0x26e)]['id']}})[_0x3f6c42(0x258)](handleEntityNotFound(_0x144425,null))[_0x3f6c42(0x258)](saveUpdates(_0x2454d1[_0x3f6c42(0x1de)],null))[_0x3f6c42(0x258)](respondWithResult(_0x144425,null))[_0x3f6c42(0x22b)](handleError(_0x144425,null));},exports[a236_0x1889ec(0x1c5)]=function(_0x517d48,_0x3f49cd){const _0x28c846=a236_0x1889ec;return db[_0x28c846(0x25b)][_0x28c846(0x1ff)]({'where':{'id':_0x517d48['params']['id']}})[_0x28c846(0x258)](handleEntityNotFound(_0x3f49cd,null))[_0x28c846(0x258)](removeEntity(_0x3f49cd,null))['catch'](handleError(_0x3f49cd,null));},exports[a236_0x1889ec(0x279)]=function(_0x2a7b05,_0x4d4d5b){const _0x2d6157=a236_0x1889ec;return db['FaxInteraction'][_0x2d6157(0x279)]()['then'](respondWithResult(_0x4d4d5b,null))['catch'](handleError(_0x4d4d5b,null));},exports[a236_0x1889ec(0x1e8)]=function(_0x493a3d,_0x24ff63){const _0x234f58=a236_0x1889ec;return db[_0x234f58(0x223)][_0x234f58(0x1ff)]({'where':{'id':_0x493a3d['params']['id']}})[_0x234f58(0x258)](function(_0x118bba){const _0x50ed5f=_0x234f58;if(_0x118bba)return _0x118bba[_0x50ed5f(0x1e8)](_0x493a3d[_0x50ed5f(0x1de)][_0x50ed5f(0x1ee)],{'through':_[_0x50ed5f(0x1dc)](_0x493a3d[_0x50ed5f(0x1de)],[_0x50ed5f(0x1ee),'id'])});})[_0x234f58(0x258)](respondWithResult(_0x24ff63,null))['catch'](handleError(_0x24ff63,null));},exports[a236_0x1889ec(0x23d)]=function(_0x5857be,_0x4af369){const _0x239584=a236_0x1889ec;let _0x2f4843={'raw':![],'where':{}};const _0x557f1e={},_0x963cf4={'count':0x0,'rows':[]};return db['FaxInteraction'][_0x239584(0x1ff)]({'where':{'id':_0x5857be['params']['id']}})[_0x239584(0x258)](handleEntityNotFound(_0x4af369,null))['then'](function(_0x25ed28){const _0x32f9f8=_0x239584;if(_0x25ed28){_0x557f1e['model']=_[_0x32f9f8(0x1fa)](db['FaxMessage'][_0x32f9f8(0x237)]),_0x557f1e['query']=_[_0x32f9f8(0x1fa)](_0x5857be[_0x32f9f8(0x276)]),_0x557f1e[_0x32f9f8(0x23c)]=_['intersection'](_0x557f1e[_0x32f9f8(0x1c0)],_0x557f1e[_0x32f9f8(0x276)]),_0x2f4843[_0x32f9f8(0x269)]=_['intersection'](_0x557f1e[_0x32f9f8(0x1c0)],qs[_0x32f9f8(0x20b)](_0x5857be[_0x32f9f8(0x276)][_0x32f9f8(0x20b)])),_0x2f4843[_0x32f9f8(0x269)]=_0x2f4843[_0x32f9f8(0x269)]['length']?_0x2f4843[_0x32f9f8(0x269)]:_0x557f1e[_0x32f9f8(0x1c0)];typeof _0x5857be[_0x32f9f8(0x276)][_0x32f9f8(0x225)]===_0x32f9f8(0x21d)&&(_0x2f4843[_0x32f9f8(0x1f8)]=qs[_0x32f9f8(0x1f8)](_0x5857be[_0x32f9f8(0x276)][_0x32f9f8(0x1f8)]),_0x2f4843[_0x32f9f8(0x20e)]=qs[_0x32f9f8(0x20e)](_0x5857be['query'][_0x32f9f8(0x20e)]));_0x2f4843[_0x32f9f8(0x1f7)]=qs[_0x32f9f8(0x217)](_0x5857be['query'][_0x32f9f8(0x217)]),_0x2f4843[_0x32f9f8(0x1bf)]=qs[_0x32f9f8(0x23c)](_[_0x32f9f8(0x1d8)](_0x5857be[_0x32f9f8(0x276)],_0x557f1e[_0x32f9f8(0x23c)])),_0x2f4843[_0x32f9f8(0x1bf)]['FaxInteractionId']=_0x25ed28['id'];_0x5857be[_0x32f9f8(0x276)][_0x32f9f8(0x22c)]&&(_0x2f4843['where']=_[_0x32f9f8(0x26f)](_0x2f4843[_0x32f9f8(0x1bf)],{[Op['or']]:_['map'](_0x2f4843[_0x32f9f8(0x269)],function(_0x41f65f){const _0x39c82c=_0x32f9f8,_0x2ca9d9={};return _0x2ca9d9[_0x41f65f]={[Op[_0x39c82c(0x21c)]]:'%'+_0x5857be['query'][_0x39c82c(0x22c)]+'%'},_0x2ca9d9;})}));if(_0x5857be['query'][_0x32f9f8(0x24d)]){const _0x21a602=_0x5857be[_0x32f9f8(0x276)]['$gte'][_0x32f9f8(0x1f4)](','),_0x2d0235={};_0x2d0235[_0x21a602[0x0]]={[Op[_0x32f9f8(0x1ed)]]:moment(_0x21a602[0x1])[_0x32f9f8(0x278)](_0x32f9f8(0x24c))},_0x2f4843[_0x32f9f8(0x1bf)]=_[_0x32f9f8(0x26f)](_0x2f4843[_0x32f9f8(0x1bf)],_0x2d0235);}return _0x2f4843=_[_0x32f9f8(0x26f)]({},_0x2f4843,_0x5857be[_0x32f9f8(0x224)]),db[_0x32f9f8(0x223)][_0x32f9f8(0x1b8)]({'where':_0x2f4843[_0x32f9f8(0x1bf)]})[_0x32f9f8(0x258)](function(_0x1d3fd5){const _0x5e295e=_0x32f9f8;return _0x963cf4[_0x5e295e(0x1b8)]=_0x1d3fd5,_0x5857be['query'][_0x5e295e(0x1ec)]&&(_0x2f4843['include']=[{'all':!![]}]),db['FaxMessage'][_0x5e295e(0x20c)](_0x2f4843);})[_0x32f9f8(0x258)](function(_0x379c90){const _0x30c4e0=_0x32f9f8;return _0x963cf4[_0x30c4e0(0x219)]=_0x379c90,_0x963cf4;});}})['then'](respondWithFilteredResult(_0x4af369,_0x2f4843))[_0x239584(0x22b)](handleError(_0x4af369,null));},exports[a236_0x1889ec(0x25f)]=function(_0x1373c2,_0x8dfd07){const _0x12a8a7=a236_0x1889ec;return db[_0x12a8a7(0x25b)][_0x12a8a7(0x1ff)]({'where':{'id':_0x1373c2[_0x12a8a7(0x26e)]['id']}})[_0x12a8a7(0x258)](function(_0x120a14){const _0x3d94c7=_0x12a8a7;if(_0x120a14)return _0x120a14[_0x3d94c7(0x210)](_0x1373c2[_0x3d94c7(0x1de)][_0x3d94c7(0x1ee)],{'through':_[_0x3d94c7(0x1dc)](_0x1373c2[_0x3d94c7(0x1de)],[_0x3d94c7(0x1ee),'id'])})['then'](function(){const _0x50ce20=_0x3d94c7;return db[_0x50ce20(0x1cb)][_0x50ce20(0x20c)]({'attributes':['id','name','color'],'where':{'id':_0x1373c2[_0x50ce20(0x1de)][_0x50ce20(0x1ee)]}});})[_0x3d94c7(0x258)](function(_0x5f137c){const _0x2fc952=_0x3d94c7;return socket[_0x2fc952(0x21f)](_0x2fc952(0x25e),{'id':Number(_0x1373c2['params']['id']),'tags':_0x5f137c||[]}),{'id':Number(_0x1373c2[_0x2fc952(0x26e)]['id']),'tags':_0x5f137c||[]};});})['then'](respondWithResult(_0x8dfd07,null))[_0x12a8a7(0x22b)](handleError(_0x8dfd07,null));},exports[a236_0x1889ec(0x1c6)]=function(_0x875506,_0x47d862){const _0x4d8c49=a236_0x1889ec;return db[_0x4d8c49(0x25b)]['findOne']({'where':{'id':_0x875506[_0x4d8c49(0x26e)]['id']}})[_0x4d8c49(0x258)](handleEntityNotFound(_0x47d862,null))[_0x4d8c49(0x258)](function(_0x553f9e){const _0x4a6c8c=_0x4d8c49;if(_0x553f9e)return _0x553f9e[_0x4a6c8c(0x1c6)](_0x875506[_0x4a6c8c(0x276)]['ids']);})[_0x4d8c49(0x258)](respondWithStatusCode(_0x47d862,null))[_0x4d8c49(0x22b)](handleError(_0x47d862,null));},exports[a236_0x1889ec(0x252)]=function(_0x33e498,_0x1e25a9){const _0x397175=a236_0x1889ec,_0x335f81=moment()[_0x397175(0x257)]()[_0x397175(0x235)](),_0x5df8f9=path['join'](config[_0x397175(0x1bc)],_0x397175(0x26d),_0x397175(0x1c2)),_0x255a0d=path[_0x397175(0x240)](config[_0x397175(0x1bc)],_0x397175(0x264),_0x397175(0x26d),'attachments'),_0x4f3492=path[_0x397175(0x240)](_0x5df8f9,_0x335f81),_0x542287=util[_0x397175(0x278)]('transcript-%d-%s.zip',_0x33e498[_0x397175(0x26e)]['id'],_0x335f81),_0x42a3a9=path['join'](_0x5df8f9,_0x542287),_0x2192d5=[];_0x2192d5[_0x397175(0x254)]({'model':db[_0x397175(0x246)],'as':_0x397175(0x246),'raw':!![]});const _0x566250=[{'model':db[_0x397175(0x223)],'as':_0x397175(0x23b),'attributes':['id',_0x397175(0x1de),_0x397175(0x1fc)],'include':_0x2192d5}];return db[_0x397175(0x25b)][_0x397175(0x1ff)]({'where':{'id':_0x33e498['params']['id']},'include':_0x566250})[_0x397175(0x258)](handleEntityNotFound(_0x1e25a9,null))['then'](function(_0x179a16){const _0x1acf19=_0x397175;if(_0x179a16&&_0x179a16[_0x1acf19(0x23b)]){const _0x3836d7=_0x179a16['get']({'plain':!![]});fs[_0x1acf19(0x1d7)](_0x4f3492);for(let _0x18b527=0x0;_0x18b527<_0x3836d7[_0x1acf19(0x23b)][_0x1acf19(0x271)];_0x18b527++){const _0x2f22bd=_0x3836d7[_0x1acf19(0x23b)][_0x18b527][_0x1acf19(0x246)];if(_0x2f22bd){const _0x500229=path[_0x1acf19(0x240)](_0x255a0d,_0x2f22bd[_0x1acf19(0x1b9)]);fs[_0x1acf19(0x209)](_0x500229)&&fs[_0x1acf19(0x1e9)](_0x500229)[_0x1acf19(0x1f1)](fs[_0x1acf19(0x249)](path[_0x1acf19(0x240)](_0x4f3492,_0x2f22bd[_0x1acf19(0x1b9)])));}}return Promise['resolve']()[_0x1acf19(0x258)](function(){const _0x248ab3=_0x1acf19;return new Promise(function(_0x432772,_0x2ccc9f){zipdir(_0x4f3492,{'saveTo':_0x42a3a9},function(_0x3829a1,_0x57e2ab){if(_0x3829a1)return _0x2ccc9f(_0x3829a1);return _0x432772(_0x57e2ab);});})[_0x248ab3(0x258)](function(){return new Promise(function(_0x5f1b04,_0x1a809d){rimraf(_0x4f3492,function(_0x1dead0){if(_0x1dead0)_0x1a809d(_0x1dead0);return _0x5f1b04();});});})[_0x248ab3(0x258)](function(){const _0x38810d=_0x248ab3;return _0x1e25a9[_0x38810d(0x252)](_0x42a3a9,_0x542287,function(_0x66cdd6){const _0x49d328=_0x38810d;_0x66cdd6?console[_0x49d328(0x20d)](_0x49d328(0x250),_0x66cdd6):fs[_0x49d328(0x243)](_0x42a3a9);});});});}else return _0x1e25a9[_0x1acf19(0x1c4)](0xc8);})[_0x397175(0x22b)](handleError(_0x1e25a9,null));};
\ No newline at end of file