Built motion from commit (unavailable).|2.2.0
[motion2.git] / server / api / faxInteraction / faxInteraction.controller.js
index 0daeb1f..5a6e081 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x0f96=['Tags','ThroughTags','color','findAll','rows','show','params','fields','find','create','body','catch','addMessage','ids','omit','findOne','map','$gte','split','YYYY-MM-DD\x20HH:mm:ss','addTags','setTags','emit','faxInteractionTags:save','removeTags','toString','root','server','files','tmp','format','join','getMessages','Attachment','mkdirSync','basename','existsSync','createReadStream','pipe','createWriteStream','log','err','unlinkSync','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','sox','to-csv','ejs','jsforce','desk.js','querystring','papaparse','ioredis','../../components/parsers/qs','../../config/logger','api','../../config/environment','defaults','redis','socket.io-emitter','./faxInteraction.socket','register','sendStatus','status','count','offset','set','Content-Range','json','apply','reject','update','then','end','error','stack','name','FaxInteraction','rawAttributes','query','dateStart','dateEnd','keys','filters','intersection','attributes','model','length','hasOwnProperty','nolimit','limit','order','sort','pick','add','day','merge','filter','where','options','include','tag','push','Tag','FaxMessage','Messages','direction','createdAt','read','distinct','includeAll','User','Users','fullname','CmContact','Contact','Owner','internal','FaxAccount','Account','key'];(function(_0x1b8829,_0xf3999d){var _0x3aa936=function(_0x599421){while(--_0x599421){_0x1b8829['push'](_0x1b8829['shift']());}};_0x3aa936(++_0xf3999d);}(_0x0f96,0x125));var _0x60f9=function(_0x55246b,_0x37d4e1){_0x55246b=_0x55246b-0x0;var _0x101838=_0x0f96[_0x55246b];return _0x101838;};'use strict';var pdf=require('html-pdf');var emlformat=require('eml-format');var rimraf=require('rimraf');var zipdir=require(_0x60f9('0x0'));var jsonpatch=require(_0x60f9('0x1'));var rp=require(_0x60f9('0x2'));var moment=require(_0x60f9('0x3'));var BPromise=require(_0x60f9('0x4'));var Mustache=require(_0x60f9('0x5'));var util=require('util');var path=require('path');var sox=require(_0x60f9('0x6'));var csv=require(_0x60f9('0x7'));var ejs=require(_0x60f9('0x8'));var fs=require('fs');var _=require('lodash');var squel=require('squel');var crypto=require('crypto');var jsforce=require(_0x60f9('0x9'));var deskjs=require(_0x60f9('0xa'));var toCsv=require(_0x60f9('0x7'));var querystring=require(_0x60f9('0xb'));var Papa=require(_0x60f9('0xc'));var Redis=require(_0x60f9('0xd'));var qs=require(_0x60f9('0xe'));var logger=require(_0x60f9('0xf'))(_0x60f9('0x10'));var utils=require('../../config/utils');var config=require(_0x60f9('0x11'));var db=require('../../mysqldb')['db'];config['redis']=_[_0x60f9('0x12')](config[_0x60f9('0x13')],{'host':'localhost','port':0x18eb});var socket=require(_0x60f9('0x14'))(new Redis(config[_0x60f9('0x13')]));require(_0x60f9('0x15'))[_0x60f9('0x16')](socket);function respondWithStatusCode(_0x23328f,_0xf4ef8b){_0xf4ef8b=_0xf4ef8b||0xcc;return function(_0x32dcb0){if(_0x32dcb0){return _0x23328f[_0x60f9('0x17')](_0xf4ef8b);}return _0x23328f[_0x60f9('0x18')](_0xf4ef8b)['end']();};}function respondWithResult(_0x5acc4e,_0x162dbc){_0x162dbc=_0x162dbc||0xc8;return function(_0x552acf){if(_0x552acf){return _0x5acc4e[_0x60f9('0x18')](_0x162dbc)['json'](_0x552acf);}};}function respondWithFilteredResult(_0x1fa53a,_0x3fda5f){return function(_0x5abdde){if(_0x5abdde){var _0x4bd993=_0x5abdde[_0x60f9('0x19')],_0x45b839=_0x3fda5f[_0x60f9('0x1a')],_0x9c0df6=_0x3fda5f[_0x60f9('0x1a')]+_0x3fda5f['limit'],_0x56b600;if(_0x9c0df6>=_0x4bd993){_0x9c0df6=_0x4bd993;_0x56b600=0xc8;}else{_0x56b600=0xce;}_0x1fa53a['status'](_0x56b600);return _0x1fa53a[_0x60f9('0x1b')](_0x60f9('0x1c'),_0x45b839+'-'+_0x9c0df6+'/'+_0x4bd993)[_0x60f9('0x1d')](_0x5abdde);}return null;};}function patchUpdates(_0x1d1b56){return function(_0x3cb389){try{jsonpatch[_0x60f9('0x1e')](_0x3cb389,_0x1d1b56,!![]);}catch(_0x35bb4e){return BPromise[_0x60f9('0x1f')](_0x35bb4e);}return _0x3cb389['save']();};}function saveUpdates(_0x59b143,_0x583e90){return function(_0x35bad6){if(_0x35bad6){return _0x35bad6[_0x60f9('0x20')](_0x59b143)['then'](function(_0x18b189){return _0x18b189;});}return null;};}function removeEntity(_0xd1520a,_0x2c8037){return function(_0x52473d){if(_0x52473d){return _0x52473d['destroy']()[_0x60f9('0x21')](function(){_0xd1520a[_0x60f9('0x18')](0xcc)[_0x60f9('0x22')]();});}};}function handleEntityNotFound(_0x3006a0,_0x449601){return function(_0x85ef88){if(!_0x85ef88){_0x3006a0['sendStatus'](0x194);}return _0x85ef88;};}function handleError(_0x2448b4,_0x4e78f4){_0x4e78f4=_0x4e78f4||0x1f4;return function(_0x2b045a){logger[_0x60f9('0x23')](_0x2b045a[_0x60f9('0x24')]);if(_0x2b045a[_0x60f9('0x25')]){delete _0x2b045a[_0x60f9('0x25')];}_0x2448b4[_0x60f9('0x18')](_0x4e78f4)['send'](_0x2b045a);};}exports['index']=function(_0x590916,_0x3122ea){var _0x283b80={},_0x18fbbe={},_0x587e29={'count':0x0,'rows':[]};var _0x12eda1=db[_0x60f9('0x26')][_0x60f9('0x27')];_0x18fbbe['model']=_['keys'](_0x12eda1);var _0x2431b8={'dateStart':_0x590916[_0x60f9('0x28')][_0x60f9('0x29')],'dateEnd':_0x590916['query'][_0x60f9('0x2a')]};delete _0x590916[_0x60f9('0x28')][_0x60f9('0x29')];delete _0x590916[_0x60f9('0x28')][_0x60f9('0x2a')];_0x18fbbe[_0x60f9('0x28')]=_[_0x60f9('0x2b')](_0x590916[_0x60f9('0x28')]);_0x18fbbe[_0x60f9('0x2c')]=_[_0x60f9('0x2d')](_0x18fbbe['model'],_0x18fbbe['query']);_0x283b80[_0x60f9('0x2e')]=_['intersection'](_0x18fbbe[_0x60f9('0x2f')],qs['fields'](_0x590916[_0x60f9('0x28')]['fields']));_0x283b80[_0x60f9('0x2e')]=_0x283b80['attributes'][_0x60f9('0x30')]?_0x283b80[_0x60f9('0x2e')]:_0x18fbbe[_0x60f9('0x2f')];if(!_0x590916[_0x60f9('0x28')][_0x60f9('0x31')](_0x60f9('0x32'))){_0x283b80[_0x60f9('0x33')]=qs['limit'](_0x590916[_0x60f9('0x28')][_0x60f9('0x33')]);_0x283b80['offset']=qs['offset'](_0x590916[_0x60f9('0x28')][_0x60f9('0x1a')]);}_0x283b80[_0x60f9('0x34')]=qs[_0x60f9('0x35')](_0x590916[_0x60f9('0x28')][_0x60f9('0x35')]);_0x283b80['where']=qs[_0x60f9('0x2c')](_[_0x60f9('0x36')](_0x590916[_0x60f9('0x28')],_0x18fbbe['filters']));if(_0x2431b8[_0x60f9('0x29')]){if(_0x2431b8[_0x60f9('0x2a')]){_0x2431b8[_0x60f9('0x2a')]=moment(_0x2431b8['dateEnd'])[_0x60f9('0x37')](0x1,_0x60f9('0x38'));}else{_0x2431b8[_0x60f9('0x2a')]=moment(_0x2431b8[_0x60f9('0x29')])[_0x60f9('0x37')](0x1,_0x60f9('0x38'));}_[_0x60f9('0x39')](_0x283b80['where'],{'createdAt':{'$gte':_0x2431b8[_0x60f9('0x29')],'$lte':_0x2431b8[_0x60f9('0x2a')]}});}if(_0x590916[_0x60f9('0x28')][_0x60f9('0x3a')]){_0x283b80[_0x60f9('0x3b')]=_[_0x60f9('0x39')](_0x283b80[_0x60f9('0x3b')],{'$or':_['map'](_0x283b80[_0x60f9('0x2e')],function(_0x3a1a04){var _0x122cde={};_0x122cde[_0x3a1a04]={'$like':'%'+_0x590916[_0x60f9('0x28')][_0x60f9('0x3a')]+'%'};return _0x122cde;})});}_0x283b80=_[_0x60f9('0x39')]({},_0x283b80,_0x590916[_0x60f9('0x3c')]);var _0x2bbd09={'where':_0x283b80[_0x60f9('0x3b')]};_0x2bbd09[_0x60f9('0x3d')]=[];if(_0x590916['query'][_0x60f9('0x3e')]){_0x2bbd09[_0x60f9('0x3d')][_0x60f9('0x3f')]({'model':db[_0x60f9('0x40')],'as':'Tags','attributes':['id'],'where':{'id':_0x590916[_0x60f9('0x28')]['tag']},'required':!![]});_0x2bbd09['distinct']=!![];}if(_0x590916[_0x60f9('0x28')]['read']){_0x2bbd09['include'][_0x60f9('0x3f')]({'model':db[_0x60f9('0x41')],'as':_0x60f9('0x42'),'attributes':['id',_0x60f9('0x43'),_0x60f9('0x44'),_0x60f9('0x45')],'where':{'direction':'in','read':_0x590916[_0x60f9('0x28')][_0x60f9('0x45')]||![]},'required':!![]});_0x2bbd09[_0x60f9('0x46')]=!![];}return db['FaxInteraction']['count'](_0x2bbd09)[_0x60f9('0x21')](function(_0x84cba4){_0x587e29[_0x60f9('0x19')]=_0x84cba4;if(_0x590916[_0x60f9('0x28')][_0x60f9('0x47')]){_0x283b80[_0x60f9('0x3d')]=[{'model':db[_0x60f9('0x48')],'as':_0x60f9('0x49'),'required':![],'attributes':['id',_0x60f9('0x25'),_0x60f9('0x4a')]},{'model':db[_0x60f9('0x4b')],'as':_0x60f9('0x4c'),'required':![]},{'model':db[_0x60f9('0x48')],'as':_0x60f9('0x4d'),'attributes':['name',_0x60f9('0x4a'),_0x60f9('0x4e')],'required':![]},{'model':db[_0x60f9('0x4f')],'as':_0x60f9('0x50'),'attributes':[_0x60f9('0x25'),_0x60f9('0x51')],'required':![]},{'model':db[_0x60f9('0x41')],'as':_0x60f9('0x42'),'attributes':['id',_0x60f9('0x43'),_0x60f9('0x44'),'read'],'where':{'direction':'in','read':_0x590916[_0x60f9('0x28')][_0x60f9('0x45')]||![]},'required':_0x590916['query'][_0x60f9('0x45')]||![]},{'model':db[_0x60f9('0x40')],'as':_0x60f9('0x52'),'attributes':['id','name','color'],'required':_0x590916[_0x60f9('0x28')][_0x60f9('0x3e')]?!![]:![]},{'model':db[_0x60f9('0x40')],'as':_0x60f9('0x53'),'attributes':['id',_0x60f9('0x25'),_0x60f9('0x54')],'through':_0x590916[_0x60f9('0x28')][_0x60f9('0x3e')]?{'attributes':[],'where':{'TagId':_0x590916['query'][_0x60f9('0x3e')]||undefined}}:{},'required':_0x590916['query'][_0x60f9('0x3e')]?!![]:![]}];}return db['FaxInteraction'][_0x60f9('0x55')](_0x283b80);})[_0x60f9('0x21')](function(_0x475888){_0x587e29[_0x60f9('0x56')]=_0x475888;return _0x587e29;})[_0x60f9('0x21')](respondWithFilteredResult(_0x3122ea,_0x283b80))['catch'](handleError(_0x3122ea,null));};exports[_0x60f9('0x57')]=function(_0x39e9bf,_0xcdc453){var _0xe24b1e={'raw':![],'where':{'id':_0x39e9bf[_0x60f9('0x58')]['id']}},_0x55e6a4={};_0x55e6a4[_0x60f9('0x2f')]=_['keys'](db[_0x60f9('0x26')]['rawAttributes']);_0x55e6a4[_0x60f9('0x28')]=_[_0x60f9('0x2b')](_0x39e9bf[_0x60f9('0x28')]);_0x55e6a4['filters']=_[_0x60f9('0x2d')](_0x55e6a4[_0x60f9('0x2f')],_0x55e6a4['query']);_0xe24b1e[_0x60f9('0x2e')]=_[_0x60f9('0x2d')](_0x55e6a4[_0x60f9('0x2f')],qs[_0x60f9('0x59')](_0x39e9bf[_0x60f9('0x28')][_0x60f9('0x59')]));_0xe24b1e[_0x60f9('0x2e')]=_0xe24b1e['attributes'][_0x60f9('0x30')]?_0xe24b1e[_0x60f9('0x2e')]:_0x55e6a4[_0x60f9('0x2f')];if(_0x39e9bf[_0x60f9('0x28')][_0x60f9('0x47')]){_0xe24b1e[_0x60f9('0x3d')]=[{'all':!![]}];}_0xe24b1e=_[_0x60f9('0x39')]({},_0xe24b1e,_0x39e9bf[_0x60f9('0x3c')]);return db[_0x60f9('0x26')][_0x60f9('0x5a')](_0xe24b1e)[_0x60f9('0x21')](handleEntityNotFound(_0xcdc453,null))[_0x60f9('0x21')](respondWithResult(_0xcdc453,null))['catch'](handleError(_0xcdc453,null));};exports[_0x60f9('0x5b')]=function(_0x5712c7,_0x36c5a1){return db[_0x60f9('0x26')][_0x60f9('0x5b')](_0x5712c7[_0x60f9('0x5c')],{})[_0x60f9('0x21')](respondWithResult(_0x36c5a1,0xc9))[_0x60f9('0x5d')](handleError(_0x36c5a1,null));};exports['update']=function(_0x34ceea,_0x318982){if(_0x34ceea[_0x60f9('0x5c')]['id']){delete _0x34ceea[_0x60f9('0x5c')]['id'];}return db[_0x60f9('0x26')][_0x60f9('0x5a')]({'where':{'id':_0x34ceea[_0x60f9('0x58')]['id']}})['then'](handleEntityNotFound(_0x318982,null))['then'](saveUpdates(_0x34ceea[_0x60f9('0x5c')],null))[_0x60f9('0x21')](respondWithResult(_0x318982,null))[_0x60f9('0x5d')](handleError(_0x318982,null));};exports['destroy']=function(_0x1421e3,_0x5df4c8){return db['FaxInteraction'][_0x60f9('0x5a')]({'where':{'id':_0x1421e3[_0x60f9('0x58')]['id']}})['then'](handleEntityNotFound(_0x5df4c8,null))[_0x60f9('0x21')](removeEntity(_0x5df4c8,null))[_0x60f9('0x5d')](handleError(_0x5df4c8,null));};exports['describe']=function(_0x3cc523,_0xc426d0){return db[_0x60f9('0x26')]['describe']()[_0x60f9('0x21')](respondWithResult(_0xc426d0,null))[_0x60f9('0x5d')](handleError(_0xc426d0,null));};exports[_0x60f9('0x5e')]=function(_0x3ed012,_0x56faff,_0x9ab982){return db[_0x60f9('0x41')][_0x60f9('0x5a')]({'where':{'id':_0x3ed012[_0x60f9('0x58')]['id']}})[_0x60f9('0x21')](handleEntityNotFound(_0x56faff,null))[_0x60f9('0x21')](function(_0x31d62d){if(_0x31d62d){return _0x31d62d[_0x60f9('0x5e')](_0x3ed012[_0x60f9('0x5c')][_0x60f9('0x5f')],_[_0x60f9('0x60')](_0x3ed012[_0x60f9('0x5c')],[_0x60f9('0x5f'),'id'])||{});}})[_0x60f9('0x21')](respondWithResult(_0x56faff,null))[_0x60f9('0x5d')](handleError(_0x56faff,null));};exports['getMessages']=function(_0x3f37f9,_0x45b76d,_0x3f238e){var _0xf231ca={'raw':![],'where':{}};var _0x3e11fd={};var _0x475c12={'count':0x0,'rows':[]};return db[_0x60f9('0x26')][_0x60f9('0x61')]({'where':{'id':_0x3f37f9[_0x60f9('0x58')]['id']}})[_0x60f9('0x21')](handleEntityNotFound(_0x45b76d,null))[_0x60f9('0x21')](function(_0x1dbc3a){if(_0x1dbc3a){_0x3e11fd['model']=_[_0x60f9('0x2b')](db[_0x60f9('0x41')][_0x60f9('0x27')]);_0x3e11fd[_0x60f9('0x28')]=_[_0x60f9('0x2b')](_0x3f37f9[_0x60f9('0x28')]);_0x3e11fd['filters']=_[_0x60f9('0x2d')](_0x3e11fd['model'],_0x3e11fd['query']);_0xf231ca[_0x60f9('0x2e')]=_[_0x60f9('0x2d')](_0x3e11fd[_0x60f9('0x2f')],qs['fields'](_0x3f37f9[_0x60f9('0x28')][_0x60f9('0x59')]));_0xf231ca['attributes']=_0xf231ca[_0x60f9('0x2e')]['length']?_0xf231ca[_0x60f9('0x2e')]:_0x3e11fd[_0x60f9('0x2f')];if(!_0x3f37f9[_0x60f9('0x28')]['hasOwnProperty'](_0x60f9('0x32'))){_0xf231ca[_0x60f9('0x33')]=qs[_0x60f9('0x33')](_0x3f37f9[_0x60f9('0x28')][_0x60f9('0x33')]);_0xf231ca['offset']=qs['offset'](_0x3f37f9['query']['offset']);}_0xf231ca[_0x60f9('0x34')]=qs[_0x60f9('0x35')](_0x3f37f9[_0x60f9('0x28')]['sort']);_0xf231ca['where']=qs[_0x60f9('0x2c')](_[_0x60f9('0x36')](_0x3f37f9[_0x60f9('0x28')],_0x3e11fd['filters']));_0xf231ca['where']['FaxInteractionId']=_0x1dbc3a['id'];if(_0x3f37f9[_0x60f9('0x28')]['filter']){_0xf231ca[_0x60f9('0x3b')]=_[_0x60f9('0x39')](_0xf231ca[_0x60f9('0x3b')],{'$or':_[_0x60f9('0x62')](_0xf231ca[_0x60f9('0x2e')],function(_0x46e341){var _0x192032={};_0x192032[_0x46e341]={'$like':'%'+_0x3f37f9['query']['filter']+'%'};return _0x192032;})});}if(_0x3f37f9['query'][_0x60f9('0x63')]){var _0x3e71cd=_0x3f37f9[_0x60f9('0x28')]['$gte'][_0x60f9('0x64')](',');var _0x129731={};_0x129731[_0x3e71cd[0x0]]={'$gte':moment(_0x3e71cd[0x1])['format'](_0x60f9('0x65'))};_0xf231ca[_0x60f9('0x3b')]=_[_0x60f9('0x39')](_0xf231ca[_0x60f9('0x3b')],_0x129731);}_0xf231ca=_[_0x60f9('0x39')]({},_0xf231ca,_0x3f37f9[_0x60f9('0x3c')]);return db[_0x60f9('0x41')][_0x60f9('0x19')]({'where':_0xf231ca['where']})[_0x60f9('0x21')](function(_0x18ecc3){_0x475c12[_0x60f9('0x19')]=_0x18ecc3;if(_0x3f37f9[_0x60f9('0x28')]['includeAll']){_0xf231ca[_0x60f9('0x3d')]=[{'all':!![]}];}return db[_0x60f9('0x41')][_0x60f9('0x55')](_0xf231ca);})['then'](function(_0xebcc78){_0x475c12[_0x60f9('0x56')]=_0xebcc78;return _0x475c12;});}})['then'](respondWithFilteredResult(_0x45b76d,_0xf231ca))[_0x60f9('0x5d')](handleError(_0x45b76d,null));};exports[_0x60f9('0x66')]=function(_0x1e8108,_0x18f0f7,_0x54842f){return db[_0x60f9('0x26')]['find']({'where':{'id':_0x1e8108[_0x60f9('0x58')]['id']}})[_0x60f9('0x21')](handleEntityNotFound(_0x18f0f7,null))[_0x60f9('0x21')](function(_0x37fe51){if(_0x37fe51){return _0x37fe51[_0x60f9('0x67')](_0x1e8108[_0x60f9('0x5c')][_0x60f9('0x5f')],_[_0x60f9('0x60')](_0x1e8108[_0x60f9('0x5c')],['ids','id'])||{})['spread'](function(){return db[_0x60f9('0x40')][_0x60f9('0x55')]({'attributes':['id',_0x60f9('0x25'),_0x60f9('0x54')],'where':{'id':_0x1e8108[_0x60f9('0x5c')][_0x60f9('0x5f')]}});})[_0x60f9('0x21')](function(_0x403a5d){socket[_0x60f9('0x68')](_0x60f9('0x69'),{'id':Number(_0x1e8108[_0x60f9('0x58')]['id']),'tags':_0x403a5d||[]});return{'id':Number(_0x1e8108[_0x60f9('0x58')]['id']),'tags':_0x403a5d||[]};});}})[_0x60f9('0x21')](respondWithResult(_0x18f0f7,null))['catch'](handleError(_0x18f0f7,null));};exports[_0x60f9('0x6a')]=function(_0xe2166c,_0x29ad4c,_0x58175a){var _0x2c3b5d;return db['FaxInteraction'][_0x60f9('0x5a')]({'where':{'id':_0xe2166c[_0x60f9('0x58')]['id']}})[_0x60f9('0x21')](handleEntityNotFound(_0x29ad4c,null))[_0x60f9('0x21')](function(_0x3c7301){if(_0x3c7301){return _0x3c7301[_0x60f9('0x6a')](_0xe2166c[_0x60f9('0x28')]['ids']);}})[_0x60f9('0x21')](respondWithStatusCode(_0x29ad4c,null))[_0x60f9('0x5d')](handleError(_0x29ad4c,null));};exports['download']=function(_0x273fc2,_0x2efd16){var _0x47be74=moment()['unix']()[_0x60f9('0x6b')]();var _0x113f38=path['join'](config[_0x60f9('0x6c')],_0x60f9('0x6d'),_0x60f9('0x6e'),'attachments');var _0x5b35df=path['join'](config['root'],_0x60f9('0x6d'),_0x60f9('0x6e'),_0x60f9('0x6f'));var _0x529760=path['join'](_0x5b35df,_0x47be74);var _0x2d93cf=util[_0x60f9('0x70')]('interaction-%s.zip',_0x47be74);var _0x307a47=path[_0x60f9('0x71')](_0x5b35df,_0x2d93cf);var _0x4c71de=![];return db[_0x60f9('0x26')][_0x60f9('0x5a')]({'where':{'id':_0x273fc2[_0x60f9('0x58')]['id']}})[_0x60f9('0x21')](handleEntityNotFound(_0x2efd16,null))['then'](function(_0x547336){if(_0x547336){return _0x547336[_0x60f9('0x72')]({'attributes':['id','body',_0x60f9('0x44')],'include':[{'model':db[_0x60f9('0x73')],'as':_0x60f9('0x73')}]});}return[];})[_0x60f9('0x21')](function(_0xa464ec){_0x4c71de=_0xa464ec[_0x60f9('0x30')];if(_0xa464ec[_0x60f9('0x30')]){fs[_0x60f9('0x74')](_0x529760);for(var _0x42fc14=0x0;_0x42fc14<_0xa464ec['length'];_0x42fc14++){var _0x47bca4=_0xa464ec[_0x42fc14];var _0xf825c9=_0x47bca4[_0x60f9('0x73')];if(_0xf825c9){var _0x57ef8c=path[_0x60f9('0x71')](_0x113f38,_0xf825c9[_0x60f9('0x75')]);if(fs[_0x60f9('0x76')](_0x57ef8c)){fs[_0x60f9('0x77')](_0x57ef8c)[_0x60f9('0x78')](fs[_0x60f9('0x79')](path['join'](_0x529760,_0xf825c9[_0x60f9('0x75')])));}}}}})[_0x60f9('0x21')](function(){if(_0x4c71de){return new BPromise(function(_0x4ae404,_0x142ee1){zipdir(_0x529760,{'saveTo':_0x307a47},function(_0x8c9c98,_0x4d5cb1){if(_0x8c9c98)return _0x142ee1(_0x8c9c98);return _0x4ae404(_0x4d5cb1);});});}})[_0x60f9('0x21')](function(){if(_0x4c71de){return new BPromise(function(_0x1ebefb,_0x517d6e){rimraf(_0x529760,function(_0x3edf13){if(_0x3edf13)_0x517d6e(_0x3edf13);return _0x1ebefb();});});}})[_0x60f9('0x21')](function(){if(_0x4c71de){return _0x2efd16['download'](_0x307a47,_0x2d93cf,function(_0x2db8cc){if(_0x2db8cc){console[_0x60f9('0x7a')](_0x60f9('0x7b'),_0x2db8cc);}else{fs[_0x60f9('0x7c')](_0x307a47);}});}else{return _0x2efd16[_0x60f9('0x17')](0xc8);}})[_0x60f9('0x5d')](handleError(_0x2efd16,null));};
\ No newline at end of file
+var _0xa9e0=['params','describe','addMessage','ids','omit','getMessages','findOne','$gte','split','format','YYYY-MM-DD\x20HH:mm:ss','rows','addTags','setTags','spread','faxInteractionTags:save','removeTags','download','toString','join','server','files','attachments','root','interaction-%s.zip','Attachment','mkdirSync','existsSync','createReadStream','pipe','createWriteStream','log','err','html-pdf','eml-format','rimraf','request-promise','bluebird','mustache','util','path','sox','ejs','lodash','squel','desk.js','papaparse','ioredis','../../components/parsers/qs','../../config/logger','api','../../config/utils','redis','localhost','socket.io-emitter','./faxInteraction.socket','register','sendStatus','status','end','json','count','offset','limit','set','Content-Range','apply','reject','save','then','destroy','error','stack','name','send','FaxInteraction','rawAttributes','keys','query','dateStart','dateEnd','filters','model','attributes','intersection','fields','length','hasOwnProperty','nolimit','order','sort','pick','add','day','merge','where','map','key','VIRTUAL','field','filter','options','include','tag','push','Tag','Tags','distinct','read','FaxMessage','Messages','direction','createdAt','includeAll','User','Users','fullname','CmContact','internal','Account','color','ThroughTags','findAll','catch','show','find','create','body','update'];(function(_0xfae23b,_0x2be4ba){var _0x200640=function(_0x4ae258){while(--_0x4ae258){_0xfae23b['push'](_0xfae23b['shift']());}};_0x200640(++_0x2be4ba);}(_0xa9e0,0x123));var _0x0a9e=function(_0x491a7f,_0x28bb80){_0x491a7f=_0x491a7f-0x0;var _0x3d8f44=_0xa9e0[_0x491a7f];return _0x3d8f44;};'use strict';var pdf=require(_0x0a9e('0x0'));var emlformat=require(_0x0a9e('0x1'));var rimraf=require(_0x0a9e('0x2'));var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require(_0x0a9e('0x3'));var moment=require('moment');var BPromise=require(_0x0a9e('0x4'));var Mustache=require(_0x0a9e('0x5'));var util=require(_0x0a9e('0x6'));var path=require(_0x0a9e('0x7'));var sox=require(_0x0a9e('0x8'));var csv=require('to-csv');var ejs=require(_0x0a9e('0x9'));var fs=require('fs');var _=require(_0x0a9e('0xa'));var squel=require(_0x0a9e('0xb'));var crypto=require('crypto');var jsforce=require('jsforce');var deskjs=require(_0x0a9e('0xc'));var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0x0a9e('0xd'));var Redis=require(_0x0a9e('0xe'));var qs=require(_0x0a9e('0xf'));var logger=require(_0x0a9e('0x10'))(_0x0a9e('0x11'));var utils=require(_0x0a9e('0x12'));var config=require('../../config/environment');var db=require('../../mysqldb')['db'];config['redis']=_['defaults'](config[_0x0a9e('0x13')],{'host':_0x0a9e('0x14'),'port':0x18eb});var socket=require(_0x0a9e('0x15'))(new Redis(config[_0x0a9e('0x13')]));require(_0x0a9e('0x16'))[_0x0a9e('0x17')](socket);function respondWithStatusCode(_0x5db4b0,_0x4283ce){_0x4283ce=_0x4283ce||0xcc;return function(_0x239b12){if(_0x239b12){return _0x5db4b0[_0x0a9e('0x18')](_0x4283ce);}return _0x5db4b0[_0x0a9e('0x19')](_0x4283ce)[_0x0a9e('0x1a')]();};}function respondWithResult(_0x4d5611,_0x52a03d){_0x52a03d=_0x52a03d||0xc8;return function(_0x22dccb){if(_0x22dccb){return _0x4d5611['status'](_0x52a03d)[_0x0a9e('0x1b')](_0x22dccb);}};}function respondWithFilteredResult(_0x519dfd,_0x16033c){return function(_0x12066b){if(_0x12066b){var _0x48f32d=_0x12066b[_0x0a9e('0x1c')],_0x225616=_0x16033c[_0x0a9e('0x1d')],_0x5a0a06=_0x16033c[_0x0a9e('0x1d')]+_0x16033c[_0x0a9e('0x1e')],_0x459eb1;if(_0x5a0a06>=_0x48f32d){_0x5a0a06=_0x48f32d;_0x459eb1=0xc8;}else{_0x459eb1=0xce;}_0x519dfd[_0x0a9e('0x19')](_0x459eb1);return _0x519dfd[_0x0a9e('0x1f')](_0x0a9e('0x20'),_0x225616+'-'+_0x5a0a06+'/'+_0x48f32d)[_0x0a9e('0x1b')](_0x12066b);}return null;};}function patchUpdates(_0x112016){return function(_0x1c696a){try{jsonpatch[_0x0a9e('0x21')](_0x1c696a,_0x112016,!![]);}catch(_0x4bb1e3){return BPromise[_0x0a9e('0x22')](_0x4bb1e3);}return _0x1c696a[_0x0a9e('0x23')]();};}function saveUpdates(_0x53682f,_0x20f109){return function(_0x5a09ef){if(_0x5a09ef){return _0x5a09ef['update'](_0x53682f)[_0x0a9e('0x24')](function(_0x432e56){return _0x432e56;});}return null;};}function removeEntity(_0x38e7c4,_0x30bae6){return function(_0x4abc77){if(_0x4abc77){return _0x4abc77[_0x0a9e('0x25')]()[_0x0a9e('0x24')](function(){_0x38e7c4[_0x0a9e('0x19')](0xcc)[_0x0a9e('0x1a')]();});}};}function handleEntityNotFound(_0x370d86,_0x42ac8f){return function(_0x16b1ca){if(!_0x16b1ca){_0x370d86['sendStatus'](0x194);}return _0x16b1ca;};}function handleError(_0x59181e,_0x197ec0){_0x197ec0=_0x197ec0||0x1f4;return function(_0x3a8e58){logger[_0x0a9e('0x26')](_0x3a8e58[_0x0a9e('0x27')]);if(_0x3a8e58['name']){delete _0x3a8e58[_0x0a9e('0x28')];}_0x59181e['status'](_0x197ec0)[_0x0a9e('0x29')](_0x3a8e58);};}exports['index']=function(_0x1dc186,_0x34dc65){var _0x25fba9={},_0x14433c={},_0x140511={'count':0x0,'rows':[]};var _0x1538a4=db[_0x0a9e('0x2a')][_0x0a9e('0x2b')];_0x14433c['model']=_[_0x0a9e('0x2c')](_0x1538a4);var _0x468813={'dateStart':_0x1dc186[_0x0a9e('0x2d')][_0x0a9e('0x2e')],'dateEnd':_0x1dc186['query'][_0x0a9e('0x2f')]};delete _0x1dc186[_0x0a9e('0x2d')][_0x0a9e('0x2e')];delete _0x1dc186[_0x0a9e('0x2d')][_0x0a9e('0x2f')];_0x14433c[_0x0a9e('0x2d')]=_[_0x0a9e('0x2c')](_0x1dc186[_0x0a9e('0x2d')]);_0x14433c[_0x0a9e('0x30')]=_['intersection'](_0x14433c[_0x0a9e('0x31')],_0x14433c['query']);_0x25fba9[_0x0a9e('0x32')]=_[_0x0a9e('0x33')](_0x14433c[_0x0a9e('0x31')],qs[_0x0a9e('0x34')](_0x1dc186[_0x0a9e('0x2d')]['fields']));_0x25fba9[_0x0a9e('0x32')]=_0x25fba9[_0x0a9e('0x32')][_0x0a9e('0x35')]?_0x25fba9[_0x0a9e('0x32')]:_0x14433c[_0x0a9e('0x31')];if(!_0x1dc186[_0x0a9e('0x2d')][_0x0a9e('0x36')](_0x0a9e('0x37'))){_0x25fba9['limit']=qs[_0x0a9e('0x1e')](_0x1dc186['query'][_0x0a9e('0x1e')]);_0x25fba9[_0x0a9e('0x1d')]=qs[_0x0a9e('0x1d')](_0x1dc186[_0x0a9e('0x2d')]['offset']);}_0x25fba9[_0x0a9e('0x38')]=qs[_0x0a9e('0x39')](_0x1dc186[_0x0a9e('0x2d')][_0x0a9e('0x39')]);_0x25fba9['where']=qs['filters'](_[_0x0a9e('0x3a')](_0x1dc186['query'],_0x14433c[_0x0a9e('0x30')]));if(_0x468813[_0x0a9e('0x2e')]){if(_0x468813[_0x0a9e('0x2f')]){_0x468813[_0x0a9e('0x2f')]=moment(_0x468813['dateEnd'])[_0x0a9e('0x3b')](0x1,_0x0a9e('0x3c'));}else{_0x468813[_0x0a9e('0x2f')]=moment(_0x468813['dateStart'])[_0x0a9e('0x3b')](0x1,_0x0a9e('0x3c'));}_[_0x0a9e('0x3d')](_0x25fba9['where'],{'createdAt':{'$gte':_0x468813['dateStart'],'$lte':_0x468813[_0x0a9e('0x2f')]}});}if(_0x1dc186[_0x0a9e('0x2d')]['filter']){_0x25fba9[_0x0a9e('0x3e')]=_[_0x0a9e('0x3d')](_0x25fba9[_0x0a9e('0x3e')],{'$or':_[_0x0a9e('0x3f')](_0x1538a4,function(_0x4b38d9){if(_0x4b38d9['type'][_0x0a9e('0x40')]!==_0x0a9e('0x41')){var _0x53f3ee={};_0x53f3ee[_0x4b38d9[_0x0a9e('0x42')]]={'$like':'%'+_0x1dc186[_0x0a9e('0x2d')][_0x0a9e('0x43')]+'%'};return _0x53f3ee;}})});}_0x25fba9=_['merge']({},_0x25fba9,_0x1dc186[_0x0a9e('0x44')]);var _0x2cfea9={'where':_0x25fba9[_0x0a9e('0x3e')]};_0x2cfea9[_0x0a9e('0x45')]=[];if(_0x1dc186[_0x0a9e('0x2d')][_0x0a9e('0x46')]){_0x2cfea9[_0x0a9e('0x45')][_0x0a9e('0x47')]({'model':db[_0x0a9e('0x48')],'as':_0x0a9e('0x49'),'attributes':['id'],'where':{'id':_0x1dc186[_0x0a9e('0x2d')][_0x0a9e('0x46')]},'required':!![]});_0x2cfea9[_0x0a9e('0x4a')]=!![];}if(_0x1dc186[_0x0a9e('0x2d')][_0x0a9e('0x4b')]){_0x2cfea9['include']['push']({'model':db[_0x0a9e('0x4c')],'as':_0x0a9e('0x4d'),'attributes':['id',_0x0a9e('0x4e'),_0x0a9e('0x4f'),_0x0a9e('0x4b')],'where':{'direction':'in','read':_0x1dc186[_0x0a9e('0x2d')][_0x0a9e('0x4b')]||![]},'required':!![]});_0x2cfea9[_0x0a9e('0x4a')]=!![];}return db[_0x0a9e('0x2a')][_0x0a9e('0x1c')](_0x2cfea9)[_0x0a9e('0x24')](function(_0x35ed4a){_0x140511['count']=_0x35ed4a;if(_0x1dc186[_0x0a9e('0x2d')][_0x0a9e('0x50')]){_0x25fba9[_0x0a9e('0x45')]=[{'model':db[_0x0a9e('0x51')],'as':_0x0a9e('0x52'),'required':![],'attributes':['id',_0x0a9e('0x28'),_0x0a9e('0x53')]},{'model':db[_0x0a9e('0x54')],'as':'Contact','required':![]},{'model':db[_0x0a9e('0x51')],'as':'Owner','attributes':[_0x0a9e('0x28'),_0x0a9e('0x53'),_0x0a9e('0x55')],'required':![]},{'model':db['FaxAccount'],'as':_0x0a9e('0x56'),'attributes':[_0x0a9e('0x28'),_0x0a9e('0x40')],'required':![]},{'model':db[_0x0a9e('0x4c')],'as':_0x0a9e('0x4d'),'attributes':['id',_0x0a9e('0x4e'),_0x0a9e('0x4f'),'read'],'where':{'direction':'in','read':_0x1dc186[_0x0a9e('0x2d')][_0x0a9e('0x4b')]||![]},'required':_0x1dc186[_0x0a9e('0x2d')][_0x0a9e('0x4b')]||![]},{'model':db[_0x0a9e('0x48')],'as':_0x0a9e('0x49'),'attributes':['id',_0x0a9e('0x28'),_0x0a9e('0x57')],'required':_0x1dc186[_0x0a9e('0x2d')]['tag']?!![]:![]},{'model':db[_0x0a9e('0x48')],'as':_0x0a9e('0x58'),'attributes':['id','name','color'],'through':_0x1dc186['query'][_0x0a9e('0x46')]?{'attributes':[],'where':{'TagId':_0x1dc186[_0x0a9e('0x2d')][_0x0a9e('0x46')]||undefined}}:{},'required':_0x1dc186[_0x0a9e('0x2d')][_0x0a9e('0x46')]?!![]:![]}];}return db[_0x0a9e('0x2a')][_0x0a9e('0x59')](_0x25fba9);})[_0x0a9e('0x24')](function(_0x5d38ae){_0x140511['rows']=_0x5d38ae;return _0x140511;})['then'](respondWithFilteredResult(_0x34dc65,_0x25fba9))[_0x0a9e('0x5a')](handleError(_0x34dc65,null));};exports[_0x0a9e('0x5b')]=function(_0x14d602,_0x5bb3ed){var _0x2b69d9={'raw':![],'where':{'id':_0x14d602['params']['id']}},_0x161aa7={};_0x161aa7['model']=_[_0x0a9e('0x2c')](db['FaxInteraction'][_0x0a9e('0x2b')]);_0x161aa7['query']=_[_0x0a9e('0x2c')](_0x14d602[_0x0a9e('0x2d')]);_0x161aa7[_0x0a9e('0x30')]=_['intersection'](_0x161aa7[_0x0a9e('0x31')],_0x161aa7[_0x0a9e('0x2d')]);_0x2b69d9['attributes']=_['intersection'](_0x161aa7[_0x0a9e('0x31')],qs[_0x0a9e('0x34')](_0x14d602['query'][_0x0a9e('0x34')]));_0x2b69d9['attributes']=_0x2b69d9[_0x0a9e('0x32')]['length']?_0x2b69d9[_0x0a9e('0x32')]:_0x161aa7['model'];if(_0x14d602['query']['includeAll']){_0x2b69d9[_0x0a9e('0x45')]=[{'all':!![]}];}_0x2b69d9=_['merge']({},_0x2b69d9,_0x14d602[_0x0a9e('0x44')]);return db[_0x0a9e('0x2a')][_0x0a9e('0x5c')](_0x2b69d9)[_0x0a9e('0x24')](handleEntityNotFound(_0x5bb3ed,null))[_0x0a9e('0x24')](respondWithResult(_0x5bb3ed,null))[_0x0a9e('0x5a')](handleError(_0x5bb3ed,null));};exports[_0x0a9e('0x5d')]=function(_0x28d814,_0x4e67ab){return db[_0x0a9e('0x2a')][_0x0a9e('0x5d')](_0x28d814[_0x0a9e('0x5e')],{})[_0x0a9e('0x24')](respondWithResult(_0x4e67ab,0xc9))[_0x0a9e('0x5a')](handleError(_0x4e67ab,null));};exports[_0x0a9e('0x5f')]=function(_0x5d86e9,_0x956fbe){if(_0x5d86e9[_0x0a9e('0x5e')]['id']){delete _0x5d86e9['body']['id'];}return db[_0x0a9e('0x2a')]['find']({'where':{'id':_0x5d86e9[_0x0a9e('0x60')]['id']}})['then'](handleEntityNotFound(_0x956fbe,null))['then'](saveUpdates(_0x5d86e9['body'],null))[_0x0a9e('0x24')](respondWithResult(_0x956fbe,null))['catch'](handleError(_0x956fbe,null));};exports[_0x0a9e('0x25')]=function(_0x1fc70e,_0x261adb){return db[_0x0a9e('0x2a')][_0x0a9e('0x5c')]({'where':{'id':_0x1fc70e[_0x0a9e('0x60')]['id']}})['then'](handleEntityNotFound(_0x261adb,null))[_0x0a9e('0x24')](removeEntity(_0x261adb,null))['catch'](handleError(_0x261adb,null));};exports[_0x0a9e('0x61')]=function(_0x1f07cb,_0x51aaf7){return db['FaxInteraction'][_0x0a9e('0x61')]()[_0x0a9e('0x24')](respondWithResult(_0x51aaf7,null))[_0x0a9e('0x5a')](handleError(_0x51aaf7,null));};exports[_0x0a9e('0x62')]=function(_0x497d91,_0x1d0dc8,_0xe05a5a){return db['FaxMessage'][_0x0a9e('0x5c')]({'where':{'id':_0x497d91[_0x0a9e('0x60')]['id']}})[_0x0a9e('0x24')](handleEntityNotFound(_0x1d0dc8,null))[_0x0a9e('0x24')](function(_0x401837){if(_0x401837){return _0x401837['addMessage'](_0x497d91[_0x0a9e('0x5e')][_0x0a9e('0x63')],_[_0x0a9e('0x64')](_0x497d91['body'],[_0x0a9e('0x63'),'id'])||{});}})['then'](respondWithResult(_0x1d0dc8,null))['catch'](handleError(_0x1d0dc8,null));};exports[_0x0a9e('0x65')]=function(_0x4556c5,_0x9375fb,_0x19c995){var _0x186f39={'raw':![],'where':{}};var _0xc8c264={};var _0x387489={'count':0x0,'rows':[]};return db[_0x0a9e('0x2a')][_0x0a9e('0x66')]({'where':{'id':_0x4556c5[_0x0a9e('0x60')]['id']}})[_0x0a9e('0x24')](handleEntityNotFound(_0x9375fb,null))[_0x0a9e('0x24')](function(_0x2bbb86){if(_0x2bbb86){_0xc8c264[_0x0a9e('0x31')]=_[_0x0a9e('0x2c')](db[_0x0a9e('0x4c')][_0x0a9e('0x2b')]);_0xc8c264[_0x0a9e('0x2d')]=_['keys'](_0x4556c5[_0x0a9e('0x2d')]);_0xc8c264[_0x0a9e('0x30')]=_[_0x0a9e('0x33')](_0xc8c264['model'],_0xc8c264[_0x0a9e('0x2d')]);_0x186f39[_0x0a9e('0x32')]=_['intersection'](_0xc8c264[_0x0a9e('0x31')],qs[_0x0a9e('0x34')](_0x4556c5[_0x0a9e('0x2d')][_0x0a9e('0x34')]));_0x186f39[_0x0a9e('0x32')]=_0x186f39['attributes']['length']?_0x186f39['attributes']:_0xc8c264[_0x0a9e('0x31')];if(!_0x4556c5[_0x0a9e('0x2d')][_0x0a9e('0x36')](_0x0a9e('0x37'))){_0x186f39[_0x0a9e('0x1e')]=qs[_0x0a9e('0x1e')](_0x4556c5[_0x0a9e('0x2d')][_0x0a9e('0x1e')]);_0x186f39['offset']=qs[_0x0a9e('0x1d')](_0x4556c5[_0x0a9e('0x2d')][_0x0a9e('0x1d')]);}_0x186f39['order']=qs[_0x0a9e('0x39')](_0x4556c5['query'][_0x0a9e('0x39')]);_0x186f39[_0x0a9e('0x3e')]=qs['filters'](_[_0x0a9e('0x3a')](_0x4556c5[_0x0a9e('0x2d')],_0xc8c264[_0x0a9e('0x30')]));_0x186f39[_0x0a9e('0x3e')]['FaxInteractionId']=_0x2bbb86['id'];if(_0x4556c5[_0x0a9e('0x2d')][_0x0a9e('0x43')]){_0x186f39[_0x0a9e('0x3e')]=_[_0x0a9e('0x3d')](_0x186f39['where'],{'$or':_[_0x0a9e('0x3f')](_0x186f39[_0x0a9e('0x32')],function(_0x2d5506){var _0x361b21={};_0x361b21[_0x2d5506]={'$like':'%'+_0x4556c5['query'][_0x0a9e('0x43')]+'%'};return _0x361b21;})});}if(_0x4556c5[_0x0a9e('0x2d')][_0x0a9e('0x67')]){var _0xf410e5=_0x4556c5[_0x0a9e('0x2d')][_0x0a9e('0x67')][_0x0a9e('0x68')](',');var _0x3df0e3={};_0x3df0e3[_0xf410e5[0x0]]={'$gte':moment(_0xf410e5[0x1])[_0x0a9e('0x69')](_0x0a9e('0x6a'))};_0x186f39[_0x0a9e('0x3e')]=_[_0x0a9e('0x3d')](_0x186f39[_0x0a9e('0x3e')],_0x3df0e3);}_0x186f39=_[_0x0a9e('0x3d')]({},_0x186f39,_0x4556c5['options']);return db[_0x0a9e('0x4c')][_0x0a9e('0x1c')]({'where':_0x186f39[_0x0a9e('0x3e')]})['then'](function(_0x3736e0){_0x387489[_0x0a9e('0x1c')]=_0x3736e0;if(_0x4556c5[_0x0a9e('0x2d')][_0x0a9e('0x50')]){_0x186f39['include']=[{'all':!![]}];}return db['FaxMessage'][_0x0a9e('0x59')](_0x186f39);})[_0x0a9e('0x24')](function(_0x4c54fa){_0x387489[_0x0a9e('0x6b')]=_0x4c54fa;return _0x387489;});}})['then'](respondWithFilteredResult(_0x9375fb,_0x186f39))[_0x0a9e('0x5a')](handleError(_0x9375fb,null));};exports[_0x0a9e('0x6c')]=function(_0x5637a1,_0x28a942,_0x41cf12){return db[_0x0a9e('0x2a')][_0x0a9e('0x5c')]({'where':{'id':_0x5637a1[_0x0a9e('0x60')]['id']}})[_0x0a9e('0x24')](handleEntityNotFound(_0x28a942,null))[_0x0a9e('0x24')](function(_0x482ca2){if(_0x482ca2){return _0x482ca2[_0x0a9e('0x6d')](_0x5637a1[_0x0a9e('0x5e')][_0x0a9e('0x63')],_[_0x0a9e('0x64')](_0x5637a1['body'],[_0x0a9e('0x63'),'id'])||{})[_0x0a9e('0x6e')](function(){return db['Tag'][_0x0a9e('0x59')]({'attributes':['id','name',_0x0a9e('0x57')],'where':{'id':_0x5637a1[_0x0a9e('0x5e')][_0x0a9e('0x63')]}});})[_0x0a9e('0x24')](function(_0x5af453){socket['emit'](_0x0a9e('0x6f'),{'id':Number(_0x5637a1[_0x0a9e('0x60')]['id']),'tags':_0x5af453||[]});return{'id':Number(_0x5637a1[_0x0a9e('0x60')]['id']),'tags':_0x5af453||[]};});}})['then'](respondWithResult(_0x28a942,null))[_0x0a9e('0x5a')](handleError(_0x28a942,null));};exports[_0x0a9e('0x70')]=function(_0x524e38,_0x4e46b2,_0xf0a802){var _0x56acca;return db['FaxInteraction']['find']({'where':{'id':_0x524e38[_0x0a9e('0x60')]['id']}})[_0x0a9e('0x24')](handleEntityNotFound(_0x4e46b2,null))[_0x0a9e('0x24')](function(_0x3bfadf){if(_0x3bfadf){return _0x3bfadf[_0x0a9e('0x70')](_0x524e38[_0x0a9e('0x2d')]['ids']);}})[_0x0a9e('0x24')](respondWithStatusCode(_0x4e46b2,null))['catch'](handleError(_0x4e46b2,null));};exports[_0x0a9e('0x71')]=function(_0x2aabab,_0x18ad56){var _0x4566b0=moment()['unix']()[_0x0a9e('0x72')]();var _0x32f761=path[_0x0a9e('0x73')](config['root'],_0x0a9e('0x74'),_0x0a9e('0x75'),_0x0a9e('0x76'));var _0x22063c=path[_0x0a9e('0x73')](config[_0x0a9e('0x77')],_0x0a9e('0x74'),_0x0a9e('0x75'),'tmp');var _0x2645d6=path[_0x0a9e('0x73')](_0x22063c,_0x4566b0);var _0x589ff3=util[_0x0a9e('0x69')](_0x0a9e('0x78'),_0x4566b0);var _0x3a1974=path['join'](_0x22063c,_0x589ff3);var _0x96672f=![];return db['FaxInteraction'][_0x0a9e('0x5c')]({'where':{'id':_0x2aabab[_0x0a9e('0x60')]['id']}})[_0x0a9e('0x24')](handleEntityNotFound(_0x18ad56,null))[_0x0a9e('0x24')](function(_0x842d6f){if(_0x842d6f){return _0x842d6f[_0x0a9e('0x65')]({'attributes':['id',_0x0a9e('0x5e'),_0x0a9e('0x4f')],'include':[{'model':db['Attachment'],'as':_0x0a9e('0x79')}]});}return[];})[_0x0a9e('0x24')](function(_0x17f692){_0x96672f=_0x17f692[_0x0a9e('0x35')];if(_0x17f692[_0x0a9e('0x35')]){fs[_0x0a9e('0x7a')](_0x2645d6);for(var _0x6803d6=0x0;_0x6803d6<_0x17f692[_0x0a9e('0x35')];_0x6803d6++){var _0x1808ba=_0x17f692[_0x6803d6];var _0x31af8c=_0x1808ba[_0x0a9e('0x79')];if(_0x31af8c){var _0x3754e2=path[_0x0a9e('0x73')](_0x32f761,_0x31af8c['basename']);if(fs[_0x0a9e('0x7b')](_0x3754e2)){fs[_0x0a9e('0x7c')](_0x3754e2)[_0x0a9e('0x7d')](fs[_0x0a9e('0x7e')](path[_0x0a9e('0x73')](_0x2645d6,_0x31af8c['basename'])));}}}}})[_0x0a9e('0x24')](function(){if(_0x96672f){return new BPromise(function(_0x1756c7,_0x5ce99d){zipdir(_0x2645d6,{'saveTo':_0x3a1974},function(_0x23b447,_0x5e725e){if(_0x23b447)return _0x5ce99d(_0x23b447);return _0x1756c7(_0x5e725e);});});}})[_0x0a9e('0x24')](function(){if(_0x96672f){return new BPromise(function(_0x27041d,_0x1d93b1){rimraf(_0x2645d6,function(_0xf8c6c4){if(_0xf8c6c4)_0x1d93b1(_0xf8c6c4);return _0x27041d();});});}})['then'](function(){if(_0x96672f){return _0x18ad56[_0x0a9e('0x71')](_0x3a1974,_0x589ff3,function(_0x4cf72d){if(_0x4cf72d){console[_0x0a9e('0x7f')](_0x0a9e('0x80'),_0x4cf72d);}else{fs['unlinkSync'](_0x3a1974);}});}else{return _0x18ad56[_0x0a9e('0x18')](0xc8);}})[_0x0a9e('0x5a')](handleError(_0x18ad56,null));};
\ No newline at end of file