Built motion from commit eddce310.|2.6.12
[motion2.git] / server / api / faxInteraction / faxInteraction.controller.js
index 43ba3d8..7e7f3db 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xf907=['ContactId','CONCAT(\x27,\x27,\x20`TagIds`,\x20\x27,\x27)\x20LIKE\x20?','union','$substring','CONCAT_WS(\x27\x20\x27,\x20o.name,\x20o.fullname)\x20LIKE\x20?','UserId','buildExpression','text','start','keys','some','compact','isEmpty','FaxAccountId','concat','createdAt','parse','$gte','$lte','null','\x20IS\x20NULL','read','`unreadMessages`\x20=\x200','`unreadMessages`\x20>\x200','isArray','tag','filter','replace','\x27\x27\x27\x27','isNumeric','i.id\x20LIKE\x20?','i.fax\x20LIKE\x20?','CONCAT(c.firstName,\x20\x27\x20\x27,\x20c.lastName)\x20LIKE\x20?','group','i.id','Sequelize','QueryTypes','SELECT','clone','SUM(me.read\x20=\x200\x20AND\x20me.direction\x20=\x20\x27in\x27)','t.id\x20IN\x20?','resolve','journey','i.FaxAccountId\x20IS\x20NOT\x20NULL','user','i.FaxAccountId\x20IN\x20?','sequelize','toString','count','keyBy','merge','a.key','Account.key','a.mandatoryDisposition','Account.mandatoryDisposition','c.firstName','Contact.firstName','c.lastName','Contact.email','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?','FaxInteractionId','all','catch','show','params','includeAll','include','options','create','body','describe','addMessage','FaxMessage','omit','findOne','sort','format','YYYY-MM-DD\x20HH:mm:ss','setTags','ids','removeTags','download','server','files','tmp','root','attachments','join','transcript-%d-%s.zip','Attachment','Messages','get','mkdirSync','basename','existsSync','createReadStream','createWriteStream','log','err','unlinkSync','html-pdf','rimraf','fast-json-patch','request-promise','moment','mustache','util','sox','ejs','lodash','squel','crypto','jsforce','desk.js','to-csv','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','redis','defaults','socket.io-emitter','register','status','end','json','offset','set','Content-Range','apply','reject','save','update','then','destroy','sendStatus','error','stack','name','send','map','fullname','TagIds','forEach','push','index','FaxInteraction','rawAttributes','fieldName','type','key','query','filters','model','attributes','intersection','fields','hasOwnProperty','nolimit','limit','order','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','me.FaxInteractionId\x20=\x20i.id','fax_interaction_has_tags','it.FaxInteractionId\x20=\x20i.id','t.id\x20=\x20it.TagId','expr','search','parseSearch','sqlOperator','conditions','length','find','unreadMessages','value','`\x20=\x200','having','`\x20>\x200','Contact','operator','split','c.firstName\x20LIKE\x20?\x20OR\x20c.lastName\x20LIKE\x20?\x20OR\x20c.email\x20LIKE\x20?'];(function(_0x2bfdfe,_0x908d3f){var _0x30b5b5=function(_0x5989c1){while(--_0x5989c1){_0x2bfdfe['push'](_0x2bfdfe['shift']());}};_0x30b5b5(++_0x908d3f);}(_0xf907,0x145));var _0x7f90=function(_0x4ddc5a,_0x5e319b){_0x4ddc5a=_0x4ddc5a-0x0;var _0x499313=_0xf907[_0x4ddc5a];return _0x499313;};'use strict';var pdf=require(_0x7f90('0x0'));var emlformat=require('eml-format');var rimraf=require(_0x7f90('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0x7f90('0x2'));var rp=require(_0x7f90('0x3'));var moment=require(_0x7f90('0x4'));var BPromise=require('bluebird');var Mustache=require(_0x7f90('0x5'));var util=require(_0x7f90('0x6'));var path=require('path');var sox=require(_0x7f90('0x7'));var csv=require('to-csv');var ejs=require(_0x7f90('0x8'));var fs=require('fs');var _=require(_0x7f90('0x9'));var squel=require(_0x7f90('0xa'));var crypto=require(_0x7f90('0xb'));var jsforce=require(_0x7f90('0xc'));var deskjs=require(_0x7f90('0xd'));var toCsv=require(_0x7f90('0xe'));var querystring=require(_0x7f90('0xf'));var Papa=require(_0x7f90('0x10'));var Redis=require(_0x7f90('0x11'));var authService=require(_0x7f90('0x12'));var qs=require(_0x7f90('0x13'));var as=require(_0x7f90('0x14'));var hardwareService=require(_0x7f90('0x15'));var logger=require(_0x7f90('0x16'))(_0x7f90('0x17'));var utils=require(_0x7f90('0x18'));var config=require('../../config/environment');var db=require('../../mysqldb')['db'];config[_0x7f90('0x19')]=_[_0x7f90('0x1a')](config[_0x7f90('0x19')],{'host':'localhost','port':0x18eb});var socket=require(_0x7f90('0x1b'))(new Redis(config[_0x7f90('0x19')]));require('./faxInteraction.socket')[_0x7f90('0x1c')](socket);function respondWithStatusCode(_0x2b063e,_0x2b1d52){_0x2b1d52=_0x2b1d52||0xcc;return function(_0x4d96b9){if(_0x4d96b9){return _0x2b063e['sendStatus'](_0x2b1d52);}return _0x2b063e[_0x7f90('0x1d')](_0x2b1d52)[_0x7f90('0x1e')]();};}function respondWithResult(_0x9f4c9b,_0x2b7c30){_0x2b7c30=_0x2b7c30||0xc8;return function(_0x517a77){if(_0x517a77){return _0x9f4c9b[_0x7f90('0x1d')](_0x2b7c30)[_0x7f90('0x1f')](_0x517a77);}};}function respondWithFilteredResult(_0x5e5058,_0x3ea55b){return function(_0x517358){if(_0x517358){var _0x118057=_0x517358['count'],_0xff83d9=_0x3ea55b['offset'],_0x13e2c6=_0x3ea55b[_0x7f90('0x20')]+_0x3ea55b['limit'],_0x46d7b8;if(_0x13e2c6>=_0x118057){_0x13e2c6=_0x118057;_0x46d7b8=0xc8;}else{_0x46d7b8=0xce;}_0x5e5058[_0x7f90('0x1d')](_0x46d7b8);return _0x5e5058[_0x7f90('0x21')](_0x7f90('0x22'),_0xff83d9+'-'+_0x13e2c6+'/'+_0x118057)['json'](_0x517358);}return null;};}function patchUpdates(_0x3aea30){return function(_0x3cddfb){try{jsonpatch[_0x7f90('0x23')](_0x3cddfb,_0x3aea30,!![]);}catch(_0x41fe5d){return BPromise[_0x7f90('0x24')](_0x41fe5d);}return _0x3cddfb[_0x7f90('0x25')]();};}function saveUpdates(_0x5e4659,_0x4746b4){return function(_0x529ab7){if(_0x529ab7){return _0x529ab7[_0x7f90('0x26')](_0x5e4659)[_0x7f90('0x27')](function(_0x54f45f){return _0x54f45f;});}return null;};}function removeEntity(_0x3151d7,_0xfa102c){return function(_0x26c203){if(_0x26c203){return _0x26c203[_0x7f90('0x28')]()['then'](function(){_0x3151d7['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x431ddd,_0x2474bb){return function(_0x57a1c9){if(!_0x57a1c9){_0x431ddd[_0x7f90('0x29')](0x194);}return _0x57a1c9;};}function handleError(_0x341ae6,_0x2c0472){_0x2c0472=_0x2c0472||0x1f4;return function(_0x2dd65e){logger[_0x7f90('0x2a')](_0x2dd65e[_0x7f90('0x2b')]);if(_0x2dd65e[_0x7f90('0x2c')]){delete _0x2dd65e['name'];}_0x341ae6[_0x7f90('0x1d')](_0x2c0472)[_0x7f90('0x2d')](_0x2dd65e);};}function getInteractionUsers(_0x3f104a,_0x4008c2){return new BPromise(function(_0x5628f4,_0x513d72){try{if(_0x4008c2[_0x3f104a['id']]){_0x3f104a['Users']=_[_0x7f90('0x2e')](_0x4008c2[_0x3f104a['id']],function(_0x426ede){return{'id':_0x426ede['id'],'fullname':_0x426ede[_0x7f90('0x2f')]};});}}catch(_0x432fb5){_0x513d72(_0x432fb5);}_0x5628f4(_0x3f104a);});}function getInteractionTags(_0x20d0eb,_0x2afdb8){return new BPromise(function(_0x1e8c9f,_0x1e10fb){try{if(_0x20d0eb[_0x7f90('0x30')]){_0x20d0eb['Tags']=[];_0x20d0eb[_0x7f90('0x30')]['split'](',')[_0x7f90('0x31')](function(_0x1d6d90){_0x20d0eb['Tags'][_0x7f90('0x32')](_0x2afdb8[_0x1d6d90]);});}delete _0x20d0eb[_0x7f90('0x30')];}catch(_0x1ed028){_0x1e10fb(_0x1ed028);}_0x1e8c9f(_0x20d0eb);});}function updateFaxInteraction(_0x4341a2,_0x48b1f3,_0x4268c4){return new BPromise(function(_0x43c16b,_0x246e10){return getInteractionUsers(_0x4341a2,_0x4268c4)[_0x7f90('0x27')](function(_0x319211){return getInteractionTags(_0x319211,_0x48b1f3);})['then'](function(_0x5c9550){_0x43c16b(_0x5c9550);})['catch'](function(_0x47bf6e){_0x246e10(_0x47bf6e);});});}exports[_0x7f90('0x33')]=function(_0x1f0ac0,_0x1f7d69){var _0x4a945b={},_0x390a52={},_0x30fe40={'count':0x0,'rows':[]};var _0x3c55e8=_['map'](db[_0x7f90('0x34')][_0x7f90('0x35')],function(_0x2c40da){return{'name':_0x2c40da[_0x7f90('0x36')],'type':_0x2c40da[_0x7f90('0x37')][_0x7f90('0x38')]};});_0x390a52['model']=_[_0x7f90('0x2e')](_0x3c55e8,_0x7f90('0x2c'));_0x390a52[_0x7f90('0x39')]=_['keys'](_0x1f0ac0[_0x7f90('0x39')]);_0x390a52[_0x7f90('0x3a')]=_['intersection'](_0x390a52[_0x7f90('0x3b')],_0x390a52['query']);_0x4a945b[_0x7f90('0x3c')]=_[_0x7f90('0x3d')](_0x390a52['model'],qs[_0x7f90('0x3e')](_0x1f0ac0[_0x7f90('0x39')][_0x7f90('0x3e')]));_0x4a945b['attributes']=_0x4a945b['attributes']['length']?_0x4a945b[_0x7f90('0x3c')]:_0x390a52[_0x7f90('0x3b')];if(!_0x1f0ac0['query'][_0x7f90('0x3f')](_0x7f90('0x40'))){_0x4a945b['limit']=qs[_0x7f90('0x41')](_0x1f0ac0[_0x7f90('0x39')][_0x7f90('0x41')]);_0x4a945b['offset']=qs[_0x7f90('0x20')](_0x1f0ac0['query']['offset']);}_0x4a945b[_0x7f90('0x42')]=qs['sort'](_0x1f0ac0[_0x7f90('0x39')]['sort']);_0x4a945b[_0x7f90('0x43')]=qs[_0x7f90('0x3a')](_[_0x7f90('0x44')](_0x1f0ac0['query'],_0x390a52[_0x7f90('0x3a')]));var _0x22c191=[];var _0x5574b6=squel[_0x7f90('0x45')]()[_0x7f90('0x46')]('id')[_0x7f90('0x46')](_0x7f90('0x2c'))[_0x7f90('0x46')](_0x7f90('0x47'))[_0x7f90('0x48')](_0x7f90('0x49'));var _0x20c3e3=squel[_0x7f90('0x45')]()[_0x7f90('0x46')](_0x7f90('0x4a'))[_0x7f90('0x46')](_0x7f90('0x4b'))[_0x7f90('0x46')](_0x7f90('0x4c'))[_0x7f90('0x48')](_0x7f90('0x4d'),'ui')[_0x7f90('0x4e')](_0x7f90('0x4f'),'u',_0x7f90('0x50'));var _0x358444=squel[_0x7f90('0x45')]()['from'](_0x7f90('0x51'),'i')[_0x7f90('0x4e')](_0x7f90('0x52'),'c',_0x7f90('0x53'))[_0x7f90('0x4e')](_0x7f90('0x4f'),'o','o.id\x20=\x20i.UserId')[_0x7f90('0x4e')](_0x7f90('0x54'),'a',_0x7f90('0x55'))[_0x7f90('0x4e')](_0x7f90('0x56'),'me',_0x7f90('0x57'))[_0x7f90('0x4e')](_0x7f90('0x58'),'it',_0x7f90('0x59'))[_0x7f90('0x4e')]('tools_tags','t',_0x7f90('0x5a'));var _0x209503=squel[_0x7f90('0x5b')]();var _0x1afe5a=[];var _0x392d38=squel[_0x7f90('0x5b')]();var _0x372877;if(_0x1f0ac0[_0x7f90('0x39')][_0x7f90('0x5c')]){_0x372877=as[_0x7f90('0x5d')](_0x1f0ac0[_0x7f90('0x39')][_0x7f90('0x5c')]);var _0x4c2c93=_0x372877[_0x7f90('0x5e')];for(var _0xdfcb45=0x0;_0xdfcb45<_0x372877[_0x7f90('0x5f')][_0x7f90('0x60')];_0xdfcb45++){var _0x353d8f=_0x372877['conditions'][_0xdfcb45];var _0x2c293d='i';var _0x3f3d3b=_[_0x7f90('0x61')](_0x3c55e8,['name',_0x353d8f[_0x7f90('0x46')]]);if(!_0x3f3d3b){switch(_0x353d8f[_0x7f90('0x46')]){case _0x7f90('0x62'):if(_0x353d8f[_0x7f90('0x63')]==0x1){_0x358444['having']('`'+_0x353d8f['field']+_0x7f90('0x64'));}else{_0x358444[_0x7f90('0x65')]('`'+_0x353d8f['field']+_0x7f90('0x66'));}break;case _0x7f90('0x67'):if(_0x353d8f[_0x7f90('0x68')]==='$substring'){if(_0x353d8f[_0x7f90('0x63')][_0x7f90('0x69')]('\x20')[_0x7f90('0x60')]>0x1){_0x209503[_0x4c2c93]('MATCH\x20(c.firstName,\x20c.lastName,\x20c.phone,\x20c.mobile,\x20c.fax,\x20c.email)\x20AGAINST\x20(?\x20IN\x20BOOLEAN\x20MODE)',qs['getFullTextValue'](_0x353d8f[_0x7f90('0x63')]),null);}else{var _0x4358e2='%'+_0x353d8f[_0x7f90('0x63')]+'%';_0x209503[_0x4c2c93](_0x7f90('0x6a'),_0x4358e2,_0x4358e2,_0x4358e2);}}else{_0x3f3d3b=_[_0x7f90('0x61')](_0x3c55e8,[_0x7f90('0x2c'),_0x7f90('0x6b')]);_0x353d8f['field']='ContactId';_0x5e078f=as['buildExpression'](_0x2c293d,_0x3f3d3b[_0x7f90('0x37')],_0x353d8f);_0x209503[_0x4c2c93](_0x5e078f['text'],_0x5e078f[_0x7f90('0x63')]['start'],_0x5e078f[_0x7f90('0x63')][_0x7f90('0x1e')]);}break;case'Tag':var _0x3a1e02=_0x353d8f[_0x7f90('0x63')][_0x7f90('0x69')](',')[_0x7f90('0x2e')](function(_0x27eca4){return Number(_0x27eca4);});_0x3a1e02['forEach'](function(_0x52d802){_0x392d38['or'](_0x7f90('0x6c'),'%,'+_0x52d802+',%');});_0x1afe5a=_[_0x7f90('0x6d')](_0x1afe5a,_0x3a1e02);break;case'User':if(_0x353d8f[_0x7f90('0x68')]===_0x7f90('0x6e')){_0x209503[_0x4c2c93](_0x7f90('0x6f'),'%'+_0x353d8f[_0x7f90('0x63')]+'%',null);}else{_0x3f3d3b=_[_0x7f90('0x61')](_0x3c55e8,[_0x7f90('0x2c'),'UserId']);_0x353d8f[_0x7f90('0x46')]=_0x7f90('0x70');_0x5e078f=as[_0x7f90('0x71')](_0x2c293d,_0x3f3d3b[_0x7f90('0x37')],_0x353d8f);_0x209503[_0x4c2c93](_0x5e078f[_0x7f90('0x72')],_0x5e078f[_0x7f90('0x63')][_0x7f90('0x73')],_0x5e078f['value'][_0x7f90('0x1e')]);}break;case'body':_0x5e078f=as[_0x7f90('0x71')]('me',null,_0x353d8f);_0x209503[_0x4c2c93](_0x5e078f['text'],_0x5e078f['value'][_0x7f90('0x73')],_0x5e078f[_0x7f90('0x63')]['end']);break;}}else{var _0x5e078f=as[_0x7f90('0x71')](_0x2c293d,_0x3f3d3b[_0x7f90('0x37')],_0x353d8f);_0x209503[_0x4c2c93](_0x5e078f[_0x7f90('0x72')],_0x5e078f[_0x7f90('0x63')]['start'],_0x5e078f[_0x7f90('0x63')][_0x7f90('0x1e')]);}}}else{var _0x239833=_(_0x1f0ac0[_0x7f90('0x39')])[_0x7f90('0x74')]()[_0x7f90('0x2e')](function(_0x340f0a){return _[_0x7f90('0x75')](_0x3c55e8,[_0x7f90('0x2c'),_0x340f0a])?_0x340f0a:undefined;})[_0x7f90('0x76')]()[_0x7f90('0x63')]();if(!_[_0x7f90('0x77')](_0x239833)){_0x239833[_0x7f90('0x31')](function(_0x4708c1){if(_0x4708c1===_0x7f90('0x78')){_0x358444[_0x7f90('0x43')]('i.FaxAccountId\x20IN\x20?',[][_0x7f90('0x79')](_0x1f0ac0[_0x7f90('0x39')][_0x4708c1]));}else if(_0x4708c1===_0x7f90('0x7a')){var _0x5b5984=JSON[_0x7f90('0x7b')](_0x1f0ac0[_0x7f90('0x39')][_0x4708c1])[_0x7f90('0x7c')];var _0x233794=JSON[_0x7f90('0x7b')](_0x1f0ac0[_0x7f90('0x39')][_0x4708c1])[_0x7f90('0x7d')];_0x358444[_0x7f90('0x43')]('i.createdAt\x20BETWEEN\x20?\x20AND\x20?',_0x5b5984,_0x233794);}else{if(_0x1f0ac0[_0x7f90('0x39')][_0x4708c1]===_0x7f90('0x7e')){_0x358444[_0x7f90('0x43')]('i.'+_0x4708c1+_0x7f90('0x7f'));}else{_0x358444['where']('i.'+_0x4708c1+'\x20=\x20?',_0x1f0ac0[_0x7f90('0x39')][_0x4708c1]);}}});}if(_0x1f0ac0[_0x7f90('0x39')]['read']){if(_0x1f0ac0[_0x7f90('0x39')][_0x7f90('0x80')]==0x1){_0x358444[_0x7f90('0x65')](_0x7f90('0x81'));}else{_0x358444[_0x7f90('0x65')](_0x7f90('0x82'));}}if(_0x1f0ac0['query']['tag']){_0x1afe5a=_[_0x7f90('0x83')](_0x1f0ac0['query'][_0x7f90('0x84')])?_0x1f0ac0[_0x7f90('0x39')][_0x7f90('0x84')]:new Array(_0x1f0ac0[_0x7f90('0x39')][_0x7f90('0x84')]);_0x1afe5a[_0x7f90('0x31')](function(_0x324db3){_0x392d38['or'](_0x7f90('0x6c'),'%,'+_0x324db3+',%');});}if(_0x1f0ac0[_0x7f90('0x39')][_0x7f90('0x85')]){var _0x4da900=_0x1f0ac0[_0x7f90('0x39')]['filter']['replace']('\x5c','\x5c\x5c')[_0x7f90('0x86')]('\x27\x27',_0x7f90('0x87'));if(qs[_0x7f90('0x88')](_0x4da900)){_0x209503['or'](_0x7f90('0x89'),_0x4da900+'%')['or'](_0x7f90('0x8a'),_0x4da900+'%');}_0x209503['or'](_0x7f90('0x8b'),_0x4da900+'%');}}_0x358444[_0x7f90('0x43')](_0x209503);_0x358444[_0x7f90('0x8c')](_0x7f90('0x8d'));var _0x15dc40={'type':db[_0x7f90('0x8e')][_0x7f90('0x8f')][_0x7f90('0x90')],'raw':!![]};var _0x366c2d=_0x358444[_0x7f90('0x91')]();_0x366c2d['field'](_0x7f90('0x8d'));_0x366c2d[_0x7f90('0x46')](_0x7f90('0x92'),_0x7f90('0x62'));if(_0x4a945b[_0x7f90('0x42')]){_0x4a945b['order'][_0x7f90('0x31')](function(_0xabe294){_0x358444[_0x7f90('0x42')]('i.'+_0xabe294[0x0],_0xabe294[0x1]==='DESC'?![]:!![]);});}if(!_['isEmpty'](_0x1afe5a)){_0x358444['having'](_0x392d38);_0x366c2d['where'](_0x7f90('0x93'),_0x1afe5a);}BPromise[_0x7f90('0x94')]()['then'](function(){if(!_0x372877){if(_0x1f0ac0[_0x7f90('0x39')]['FaxAccountId']||_0x1f0ac0['query'][_0x7f90('0x95')])return;_0x366c2d[_0x7f90('0x43')]('i.FaxAccountId\x20IS\x20NOT\x20NULL');_0x358444[_0x7f90('0x43')](_0x7f90('0x96'));return;}return _0x1f0ac0[_0x7f90('0x97')]['getFaxAccounts']({'attributes':['id'],'raw':!![]})[_0x7f90('0x27')](function(_0x59e0bd){if(_[_0x7f90('0x77')](_0x59e0bd)){_0x366c2d[_0x7f90('0x43')]('i.FaxAccountId\x20IS\x20NULL');_0x358444['where']('i.FaxAccountId\x20IS\x20NULL');}else{_0x366c2d[_0x7f90('0x43')]('i.FaxAccountId\x20IN\x20?',_['map'](_0x59e0bd,'id'));_0x358444[_0x7f90('0x43')](_0x7f90('0x98'),_[_0x7f90('0x2e')](_0x59e0bd,'id'));}});})[_0x7f90('0x27')](function(){db[_0x7f90('0x99')][_0x7f90('0x39')](_0x366c2d[_0x7f90('0x9a')](),_0x15dc40)[_0x7f90('0x27')](function(_0x32b74b){_0x30fe40[_0x7f90('0x9b')]=_0x32b74b[_0x7f90('0x60')];if(_0x30fe40[_0x7f90('0x9b')]===0x0)return[];return db[_0x7f90('0x99')]['query'](_0x5574b6[_0x7f90('0x9a')](),_0x15dc40)[_0x7f90('0x27')](function(_0x2c84c1){_0x22c191=_[_0x7f90('0x9c')](_0x2c84c1,'id');_0x15dc40=_[_0x7f90('0x9d')](_0x15dc40,{'model':db[_0x7f90('0x34')],'mapToModel':!![],'raw':!![],'nest':!![]});if(_0x1f0ac0['query'][_0x7f90('0x3e')]){_0x4a945b[_0x7f90('0x3c')][_0x7f90('0x31')](function(_0x40ff0b){_0x358444[_0x7f90('0x46')]('i.'+_0x40ff0b);});}else{_0x358444['field']('SUM(me.read\x20=\x200\x20AND\x20me.direction\x20=\x20\x27in\x27)',_0x7f90('0x62'));_0x358444[_0x7f90('0x46')](_0x7f90('0x9e'),_0x7f90('0x9f'));_0x358444[_0x7f90('0x46')](_0x7f90('0xa0'),_0x7f90('0xa1'));_0x358444[_0x7f90('0x46')]('i.*');_0x358444[_0x7f90('0x46')](_0x7f90('0xa2'),_0x7f90('0xa3'));_0x358444[_0x7f90('0x46')](_0x7f90('0xa4'),'Contact.lastName');_0x358444[_0x7f90('0x46')]('c.email',_0x7f90('0xa5'));_0x358444[_0x7f90('0x46')]('c.phone','Contact.phone');_0x358444[_0x7f90('0x46')](_0x7f90('0xa6'),_0x7f90('0xa7'));_0x358444[_0x7f90('0x46')](_0x7f90('0xa8'),_0x7f90('0xa9'));_0x358444['field'](_0x7f90('0xaa'),_0x7f90('0xab'));_0x358444[_0x7f90('0x46')](_0x7f90('0xac'),_0x7f90('0xad'));_0x358444[_0x7f90('0x46')](_0x7f90('0xae'),_0x7f90('0x30'));}_0x358444['limit'](_0x4a945b[_0x7f90('0x41')]);_0x358444[_0x7f90('0x20')](_0x4a945b['offset']);return db[_0x7f90('0x99')][_0x7f90('0x39')](_0x358444[_0x7f90('0x9a')](),_0x15dc40);})[_0x7f90('0x27')](function(_0x117758){_0x20c3e3[_0x7f90('0x43')](_0x7f90('0xaf'),_['map'](_0x117758,'id'));return db[_0x7f90('0x99')][_0x7f90('0x39')](_0x20c3e3[_0x7f90('0x9a')](),_0x15dc40)[_0x7f90('0x27')](function(_0x40d5ae){var _0x2b0291=_['groupBy'](_0x40d5ae,_0x7f90('0xb0'));var _0xd88655=[];_0x117758[_0x7f90('0x31')](function(_0x24becd){_0xd88655['push'](updateFaxInteraction(_0x24becd,_0x22c191,_0x2b0291));});return BPromise[_0x7f90('0xb1')](_0xd88655);});});})['then'](function(_0x17e469){_0x30fe40['rows']=_0x17e469;return _0x30fe40;})['then'](respondWithFilteredResult(_0x1f7d69,_0x4a945b));})[_0x7f90('0xb2')](handleError(_0x1f7d69,null));};exports[_0x7f90('0xb3')]=function(_0xcf362a,_0x30f8f3){var _0xb4245e={'raw':![],'where':{'id':_0xcf362a[_0x7f90('0xb4')]['id']}},_0x4dc062={};_0x4dc062[_0x7f90('0x3b')]=_['keys'](db[_0x7f90('0x34')]['rawAttributes']);_0x4dc062['query']=_[_0x7f90('0x74')](_0xcf362a[_0x7f90('0x39')]);_0x4dc062['filters']=_[_0x7f90('0x3d')](_0x4dc062[_0x7f90('0x3b')],_0x4dc062[_0x7f90('0x39')]);_0xb4245e[_0x7f90('0x3c')]=_[_0x7f90('0x3d')](_0x4dc062[_0x7f90('0x3b')],qs[_0x7f90('0x3e')](_0xcf362a[_0x7f90('0x39')]['fields']));_0xb4245e[_0x7f90('0x3c')]=_0xb4245e['attributes'][_0x7f90('0x60')]?_0xb4245e[_0x7f90('0x3c')]:_0x4dc062[_0x7f90('0x3b')];if(_0xcf362a[_0x7f90('0x39')][_0x7f90('0xb5')]){_0xb4245e[_0x7f90('0xb6')]=[{'all':!![]}];}_0xb4245e=_[_0x7f90('0x9d')]({},_0xb4245e,_0xcf362a[_0x7f90('0xb7')]);return db[_0x7f90('0x34')][_0x7f90('0x61')](_0xb4245e)['then'](handleEntityNotFound(_0x30f8f3,null))['then'](respondWithResult(_0x30f8f3,null))[_0x7f90('0xb2')](handleError(_0x30f8f3,null));};exports[_0x7f90('0xb8')]=function(_0x14bc72,_0x317b29){return db[_0x7f90('0x34')]['create'](_0x14bc72[_0x7f90('0xb9')],{})['then'](respondWithResult(_0x317b29,0xc9))[_0x7f90('0xb2')](handleError(_0x317b29,null));};exports[_0x7f90('0x26')]=function(_0x1089d1,_0x3a14aa){if(_0x1089d1[_0x7f90('0xb9')]['id']){delete _0x1089d1['body']['id'];}return db[_0x7f90('0x34')][_0x7f90('0x61')]({'where':{'id':_0x1089d1['params']['id']}})['then'](handleEntityNotFound(_0x3a14aa,null))[_0x7f90('0x27')](saveUpdates(_0x1089d1[_0x7f90('0xb9')],null))[_0x7f90('0x27')](respondWithResult(_0x3a14aa,null))[_0x7f90('0xb2')](handleError(_0x3a14aa,null));};exports[_0x7f90('0x28')]=function(_0x4efed2,_0x4606bf){return db['FaxInteraction'][_0x7f90('0x61')]({'where':{'id':_0x4efed2[_0x7f90('0xb4')]['id']}})['then'](handleEntityNotFound(_0x4606bf,null))[_0x7f90('0x27')](removeEntity(_0x4606bf,null))[_0x7f90('0xb2')](handleError(_0x4606bf,null));};exports['describe']=function(_0x2065e5,_0xb24cfe){return db[_0x7f90('0x34')][_0x7f90('0xba')]()['then'](respondWithResult(_0xb24cfe,null))[_0x7f90('0xb2')](handleError(_0xb24cfe,null));};exports[_0x7f90('0xbb')]=function(_0x1e9957,_0x34dc2a,_0x33a639){return db[_0x7f90('0xbc')][_0x7f90('0x61')]({'where':{'id':_0x1e9957[_0x7f90('0xb4')]['id']}})[_0x7f90('0x27')](handleEntityNotFound(_0x34dc2a,null))[_0x7f90('0x27')](function(_0x1768e7){if(_0x1768e7){return _0x1768e7[_0x7f90('0xbb')](_0x1e9957[_0x7f90('0xb9')]['ids'],_[_0x7f90('0xbd')](_0x1e9957[_0x7f90('0xb9')],['ids','id'])||{});}})[_0x7f90('0x27')](respondWithResult(_0x34dc2a,null))[_0x7f90('0xb2')](handleError(_0x34dc2a,null));};exports['getMessages']=function(_0x48cd26,_0x59febb,_0xa2f745){var _0x53f734={'raw':![],'where':{}};var _0x45867e={};var _0x5e9e8f={'count':0x0,'rows':[]};return db[_0x7f90('0x34')][_0x7f90('0xbe')]({'where':{'id':_0x48cd26[_0x7f90('0xb4')]['id']}})[_0x7f90('0x27')](handleEntityNotFound(_0x59febb,null))[_0x7f90('0x27')](function(_0xcfb960){if(_0xcfb960){_0x45867e['model']=_[_0x7f90('0x74')](db[_0x7f90('0xbc')][_0x7f90('0x35')]);_0x45867e[_0x7f90('0x39')]=_[_0x7f90('0x74')](_0x48cd26['query']);_0x45867e[_0x7f90('0x3a')]=_[_0x7f90('0x3d')](_0x45867e[_0x7f90('0x3b')],_0x45867e[_0x7f90('0x39')]);_0x53f734[_0x7f90('0x3c')]=_['intersection'](_0x45867e[_0x7f90('0x3b')],qs[_0x7f90('0x3e')](_0x48cd26[_0x7f90('0x39')][_0x7f90('0x3e')]));_0x53f734[_0x7f90('0x3c')]=_0x53f734[_0x7f90('0x3c')][_0x7f90('0x60')]?_0x53f734[_0x7f90('0x3c')]:_0x45867e['model'];if(!_0x48cd26[_0x7f90('0x39')][_0x7f90('0x3f')](_0x7f90('0x40'))){_0x53f734[_0x7f90('0x41')]=qs[_0x7f90('0x41')](_0x48cd26[_0x7f90('0x39')]['limit']);_0x53f734[_0x7f90('0x20')]=qs[_0x7f90('0x20')](_0x48cd26[_0x7f90('0x39')][_0x7f90('0x20')]);}_0x53f734[_0x7f90('0x42')]=qs['sort'](_0x48cd26[_0x7f90('0x39')][_0x7f90('0xbf')]);_0x53f734[_0x7f90('0x43')]=qs[_0x7f90('0x3a')](_[_0x7f90('0x44')](_0x48cd26[_0x7f90('0x39')],_0x45867e[_0x7f90('0x3a')]));_0x53f734[_0x7f90('0x43')][_0x7f90('0xb0')]=_0xcfb960['id'];if(_0x48cd26[_0x7f90('0x39')][_0x7f90('0x85')]){_0x53f734['where']=_[_0x7f90('0x9d')](_0x53f734[_0x7f90('0x43')],{'$or':_['map'](_0x53f734[_0x7f90('0x3c')],function(_0x57f54d){var _0x173f64={};_0x173f64[_0x57f54d]={'$like':'%'+_0x48cd26[_0x7f90('0x39')]['filter']+'%'};return _0x173f64;})});}if(_0x48cd26['query']['$gte']){var _0xfe3d00=_0x48cd26[_0x7f90('0x39')][_0x7f90('0x7c')][_0x7f90('0x69')](',');var _0x3cae1d={};_0x3cae1d[_0xfe3d00[0x0]]={'$gte':moment(_0xfe3d00[0x1])[_0x7f90('0xc0')](_0x7f90('0xc1'))};_0x53f734[_0x7f90('0x43')]=_[_0x7f90('0x9d')](_0x53f734[_0x7f90('0x43')],_0x3cae1d);}_0x53f734=_[_0x7f90('0x9d')]({},_0x53f734,_0x48cd26[_0x7f90('0xb7')]);return db['FaxMessage'][_0x7f90('0x9b')]({'where':_0x53f734[_0x7f90('0x43')]})[_0x7f90('0x27')](function(_0x378440){_0x5e9e8f[_0x7f90('0x9b')]=_0x378440;if(_0x48cd26[_0x7f90('0x39')][_0x7f90('0xb5')]){_0x53f734[_0x7f90('0xb6')]=[{'all':!![]}];}return db[_0x7f90('0xbc')]['findAll'](_0x53f734);})['then'](function(_0x432450){_0x5e9e8f['rows']=_0x432450;return _0x5e9e8f;});}})['then'](respondWithFilteredResult(_0x59febb,_0x53f734))[_0x7f90('0xb2')](handleError(_0x59febb,null));};exports['addTags']=function(_0x10236b,_0x2b48e3,_0x2df366){return db[_0x7f90('0x34')][_0x7f90('0x61')]({'where':{'id':_0x10236b[_0x7f90('0xb4')]['id']}})['then'](handleEntityNotFound(_0x2b48e3,null))['then'](function(_0x574d84){if(_0x574d84){return _0x574d84[_0x7f90('0xc2')](_0x10236b[_0x7f90('0xb9')][_0x7f90('0xc3')],_[_0x7f90('0xbd')](_0x10236b[_0x7f90('0xb9')],['ids','id'])||{})['spread'](function(){return db['Tag']['findAll']({'attributes':['id','name',_0x7f90('0x47')],'where':{'id':_0x10236b[_0x7f90('0xb9')]['ids']}});})[_0x7f90('0x27')](function(_0x2575f5){socket['emit']('faxInteractionTags:save',{'id':Number(_0x10236b['params']['id']),'tags':_0x2575f5||[]});return{'id':Number(_0x10236b[_0x7f90('0xb4')]['id']),'tags':_0x2575f5||[]};});}})[_0x7f90('0x27')](respondWithResult(_0x2b48e3,null))['catch'](handleError(_0x2b48e3,null));};exports[_0x7f90('0xc4')]=function(_0x195b69,_0xe3e21,_0x315731){return db[_0x7f90('0x34')]['find']({'where':{'id':_0x195b69[_0x7f90('0xb4')]['id']}})[_0x7f90('0x27')](handleEntityNotFound(_0xe3e21,null))['then'](function(_0x4c2ece){if(_0x4c2ece){return _0x4c2ece['removeTags'](_0x195b69[_0x7f90('0x39')][_0x7f90('0xc3')]);}})[_0x7f90('0x27')](respondWithStatusCode(_0xe3e21,null))[_0x7f90('0xb2')](handleError(_0xe3e21,null));};exports[_0x7f90('0xc5')]=function(_0x224a90,_0x55caf1){var _0x4e4817=moment()['unix']()['toString']();var _0x52a1f0=path['join'](config['root'],_0x7f90('0xc6'),_0x7f90('0xc7'),_0x7f90('0xc8'));var _0x37fc48=path['join'](config[_0x7f90('0xc9')],_0x7f90('0xc6'),_0x7f90('0xc7'),_0x7f90('0xca'));var _0x6bbfb=path[_0x7f90('0xcb')](_0x52a1f0,_0x4e4817);var _0x51e45=util[_0x7f90('0xc0')](_0x7f90('0xcc'),_0x224a90[_0x7f90('0xb4')]['id'],_0x4e4817);var _0x46d817=path[_0x7f90('0xcb')](_0x52a1f0,_0x51e45);var _0x5a79a5=[];_0x5a79a5[_0x7f90('0x32')]({'model':db[_0x7f90('0xcd')],'as':_0x7f90('0xcd'),'raw':!![]});var _0x14dcae=[{'model':db[_0x7f90('0xbc')],'as':_0x7f90('0xce'),'attributes':['id',_0x7f90('0xb9'),_0x7f90('0x7a')],'include':_0x5a79a5}];return db[_0x7f90('0x34')][_0x7f90('0x61')]({'where':{'id':_0x224a90[_0x7f90('0xb4')]['id']},'include':_0x14dcae})[_0x7f90('0x27')](handleEntityNotFound(_0x55caf1,null))[_0x7f90('0x27')](function(_0x1699b8){if(_0x1699b8&&_0x1699b8['Messages']){var _0x4beaf8=_0x1699b8[_0x7f90('0xcf')]({'plain':!![]});fs[_0x7f90('0xd0')](_0x6bbfb);for(var _0x319abe=0x0;_0x319abe<_0x4beaf8[_0x7f90('0xce')][_0x7f90('0x60')];_0x319abe++){var _0x1dc1c9=_0x4beaf8['Messages'][_0x319abe][_0x7f90('0xcd')];if(_0x1dc1c9){var _0x9cfba3=path[_0x7f90('0xcb')](_0x37fc48,_0x1dc1c9[_0x7f90('0xd1')]);if(fs[_0x7f90('0xd2')](_0x9cfba3)){fs[_0x7f90('0xd3')](_0x9cfba3)['pipe'](fs[_0x7f90('0xd4')](path[_0x7f90('0xcb')](_0x6bbfb,_0x1dc1c9[_0x7f90('0xd1')])));}}}return BPromise['resolve']()[_0x7f90('0x27')](function(){return new BPromise(function(_0x4b05d2,_0x3c8185){zipdir(_0x6bbfb,{'saveTo':_0x46d817},function(_0x1a1e59,_0x31a0c4){if(_0x1a1e59)return _0x3c8185(_0x1a1e59);return _0x4b05d2(_0x31a0c4);});})[_0x7f90('0x27')](function(){return new BPromise(function(_0x1951d4,_0x4b046d){rimraf(_0x6bbfb,function(_0x3227f8){if(_0x3227f8)_0x4b046d(_0x3227f8);return _0x1951d4();});});})[_0x7f90('0x27')](function(){return _0x55caf1[_0x7f90('0xc5')](_0x46d817,_0x51e45,function(_0x169935){if(_0x169935){console[_0x7f90('0xd5')](_0x7f90('0xd6'),_0x169935);}else{fs[_0x7f90('0xd7')](_0x46d817);}});});});}else{return _0x55caf1[_0x7f90('0x29')](0xc8);}})[_0x7f90('0xb2')](handleError(_0x55caf1,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