Built motion from commit 0900f080.|2.5.45
[motion2.git] / server / api / faxMessage / faxMessage.controller.js
index 377e24e..3577b0d 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x160f=['../../config/license/util','../../mysqldb','redis','defaults','localhost','./faxMessage.socket','register','jayson/promise','client','http','request','info','FaxMessage,\x20%s,\x20%s','request\x20sent','debug','FaxMessage,\x20%s,\x20%s,\x20%s','stringify','error','code','message','catch','sendStatus','status','end','offset','set','json','save','update','then','stack','name','send','index','map','FaxMessage','rawAttributes','fieldName','type','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','limit','order','sort','where','pick','filter','merge','options','count','include','findAll','show','params','includeAll','find','body','destroy','accept','fax','readAt','format','YYYY-MM-DD\x20HH:mm:ss','user','agent','UserId','CmContact','Contact','get','FaxInteraction','FaxInteractionId','isNil','read1stAt','[FAXMESSAGE:ACCEPT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','role','interaction','null','acceptMessage','manual','interface','SIP/%s','channel','EventManager','fax-interactions','reject','RejectMessage','event','rejectmessage','create','AttachmentId','SendFax','FaxAccountId','/var/opt/motion2/server/files/attachments/%s','basename','download','root','files','Attachment','join','html-pdf','eml-format','rimraf','zip-dir','request-promise','moment','bluebird','mustache','util','path','to-csv','ejs','crypto','querystring','papaparse','ioredis','../../components/auth/service','../../config/license/hardware','../../config/logger','api','../../config/environment'];(function(_0x5c84a6,_0x321f95){var _0xb8c5f0=function(_0x106d58){while(--_0x106d58){_0x5c84a6['push'](_0x5c84a6['shift']());}};_0xb8c5f0(++_0x321f95);}(_0x160f,0x1ef));var _0xf160=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0x160f[_0x3dd15e];return _0x231fd0;};'use strict';var pdf=require(_0xf160('0x0'));var emlformat=require(_0xf160('0x1'));var rimraf=require(_0xf160('0x2'));var zipdir=require(_0xf160('0x3'));var jsonpatch=require('fast-json-patch');var rp=require(_0xf160('0x4'));var moment=require(_0xf160('0x5'));var BPromise=require(_0xf160('0x6'));var Mustache=require(_0xf160('0x7'));var util=require(_0xf160('0x8'));var path=require(_0xf160('0x9'));var sox=require('sox');var csv=require(_0xf160('0xa'));var ejs=require(_0xf160('0xb'));var fs=require('fs');var _=require('lodash');var squel=require('squel');var crypto=require(_0xf160('0xc'));var jsforce=require('jsforce');var deskjs=require('desk.js');var toCsv=require('to-csv');var querystring=require(_0xf160('0xd'));var Papa=require(_0xf160('0xe'));var Redis=require(_0xf160('0xf'));var authService=require(_0xf160('0x10'));var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xf160('0x11'));var logger=require(_0xf160('0x12'))(_0xf160('0x13'));var utils=require('../../config/utils');var config=require(_0xf160('0x14'));var licenseUtil=require(_0xf160('0x15'));var db=require(_0xf160('0x16'))['db'];config[_0xf160('0x17')]=_[_0xf160('0x18')](config['redis'],{'host':_0xf160('0x19'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xf160('0x17')]));require(_0xf160('0x1a'))[_0xf160('0x1b')](socket);var jayson=require(_0xf160('0x1c'));var client=jayson[_0xf160('0x1d')][_0xf160('0x1e')]({'port':0x232c});var client9002=jayson[_0xf160('0x1d')][_0xf160('0x1e')]({'port':0x232a});function respondWithRpcPromise(_0x1396ba,_0x59ac02,_0x477e4d,_0x400bda){return new BPromise(function(_0x8699a0,_0x2e0d71){var _0x51824b=_0x400bda||client;return _0x51824b[_0xf160('0x1f')](_0x1396ba,_0x477e4d)['then'](function(_0x5388c7){logger[_0xf160('0x20')](_0xf160('0x21'),_0x59ac02,_0xf160('0x22'));logger[_0xf160('0x23')](_0xf160('0x24'),_0x59ac02,_0xf160('0x22'),JSON[_0xf160('0x25')](_0x5388c7));if(_0x5388c7[_0xf160('0x26')]){if(_0x5388c7['error'][_0xf160('0x27')]===0x1f4){logger[_0xf160('0x26')](_0xf160('0x21'),_0x59ac02,_0x5388c7['error'][_0xf160('0x28')]);return _0x2e0d71(_0x5388c7[_0xf160('0x26')][_0xf160('0x28')]);}logger[_0xf160('0x26')](_0xf160('0x21'),_0x59ac02,_0x5388c7[_0xf160('0x26')][_0xf160('0x28')]);return _0x8699a0(_0x5388c7['error'][_0xf160('0x28')]);}else{logger[_0xf160('0x20')](_0xf160('0x21'),_0x59ac02,_0xf160('0x22'));_0x8699a0(_0x5388c7['result'][_0xf160('0x28')]);}})[_0xf160('0x29')](function(_0x4a8003){logger['error'](_0xf160('0x21'),_0x59ac02,_0x4a8003);_0x2e0d71(_0x4a8003);});});}function respondWithStatusCode(_0x1cc04c,_0x39c0e3){_0x39c0e3=_0x39c0e3||0xcc;return function(_0x4c0c51){if(_0x4c0c51){return _0x1cc04c[_0xf160('0x2a')](_0x39c0e3);}return _0x1cc04c[_0xf160('0x2b')](_0x39c0e3)[_0xf160('0x2c')]();};}function respondWithResult(_0x2e2b00,_0x135e0f){_0x135e0f=_0x135e0f||0xc8;return function(_0x193e1e){if(_0x193e1e){return _0x2e2b00['status'](_0x135e0f)['json'](_0x193e1e);}};}function respondWithFilteredResult(_0x48145e,_0x26e7b9){return function(_0x16a5fa){if(_0x16a5fa){var _0xcaab39=_0x16a5fa['count'],_0x26e06b=_0x26e7b9[_0xf160('0x2d')],_0x399cce=_0x26e7b9['offset']+_0x26e7b9['limit'],_0x563103;if(_0x399cce>=_0xcaab39){_0x399cce=_0xcaab39;_0x563103=0xc8;}else{_0x563103=0xce;}_0x48145e[_0xf160('0x2b')](_0x563103);return _0x48145e[_0xf160('0x2e')]('Content-Range',_0x26e06b+'-'+_0x399cce+'/'+_0xcaab39)[_0xf160('0x2f')](_0x16a5fa);}return null;};}function patchUpdates(_0x270933){return function(_0x4ab048){try{jsonpatch['apply'](_0x4ab048,_0x270933,!![]);}catch(_0x4b3ef4){return BPromise['reject'](_0x4b3ef4);}return _0x4ab048[_0xf160('0x30')]();};}function saveUpdates(_0x2bb5c4,_0x2ef512){return function(_0x1ccaf6){if(_0x1ccaf6){return _0x1ccaf6[_0xf160('0x31')](_0x2bb5c4)[_0xf160('0x32')](function(_0x4be359){return _0x4be359;});}return null;};}function removeEntity(_0x5495b5,_0x52178d){return function(_0x222b83){if(_0x222b83){return _0x222b83['destroy']()['then'](function(){_0x5495b5[_0xf160('0x2b')](0xcc)[_0xf160('0x2c')]();});}};}function handleEntityNotFound(_0x4dbe9d,_0x1930b8){return function(_0x1653ab){if(!_0x1653ab){_0x4dbe9d[_0xf160('0x2a')](0x194);}return _0x1653ab;};}function handleError(_0x2a7a5a,_0x268dcb){_0x268dcb=_0x268dcb||0x1f4;return function(_0x590f2a){logger[_0xf160('0x26')](_0x590f2a[_0xf160('0x33')]);if(_0x590f2a[_0xf160('0x34')]){delete _0x590f2a['name'];}_0x2a7a5a[_0xf160('0x2b')](_0x268dcb)[_0xf160('0x35')](_0x590f2a);};}exports[_0xf160('0x36')]=function(_0x22d152,_0x27a9e9){var _0x32ddc3={},_0x53795c={},_0x5ba20b={'count':0x0,'rows':[]};var _0x36d21b=_[_0xf160('0x37')](db[_0xf160('0x38')][_0xf160('0x39')],function(_0x75fb8c){return{'name':_0x75fb8c[_0xf160('0x3a')],'type':_0x75fb8c[_0xf160('0x3b')][_0xf160('0x3c')]};});_0x53795c[_0xf160('0x3d')]=_[_0xf160('0x37')](_0x36d21b,_0xf160('0x34'));_0x53795c[_0xf160('0x3e')]=_[_0xf160('0x3f')](_0x22d152[_0xf160('0x3e')]);_0x53795c[_0xf160('0x40')]=_[_0xf160('0x41')](_0x53795c[_0xf160('0x3d')],_0x53795c[_0xf160('0x3e')]);_0x32ddc3[_0xf160('0x42')]=_[_0xf160('0x41')](_0x53795c[_0xf160('0x3d')],qs[_0xf160('0x43')](_0x22d152[_0xf160('0x3e')][_0xf160('0x43')]));_0x32ddc3['attributes']=_0x32ddc3[_0xf160('0x42')][_0xf160('0x44')]?_0x32ddc3[_0xf160('0x42')]:_0x53795c[_0xf160('0x3d')];if(!_0x22d152[_0xf160('0x3e')][_0xf160('0x45')](_0xf160('0x46'))){_0x32ddc3['limit']=qs[_0xf160('0x47')](_0x22d152['query'][_0xf160('0x47')]);_0x32ddc3[_0xf160('0x2d')]=qs['offset'](_0x22d152[_0xf160('0x3e')][_0xf160('0x2d')]);}_0x32ddc3[_0xf160('0x48')]=qs[_0xf160('0x49')](_0x22d152[_0xf160('0x3e')][_0xf160('0x49')]);_0x32ddc3[_0xf160('0x4a')]=qs['filters'](_[_0xf160('0x4b')](_0x22d152[_0xf160('0x3e')],_0x53795c[_0xf160('0x40')]),_0x36d21b);if(_0x22d152[_0xf160('0x3e')][_0xf160('0x4c')]){_0x32ddc3[_0xf160('0x4a')]=_[_0xf160('0x4d')](_0x32ddc3[_0xf160('0x4a')],{'$or':_[_0xf160('0x37')](_0x36d21b,function(_0x1cb75e){if(_0x1cb75e[_0xf160('0x3b')]!=='VIRTUAL'){var _0x5b8f5f={};_0x5b8f5f[_0x1cb75e[_0xf160('0x34')]]={'$like':'%'+_0x22d152[_0xf160('0x3e')][_0xf160('0x4c')]+'%'};return _0x5b8f5f;}})});}_0x32ddc3=_[_0xf160('0x4d')]({},_0x32ddc3,_0x22d152[_0xf160('0x4e')]);var _0x152cf9={'where':_0x32ddc3['where']};return db[_0xf160('0x38')]['count'](_0x152cf9)['then'](function(_0x44fd52){_0x5ba20b[_0xf160('0x4f')]=_0x44fd52;if(_0x22d152['query']['includeAll']){_0x32ddc3[_0xf160('0x50')]=[{'all':!![]}];}return db[_0xf160('0x38')][_0xf160('0x51')](_0x32ddc3);})[_0xf160('0x32')](function(_0x5c73b9){_0x5ba20b['rows']=_0x5c73b9;return _0x5ba20b;})['then'](respondWithFilteredResult(_0x27a9e9,_0x32ddc3))['catch'](handleError(_0x27a9e9,null));};exports[_0xf160('0x52')]=function(_0x57f5a9,_0x418b8a){var _0x1a440b={'raw':!![],'where':{'id':_0x57f5a9[_0xf160('0x53')]['id']}},_0x1f7e15={};_0x1f7e15['model']=_[_0xf160('0x3f')](db[_0xf160('0x38')][_0xf160('0x39')]);_0x1f7e15['query']=_[_0xf160('0x3f')](_0x57f5a9[_0xf160('0x3e')]);_0x1f7e15[_0xf160('0x40')]=_['intersection'](_0x1f7e15[_0xf160('0x3d')],_0x1f7e15[_0xf160('0x3e')]);_0x1a440b[_0xf160('0x42')]=_[_0xf160('0x41')](_0x1f7e15[_0xf160('0x3d')],qs['fields'](_0x57f5a9['query'][_0xf160('0x43')]));_0x1a440b['attributes']=_0x1a440b[_0xf160('0x42')][_0xf160('0x44')]?_0x1a440b['attributes']:_0x1f7e15['model'];if(_0x57f5a9[_0xf160('0x3e')][_0xf160('0x54')]){_0x1a440b['include']=[{'all':!![]}];}_0x1a440b=_[_0xf160('0x4d')]({},_0x1a440b,_0x57f5a9[_0xf160('0x4e')]);return db[_0xf160('0x38')][_0xf160('0x55')](_0x1a440b)['then'](handleEntityNotFound(_0x418b8a,null))[_0xf160('0x32')](respondWithResult(_0x418b8a,null))['catch'](handleError(_0x418b8a,null));};exports[_0xf160('0x31')]=function(_0x1b3ec0,_0x780f95){if(_0x1b3ec0[_0xf160('0x56')]['id']){delete _0x1b3ec0[_0xf160('0x56')]['id'];}return db['FaxMessage'][_0xf160('0x55')]({'where':{'id':_0x1b3ec0['params']['id']}})[_0xf160('0x32')](handleEntityNotFound(_0x780f95,null))[_0xf160('0x32')](saveUpdates(_0x1b3ec0[_0xf160('0x56')],null))[_0xf160('0x32')](respondWithResult(_0x780f95,null))[_0xf160('0x29')](handleError(_0x780f95,null));};exports[_0xf160('0x57')]=function(_0x11855b,_0x12c22){return db[_0xf160('0x38')][_0xf160('0x55')]({'where':{'id':_0x11855b['params']['id']}})['then'](handleEntityNotFound(_0x12c22,null))[_0xf160('0x32')](removeEntity(_0x12c22,null))[_0xf160('0x29')](handleError(_0x12c22,null));};exports['describe']=function(_0x12083d,_0x1ca751){return db[_0xf160('0x38')]['describe']()['then'](respondWithResult(_0x1ca751,null))[_0xf160('0x29')](handleError(_0x1ca751,null));};var interaction_log=require(_0xf160('0x12'))('fax-interactions');exports[_0xf160('0x58')]=function(_0x1de36a,_0x4b3224,_0x2cbe17){var _0x39eb3b={'agent':{},'channel':_0xf160('0x59')};if(_0x1de36a[_0xf160('0x56')]['id']){delete _0x1de36a[_0xf160('0x56')]['id'];}_0x1de36a[_0xf160('0x56')]['read']=!![];_0x1de36a[_0xf160('0x56')][_0xf160('0x5a')]=moment()[_0xf160('0x5b')](_0xf160('0x5c'));_0x1de36a[_0xf160('0x56')]['UserId']=_0x1de36a[_0xf160('0x56')]['UserId']||_0x1de36a[_0xf160('0x5d')]['id'];_0x39eb3b[_0xf160('0x5e')]['id']=_0x1de36a[_0xf160('0x56')][_0xf160('0x5f')];return db[_0xf160('0x38')][_0xf160('0x55')]({'where':{'id':_0x1de36a['params']['id'],'UserId':null},'include':[{'model':db[_0xf160('0x60')],'as':_0xf160('0x61')}]})[_0xf160('0x32')](handleEntityNotFound(_0x4b3224,null))[_0xf160('0x32')](saveUpdates(_0x1de36a[_0xf160('0x56')],null))['then'](function(_0x5aa022){if(_0x5aa022){_0x39eb3b[_0xf160('0x28')]=_0x5aa022[_0xf160('0x62')]({'plain':!![]});return db[_0xf160('0x63')][_0xf160('0x55')]({'where':{'id':_0x5aa022[_0xf160('0x64')]}});}return null;})[_0xf160('0x32')](handleEntityNotFound(_0x4b3224,null))['then'](function(_0x25f79e){if(_0x25f79e){return _0x25f79e[_0xf160('0x31')]({'UserId':_0x1de36a[_0xf160('0x56')][_0xf160('0x5f')],'read1stAt':_[_0xf160('0x65')](_0x25f79e[_0xf160('0x66')])?moment()[_0xf160('0x5b')](_0xf160('0x5c')):undefined});}return null;})['then'](function(_0x1818f8){if(_0x1818f8){_0x39eb3b['interaction']=_0x1818f8[_0xf160('0x62')]({'plain':!![]});interaction_log[_0xf160('0x20')](_0xf160('0x67'),_0x1de36a[_0xf160('0x5d')]['id'],_0x1de36a[_0xf160('0x5d')][_0xf160('0x34')],_0x1de36a['user'][_0xf160('0x68')],_0x39eb3b[_0xf160('0x69')]['id'],_0x1de36a[_0xf160('0x56')]?JSON['stringify'](_0x1de36a[_0xf160('0x56')]):_0xf160('0x6a'));return respondWithRpcPromise('AcceptMessage',_0xf160('0x6b'),_0x39eb3b);}return null;})[_0xf160('0x32')](function(_0x37de7b){if(_0x37de7b){if(_0x1de36a['body'][_0xf160('0x6c')]){_0x39eb3b[_0xf160('0x28')][_0xf160('0x6d')]=util['format'](_0xf160('0x6e'),_0x1de36a[_0xf160('0x5d')][_0xf160('0x34')]);_0x39eb3b[_0xf160('0x28')][_0xf160('0x6f')]=_0x39eb3b[_0xf160('0x6f')];_0x39eb3b[_0xf160('0x28')]['event']=_0xf160('0x58');return respondWithRpcPromise(_0xf160('0x70'),_0xf160('0x70'),{'event':'acceptmessage','message':_0x39eb3b[_0xf160('0x28')]},client9002)[_0xf160('0x32')](function(){return _0x39eb3b;});}return _0x39eb3b;}return null;})[_0xf160('0x32')](respondWithResult(_0x4b3224,null))[_0xf160('0x29')](handleError(_0x4b3224,null));};var interaction_log=require(_0xf160('0x12'))(_0xf160('0x71'));exports[_0xf160('0x72')]=function(_0x59b63c,_0x4c8103,_0x3b3e14){var _0x32d85c={'agent':{},'channel':_0xf160('0x59')};if(_0x59b63c[_0xf160('0x56')]['id']){delete _0x59b63c[_0xf160('0x56')]['id'];}_0x59b63c[_0xf160('0x56')][_0xf160('0x5f')]=_0x59b63c['body'][_0xf160('0x5f')]||_0x59b63c[_0xf160('0x5d')]['id'];_0x32d85c['agent']['id']=_0x59b63c['body'][_0xf160('0x5f')];return db[_0xf160('0x38')]['find']({'where':{'id':_0x59b63c[_0xf160('0x53')]['id'],'UserId':null}})[_0xf160('0x32')](handleEntityNotFound(_0x4c8103,null))['then'](function(_0x377038){if(_0x377038){_0x32d85c['message']=_0x377038[_0xf160('0x62')]({'plain':!![]});return db[_0xf160('0x63')][_0xf160('0x55')]({'where':{'id':_0x377038[_0xf160('0x64')]}});}return null;})['then'](handleEntityNotFound(_0x4c8103,null))[_0xf160('0x32')](function(_0x2c5d3e){if(_0x2c5d3e){_0x32d85c[_0xf160('0x69')]=_0x2c5d3e[_0xf160('0x62')]({'plain':!![]});interaction_log[_0xf160('0x20')]('[FAXMESSAGE:REJECT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s',_0x59b63c[_0xf160('0x5d')]['id'],_0x59b63c[_0xf160('0x5d')][_0xf160('0x34')],_0x59b63c[_0xf160('0x5d')][_0xf160('0x68')],_0x32d85c[_0xf160('0x69')]['id'],_0x59b63c[_0xf160('0x56')]?JSON[_0xf160('0x25')](_0x59b63c[_0xf160('0x56')]):_0xf160('0x6a'));return respondWithRpcPromise(_0xf160('0x73'),'rejectMessage',_0x32d85c);}return null;})[_0xf160('0x32')](function(_0x1dc546){if(_0x1dc546){_0x1dc546[_0xf160('0x28')][_0xf160('0x6d')]=util[_0xf160('0x5b')]('SIP/%s',_0x59b63c[_0xf160('0x5d')][_0xf160('0x34')]);_0x1dc546[_0xf160('0x28')][_0xf160('0x6f')]=_0x32d85c[_0xf160('0x6f')];_0x1dc546[_0xf160('0x28')][_0xf160('0x74')]=_0xf160('0x72');respondWithRpcPromise(_0xf160('0x70'),_0xf160('0x70'),{'event':_0xf160('0x75'),'message':_0x1dc546['message']},client9002);return _0x32d85c;}return null;})[_0xf160('0x32')](respondWithResult(_0x4c8103,null))['catch'](handleError(_0x4c8103,null));};exports[_0xf160('0x76')]=function(_0x11f67a,_0xd0006f){var _0xf29ffa;return db[_0xf160('0x38')]['create'](_0x11f67a[_0xf160('0x56')],{})[_0xf160('0x32')](function(_0x2a992a){_0xf29ffa=_0x2a992a;return db[_0xf160('0x60')]['findOne']({'where':{'id':_0xf29ffa['ContactId']}});})[_0xf160('0x32')](function(_0x4cd533){if(_[_0xf160('0x65')](_0x4cd533)){return;}else{_0xf29ffa['fax']=_0x4cd533[_0xf160('0x59')];return db['Attachment']['findOne']({'where':{'id':_0xf29ffa[_0xf160('0x77')]}});}})[_0xf160('0x32')](function(_0x118bc3){return respondWithRpcPromise(_0xf160('0x78'),_0xf160('0x78'),{'FaxAccountId':_[_0xf160('0x65')](_0x11f67a[_0xf160('0x56')])?undefined:_0x11f67a[_0xf160('0x56')][_0xf160('0x79')],'path':_['isNil'](_0x118bc3)?undefined:util['format'](_0xf160('0x7a'),_0x118bc3[_0xf160('0x7b')]),'fax':_[_0xf160('0x65')](_0xf29ffa[_0xf160('0x59')])?undefined:_0xf29ffa[_0xf160('0x59')],'AttachmentId':_0xf29ffa['AttachmentId']},client9002);})[_0xf160('0x32')](respondWithResult(_0xd0006f,0xc9))[_0xf160('0x29')](handleError(_0xd0006f,null));};exports[_0xf160('0x7c')]=function(_0x2d708d,_0x5981c9){var _0x5a0fee=path['join'](config[_0xf160('0x7d')],'server',_0xf160('0x7e'),'attachments');return db[_0xf160('0x38')][_0xf160('0x55')]({'where':{'id':_0x2d708d['params']['id']},'include':[{'model':db[_0xf160('0x7f')],'as':_0xf160('0x7f')}]})[_0xf160('0x32')](handleEntityNotFound(_0x5981c9,null))[_0xf160('0x32')](function(_0xafdba6){if(_0xafdba6){return _0x5981c9[_0xf160('0x7c')](path[_0xf160('0x80')](_0x5a0fee,_0xafdba6['Attachment']['basename']));}})[_0xf160('0x29')](handleError(_0x5981c9,null));};
\ No newline at end of file
+var _0x96c3=['localhost','socket.io-emitter','./faxMessage.socket','register','jayson/promise','client','http','request','then','info','debug','request\x20sent','stringify','code','error','message','FaxMessage,\x20%s,\x20%s','result','sendStatus','status','end','json','offset','limit','undefined','count','set','Content-Range','apply','reject','save','update','destroy','stack','index','FaxMessage','rawAttributes','fieldName','key','model','map','name','keys','filters','intersection','attributes','fields','query','length','hasOwnProperty','nolimit','order','sort','pick','filter','where','merge','type','VIRTUAL','options','findAll','catch','show','params','includeAll','body','find','describe','fax-interactions','accept','YYYY-MM-DD\x20HH:mm:ss','UserId','get','FaxInteraction','FaxInteractionId','format','interaction','user','role','acceptMessage','Sequelize','QueryTypes','contact','User','agent','fullname','email','internal','manual','SIP/%s','channel','event','EventManager','fax','[FAXMESSAGE:REJECT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','null','RejectMessage','rejectMessage','SELECT\x20*\x20FROM\x20cm_contacts\x20WHERE\x20id\x20=\x20','ContactId','sequelize','motionChannel','rejectmessage','create','findOne','isNil','Attachment','SendFax','FaxAccountId','/var/opt/motion2/server/files/attachments/%s','basename','join','root','server','files','attachments','eml-format','zip-dir','request-promise','moment','bluebird','util','path','to-csv','ejs','squel','jsforce','desk.js','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','../../config/utils','../../config/environment','../../config/license/util','redis','defaults'];(function(_0x411add,_0x1aed38){var _0x238242=function(_0x4a1cd5){while(--_0x4a1cd5){_0x411add['push'](_0x411add['shift']());}};_0x238242(++_0x1aed38);}(_0x96c3,0xff));var _0x396c=function(_0x50c88d,_0x30cbd1){_0x50c88d=_0x50c88d-0x0;var _0x4bba24=_0x96c3[_0x50c88d];return _0x4bba24;};'use strict';var emlformat=require(_0x396c('0x0'));var rimraf=require('rimraf');var zipdir=require(_0x396c('0x1'));var jsonpatch=require('fast-json-patch');var rp=require(_0x396c('0x2'));var moment=require(_0x396c('0x3'));var BPromise=require(_0x396c('0x4'));var Mustache=require('mustache');var util=require(_0x396c('0x5'));var path=require(_0x396c('0x6'));var sox=require('sox');var csv=require(_0x396c('0x7'));var ejs=require(_0x396c('0x8'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require('lodash');var squel=require(_0x396c('0x9'));var crypto=require('crypto');var jsforce=require(_0x396c('0xa'));var deskjs=require(_0x396c('0xb'));var toCsv=require(_0x396c('0x7'));var querystring=require(_0x396c('0xc'));var Papa=require('papaparse');var Redis=require(_0x396c('0xd'));var authService=require(_0x396c('0xe'));var qs=require(_0x396c('0xf'));var as=require(_0x396c('0x10'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x396c('0x11'))('api');var utils=require(_0x396c('0x12'));var config=require(_0x396c('0x13'));var licenseUtil=require(_0x396c('0x14'));var db=require('../../mysqldb')['db'];config[_0x396c('0x15')]=_[_0x396c('0x16')](config['redis'],{'host':_0x396c('0x17'),'port':0x18eb});var socket=require(_0x396c('0x18'))(new Redis(config[_0x396c('0x15')]));require(_0x396c('0x19'))[_0x396c('0x1a')](socket);var jayson=require(_0x396c('0x1b'));var client=jayson[_0x396c('0x1c')][_0x396c('0x1d')]({'port':0x232c});var client9002=jayson[_0x396c('0x1c')][_0x396c('0x1d')]({'port':0x232a});function respondWithRpcPromise(_0x1f9bf4,_0x56cb68,_0xbc2733,_0xd8a6e5){return new BPromise(function(_0x3f6731,_0x4967fb){var _0x2e6f75=_0xd8a6e5||client;return _0x2e6f75[_0x396c('0x1e')](_0x1f9bf4,_0xbc2733)[_0x396c('0x1f')](function(_0x4f7f89){logger[_0x396c('0x20')]('FaxMessage,\x20%s,\x20%s',_0x56cb68,'request\x20sent');logger[_0x396c('0x21')]('FaxMessage,\x20%s,\x20%s,\x20%s',_0x56cb68,_0x396c('0x22'),JSON[_0x396c('0x23')](_0x4f7f89));if(_0x4f7f89['error']){if(_0x4f7f89['error'][_0x396c('0x24')]===0x1f4){logger[_0x396c('0x25')]('FaxMessage,\x20%s,\x20%s',_0x56cb68,_0x4f7f89[_0x396c('0x25')][_0x396c('0x26')]);return _0x4967fb(_0x4f7f89[_0x396c('0x25')]['message']);}logger[_0x396c('0x25')]('FaxMessage,\x20%s,\x20%s',_0x56cb68,_0x4f7f89[_0x396c('0x25')][_0x396c('0x26')]);return _0x3f6731(_0x4f7f89['error'][_0x396c('0x26')]);}else{logger['info'](_0x396c('0x27'),_0x56cb68,_0x396c('0x22'));_0x3f6731(_0x4f7f89[_0x396c('0x28')][_0x396c('0x26')]);}})['catch'](function(_0x571d57){logger[_0x396c('0x25')](_0x396c('0x27'),_0x56cb68,_0x571d57);_0x4967fb(_0x571d57);});});}function respondWithStatusCode(_0x2b82bd,_0x37b8b8){_0x37b8b8=_0x37b8b8||0xcc;return function(_0x1e2e77){if(_0x1e2e77){return _0x2b82bd[_0x396c('0x29')](_0x37b8b8);}return _0x2b82bd[_0x396c('0x2a')](_0x37b8b8)[_0x396c('0x2b')]();};}function respondWithResult(_0x392d5d,_0x2ab7f4){_0x2ab7f4=_0x2ab7f4||0xc8;return function(_0x206665){if(_0x206665){return _0x392d5d[_0x396c('0x2a')](_0x2ab7f4)[_0x396c('0x2c')](_0x206665);}};}function respondWithFilteredResult(_0x348db2,_0x579d55){return function(_0x20bc0d){if(_0x20bc0d){var _0x5d1134=typeof _0x579d55[_0x396c('0x2d')]==='undefined'&&typeof _0x579d55[_0x396c('0x2e')]===_0x396c('0x2f');var _0x35368a=_0x20bc0d[_0x396c('0x30')];var _0x8938e0=_0x5d1134?0x0:_0x579d55[_0x396c('0x2d')];var _0x1524ed=_0x5d1134?_0x20bc0d[_0x396c('0x30')]:_0x579d55[_0x396c('0x2d')]+_0x579d55[_0x396c('0x2e')];var _0x1417cc;if(_0x1524ed>=_0x35368a){_0x1524ed=_0x35368a;_0x1417cc=0xc8;}else{_0x1417cc=0xce;}_0x348db2[_0x396c('0x2a')](_0x1417cc);return _0x348db2[_0x396c('0x31')](_0x396c('0x32'),_0x8938e0+'-'+_0x1524ed+'/'+_0x35368a)[_0x396c('0x2c')](_0x20bc0d);}return null;};}function patchUpdates(_0x2a33f3){return function(_0x2d48f4){try{jsonpatch[_0x396c('0x33')](_0x2d48f4,_0x2a33f3,!![]);}catch(_0x34f88d){return BPromise[_0x396c('0x34')](_0x34f88d);}return _0x2d48f4[_0x396c('0x35')]();};}function saveUpdates(_0xd949c7,_0x3ed447){return function(_0x46bce7){if(_0x46bce7){return _0x46bce7[_0x396c('0x36')](_0xd949c7)[_0x396c('0x1f')](function(_0x1c083a){return _0x1c083a;});}return null;};}function removeEntity(_0x1d33eb,_0x1cbfc2){return function(_0x8330f5){if(_0x8330f5){return _0x8330f5[_0x396c('0x37')]()[_0x396c('0x1f')](function(){_0x1d33eb[_0x396c('0x2a')](0xcc)[_0x396c('0x2b')]();});}};}function handleEntityNotFound(_0x1c65bd,_0x3daae0){return function(_0x1f8e80){if(!_0x1f8e80){_0x1c65bd[_0x396c('0x29')](0x194);}return _0x1f8e80;};}function handleError(_0x44a9cd,_0x17e6b6){_0x17e6b6=_0x17e6b6||0x1f4;return function(_0x4b84e5){logger[_0x396c('0x25')](_0x4b84e5[_0x396c('0x38')]);if(_0x4b84e5['name']){delete _0x4b84e5['name'];}_0x44a9cd[_0x396c('0x2a')](_0x17e6b6)['send'](_0x4b84e5);};}exports[_0x396c('0x39')]=function(_0x50a0e6,_0x149add){var _0x281eeb={},_0x5c66f5={},_0x5bf70b={'count':0x0,'rows':[]};var _0x11d842=_['map'](db[_0x396c('0x3a')][_0x396c('0x3b')],function(_0xae168b){return{'name':_0xae168b[_0x396c('0x3c')],'type':_0xae168b['type'][_0x396c('0x3d')]};});_0x5c66f5[_0x396c('0x3e')]=_[_0x396c('0x3f')](_0x11d842,_0x396c('0x40'));_0x5c66f5['query']=_[_0x396c('0x41')](_0x50a0e6['query']);_0x5c66f5[_0x396c('0x42')]=_[_0x396c('0x43')](_0x5c66f5[_0x396c('0x3e')],_0x5c66f5['query']);_0x281eeb[_0x396c('0x44')]=_['intersection'](_0x5c66f5[_0x396c('0x3e')],qs[_0x396c('0x45')](_0x50a0e6[_0x396c('0x46')][_0x396c('0x45')]));_0x281eeb[_0x396c('0x44')]=_0x281eeb['attributes'][_0x396c('0x47')]?_0x281eeb[_0x396c('0x44')]:_0x5c66f5[_0x396c('0x3e')];if(!_0x50a0e6[_0x396c('0x46')][_0x396c('0x48')](_0x396c('0x49'))){_0x281eeb['limit']=qs['limit'](_0x50a0e6['query'][_0x396c('0x2e')]);_0x281eeb[_0x396c('0x2d')]=qs[_0x396c('0x2d')](_0x50a0e6[_0x396c('0x46')][_0x396c('0x2d')]);}_0x281eeb[_0x396c('0x4a')]=qs[_0x396c('0x4b')](_0x50a0e6[_0x396c('0x46')][_0x396c('0x4b')]);_0x281eeb['where']=qs[_0x396c('0x42')](_[_0x396c('0x4c')](_0x50a0e6[_0x396c('0x46')],_0x5c66f5[_0x396c('0x42')]),_0x11d842);if(_0x50a0e6['query'][_0x396c('0x4d')]){_0x281eeb[_0x396c('0x4e')]=_[_0x396c('0x4f')](_0x281eeb[_0x396c('0x4e')],{'$or':_[_0x396c('0x3f')](_0x11d842,function(_0x4a9098){if(_0x4a9098[_0x396c('0x50')]!==_0x396c('0x51')){var _0x2102db={};_0x2102db[_0x4a9098[_0x396c('0x40')]]={'$like':'%'+_0x50a0e6[_0x396c('0x46')]['filter']+'%'};return _0x2102db;}})});}_0x281eeb=_[_0x396c('0x4f')]({},_0x281eeb,_0x50a0e6[_0x396c('0x52')]);var _0x34a250={'where':_0x281eeb[_0x396c('0x4e')]};return db[_0x396c('0x3a')][_0x396c('0x30')](_0x34a250)[_0x396c('0x1f')](function(_0x2f2d45){_0x5bf70b[_0x396c('0x30')]=_0x2f2d45;if(_0x50a0e6[_0x396c('0x46')]['includeAll']){_0x281eeb['include']=[{'all':!![]}];}return db[_0x396c('0x3a')][_0x396c('0x53')](_0x281eeb);})[_0x396c('0x1f')](function(_0x2f6746){_0x5bf70b['rows']=_0x2f6746;return _0x5bf70b;})[_0x396c('0x1f')](respondWithFilteredResult(_0x149add,_0x281eeb))[_0x396c('0x54')](handleError(_0x149add,null));};exports[_0x396c('0x55')]=function(_0x5992c4,_0x2e6bc0){var _0x2dadae={'raw':!![],'where':{'id':_0x5992c4[_0x396c('0x56')]['id']}},_0x331723={};_0x331723[_0x396c('0x3e')]=_['keys'](db[_0x396c('0x3a')][_0x396c('0x3b')]);_0x331723[_0x396c('0x46')]=_[_0x396c('0x41')](_0x5992c4[_0x396c('0x46')]);_0x331723[_0x396c('0x42')]=_[_0x396c('0x43')](_0x331723[_0x396c('0x3e')],_0x331723[_0x396c('0x46')]);_0x2dadae[_0x396c('0x44')]=_[_0x396c('0x43')](_0x331723['model'],qs[_0x396c('0x45')](_0x5992c4[_0x396c('0x46')][_0x396c('0x45')]));_0x2dadae[_0x396c('0x44')]=_0x2dadae[_0x396c('0x44')][_0x396c('0x47')]?_0x2dadae[_0x396c('0x44')]:_0x331723[_0x396c('0x3e')];if(_0x5992c4[_0x396c('0x46')][_0x396c('0x57')]){_0x2dadae['include']=[{'all':!![]}];}_0x2dadae=_['merge']({},_0x2dadae,_0x5992c4[_0x396c('0x52')]);return db[_0x396c('0x3a')]['find'](_0x2dadae)[_0x396c('0x1f')](handleEntityNotFound(_0x2e6bc0,null))[_0x396c('0x1f')](respondWithResult(_0x2e6bc0,null))['catch'](handleError(_0x2e6bc0,null));};exports['update']=function(_0x992b18,_0x3ed71e){if(_0x992b18[_0x396c('0x58')]['id']){delete _0x992b18['body']['id'];}return db[_0x396c('0x3a')][_0x396c('0x59')]({'where':{'id':_0x992b18[_0x396c('0x56')]['id']}})['then'](handleEntityNotFound(_0x3ed71e,null))[_0x396c('0x1f')](saveUpdates(_0x992b18[_0x396c('0x58')],null))[_0x396c('0x1f')](respondWithResult(_0x3ed71e,null))['catch'](handleError(_0x3ed71e,null));};exports[_0x396c('0x37')]=function(_0x1ae572,_0x578c43){return db['FaxMessage'][_0x396c('0x59')]({'where':{'id':_0x1ae572[_0x396c('0x56')]['id']}})[_0x396c('0x1f')](handleEntityNotFound(_0x578c43,null))[_0x396c('0x1f')](removeEntity(_0x578c43,null))[_0x396c('0x54')](handleError(_0x578c43,null));};exports['describe']=function(_0x9654ec,_0x23da8e){return db[_0x396c('0x3a')][_0x396c('0x5a')]()[_0x396c('0x1f')](respondWithResult(_0x23da8e,null))[_0x396c('0x54')](handleError(_0x23da8e,null));};var interaction_log=require(_0x396c('0x11'))(_0x396c('0x5b'));exports[_0x396c('0x5c')]=function(_0xa1a074,_0x2596ee,_0x5497ce){var _0x21fa54={'agent':{},'channel':'fax'};if(_0xa1a074[_0x396c('0x58')]['id']){delete _0xa1a074[_0x396c('0x58')]['id'];}_0xa1a074['body']['read']=!![];_0xa1a074[_0x396c('0x58')]['readAt']=moment()['format'](_0x396c('0x5d'));_0xa1a074[_0x396c('0x58')]['UserId']=_0xa1a074['body'][_0x396c('0x5e')]||_0xa1a074['user']['id'];_0x21fa54['agent']['id']=_0xa1a074[_0x396c('0x58')][_0x396c('0x5e')];return db[_0x396c('0x3a')]['find']({'where':{'id':_0xa1a074[_0x396c('0x56')]['id'],'UserId':null}})['then'](handleEntityNotFound(_0x2596ee,null))['then'](saveUpdates(_0xa1a074[_0x396c('0x58')],null))['then'](function(_0xe97673){if(_0xe97673){_0x21fa54[_0x396c('0x26')]=_0xe97673[_0x396c('0x5f')]({'plain':!![]});return db[_0x396c('0x60')][_0x396c('0x59')]({'where':{'id':_0xe97673[_0x396c('0x61')]}});}return null;})[_0x396c('0x1f')](handleEntityNotFound(_0x2596ee,null))[_0x396c('0x1f')](function(_0x42a9dc){if(_0x42a9dc){return _0x42a9dc['update']({'UserId':_0xa1a074['body']['UserId'],'read1stAt':_['isNil'](_0x42a9dc['read1stAt'])?moment()[_0x396c('0x62')](_0x396c('0x5d')):undefined});}return null;})[_0x396c('0x1f')](function(_0x1259be){if(_0x1259be){_0x21fa54[_0x396c('0x63')]=_0x1259be[_0x396c('0x5f')]({'plain':!![]});interaction_log['info']('[FAXMESSAGE:ACCEPT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s',_0xa1a074[_0x396c('0x64')]['id'],_0xa1a074[_0x396c('0x64')]['name'],_0xa1a074[_0x396c('0x64')][_0x396c('0x65')],_0x21fa54[_0x396c('0x63')]['id'],_0xa1a074[_0x396c('0x58')]?JSON['stringify'](_0xa1a074[_0x396c('0x58')]):'null');return respondWithRpcPromise('AcceptMessage',_0x396c('0x66'),_0x21fa54);}return null;})[_0x396c('0x1f')](function(_0xc384){var _0x427807='SELECT\x20*\x20FROM\x20cm_contacts\x20WHERE\x20id\x20=\x20'+_0xc384['message']['ContactId'];return db['sequelize'][_0x396c('0x46')](_0x427807,{'type':db[_0x396c('0x67')][_0x396c('0x68')]['SELECT'],'raw':!![]})[_0x396c('0x1f')](function(_0x266f6c){return _0x266f6c;});})['then'](function(_0x4d5c45){if(_0x4d5c45){_0x21fa54[_0x396c('0x26')][_0x396c('0x69')]=_0x4d5c45[0x0];if(!_0xa1a074[_0x396c('0x58')][_0x396c('0x5e')])return;return db[_0x396c('0x6a')][_0x396c('0x59')]({'where':{'id':_0xa1a074[_0x396c('0x58')][_0x396c('0x5e')],'role':_0x396c('0x6b')},'attributes':['id',_0x396c('0x40'),_0x396c('0x6c'),_0x396c('0x6d'),_0x396c('0x6e')],'raw':!![]});}return null;})[_0x396c('0x1f')](function(_0x43e7f9){if(!_0x43e7f9)return null;_0x21fa54[_0x396c('0x26')][_0x396c('0x6b')]=_0x43e7f9;return _0x21fa54;})[_0x396c('0x1f')](function(_0x251569){if(_0x251569){if(_0xa1a074[_0x396c('0x58')][_0x396c('0x6f')]){_0x21fa54[_0x396c('0x26')]['interface']=util[_0x396c('0x62')](_0x396c('0x70'),_0xa1a074['user'][_0x396c('0x40')]);_0x21fa54['message']['channel']=_0x21fa54[_0x396c('0x71')];_0x21fa54['message']['motionChannel']=_0x21fa54[_0x396c('0x71')];_0x21fa54['message'][_0x396c('0x72')]=_0x396c('0x5c');return respondWithRpcPromise('EventManager',_0x396c('0x73'),{'event':'acceptmessage','message':_0x21fa54[_0x396c('0x26')]},client9002)['then'](function(){return _0x21fa54;});}return _0x21fa54;}return null;})['then'](respondWithResult(_0x2596ee,null))[_0x396c('0x54')](handleError(_0x2596ee,null));};var interaction_log=require(_0x396c('0x11'))(_0x396c('0x5b'));exports[_0x396c('0x34')]=function(_0x357265,_0x1eab4b,_0x4e40e4){var _0x38ff54={'agent':{},'channel':_0x396c('0x74')};if(_0x357265[_0x396c('0x58')]['id']){delete _0x357265[_0x396c('0x58')]['id'];}_0x357265['body'][_0x396c('0x5e')]=_0x357265[_0x396c('0x58')][_0x396c('0x5e')]||_0x357265[_0x396c('0x64')]['id'];_0x38ff54[_0x396c('0x6b')]['id']=_0x357265[_0x396c('0x58')]['UserId'];return db[_0x396c('0x3a')][_0x396c('0x59')]({'where':{'id':_0x357265[_0x396c('0x56')]['id'],'UserId':null}})[_0x396c('0x1f')](handleEntityNotFound(_0x1eab4b,null))[_0x396c('0x1f')](function(_0x2eb072){if(_0x2eb072){_0x38ff54['message']=_0x2eb072['get']({'plain':!![]});return db[_0x396c('0x60')][_0x396c('0x59')]({'where':{'id':_0x2eb072[_0x396c('0x61')]}});}return null;})[_0x396c('0x1f')](handleEntityNotFound(_0x1eab4b,null))['then'](function(_0x2d17ee){if(_0x2d17ee){_0x38ff54[_0x396c('0x63')]=_0x2d17ee[_0x396c('0x5f')]({'plain':!![]});interaction_log[_0x396c('0x20')](_0x396c('0x75'),_0x357265[_0x396c('0x64')]['id'],_0x357265[_0x396c('0x64')][_0x396c('0x40')],_0x357265[_0x396c('0x64')]['role'],_0x38ff54[_0x396c('0x63')]['id'],_0x357265[_0x396c('0x58')]?JSON[_0x396c('0x23')](_0x357265['body']):_0x396c('0x76'));return respondWithRpcPromise(_0x396c('0x77'),_0x396c('0x78'),_0x38ff54);}return null;})['then'](function(_0x6277cc){var _0x331ca5=_0x396c('0x79')+_0x6277cc[_0x396c('0x26')][_0x396c('0x7a')];return db[_0x396c('0x7b')][_0x396c('0x46')](_0x331ca5,{'type':db[_0x396c('0x67')]['QueryTypes']['SELECT'],'raw':!![]})[_0x396c('0x1f')](function(_0xb4e231){return _0xb4e231;});})['then'](function(_0x42edeb){if(_0x42edeb){_0x38ff54[_0x396c('0x26')]['contact']=_0x42edeb[0x0];if(!_0x357265[_0x396c('0x58')]['UserId'])return;return db['User'][_0x396c('0x59')]({'where':{'id':_0x357265[_0x396c('0x58')][_0x396c('0x5e')],'role':'agent'},'attributes':['id','name',_0x396c('0x6c'),'email','internal'],'raw':!![]});}return null;})[_0x396c('0x1f')](function(_0x5debcd){if(!_0x5debcd)return null;_0x38ff54[_0x396c('0x26')]['agent']=_0x5debcd;return _0x38ff54;})[_0x396c('0x1f')](function(_0x5b7d37){if(_0x5b7d37){_0x5b7d37[_0x396c('0x26')]['interface']=util['format'](_0x396c('0x70'),_0x357265[_0x396c('0x64')][_0x396c('0x40')]);_0x5b7d37[_0x396c('0x26')][_0x396c('0x71')]=_0x38ff54['channel'];_0x5b7d37['message'][_0x396c('0x7c')]=_0x38ff54[_0x396c('0x71')];_0x5b7d37[_0x396c('0x26')][_0x396c('0x72')]=_0x396c('0x34');respondWithRpcPromise(_0x396c('0x73'),_0x396c('0x73'),{'event':_0x396c('0x7d'),'message':_0x5b7d37[_0x396c('0x26')]},client9002);return _0x38ff54;}return null;})[_0x396c('0x1f')](respondWithResult(_0x1eab4b,null))[_0x396c('0x54')](handleError(_0x1eab4b,null));};exports[_0x396c('0x7e')]=function(_0x1396b8,_0x5aae9b){var _0x20c7b7;return db[_0x396c('0x3a')][_0x396c('0x7e')](_0x1396b8['body'],{})['then'](function(_0x12d971){_0x20c7b7=_0x12d971;return db['CmContact'][_0x396c('0x7f')]({'where':{'id':_0x20c7b7[_0x396c('0x7a')]}});})[_0x396c('0x1f')](function(_0x421cba){if(_[_0x396c('0x80')](_0x421cba)){return;}else{_0x20c7b7[_0x396c('0x74')]=_0x421cba[_0x396c('0x74')];return db[_0x396c('0x81')][_0x396c('0x7f')]({'where':{'id':_0x20c7b7['AttachmentId']}});}})[_0x396c('0x1f')](function(_0xa1f9cd){return respondWithRpcPromise('SendFax',_0x396c('0x82'),{'FaxAccountId':_[_0x396c('0x80')](_0x1396b8[_0x396c('0x58')])?undefined:_0x1396b8['body'][_0x396c('0x83')],'path':_[_0x396c('0x80')](_0xa1f9cd)?undefined:util['format'](_0x396c('0x84'),_0xa1f9cd[_0x396c('0x85')]),'fax':_[_0x396c('0x80')](_0x20c7b7[_0x396c('0x74')])?undefined:_0x20c7b7[_0x396c('0x74')],'AttachmentId':_0x20c7b7['AttachmentId']},client9002);})[_0x396c('0x1f')](respondWithResult(_0x5aae9b,0xc9))['catch'](handleError(_0x5aae9b,null));};exports['download']=function(_0x10c1a3,_0x300add){var _0x172d48=path[_0x396c('0x86')](config[_0x396c('0x87')],_0x396c('0x88'),_0x396c('0x89'),_0x396c('0x8a'));return db[_0x396c('0x3a')][_0x396c('0x59')]({'where':{'id':_0x10c1a3[_0x396c('0x56')]['id']},'include':[{'model':db[_0x396c('0x81')],'as':_0x396c('0x81')}]})['then'](handleEntityNotFound(_0x300add,null))[_0x396c('0x1f')](function(_0x6e8cb2){if(_0x6e8cb2){return _0x300add['download'](path[_0x396c('0x86')](_0x172d48,_0x6e8cb2[_0x396c('0x81')][_0x396c('0x85')]));}})[_0x396c('0x54')](handleError(_0x300add,null));};
\ No newline at end of file