Built motion from commit 3c2ce842.|2.6.31
[motion2.git] / server / api / faxInteraction / faxInteraction.controller.js
index c16b2f7..edb87a4 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xc96e=['set','Content-Range','json','update','then','error','stack','name','send','map','FaxInteraction','rawAttributes','fieldName','type','getOptions','findAll','fax','query','catch','show','model','keys','filters','intersection','fields','attributes','includeAll','merge','create','body','find','params','destroy','describe','addMessage','ids','omit','getMessages','findOne','FaxMessage','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','split','format','YYYY-MM-DD\x20HH:mm:ss','options','include','addTags','spread','Tag','emit','faxInteractionTags:save','removeTags','download','unix','toString','join','root','server','files','transcript-%d-%s.zip','push','Attachment','Messages','createdAt','get','mkdirSync','basename','existsSync','createReadStream','pipe','log','err','unlinkSync','rimraf','moment','util','path','lodash','ioredis','../../components/interaction/service','../../components/parsers/qs','../../config/logger','api','../../config/environment','defaults','redis','localhost','./faxInteraction.socket','sendStatus','status','end','offset','undefined','count','limit'];(function(_0x1ea215,_0x3e5d9a){var _0x4418c2=function(_0x49823a){while(--_0x49823a){_0x1ea215['push'](_0x1ea215['shift']());}};_0x4418c2(++_0x3e5d9a);}(_0xc96e,0xb6));var _0xec96=function(_0x15d7e6,_0x15f8b7){_0x15d7e6=_0x15d7e6-0x0;var _0x144e20=_0xc96e[_0x15d7e6];return _0x144e20;};'use strict';var rimraf=require(_0xec96('0x0'));var zipdir=require('zip-dir');var moment=require(_0xec96('0x1'));var BPromise=require('bluebird');var util=require(_0xec96('0x2'));var path=require(_0xec96('0x3'));var fs=require('fs');var _=require(_0xec96('0x4'));var Redis=require(_0xec96('0x5'));var interaction=require(_0xec96('0x6'));var qs=require(_0xec96('0x7'));var logger=require(_0xec96('0x8'))(_0xec96('0x9'));var config=require(_0xec96('0xa'));var db=require('../../mysqldb')['db'];config['redis']=_[_0xec96('0xb')](config[_0xec96('0xc')],{'host':_0xec96('0xd'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xec96('0xc')]));require(_0xec96('0xe'))['register'](socket);function respondWithStatusCode(_0x9a0879,_0x216cf5){_0x216cf5=_0x216cf5||0xcc;return function(_0x252c84){if(_0x252c84){return _0x9a0879[_0xec96('0xf')](_0x216cf5);}return _0x9a0879[_0xec96('0x10')](_0x216cf5)[_0xec96('0x11')]();};}function respondWithResult(_0x469d3c,_0x1275de){_0x1275de=_0x1275de||0xc8;return function(_0x290e35){if(_0x290e35){return _0x469d3c['status'](_0x1275de)['json'](_0x290e35);}};}function respondWithFilteredResult(_0x58b247,_0x2736cb){return function(_0x4ac678){if(_0x4ac678){var _0x2d9e39=typeof _0x2736cb[_0xec96('0x12')]===_0xec96('0x13')&&typeof _0x2736cb['limit']===_0xec96('0x13');var _0x26d26c=_0x4ac678[_0xec96('0x14')];var _0x2377d1=_0x2d9e39?0x0:_0x2736cb[_0xec96('0x12')];var _0x37c9aa=_0x2d9e39?_0x4ac678[_0xec96('0x14')]:_0x2736cb[_0xec96('0x12')]+_0x2736cb[_0xec96('0x15')];var _0x39ed36;if(_0x37c9aa>=_0x26d26c){_0x37c9aa=_0x26d26c;_0x39ed36=0xc8;}else{_0x39ed36=0xce;}_0x58b247[_0xec96('0x10')](_0x39ed36);return _0x58b247[_0xec96('0x16')](_0xec96('0x17'),_0x2377d1+'-'+_0x37c9aa+'/'+_0x26d26c)[_0xec96('0x18')](_0x4ac678);}return null;};}function saveUpdates(_0x89eed0){return function(_0x654b77){if(_0x654b77){return _0x654b77[_0xec96('0x19')](_0x89eed0)[_0xec96('0x1a')](function(_0x1bb1b6){return _0x1bb1b6;});}return null;};}function removeEntity(_0x6006e7){return function(_0x5990d4){if(_0x5990d4){return _0x5990d4['destroy']()['then'](function(){_0x6006e7[_0xec96('0x10')](0xcc)['end']();});}};}function handleEntityNotFound(_0x82ae26){return function(_0x25d3c2){if(!_0x25d3c2){_0x82ae26[_0xec96('0xf')](0x194);}return _0x25d3c2;};}function handleError(_0x5a3cfe,_0x5ac2b0){_0x5ac2b0=_0x5ac2b0||0x1f4;return function(_0x40d0cb){logger[_0xec96('0x1b')](_0x40d0cb[_0xec96('0x1c')]);if(_0x40d0cb[_0xec96('0x1d')]){delete _0x40d0cb[_0xec96('0x1d')];}_0x5a3cfe[_0xec96('0x10')](_0x5ac2b0)[_0xec96('0x1e')](_0x40d0cb);};}exports['index']=function(_0x22aacf,_0x5c8357){var _0x4d8396={};var _0x2c0cad=_[_0xec96('0x1f')](db[_0xec96('0x20')][_0xec96('0x21')],function(_0x3fee7b){return{'name':_0x3fee7b[_0xec96('0x22')],'type':_0x3fee7b[_0xec96('0x23')]['key']};});_0x4d8396=qs[_0xec96('0x24')](_0x2c0cad,_0x22aacf);return interaction[_0xec96('0x25')](_0xec96('0x26'),_0x22aacf[_0xec96('0x27')],_0x22aacf['user'],_0x4d8396,_0x2c0cad)[_0xec96('0x1a')](respondWithFilteredResult(_0x5c8357,_0x4d8396))[_0xec96('0x28')](handleError(_0x5c8357,null));};exports[_0xec96('0x29')]=function(_0xe9bd6e,_0x1d8fae){var _0x2366d4={'raw':![],'where':{'id':_0xe9bd6e['params']['id']}},_0x55a4b4={};_0x55a4b4[_0xec96('0x2a')]=_[_0xec96('0x2b')](db[_0xec96('0x20')][_0xec96('0x21')]);_0x55a4b4['query']=_[_0xec96('0x2b')](_0xe9bd6e['query']);_0x55a4b4[_0xec96('0x2c')]=_[_0xec96('0x2d')](_0x55a4b4['model'],_0x55a4b4['query']);_0x2366d4['attributes']=_[_0xec96('0x2d')](_0x55a4b4['model'],qs[_0xec96('0x2e')](_0xe9bd6e[_0xec96('0x27')]['fields']));_0x2366d4[_0xec96('0x2f')]=_0x2366d4['attributes']['length']?_0x2366d4[_0xec96('0x2f')]:_0x55a4b4[_0xec96('0x2a')];if(_0xe9bd6e[_0xec96('0x27')][_0xec96('0x30')]){_0x2366d4['include']=[{'all':!![]}];}_0x2366d4=_[_0xec96('0x31')]({},_0x2366d4,_0xe9bd6e['options']);return db['FaxInteraction']['find'](_0x2366d4)['then'](handleEntityNotFound(_0x1d8fae,null))[_0xec96('0x1a')](respondWithResult(_0x1d8fae,null))[_0xec96('0x28')](handleError(_0x1d8fae,null));};exports[_0xec96('0x32')]=function(_0x1dd584,_0x34bfbd){return db['FaxInteraction'][_0xec96('0x32')](_0x1dd584['body'],{})['then'](respondWithResult(_0x34bfbd,0xc9))[_0xec96('0x28')](handleError(_0x34bfbd,null));};exports[_0xec96('0x19')]=function(_0x43530b,_0xde4e0){if(_0x43530b[_0xec96('0x33')]['id']){delete _0x43530b[_0xec96('0x33')]['id'];}return db[_0xec96('0x20')][_0xec96('0x34')]({'where':{'id':_0x43530b[_0xec96('0x35')]['id']}})['then'](handleEntityNotFound(_0xde4e0,null))['then'](saveUpdates(_0x43530b[_0xec96('0x33')],null))[_0xec96('0x1a')](respondWithResult(_0xde4e0,null))[_0xec96('0x28')](handleError(_0xde4e0,null));};exports[_0xec96('0x36')]=function(_0x21adaa,_0x37d82d){return db[_0xec96('0x20')][_0xec96('0x34')]({'where':{'id':_0x21adaa['params']['id']}})[_0xec96('0x1a')](handleEntityNotFound(_0x37d82d,null))['then'](removeEntity(_0x37d82d,null))['catch'](handleError(_0x37d82d,null));};exports[_0xec96('0x37')]=function(_0x2bc7cd,_0x25f46b){return db[_0xec96('0x20')][_0xec96('0x37')]()[_0xec96('0x1a')](respondWithResult(_0x25f46b,null))[_0xec96('0x28')](handleError(_0x25f46b,null));};exports['addMessage']=function(_0x241b43,_0x53414c){return db['FaxMessage']['find']({'where':{'id':_0x241b43[_0xec96('0x35')]['id']}})[_0xec96('0x1a')](handleEntityNotFound(_0x53414c,null))[_0xec96('0x1a')](function(_0x1fc85a){if(_0x1fc85a){return _0x1fc85a[_0xec96('0x38')](_0x241b43[_0xec96('0x33')][_0xec96('0x39')],_[_0xec96('0x3a')](_0x241b43[_0xec96('0x33')],[_0xec96('0x39'),'id'])||{});}})[_0xec96('0x1a')](respondWithResult(_0x53414c,null))[_0xec96('0x28')](handleError(_0x53414c,null));};exports[_0xec96('0x3b')]=function(_0x137094,_0x52fef5){var _0x425870={'raw':![],'where':{}};var _0x5404af={};var _0x4c9a95={'count':0x0,'rows':[]};return db[_0xec96('0x20')][_0xec96('0x3c')]({'where':{'id':_0x137094[_0xec96('0x35')]['id']}})[_0xec96('0x1a')](handleEntityNotFound(_0x52fef5,null))[_0xec96('0x1a')](function(_0x97cdf3){if(_0x97cdf3){_0x5404af[_0xec96('0x2a')]=_[_0xec96('0x2b')](db[_0xec96('0x3d')][_0xec96('0x21')]);_0x5404af[_0xec96('0x27')]=_[_0xec96('0x2b')](_0x137094[_0xec96('0x27')]);_0x5404af[_0xec96('0x2c')]=_[_0xec96('0x2d')](_0x5404af[_0xec96('0x2a')],_0x5404af[_0xec96('0x27')]);_0x425870[_0xec96('0x2f')]=_[_0xec96('0x2d')](_0x5404af[_0xec96('0x2a')],qs[_0xec96('0x2e')](_0x137094[_0xec96('0x27')][_0xec96('0x2e')]));_0x425870[_0xec96('0x2f')]=_0x425870['attributes'][_0xec96('0x3e')]?_0x425870[_0xec96('0x2f')]:_0x5404af['model'];if(!_0x137094[_0xec96('0x27')][_0xec96('0x3f')](_0xec96('0x40'))){_0x425870[_0xec96('0x15')]=qs[_0xec96('0x15')](_0x137094['query'][_0xec96('0x15')]);_0x425870['offset']=qs['offset'](_0x137094[_0xec96('0x27')][_0xec96('0x12')]);}_0x425870[_0xec96('0x41')]=qs[_0xec96('0x42')](_0x137094[_0xec96('0x27')][_0xec96('0x42')]);_0x425870[_0xec96('0x43')]=qs[_0xec96('0x2c')](_[_0xec96('0x44')](_0x137094[_0xec96('0x27')],_0x5404af[_0xec96('0x2c')]));_0x425870[_0xec96('0x43')]['FaxInteractionId']=_0x97cdf3['id'];if(_0x137094[_0xec96('0x27')]['filter']){_0x425870['where']=_[_0xec96('0x31')](_0x425870[_0xec96('0x43')],{'$or':_[_0xec96('0x1f')](_0x425870[_0xec96('0x2f')],function(_0x374cb4){var _0x301b42={};_0x301b42[_0x374cb4]={'$like':'%'+_0x137094[_0xec96('0x27')][_0xec96('0x45')]+'%'};return _0x301b42;})});}if(_0x137094[_0xec96('0x27')]['$gte']){var _0x444688=_0x137094[_0xec96('0x27')]['$gte'][_0xec96('0x46')](',');var _0x11531d={};_0x11531d[_0x444688[0x0]]={'$gte':moment(_0x444688[0x1])[_0xec96('0x47')](_0xec96('0x48'))};_0x425870[_0xec96('0x43')]=_['merge'](_0x425870[_0xec96('0x43')],_0x11531d);}_0x425870=_[_0xec96('0x31')]({},_0x425870,_0x137094[_0xec96('0x49')]);return db['FaxMessage']['count']({'where':_0x425870[_0xec96('0x43')]})[_0xec96('0x1a')](function(_0x1c8ec0){_0x4c9a95['count']=_0x1c8ec0;if(_0x137094[_0xec96('0x27')]['includeAll']){_0x425870[_0xec96('0x4a')]=[{'all':!![]}];}return db[_0xec96('0x3d')][_0xec96('0x25')](_0x425870);})['then'](function(_0x4a30c3){_0x4c9a95['rows']=_0x4a30c3;return _0x4c9a95;});}})[_0xec96('0x1a')](respondWithFilteredResult(_0x52fef5,_0x425870))[_0xec96('0x28')](handleError(_0x52fef5,null));};exports[_0xec96('0x4b')]=function(_0x310988,_0x4ceaaf){return db[_0xec96('0x20')][_0xec96('0x34')]({'where':{'id':_0x310988[_0xec96('0x35')]['id']}})[_0xec96('0x1a')](handleEntityNotFound(_0x4ceaaf,null))[_0xec96('0x1a')](function(_0x456bae){if(_0x456bae){return _0x456bae['setTags'](_0x310988['body'][_0xec96('0x39')],_['omit'](_0x310988['body'],[_0xec96('0x39'),'id'])||{})[_0xec96('0x4c')](function(){return db[_0xec96('0x4d')][_0xec96('0x25')]({'attributes':['id',_0xec96('0x1d'),'color'],'where':{'id':_0x310988[_0xec96('0x33')][_0xec96('0x39')]}});})[_0xec96('0x1a')](function(_0x2cc9ab){socket[_0xec96('0x4e')](_0xec96('0x4f'),{'id':Number(_0x310988[_0xec96('0x35')]['id']),'tags':_0x2cc9ab||[]});return{'id':Number(_0x310988[_0xec96('0x35')]['id']),'tags':_0x2cc9ab||[]};});}})[_0xec96('0x1a')](respondWithResult(_0x4ceaaf,null))[_0xec96('0x28')](handleError(_0x4ceaaf,null));};exports[_0xec96('0x50')]=function(_0x460b69,_0x2cd16e){return db[_0xec96('0x20')][_0xec96('0x34')]({'where':{'id':_0x460b69[_0xec96('0x35')]['id']}})['then'](handleEntityNotFound(_0x2cd16e,null))[_0xec96('0x1a')](function(_0x45aea6){if(_0x45aea6){return _0x45aea6[_0xec96('0x50')](_0x460b69[_0xec96('0x27')][_0xec96('0x39')]);}})['then'](respondWithStatusCode(_0x2cd16e,null))[_0xec96('0x28')](handleError(_0x2cd16e,null));};exports[_0xec96('0x51')]=function(_0x476cab,_0xdf368a){var _0x545254=moment()[_0xec96('0x52')]()[_0xec96('0x53')]();var _0x179591=path[_0xec96('0x54')](config[_0xec96('0x55')],_0xec96('0x56'),_0xec96('0x57'),'tmp');var _0x1e8e48=path['join'](config[_0xec96('0x55')],'server',_0xec96('0x57'),'attachments');var _0x1ab07b=path[_0xec96('0x54')](_0x179591,_0x545254);var _0x4ee949=util[_0xec96('0x47')](_0xec96('0x58'),_0x476cab[_0xec96('0x35')]['id'],_0x545254);var _0x367b4d=path[_0xec96('0x54')](_0x179591,_0x4ee949);var _0x45a11d=[];_0x45a11d[_0xec96('0x59')]({'model':db['Attachment'],'as':_0xec96('0x5a'),'raw':!![]});var _0x284a4e=[{'model':db[_0xec96('0x3d')],'as':_0xec96('0x5b'),'attributes':['id',_0xec96('0x33'),_0xec96('0x5c')],'include':_0x45a11d}];return db['FaxInteraction'][_0xec96('0x34')]({'where':{'id':_0x476cab[_0xec96('0x35')]['id']},'include':_0x284a4e})['then'](handleEntityNotFound(_0xdf368a,null))[_0xec96('0x1a')](function(_0x734158){if(_0x734158&&_0x734158[_0xec96('0x5b')]){var _0x4a2d0b=_0x734158[_0xec96('0x5d')]({'plain':!![]});fs[_0xec96('0x5e')](_0x1ab07b);for(var _0x30984e=0x0;_0x30984e<_0x4a2d0b[_0xec96('0x5b')][_0xec96('0x3e')];_0x30984e++){var _0x2195e0=_0x4a2d0b[_0xec96('0x5b')][_0x30984e][_0xec96('0x5a')];if(_0x2195e0){var _0x47056f=path[_0xec96('0x54')](_0x1e8e48,_0x2195e0[_0xec96('0x5f')]);if(fs[_0xec96('0x60')](_0x47056f)){fs[_0xec96('0x61')](_0x47056f)[_0xec96('0x62')](fs['createWriteStream'](path[_0xec96('0x54')](_0x1ab07b,_0x2195e0['basename'])));}}}return BPromise['resolve']()['then'](function(){return new BPromise(function(_0x94487c,_0x3ca2c3){zipdir(_0x1ab07b,{'saveTo':_0x367b4d},function(_0xcecba4,_0x51f8c9){if(_0xcecba4)return _0x3ca2c3(_0xcecba4);return _0x94487c(_0x51f8c9);});})['then'](function(){return new BPromise(function(_0x430aba,_0x310c0a){rimraf(_0x1ab07b,function(_0x34b08f){if(_0x34b08f)_0x310c0a(_0x34b08f);return _0x430aba();});});})[_0xec96('0x1a')](function(){return _0xdf368a[_0xec96('0x51')](_0x367b4d,_0x4ee949,function(_0x580d82){if(_0x580d82){console[_0xec96('0x63')](_0xec96('0x64'),_0x580d82);}else{fs[_0xec96('0x65')](_0x367b4d);}});});});}else{return _0xdf368a[_0xec96('0xf')](0xc8);}})[_0xec96('0x28')](handleError(_0xdf368a,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