Built motion from commit eddce310.|2.6.12
[motion2.git] / server / api / faxInteraction / faxInteraction.controller.js
index bbbc922..7e7f3db 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x3531=['count','limit','set','Content-Range','json','update','then','destroy','error','stack','name','index','FaxInteraction','rawAttributes','fieldName','type','key','getOptions','fax','query','user','catch','show','params','model','keys','filters','intersection','fields','attributes','length','includeAll','include','merge','options','find','create','body','addMessage','FaxMessage','ids','omit','getMessages','hasOwnProperty','nolimit','order','sort','where','pick','FaxInteractionId','filter','map','$gte','format','YYYY-MM-DD\x20HH:mm:ss','findAll','rows','addTags','setTags','spread','color','faxInteractionTags:save','removeTags','unix','join','root','server','files','tmp','attachments','push','Attachment','Messages','mkdirSync','basename','existsSync','createReadStream','resolve','download','log','err','unlinkSync','zip-dir','moment','bluebird','util','lodash','ioredis','../../components/parsers/qs','api','../../config/environment','../../mysqldb','defaults','redis','localhost','socket.io-emitter','./faxInteraction.socket','sendStatus','status','end','offset','undefined'];(function(_0x4cc6ee,_0x2b4705){var _0x283a81=function(_0x5aca62){while(--_0x5aca62){_0x4cc6ee['push'](_0x4cc6ee['shift']());}};_0x283a81(++_0x2b4705);}(_0x3531,0x1ea));var _0x1353=function(_0x92c450,_0x41f1e3){_0x92c450=_0x92c450-0x0;var _0x2a9599=_0x3531[_0x92c450];return _0x2a9599;};'use strict';var rimraf=require('rimraf');var zipdir=require(_0x1353('0x0'));var moment=require(_0x1353('0x1'));var BPromise=require(_0x1353('0x2'));var util=require(_0x1353('0x3'));var path=require('path');var fs=require('fs');var _=require(_0x1353('0x4'));var Redis=require(_0x1353('0x5'));var interaction=require('../../components/interaction/service');var qs=require(_0x1353('0x6'));var logger=require('../../config/logger')(_0x1353('0x7'));var config=require(_0x1353('0x8'));var db=require(_0x1353('0x9'))['db'];config['redis']=_[_0x1353('0xa')](config[_0x1353('0xb')],{'host':_0x1353('0xc'),'port':0x18eb});var socket=require(_0x1353('0xd'))(new Redis(config[_0x1353('0xb')]));require(_0x1353('0xe'))['register'](socket);function respondWithStatusCode(_0x151802,_0x4d778e){_0x4d778e=_0x4d778e||0xcc;return function(_0x12923a){if(_0x12923a){return _0x151802[_0x1353('0xf')](_0x4d778e);}return _0x151802[_0x1353('0x10')](_0x4d778e)[_0x1353('0x11')]();};}function respondWithResult(_0x16da4d,_0x1dc495){_0x1dc495=_0x1dc495||0xc8;return function(_0x18b960){if(_0x18b960){return _0x16da4d['status'](_0x1dc495)['json'](_0x18b960);}};}function respondWithFilteredResult(_0x420739,_0x3c741c){return function(_0x5207ca){if(_0x5207ca){var _0x1fa67f=typeof _0x3c741c[_0x1353('0x12')]===_0x1353('0x13')&&typeof _0x3c741c['limit']===_0x1353('0x13');var _0x489ff0=_0x5207ca[_0x1353('0x14')];var _0x29233e=_0x1fa67f?0x0:_0x3c741c['offset'];var _0x49ac9d=_0x1fa67f?_0x5207ca[_0x1353('0x14')]:_0x3c741c[_0x1353('0x12')]+_0x3c741c[_0x1353('0x15')];var _0x3c7622;if(_0x49ac9d>=_0x489ff0){_0x49ac9d=_0x489ff0;_0x3c7622=0xc8;}else{_0x3c7622=0xce;}_0x420739[_0x1353('0x10')](_0x3c7622);return _0x420739[_0x1353('0x16')](_0x1353('0x17'),_0x29233e+'-'+_0x49ac9d+'/'+_0x489ff0)[_0x1353('0x18')](_0x5207ca);}return null;};}function saveUpdates(_0x58adaa){return function(_0xf393e5){if(_0xf393e5){return _0xf393e5[_0x1353('0x19')](_0x58adaa)[_0x1353('0x1a')](function(_0x42795c){return _0x42795c;});}return null;};}function removeEntity(_0xa16c30){return function(_0x122599){if(_0x122599){return _0x122599[_0x1353('0x1b')]()[_0x1353('0x1a')](function(){_0xa16c30[_0x1353('0x10')](0xcc)['end']();});}};}function handleEntityNotFound(_0x4f5ef2){return function(_0x59ee3b){if(!_0x59ee3b){_0x4f5ef2['sendStatus'](0x194);}return _0x59ee3b;};}function handleError(_0x3d92fa,_0x306ef1){_0x306ef1=_0x306ef1||0x1f4;return function(_0x2f5e01){logger[_0x1353('0x1c')](_0x2f5e01[_0x1353('0x1d')]);if(_0x2f5e01[_0x1353('0x1e')]){delete _0x2f5e01[_0x1353('0x1e')];}_0x3d92fa['status'](_0x306ef1)['send'](_0x2f5e01);};}exports[_0x1353('0x1f')]=function(_0x585033,_0x305815){var _0x1f0e43={};var _0x13f153=_['map'](db[_0x1353('0x20')][_0x1353('0x21')],function(_0x7b55a8){return{'name':_0x7b55a8[_0x1353('0x22')],'type':_0x7b55a8[_0x1353('0x23')][_0x1353('0x24')]};});_0x1f0e43=qs[_0x1353('0x25')](_0x13f153,_0x585033);return interaction['findAll'](_0x1353('0x26'),_0x585033[_0x1353('0x27')],_0x585033[_0x1353('0x28')],_0x1f0e43,_0x13f153)[_0x1353('0x1a')](respondWithFilteredResult(_0x305815,_0x1f0e43))[_0x1353('0x29')](handleError(_0x305815,null));};exports[_0x1353('0x2a')]=function(_0x215aa2,_0x54ea4b){var _0x249000={'raw':![],'where':{'id':_0x215aa2[_0x1353('0x2b')]['id']}},_0x1cd08a={};_0x1cd08a[_0x1353('0x2c')]=_[_0x1353('0x2d')](db[_0x1353('0x20')][_0x1353('0x21')]);_0x1cd08a[_0x1353('0x27')]=_[_0x1353('0x2d')](_0x215aa2[_0x1353('0x27')]);_0x1cd08a[_0x1353('0x2e')]=_[_0x1353('0x2f')](_0x1cd08a[_0x1353('0x2c')],_0x1cd08a['query']);_0x249000['attributes']=_[_0x1353('0x2f')](_0x1cd08a[_0x1353('0x2c')],qs[_0x1353('0x30')](_0x215aa2[_0x1353('0x27')][_0x1353('0x30')]));_0x249000[_0x1353('0x31')]=_0x249000[_0x1353('0x31')][_0x1353('0x32')]?_0x249000[_0x1353('0x31')]:_0x1cd08a[_0x1353('0x2c')];if(_0x215aa2[_0x1353('0x27')][_0x1353('0x33')]){_0x249000[_0x1353('0x34')]=[{'all':!![]}];}_0x249000=_[_0x1353('0x35')]({},_0x249000,_0x215aa2[_0x1353('0x36')]);return db[_0x1353('0x20')][_0x1353('0x37')](_0x249000)[_0x1353('0x1a')](handleEntityNotFound(_0x54ea4b,null))[_0x1353('0x1a')](respondWithResult(_0x54ea4b,null))[_0x1353('0x29')](handleError(_0x54ea4b,null));};exports[_0x1353('0x38')]=function(_0x410204,_0x2369ed){return db[_0x1353('0x20')][_0x1353('0x38')](_0x410204['body'],{})['then'](respondWithResult(_0x2369ed,0xc9))[_0x1353('0x29')](handleError(_0x2369ed,null));};exports[_0x1353('0x19')]=function(_0x45657b,_0xeb8e10){if(_0x45657b[_0x1353('0x39')]['id']){delete _0x45657b[_0x1353('0x39')]['id'];}return db[_0x1353('0x20')][_0x1353('0x37')]({'where':{'id':_0x45657b['params']['id']}})[_0x1353('0x1a')](handleEntityNotFound(_0xeb8e10,null))[_0x1353('0x1a')](saveUpdates(_0x45657b['body'],null))['then'](respondWithResult(_0xeb8e10,null))[_0x1353('0x29')](handleError(_0xeb8e10,null));};exports[_0x1353('0x1b')]=function(_0x1caf46,_0x185031){return db[_0x1353('0x20')][_0x1353('0x37')]({'where':{'id':_0x1caf46['params']['id']}})['then'](handleEntityNotFound(_0x185031,null))[_0x1353('0x1a')](removeEntity(_0x185031,null))['catch'](handleError(_0x185031,null));};exports['describe']=function(_0x10cd25,_0x3ea905){return db[_0x1353('0x20')]['describe']()[_0x1353('0x1a')](respondWithResult(_0x3ea905,null))[_0x1353('0x29')](handleError(_0x3ea905,null));};exports[_0x1353('0x3a')]=function(_0x15dc57,_0x16d186){return db[_0x1353('0x3b')][_0x1353('0x37')]({'where':{'id':_0x15dc57[_0x1353('0x2b')]['id']}})['then'](handleEntityNotFound(_0x16d186,null))[_0x1353('0x1a')](function(_0x50795e){if(_0x50795e){return _0x50795e[_0x1353('0x3a')](_0x15dc57[_0x1353('0x39')][_0x1353('0x3c')],_[_0x1353('0x3d')](_0x15dc57[_0x1353('0x39')],[_0x1353('0x3c'),'id'])||{});}})[_0x1353('0x1a')](respondWithResult(_0x16d186,null))[_0x1353('0x29')](handleError(_0x16d186,null));};exports[_0x1353('0x3e')]=function(_0x2b303f,_0x3b8523){var _0x1ea72f={'raw':![],'where':{}};var _0x26cfe0={};var _0x43ede1={'count':0x0,'rows':[]};return db[_0x1353('0x20')]['findOne']({'where':{'id':_0x2b303f[_0x1353('0x2b')]['id']}})[_0x1353('0x1a')](handleEntityNotFound(_0x3b8523,null))[_0x1353('0x1a')](function(_0x3e1fda){if(_0x3e1fda){_0x26cfe0[_0x1353('0x2c')]=_[_0x1353('0x2d')](db[_0x1353('0x3b')][_0x1353('0x21')]);_0x26cfe0[_0x1353('0x27')]=_[_0x1353('0x2d')](_0x2b303f[_0x1353('0x27')]);_0x26cfe0[_0x1353('0x2e')]=_[_0x1353('0x2f')](_0x26cfe0[_0x1353('0x2c')],_0x26cfe0['query']);_0x1ea72f[_0x1353('0x31')]=_[_0x1353('0x2f')](_0x26cfe0[_0x1353('0x2c')],qs[_0x1353('0x30')](_0x2b303f[_0x1353('0x27')]['fields']));_0x1ea72f[_0x1353('0x31')]=_0x1ea72f[_0x1353('0x31')][_0x1353('0x32')]?_0x1ea72f[_0x1353('0x31')]:_0x26cfe0[_0x1353('0x2c')];if(!_0x2b303f[_0x1353('0x27')][_0x1353('0x3f')](_0x1353('0x40'))){_0x1ea72f[_0x1353('0x15')]=qs[_0x1353('0x15')](_0x2b303f['query'][_0x1353('0x15')]);_0x1ea72f[_0x1353('0x12')]=qs[_0x1353('0x12')](_0x2b303f['query'][_0x1353('0x12')]);}_0x1ea72f[_0x1353('0x41')]=qs[_0x1353('0x42')](_0x2b303f[_0x1353('0x27')][_0x1353('0x42')]);_0x1ea72f[_0x1353('0x43')]=qs[_0x1353('0x2e')](_[_0x1353('0x44')](_0x2b303f['query'],_0x26cfe0[_0x1353('0x2e')]));_0x1ea72f['where'][_0x1353('0x45')]=_0x3e1fda['id'];if(_0x2b303f['query'][_0x1353('0x46')]){_0x1ea72f[_0x1353('0x43')]=_['merge'](_0x1ea72f['where'],{'$or':_[_0x1353('0x47')](_0x1ea72f[_0x1353('0x31')],function(_0x86b64e){var _0xa0f415={};_0xa0f415[_0x86b64e]={'$like':'%'+_0x2b303f[_0x1353('0x27')][_0x1353('0x46')]+'%'};return _0xa0f415;})});}if(_0x2b303f['query'][_0x1353('0x48')]){var _0x4f7c22=_0x2b303f[_0x1353('0x27')]['$gte']['split'](',');var _0x5c0eb9={};_0x5c0eb9[_0x4f7c22[0x0]]={'$gte':moment(_0x4f7c22[0x1])[_0x1353('0x49')](_0x1353('0x4a'))};_0x1ea72f[_0x1353('0x43')]=_[_0x1353('0x35')](_0x1ea72f[_0x1353('0x43')],_0x5c0eb9);}_0x1ea72f=_['merge']({},_0x1ea72f,_0x2b303f[_0x1353('0x36')]);return db[_0x1353('0x3b')][_0x1353('0x14')]({'where':_0x1ea72f[_0x1353('0x43')]})['then'](function(_0x4cfd40){_0x43ede1['count']=_0x4cfd40;if(_0x2b303f[_0x1353('0x27')][_0x1353('0x33')]){_0x1ea72f[_0x1353('0x34')]=[{'all':!![]}];}return db[_0x1353('0x3b')][_0x1353('0x4b')](_0x1ea72f);})[_0x1353('0x1a')](function(_0x1306f7){_0x43ede1[_0x1353('0x4c')]=_0x1306f7;return _0x43ede1;});}})[_0x1353('0x1a')](respondWithFilteredResult(_0x3b8523,_0x1ea72f))[_0x1353('0x29')](handleError(_0x3b8523,null));};exports[_0x1353('0x4d')]=function(_0xeeffe6,_0x1dbf53){return db['FaxInteraction'][_0x1353('0x37')]({'where':{'id':_0xeeffe6[_0x1353('0x2b')]['id']}})[_0x1353('0x1a')](handleEntityNotFound(_0x1dbf53,null))[_0x1353('0x1a')](function(_0x3e7644){if(_0x3e7644){return _0x3e7644[_0x1353('0x4e')](_0xeeffe6[_0x1353('0x39')][_0x1353('0x3c')],_[_0x1353('0x3d')](_0xeeffe6[_0x1353('0x39')],[_0x1353('0x3c'),'id'])||{})[_0x1353('0x4f')](function(){return db['Tag'][_0x1353('0x4b')]({'attributes':['id','name',_0x1353('0x50')],'where':{'id':_0xeeffe6[_0x1353('0x39')][_0x1353('0x3c')]}});})[_0x1353('0x1a')](function(_0x36a202){socket['emit'](_0x1353('0x51'),{'id':Number(_0xeeffe6[_0x1353('0x2b')]['id']),'tags':_0x36a202||[]});return{'id':Number(_0xeeffe6[_0x1353('0x2b')]['id']),'tags':_0x36a202||[]};});}})[_0x1353('0x1a')](respondWithResult(_0x1dbf53,null))[_0x1353('0x29')](handleError(_0x1dbf53,null));};exports[_0x1353('0x52')]=function(_0x5e2927,_0x5ee4a2){return db[_0x1353('0x20')][_0x1353('0x37')]({'where':{'id':_0x5e2927[_0x1353('0x2b')]['id']}})[_0x1353('0x1a')](handleEntityNotFound(_0x5ee4a2,null))['then'](function(_0x5bfc17){if(_0x5bfc17){return _0x5bfc17[_0x1353('0x52')](_0x5e2927[_0x1353('0x27')][_0x1353('0x3c')]);}})[_0x1353('0x1a')](respondWithStatusCode(_0x5ee4a2,null))['catch'](handleError(_0x5ee4a2,null));};exports['download']=function(_0x468c61,_0x377204){var _0x545f62=moment()[_0x1353('0x53')]()['toString']();var _0x1aa12e=path[_0x1353('0x54')](config[_0x1353('0x55')],_0x1353('0x56'),_0x1353('0x57'),_0x1353('0x58'));var _0x5c1397=path[_0x1353('0x54')](config[_0x1353('0x55')],_0x1353('0x56'),_0x1353('0x57'),_0x1353('0x59'));var _0x1cbfb1=path[_0x1353('0x54')](_0x1aa12e,_0x545f62);var _0x20605d=util[_0x1353('0x49')]('transcript-%d-%s.zip',_0x468c61[_0x1353('0x2b')]['id'],_0x545f62);var _0x1d6ccf=path[_0x1353('0x54')](_0x1aa12e,_0x20605d);var _0x5c47c5=[];_0x5c47c5[_0x1353('0x5a')]({'model':db[_0x1353('0x5b')],'as':'Attachment','raw':!![]});var _0x2dac89=[{'model':db['FaxMessage'],'as':'Messages','attributes':['id',_0x1353('0x39'),'createdAt'],'include':_0x5c47c5}];return db[_0x1353('0x20')][_0x1353('0x37')]({'where':{'id':_0x468c61[_0x1353('0x2b')]['id']},'include':_0x2dac89})['then'](handleEntityNotFound(_0x377204,null))[_0x1353('0x1a')](function(_0x8ba490){if(_0x8ba490&&_0x8ba490[_0x1353('0x5c')]){var _0x3c81b1=_0x8ba490['get']({'plain':!![]});fs[_0x1353('0x5d')](_0x1cbfb1);for(var _0x1c4396=0x0;_0x1c4396<_0x3c81b1[_0x1353('0x5c')][_0x1353('0x32')];_0x1c4396++){var _0x33f3ab=_0x3c81b1[_0x1353('0x5c')][_0x1c4396][_0x1353('0x5b')];if(_0x33f3ab){var _0x2c52ce=path[_0x1353('0x54')](_0x5c1397,_0x33f3ab[_0x1353('0x5e')]);if(fs[_0x1353('0x5f')](_0x2c52ce)){fs[_0x1353('0x60')](_0x2c52ce)['pipe'](fs['createWriteStream'](path[_0x1353('0x54')](_0x1cbfb1,_0x33f3ab[_0x1353('0x5e')])));}}}return BPromise[_0x1353('0x61')]()[_0x1353('0x1a')](function(){return new BPromise(function(_0x32b7a5,_0x13b025){zipdir(_0x1cbfb1,{'saveTo':_0x1d6ccf},function(_0x369993,_0x452d04){if(_0x369993)return _0x13b025(_0x369993);return _0x32b7a5(_0x452d04);});})[_0x1353('0x1a')](function(){return new BPromise(function(_0x487992,_0x2ae8a5){rimraf(_0x1cbfb1,function(_0x520885){if(_0x520885)_0x2ae8a5(_0x520885);return _0x487992();});});})['then'](function(){return _0x377204[_0x1353('0x62')](_0x1d6ccf,_0x20605d,function(_0x2be680){if(_0x2be680){console[_0x1353('0x63')](_0x1353('0x64'),_0x2be680);}else{fs[_0x1353('0x65')](_0x1d6ccf);}});});});}else{return _0x377204['sendStatus'](0xc8);}})[_0x1353('0x29')](handleError(_0x377204,null));};
\ No newline at end of file
+var _0x81cf=['undefined','limit','set','Content-Range','update','then','destroy','stack','name','send','index','FaxInteraction','rawAttributes','fieldName','type','key','fax','query','user','show','model','keys','filters','intersection','attributes','fields','length','includeAll','include','merge','options','catch','create','body','find','params','describe','addMessage','FaxMessage','ids','findOne','hasOwnProperty','nolimit','order','sort','pick','where','map','$gte','split','count','findAll','rows','addTags','setTags','omit','spread','Tag','color','faxInteractionTags:save','download','unix','join','root','server','files','tmp','attachments','format','transcript-%d-%s.zip','push','Attachment','createdAt','get','mkdirSync','Messages','basename','existsSync','createReadStream','createWriteStream','resolve','log','err','unlinkSync','rimraf','moment','util','path','lodash','ioredis','../../components/interaction/service','../../components/parsers/qs','../../config/logger','../../config/environment','defaults','localhost','socket.io-emitter','./faxInteraction.socket','sendStatus','end','status','json','offset'];(function(_0x41a3af,_0x35694d){var _0x2075ec=function(_0x36dffb){while(--_0x36dffb){_0x41a3af['push'](_0x41a3af['shift']());}};_0x2075ec(++_0x35694d);}(_0x81cf,0x1f0));var _0xf81c=function(_0x423edc,_0x1ec185){_0x423edc=_0x423edc-0x0;var _0x3d6101=_0x81cf[_0x423edc];return _0x3d6101;};'use strict';var rimraf=require(_0xf81c('0x0'));var zipdir=require('zip-dir');var moment=require(_0xf81c('0x1'));var BPromise=require('bluebird');var util=require(_0xf81c('0x2'));var path=require(_0xf81c('0x3'));var fs=require('fs');var _=require(_0xf81c('0x4'));var Redis=require(_0xf81c('0x5'));var interaction=require(_0xf81c('0x6'));var qs=require(_0xf81c('0x7'));var logger=require(_0xf81c('0x8'))('api');var config=require(_0xf81c('0x9'));var db=require('../../mysqldb')['db'];config['redis']=_[_0xf81c('0xa')](config['redis'],{'host':_0xf81c('0xb'),'port':0x18eb});var socket=require(_0xf81c('0xc'))(new Redis(config['redis']));require(_0xf81c('0xd'))['register'](socket);function respondWithStatusCode(_0x21a2b6,_0x5ae3db){_0x5ae3db=_0x5ae3db||0xcc;return function(_0x1fafb6){if(_0x1fafb6){return _0x21a2b6[_0xf81c('0xe')](_0x5ae3db);}return _0x21a2b6['status'](_0x5ae3db)[_0xf81c('0xf')]();};}function respondWithResult(_0x2adebb,_0x59ee9b){_0x59ee9b=_0x59ee9b||0xc8;return function(_0x40230b){if(_0x40230b){return _0x2adebb[_0xf81c('0x10')](_0x59ee9b)[_0xf81c('0x11')](_0x40230b);}};}function respondWithFilteredResult(_0x3470f0,_0x32e454){return function(_0x4756dd){if(_0x4756dd){var _0x594d4d=typeof _0x32e454[_0xf81c('0x12')]===_0xf81c('0x13')&&typeof _0x32e454[_0xf81c('0x14')]===_0xf81c('0x13');var _0x22ce73=_0x4756dd['count'];var _0x5528d5=_0x594d4d?0x0:_0x32e454[_0xf81c('0x12')];var _0x72f842=_0x594d4d?_0x4756dd['count']:_0x32e454[_0xf81c('0x12')]+_0x32e454[_0xf81c('0x14')];var _0x2ca4e2;if(_0x72f842>=_0x22ce73){_0x72f842=_0x22ce73;_0x2ca4e2=0xc8;}else{_0x2ca4e2=0xce;}_0x3470f0[_0xf81c('0x10')](_0x2ca4e2);return _0x3470f0[_0xf81c('0x15')](_0xf81c('0x16'),_0x5528d5+'-'+_0x72f842+'/'+_0x22ce73)[_0xf81c('0x11')](_0x4756dd);}return null;};}function saveUpdates(_0x2b339c){return function(_0x1fe6ad){if(_0x1fe6ad){return _0x1fe6ad[_0xf81c('0x17')](_0x2b339c)[_0xf81c('0x18')](function(_0x34f2a5){return _0x34f2a5;});}return null;};}function removeEntity(_0x2ce548){return function(_0x4dffa0){if(_0x4dffa0){return _0x4dffa0[_0xf81c('0x19')]()['then'](function(){_0x2ce548[_0xf81c('0x10')](0xcc)[_0xf81c('0xf')]();});}};}function handleEntityNotFound(_0x18df54){return function(_0x5aee2b){if(!_0x5aee2b){_0x18df54[_0xf81c('0xe')](0x194);}return _0x5aee2b;};}function handleError(_0x12eb16,_0x2f3b2f){_0x2f3b2f=_0x2f3b2f||0x1f4;return function(_0x4904ab){logger['error'](_0x4904ab[_0xf81c('0x1a')]);if(_0x4904ab[_0xf81c('0x1b')]){delete _0x4904ab[_0xf81c('0x1b')];}_0x12eb16[_0xf81c('0x10')](_0x2f3b2f)[_0xf81c('0x1c')](_0x4904ab);};}exports[_0xf81c('0x1d')]=function(_0x115265,_0x16dacd){var _0x270aaa={};var _0x207251=_['map'](db[_0xf81c('0x1e')][_0xf81c('0x1f')],function(_0x2438f4){return{'name':_0x2438f4[_0xf81c('0x20')],'type':_0x2438f4[_0xf81c('0x21')][_0xf81c('0x22')]};});_0x270aaa=qs['getOptions'](_0x207251,_0x115265);return interaction['findAll'](_0xf81c('0x23'),_0x115265[_0xf81c('0x24')],_0x115265[_0xf81c('0x25')],_0x270aaa,_0x207251)[_0xf81c('0x18')](respondWithFilteredResult(_0x16dacd,_0x270aaa))['catch'](handleError(_0x16dacd,null));};exports[_0xf81c('0x26')]=function(_0x5e0996,_0x118190){var _0x391501={'raw':![],'where':{'id':_0x5e0996['params']['id']}},_0x382a3b={};_0x382a3b[_0xf81c('0x27')]=_[_0xf81c('0x28')](db['FaxInteraction'][_0xf81c('0x1f')]);_0x382a3b['query']=_[_0xf81c('0x28')](_0x5e0996[_0xf81c('0x24')]);_0x382a3b[_0xf81c('0x29')]=_[_0xf81c('0x2a')](_0x382a3b[_0xf81c('0x27')],_0x382a3b['query']);_0x391501[_0xf81c('0x2b')]=_['intersection'](_0x382a3b[_0xf81c('0x27')],qs[_0xf81c('0x2c')](_0x5e0996[_0xf81c('0x24')][_0xf81c('0x2c')]));_0x391501[_0xf81c('0x2b')]=_0x391501[_0xf81c('0x2b')][_0xf81c('0x2d')]?_0x391501[_0xf81c('0x2b')]:_0x382a3b[_0xf81c('0x27')];if(_0x5e0996[_0xf81c('0x24')][_0xf81c('0x2e')]){_0x391501[_0xf81c('0x2f')]=[{'all':!![]}];}_0x391501=_[_0xf81c('0x30')]({},_0x391501,_0x5e0996[_0xf81c('0x31')]);return db[_0xf81c('0x1e')]['find'](_0x391501)[_0xf81c('0x18')](handleEntityNotFound(_0x118190,null))[_0xf81c('0x18')](respondWithResult(_0x118190,null))[_0xf81c('0x32')](handleError(_0x118190,null));};exports[_0xf81c('0x33')]=function(_0x40b77c,_0x37ced1){return db[_0xf81c('0x1e')][_0xf81c('0x33')](_0x40b77c[_0xf81c('0x34')],{})[_0xf81c('0x18')](respondWithResult(_0x37ced1,0xc9))[_0xf81c('0x32')](handleError(_0x37ced1,null));};exports['update']=function(_0x1663af,_0x19b56f){if(_0x1663af['body']['id']){delete _0x1663af[_0xf81c('0x34')]['id'];}return db['FaxInteraction'][_0xf81c('0x35')]({'where':{'id':_0x1663af[_0xf81c('0x36')]['id']}})[_0xf81c('0x18')](handleEntityNotFound(_0x19b56f,null))[_0xf81c('0x18')](saveUpdates(_0x1663af[_0xf81c('0x34')],null))[_0xf81c('0x18')](respondWithResult(_0x19b56f,null))[_0xf81c('0x32')](handleError(_0x19b56f,null));};exports['destroy']=function(_0x2afdf2,_0x58eebe){return db['FaxInteraction'][_0xf81c('0x35')]({'where':{'id':_0x2afdf2[_0xf81c('0x36')]['id']}})[_0xf81c('0x18')](handleEntityNotFound(_0x58eebe,null))[_0xf81c('0x18')](removeEntity(_0x58eebe,null))[_0xf81c('0x32')](handleError(_0x58eebe,null));};exports[_0xf81c('0x37')]=function(_0x14b1a5,_0x5eb873){return db[_0xf81c('0x1e')][_0xf81c('0x37')]()[_0xf81c('0x18')](respondWithResult(_0x5eb873,null))[_0xf81c('0x32')](handleError(_0x5eb873,null));};exports[_0xf81c('0x38')]=function(_0x5c7111,_0x4e6953){return db[_0xf81c('0x39')]['find']({'where':{'id':_0x5c7111[_0xf81c('0x36')]['id']}})['then'](handleEntityNotFound(_0x4e6953,null))[_0xf81c('0x18')](function(_0x54fff7){if(_0x54fff7){return _0x54fff7[_0xf81c('0x38')](_0x5c7111[_0xf81c('0x34')][_0xf81c('0x3a')],_['omit'](_0x5c7111[_0xf81c('0x34')],['ids','id'])||{});}})[_0xf81c('0x18')](respondWithResult(_0x4e6953,null))[_0xf81c('0x32')](handleError(_0x4e6953,null));};exports['getMessages']=function(_0x395ea3,_0xb7a94c){var _0x12c6c7={'raw':![],'where':{}};var _0x4e58b5={};var _0xb8b846={'count':0x0,'rows':[]};return db[_0xf81c('0x1e')][_0xf81c('0x3b')]({'where':{'id':_0x395ea3['params']['id']}})['then'](handleEntityNotFound(_0xb7a94c,null))['then'](function(_0x3cb87e){if(_0x3cb87e){_0x4e58b5[_0xf81c('0x27')]=_[_0xf81c('0x28')](db[_0xf81c('0x39')][_0xf81c('0x1f')]);_0x4e58b5['query']=_[_0xf81c('0x28')](_0x395ea3[_0xf81c('0x24')]);_0x4e58b5[_0xf81c('0x29')]=_[_0xf81c('0x2a')](_0x4e58b5[_0xf81c('0x27')],_0x4e58b5[_0xf81c('0x24')]);_0x12c6c7[_0xf81c('0x2b')]=_[_0xf81c('0x2a')](_0x4e58b5[_0xf81c('0x27')],qs['fields'](_0x395ea3[_0xf81c('0x24')][_0xf81c('0x2c')]));_0x12c6c7[_0xf81c('0x2b')]=_0x12c6c7[_0xf81c('0x2b')][_0xf81c('0x2d')]?_0x12c6c7[_0xf81c('0x2b')]:_0x4e58b5[_0xf81c('0x27')];if(!_0x395ea3[_0xf81c('0x24')][_0xf81c('0x3c')](_0xf81c('0x3d'))){_0x12c6c7[_0xf81c('0x14')]=qs[_0xf81c('0x14')](_0x395ea3[_0xf81c('0x24')][_0xf81c('0x14')]);_0x12c6c7[_0xf81c('0x12')]=qs[_0xf81c('0x12')](_0x395ea3[_0xf81c('0x24')][_0xf81c('0x12')]);}_0x12c6c7[_0xf81c('0x3e')]=qs[_0xf81c('0x3f')](_0x395ea3[_0xf81c('0x24')][_0xf81c('0x3f')]);_0x12c6c7['where']=qs[_0xf81c('0x29')](_[_0xf81c('0x40')](_0x395ea3[_0xf81c('0x24')],_0x4e58b5[_0xf81c('0x29')]));_0x12c6c7['where']['FaxInteractionId']=_0x3cb87e['id'];if(_0x395ea3['query']['filter']){_0x12c6c7[_0xf81c('0x41')]=_[_0xf81c('0x30')](_0x12c6c7[_0xf81c('0x41')],{'$or':_[_0xf81c('0x42')](_0x12c6c7[_0xf81c('0x2b')],function(_0x45d1dd){var _0x3fac6e={};_0x3fac6e[_0x45d1dd]={'$like':'%'+_0x395ea3[_0xf81c('0x24')]['filter']+'%'};return _0x3fac6e;})});}if(_0x395ea3[_0xf81c('0x24')]['$gte']){var _0x283b00=_0x395ea3[_0xf81c('0x24')][_0xf81c('0x43')][_0xf81c('0x44')](',');var _0x54f0b9={};_0x54f0b9[_0x283b00[0x0]]={'$gte':moment(_0x283b00[0x1])['format']('YYYY-MM-DD\x20HH:mm:ss')};_0x12c6c7[_0xf81c('0x41')]=_[_0xf81c('0x30')](_0x12c6c7['where'],_0x54f0b9);}_0x12c6c7=_[_0xf81c('0x30')]({},_0x12c6c7,_0x395ea3['options']);return db[_0xf81c('0x39')][_0xf81c('0x45')]({'where':_0x12c6c7[_0xf81c('0x41')]})['then'](function(_0x8814af){_0xb8b846['count']=_0x8814af;if(_0x395ea3[_0xf81c('0x24')]['includeAll']){_0x12c6c7[_0xf81c('0x2f')]=[{'all':!![]}];}return db[_0xf81c('0x39')][_0xf81c('0x46')](_0x12c6c7);})[_0xf81c('0x18')](function(_0x1bcf6a){_0xb8b846[_0xf81c('0x47')]=_0x1bcf6a;return _0xb8b846;});}})[_0xf81c('0x18')](respondWithFilteredResult(_0xb7a94c,_0x12c6c7))[_0xf81c('0x32')](handleError(_0xb7a94c,null));};exports[_0xf81c('0x48')]=function(_0x3b7a9f,_0x44dadd){return db[_0xf81c('0x1e')][_0xf81c('0x35')]({'where':{'id':_0x3b7a9f[_0xf81c('0x36')]['id']}})[_0xf81c('0x18')](handleEntityNotFound(_0x44dadd,null))[_0xf81c('0x18')](function(_0x277598){if(_0x277598){return _0x277598[_0xf81c('0x49')](_0x3b7a9f[_0xf81c('0x34')][_0xf81c('0x3a')],_[_0xf81c('0x4a')](_0x3b7a9f[_0xf81c('0x34')],[_0xf81c('0x3a'),'id'])||{})[_0xf81c('0x4b')](function(){return db[_0xf81c('0x4c')]['findAll']({'attributes':['id',_0xf81c('0x1b'),_0xf81c('0x4d')],'where':{'id':_0x3b7a9f['body'][_0xf81c('0x3a')]}});})[_0xf81c('0x18')](function(_0x27abee){socket['emit'](_0xf81c('0x4e'),{'id':Number(_0x3b7a9f[_0xf81c('0x36')]['id']),'tags':_0x27abee||[]});return{'id':Number(_0x3b7a9f[_0xf81c('0x36')]['id']),'tags':_0x27abee||[]};});}})[_0xf81c('0x18')](respondWithResult(_0x44dadd,null))['catch'](handleError(_0x44dadd,null));};exports['removeTags']=function(_0x28d028,_0x211524){return db[_0xf81c('0x1e')][_0xf81c('0x35')]({'where':{'id':_0x28d028[_0xf81c('0x36')]['id']}})[_0xf81c('0x18')](handleEntityNotFound(_0x211524,null))[_0xf81c('0x18')](function(_0x2a39a6){if(_0x2a39a6){return _0x2a39a6['removeTags'](_0x28d028['query'][_0xf81c('0x3a')]);}})[_0xf81c('0x18')](respondWithStatusCode(_0x211524,null))[_0xf81c('0x32')](handleError(_0x211524,null));};exports[_0xf81c('0x4f')]=function(_0x1a2150,_0xf8b5db){var _0x565dd1=moment()[_0xf81c('0x50')]()['toString']();var _0x8272ed=path[_0xf81c('0x51')](config[_0xf81c('0x52')],_0xf81c('0x53'),_0xf81c('0x54'),_0xf81c('0x55'));var _0x20daca=path[_0xf81c('0x51')](config['root'],_0xf81c('0x53'),_0xf81c('0x54'),_0xf81c('0x56'));var _0x132ae8=path[_0xf81c('0x51')](_0x8272ed,_0x565dd1);var _0x52ecd0=util[_0xf81c('0x57')](_0xf81c('0x58'),_0x1a2150[_0xf81c('0x36')]['id'],_0x565dd1);var _0x29701e=path['join'](_0x8272ed,_0x52ecd0);var _0x4d5854=[];_0x4d5854[_0xf81c('0x59')]({'model':db[_0xf81c('0x5a')],'as':_0xf81c('0x5a'),'raw':!![]});var _0x222300=[{'model':db[_0xf81c('0x39')],'as':'Messages','attributes':['id',_0xf81c('0x34'),_0xf81c('0x5b')],'include':_0x4d5854}];return db['FaxInteraction'][_0xf81c('0x35')]({'where':{'id':_0x1a2150[_0xf81c('0x36')]['id']},'include':_0x222300})[_0xf81c('0x18')](handleEntityNotFound(_0xf8b5db,null))[_0xf81c('0x18')](function(_0x2df6fb){if(_0x2df6fb&&_0x2df6fb['Messages']){var _0x114765=_0x2df6fb[_0xf81c('0x5c')]({'plain':!![]});fs[_0xf81c('0x5d')](_0x132ae8);for(var _0x675e9a=0x0;_0x675e9a<_0x114765[_0xf81c('0x5e')][_0xf81c('0x2d')];_0x675e9a++){var _0x44b7ae=_0x114765['Messages'][_0x675e9a][_0xf81c('0x5a')];if(_0x44b7ae){var _0x5a6af8=path[_0xf81c('0x51')](_0x20daca,_0x44b7ae[_0xf81c('0x5f')]);if(fs[_0xf81c('0x60')](_0x5a6af8)){fs[_0xf81c('0x61')](_0x5a6af8)['pipe'](fs[_0xf81c('0x62')](path[_0xf81c('0x51')](_0x132ae8,_0x44b7ae[_0xf81c('0x5f')])));}}}return BPromise[_0xf81c('0x63')]()['then'](function(){return new BPromise(function(_0x575de5,_0x2d6e4d){zipdir(_0x132ae8,{'saveTo':_0x29701e},function(_0x190e23,_0x3146c7){if(_0x190e23)return _0x2d6e4d(_0x190e23);return _0x575de5(_0x3146c7);});})['then'](function(){return new BPromise(function(_0x414a75,_0x3dccdc){rimraf(_0x132ae8,function(_0xbf6e96){if(_0xbf6e96)_0x3dccdc(_0xbf6e96);return _0x414a75();});});})[_0xf81c('0x18')](function(){return _0xf8b5db[_0xf81c('0x4f')](_0x29701e,_0x52ecd0,function(_0x29159b){if(_0x29159b){console[_0xf81c('0x64')](_0xf81c('0x65'),_0x29159b);}else{fs[_0xf81c('0x66')](_0x29701e);}});});});}else{return _0xf8b5db[_0xf81c('0xe')](0xc8);}})[_0xf81c('0x32')](handleError(_0xf8b5db,null));};
\ No newline at end of file