Built motion from commit 3c2ce842.|2.6.31
[motion2.git] / server / api / faxInteraction / faxInteraction.controller.js
index 43ba3d8..edb87a4 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 _0xd9b2=['count','set','Content-Range','destroy','then','stack','name','index','rawAttributes','fieldName','type','getOptions','findAll','fax','user','catch','show','params','model','keys','FaxInteraction','query','attributes','intersection','fields','length','includeAll','include','merge','options','find','create','body','describe','addMessage','ids','omit','getMessages','FaxMessage','hasOwnProperty','nolimit','order','sort','where','filters','pick','FaxInteractionId','filter','map','$gte','split','YYYY-MM-DD\x20HH:mm:ss','rows','setTags','color','emit','removeTags','download','unix','toString','root','tmp','join','server','files','transcript-%d-%s.zip','push','Attachment','Messages','createdAt','basename','existsSync','createReadStream','pipe','createWriteStream','resolve','log','err','unlinkSync','rimraf','moment','util','lodash','ioredis','../../components/interaction/service','../../components/parsers/qs','../../config/logger','api','../../mysqldb','redis','defaults','localhost','./faxInteraction.socket','register','sendStatus','status','end','json','offset','undefined','limit'];(function(_0x3d5638,_0xa26995){var _0x2c2455=function(_0x5384e0){while(--_0x5384e0){_0x3d5638['push'](_0x3d5638['shift']());}};_0x2c2455(++_0xa26995);}(_0xd9b2,0xb4));var _0x2d9b=function(_0x2d2258,_0x2ce510){_0x2d2258=_0x2d2258-0x0;var _0x18e155=_0xd9b2[_0x2d2258];return _0x18e155;};'use strict';var rimraf=require(_0x2d9b('0x0'));var zipdir=require('zip-dir');var moment=require(_0x2d9b('0x1'));var BPromise=require('bluebird');var util=require(_0x2d9b('0x2'));var path=require('path');var fs=require('fs');var _=require(_0x2d9b('0x3'));var Redis=require(_0x2d9b('0x4'));var interaction=require(_0x2d9b('0x5'));var qs=require(_0x2d9b('0x6'));var logger=require(_0x2d9b('0x7'))(_0x2d9b('0x8'));var config=require('../../config/environment');var db=require(_0x2d9b('0x9'))['db'];config[_0x2d9b('0xa')]=_[_0x2d9b('0xb')](config[_0x2d9b('0xa')],{'host':_0x2d9b('0xc'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x2d9b('0xa')]));require(_0x2d9b('0xd'))[_0x2d9b('0xe')](socket);function respondWithStatusCode(_0x5d727b,_0x28a2d5){_0x28a2d5=_0x28a2d5||0xcc;return function(_0x493bed){if(_0x493bed){return _0x5d727b[_0x2d9b('0xf')](_0x28a2d5);}return _0x5d727b[_0x2d9b('0x10')](_0x28a2d5)[_0x2d9b('0x11')]();};}function respondWithResult(_0x182b3a,_0x1d6d67){_0x1d6d67=_0x1d6d67||0xc8;return function(_0x202a28){if(_0x202a28){return _0x182b3a[_0x2d9b('0x10')](_0x1d6d67)[_0x2d9b('0x12')](_0x202a28);}};}function respondWithFilteredResult(_0x5ba3c7,_0x5e299c){return function(_0xc71899){if(_0xc71899){var _0xd4b89d=typeof _0x5e299c[_0x2d9b('0x13')]===_0x2d9b('0x14')&&typeof _0x5e299c[_0x2d9b('0x15')]==='undefined';var _0x2f1b56=_0xc71899['count'];var _0x484164=_0xd4b89d?0x0:_0x5e299c[_0x2d9b('0x13')];var _0x102aec=_0xd4b89d?_0xc71899[_0x2d9b('0x16')]:_0x5e299c['offset']+_0x5e299c['limit'];var _0x1d02a0;if(_0x102aec>=_0x2f1b56){_0x102aec=_0x2f1b56;_0x1d02a0=0xc8;}else{_0x1d02a0=0xce;}_0x5ba3c7[_0x2d9b('0x10')](_0x1d02a0);return _0x5ba3c7[_0x2d9b('0x17')](_0x2d9b('0x18'),_0x484164+'-'+_0x102aec+'/'+_0x2f1b56)[_0x2d9b('0x12')](_0xc71899);}return null;};}function saveUpdates(_0xc23202){return function(_0x2b13d3){if(_0x2b13d3){return _0x2b13d3['update'](_0xc23202)['then'](function(_0x542b16){return _0x542b16;});}return null;};}function removeEntity(_0x50fd02){return function(_0x3612f8){if(_0x3612f8){return _0x3612f8[_0x2d9b('0x19')]()[_0x2d9b('0x1a')](function(){_0x50fd02[_0x2d9b('0x10')](0xcc)['end']();});}};}function handleEntityNotFound(_0x2f6c4e){return function(_0x2d8ff1){if(!_0x2d8ff1){_0x2f6c4e[_0x2d9b('0xf')](0x194);}return _0x2d8ff1;};}function handleError(_0x1da875,_0x3346c5){_0x3346c5=_0x3346c5||0x1f4;return function(_0x3d946a){logger['error'](_0x3d946a[_0x2d9b('0x1b')]);if(_0x3d946a[_0x2d9b('0x1c')]){delete _0x3d946a[_0x2d9b('0x1c')];}_0x1da875['status'](_0x3346c5)['send'](_0x3d946a);};}exports[_0x2d9b('0x1d')]=function(_0x3dc29c,_0x30b097){var _0x19eddb={};var _0x39473b=_['map'](db['FaxInteraction'][_0x2d9b('0x1e')],function(_0x39f2b4){return{'name':_0x39f2b4[_0x2d9b('0x1f')],'type':_0x39f2b4[_0x2d9b('0x20')]['key']};});_0x19eddb=qs[_0x2d9b('0x21')](_0x39473b,_0x3dc29c);return interaction[_0x2d9b('0x22')](_0x2d9b('0x23'),_0x3dc29c['query'],_0x3dc29c[_0x2d9b('0x24')],_0x19eddb,_0x39473b)['then'](respondWithFilteredResult(_0x30b097,_0x19eddb))[_0x2d9b('0x25')](handleError(_0x30b097,null));};exports[_0x2d9b('0x26')]=function(_0xd589da,_0x10a8b0){var _0x1e7cba={'raw':![],'where':{'id':_0xd589da[_0x2d9b('0x27')]['id']}},_0x226a3d={};_0x226a3d[_0x2d9b('0x28')]=_[_0x2d9b('0x29')](db[_0x2d9b('0x2a')]['rawAttributes']);_0x226a3d[_0x2d9b('0x2b')]=_['keys'](_0xd589da[_0x2d9b('0x2b')]);_0x226a3d['filters']=_['intersection'](_0x226a3d[_0x2d9b('0x28')],_0x226a3d[_0x2d9b('0x2b')]);_0x1e7cba[_0x2d9b('0x2c')]=_[_0x2d9b('0x2d')](_0x226a3d[_0x2d9b('0x28')],qs['fields'](_0xd589da['query'][_0x2d9b('0x2e')]));_0x1e7cba['attributes']=_0x1e7cba[_0x2d9b('0x2c')][_0x2d9b('0x2f')]?_0x1e7cba[_0x2d9b('0x2c')]:_0x226a3d[_0x2d9b('0x28')];if(_0xd589da[_0x2d9b('0x2b')][_0x2d9b('0x30')]){_0x1e7cba[_0x2d9b('0x31')]=[{'all':!![]}];}_0x1e7cba=_[_0x2d9b('0x32')]({},_0x1e7cba,_0xd589da[_0x2d9b('0x33')]);return db['FaxInteraction'][_0x2d9b('0x34')](_0x1e7cba)['then'](handleEntityNotFound(_0x10a8b0,null))[_0x2d9b('0x1a')](respondWithResult(_0x10a8b0,null))[_0x2d9b('0x25')](handleError(_0x10a8b0,null));};exports[_0x2d9b('0x35')]=function(_0x145338,_0x1f0f3a){return db[_0x2d9b('0x2a')][_0x2d9b('0x35')](_0x145338[_0x2d9b('0x36')],{})[_0x2d9b('0x1a')](respondWithResult(_0x1f0f3a,0xc9))[_0x2d9b('0x25')](handleError(_0x1f0f3a,null));};exports['update']=function(_0x129b80,_0x19b3ce){if(_0x129b80['body']['id']){delete _0x129b80[_0x2d9b('0x36')]['id'];}return db[_0x2d9b('0x2a')][_0x2d9b('0x34')]({'where':{'id':_0x129b80[_0x2d9b('0x27')]['id']}})['then'](handleEntityNotFound(_0x19b3ce,null))[_0x2d9b('0x1a')](saveUpdates(_0x129b80[_0x2d9b('0x36')],null))[_0x2d9b('0x1a')](respondWithResult(_0x19b3ce,null))['catch'](handleError(_0x19b3ce,null));};exports[_0x2d9b('0x19')]=function(_0x334924,_0x427064){return db[_0x2d9b('0x2a')][_0x2d9b('0x34')]({'where':{'id':_0x334924[_0x2d9b('0x27')]['id']}})[_0x2d9b('0x1a')](handleEntityNotFound(_0x427064,null))['then'](removeEntity(_0x427064,null))['catch'](handleError(_0x427064,null));};exports[_0x2d9b('0x37')]=function(_0x529f9b,_0x57611b){return db[_0x2d9b('0x2a')]['describe']()[_0x2d9b('0x1a')](respondWithResult(_0x57611b,null))[_0x2d9b('0x25')](handleError(_0x57611b,null));};exports[_0x2d9b('0x38')]=function(_0x2b7eb3,_0x40a577){return db['FaxMessage'][_0x2d9b('0x34')]({'where':{'id':_0x2b7eb3['params']['id']}})[_0x2d9b('0x1a')](handleEntityNotFound(_0x40a577,null))[_0x2d9b('0x1a')](function(_0x24b17b){if(_0x24b17b){return _0x24b17b[_0x2d9b('0x38')](_0x2b7eb3['body'][_0x2d9b('0x39')],_[_0x2d9b('0x3a')](_0x2b7eb3[_0x2d9b('0x36')],[_0x2d9b('0x39'),'id'])||{});}})[_0x2d9b('0x1a')](respondWithResult(_0x40a577,null))[_0x2d9b('0x25')](handleError(_0x40a577,null));};exports[_0x2d9b('0x3b')]=function(_0x23fbfc,_0x1e728e){var _0x10eefd={'raw':![],'where':{}};var _0x477d44={};var _0x5b328c={'count':0x0,'rows':[]};return db['FaxInteraction']['findOne']({'where':{'id':_0x23fbfc[_0x2d9b('0x27')]['id']}})[_0x2d9b('0x1a')](handleEntityNotFound(_0x1e728e,null))['then'](function(_0x5635c1){if(_0x5635c1){_0x477d44[_0x2d9b('0x28')]=_[_0x2d9b('0x29')](db[_0x2d9b('0x3c')][_0x2d9b('0x1e')]);_0x477d44[_0x2d9b('0x2b')]=_[_0x2d9b('0x29')](_0x23fbfc[_0x2d9b('0x2b')]);_0x477d44['filters']=_[_0x2d9b('0x2d')](_0x477d44['model'],_0x477d44[_0x2d9b('0x2b')]);_0x10eefd[_0x2d9b('0x2c')]=_['intersection'](_0x477d44[_0x2d9b('0x28')],qs[_0x2d9b('0x2e')](_0x23fbfc['query'][_0x2d9b('0x2e')]));_0x10eefd[_0x2d9b('0x2c')]=_0x10eefd[_0x2d9b('0x2c')][_0x2d9b('0x2f')]?_0x10eefd[_0x2d9b('0x2c')]:_0x477d44[_0x2d9b('0x28')];if(!_0x23fbfc[_0x2d9b('0x2b')][_0x2d9b('0x3d')](_0x2d9b('0x3e'))){_0x10eefd[_0x2d9b('0x15')]=qs[_0x2d9b('0x15')](_0x23fbfc['query']['limit']);_0x10eefd[_0x2d9b('0x13')]=qs[_0x2d9b('0x13')](_0x23fbfc[_0x2d9b('0x2b')][_0x2d9b('0x13')]);}_0x10eefd[_0x2d9b('0x3f')]=qs[_0x2d9b('0x40')](_0x23fbfc[_0x2d9b('0x2b')][_0x2d9b('0x40')]);_0x10eefd[_0x2d9b('0x41')]=qs[_0x2d9b('0x42')](_[_0x2d9b('0x43')](_0x23fbfc[_0x2d9b('0x2b')],_0x477d44['filters']));_0x10eefd[_0x2d9b('0x41')][_0x2d9b('0x44')]=_0x5635c1['id'];if(_0x23fbfc[_0x2d9b('0x2b')][_0x2d9b('0x45')]){_0x10eefd['where']=_['merge'](_0x10eefd[_0x2d9b('0x41')],{'$or':_[_0x2d9b('0x46')](_0x10eefd['attributes'],function(_0x876afc){var _0x217042={};_0x217042[_0x876afc]={'$like':'%'+_0x23fbfc[_0x2d9b('0x2b')][_0x2d9b('0x45')]+'%'};return _0x217042;})});}if(_0x23fbfc['query'][_0x2d9b('0x47')]){var _0x5d1317=_0x23fbfc[_0x2d9b('0x2b')]['$gte'][_0x2d9b('0x48')](',');var _0x50c09f={};_0x50c09f[_0x5d1317[0x0]]={'$gte':moment(_0x5d1317[0x1])['format'](_0x2d9b('0x49'))};_0x10eefd[_0x2d9b('0x41')]=_[_0x2d9b('0x32')](_0x10eefd['where'],_0x50c09f);}_0x10eefd=_['merge']({},_0x10eefd,_0x23fbfc['options']);return db['FaxMessage'][_0x2d9b('0x16')]({'where':_0x10eefd['where']})['then'](function(_0x172444){_0x5b328c['count']=_0x172444;if(_0x23fbfc['query'][_0x2d9b('0x30')]){_0x10eefd[_0x2d9b('0x31')]=[{'all':!![]}];}return db[_0x2d9b('0x3c')]['findAll'](_0x10eefd);})['then'](function(_0x2f98a4){_0x5b328c[_0x2d9b('0x4a')]=_0x2f98a4;return _0x5b328c;});}})['then'](respondWithFilteredResult(_0x1e728e,_0x10eefd))[_0x2d9b('0x25')](handleError(_0x1e728e,null));};exports['addTags']=function(_0x240f95,_0x1aebbb){return db[_0x2d9b('0x2a')][_0x2d9b('0x34')]({'where':{'id':_0x240f95[_0x2d9b('0x27')]['id']}})[_0x2d9b('0x1a')](handleEntityNotFound(_0x1aebbb,null))[_0x2d9b('0x1a')](function(_0x243524){if(_0x243524){return _0x243524[_0x2d9b('0x4b')](_0x240f95[_0x2d9b('0x36')][_0x2d9b('0x39')],_['omit'](_0x240f95['body'],['ids','id'])||{})['spread'](function(){return db['Tag'][_0x2d9b('0x22')]({'attributes':['id',_0x2d9b('0x1c'),_0x2d9b('0x4c')],'where':{'id':_0x240f95[_0x2d9b('0x36')]['ids']}});})[_0x2d9b('0x1a')](function(_0x560375){socket[_0x2d9b('0x4d')]('faxInteractionTags:save',{'id':Number(_0x240f95['params']['id']),'tags':_0x560375||[]});return{'id':Number(_0x240f95['params']['id']),'tags':_0x560375||[]};});}})[_0x2d9b('0x1a')](respondWithResult(_0x1aebbb,null))[_0x2d9b('0x25')](handleError(_0x1aebbb,null));};exports['removeTags']=function(_0x6d63b6,_0x59af83){return db['FaxInteraction'][_0x2d9b('0x34')]({'where':{'id':_0x6d63b6[_0x2d9b('0x27')]['id']}})[_0x2d9b('0x1a')](handleEntityNotFound(_0x59af83,null))[_0x2d9b('0x1a')](function(_0x12053b){if(_0x12053b){return _0x12053b[_0x2d9b('0x4e')](_0x6d63b6[_0x2d9b('0x2b')][_0x2d9b('0x39')]);}})[_0x2d9b('0x1a')](respondWithStatusCode(_0x59af83,null))[_0x2d9b('0x25')](handleError(_0x59af83,null));};exports[_0x2d9b('0x4f')]=function(_0x2f93b6,_0x2b4828){var _0xe8cd5=moment()[_0x2d9b('0x50')]()[_0x2d9b('0x51')]();var _0x19ce12=path['join'](config[_0x2d9b('0x52')],'server','files',_0x2d9b('0x53'));var _0x2fb4a9=path[_0x2d9b('0x54')](config['root'],_0x2d9b('0x55'),_0x2d9b('0x56'),'attachments');var _0x231877=path[_0x2d9b('0x54')](_0x19ce12,_0xe8cd5);var _0x4fa29a=util['format'](_0x2d9b('0x57'),_0x2f93b6['params']['id'],_0xe8cd5);var _0x1a1d89=path[_0x2d9b('0x54')](_0x19ce12,_0x4fa29a);var _0xe36156=[];_0xe36156[_0x2d9b('0x58')]({'model':db['Attachment'],'as':_0x2d9b('0x59'),'raw':!![]});var _0x14f631=[{'model':db[_0x2d9b('0x3c')],'as':_0x2d9b('0x5a'),'attributes':['id',_0x2d9b('0x36'),_0x2d9b('0x5b')],'include':_0xe36156}];return db[_0x2d9b('0x2a')]['find']({'where':{'id':_0x2f93b6[_0x2d9b('0x27')]['id']},'include':_0x14f631})['then'](handleEntityNotFound(_0x2b4828,null))[_0x2d9b('0x1a')](function(_0x57712e){if(_0x57712e&&_0x57712e[_0x2d9b('0x5a')]){var _0xa742d8=_0x57712e['get']({'plain':!![]});fs['mkdirSync'](_0x231877);for(var _0x4c307b=0x0;_0x4c307b<_0xa742d8[_0x2d9b('0x5a')]['length'];_0x4c307b++){var _0x4a3dbd=_0xa742d8['Messages'][_0x4c307b][_0x2d9b('0x59')];if(_0x4a3dbd){var _0x1be946=path[_0x2d9b('0x54')](_0x2fb4a9,_0x4a3dbd[_0x2d9b('0x5c')]);if(fs[_0x2d9b('0x5d')](_0x1be946)){fs[_0x2d9b('0x5e')](_0x1be946)[_0x2d9b('0x5f')](fs[_0x2d9b('0x60')](path[_0x2d9b('0x54')](_0x231877,_0x4a3dbd[_0x2d9b('0x5c')])));}}}return BPromise[_0x2d9b('0x61')]()['then'](function(){return new BPromise(function(_0x289b0d,_0x29c08b){zipdir(_0x231877,{'saveTo':_0x1a1d89},function(_0x41b26f,_0x23bbd7){if(_0x41b26f)return _0x29c08b(_0x41b26f);return _0x289b0d(_0x23bbd7);});})[_0x2d9b('0x1a')](function(){return new BPromise(function(_0x46a1a4,_0x304384){rimraf(_0x231877,function(_0x52fc81){if(_0x52fc81)_0x304384(_0x52fc81);return _0x46a1a4();});});})[_0x2d9b('0x1a')](function(){return _0x2b4828[_0x2d9b('0x4f')](_0x1a1d89,_0x4fa29a,function(_0x1f3f23){if(_0x1f3f23){console[_0x2d9b('0x62')](_0x2d9b('0x63'),_0x1f3f23);}else{fs[_0x2d9b('0x64')](_0x1a1d89);}});});});}else{return _0x2b4828[_0x2d9b('0xf')](0xc8);}})['catch'](handleError(_0x2b4828,null));};
\ No newline at end of file