Built motion from commit 3d3e98f2.|2.6.29
[motion2.git] / server / api / faxInteraction / faxInteraction.controller.js
index dcec1c4..192a4f2 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xbad1=['query','user','catch','show','params','model','keys','filters','intersection','attributes','fields','includeAll','include','merge','options','find','create','body','describe','addMessage','FaxMessage','ids','getMessages','findOne','length','hasOwnProperty','nolimit','order','pick','where','FaxInteractionId','filter','$gte','split','format','YYYY-MM-DD\x20HH:mm:ss','rows','addTags','setTags','omit','spread','Tag','color','emit','faxInteractionTags:save','removeTags','download','toString','join','root','server','files','tmp','attachments','transcript-%d-%s.zip','push','Attachment','Messages','mkdirSync','basename','existsSync','createReadStream','resolve','log','unlinkSync','rimraf','zip-dir','moment','util','lodash','ioredis','../../components/interaction/service','../../config/logger','api','../../config/environment','../../mysqldb','redis','localhost','socket.io-emitter','register','status','end','offset','undefined','limit','count','set','Content-Range','json','update','then','destroy','sendStatus','error','name','send','index','map','FaxInteraction','rawAttributes','fieldName','type','key','getOptions','findAll','fax'];(function(_0x1d8495,_0x4a09fa){var _0x513a8b=function(_0x286e79){while(--_0x286e79){_0x1d8495['push'](_0x1d8495['shift']());}};_0x513a8b(++_0x4a09fa);}(_0xbad1,0x115));var _0x1bad=function(_0x544f22,_0x4d4ad8){_0x544f22=_0x544f22-0x0;var _0x47090b=_0xbad1[_0x544f22];return _0x47090b;};'use strict';var rimraf=require(_0x1bad('0x0'));var zipdir=require(_0x1bad('0x1'));var moment=require(_0x1bad('0x2'));var BPromise=require('bluebird');var util=require(_0x1bad('0x3'));var path=require('path');var fs=require('fs');var _=require(_0x1bad('0x4'));var Redis=require(_0x1bad('0x5'));var interaction=require(_0x1bad('0x6'));var qs=require('../../components/parsers/qs');var logger=require(_0x1bad('0x7'))(_0x1bad('0x8'));var config=require(_0x1bad('0x9'));var db=require(_0x1bad('0xa'))['db'];config[_0x1bad('0xb')]=_['defaults'](config['redis'],{'host':_0x1bad('0xc'),'port':0x18eb});var socket=require(_0x1bad('0xd'))(new Redis(config[_0x1bad('0xb')]));require('./faxInteraction.socket')[_0x1bad('0xe')](socket);function respondWithStatusCode(_0x46005e,_0x158eb9){_0x158eb9=_0x158eb9||0xcc;return function(_0x24f97b){if(_0x24f97b){return _0x46005e['sendStatus'](_0x158eb9);}return _0x46005e[_0x1bad('0xf')](_0x158eb9)[_0x1bad('0x10')]();};}function respondWithResult(_0x42de37,_0x231dae){_0x231dae=_0x231dae||0xc8;return function(_0x49feca){if(_0x49feca){return _0x42de37['status'](_0x231dae)['json'](_0x49feca);}};}function respondWithFilteredResult(_0x4edc78,_0x106213){return function(_0x297303){if(_0x297303){var _0x1d03e8=typeof _0x106213[_0x1bad('0x11')]===_0x1bad('0x12')&&typeof _0x106213[_0x1bad('0x13')]===_0x1bad('0x12');var _0x1e46fe=_0x297303[_0x1bad('0x14')];var _0x1d38eb=_0x1d03e8?0x0:_0x106213[_0x1bad('0x11')];var _0xef259f=_0x1d03e8?_0x297303[_0x1bad('0x14')]:_0x106213[_0x1bad('0x11')]+_0x106213[_0x1bad('0x13')];var _0x4830f0;if(_0xef259f>=_0x1e46fe){_0xef259f=_0x1e46fe;_0x4830f0=0xc8;}else{_0x4830f0=0xce;}_0x4edc78[_0x1bad('0xf')](_0x4830f0);return _0x4edc78[_0x1bad('0x15')](_0x1bad('0x16'),_0x1d38eb+'-'+_0xef259f+'/'+_0x1e46fe)[_0x1bad('0x17')](_0x297303);}return null;};}function saveUpdates(_0x38ab72){return function(_0x595135){if(_0x595135){return _0x595135[_0x1bad('0x18')](_0x38ab72)[_0x1bad('0x19')](function(_0x4f2343){return _0x4f2343;});}return null;};}function removeEntity(_0x3f9daf){return function(_0x2c489d){if(_0x2c489d){return _0x2c489d[_0x1bad('0x1a')]()['then'](function(){_0x3f9daf[_0x1bad('0xf')](0xcc)[_0x1bad('0x10')]();});}};}function handleEntityNotFound(_0x267b08){return function(_0x30f04c){if(!_0x30f04c){_0x267b08[_0x1bad('0x1b')](0x194);}return _0x30f04c;};}function handleError(_0x2ff3f1,_0x3b7269){_0x3b7269=_0x3b7269||0x1f4;return function(_0x217ee2){logger[_0x1bad('0x1c')](_0x217ee2['stack']);if(_0x217ee2[_0x1bad('0x1d')]){delete _0x217ee2[_0x1bad('0x1d')];}_0x2ff3f1[_0x1bad('0xf')](_0x3b7269)[_0x1bad('0x1e')](_0x217ee2);};}exports[_0x1bad('0x1f')]=function(_0x2d1c27,_0x32a7bd){var _0x126027={};var _0x1fbe36=_[_0x1bad('0x20')](db[_0x1bad('0x21')][_0x1bad('0x22')],function(_0x5e4bb1){return{'name':_0x5e4bb1[_0x1bad('0x23')],'type':_0x5e4bb1[_0x1bad('0x24')][_0x1bad('0x25')]};});_0x126027=qs[_0x1bad('0x26')](_0x1fbe36,_0x2d1c27);return interaction[_0x1bad('0x27')](_0x1bad('0x28'),_0x2d1c27[_0x1bad('0x29')],_0x2d1c27[_0x1bad('0x2a')],_0x126027,_0x1fbe36)[_0x1bad('0x19')](respondWithFilteredResult(_0x32a7bd,_0x126027))[_0x1bad('0x2b')](handleError(_0x32a7bd,null));};exports[_0x1bad('0x2c')]=function(_0x12546c,_0x35a7a9){var _0x26a581={'raw':![],'where':{'id':_0x12546c[_0x1bad('0x2d')]['id']}},_0x583f02={};_0x583f02[_0x1bad('0x2e')]=_['keys'](db['FaxInteraction'][_0x1bad('0x22')]);_0x583f02[_0x1bad('0x29')]=_[_0x1bad('0x2f')](_0x12546c[_0x1bad('0x29')]);_0x583f02[_0x1bad('0x30')]=_[_0x1bad('0x31')](_0x583f02[_0x1bad('0x2e')],_0x583f02[_0x1bad('0x29')]);_0x26a581[_0x1bad('0x32')]=_[_0x1bad('0x31')](_0x583f02[_0x1bad('0x2e')],qs[_0x1bad('0x33')](_0x12546c['query'][_0x1bad('0x33')]));_0x26a581['attributes']=_0x26a581[_0x1bad('0x32')]['length']?_0x26a581[_0x1bad('0x32')]:_0x583f02[_0x1bad('0x2e')];if(_0x12546c[_0x1bad('0x29')][_0x1bad('0x34')]){_0x26a581[_0x1bad('0x35')]=[{'all':!![]}];}_0x26a581=_[_0x1bad('0x36')]({},_0x26a581,_0x12546c[_0x1bad('0x37')]);return db['FaxInteraction'][_0x1bad('0x38')](_0x26a581)['then'](handleEntityNotFound(_0x35a7a9,null))[_0x1bad('0x19')](respondWithResult(_0x35a7a9,null))[_0x1bad('0x2b')](handleError(_0x35a7a9,null));};exports[_0x1bad('0x39')]=function(_0x984711,_0x19c2dc){return db[_0x1bad('0x21')][_0x1bad('0x39')](_0x984711[_0x1bad('0x3a')],{})['then'](respondWithResult(_0x19c2dc,0xc9))['catch'](handleError(_0x19c2dc,null));};exports[_0x1bad('0x18')]=function(_0x2189e6,_0x423bf1){if(_0x2189e6[_0x1bad('0x3a')]['id']){delete _0x2189e6[_0x1bad('0x3a')]['id'];}return db[_0x1bad('0x21')][_0x1bad('0x38')]({'where':{'id':_0x2189e6['params']['id']}})[_0x1bad('0x19')](handleEntityNotFound(_0x423bf1,null))[_0x1bad('0x19')](saveUpdates(_0x2189e6[_0x1bad('0x3a')],null))[_0x1bad('0x19')](respondWithResult(_0x423bf1,null))[_0x1bad('0x2b')](handleError(_0x423bf1,null));};exports[_0x1bad('0x1a')]=function(_0x1caad9,_0x493343){return db[_0x1bad('0x21')]['find']({'where':{'id':_0x1caad9['params']['id']}})[_0x1bad('0x19')](handleEntityNotFound(_0x493343,null))['then'](removeEntity(_0x493343,null))[_0x1bad('0x2b')](handleError(_0x493343,null));};exports[_0x1bad('0x3b')]=function(_0x1d971e,_0x558523){return db[_0x1bad('0x21')][_0x1bad('0x3b')]()[_0x1bad('0x19')](respondWithResult(_0x558523,null))[_0x1bad('0x2b')](handleError(_0x558523,null));};exports[_0x1bad('0x3c')]=function(_0x2723c1,_0x165495){return db[_0x1bad('0x3d')][_0x1bad('0x38')]({'where':{'id':_0x2723c1['params']['id']}})[_0x1bad('0x19')](handleEntityNotFound(_0x165495,null))[_0x1bad('0x19')](function(_0x336dd6){if(_0x336dd6){return _0x336dd6['addMessage'](_0x2723c1[_0x1bad('0x3a')][_0x1bad('0x3e')],_['omit'](_0x2723c1[_0x1bad('0x3a')],[_0x1bad('0x3e'),'id'])||{});}})[_0x1bad('0x19')](respondWithResult(_0x165495,null))['catch'](handleError(_0x165495,null));};exports[_0x1bad('0x3f')]=function(_0x3edeca,_0x1df2ee){var _0x297d25={'raw':![],'where':{}};var _0x4ac498={};var _0x40ebbb={'count':0x0,'rows':[]};return db[_0x1bad('0x21')][_0x1bad('0x40')]({'where':{'id':_0x3edeca['params']['id']}})[_0x1bad('0x19')](handleEntityNotFound(_0x1df2ee,null))['then'](function(_0x561097){if(_0x561097){_0x4ac498[_0x1bad('0x2e')]=_['keys'](db[_0x1bad('0x3d')]['rawAttributes']);_0x4ac498[_0x1bad('0x29')]=_[_0x1bad('0x2f')](_0x3edeca[_0x1bad('0x29')]);_0x4ac498[_0x1bad('0x30')]=_[_0x1bad('0x31')](_0x4ac498['model'],_0x4ac498[_0x1bad('0x29')]);_0x297d25[_0x1bad('0x32')]=_[_0x1bad('0x31')](_0x4ac498[_0x1bad('0x2e')],qs[_0x1bad('0x33')](_0x3edeca[_0x1bad('0x29')][_0x1bad('0x33')]));_0x297d25['attributes']=_0x297d25['attributes'][_0x1bad('0x41')]?_0x297d25['attributes']:_0x4ac498['model'];if(!_0x3edeca[_0x1bad('0x29')][_0x1bad('0x42')](_0x1bad('0x43'))){_0x297d25['limit']=qs['limit'](_0x3edeca[_0x1bad('0x29')]['limit']);_0x297d25[_0x1bad('0x11')]=qs[_0x1bad('0x11')](_0x3edeca[_0x1bad('0x29')][_0x1bad('0x11')]);}_0x297d25[_0x1bad('0x44')]=qs['sort'](_0x3edeca[_0x1bad('0x29')]['sort']);_0x297d25['where']=qs[_0x1bad('0x30')](_[_0x1bad('0x45')](_0x3edeca[_0x1bad('0x29')],_0x4ac498[_0x1bad('0x30')]));_0x297d25[_0x1bad('0x46')][_0x1bad('0x47')]=_0x561097['id'];if(_0x3edeca[_0x1bad('0x29')]['filter']){_0x297d25[_0x1bad('0x46')]=_[_0x1bad('0x36')](_0x297d25[_0x1bad('0x46')],{'$or':_[_0x1bad('0x20')](_0x297d25['attributes'],function(_0x5a43e9){var _0x22bc31={};_0x22bc31[_0x5a43e9]={'$like':'%'+_0x3edeca['query'][_0x1bad('0x48')]+'%'};return _0x22bc31;})});}if(_0x3edeca['query']['$gte']){var _0x4acb97=_0x3edeca[_0x1bad('0x29')][_0x1bad('0x49')][_0x1bad('0x4a')](',');var _0x56535e={};_0x56535e[_0x4acb97[0x0]]={'$gte':moment(_0x4acb97[0x1])[_0x1bad('0x4b')](_0x1bad('0x4c'))};_0x297d25[_0x1bad('0x46')]=_[_0x1bad('0x36')](_0x297d25['where'],_0x56535e);}_0x297d25=_[_0x1bad('0x36')]({},_0x297d25,_0x3edeca['options']);return db[_0x1bad('0x3d')][_0x1bad('0x14')]({'where':_0x297d25[_0x1bad('0x46')]})['then'](function(_0x39282c){_0x40ebbb[_0x1bad('0x14')]=_0x39282c;if(_0x3edeca[_0x1bad('0x29')]['includeAll']){_0x297d25[_0x1bad('0x35')]=[{'all':!![]}];}return db['FaxMessage'][_0x1bad('0x27')](_0x297d25);})[_0x1bad('0x19')](function(_0x1f3333){_0x40ebbb[_0x1bad('0x4d')]=_0x1f3333;return _0x40ebbb;});}})[_0x1bad('0x19')](respondWithFilteredResult(_0x1df2ee,_0x297d25))[_0x1bad('0x2b')](handleError(_0x1df2ee,null));};exports[_0x1bad('0x4e')]=function(_0x1b3bca,_0x3aee63){return db[_0x1bad('0x21')]['find']({'where':{'id':_0x1b3bca['params']['id']}})[_0x1bad('0x19')](handleEntityNotFound(_0x3aee63,null))['then'](function(_0x459a3a){if(_0x459a3a){return _0x459a3a[_0x1bad('0x4f')](_0x1b3bca[_0x1bad('0x3a')]['ids'],_[_0x1bad('0x50')](_0x1b3bca[_0x1bad('0x3a')],[_0x1bad('0x3e'),'id'])||{})[_0x1bad('0x51')](function(){return db[_0x1bad('0x52')][_0x1bad('0x27')]({'attributes':['id',_0x1bad('0x1d'),_0x1bad('0x53')],'where':{'id':_0x1b3bca[_0x1bad('0x3a')]['ids']}});})[_0x1bad('0x19')](function(_0x11c231){socket[_0x1bad('0x54')](_0x1bad('0x55'),{'id':Number(_0x1b3bca[_0x1bad('0x2d')]['id']),'tags':_0x11c231||[]});return{'id':Number(_0x1b3bca[_0x1bad('0x2d')]['id']),'tags':_0x11c231||[]};});}})[_0x1bad('0x19')](respondWithResult(_0x3aee63,null))[_0x1bad('0x2b')](handleError(_0x3aee63,null));};exports[_0x1bad('0x56')]=function(_0x1efdb4,_0x50ca12){return db[_0x1bad('0x21')]['find']({'where':{'id':_0x1efdb4[_0x1bad('0x2d')]['id']}})['then'](handleEntityNotFound(_0x50ca12,null))[_0x1bad('0x19')](function(_0x7ef6d5){if(_0x7ef6d5){return _0x7ef6d5['removeTags'](_0x1efdb4['query'][_0x1bad('0x3e')]);}})[_0x1bad('0x19')](respondWithStatusCode(_0x50ca12,null))[_0x1bad('0x2b')](handleError(_0x50ca12,null));};exports[_0x1bad('0x57')]=function(_0xd8930e,_0x48829b){var _0x404524=moment()['unix']()[_0x1bad('0x58')]();var _0xf044ae=path[_0x1bad('0x59')](config[_0x1bad('0x5a')],_0x1bad('0x5b'),_0x1bad('0x5c'),_0x1bad('0x5d'));var _0x519804=path[_0x1bad('0x59')](config[_0x1bad('0x5a')],_0x1bad('0x5b'),_0x1bad('0x5c'),_0x1bad('0x5e'));var _0x4f3a01=path[_0x1bad('0x59')](_0xf044ae,_0x404524);var _0x583420=util['format'](_0x1bad('0x5f'),_0xd8930e[_0x1bad('0x2d')]['id'],_0x404524);var _0x50d82a=path['join'](_0xf044ae,_0x583420);var _0x7b544b=[];_0x7b544b[_0x1bad('0x60')]({'model':db[_0x1bad('0x61')],'as':'Attachment','raw':!![]});var _0x5b12ab=[{'model':db[_0x1bad('0x3d')],'as':_0x1bad('0x62'),'attributes':['id',_0x1bad('0x3a'),'createdAt'],'include':_0x7b544b}];return db[_0x1bad('0x21')][_0x1bad('0x38')]({'where':{'id':_0xd8930e['params']['id']},'include':_0x5b12ab})[_0x1bad('0x19')](handleEntityNotFound(_0x48829b,null))[_0x1bad('0x19')](function(_0x1507b1){if(_0x1507b1&&_0x1507b1[_0x1bad('0x62')]){var _0x4ddcdf=_0x1507b1['get']({'plain':!![]});fs[_0x1bad('0x63')](_0x4f3a01);for(var _0x3e8ad5=0x0;_0x3e8ad5<_0x4ddcdf[_0x1bad('0x62')][_0x1bad('0x41')];_0x3e8ad5++){var _0x1d1a21=_0x4ddcdf[_0x1bad('0x62')][_0x3e8ad5][_0x1bad('0x61')];if(_0x1d1a21){var _0x332ff3=path[_0x1bad('0x59')](_0x519804,_0x1d1a21[_0x1bad('0x64')]);if(fs[_0x1bad('0x65')](_0x332ff3)){fs[_0x1bad('0x66')](_0x332ff3)['pipe'](fs['createWriteStream'](path[_0x1bad('0x59')](_0x4f3a01,_0x1d1a21[_0x1bad('0x64')])));}}}return BPromise[_0x1bad('0x67')]()[_0x1bad('0x19')](function(){return new BPromise(function(_0x4f899e,_0x467630){zipdir(_0x4f3a01,{'saveTo':_0x50d82a},function(_0x513682,_0x33ec2d){if(_0x513682)return _0x467630(_0x513682);return _0x4f899e(_0x33ec2d);});})[_0x1bad('0x19')](function(){return new BPromise(function(_0x5536af,_0x424c5d){rimraf(_0x4f3a01,function(_0x4c2912){if(_0x4c2912)_0x424c5d(_0x4c2912);return _0x5536af();});});})[_0x1bad('0x19')](function(){return _0x48829b[_0x1bad('0x57')](_0x50d82a,_0x583420,function(_0x1702de){if(_0x1702de){console[_0x1bad('0x68')]('err',_0x1702de);}else{fs[_0x1bad('0x69')](_0x50d82a);}});});});}else{return _0x48829b[_0x1bad('0x1b')](0xc8);}})['catch'](handleError(_0x48829b,null));};
\ No newline at end of file
+var _0xbf23=['fieldName','key','getOptions','findAll','fax','query','catch','show','params','model','keys','filters','intersection','attributes','fields','length','includeAll','include','merge','options','find','create','body','describe','addMessage','ids','omit','findOne','hasOwnProperty','nolimit','limit','sort','where','pick','FaxInteractionId','filter','$gte','split','format','YYYY-MM-DD\x20HH:mm:ss','FaxMessage','rows','addTags','setTags','spread','color','emit','removeTags','toString','join','root','files','server','attachments','transcript-%d-%s.zip','push','Attachment','Messages','get','existsSync','createReadStream','pipe','createWriteStream','basename','resolve','log','unlinkSync','rimraf','zip-dir','moment','bluebird','util','path','lodash','../../components/interaction/service','api','../../mysqldb','redis','defaults','localhost','sendStatus','status','end','json','offset','undefined','count','set','Content-Range','update','then','destroy','error','stack','name','send','map','FaxInteraction','rawAttributes'];(function(_0x6c0123,_0x4c8d3b){var _0x5a87d2=function(_0x1ff614){while(--_0x1ff614){_0x6c0123['push'](_0x6c0123['shift']());}};_0x5a87d2(++_0x4c8d3b);}(_0xbf23,0xa6));var _0x3bf2=function(_0x2d7c67,_0x358a79){_0x2d7c67=_0x2d7c67-0x0;var _0x523bd4=_0xbf23[_0x2d7c67];return _0x523bd4;};'use strict';var rimraf=require(_0x3bf2('0x0'));var zipdir=require(_0x3bf2('0x1'));var moment=require(_0x3bf2('0x2'));var BPromise=require(_0x3bf2('0x3'));var util=require(_0x3bf2('0x4'));var path=require(_0x3bf2('0x5'));var fs=require('fs');var _=require(_0x3bf2('0x6'));var Redis=require('ioredis');var interaction=require(_0x3bf2('0x7'));var qs=require('../../components/parsers/qs');var logger=require('../../config/logger')(_0x3bf2('0x8'));var config=require('../../config/environment');var db=require(_0x3bf2('0x9'))['db'];config[_0x3bf2('0xa')]=_[_0x3bf2('0xb')](config[_0x3bf2('0xa')],{'host':_0x3bf2('0xc'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x3bf2('0xa')]));require('./faxInteraction.socket')['register'](socket);function respondWithStatusCode(_0x3479b7,_0x46dd81){_0x46dd81=_0x46dd81||0xcc;return function(_0x3fb83c){if(_0x3fb83c){return _0x3479b7[_0x3bf2('0xd')](_0x46dd81);}return _0x3479b7[_0x3bf2('0xe')](_0x46dd81)[_0x3bf2('0xf')]();};}function respondWithResult(_0x22431f,_0x27e121){_0x27e121=_0x27e121||0xc8;return function(_0x4979bf){if(_0x4979bf){return _0x22431f[_0x3bf2('0xe')](_0x27e121)[_0x3bf2('0x10')](_0x4979bf);}};}function respondWithFilteredResult(_0x2c8a06,_0x3c0471){return function(_0x4f42b0){if(_0x4f42b0){var _0x389af2=typeof _0x3c0471[_0x3bf2('0x11')]===_0x3bf2('0x12')&&typeof _0x3c0471['limit']===_0x3bf2('0x12');var _0x251a14=_0x4f42b0[_0x3bf2('0x13')];var _0x38bef1=_0x389af2?0x0:_0x3c0471[_0x3bf2('0x11')];var _0x41c72b=_0x389af2?_0x4f42b0[_0x3bf2('0x13')]:_0x3c0471[_0x3bf2('0x11')]+_0x3c0471['limit'];var _0x2b8ce6;if(_0x41c72b>=_0x251a14){_0x41c72b=_0x251a14;_0x2b8ce6=0xc8;}else{_0x2b8ce6=0xce;}_0x2c8a06['status'](_0x2b8ce6);return _0x2c8a06[_0x3bf2('0x14')](_0x3bf2('0x15'),_0x38bef1+'-'+_0x41c72b+'/'+_0x251a14)[_0x3bf2('0x10')](_0x4f42b0);}return null;};}function saveUpdates(_0x1650de){return function(_0x4d0613){if(_0x4d0613){return _0x4d0613[_0x3bf2('0x16')](_0x1650de)[_0x3bf2('0x17')](function(_0x5bf6f7){return _0x5bf6f7;});}return null;};}function removeEntity(_0x2e62f2){return function(_0x1d3d4f){if(_0x1d3d4f){return _0x1d3d4f[_0x3bf2('0x18')]()[_0x3bf2('0x17')](function(){_0x2e62f2['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x3288b6){return function(_0x3f214f){if(!_0x3f214f){_0x3288b6['sendStatus'](0x194);}return _0x3f214f;};}function handleError(_0x466a34,_0x545396){_0x545396=_0x545396||0x1f4;return function(_0x9ffe34){logger[_0x3bf2('0x19')](_0x9ffe34[_0x3bf2('0x1a')]);if(_0x9ffe34['name']){delete _0x9ffe34[_0x3bf2('0x1b')];}_0x466a34[_0x3bf2('0xe')](_0x545396)[_0x3bf2('0x1c')](_0x9ffe34);};}exports['index']=function(_0x4b7377,_0x55891e){var _0x318987={};var _0x474557=_[_0x3bf2('0x1d')](db[_0x3bf2('0x1e')][_0x3bf2('0x1f')],function(_0x55b98e){return{'name':_0x55b98e[_0x3bf2('0x20')],'type':_0x55b98e['type'][_0x3bf2('0x21')]};});_0x318987=qs[_0x3bf2('0x22')](_0x474557,_0x4b7377);return interaction[_0x3bf2('0x23')](_0x3bf2('0x24'),_0x4b7377[_0x3bf2('0x25')],_0x4b7377['user'],_0x318987,_0x474557)[_0x3bf2('0x17')](respondWithFilteredResult(_0x55891e,_0x318987))[_0x3bf2('0x26')](handleError(_0x55891e,null));};exports[_0x3bf2('0x27')]=function(_0x2d9343,_0x2dd980){var _0x4f100f={'raw':![],'where':{'id':_0x2d9343[_0x3bf2('0x28')]['id']}},_0x41b4e9={};_0x41b4e9[_0x3bf2('0x29')]=_[_0x3bf2('0x2a')](db[_0x3bf2('0x1e')][_0x3bf2('0x1f')]);_0x41b4e9[_0x3bf2('0x25')]=_[_0x3bf2('0x2a')](_0x2d9343[_0x3bf2('0x25')]);_0x41b4e9[_0x3bf2('0x2b')]=_[_0x3bf2('0x2c')](_0x41b4e9['model'],_0x41b4e9[_0x3bf2('0x25')]);_0x4f100f[_0x3bf2('0x2d')]=_[_0x3bf2('0x2c')](_0x41b4e9[_0x3bf2('0x29')],qs[_0x3bf2('0x2e')](_0x2d9343['query'][_0x3bf2('0x2e')]));_0x4f100f[_0x3bf2('0x2d')]=_0x4f100f[_0x3bf2('0x2d')][_0x3bf2('0x2f')]?_0x4f100f[_0x3bf2('0x2d')]:_0x41b4e9[_0x3bf2('0x29')];if(_0x2d9343['query'][_0x3bf2('0x30')]){_0x4f100f[_0x3bf2('0x31')]=[{'all':!![]}];}_0x4f100f=_[_0x3bf2('0x32')]({},_0x4f100f,_0x2d9343[_0x3bf2('0x33')]);return db[_0x3bf2('0x1e')][_0x3bf2('0x34')](_0x4f100f)['then'](handleEntityNotFound(_0x2dd980,null))[_0x3bf2('0x17')](respondWithResult(_0x2dd980,null))[_0x3bf2('0x26')](handleError(_0x2dd980,null));};exports['create']=function(_0x5ed969,_0x55ce50){return db[_0x3bf2('0x1e')][_0x3bf2('0x35')](_0x5ed969[_0x3bf2('0x36')],{})[_0x3bf2('0x17')](respondWithResult(_0x55ce50,0xc9))[_0x3bf2('0x26')](handleError(_0x55ce50,null));};exports[_0x3bf2('0x16')]=function(_0xd92e49,_0x5a5131){if(_0xd92e49[_0x3bf2('0x36')]['id']){delete _0xd92e49[_0x3bf2('0x36')]['id'];}return db[_0x3bf2('0x1e')][_0x3bf2('0x34')]({'where':{'id':_0xd92e49[_0x3bf2('0x28')]['id']}})[_0x3bf2('0x17')](handleEntityNotFound(_0x5a5131,null))[_0x3bf2('0x17')](saveUpdates(_0xd92e49['body'],null))[_0x3bf2('0x17')](respondWithResult(_0x5a5131,null))[_0x3bf2('0x26')](handleError(_0x5a5131,null));};exports['destroy']=function(_0x164b6b,_0x41cdf2){return db[_0x3bf2('0x1e')][_0x3bf2('0x34')]({'where':{'id':_0x164b6b['params']['id']}})[_0x3bf2('0x17')](handleEntityNotFound(_0x41cdf2,null))[_0x3bf2('0x17')](removeEntity(_0x41cdf2,null))['catch'](handleError(_0x41cdf2,null));};exports['describe']=function(_0x5d5516,_0x11364f){return db[_0x3bf2('0x1e')][_0x3bf2('0x37')]()['then'](respondWithResult(_0x11364f,null))[_0x3bf2('0x26')](handleError(_0x11364f,null));};exports[_0x3bf2('0x38')]=function(_0x54c4fd,_0x478c47){return db['FaxMessage'][_0x3bf2('0x34')]({'where':{'id':_0x54c4fd[_0x3bf2('0x28')]['id']}})[_0x3bf2('0x17')](handleEntityNotFound(_0x478c47,null))[_0x3bf2('0x17')](function(_0x3a7d14){if(_0x3a7d14){return _0x3a7d14[_0x3bf2('0x38')](_0x54c4fd['body'][_0x3bf2('0x39')],_[_0x3bf2('0x3a')](_0x54c4fd['body'],['ids','id'])||{});}})['then'](respondWithResult(_0x478c47,null))[_0x3bf2('0x26')](handleError(_0x478c47,null));};exports['getMessages']=function(_0x395840,_0x4654d9){var _0x24a26f={'raw':![],'where':{}};var _0x40554e={};var _0x2d1b73={'count':0x0,'rows':[]};return db[_0x3bf2('0x1e')][_0x3bf2('0x3b')]({'where':{'id':_0x395840['params']['id']}})['then'](handleEntityNotFound(_0x4654d9,null))[_0x3bf2('0x17')](function(_0x88eb9b){if(_0x88eb9b){_0x40554e[_0x3bf2('0x29')]=_[_0x3bf2('0x2a')](db['FaxMessage'][_0x3bf2('0x1f')]);_0x40554e[_0x3bf2('0x25')]=_['keys'](_0x395840[_0x3bf2('0x25')]);_0x40554e[_0x3bf2('0x2b')]=_[_0x3bf2('0x2c')](_0x40554e[_0x3bf2('0x29')],_0x40554e['query']);_0x24a26f[_0x3bf2('0x2d')]=_[_0x3bf2('0x2c')](_0x40554e[_0x3bf2('0x29')],qs['fields'](_0x395840[_0x3bf2('0x25')][_0x3bf2('0x2e')]));_0x24a26f['attributes']=_0x24a26f[_0x3bf2('0x2d')][_0x3bf2('0x2f')]?_0x24a26f['attributes']:_0x40554e['model'];if(!_0x395840['query'][_0x3bf2('0x3c')](_0x3bf2('0x3d'))){_0x24a26f[_0x3bf2('0x3e')]=qs['limit'](_0x395840[_0x3bf2('0x25')][_0x3bf2('0x3e')]);_0x24a26f[_0x3bf2('0x11')]=qs[_0x3bf2('0x11')](_0x395840[_0x3bf2('0x25')][_0x3bf2('0x11')]);}_0x24a26f['order']=qs[_0x3bf2('0x3f')](_0x395840[_0x3bf2('0x25')][_0x3bf2('0x3f')]);_0x24a26f[_0x3bf2('0x40')]=qs[_0x3bf2('0x2b')](_[_0x3bf2('0x41')](_0x395840['query'],_0x40554e[_0x3bf2('0x2b')]));_0x24a26f[_0x3bf2('0x40')][_0x3bf2('0x42')]=_0x88eb9b['id'];if(_0x395840[_0x3bf2('0x25')][_0x3bf2('0x43')]){_0x24a26f[_0x3bf2('0x40')]=_[_0x3bf2('0x32')](_0x24a26f['where'],{'$or':_['map'](_0x24a26f[_0x3bf2('0x2d')],function(_0x2b41cd){var _0x5b5e7c={};_0x5b5e7c[_0x2b41cd]={'$like':'%'+_0x395840[_0x3bf2('0x25')]['filter']+'%'};return _0x5b5e7c;})});}if(_0x395840[_0x3bf2('0x25')][_0x3bf2('0x44')]){var _0x159d51=_0x395840[_0x3bf2('0x25')]['$gte'][_0x3bf2('0x45')](',');var _0x25aedf={};_0x25aedf[_0x159d51[0x0]]={'$gte':moment(_0x159d51[0x1])[_0x3bf2('0x46')](_0x3bf2('0x47'))};_0x24a26f[_0x3bf2('0x40')]=_[_0x3bf2('0x32')](_0x24a26f[_0x3bf2('0x40')],_0x25aedf);}_0x24a26f=_[_0x3bf2('0x32')]({},_0x24a26f,_0x395840[_0x3bf2('0x33')]);return db[_0x3bf2('0x48')][_0x3bf2('0x13')]({'where':_0x24a26f['where']})[_0x3bf2('0x17')](function(_0x3ee7aa){_0x2d1b73[_0x3bf2('0x13')]=_0x3ee7aa;if(_0x395840[_0x3bf2('0x25')][_0x3bf2('0x30')]){_0x24a26f[_0x3bf2('0x31')]=[{'all':!![]}];}return db['FaxMessage'][_0x3bf2('0x23')](_0x24a26f);})[_0x3bf2('0x17')](function(_0x414314){_0x2d1b73[_0x3bf2('0x49')]=_0x414314;return _0x2d1b73;});}})[_0x3bf2('0x17')](respondWithFilteredResult(_0x4654d9,_0x24a26f))[_0x3bf2('0x26')](handleError(_0x4654d9,null));};exports[_0x3bf2('0x4a')]=function(_0x5ec941,_0x3852b9){return db['FaxInteraction'][_0x3bf2('0x34')]({'where':{'id':_0x5ec941[_0x3bf2('0x28')]['id']}})[_0x3bf2('0x17')](handleEntityNotFound(_0x3852b9,null))[_0x3bf2('0x17')](function(_0x2a54d2){if(_0x2a54d2){return _0x2a54d2[_0x3bf2('0x4b')](_0x5ec941[_0x3bf2('0x36')][_0x3bf2('0x39')],_[_0x3bf2('0x3a')](_0x5ec941['body'],[_0x3bf2('0x39'),'id'])||{})[_0x3bf2('0x4c')](function(){return db['Tag']['findAll']({'attributes':['id',_0x3bf2('0x1b'),_0x3bf2('0x4d')],'where':{'id':_0x5ec941[_0x3bf2('0x36')][_0x3bf2('0x39')]}});})[_0x3bf2('0x17')](function(_0x3b00a9){socket[_0x3bf2('0x4e')]('faxInteractionTags:save',{'id':Number(_0x5ec941[_0x3bf2('0x28')]['id']),'tags':_0x3b00a9||[]});return{'id':Number(_0x5ec941[_0x3bf2('0x28')]['id']),'tags':_0x3b00a9||[]};});}})['then'](respondWithResult(_0x3852b9,null))['catch'](handleError(_0x3852b9,null));};exports[_0x3bf2('0x4f')]=function(_0x35462f,_0x5ae063){return db[_0x3bf2('0x1e')]['find']({'where':{'id':_0x35462f[_0x3bf2('0x28')]['id']}})[_0x3bf2('0x17')](handleEntityNotFound(_0x5ae063,null))[_0x3bf2('0x17')](function(_0x434203){if(_0x434203){return _0x434203[_0x3bf2('0x4f')](_0x35462f[_0x3bf2('0x25')]['ids']);}})[_0x3bf2('0x17')](respondWithStatusCode(_0x5ae063,null))[_0x3bf2('0x26')](handleError(_0x5ae063,null));};exports['download']=function(_0xa16a42,_0x255cee){var _0x883dfa=moment()['unix']()[_0x3bf2('0x50')]();var _0x1782f1=path[_0x3bf2('0x51')](config[_0x3bf2('0x52')],'server',_0x3bf2('0x53'),'tmp');var _0x3ad592=path['join'](config['root'],_0x3bf2('0x54'),_0x3bf2('0x53'),_0x3bf2('0x55'));var _0x539ef1=path[_0x3bf2('0x51')](_0x1782f1,_0x883dfa);var _0x3be519=util[_0x3bf2('0x46')](_0x3bf2('0x56'),_0xa16a42[_0x3bf2('0x28')]['id'],_0x883dfa);var _0x21934a=path[_0x3bf2('0x51')](_0x1782f1,_0x3be519);var _0x85ebac=[];_0x85ebac[_0x3bf2('0x57')]({'model':db[_0x3bf2('0x58')],'as':'Attachment','raw':!![]});var _0x5c466f=[{'model':db['FaxMessage'],'as':_0x3bf2('0x59'),'attributes':['id',_0x3bf2('0x36'),'createdAt'],'include':_0x85ebac}];return db[_0x3bf2('0x1e')]['find']({'where':{'id':_0xa16a42['params']['id']},'include':_0x5c466f})[_0x3bf2('0x17')](handleEntityNotFound(_0x255cee,null))[_0x3bf2('0x17')](function(_0x429c15){if(_0x429c15&&_0x429c15[_0x3bf2('0x59')]){var _0x3a23db=_0x429c15[_0x3bf2('0x5a')]({'plain':!![]});fs['mkdirSync'](_0x539ef1);for(var _0x1dad86=0x0;_0x1dad86<_0x3a23db[_0x3bf2('0x59')]['length'];_0x1dad86++){var _0x23cc5e=_0x3a23db[_0x3bf2('0x59')][_0x1dad86][_0x3bf2('0x58')];if(_0x23cc5e){var _0x50725b=path[_0x3bf2('0x51')](_0x3ad592,_0x23cc5e['basename']);if(fs[_0x3bf2('0x5b')](_0x50725b)){fs[_0x3bf2('0x5c')](_0x50725b)[_0x3bf2('0x5d')](fs[_0x3bf2('0x5e')](path['join'](_0x539ef1,_0x23cc5e[_0x3bf2('0x5f')])));}}}return BPromise[_0x3bf2('0x60')]()[_0x3bf2('0x17')](function(){return new BPromise(function(_0x14ed18,_0x12f9e3){zipdir(_0x539ef1,{'saveTo':_0x21934a},function(_0x26f0b4,_0x4d3e94){if(_0x26f0b4)return _0x12f9e3(_0x26f0b4);return _0x14ed18(_0x4d3e94);});})[_0x3bf2('0x17')](function(){return new BPromise(function(_0x1ef5fa,_0x108f49){rimraf(_0x539ef1,function(_0x588a91){if(_0x588a91)_0x108f49(_0x588a91);return _0x1ef5fa();});});})['then'](function(){return _0x255cee['download'](_0x21934a,_0x3be519,function(_0x4b9078){if(_0x4b9078){console[_0x3bf2('0x61')]('err',_0x4b9078);}else{fs[_0x3bf2('0x62')](_0x21934a);}});});});}else{return _0x255cee[_0x3bf2('0xd')](0xc8);}})[_0x3bf2('0x26')](handleError(_0x255cee,null));};
\ No newline at end of file