Built motion from commit b5996064.|2.6.21
[motion2.git] / server / api / faxInteraction / faxInteraction.controller.js
index cc758d5..f59775c 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xbe91=['Attachment','Messages','createdAt','get','mkdirSync','basename','existsSync','createReadStream','createWriteStream','resolve','err','unlinkSync','rimraf','zip-dir','moment','bluebird','util','path','lodash','ioredis','../../components/parsers/qs','../../config/environment','redis','localhost','socket.io-emitter','./faxInteraction.socket','register','sendStatus','status','json','limit','undefined','count','offset','set','Content-Range','update','then','end','error','name','index','map','FaxInteraction','rawAttributes','fieldName','type','key','getOptions','findAll','fax','query','user','catch','show','params','keys','filters','intersection','model','fields','attributes','length','include','options','find','create','body','destroy','describe','addMessage','omit','getMessages','findOne','FaxMessage','hasOwnProperty','nolimit','sort','pick','where','filter','merge','$gte','split','format','YYYY-MM-DD\x20HH:mm:ss','rows','setTags','ids','spread','emit','faxInteractionTags:save','removeTags','download','unix','join','root','server','files','tmp','transcript-%d-%s.zip','push'];(function(_0x303c30,_0x16edcb){var _0x43161b=function(_0x3330ff){while(--_0x3330ff){_0x303c30['push'](_0x303c30['shift']());}};_0x43161b(++_0x16edcb);}(_0xbe91,0x1a4));var _0x1be9=function(_0x3f761d,_0x5d907d){_0x3f761d=_0x3f761d-0x0;var _0x49d6e3=_0xbe91[_0x3f761d];return _0x49d6e3;};'use strict';var rimraf=require(_0x1be9('0x0'));var zipdir=require(_0x1be9('0x1'));var moment=require(_0x1be9('0x2'));var BPromise=require(_0x1be9('0x3'));var util=require(_0x1be9('0x4'));var path=require(_0x1be9('0x5'));var fs=require('fs');var _=require(_0x1be9('0x6'));var Redis=require(_0x1be9('0x7'));var interaction=require('../../components/interaction/service');var qs=require(_0x1be9('0x8'));var logger=require('../../config/logger')('api');var config=require(_0x1be9('0x9'));var db=require('../../mysqldb')['db'];config['redis']=_['defaults'](config[_0x1be9('0xa')],{'host':_0x1be9('0xb'),'port':0x18eb});var socket=require(_0x1be9('0xc'))(new Redis(config[_0x1be9('0xa')]));require(_0x1be9('0xd'))[_0x1be9('0xe')](socket);function respondWithStatusCode(_0x300146,_0x5679e0){_0x5679e0=_0x5679e0||0xcc;return function(_0x51ea57){if(_0x51ea57){return _0x300146[_0x1be9('0xf')](_0x5679e0);}return _0x300146[_0x1be9('0x10')](_0x5679e0)['end']();};}function respondWithResult(_0x4d64a9,_0x27cc3c){_0x27cc3c=_0x27cc3c||0xc8;return function(_0x5a0528){if(_0x5a0528){return _0x4d64a9['status'](_0x27cc3c)[_0x1be9('0x11')](_0x5a0528);}};}function respondWithFilteredResult(_0x34339b,_0x40cbb5){return function(_0x415e03){if(_0x415e03){var _0x1021d9=typeof _0x40cbb5['offset']==='undefined'&&typeof _0x40cbb5[_0x1be9('0x12')]===_0x1be9('0x13');var _0x7223b0=_0x415e03[_0x1be9('0x14')];var _0xbc1902=_0x1021d9?0x0:_0x40cbb5[_0x1be9('0x15')];var _0x5a4dd4=_0x1021d9?_0x415e03['count']:_0x40cbb5[_0x1be9('0x15')]+_0x40cbb5[_0x1be9('0x12')];var _0x563ff2;if(_0x5a4dd4>=_0x7223b0){_0x5a4dd4=_0x7223b0;_0x563ff2=0xc8;}else{_0x563ff2=0xce;}_0x34339b[_0x1be9('0x10')](_0x563ff2);return _0x34339b[_0x1be9('0x16')](_0x1be9('0x17'),_0xbc1902+'-'+_0x5a4dd4+'/'+_0x7223b0)[_0x1be9('0x11')](_0x415e03);}return null;};}function saveUpdates(_0x5af92c){return function(_0xfe1b03){if(_0xfe1b03){return _0xfe1b03[_0x1be9('0x18')](_0x5af92c)[_0x1be9('0x19')](function(_0x1fde2b){return _0x1fde2b;});}return null;};}function removeEntity(_0x1af8b8){return function(_0xa56a1){if(_0xa56a1){return _0xa56a1['destroy']()[_0x1be9('0x19')](function(){_0x1af8b8['status'](0xcc)[_0x1be9('0x1a')]();});}};}function handleEntityNotFound(_0xbd2190){return function(_0x35c17b){if(!_0x35c17b){_0xbd2190[_0x1be9('0xf')](0x194);}return _0x35c17b;};}function handleError(_0x69d670,_0x36d404){_0x36d404=_0x36d404||0x1f4;return function(_0x4c0c6b){logger[_0x1be9('0x1b')](_0x4c0c6b['stack']);if(_0x4c0c6b[_0x1be9('0x1c')]){delete _0x4c0c6b[_0x1be9('0x1c')];}_0x69d670['status'](_0x36d404)['send'](_0x4c0c6b);};}exports[_0x1be9('0x1d')]=function(_0x13a5b0,_0x4a852e){var _0x289a94={};var _0x3fa30d=_[_0x1be9('0x1e')](db[_0x1be9('0x1f')][_0x1be9('0x20')],function(_0x1a0e86){return{'name':_0x1a0e86[_0x1be9('0x21')],'type':_0x1a0e86[_0x1be9('0x22')][_0x1be9('0x23')]};});_0x289a94=qs[_0x1be9('0x24')](_0x3fa30d,_0x13a5b0);return interaction[_0x1be9('0x25')](_0x1be9('0x26'),_0x13a5b0[_0x1be9('0x27')],_0x13a5b0[_0x1be9('0x28')],_0x289a94,_0x3fa30d)[_0x1be9('0x19')](respondWithFilteredResult(_0x4a852e,_0x289a94))[_0x1be9('0x29')](handleError(_0x4a852e,null));};exports[_0x1be9('0x2a')]=function(_0x27279e,_0x30740b){var _0x59564a={'raw':![],'where':{'id':_0x27279e[_0x1be9('0x2b')]['id']}},_0x14589d={};_0x14589d['model']=_[_0x1be9('0x2c')](db['FaxInteraction']['rawAttributes']);_0x14589d[_0x1be9('0x27')]=_[_0x1be9('0x2c')](_0x27279e[_0x1be9('0x27')]);_0x14589d[_0x1be9('0x2d')]=_[_0x1be9('0x2e')](_0x14589d[_0x1be9('0x2f')],_0x14589d[_0x1be9('0x27')]);_0x59564a['attributes']=_['intersection'](_0x14589d['model'],qs[_0x1be9('0x30')](_0x27279e[_0x1be9('0x27')][_0x1be9('0x30')]));_0x59564a[_0x1be9('0x31')]=_0x59564a[_0x1be9('0x31')][_0x1be9('0x32')]?_0x59564a[_0x1be9('0x31')]:_0x14589d['model'];if(_0x27279e[_0x1be9('0x27')]['includeAll']){_0x59564a[_0x1be9('0x33')]=[{'all':!![]}];}_0x59564a=_['merge']({},_0x59564a,_0x27279e[_0x1be9('0x34')]);return db[_0x1be9('0x1f')][_0x1be9('0x35')](_0x59564a)[_0x1be9('0x19')](handleEntityNotFound(_0x30740b,null))['then'](respondWithResult(_0x30740b,null))[_0x1be9('0x29')](handleError(_0x30740b,null));};exports[_0x1be9('0x36')]=function(_0xc7a459,_0x220fe5){return db[_0x1be9('0x1f')][_0x1be9('0x36')](_0xc7a459[_0x1be9('0x37')],{})[_0x1be9('0x19')](respondWithResult(_0x220fe5,0xc9))['catch'](handleError(_0x220fe5,null));};exports['update']=function(_0x123827,_0x3d735a){if(_0x123827[_0x1be9('0x37')]['id']){delete _0x123827[_0x1be9('0x37')]['id'];}return db[_0x1be9('0x1f')][_0x1be9('0x35')]({'where':{'id':_0x123827[_0x1be9('0x2b')]['id']}})[_0x1be9('0x19')](handleEntityNotFound(_0x3d735a,null))[_0x1be9('0x19')](saveUpdates(_0x123827[_0x1be9('0x37')],null))[_0x1be9('0x19')](respondWithResult(_0x3d735a,null))[_0x1be9('0x29')](handleError(_0x3d735a,null));};exports[_0x1be9('0x38')]=function(_0x417d5a,_0x46e65f){return db[_0x1be9('0x1f')][_0x1be9('0x35')]({'where':{'id':_0x417d5a[_0x1be9('0x2b')]['id']}})[_0x1be9('0x19')](handleEntityNotFound(_0x46e65f,null))[_0x1be9('0x19')](removeEntity(_0x46e65f,null))[_0x1be9('0x29')](handleError(_0x46e65f,null));};exports[_0x1be9('0x39')]=function(_0x6d5775,_0x164087){return db[_0x1be9('0x1f')][_0x1be9('0x39')]()[_0x1be9('0x19')](respondWithResult(_0x164087,null))[_0x1be9('0x29')](handleError(_0x164087,null));};exports[_0x1be9('0x3a')]=function(_0x3ada6f,_0x5787aa){return db['FaxMessage'][_0x1be9('0x35')]({'where':{'id':_0x3ada6f[_0x1be9('0x2b')]['id']}})['then'](handleEntityNotFound(_0x5787aa,null))[_0x1be9('0x19')](function(_0x134026){if(_0x134026){return _0x134026[_0x1be9('0x3a')](_0x3ada6f[_0x1be9('0x37')]['ids'],_[_0x1be9('0x3b')](_0x3ada6f[_0x1be9('0x37')],['ids','id'])||{});}})['then'](respondWithResult(_0x5787aa,null))[_0x1be9('0x29')](handleError(_0x5787aa,null));};exports[_0x1be9('0x3c')]=function(_0x282170,_0x15c145){var _0x46dbed={'raw':![],'where':{}};var _0x45471f={};var _0x10001e={'count':0x0,'rows':[]};return db[_0x1be9('0x1f')][_0x1be9('0x3d')]({'where':{'id':_0x282170[_0x1be9('0x2b')]['id']}})[_0x1be9('0x19')](handleEntityNotFound(_0x15c145,null))['then'](function(_0x27ede5){if(_0x27ede5){_0x45471f[_0x1be9('0x2f')]=_[_0x1be9('0x2c')](db[_0x1be9('0x3e')][_0x1be9('0x20')]);_0x45471f[_0x1be9('0x27')]=_[_0x1be9('0x2c')](_0x282170[_0x1be9('0x27')]);_0x45471f['filters']=_[_0x1be9('0x2e')](_0x45471f['model'],_0x45471f[_0x1be9('0x27')]);_0x46dbed[_0x1be9('0x31')]=_[_0x1be9('0x2e')](_0x45471f['model'],qs[_0x1be9('0x30')](_0x282170['query']['fields']));_0x46dbed[_0x1be9('0x31')]=_0x46dbed['attributes'][_0x1be9('0x32')]?_0x46dbed['attributes']:_0x45471f['model'];if(!_0x282170[_0x1be9('0x27')][_0x1be9('0x3f')](_0x1be9('0x40'))){_0x46dbed[_0x1be9('0x12')]=qs['limit'](_0x282170[_0x1be9('0x27')][_0x1be9('0x12')]);_0x46dbed['offset']=qs[_0x1be9('0x15')](_0x282170['query'][_0x1be9('0x15')]);}_0x46dbed['order']=qs['sort'](_0x282170[_0x1be9('0x27')][_0x1be9('0x41')]);_0x46dbed['where']=qs[_0x1be9('0x2d')](_[_0x1be9('0x42')](_0x282170['query'],_0x45471f[_0x1be9('0x2d')]));_0x46dbed[_0x1be9('0x43')]['FaxInteractionId']=_0x27ede5['id'];if(_0x282170[_0x1be9('0x27')][_0x1be9('0x44')]){_0x46dbed[_0x1be9('0x43')]=_[_0x1be9('0x45')](_0x46dbed[_0x1be9('0x43')],{'$or':_['map'](_0x46dbed[_0x1be9('0x31')],function(_0xb0cf4f){var _0x121907={};_0x121907[_0xb0cf4f]={'$like':'%'+_0x282170['query'][_0x1be9('0x44')]+'%'};return _0x121907;})});}if(_0x282170[_0x1be9('0x27')][_0x1be9('0x46')]){var _0x348742=_0x282170[_0x1be9('0x27')][_0x1be9('0x46')][_0x1be9('0x47')](',');var _0x4b0bf1={};_0x4b0bf1[_0x348742[0x0]]={'$gte':moment(_0x348742[0x1])[_0x1be9('0x48')](_0x1be9('0x49'))};_0x46dbed['where']=_[_0x1be9('0x45')](_0x46dbed['where'],_0x4b0bf1);}_0x46dbed=_['merge']({},_0x46dbed,_0x282170[_0x1be9('0x34')]);return db[_0x1be9('0x3e')][_0x1be9('0x14')]({'where':_0x46dbed[_0x1be9('0x43')]})['then'](function(_0x9d2c3d){_0x10001e[_0x1be9('0x14')]=_0x9d2c3d;if(_0x282170[_0x1be9('0x27')]['includeAll']){_0x46dbed[_0x1be9('0x33')]=[{'all':!![]}];}return db[_0x1be9('0x3e')]['findAll'](_0x46dbed);})[_0x1be9('0x19')](function(_0x30fe68){_0x10001e[_0x1be9('0x4a')]=_0x30fe68;return _0x10001e;});}})[_0x1be9('0x19')](respondWithFilteredResult(_0x15c145,_0x46dbed))[_0x1be9('0x29')](handleError(_0x15c145,null));};exports['addTags']=function(_0x1b3037,_0x54f060){return db[_0x1be9('0x1f')][_0x1be9('0x35')]({'where':{'id':_0x1b3037[_0x1be9('0x2b')]['id']}})[_0x1be9('0x19')](handleEntityNotFound(_0x54f060,null))[_0x1be9('0x19')](function(_0x5b457a){if(_0x5b457a){return _0x5b457a[_0x1be9('0x4b')](_0x1b3037[_0x1be9('0x37')][_0x1be9('0x4c')],_[_0x1be9('0x3b')](_0x1b3037[_0x1be9('0x37')],[_0x1be9('0x4c'),'id'])||{})[_0x1be9('0x4d')](function(){return db['Tag']['findAll']({'attributes':['id',_0x1be9('0x1c'),'color'],'where':{'id':_0x1b3037[_0x1be9('0x37')]['ids']}});})[_0x1be9('0x19')](function(_0x2ceafe){socket[_0x1be9('0x4e')](_0x1be9('0x4f'),{'id':Number(_0x1b3037['params']['id']),'tags':_0x2ceafe||[]});return{'id':Number(_0x1b3037[_0x1be9('0x2b')]['id']),'tags':_0x2ceafe||[]};});}})[_0x1be9('0x19')](respondWithResult(_0x54f060,null))['catch'](handleError(_0x54f060,null));};exports[_0x1be9('0x50')]=function(_0x56fd83,_0x4e61c5){return db[_0x1be9('0x1f')][_0x1be9('0x35')]({'where':{'id':_0x56fd83['params']['id']}})[_0x1be9('0x19')](handleEntityNotFound(_0x4e61c5,null))[_0x1be9('0x19')](function(_0x27d0b9){if(_0x27d0b9){return _0x27d0b9[_0x1be9('0x50')](_0x56fd83[_0x1be9('0x27')][_0x1be9('0x4c')]);}})['then'](respondWithStatusCode(_0x4e61c5,null))[_0x1be9('0x29')](handleError(_0x4e61c5,null));};exports[_0x1be9('0x51')]=function(_0x356158,_0xe31a11){var _0x391be1=moment()[_0x1be9('0x52')]()['toString']();var _0x524e61=path[_0x1be9('0x53')](config[_0x1be9('0x54')],_0x1be9('0x55'),_0x1be9('0x56'),_0x1be9('0x57'));var _0x2b814a=path[_0x1be9('0x53')](config[_0x1be9('0x54')],_0x1be9('0x55'),'files','attachments');var _0x5a5b4c=path[_0x1be9('0x53')](_0x524e61,_0x391be1);var _0x2391de=util['format'](_0x1be9('0x58'),_0x356158[_0x1be9('0x2b')]['id'],_0x391be1);var _0x4a570d=path['join'](_0x524e61,_0x2391de);var _0x19dbc1=[];_0x19dbc1[_0x1be9('0x59')]({'model':db['Attachment'],'as':_0x1be9('0x5a'),'raw':!![]});var _0x5641b1=[{'model':db['FaxMessage'],'as':_0x1be9('0x5b'),'attributes':['id',_0x1be9('0x37'),_0x1be9('0x5c')],'include':_0x19dbc1}];return db[_0x1be9('0x1f')][_0x1be9('0x35')]({'where':{'id':_0x356158[_0x1be9('0x2b')]['id']},'include':_0x5641b1})[_0x1be9('0x19')](handleEntityNotFound(_0xe31a11,null))[_0x1be9('0x19')](function(_0x2098d6){if(_0x2098d6&&_0x2098d6[_0x1be9('0x5b')]){var _0x37c42d=_0x2098d6[_0x1be9('0x5d')]({'plain':!![]});fs[_0x1be9('0x5e')](_0x5a5b4c);for(var _0x5d711e=0x0;_0x5d711e<_0x37c42d['Messages'][_0x1be9('0x32')];_0x5d711e++){var _0x39a91a=_0x37c42d[_0x1be9('0x5b')][_0x5d711e][_0x1be9('0x5a')];if(_0x39a91a){var _0x5aa20d=path['join'](_0x2b814a,_0x39a91a[_0x1be9('0x5f')]);if(fs[_0x1be9('0x60')](_0x5aa20d)){fs[_0x1be9('0x61')](_0x5aa20d)['pipe'](fs[_0x1be9('0x62')](path[_0x1be9('0x53')](_0x5a5b4c,_0x39a91a[_0x1be9('0x5f')])));}}}return BPromise[_0x1be9('0x63')]()[_0x1be9('0x19')](function(){return new BPromise(function(_0x53fa60,_0x4bf329){zipdir(_0x5a5b4c,{'saveTo':_0x4a570d},function(_0x4265b7,_0x134014){if(_0x4265b7)return _0x4bf329(_0x4265b7);return _0x53fa60(_0x134014);});})['then'](function(){return new BPromise(function(_0x3cb8dc,_0x3603dc){rimraf(_0x5a5b4c,function(_0x2bcd3a){if(_0x2bcd3a)_0x3603dc(_0x2bcd3a);return _0x3cb8dc();});});})['then'](function(){return _0xe31a11[_0x1be9('0x51')](_0x4a570d,_0x2391de,function(_0xbd3d2c){if(_0xbd3d2c){console['log'](_0x1be9('0x64'),_0xbd3d2c);}else{fs[_0x1be9('0x65')](_0x4a570d);}});});});}else{return _0xe31a11[_0x1be9('0xf')](0xc8);}})['catch'](handleError(_0xe31a11,null));};
\ No newline at end of file
+var _0xfc9c=['defaults','localhost','socket.io-emitter','./faxInteraction.socket','sendStatus','end','status','limit','undefined','count','offset','set','Content-Range','json','update','then','destroy','name','send','map','FaxInteraction','type','key','getOptions','findAll','query','user','catch','show','params','model','keys','rawAttributes','filters','intersection','attributes','length','includeAll','include','merge','options','find','create','body','describe','FaxMessage','addMessage','ids','omit','getMessages','findOne','fields','nolimit','order','sort','where','pick','filter','$gte','split','format','YYYY-MM-DD\x20HH:mm:ss','rows','addTags','setTags','color','removeTags','download','unix','toString','join','root','server','files','tmp','transcript-%d-%s.zip','Attachment','createdAt','Messages','get','mkdirSync','basename','existsSync','createReadStream','pipe','createWriteStream','resolve','err','unlinkSync','zip-dir','moment','bluebird','util','path','lodash','ioredis','../../components/parsers/qs','../../mysqldb','redis'];(function(_0x4243a3,_0x447337){var _0x1b2a33=function(_0x6a8200){while(--_0x6a8200){_0x4243a3['push'](_0x4243a3['shift']());}};_0x1b2a33(++_0x447337);}(_0xfc9c,0x11f));var _0xcfc9=function(_0x6250d6,_0x89713c){_0x6250d6=_0x6250d6-0x0;var _0x5c5e76=_0xfc9c[_0x6250d6];return _0x5c5e76;};'use strict';var rimraf=require('rimraf');var zipdir=require(_0xcfc9('0x0'));var moment=require(_0xcfc9('0x1'));var BPromise=require(_0xcfc9('0x2'));var util=require(_0xcfc9('0x3'));var path=require(_0xcfc9('0x4'));var fs=require('fs');var _=require(_0xcfc9('0x5'));var Redis=require(_0xcfc9('0x6'));var interaction=require('../../components/interaction/service');var qs=require(_0xcfc9('0x7'));var logger=require('../../config/logger')('api');var config=require('../../config/environment');var db=require(_0xcfc9('0x8'))['db'];config[_0xcfc9('0x9')]=_[_0xcfc9('0xa')](config[_0xcfc9('0x9')],{'host':_0xcfc9('0xb'),'port':0x18eb});var socket=require(_0xcfc9('0xc'))(new Redis(config[_0xcfc9('0x9')]));require(_0xcfc9('0xd'))['register'](socket);function respondWithStatusCode(_0xd540c9,_0x18b7f8){_0x18b7f8=_0x18b7f8||0xcc;return function(_0x114cb5){if(_0x114cb5){return _0xd540c9[_0xcfc9('0xe')](_0x18b7f8);}return _0xd540c9['status'](_0x18b7f8)[_0xcfc9('0xf')]();};}function respondWithResult(_0x51f37f,_0x3adc77){_0x3adc77=_0x3adc77||0xc8;return function(_0x2250d){if(_0x2250d){return _0x51f37f[_0xcfc9('0x10')](_0x3adc77)['json'](_0x2250d);}};}function respondWithFilteredResult(_0x224ee6,_0x262817){return function(_0x4af4a1){if(_0x4af4a1){var _0x4ffced=typeof _0x262817['offset']==='undefined'&&typeof _0x262817[_0xcfc9('0x11')]===_0xcfc9('0x12');var _0x3b6ae6=_0x4af4a1[_0xcfc9('0x13')];var _0x2a26ba=_0x4ffced?0x0:_0x262817[_0xcfc9('0x14')];var _0x274db2=_0x4ffced?_0x4af4a1[_0xcfc9('0x13')]:_0x262817['offset']+_0x262817[_0xcfc9('0x11')];var _0x5f0215;if(_0x274db2>=_0x3b6ae6){_0x274db2=_0x3b6ae6;_0x5f0215=0xc8;}else{_0x5f0215=0xce;}_0x224ee6[_0xcfc9('0x10')](_0x5f0215);return _0x224ee6[_0xcfc9('0x15')](_0xcfc9('0x16'),_0x2a26ba+'-'+_0x274db2+'/'+_0x3b6ae6)[_0xcfc9('0x17')](_0x4af4a1);}return null;};}function saveUpdates(_0x2bcb35){return function(_0x17837c){if(_0x17837c){return _0x17837c[_0xcfc9('0x18')](_0x2bcb35)[_0xcfc9('0x19')](function(_0x2447f1){return _0x2447f1;});}return null;};}function removeEntity(_0x1ddc58){return function(_0x13221e){if(_0x13221e){return _0x13221e[_0xcfc9('0x1a')]()['then'](function(){_0x1ddc58[_0xcfc9('0x10')](0xcc)[_0xcfc9('0xf')]();});}};}function handleEntityNotFound(_0x78b575){return function(_0x459f73){if(!_0x459f73){_0x78b575[_0xcfc9('0xe')](0x194);}return _0x459f73;};}function handleError(_0x208db0,_0x5cb1fa){_0x5cb1fa=_0x5cb1fa||0x1f4;return function(_0xca7cd5){logger['error'](_0xca7cd5['stack']);if(_0xca7cd5[_0xcfc9('0x1b')]){delete _0xca7cd5[_0xcfc9('0x1b')];}_0x208db0[_0xcfc9('0x10')](_0x5cb1fa)[_0xcfc9('0x1c')](_0xca7cd5);};}exports['index']=function(_0x2621ce,_0x2c2d1c){var _0x272147={};var _0xac1884=_[_0xcfc9('0x1d')](db[_0xcfc9('0x1e')]['rawAttributes'],function(_0x17b66a){return{'name':_0x17b66a['fieldName'],'type':_0x17b66a[_0xcfc9('0x1f')][_0xcfc9('0x20')]};});_0x272147=qs[_0xcfc9('0x21')](_0xac1884,_0x2621ce);return interaction[_0xcfc9('0x22')]('fax',_0x2621ce[_0xcfc9('0x23')],_0x2621ce[_0xcfc9('0x24')],_0x272147,_0xac1884)['then'](respondWithFilteredResult(_0x2c2d1c,_0x272147))[_0xcfc9('0x25')](handleError(_0x2c2d1c,null));};exports[_0xcfc9('0x26')]=function(_0x76179a,_0x4ed4cb){var _0x4cfdfa={'raw':![],'where':{'id':_0x76179a[_0xcfc9('0x27')]['id']}},_0x4a2fa8={};_0x4a2fa8[_0xcfc9('0x28')]=_[_0xcfc9('0x29')](db[_0xcfc9('0x1e')][_0xcfc9('0x2a')]);_0x4a2fa8[_0xcfc9('0x23')]=_[_0xcfc9('0x29')](_0x76179a['query']);_0x4a2fa8[_0xcfc9('0x2b')]=_[_0xcfc9('0x2c')](_0x4a2fa8[_0xcfc9('0x28')],_0x4a2fa8['query']);_0x4cfdfa['attributes']=_['intersection'](_0x4a2fa8[_0xcfc9('0x28')],qs['fields'](_0x76179a[_0xcfc9('0x23')]['fields']));_0x4cfdfa[_0xcfc9('0x2d')]=_0x4cfdfa[_0xcfc9('0x2d')][_0xcfc9('0x2e')]?_0x4cfdfa[_0xcfc9('0x2d')]:_0x4a2fa8['model'];if(_0x76179a[_0xcfc9('0x23')][_0xcfc9('0x2f')]){_0x4cfdfa[_0xcfc9('0x30')]=[{'all':!![]}];}_0x4cfdfa=_[_0xcfc9('0x31')]({},_0x4cfdfa,_0x76179a[_0xcfc9('0x32')]);return db[_0xcfc9('0x1e')][_0xcfc9('0x33')](_0x4cfdfa)['then'](handleEntityNotFound(_0x4ed4cb,null))[_0xcfc9('0x19')](respondWithResult(_0x4ed4cb,null))['catch'](handleError(_0x4ed4cb,null));};exports[_0xcfc9('0x34')]=function(_0x20eee0,_0x48b58a){return db[_0xcfc9('0x1e')][_0xcfc9('0x34')](_0x20eee0[_0xcfc9('0x35')],{})[_0xcfc9('0x19')](respondWithResult(_0x48b58a,0xc9))[_0xcfc9('0x25')](handleError(_0x48b58a,null));};exports['update']=function(_0x3fa8ee,_0x547f45){if(_0x3fa8ee['body']['id']){delete _0x3fa8ee[_0xcfc9('0x35')]['id'];}return db[_0xcfc9('0x1e')]['find']({'where':{'id':_0x3fa8ee[_0xcfc9('0x27')]['id']}})[_0xcfc9('0x19')](handleEntityNotFound(_0x547f45,null))[_0xcfc9('0x19')](saveUpdates(_0x3fa8ee[_0xcfc9('0x35')],null))[_0xcfc9('0x19')](respondWithResult(_0x547f45,null))[_0xcfc9('0x25')](handleError(_0x547f45,null));};exports[_0xcfc9('0x1a')]=function(_0x1d99d7,_0x336f20){return db['FaxInteraction'][_0xcfc9('0x33')]({'where':{'id':_0x1d99d7[_0xcfc9('0x27')]['id']}})[_0xcfc9('0x19')](handleEntityNotFound(_0x336f20,null))[_0xcfc9('0x19')](removeEntity(_0x336f20,null))[_0xcfc9('0x25')](handleError(_0x336f20,null));};exports[_0xcfc9('0x36')]=function(_0x2c4596,_0x547499){return db[_0xcfc9('0x1e')][_0xcfc9('0x36')]()[_0xcfc9('0x19')](respondWithResult(_0x547499,null))[_0xcfc9('0x25')](handleError(_0x547499,null));};exports['addMessage']=function(_0x586b97,_0x36b432){return db[_0xcfc9('0x37')][_0xcfc9('0x33')]({'where':{'id':_0x586b97[_0xcfc9('0x27')]['id']}})['then'](handleEntityNotFound(_0x36b432,null))['then'](function(_0x5bf0bc){if(_0x5bf0bc){return _0x5bf0bc[_0xcfc9('0x38')](_0x586b97[_0xcfc9('0x35')][_0xcfc9('0x39')],_[_0xcfc9('0x3a')](_0x586b97['body'],[_0xcfc9('0x39'),'id'])||{});}})[_0xcfc9('0x19')](respondWithResult(_0x36b432,null))[_0xcfc9('0x25')](handleError(_0x36b432,null));};exports[_0xcfc9('0x3b')]=function(_0x4b9e57,_0x391dcb){var _0x1dc52d={'raw':![],'where':{}};var _0x2ca297={};var _0x286730={'count':0x0,'rows':[]};return db[_0xcfc9('0x1e')][_0xcfc9('0x3c')]({'where':{'id':_0x4b9e57[_0xcfc9('0x27')]['id']}})[_0xcfc9('0x19')](handleEntityNotFound(_0x391dcb,null))['then'](function(_0x3b039c){if(_0x3b039c){_0x2ca297[_0xcfc9('0x28')]=_[_0xcfc9('0x29')](db[_0xcfc9('0x37')][_0xcfc9('0x2a')]);_0x2ca297['query']=_[_0xcfc9('0x29')](_0x4b9e57[_0xcfc9('0x23')]);_0x2ca297[_0xcfc9('0x2b')]=_['intersection'](_0x2ca297['model'],_0x2ca297['query']);_0x1dc52d[_0xcfc9('0x2d')]=_[_0xcfc9('0x2c')](_0x2ca297[_0xcfc9('0x28')],qs[_0xcfc9('0x3d')](_0x4b9e57[_0xcfc9('0x23')][_0xcfc9('0x3d')]));_0x1dc52d['attributes']=_0x1dc52d['attributes'][_0xcfc9('0x2e')]?_0x1dc52d['attributes']:_0x2ca297[_0xcfc9('0x28')];if(!_0x4b9e57[_0xcfc9('0x23')]['hasOwnProperty'](_0xcfc9('0x3e'))){_0x1dc52d[_0xcfc9('0x11')]=qs[_0xcfc9('0x11')](_0x4b9e57[_0xcfc9('0x23')][_0xcfc9('0x11')]);_0x1dc52d[_0xcfc9('0x14')]=qs[_0xcfc9('0x14')](_0x4b9e57[_0xcfc9('0x23')][_0xcfc9('0x14')]);}_0x1dc52d[_0xcfc9('0x3f')]=qs[_0xcfc9('0x40')](_0x4b9e57['query']['sort']);_0x1dc52d[_0xcfc9('0x41')]=qs['filters'](_[_0xcfc9('0x42')](_0x4b9e57[_0xcfc9('0x23')],_0x2ca297[_0xcfc9('0x2b')]));_0x1dc52d['where']['FaxInteractionId']=_0x3b039c['id'];if(_0x4b9e57[_0xcfc9('0x23')][_0xcfc9('0x43')]){_0x1dc52d[_0xcfc9('0x41')]=_[_0xcfc9('0x31')](_0x1dc52d[_0xcfc9('0x41')],{'$or':_['map'](_0x1dc52d[_0xcfc9('0x2d')],function(_0x4a3df0){var _0x33ba64={};_0x33ba64[_0x4a3df0]={'$like':'%'+_0x4b9e57['query'][_0xcfc9('0x43')]+'%'};return _0x33ba64;})});}if(_0x4b9e57[_0xcfc9('0x23')][_0xcfc9('0x44')]){var _0x51a11d=_0x4b9e57[_0xcfc9('0x23')][_0xcfc9('0x44')][_0xcfc9('0x45')](',');var _0x2ccc03={};_0x2ccc03[_0x51a11d[0x0]]={'$gte':moment(_0x51a11d[0x1])[_0xcfc9('0x46')](_0xcfc9('0x47'))};_0x1dc52d[_0xcfc9('0x41')]=_[_0xcfc9('0x31')](_0x1dc52d[_0xcfc9('0x41')],_0x2ccc03);}_0x1dc52d=_[_0xcfc9('0x31')]({},_0x1dc52d,_0x4b9e57[_0xcfc9('0x32')]);return db[_0xcfc9('0x37')][_0xcfc9('0x13')]({'where':_0x1dc52d[_0xcfc9('0x41')]})[_0xcfc9('0x19')](function(_0x5cd9c6){_0x286730[_0xcfc9('0x13')]=_0x5cd9c6;if(_0x4b9e57[_0xcfc9('0x23')][_0xcfc9('0x2f')]){_0x1dc52d[_0xcfc9('0x30')]=[{'all':!![]}];}return db[_0xcfc9('0x37')][_0xcfc9('0x22')](_0x1dc52d);})[_0xcfc9('0x19')](function(_0x4ad4d1){_0x286730[_0xcfc9('0x48')]=_0x4ad4d1;return _0x286730;});}})[_0xcfc9('0x19')](respondWithFilteredResult(_0x391dcb,_0x1dc52d))[_0xcfc9('0x25')](handleError(_0x391dcb,null));};exports[_0xcfc9('0x49')]=function(_0x3080b8,_0x14c486){return db[_0xcfc9('0x1e')][_0xcfc9('0x33')]({'where':{'id':_0x3080b8[_0xcfc9('0x27')]['id']}})[_0xcfc9('0x19')](handleEntityNotFound(_0x14c486,null))[_0xcfc9('0x19')](function(_0x5381d9){if(_0x5381d9){return _0x5381d9[_0xcfc9('0x4a')](_0x3080b8[_0xcfc9('0x35')][_0xcfc9('0x39')],_[_0xcfc9('0x3a')](_0x3080b8[_0xcfc9('0x35')],['ids','id'])||{})['spread'](function(){return db['Tag'][_0xcfc9('0x22')]({'attributes':['id',_0xcfc9('0x1b'),_0xcfc9('0x4b')],'where':{'id':_0x3080b8[_0xcfc9('0x35')]['ids']}});})[_0xcfc9('0x19')](function(_0x381f6f){socket['emit']('faxInteractionTags:save',{'id':Number(_0x3080b8[_0xcfc9('0x27')]['id']),'tags':_0x381f6f||[]});return{'id':Number(_0x3080b8['params']['id']),'tags':_0x381f6f||[]};});}})[_0xcfc9('0x19')](respondWithResult(_0x14c486,null))[_0xcfc9('0x25')](handleError(_0x14c486,null));};exports[_0xcfc9('0x4c')]=function(_0x43b6ca,_0x4a5421){return db['FaxInteraction'][_0xcfc9('0x33')]({'where':{'id':_0x43b6ca[_0xcfc9('0x27')]['id']}})[_0xcfc9('0x19')](handleEntityNotFound(_0x4a5421,null))[_0xcfc9('0x19')](function(_0x2a0789){if(_0x2a0789){return _0x2a0789[_0xcfc9('0x4c')](_0x43b6ca[_0xcfc9('0x23')][_0xcfc9('0x39')]);}})[_0xcfc9('0x19')](respondWithStatusCode(_0x4a5421,null))[_0xcfc9('0x25')](handleError(_0x4a5421,null));};exports[_0xcfc9('0x4d')]=function(_0x8a429f,_0x4f74d9){var _0x3574fc=moment()[_0xcfc9('0x4e')]()[_0xcfc9('0x4f')]();var _0x16c927=path[_0xcfc9('0x50')](config[_0xcfc9('0x51')],_0xcfc9('0x52'),_0xcfc9('0x53'),_0xcfc9('0x54'));var _0x702eb6=path[_0xcfc9('0x50')](config[_0xcfc9('0x51')],'server',_0xcfc9('0x53'),'attachments');var _0x5e254f=path[_0xcfc9('0x50')](_0x16c927,_0x3574fc);var _0x4ee48a=util[_0xcfc9('0x46')](_0xcfc9('0x55'),_0x8a429f['params']['id'],_0x3574fc);var _0x40405b=path[_0xcfc9('0x50')](_0x16c927,_0x4ee48a);var _0xe028af=[];_0xe028af['push']({'model':db[_0xcfc9('0x56')],'as':_0xcfc9('0x56'),'raw':!![]});var _0x444967=[{'model':db[_0xcfc9('0x37')],'as':'Messages','attributes':['id',_0xcfc9('0x35'),_0xcfc9('0x57')],'include':_0xe028af}];return db[_0xcfc9('0x1e')][_0xcfc9('0x33')]({'where':{'id':_0x8a429f[_0xcfc9('0x27')]['id']},'include':_0x444967})[_0xcfc9('0x19')](handleEntityNotFound(_0x4f74d9,null))['then'](function(_0x46a532){if(_0x46a532&&_0x46a532[_0xcfc9('0x58')]){var _0x510f4d=_0x46a532[_0xcfc9('0x59')]({'plain':!![]});fs[_0xcfc9('0x5a')](_0x5e254f);for(var _0x5dea59=0x0;_0x5dea59<_0x510f4d[_0xcfc9('0x58')][_0xcfc9('0x2e')];_0x5dea59++){var _0xf9ac9=_0x510f4d[_0xcfc9('0x58')][_0x5dea59][_0xcfc9('0x56')];if(_0xf9ac9){var _0x27364d=path[_0xcfc9('0x50')](_0x702eb6,_0xf9ac9[_0xcfc9('0x5b')]);if(fs[_0xcfc9('0x5c')](_0x27364d)){fs[_0xcfc9('0x5d')](_0x27364d)[_0xcfc9('0x5e')](fs[_0xcfc9('0x5f')](path['join'](_0x5e254f,_0xf9ac9['basename'])));}}}return BPromise[_0xcfc9('0x60')]()[_0xcfc9('0x19')](function(){return new BPromise(function(_0x119878,_0x5b5c11){zipdir(_0x5e254f,{'saveTo':_0x40405b},function(_0x15be60,_0x4a0a65){if(_0x15be60)return _0x5b5c11(_0x15be60);return _0x119878(_0x4a0a65);});})[_0xcfc9('0x19')](function(){return new BPromise(function(_0x14994c,_0x27f0aa){rimraf(_0x5e254f,function(_0x1e9a2c){if(_0x1e9a2c)_0x27f0aa(_0x1e9a2c);return _0x14994c();});});})[_0xcfc9('0x19')](function(){return _0x4f74d9['download'](_0x40405b,_0x4ee48a,function(_0xd7d5e3){if(_0xd7d5e3){console['log'](_0xcfc9('0x61'),_0xd7d5e3);}else{fs[_0xcfc9('0x62')](_0x40405b);}});});});}else{return _0x4f74d9[_0xcfc9('0xe')](0xc8);}})[_0xcfc9('0x25')](handleError(_0x4f74d9,null));};
\ No newline at end of file