Built motion from commit eddce310.|2.6.12
[motion2.git] / server / api / faxInteraction / faxInteraction.controller.js
index ea89b9c..7e7f3db 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x93f1=['conditions','find','unreadMessages','value','having','`\x20=\x200','Contact','$substring','getFullTextValue','c.firstName\x20LIKE\x20?\x20OR\x20c.lastName\x20LIKE\x20?\x20OR\x20c.email\x20LIKE\x20?','ContactId','buildExpression','type','text','start','forEach','CONCAT(\x27,\x27,\x20`TagIds`,\x20\x27,\x27)\x20LIKE\x20?','union','User','operator','isEmpty','FaxAccountId','i.FaxAccountId\x20IN\x20?','concat','createdAt','$gte','$lte','\x20IS\x20NULL','read','`unreadMessages`\x20=\x200','`unreadMessages`\x20>\x200','tag','isArray','filter','isNumeric','i.id\x20LIKE\x20?','i.fax\x20LIKE\x20?','group','i.id','Sequelize','QueryTypes','SELECT','clone','SUM(me.read\x20=\x200\x20AND\x20me.direction\x20=\x20\x27in\x27)','order','contactName','DESC','t.id\x20IN\x20?','resolve','i.FaxAccountId\x20IS\x20NOT\x20NULL','user','role','agent','getFaxAccounts','i.FaxAccountId\x20IS\x20NULL','sequelize','toString','count','keyBy','a.key','Account.key','a.mandatoryDisposition','CASE\x20WHEN\x20(c.firstName\x20IS\x20NOT\x20NULL\x20AND\x20c.firstName\x20<>\x20\x27\x27)\x20OR\x20(c.lastName\x20IS\x20NOT\x20NULL\x20AND\x20c.lastName\x20<>\x20\x27\x27)\x20THEN\x20CONCAT(IFNULL(c.firstName,\x20\x27\x27),\x20\x27\x20\x27,\x20IFNULL(c.lastName,\x20\x27\x27))\x20ELSE\x20\x27Unknown\x27\x20END','i.*','c.firstName','Contact.firstName','c.lastName','Contact.lastName','c.email','Contact.email','c.phone','Contact.phone','c.mobile','Contact.mobile','c.fax','Contact.fax','o.fullname','Owner.fullname','o.internal','Owner.internal','GROUP_CONCAT(DISTINCT\x20t.id)','ui.FaxInteractionId\x20IN\x20?','groupBy','FaxInteractionId','all','show','includeAll','include','merge','options','create','body','params','describe','addMessage','FaxMessage','ids','omit','getMessages','findOne','findAll','rows','spread','Tag','emit','removeTags','download','join','server','tmp','root','files','attachments','format','transcript-%d-%s.zip','Attachment','Messages','get','mkdirSync','basename','existsSync','pipe','createWriteStream','log','eml-format','zip-dir','fast-json-patch','request-promise','moment','mustache','to-csv','ejs','fs-extra','lodash','squel','crypto','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/utils','../../config/license/util','../../mysqldb','redis','defaults','localhost','./faxInteraction.socket','sendStatus','status','end','json','offset','undefined','limit','set','apply','save','update','then','destroy','error','stack','name','Users','map','TagIds','Tags','split','push','catch','waiting','talking','answered','unmanaged','total','closed','UserId','index','FaxInteraction','rawAttributes','fieldName','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','sort','where','pick','select','field','color','from','tools_tags','u.id','u.fullname','ui.FaxInteractionId','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','fax_accounts','a.id\x20=\x20i.FaxAccountId','fax_messages','fax_interaction_has_tags','it.FaxInteractionId\x20=\x20i.id','t.id\x20=\x20it.TagId','expr','search','parseSearch','sqlOperator'];(function(_0x20a584,_0xe384a5){var _0x4b41a8=function(_0x2127c6){while(--_0x2127c6){_0x20a584['push'](_0x20a584['shift']());}};_0x4b41a8(++_0xe384a5);}(_0x93f1,0x7c));var _0x193f=function(_0x181a31,_0xb6daa8){_0x181a31=_0x181a31-0x0;var _0x48bcf3=_0x93f1[_0x181a31];return _0x48bcf3;};'use strict';var emlformat=require(_0x193f('0x0'));var rimraf=require('rimraf');var zipdir=require(_0x193f('0x1'));var jsonpatch=require(_0x193f('0x2'));var rp=require(_0x193f('0x3'));var moment=require(_0x193f('0x4'));var BPromise=require('bluebird');var Mustache=require(_0x193f('0x5'));var util=require('util');var path=require('path');var sox=require('sox');var csv=require(_0x193f('0x6'));var ejs=require(_0x193f('0x7'));var fs=require('fs');var fs_extra=require(_0x193f('0x8'));var _=require(_0x193f('0x9'));var squel=require(_0x193f('0xa'));var crypto=require(_0x193f('0xb'));var jsforce=require('jsforce');var deskjs=require('desk.js');var toCsv=require(_0x193f('0x6'));var querystring=require(_0x193f('0xc'));var Papa=require(_0x193f('0xd'));var Redis=require('ioredis');var authService=require(_0x193f('0xe'));var qs=require(_0x193f('0xf'));var as=require(_0x193f('0x10'));var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')('api');var utils=require(_0x193f('0x11'));var config=require('../../config/environment');var licenseUtil=require(_0x193f('0x12'));var db=require(_0x193f('0x13'))['db'];config[_0x193f('0x14')]=_[_0x193f('0x15')](config[_0x193f('0x14')],{'host':_0x193f('0x16'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x193f('0x14')]));require(_0x193f('0x17'))['register'](socket);function respondWithStatusCode(_0x326aab,_0x48a34a){_0x48a34a=_0x48a34a||0xcc;return function(_0x5d741c){if(_0x5d741c){return _0x326aab[_0x193f('0x18')](_0x48a34a);}return _0x326aab[_0x193f('0x19')](_0x48a34a)[_0x193f('0x1a')]();};}function respondWithResult(_0x3f6939,_0x1cfd1c){_0x1cfd1c=_0x1cfd1c||0xc8;return function(_0x12e724){if(_0x12e724){return _0x3f6939['status'](_0x1cfd1c)[_0x193f('0x1b')](_0x12e724);}};}function respondWithFilteredResult(_0x88cbdc,_0x43b40a){return function(_0x87f629){if(_0x87f629){var _0x5ce051=typeof _0x43b40a[_0x193f('0x1c')]===_0x193f('0x1d')&&typeof _0x43b40a[_0x193f('0x1e')]===_0x193f('0x1d');var _0x1011b7=_0x87f629['count'];var _0x16d8b4=_0x5ce051?0x0:_0x43b40a[_0x193f('0x1c')];var _0x2010b8=_0x5ce051?_0x87f629['count']:_0x43b40a[_0x193f('0x1c')]+_0x43b40a[_0x193f('0x1e')];var _0x2b87b9;if(_0x2010b8>=_0x1011b7){_0x2010b8=_0x1011b7;_0x2b87b9=0xc8;}else{_0x2b87b9=0xce;}_0x88cbdc[_0x193f('0x19')](_0x2b87b9);return _0x88cbdc[_0x193f('0x1f')]('Content-Range',_0x16d8b4+'-'+_0x2010b8+'/'+_0x1011b7)[_0x193f('0x1b')](_0x87f629);}return null;};}function patchUpdates(_0x369379){return function(_0x7a4e68){try{jsonpatch[_0x193f('0x20')](_0x7a4e68,_0x369379,!![]);}catch(_0x3ad62e){return BPromise['reject'](_0x3ad62e);}return _0x7a4e68[_0x193f('0x21')]();};}function saveUpdates(_0x2bcc42,_0x57f0b6){return function(_0x9246e4){if(_0x9246e4){return _0x9246e4[_0x193f('0x22')](_0x2bcc42)[_0x193f('0x23')](function(_0x32899a){return _0x32899a;});}return null;};}function removeEntity(_0x2dbcca,_0x2b62a5){return function(_0x4b6840){if(_0x4b6840){return _0x4b6840[_0x193f('0x24')]()['then'](function(){_0x2dbcca[_0x193f('0x19')](0xcc)['end']();});}};}function handleEntityNotFound(_0x24cf2c,_0x1e0d4f){return function(_0x2b4c7c){if(!_0x2b4c7c){_0x24cf2c[_0x193f('0x18')](0x194);}return _0x2b4c7c;};}function handleError(_0x29866f,_0x5a0804){_0x5a0804=_0x5a0804||0x1f4;return function(_0xef9ea0){logger[_0x193f('0x25')](_0xef9ea0[_0x193f('0x26')]);if(_0xef9ea0[_0x193f('0x27')]){delete _0xef9ea0[_0x193f('0x27')];}_0x29866f[_0x193f('0x19')](_0x5a0804)['send'](_0xef9ea0);};}function getInteractionUsers(_0xbaab6,_0x40b3c3){return new BPromise(function(_0x5b812f,_0x46f164){try{if(_0x40b3c3[_0xbaab6['id']]){_0xbaab6[_0x193f('0x28')]=_[_0x193f('0x29')](_0x40b3c3[_0xbaab6['id']],function(_0x1c0062){return{'id':_0x1c0062['id'],'fullname':_0x1c0062['fullname']};});}}catch(_0x24e822){_0x46f164(_0x24e822);}_0x5b812f(_0xbaab6);});}function getInteractionTags(_0x2a9d21,_0x23efd2){return new BPromise(function(_0x132987,_0x484f61){try{if(_0x2a9d21[_0x193f('0x2a')]){_0x2a9d21[_0x193f('0x2b')]=[];_0x2a9d21[_0x193f('0x2a')][_0x193f('0x2c')](',')['forEach'](function(_0x4136e5){_0x2a9d21[_0x193f('0x2b')][_0x193f('0x2d')](_0x23efd2[_0x4136e5]);});}delete _0x2a9d21[_0x193f('0x2a')];}catch(_0x331b2a){_0x484f61(_0x331b2a);}_0x132987(_0x2a9d21);});}function updateFaxInteraction(_0x2f1f37,_0x160b32,_0x365246){return new BPromise(function(_0x25bbba,_0xcf43bf){return getInteractionUsers(_0x2f1f37,_0x365246)['then'](function(_0x1e32e1){return getInteractionTags(_0x1e32e1,_0x160b32);})[_0x193f('0x23')](function(_0x32e027){return getStateInteraction(_0x32e027);})[_0x193f('0x23')](function(_0x2c39a4){_0x25bbba(_0x2c39a4);})[_0x193f('0x2e')](function(_0x495a98){_0xcf43bf(_0x495a98);});});}function getStateInteraction(_0x5d22ec){return new BPromise(function(_0x4a2814){_0x5d22ec[_0x193f('0x2f')]=0x0;_0x5d22ec[_0x193f('0x30')]=0x0;_0x5d22ec[_0x193f('0x31')]=0x0;_0x5d22ec[_0x193f('0x32')]=0x0;_0x5d22ec[_0x193f('0x33')]=0x0;if(!_0x5d22ec[_0x193f('0x34')]&&!_0x5d22ec[_0x193f('0x35')]){_0x5d22ec['waiting']+=0x1;}if(!_0x5d22ec[_0x193f('0x34')]&&_0x5d22ec[_0x193f('0x35')]){_0x5d22ec[_0x193f('0x30')]+=0x1;if(_0x5d22ec[_0x193f('0x2f')]){_0x5d22ec[_0x193f('0x2f')]-=0x1;}}if(_0x5d22ec[_0x193f('0x34')]&&_0x5d22ec[_0x193f('0x35')]){_0x5d22ec[_0x193f('0x31')]+=0x1;if(_0x5d22ec[_0x193f('0x30')]){_0x5d22ec['talking']-=0x1;}}if(_0x5d22ec[_0x193f('0x34')]&&!_0x5d22ec['UserId']){_0x5d22ec[_0x193f('0x32')]+=0x1;if(_0x5d22ec['waiting']){_0x5d22ec[_0x193f('0x2f')]-=0x1;}}_0x5d22ec[_0x193f('0x33')]+=0x1;_0x4a2814(_0x5d22ec);});}exports[_0x193f('0x36')]=function(_0x2a3b20,_0x42e512){var _0x39f71d={},_0x53fb43={},_0x203afb={'count':0x0,'rows':[]};var _0x299c53=_[_0x193f('0x29')](db[_0x193f('0x37')][_0x193f('0x38')],function(_0x32b5d4){return{'name':_0x32b5d4[_0x193f('0x39')],'type':_0x32b5d4['type'][_0x193f('0x3a')]};});_0x53fb43[_0x193f('0x3b')]=_[_0x193f('0x29')](_0x299c53,_0x193f('0x27'));_0x53fb43[_0x193f('0x3c')]=_[_0x193f('0x3d')](_0x2a3b20['query']);_0x53fb43[_0x193f('0x3e')]=_[_0x193f('0x3f')](_0x53fb43[_0x193f('0x3b')],_0x53fb43['query']);_0x39f71d[_0x193f('0x40')]=_['intersection'](_0x53fb43[_0x193f('0x3b')],qs[_0x193f('0x41')](_0x2a3b20[_0x193f('0x3c')][_0x193f('0x41')]));_0x39f71d[_0x193f('0x40')]=_0x39f71d[_0x193f('0x40')][_0x193f('0x42')]?_0x39f71d['attributes']:_0x53fb43[_0x193f('0x3b')];if(!_0x2a3b20[_0x193f('0x3c')][_0x193f('0x43')](_0x193f('0x44'))){_0x39f71d['limit']=qs['limit'](_0x2a3b20[_0x193f('0x3c')]['limit']);_0x39f71d[_0x193f('0x1c')]=qs[_0x193f('0x1c')](_0x2a3b20[_0x193f('0x3c')][_0x193f('0x1c')]);}_0x39f71d['order']=qs['sort'](_0x2a3b20['query'][_0x193f('0x45')]);_0x39f71d[_0x193f('0x46')]=qs[_0x193f('0x3e')](_[_0x193f('0x47')](_0x2a3b20[_0x193f('0x3c')],_0x53fb43['filters']),_0x299c53);var _0x406e8f=[];var _0x31f72c=squel[_0x193f('0x48')]()[_0x193f('0x49')]('id')[_0x193f('0x49')](_0x193f('0x27'))['field'](_0x193f('0x4a'))[_0x193f('0x4b')](_0x193f('0x4c'));var _0x50e4a2=squel['select']()[_0x193f('0x49')](_0x193f('0x4d'))[_0x193f('0x49')](_0x193f('0x4e'))[_0x193f('0x49')](_0x193f('0x4f'))['from'](_0x193f('0x50'),'ui')[_0x193f('0x51')](_0x193f('0x52'),'u',_0x193f('0x53'));var _0x183727=squel[_0x193f('0x48')]()[_0x193f('0x4b')](_0x193f('0x54'),'i')['left_join'](_0x193f('0x55'),'c',_0x193f('0x56'))[_0x193f('0x51')]('users','o','o.id\x20=\x20i.UserId')[_0x193f('0x51')](_0x193f('0x57'),'a',_0x193f('0x58'))[_0x193f('0x51')](_0x193f('0x59'),'me','me.FaxInteractionId\x20=\x20i.id')[_0x193f('0x51')](_0x193f('0x5a'),'it',_0x193f('0x5b'))[_0x193f('0x51')](_0x193f('0x4c'),'t',_0x193f('0x5c'));var _0x33ec60=squel[_0x193f('0x5d')]();var _0x187825=[];var _0x354766=squel[_0x193f('0x5d')]();var _0x4da17b;if(_0x2a3b20[_0x193f('0x3c')][_0x193f('0x5e')]){_0x4da17b=as[_0x193f('0x5f')](_0x2a3b20['query'][_0x193f('0x5e')]);var _0x2db8ca=_0x4da17b[_0x193f('0x60')];for(var _0x2efb5a=0x0;_0x2efb5a<_0x4da17b[_0x193f('0x61')][_0x193f('0x42')];_0x2efb5a++){var _0x3431be=_0x4da17b[_0x193f('0x61')][_0x2efb5a];var _0xc312ac='i';var _0x5c6c6f=_[_0x193f('0x62')](_0x299c53,['name',_0x3431be[_0x193f('0x49')]]);if(!_0x5c6c6f){switch(_0x3431be[_0x193f('0x49')]){case _0x193f('0x63'):if(_0x3431be[_0x193f('0x64')]==0x1){_0x183727[_0x193f('0x65')]('`'+_0x3431be[_0x193f('0x49')]+_0x193f('0x66'));}else{_0x183727[_0x193f('0x65')]('`'+_0x3431be['field']+'`\x20>\x200');}break;case _0x193f('0x67'):if(_0x3431be['operator']===_0x193f('0x68')){if(_0x3431be[_0x193f('0x64')][_0x193f('0x2c')]('\x20')[_0x193f('0x42')]>0x1){_0x33ec60[_0x2db8ca]('MATCH\x20(c.firstName,\x20c.lastName,\x20c.phone,\x20c.mobile,\x20c.fax,\x20c.email)\x20AGAINST\x20(?\x20IN\x20BOOLEAN\x20MODE)',qs[_0x193f('0x69')](_0x3431be['value']),null);}else{var _0x570b03='%'+_0x3431be[_0x193f('0x64')]+'%';_0x33ec60[_0x2db8ca](_0x193f('0x6a'),_0x570b03,_0x570b03,_0x570b03);}}else{_0x5c6c6f=_[_0x193f('0x62')](_0x299c53,['name',_0x193f('0x6b')]);_0x3431be[_0x193f('0x49')]=_0x193f('0x6b');_0x7a80fd=as[_0x193f('0x6c')](_0xc312ac,_0x5c6c6f[_0x193f('0x6d')],_0x3431be);_0x33ec60[_0x2db8ca](_0x7a80fd[_0x193f('0x6e')],_0x7a80fd[_0x193f('0x64')][_0x193f('0x6f')],_0x7a80fd[_0x193f('0x64')][_0x193f('0x1a')]);}break;case'Tag':var _0x499edd=_0x3431be['value'][_0x193f('0x2c')](',')[_0x193f('0x29')](function(_0x4bc378){return Number(_0x4bc378);});_0x499edd[_0x193f('0x70')](function(_0x3d1c8c){_0x354766['or'](_0x193f('0x71'),'%,'+_0x3d1c8c+',%');});_0x187825=_[_0x193f('0x72')](_0x187825,_0x499edd);break;case _0x193f('0x73'):if(_0x3431be[_0x193f('0x74')]==='$substring'){_0x33ec60[_0x2db8ca]('CONCAT_WS(\x27\x20\x27,\x20o.name,\x20o.fullname)\x20LIKE\x20?','%'+_0x3431be[_0x193f('0x64')]+'%',null);}else{_0x5c6c6f=_[_0x193f('0x62')](_0x299c53,[_0x193f('0x27'),_0x193f('0x35')]);_0x3431be['field']=_0x193f('0x35');_0x7a80fd=as[_0x193f('0x6c')](_0xc312ac,_0x5c6c6f[_0x193f('0x6d')],_0x3431be);_0x33ec60[_0x2db8ca](_0x7a80fd[_0x193f('0x6e')],_0x7a80fd[_0x193f('0x64')][_0x193f('0x6f')],_0x7a80fd[_0x193f('0x64')][_0x193f('0x1a')]);}break;case'body':_0x7a80fd=as['buildExpression']('me',null,_0x3431be);_0x33ec60[_0x2db8ca](_0x7a80fd['text'],_0x7a80fd[_0x193f('0x64')]['start'],_0x7a80fd[_0x193f('0x64')][_0x193f('0x1a')]);break;}}else{var _0x7a80fd=as['buildExpression'](_0xc312ac,_0x5c6c6f[_0x193f('0x6d')],_0x3431be);_0x33ec60[_0x2db8ca](_0x7a80fd['text'],_0x7a80fd[_0x193f('0x64')][_0x193f('0x6f')],_0x7a80fd[_0x193f('0x64')]['end']);}}}else{var _0x14493e=_(_0x2a3b20[_0x193f('0x3c')])[_0x193f('0x3d')]()[_0x193f('0x29')](function(_0x4721fa){return _['some'](_0x299c53,[_0x193f('0x27'),_0x4721fa])?_0x4721fa:undefined;})['compact']()[_0x193f('0x64')]();if(!_[_0x193f('0x75')](_0x14493e)){_0x14493e[_0x193f('0x70')](function(_0x1c06db){if(_0x1c06db===_0x193f('0x76')){_0x183727[_0x193f('0x46')](_0x193f('0x77'),[][_0x193f('0x78')](_0x2a3b20[_0x193f('0x3c')][_0x1c06db]));}else if(_0x1c06db===_0x193f('0x79')){var _0x29fa2e=JSON['parse'](_0x2a3b20[_0x193f('0x3c')][_0x1c06db])[_0x193f('0x7a')];var _0x84ba5d=JSON['parse'](_0x2a3b20['query'][_0x1c06db])[_0x193f('0x7b')];_0x183727[_0x193f('0x46')]('i.createdAt\x20BETWEEN\x20?\x20AND\x20?',_0x29fa2e,_0x84ba5d);}else{if(_0x2a3b20[_0x193f('0x3c')][_0x1c06db]==='null'){_0x183727['where']('i.'+_0x1c06db+_0x193f('0x7c'));}else{_0x183727[_0x193f('0x46')]('i.'+_0x1c06db+'\x20=\x20?',_0x2a3b20[_0x193f('0x3c')][_0x1c06db]);}}});}if(_0x2a3b20[_0x193f('0x3c')][_0x193f('0x7d')]){if(_0x2a3b20[_0x193f('0x3c')][_0x193f('0x7d')]==0x1){_0x183727[_0x193f('0x65')](_0x193f('0x7e'));}else{_0x183727[_0x193f('0x65')](_0x193f('0x7f'));}}if(_0x2a3b20['query'][_0x193f('0x80')]){_0x187825=_[_0x193f('0x81')](_0x2a3b20[_0x193f('0x3c')][_0x193f('0x80')])?_0x2a3b20[_0x193f('0x3c')][_0x193f('0x80')]:new Array(_0x2a3b20[_0x193f('0x3c')]['tag']);_0x187825[_0x193f('0x70')](function(_0x3d4daa){_0x354766['or'](_0x193f('0x71'),'%,'+_0x3d4daa+',%');});}if(_0x2a3b20['query']['filter']){var _0x101ca1=_0x2a3b20[_0x193f('0x3c')][_0x193f('0x82')]['replace']('\x5c','\x5c\x5c')['replace'](/'/g,'\x27\x27');if(qs[_0x193f('0x83')](_0x101ca1)){_0x33ec60['or'](_0x193f('0x84'),_0x101ca1+'%')['or'](_0x193f('0x85'),_0x101ca1+'%');}_0x33ec60['or']('CONCAT(c.firstName,\x20\x27\x20\x27,\x20c.lastName)\x20LIKE\x20?',_0x101ca1+'%');}}_0x183727[_0x193f('0x46')](_0x33ec60);_0x183727[_0x193f('0x86')](_0x193f('0x87'));var _0x8c0056={'type':db[_0x193f('0x88')][_0x193f('0x89')][_0x193f('0x8a')],'raw':!![]};var _0x15fa51=_0x183727[_0x193f('0x8b')]();_0x15fa51[_0x193f('0x49')](_0x193f('0x87'));_0x15fa51[_0x193f('0x49')](_0x193f('0x8c'),_0x193f('0x63'));if(_0x39f71d['order']){_0x39f71d[_0x193f('0x8d')][_0x193f('0x70')](function(_0x580f18){var _0x10fb1e=_0x580f18[0x0]===_0x193f('0x8e')?_0x580f18[0x0]:'i.'+_0x580f18[0x0];_0x183727['order'](_0x10fb1e,_0x580f18[0x1]===_0x193f('0x8f')?![]:!![]);});}if(!_['isEmpty'](_0x187825)){_0x183727[_0x193f('0x65')](_0x354766);_0x15fa51[_0x193f('0x46')](_0x193f('0x90'),_0x187825);}BPromise[_0x193f('0x91')]()[_0x193f('0x23')](function(){if(!_0x4da17b){if(_0x2a3b20[_0x193f('0x3c')][_0x193f('0x76')])return;_0x15fa51[_0x193f('0x46')](_0x193f('0x92'));_0x183727['where']('i.FaxAccountId\x20IS\x20NOT\x20NULL');return;}if(_0x2a3b20[_0x193f('0x93')][_0x193f('0x94')]!==_0x193f('0x95'))return;return _0x2a3b20[_0x193f('0x93')][_0x193f('0x96')]({'attributes':['id'],'raw':!![]})[_0x193f('0x23')](function(_0x4be147){if(_['isEmpty'](_0x4be147)){_0x15fa51['where'](_0x193f('0x97'));_0x183727[_0x193f('0x46')]('i.FaxAccountId\x20IS\x20NULL');}else{_0x15fa51[_0x193f('0x46')](_0x193f('0x77'),_[_0x193f('0x29')](_0x4be147,'id'));_0x183727[_0x193f('0x46')](_0x193f('0x77'),_[_0x193f('0x29')](_0x4be147,'id'));}});})[_0x193f('0x23')](function(){if(_0x2a3b20[_0x193f('0x93')][_0x193f('0x94')]===_0x193f('0x95')&&!_0x4da17b&&!_0x2a3b20[_0x193f('0x3c')][_0x193f('0x76')])return[];return db[_0x193f('0x98')][_0x193f('0x3c')](_0x15fa51[_0x193f('0x99')](),_0x8c0056);})['then'](function(_0x6c384d){_0x203afb[_0x193f('0x9a')]=_0x6c384d[_0x193f('0x42')];if(_0x203afb[_0x193f('0x9a')]===0x0)return[];return db[_0x193f('0x98')][_0x193f('0x3c')](_0x31f72c['toString'](),_0x8c0056)[_0x193f('0x23')](function(_0x62b3bd){_0x406e8f=_[_0x193f('0x9b')](_0x62b3bd,'id');_0x8c0056=_['merge'](_0x8c0056,{'model':db[_0x193f('0x37')],'mapToModel':!![],'raw':!![],'nest':!![]});if(_0x2a3b20[_0x193f('0x3c')][_0x193f('0x41')]){_0x39f71d[_0x193f('0x40')][_0x193f('0x70')](function(_0x281e65){_0x183727['field']('i.'+_0x281e65);});}else{_0x183727[_0x193f('0x49')](_0x193f('0x8c'),_0x193f('0x63'));_0x183727[_0x193f('0x49')](_0x193f('0x9c'),_0x193f('0x9d'));_0x183727[_0x193f('0x49')](_0x193f('0x9e'),'Account.mandatoryDisposition');_0x183727[_0x193f('0x49')](_0x193f('0x9f'),_0x193f('0x8e'));_0x183727['field'](_0x193f('0xa0'));_0x183727[_0x193f('0x49')](_0x193f('0xa1'),_0x193f('0xa2'));_0x183727[_0x193f('0x49')](_0x193f('0xa3'),_0x193f('0xa4'));_0x183727[_0x193f('0x49')](_0x193f('0xa5'),_0x193f('0xa6'));_0x183727[_0x193f('0x49')](_0x193f('0xa7'),_0x193f('0xa8'));_0x183727[_0x193f('0x49')](_0x193f('0xa9'),_0x193f('0xaa'));_0x183727['field'](_0x193f('0xab'),_0x193f('0xac'));_0x183727[_0x193f('0x49')](_0x193f('0xad'),_0x193f('0xae'));_0x183727['field'](_0x193f('0xaf'),_0x193f('0xb0'));_0x183727[_0x193f('0x49')](_0x193f('0xb1'),_0x193f('0x2a'));}if(_0x39f71d[_0x193f('0x1e')])_0x183727[_0x193f('0x1e')](_0x39f71d['limit']);if(_0x39f71d['offset'])_0x183727[_0x193f('0x1c')](_0x39f71d[_0x193f('0x1c')]);return db['sequelize'][_0x193f('0x3c')](_0x183727['toString'](),_0x8c0056);})[_0x193f('0x23')](function(_0x307001){if(_0x307001[_0x193f('0x42')]>0x0)_0x50e4a2[_0x193f('0x46')](_0x193f('0xb2'),_[_0x193f('0x29')](_0x307001,'id'));return db['sequelize'][_0x193f('0x3c')](_0x50e4a2[_0x193f('0x99')](),_0x8c0056)[_0x193f('0x23')](function(_0x353df2){var _0x6781b7=_[_0x193f('0xb3')](_0x353df2,_0x193f('0xb4'));var _0x106921=[];_0x307001[_0x193f('0x70')](function(_0x5d9b2b){_0x106921['push'](updateFaxInteraction(_0x5d9b2b,_0x406e8f,_0x6781b7));});return BPromise[_0x193f('0xb5')](_0x106921);});});})[_0x193f('0x23')](function(_0x5390e){_0x203afb['rows']=_0x5390e;return _0x203afb;})[_0x193f('0x23')](respondWithFilteredResult(_0x42e512,_0x39f71d))[_0x193f('0x2e')](handleError(_0x42e512,null));};exports[_0x193f('0xb6')]=function(_0x37f8ef,_0x4fdbce){var _0x178a06={'raw':![],'where':{'id':_0x37f8ef['params']['id']}},_0x41ac26={};_0x41ac26[_0x193f('0x3b')]=_[_0x193f('0x3d')](db[_0x193f('0x37')][_0x193f('0x38')]);_0x41ac26[_0x193f('0x3c')]=_[_0x193f('0x3d')](_0x37f8ef[_0x193f('0x3c')]);_0x41ac26[_0x193f('0x3e')]=_['intersection'](_0x41ac26['model'],_0x41ac26[_0x193f('0x3c')]);_0x178a06['attributes']=_[_0x193f('0x3f')](_0x41ac26[_0x193f('0x3b')],qs['fields'](_0x37f8ef['query'][_0x193f('0x41')]));_0x178a06[_0x193f('0x40')]=_0x178a06['attributes']['length']?_0x178a06['attributes']:_0x41ac26[_0x193f('0x3b')];if(_0x37f8ef['query'][_0x193f('0xb7')]){_0x178a06[_0x193f('0xb8')]=[{'all':!![]}];}_0x178a06=_[_0x193f('0xb9')]({},_0x178a06,_0x37f8ef[_0x193f('0xba')]);return db[_0x193f('0x37')][_0x193f('0x62')](_0x178a06)[_0x193f('0x23')](handleEntityNotFound(_0x4fdbce,null))['then'](respondWithResult(_0x4fdbce,null))[_0x193f('0x2e')](handleError(_0x4fdbce,null));};exports[_0x193f('0xbb')]=function(_0x45966c,_0x450af3){return db[_0x193f('0x37')][_0x193f('0xbb')](_0x45966c[_0x193f('0xbc')],{})[_0x193f('0x23')](respondWithResult(_0x450af3,0xc9))[_0x193f('0x2e')](handleError(_0x450af3,null));};exports[_0x193f('0x22')]=function(_0x26dbf2,_0xb3f3d9){if(_0x26dbf2[_0x193f('0xbc')]['id']){delete _0x26dbf2[_0x193f('0xbc')]['id'];}return db[_0x193f('0x37')][_0x193f('0x62')]({'where':{'id':_0x26dbf2[_0x193f('0xbd')]['id']}})['then'](handleEntityNotFound(_0xb3f3d9,null))['then'](saveUpdates(_0x26dbf2[_0x193f('0xbc')],null))[_0x193f('0x23')](respondWithResult(_0xb3f3d9,null))[_0x193f('0x2e')](handleError(_0xb3f3d9,null));};exports['destroy']=function(_0xa81d39,_0x23c127){return db[_0x193f('0x37')]['find']({'where':{'id':_0xa81d39['params']['id']}})[_0x193f('0x23')](handleEntityNotFound(_0x23c127,null))['then'](removeEntity(_0x23c127,null))[_0x193f('0x2e')](handleError(_0x23c127,null));};exports[_0x193f('0xbe')]=function(_0x5cdd59,_0x5a413a){return db[_0x193f('0x37')][_0x193f('0xbe')]()[_0x193f('0x23')](respondWithResult(_0x5a413a,null))[_0x193f('0x2e')](handleError(_0x5a413a,null));};exports[_0x193f('0xbf')]=function(_0x40b7d0,_0x1dab40,_0x1c0ef5){return db[_0x193f('0xc0')][_0x193f('0x62')]({'where':{'id':_0x40b7d0[_0x193f('0xbd')]['id']}})[_0x193f('0x23')](handleEntityNotFound(_0x1dab40,null))[_0x193f('0x23')](function(_0x52233e){if(_0x52233e){return _0x52233e['addMessage'](_0x40b7d0['body'][_0x193f('0xc1')],_[_0x193f('0xc2')](_0x40b7d0[_0x193f('0xbc')],[_0x193f('0xc1'),'id'])||{});}})[_0x193f('0x23')](respondWithResult(_0x1dab40,null))[_0x193f('0x2e')](handleError(_0x1dab40,null));};exports[_0x193f('0xc3')]=function(_0x222321,_0x67c563,_0x5287b7){var _0x3afd57={'raw':![],'where':{}};var _0x2c482c={};var _0x1ad848={'count':0x0,'rows':[]};return db[_0x193f('0x37')][_0x193f('0xc4')]({'where':{'id':_0x222321[_0x193f('0xbd')]['id']}})[_0x193f('0x23')](handleEntityNotFound(_0x67c563,null))[_0x193f('0x23')](function(_0x3e986a){if(_0x3e986a){_0x2c482c[_0x193f('0x3b')]=_[_0x193f('0x3d')](db[_0x193f('0xc0')][_0x193f('0x38')]);_0x2c482c[_0x193f('0x3c')]=_[_0x193f('0x3d')](_0x222321['query']);_0x2c482c[_0x193f('0x3e')]=_['intersection'](_0x2c482c[_0x193f('0x3b')],_0x2c482c['query']);_0x3afd57['attributes']=_[_0x193f('0x3f')](_0x2c482c['model'],qs['fields'](_0x222321['query'][_0x193f('0x41')]));_0x3afd57[_0x193f('0x40')]=_0x3afd57[_0x193f('0x40')][_0x193f('0x42')]?_0x3afd57[_0x193f('0x40')]:_0x2c482c['model'];if(!_0x222321['query'][_0x193f('0x43')](_0x193f('0x44'))){_0x3afd57[_0x193f('0x1e')]=qs['limit'](_0x222321[_0x193f('0x3c')][_0x193f('0x1e')]);_0x3afd57[_0x193f('0x1c')]=qs[_0x193f('0x1c')](_0x222321[_0x193f('0x3c')][_0x193f('0x1c')]);}_0x3afd57[_0x193f('0x8d')]=qs[_0x193f('0x45')](_0x222321['query'][_0x193f('0x45')]);_0x3afd57['where']=qs[_0x193f('0x3e')](_[_0x193f('0x47')](_0x222321[_0x193f('0x3c')],_0x2c482c[_0x193f('0x3e')]));_0x3afd57['where'][_0x193f('0xb4')]=_0x3e986a['id'];if(_0x222321[_0x193f('0x3c')][_0x193f('0x82')]){_0x3afd57['where']=_[_0x193f('0xb9')](_0x3afd57['where'],{'$or':_['map'](_0x3afd57['attributes'],function(_0x322ae1){var _0x2b91c9={};_0x2b91c9[_0x322ae1]={'$like':'%'+_0x222321[_0x193f('0x3c')][_0x193f('0x82')]+'%'};return _0x2b91c9;})});}if(_0x222321[_0x193f('0x3c')][_0x193f('0x7a')]){var _0x3bb66f=_0x222321['query'][_0x193f('0x7a')][_0x193f('0x2c')](',');var _0x2a7e54={};_0x2a7e54[_0x3bb66f[0x0]]={'$gte':moment(_0x3bb66f[0x1])['format']('YYYY-MM-DD\x20HH:mm:ss')};_0x3afd57[_0x193f('0x46')]=_[_0x193f('0xb9')](_0x3afd57['where'],_0x2a7e54);}_0x3afd57=_[_0x193f('0xb9')]({},_0x3afd57,_0x222321[_0x193f('0xba')]);return db[_0x193f('0xc0')][_0x193f('0x9a')]({'where':_0x3afd57[_0x193f('0x46')]})['then'](function(_0x172e8c){_0x1ad848[_0x193f('0x9a')]=_0x172e8c;if(_0x222321['query']['includeAll']){_0x3afd57[_0x193f('0xb8')]=[{'all':!![]}];}return db[_0x193f('0xc0')][_0x193f('0xc5')](_0x3afd57);})[_0x193f('0x23')](function(_0x4c7750){_0x1ad848[_0x193f('0xc6')]=_0x4c7750;return _0x1ad848;});}})['then'](respondWithFilteredResult(_0x67c563,_0x3afd57))[_0x193f('0x2e')](handleError(_0x67c563,null));};exports['addTags']=function(_0xdbde76,_0xad9967,_0x4bfa8a){return db[_0x193f('0x37')][_0x193f('0x62')]({'where':{'id':_0xdbde76[_0x193f('0xbd')]['id']}})[_0x193f('0x23')](handleEntityNotFound(_0xad9967,null))[_0x193f('0x23')](function(_0x1be84b){if(_0x1be84b){return _0x1be84b['setTags'](_0xdbde76[_0x193f('0xbc')][_0x193f('0xc1')],_['omit'](_0xdbde76[_0x193f('0xbc')],[_0x193f('0xc1'),'id'])||{})[_0x193f('0xc7')](function(){return db[_0x193f('0xc8')][_0x193f('0xc5')]({'attributes':['id',_0x193f('0x27'),_0x193f('0x4a')],'where':{'id':_0xdbde76[_0x193f('0xbc')][_0x193f('0xc1')]}});})[_0x193f('0x23')](function(_0x13c6b8){socket[_0x193f('0xc9')]('faxInteractionTags:save',{'id':Number(_0xdbde76[_0x193f('0xbd')]['id']),'tags':_0x13c6b8||[]});return{'id':Number(_0xdbde76[_0x193f('0xbd')]['id']),'tags':_0x13c6b8||[]};});}})['then'](respondWithResult(_0xad9967,null))[_0x193f('0x2e')](handleError(_0xad9967,null));};exports[_0x193f('0xca')]=function(_0x32a6a7,_0x19b372,_0x316904){return db['FaxInteraction'][_0x193f('0x62')]({'where':{'id':_0x32a6a7[_0x193f('0xbd')]['id']}})[_0x193f('0x23')](handleEntityNotFound(_0x19b372,null))['then'](function(_0x21615e){if(_0x21615e){return _0x21615e[_0x193f('0xca')](_0x32a6a7[_0x193f('0x3c')][_0x193f('0xc1')]);}})[_0x193f('0x23')](respondWithStatusCode(_0x19b372,null))[_0x193f('0x2e')](handleError(_0x19b372,null));};exports[_0x193f('0xcb')]=function(_0x4dd885,_0x4ebd77){var _0x17f2de=moment()['unix']()[_0x193f('0x99')]();var _0x263134=path[_0x193f('0xcc')](config['root'],_0x193f('0xcd'),'files',_0x193f('0xce'));var _0x3a74e1=path['join'](config[_0x193f('0xcf')],_0x193f('0xcd'),_0x193f('0xd0'),_0x193f('0xd1'));var _0x594320=path[_0x193f('0xcc')](_0x263134,_0x17f2de);var _0x271f9f=util[_0x193f('0xd2')](_0x193f('0xd3'),_0x4dd885[_0x193f('0xbd')]['id'],_0x17f2de);var _0x3c06d8=path[_0x193f('0xcc')](_0x263134,_0x271f9f);var _0x43f1d0=[];_0x43f1d0[_0x193f('0x2d')]({'model':db[_0x193f('0xd4')],'as':_0x193f('0xd4'),'raw':!![]});var _0x372f07=[{'model':db['FaxMessage'],'as':_0x193f('0xd5'),'attributes':['id',_0x193f('0xbc'),_0x193f('0x79')],'include':_0x43f1d0}];return db['FaxInteraction'][_0x193f('0x62')]({'where':{'id':_0x4dd885[_0x193f('0xbd')]['id']},'include':_0x372f07})[_0x193f('0x23')](handleEntityNotFound(_0x4ebd77,null))[_0x193f('0x23')](function(_0x1e9026){if(_0x1e9026&&_0x1e9026['Messages']){var _0x156b96=_0x1e9026[_0x193f('0xd6')]({'plain':!![]});fs[_0x193f('0xd7')](_0x594320);for(var _0x524533=0x0;_0x524533<_0x156b96[_0x193f('0xd5')][_0x193f('0x42')];_0x524533++){var _0x12aff0=_0x156b96[_0x193f('0xd5')][_0x524533]['Attachment'];if(_0x12aff0){var _0x219882=path[_0x193f('0xcc')](_0x3a74e1,_0x12aff0[_0x193f('0xd8')]);if(fs[_0x193f('0xd9')](_0x219882)){fs['createReadStream'](_0x219882)[_0x193f('0xda')](fs[_0x193f('0xdb')](path[_0x193f('0xcc')](_0x594320,_0x12aff0[_0x193f('0xd8')])));}}}return BPromise[_0x193f('0x91')]()[_0x193f('0x23')](function(){return new BPromise(function(_0x48c744,_0x47b6c8){zipdir(_0x594320,{'saveTo':_0x3c06d8},function(_0x46d430,_0x9f775c){if(_0x46d430)return _0x47b6c8(_0x46d430);return _0x48c744(_0x9f775c);});})[_0x193f('0x23')](function(){return new BPromise(function(_0x5c2f8b,_0x3e86f2){rimraf(_0x594320,function(_0x4840ef){if(_0x4840ef)_0x3e86f2(_0x4840ef);return _0x5c2f8b();});});})[_0x193f('0x23')](function(){return _0x4ebd77[_0x193f('0xcb')](_0x3c06d8,_0x271f9f,function(_0x575d42){if(_0x575d42){console[_0x193f('0xdc')]('err',_0x575d42);}else{fs['unlinkSync'](_0x3c06d8);}});});});}else{return _0x4ebd77['sendStatus'](0xc8);}})[_0x193f('0x2e')](handleError(_0x4ebd77,null));};
\ No newline at end of file
+var _0x81cf=['undefined','limit','set','Content-Range','update','then','destroy','stack','name','send','index','FaxInteraction','rawAttributes','fieldName','type','key','fax','query','user','show','model','keys','filters','intersection','attributes','fields','length','includeAll','include','merge','options','catch','create','body','find','params','describe','addMessage','FaxMessage','ids','findOne','hasOwnProperty','nolimit','order','sort','pick','where','map','$gte','split','count','findAll','rows','addTags','setTags','omit','spread','Tag','color','faxInteractionTags:save','download','unix','join','root','server','files','tmp','attachments','format','transcript-%d-%s.zip','push','Attachment','createdAt','get','mkdirSync','Messages','basename','existsSync','createReadStream','createWriteStream','resolve','log','err','unlinkSync','rimraf','moment','util','path','lodash','ioredis','../../components/interaction/service','../../components/parsers/qs','../../config/logger','../../config/environment','defaults','localhost','socket.io-emitter','./faxInteraction.socket','sendStatus','end','status','json','offset'];(function(_0x41a3af,_0x35694d){var _0x2075ec=function(_0x36dffb){while(--_0x36dffb){_0x41a3af['push'](_0x41a3af['shift']());}};_0x2075ec(++_0x35694d);}(_0x81cf,0x1f0));var _0xf81c=function(_0x423edc,_0x1ec185){_0x423edc=_0x423edc-0x0;var _0x3d6101=_0x81cf[_0x423edc];return _0x3d6101;};'use strict';var rimraf=require(_0xf81c('0x0'));var zipdir=require('zip-dir');var moment=require(_0xf81c('0x1'));var BPromise=require('bluebird');var util=require(_0xf81c('0x2'));var path=require(_0xf81c('0x3'));var fs=require('fs');var _=require(_0xf81c('0x4'));var Redis=require(_0xf81c('0x5'));var interaction=require(_0xf81c('0x6'));var qs=require(_0xf81c('0x7'));var logger=require(_0xf81c('0x8'))('api');var config=require(_0xf81c('0x9'));var db=require('../../mysqldb')['db'];config['redis']=_[_0xf81c('0xa')](config['redis'],{'host':_0xf81c('0xb'),'port':0x18eb});var socket=require(_0xf81c('0xc'))(new Redis(config['redis']));require(_0xf81c('0xd'))['register'](socket);function respondWithStatusCode(_0x21a2b6,_0x5ae3db){_0x5ae3db=_0x5ae3db||0xcc;return function(_0x1fafb6){if(_0x1fafb6){return _0x21a2b6[_0xf81c('0xe')](_0x5ae3db);}return _0x21a2b6['status'](_0x5ae3db)[_0xf81c('0xf')]();};}function respondWithResult(_0x2adebb,_0x59ee9b){_0x59ee9b=_0x59ee9b||0xc8;return function(_0x40230b){if(_0x40230b){return _0x2adebb[_0xf81c('0x10')](_0x59ee9b)[_0xf81c('0x11')](_0x40230b);}};}function respondWithFilteredResult(_0x3470f0,_0x32e454){return function(_0x4756dd){if(_0x4756dd){var _0x594d4d=typeof _0x32e454[_0xf81c('0x12')]===_0xf81c('0x13')&&typeof _0x32e454[_0xf81c('0x14')]===_0xf81c('0x13');var _0x22ce73=_0x4756dd['count'];var _0x5528d5=_0x594d4d?0x0:_0x32e454[_0xf81c('0x12')];var _0x72f842=_0x594d4d?_0x4756dd['count']:_0x32e454[_0xf81c('0x12')]+_0x32e454[_0xf81c('0x14')];var _0x2ca4e2;if(_0x72f842>=_0x22ce73){_0x72f842=_0x22ce73;_0x2ca4e2=0xc8;}else{_0x2ca4e2=0xce;}_0x3470f0[_0xf81c('0x10')](_0x2ca4e2);return _0x3470f0[_0xf81c('0x15')](_0xf81c('0x16'),_0x5528d5+'-'+_0x72f842+'/'+_0x22ce73)[_0xf81c('0x11')](_0x4756dd);}return null;};}function saveUpdates(_0x2b339c){return function(_0x1fe6ad){if(_0x1fe6ad){return _0x1fe6ad[_0xf81c('0x17')](_0x2b339c)[_0xf81c('0x18')](function(_0x34f2a5){return _0x34f2a5;});}return null;};}function removeEntity(_0x2ce548){return function(_0x4dffa0){if(_0x4dffa0){return _0x4dffa0[_0xf81c('0x19')]()['then'](function(){_0x2ce548[_0xf81c('0x10')](0xcc)[_0xf81c('0xf')]();});}};}function handleEntityNotFound(_0x18df54){return function(_0x5aee2b){if(!_0x5aee2b){_0x18df54[_0xf81c('0xe')](0x194);}return _0x5aee2b;};}function handleError(_0x12eb16,_0x2f3b2f){_0x2f3b2f=_0x2f3b2f||0x1f4;return function(_0x4904ab){logger['error'](_0x4904ab[_0xf81c('0x1a')]);if(_0x4904ab[_0xf81c('0x1b')]){delete _0x4904ab[_0xf81c('0x1b')];}_0x12eb16[_0xf81c('0x10')](_0x2f3b2f)[_0xf81c('0x1c')](_0x4904ab);};}exports[_0xf81c('0x1d')]=function(_0x115265,_0x16dacd){var _0x270aaa={};var _0x207251=_['map'](db[_0xf81c('0x1e')][_0xf81c('0x1f')],function(_0x2438f4){return{'name':_0x2438f4[_0xf81c('0x20')],'type':_0x2438f4[_0xf81c('0x21')][_0xf81c('0x22')]};});_0x270aaa=qs['getOptions'](_0x207251,_0x115265);return interaction['findAll'](_0xf81c('0x23'),_0x115265[_0xf81c('0x24')],_0x115265[_0xf81c('0x25')],_0x270aaa,_0x207251)[_0xf81c('0x18')](respondWithFilteredResult(_0x16dacd,_0x270aaa))['catch'](handleError(_0x16dacd,null));};exports[_0xf81c('0x26')]=function(_0x5e0996,_0x118190){var _0x391501={'raw':![],'where':{'id':_0x5e0996['params']['id']}},_0x382a3b={};_0x382a3b[_0xf81c('0x27')]=_[_0xf81c('0x28')](db['FaxInteraction'][_0xf81c('0x1f')]);_0x382a3b['query']=_[_0xf81c('0x28')](_0x5e0996[_0xf81c('0x24')]);_0x382a3b[_0xf81c('0x29')]=_[_0xf81c('0x2a')](_0x382a3b[_0xf81c('0x27')],_0x382a3b['query']);_0x391501[_0xf81c('0x2b')]=_['intersection'](_0x382a3b[_0xf81c('0x27')],qs[_0xf81c('0x2c')](_0x5e0996[_0xf81c('0x24')][_0xf81c('0x2c')]));_0x391501[_0xf81c('0x2b')]=_0x391501[_0xf81c('0x2b')][_0xf81c('0x2d')]?_0x391501[_0xf81c('0x2b')]:_0x382a3b[_0xf81c('0x27')];if(_0x5e0996[_0xf81c('0x24')][_0xf81c('0x2e')]){_0x391501[_0xf81c('0x2f')]=[{'all':!![]}];}_0x391501=_[_0xf81c('0x30')]({},_0x391501,_0x5e0996[_0xf81c('0x31')]);return db[_0xf81c('0x1e')]['find'](_0x391501)[_0xf81c('0x18')](handleEntityNotFound(_0x118190,null))[_0xf81c('0x18')](respondWithResult(_0x118190,null))[_0xf81c('0x32')](handleError(_0x118190,null));};exports[_0xf81c('0x33')]=function(_0x40b77c,_0x37ced1){return db[_0xf81c('0x1e')][_0xf81c('0x33')](_0x40b77c[_0xf81c('0x34')],{})[_0xf81c('0x18')](respondWithResult(_0x37ced1,0xc9))[_0xf81c('0x32')](handleError(_0x37ced1,null));};exports['update']=function(_0x1663af,_0x19b56f){if(_0x1663af['body']['id']){delete _0x1663af[_0xf81c('0x34')]['id'];}return db['FaxInteraction'][_0xf81c('0x35')]({'where':{'id':_0x1663af[_0xf81c('0x36')]['id']}})[_0xf81c('0x18')](handleEntityNotFound(_0x19b56f,null))[_0xf81c('0x18')](saveUpdates(_0x1663af[_0xf81c('0x34')],null))[_0xf81c('0x18')](respondWithResult(_0x19b56f,null))[_0xf81c('0x32')](handleError(_0x19b56f,null));};exports['destroy']=function(_0x2afdf2,_0x58eebe){return db['FaxInteraction'][_0xf81c('0x35')]({'where':{'id':_0x2afdf2[_0xf81c('0x36')]['id']}})[_0xf81c('0x18')](handleEntityNotFound(_0x58eebe,null))[_0xf81c('0x18')](removeEntity(_0x58eebe,null))[_0xf81c('0x32')](handleError(_0x58eebe,null));};exports[_0xf81c('0x37')]=function(_0x14b1a5,_0x5eb873){return db[_0xf81c('0x1e')][_0xf81c('0x37')]()[_0xf81c('0x18')](respondWithResult(_0x5eb873,null))[_0xf81c('0x32')](handleError(_0x5eb873,null));};exports[_0xf81c('0x38')]=function(_0x5c7111,_0x4e6953){return db[_0xf81c('0x39')]['find']({'where':{'id':_0x5c7111[_0xf81c('0x36')]['id']}})['then'](handleEntityNotFound(_0x4e6953,null))[_0xf81c('0x18')](function(_0x54fff7){if(_0x54fff7){return _0x54fff7[_0xf81c('0x38')](_0x5c7111[_0xf81c('0x34')][_0xf81c('0x3a')],_['omit'](_0x5c7111[_0xf81c('0x34')],['ids','id'])||{});}})[_0xf81c('0x18')](respondWithResult(_0x4e6953,null))[_0xf81c('0x32')](handleError(_0x4e6953,null));};exports['getMessages']=function(_0x395ea3,_0xb7a94c){var _0x12c6c7={'raw':![],'where':{}};var _0x4e58b5={};var _0xb8b846={'count':0x0,'rows':[]};return db[_0xf81c('0x1e')][_0xf81c('0x3b')]({'where':{'id':_0x395ea3['params']['id']}})['then'](handleEntityNotFound(_0xb7a94c,null))['then'](function(_0x3cb87e){if(_0x3cb87e){_0x4e58b5[_0xf81c('0x27')]=_[_0xf81c('0x28')](db[_0xf81c('0x39')][_0xf81c('0x1f')]);_0x4e58b5['query']=_[_0xf81c('0x28')](_0x395ea3[_0xf81c('0x24')]);_0x4e58b5[_0xf81c('0x29')]=_[_0xf81c('0x2a')](_0x4e58b5[_0xf81c('0x27')],_0x4e58b5[_0xf81c('0x24')]);_0x12c6c7[_0xf81c('0x2b')]=_[_0xf81c('0x2a')](_0x4e58b5[_0xf81c('0x27')],qs['fields'](_0x395ea3[_0xf81c('0x24')][_0xf81c('0x2c')]));_0x12c6c7[_0xf81c('0x2b')]=_0x12c6c7[_0xf81c('0x2b')][_0xf81c('0x2d')]?_0x12c6c7[_0xf81c('0x2b')]:_0x4e58b5[_0xf81c('0x27')];if(!_0x395ea3[_0xf81c('0x24')][_0xf81c('0x3c')](_0xf81c('0x3d'))){_0x12c6c7[_0xf81c('0x14')]=qs[_0xf81c('0x14')](_0x395ea3[_0xf81c('0x24')][_0xf81c('0x14')]);_0x12c6c7[_0xf81c('0x12')]=qs[_0xf81c('0x12')](_0x395ea3[_0xf81c('0x24')][_0xf81c('0x12')]);}_0x12c6c7[_0xf81c('0x3e')]=qs[_0xf81c('0x3f')](_0x395ea3[_0xf81c('0x24')][_0xf81c('0x3f')]);_0x12c6c7['where']=qs[_0xf81c('0x29')](_[_0xf81c('0x40')](_0x395ea3[_0xf81c('0x24')],_0x4e58b5[_0xf81c('0x29')]));_0x12c6c7['where']['FaxInteractionId']=_0x3cb87e['id'];if(_0x395ea3['query']['filter']){_0x12c6c7[_0xf81c('0x41')]=_[_0xf81c('0x30')](_0x12c6c7[_0xf81c('0x41')],{'$or':_[_0xf81c('0x42')](_0x12c6c7[_0xf81c('0x2b')],function(_0x45d1dd){var _0x3fac6e={};_0x3fac6e[_0x45d1dd]={'$like':'%'+_0x395ea3[_0xf81c('0x24')]['filter']+'%'};return _0x3fac6e;})});}if(_0x395ea3[_0xf81c('0x24')]['$gte']){var _0x283b00=_0x395ea3[_0xf81c('0x24')][_0xf81c('0x43')][_0xf81c('0x44')](',');var _0x54f0b9={};_0x54f0b9[_0x283b00[0x0]]={'$gte':moment(_0x283b00[0x1])['format']('YYYY-MM-DD\x20HH:mm:ss')};_0x12c6c7[_0xf81c('0x41')]=_[_0xf81c('0x30')](_0x12c6c7['where'],_0x54f0b9);}_0x12c6c7=_[_0xf81c('0x30')]({},_0x12c6c7,_0x395ea3['options']);return db[_0xf81c('0x39')][_0xf81c('0x45')]({'where':_0x12c6c7[_0xf81c('0x41')]})['then'](function(_0x8814af){_0xb8b846['count']=_0x8814af;if(_0x395ea3[_0xf81c('0x24')]['includeAll']){_0x12c6c7[_0xf81c('0x2f')]=[{'all':!![]}];}return db[_0xf81c('0x39')][_0xf81c('0x46')](_0x12c6c7);})[_0xf81c('0x18')](function(_0x1bcf6a){_0xb8b846[_0xf81c('0x47')]=_0x1bcf6a;return _0xb8b846;});}})[_0xf81c('0x18')](respondWithFilteredResult(_0xb7a94c,_0x12c6c7))[_0xf81c('0x32')](handleError(_0xb7a94c,null));};exports[_0xf81c('0x48')]=function(_0x3b7a9f,_0x44dadd){return db[_0xf81c('0x1e')][_0xf81c('0x35')]({'where':{'id':_0x3b7a9f[_0xf81c('0x36')]['id']}})[_0xf81c('0x18')](handleEntityNotFound(_0x44dadd,null))[_0xf81c('0x18')](function(_0x277598){if(_0x277598){return _0x277598[_0xf81c('0x49')](_0x3b7a9f[_0xf81c('0x34')][_0xf81c('0x3a')],_[_0xf81c('0x4a')](_0x3b7a9f[_0xf81c('0x34')],[_0xf81c('0x3a'),'id'])||{})[_0xf81c('0x4b')](function(){return db[_0xf81c('0x4c')]['findAll']({'attributes':['id',_0xf81c('0x1b'),_0xf81c('0x4d')],'where':{'id':_0x3b7a9f['body'][_0xf81c('0x3a')]}});})[_0xf81c('0x18')](function(_0x27abee){socket['emit'](_0xf81c('0x4e'),{'id':Number(_0x3b7a9f[_0xf81c('0x36')]['id']),'tags':_0x27abee||[]});return{'id':Number(_0x3b7a9f[_0xf81c('0x36')]['id']),'tags':_0x27abee||[]};});}})[_0xf81c('0x18')](respondWithResult(_0x44dadd,null))['catch'](handleError(_0x44dadd,null));};exports['removeTags']=function(_0x28d028,_0x211524){return db[_0xf81c('0x1e')][_0xf81c('0x35')]({'where':{'id':_0x28d028[_0xf81c('0x36')]['id']}})[_0xf81c('0x18')](handleEntityNotFound(_0x211524,null))[_0xf81c('0x18')](function(_0x2a39a6){if(_0x2a39a6){return _0x2a39a6['removeTags'](_0x28d028['query'][_0xf81c('0x3a')]);}})[_0xf81c('0x18')](respondWithStatusCode(_0x211524,null))[_0xf81c('0x32')](handleError(_0x211524,null));};exports[_0xf81c('0x4f')]=function(_0x1a2150,_0xf8b5db){var _0x565dd1=moment()[_0xf81c('0x50')]()['toString']();var _0x8272ed=path[_0xf81c('0x51')](config[_0xf81c('0x52')],_0xf81c('0x53'),_0xf81c('0x54'),_0xf81c('0x55'));var _0x20daca=path[_0xf81c('0x51')](config['root'],_0xf81c('0x53'),_0xf81c('0x54'),_0xf81c('0x56'));var _0x132ae8=path[_0xf81c('0x51')](_0x8272ed,_0x565dd1);var _0x52ecd0=util[_0xf81c('0x57')](_0xf81c('0x58'),_0x1a2150[_0xf81c('0x36')]['id'],_0x565dd1);var _0x29701e=path['join'](_0x8272ed,_0x52ecd0);var _0x4d5854=[];_0x4d5854[_0xf81c('0x59')]({'model':db[_0xf81c('0x5a')],'as':_0xf81c('0x5a'),'raw':!![]});var _0x222300=[{'model':db[_0xf81c('0x39')],'as':'Messages','attributes':['id',_0xf81c('0x34'),_0xf81c('0x5b')],'include':_0x4d5854}];return db['FaxInteraction'][_0xf81c('0x35')]({'where':{'id':_0x1a2150[_0xf81c('0x36')]['id']},'include':_0x222300})[_0xf81c('0x18')](handleEntityNotFound(_0xf8b5db,null))[_0xf81c('0x18')](function(_0x2df6fb){if(_0x2df6fb&&_0x2df6fb['Messages']){var _0x114765=_0x2df6fb[_0xf81c('0x5c')]({'plain':!![]});fs[_0xf81c('0x5d')](_0x132ae8);for(var _0x675e9a=0x0;_0x675e9a<_0x114765[_0xf81c('0x5e')][_0xf81c('0x2d')];_0x675e9a++){var _0x44b7ae=_0x114765['Messages'][_0x675e9a][_0xf81c('0x5a')];if(_0x44b7ae){var _0x5a6af8=path[_0xf81c('0x51')](_0x20daca,_0x44b7ae[_0xf81c('0x5f')]);if(fs[_0xf81c('0x60')](_0x5a6af8)){fs[_0xf81c('0x61')](_0x5a6af8)['pipe'](fs[_0xf81c('0x62')](path[_0xf81c('0x51')](_0x132ae8,_0x44b7ae[_0xf81c('0x5f')])));}}}return BPromise[_0xf81c('0x63')]()['then'](function(){return new BPromise(function(_0x575de5,_0x2d6e4d){zipdir(_0x132ae8,{'saveTo':_0x29701e},function(_0x190e23,_0x3146c7){if(_0x190e23)return _0x2d6e4d(_0x190e23);return _0x575de5(_0x3146c7);});})['then'](function(){return new BPromise(function(_0x414a75,_0x3dccdc){rimraf(_0x132ae8,function(_0xbf6e96){if(_0xbf6e96)_0x3dccdc(_0xbf6e96);return _0x414a75();});});})[_0xf81c('0x18')](function(){return _0xf8b5db[_0xf81c('0x4f')](_0x29701e,_0x52ecd0,function(_0x29159b){if(_0x29159b){console[_0xf81c('0x64')](_0xf81c('0x65'),_0x29159b);}else{fs[_0xf81c('0x66')](_0x29701e);}});});});}else{return _0xf8b5db[_0xf81c('0xe')](0xc8);}})[_0xf81c('0x32')](handleError(_0xf8b5db,null));};
\ No newline at end of file