Built motion from commit 0900f080.|2.5.45
[motion2.git] / server / api / faxMessage / faxMessage.controller.js
index 68badc3..3577b0d 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x5afc=['FaxMessage,\x20%s,\x20%s','request\x20sent','FaxMessage,\x20%s,\x20%s,\x20%s','stringify','error','message','catch','sendStatus','status','json','offset','undefined','limit','count','set','apply','reject','update','destroy','end','stack','name','send','index','map','rawAttributes','fieldName','type','key','model','query','keys','filters','intersection','attributes','fields','hasOwnProperty','nolimit','order','where','filter','VIRTUAL','merge','options','includeAll','include','FaxMessage','findAll','rows','show','params','length','find','body','describe','../../config/logger','fax-interactions','accept','fax','read','readAt','format','UserId','user','agent','CmContact','get','FaxInteraction','FaxInteractionId','isNil','read1stAt','YYYY-MM-DD\x20HH:mm:ss','interaction','[FAXMESSAGE:ACCEPT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','AcceptMessage','manual','interface','channel','EventManager','acceptmessage','[FAXMESSAGE:REJECT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','role','null','RejectMessage','rejectMessage','rejectmessage','create','findOne','AttachmentId','SendFax','/var/opt/motion2/server/files/attachments/%s','join','root','server','files','Attachment','download','basename','eml-format','zip-dir','fast-json-patch','moment','bluebird','mustache','util','path','sox','to-csv','ejs','fs-extra','lodash','jsforce','papaparse','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/utils','../../config/license/util','../../mysqldb','redis','defaults','localhost','./faxMessage.socket','jayson/promise','client','http','request','then','info'];(function(_0x2dcceb,_0x3743d6){var _0x183bda=function(_0x40c1b4){while(--_0x40c1b4){_0x2dcceb['push'](_0x2dcceb['shift']());}};_0x183bda(++_0x3743d6);}(_0x5afc,0x168));var _0xc5af=function(_0x267282,_0x180fa6){_0x267282=_0x267282-0x0;var _0x35a234=_0x5afc[_0x267282];return _0x35a234;};'use strict';var emlformat=require(_0xc5af('0x0'));var rimraf=require('rimraf');var zipdir=require(_0xc5af('0x1'));var jsonpatch=require(_0xc5af('0x2'));var rp=require('request-promise');var moment=require(_0xc5af('0x3'));var BPromise=require(_0xc5af('0x4'));var Mustache=require(_0xc5af('0x5'));var util=require(_0xc5af('0x6'));var path=require(_0xc5af('0x7'));var sox=require(_0xc5af('0x8'));var csv=require(_0xc5af('0x9'));var ejs=require(_0xc5af('0xa'));var fs=require('fs');var fs_extra=require(_0xc5af('0xb'));var _=require(_0xc5af('0xc'));var squel=require('squel');var crypto=require('crypto');var jsforce=require(_0xc5af('0xd'));var deskjs=require('desk.js');var toCsv=require(_0xc5af('0x9'));var querystring=require('querystring');var Papa=require(_0xc5af('0xe'));var Redis=require(_0xc5af('0xf'));var authService=require(_0xc5af('0x10'));var qs=require('../../components/parsers/qs');var as=require(_0xc5af('0x11'));var hardwareService=require(_0xc5af('0x12'));var logger=require('../../config/logger')(_0xc5af('0x13'));var utils=require(_0xc5af('0x14'));var config=require('../../config/environment');var licenseUtil=require(_0xc5af('0x15'));var db=require(_0xc5af('0x16'))['db'];config[_0xc5af('0x17')]=_[_0xc5af('0x18')](config[_0xc5af('0x17')],{'host':_0xc5af('0x19'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require(_0xc5af('0x1a'))['register'](socket);var jayson=require(_0xc5af('0x1b'));var client=jayson[_0xc5af('0x1c')][_0xc5af('0x1d')]({'port':0x232c});var client9002=jayson[_0xc5af('0x1c')][_0xc5af('0x1d')]({'port':0x232a});function respondWithRpcPromise(_0x9f95a7,_0x1b4bc7,_0x2adc22,_0xa24f76){return new BPromise(function(_0x44ae21,_0x34862f){var _0x3c49e2=_0xa24f76||client;return _0x3c49e2[_0xc5af('0x1e')](_0x9f95a7,_0x2adc22)[_0xc5af('0x1f')](function(_0x32461f){logger[_0xc5af('0x20')](_0xc5af('0x21'),_0x1b4bc7,_0xc5af('0x22'));logger['debug'](_0xc5af('0x23'),_0x1b4bc7,'request\x20sent',JSON[_0xc5af('0x24')](_0x32461f));if(_0x32461f['error']){if(_0x32461f[_0xc5af('0x25')]['code']===0x1f4){logger[_0xc5af('0x25')]('FaxMessage,\x20%s,\x20%s',_0x1b4bc7,_0x32461f[_0xc5af('0x25')]['message']);return _0x34862f(_0x32461f[_0xc5af('0x25')][_0xc5af('0x26')]);}logger[_0xc5af('0x25')](_0xc5af('0x21'),_0x1b4bc7,_0x32461f[_0xc5af('0x25')][_0xc5af('0x26')]);return _0x44ae21(_0x32461f[_0xc5af('0x25')][_0xc5af('0x26')]);}else{logger['info'](_0xc5af('0x21'),_0x1b4bc7,_0xc5af('0x22'));_0x44ae21(_0x32461f['result']['message']);}})[_0xc5af('0x27')](function(_0x301e94){logger['error'](_0xc5af('0x21'),_0x1b4bc7,_0x301e94);_0x34862f(_0x301e94);});});}function respondWithStatusCode(_0x39fa88,_0xa0ee99){_0xa0ee99=_0xa0ee99||0xcc;return function(_0x50cad9){if(_0x50cad9){return _0x39fa88[_0xc5af('0x28')](_0xa0ee99);}return _0x39fa88['status'](_0xa0ee99)['end']();};}function respondWithResult(_0x2f79e4,_0xee600e){_0xee600e=_0xee600e||0xc8;return function(_0x3a5456){if(_0x3a5456){return _0x2f79e4[_0xc5af('0x29')](_0xee600e)[_0xc5af('0x2a')](_0x3a5456);}};}function respondWithFilteredResult(_0x4dab39,_0x3476bb){return function(_0x950bd8){if(_0x950bd8){var _0x1f3a56=typeof _0x3476bb[_0xc5af('0x2b')]===_0xc5af('0x2c')&&typeof _0x3476bb[_0xc5af('0x2d')]===_0xc5af('0x2c');var _0x1dd578=_0x950bd8[_0xc5af('0x2e')];var _0x47b5f5=_0x1f3a56?0x0:_0x3476bb['offset'];var _0x365e35=_0x1f3a56?_0x950bd8[_0xc5af('0x2e')]:_0x3476bb[_0xc5af('0x2b')]+_0x3476bb['limit'];var _0x3663e0;if(_0x365e35>=_0x1dd578){_0x365e35=_0x1dd578;_0x3663e0=0xc8;}else{_0x3663e0=0xce;}_0x4dab39['status'](_0x3663e0);return _0x4dab39[_0xc5af('0x2f')]('Content-Range',_0x47b5f5+'-'+_0x365e35+'/'+_0x1dd578)[_0xc5af('0x2a')](_0x950bd8);}return null;};}function patchUpdates(_0x952df3){return function(_0x4741c8){try{jsonpatch[_0xc5af('0x30')](_0x4741c8,_0x952df3,!![]);}catch(_0x2af3f0){return BPromise[_0xc5af('0x31')](_0x2af3f0);}return _0x4741c8['save']();};}function saveUpdates(_0x156e9a,_0x2d2647){return function(_0x51a705){if(_0x51a705){return _0x51a705[_0xc5af('0x32')](_0x156e9a)[_0xc5af('0x1f')](function(_0x2668e7){return _0x2668e7;});}return null;};}function removeEntity(_0x1aac31,_0x2e8a17){return function(_0x289d1a){if(_0x289d1a){return _0x289d1a[_0xc5af('0x33')]()['then'](function(){_0x1aac31[_0xc5af('0x29')](0xcc)[_0xc5af('0x34')]();});}};}function handleEntityNotFound(_0x59f529,_0x31e180){return function(_0x4f46ae){if(!_0x4f46ae){_0x59f529[_0xc5af('0x28')](0x194);}return _0x4f46ae;};}function handleError(_0x32a281,_0x51d9e2){_0x51d9e2=_0x51d9e2||0x1f4;return function(_0x352f1e){logger[_0xc5af('0x25')](_0x352f1e[_0xc5af('0x35')]);if(_0x352f1e[_0xc5af('0x36')]){delete _0x352f1e['name'];}_0x32a281['status'](_0x51d9e2)[_0xc5af('0x37')](_0x352f1e);};}exports[_0xc5af('0x38')]=function(_0x3eb720,_0x2fad92){var _0x598e77={},_0x11e215={},_0x133562={'count':0x0,'rows':[]};var _0x3f1002=_[_0xc5af('0x39')](db['FaxMessage'][_0xc5af('0x3a')],function(_0x4059f6){return{'name':_0x4059f6[_0xc5af('0x3b')],'type':_0x4059f6[_0xc5af('0x3c')][_0xc5af('0x3d')]};});_0x11e215[_0xc5af('0x3e')]=_[_0xc5af('0x39')](_0x3f1002,'name');_0x11e215[_0xc5af('0x3f')]=_[_0xc5af('0x40')](_0x3eb720[_0xc5af('0x3f')]);_0x11e215[_0xc5af('0x41')]=_[_0xc5af('0x42')](_0x11e215[_0xc5af('0x3e')],_0x11e215[_0xc5af('0x3f')]);_0x598e77[_0xc5af('0x43')]=_['intersection'](_0x11e215[_0xc5af('0x3e')],qs[_0xc5af('0x44')](_0x3eb720['query']['fields']));_0x598e77[_0xc5af('0x43')]=_0x598e77['attributes']['length']?_0x598e77[_0xc5af('0x43')]:_0x11e215[_0xc5af('0x3e')];if(!_0x3eb720['query'][_0xc5af('0x45')](_0xc5af('0x46'))){_0x598e77[_0xc5af('0x2d')]=qs[_0xc5af('0x2d')](_0x3eb720[_0xc5af('0x3f')][_0xc5af('0x2d')]);_0x598e77['offset']=qs[_0xc5af('0x2b')](_0x3eb720[_0xc5af('0x3f')][_0xc5af('0x2b')]);}_0x598e77[_0xc5af('0x47')]=qs['sort'](_0x3eb720['query']['sort']);_0x598e77[_0xc5af('0x48')]=qs['filters'](_['pick'](_0x3eb720[_0xc5af('0x3f')],_0x11e215['filters']),_0x3f1002);if(_0x3eb720[_0xc5af('0x3f')][_0xc5af('0x49')]){_0x598e77['where']=_['merge'](_0x598e77[_0xc5af('0x48')],{'$or':_[_0xc5af('0x39')](_0x3f1002,function(_0x439bfa){if(_0x439bfa['type']!==_0xc5af('0x4a')){var _0x35d156={};_0x35d156[_0x439bfa[_0xc5af('0x36')]]={'$like':'%'+_0x3eb720[_0xc5af('0x3f')][_0xc5af('0x49')]+'%'};return _0x35d156;}})});}_0x598e77=_[_0xc5af('0x4b')]({},_0x598e77,_0x3eb720[_0xc5af('0x4c')]);var _0x3acb57={'where':_0x598e77[_0xc5af('0x48')]};return db['FaxMessage'][_0xc5af('0x2e')](_0x3acb57)[_0xc5af('0x1f')](function(_0x2ce7cb){_0x133562[_0xc5af('0x2e')]=_0x2ce7cb;if(_0x3eb720[_0xc5af('0x3f')][_0xc5af('0x4d')]){_0x598e77[_0xc5af('0x4e')]=[{'all':!![]}];}return db[_0xc5af('0x4f')][_0xc5af('0x50')](_0x598e77);})['then'](function(_0x43b42b){_0x133562[_0xc5af('0x51')]=_0x43b42b;return _0x133562;})[_0xc5af('0x1f')](respondWithFilteredResult(_0x2fad92,_0x598e77))[_0xc5af('0x27')](handleError(_0x2fad92,null));};exports[_0xc5af('0x52')]=function(_0x4a224d,_0x247e51){var _0x269bf5={'raw':!![],'where':{'id':_0x4a224d[_0xc5af('0x53')]['id']}},_0x2e9ee8={};_0x2e9ee8[_0xc5af('0x3e')]=_[_0xc5af('0x40')](db[_0xc5af('0x4f')][_0xc5af('0x3a')]);_0x2e9ee8[_0xc5af('0x3f')]=_[_0xc5af('0x40')](_0x4a224d[_0xc5af('0x3f')]);_0x2e9ee8[_0xc5af('0x41')]=_['intersection'](_0x2e9ee8[_0xc5af('0x3e')],_0x2e9ee8[_0xc5af('0x3f')]);_0x269bf5[_0xc5af('0x43')]=_[_0xc5af('0x42')](_0x2e9ee8[_0xc5af('0x3e')],qs['fields'](_0x4a224d['query'][_0xc5af('0x44')]));_0x269bf5[_0xc5af('0x43')]=_0x269bf5[_0xc5af('0x43')][_0xc5af('0x54')]?_0x269bf5[_0xc5af('0x43')]:_0x2e9ee8[_0xc5af('0x3e')];if(_0x4a224d[_0xc5af('0x3f')]['includeAll']){_0x269bf5['include']=[{'all':!![]}];}_0x269bf5=_[_0xc5af('0x4b')]({},_0x269bf5,_0x4a224d[_0xc5af('0x4c')]);return db['FaxMessage'][_0xc5af('0x55')](_0x269bf5)[_0xc5af('0x1f')](handleEntityNotFound(_0x247e51,null))['then'](respondWithResult(_0x247e51,null))[_0xc5af('0x27')](handleError(_0x247e51,null));};exports['update']=function(_0x58389b,_0x570fc5){if(_0x58389b[_0xc5af('0x56')]['id']){delete _0x58389b[_0xc5af('0x56')]['id'];}return db['FaxMessage'][_0xc5af('0x55')]({'where':{'id':_0x58389b[_0xc5af('0x53')]['id']}})[_0xc5af('0x1f')](handleEntityNotFound(_0x570fc5,null))[_0xc5af('0x1f')](saveUpdates(_0x58389b['body'],null))[_0xc5af('0x1f')](respondWithResult(_0x570fc5,null))[_0xc5af('0x27')](handleError(_0x570fc5,null));};exports[_0xc5af('0x33')]=function(_0x13af64,_0xee4349){return db[_0xc5af('0x4f')][_0xc5af('0x55')]({'where':{'id':_0x13af64[_0xc5af('0x53')]['id']}})[_0xc5af('0x1f')](handleEntityNotFound(_0xee4349,null))[_0xc5af('0x1f')](removeEntity(_0xee4349,null))[_0xc5af('0x27')](handleError(_0xee4349,null));};exports[_0xc5af('0x57')]=function(_0xd308d1,_0x502a22){return db[_0xc5af('0x4f')]['describe']()[_0xc5af('0x1f')](respondWithResult(_0x502a22,null))[_0xc5af('0x27')](handleError(_0x502a22,null));};var interaction_log=require(_0xc5af('0x58'))(_0xc5af('0x59'));exports[_0xc5af('0x5a')]=function(_0xf26fcd,_0x92ca06,_0x1eb624){var _0x32f5c1={'agent':{},'channel':_0xc5af('0x5b')};if(_0xf26fcd['body']['id']){delete _0xf26fcd['body']['id'];}_0xf26fcd[_0xc5af('0x56')][_0xc5af('0x5c')]=!![];_0xf26fcd['body'][_0xc5af('0x5d')]=moment()[_0xc5af('0x5e')]('YYYY-MM-DD\x20HH:mm:ss');_0xf26fcd[_0xc5af('0x56')][_0xc5af('0x5f')]=_0xf26fcd[_0xc5af('0x56')][_0xc5af('0x5f')]||_0xf26fcd[_0xc5af('0x60')]['id'];_0x32f5c1[_0xc5af('0x61')]['id']=_0xf26fcd[_0xc5af('0x56')][_0xc5af('0x5f')];return db[_0xc5af('0x4f')]['find']({'where':{'id':_0xf26fcd['params']['id'],'UserId':null},'include':[{'model':db[_0xc5af('0x62')],'as':'Contact'}]})[_0xc5af('0x1f')](handleEntityNotFound(_0x92ca06,null))[_0xc5af('0x1f')](saveUpdates(_0xf26fcd[_0xc5af('0x56')],null))['then'](function(_0xcb32ce){if(_0xcb32ce){_0x32f5c1[_0xc5af('0x26')]=_0xcb32ce[_0xc5af('0x63')]({'plain':!![]});return db[_0xc5af('0x64')]['find']({'where':{'id':_0xcb32ce[_0xc5af('0x65')]}});}return null;})[_0xc5af('0x1f')](handleEntityNotFound(_0x92ca06,null))[_0xc5af('0x1f')](function(_0x231b90){if(_0x231b90){return _0x231b90[_0xc5af('0x32')]({'UserId':_0xf26fcd[_0xc5af('0x56')][_0xc5af('0x5f')],'read1stAt':_[_0xc5af('0x66')](_0x231b90[_0xc5af('0x67')])?moment()[_0xc5af('0x5e')](_0xc5af('0x68')):undefined});}return null;})[_0xc5af('0x1f')](function(_0x9cdfa5){if(_0x9cdfa5){_0x32f5c1[_0xc5af('0x69')]=_0x9cdfa5['get']({'plain':!![]});interaction_log[_0xc5af('0x20')](_0xc5af('0x6a'),_0xf26fcd[_0xc5af('0x60')]['id'],_0xf26fcd['user'][_0xc5af('0x36')],_0xf26fcd['user']['role'],_0x32f5c1[_0xc5af('0x69')]['id'],_0xf26fcd['body']?JSON[_0xc5af('0x24')](_0xf26fcd[_0xc5af('0x56')]):'null');return respondWithRpcPromise(_0xc5af('0x6b'),'acceptMessage',_0x32f5c1);}return null;})[_0xc5af('0x1f')](function(_0x4c05b3){if(_0x4c05b3){if(_0xf26fcd[_0xc5af('0x56')][_0xc5af('0x6c')]){_0x32f5c1[_0xc5af('0x26')][_0xc5af('0x6d')]=util[_0xc5af('0x5e')]('SIP/%s',_0xf26fcd[_0xc5af('0x60')][_0xc5af('0x36')]);_0x32f5c1[_0xc5af('0x26')][_0xc5af('0x6e')]=_0x32f5c1[_0xc5af('0x6e')];_0x32f5c1[_0xc5af('0x26')]['event']=_0xc5af('0x5a');return respondWithRpcPromise(_0xc5af('0x6f'),_0xc5af('0x6f'),{'event':_0xc5af('0x70'),'message':_0x32f5c1[_0xc5af('0x26')]},client9002)[_0xc5af('0x1f')](function(){return _0x32f5c1;});}return _0x32f5c1;}return null;})['then'](respondWithResult(_0x92ca06,null))[_0xc5af('0x27')](handleError(_0x92ca06,null));};var interaction_log=require(_0xc5af('0x58'))(_0xc5af('0x59'));exports[_0xc5af('0x31')]=function(_0x3d27f0,_0x504cad,_0x52b190){var _0x5332a3={'agent':{},'channel':_0xc5af('0x5b')};if(_0x3d27f0['body']['id']){delete _0x3d27f0[_0xc5af('0x56')]['id'];}_0x3d27f0[_0xc5af('0x56')][_0xc5af('0x5f')]=_0x3d27f0[_0xc5af('0x56')][_0xc5af('0x5f')]||_0x3d27f0['user']['id'];_0x5332a3['agent']['id']=_0x3d27f0[_0xc5af('0x56')][_0xc5af('0x5f')];return db['FaxMessage']['find']({'where':{'id':_0x3d27f0[_0xc5af('0x53')]['id'],'UserId':null}})[_0xc5af('0x1f')](handleEntityNotFound(_0x504cad,null))[_0xc5af('0x1f')](function(_0x16c610){if(_0x16c610){_0x5332a3[_0xc5af('0x26')]=_0x16c610[_0xc5af('0x63')]({'plain':!![]});return db[_0xc5af('0x64')][_0xc5af('0x55')]({'where':{'id':_0x16c610['FaxInteractionId']}});}return null;})[_0xc5af('0x1f')](handleEntityNotFound(_0x504cad,null))[_0xc5af('0x1f')](function(_0x47ee7f){if(_0x47ee7f){_0x5332a3['interaction']=_0x47ee7f[_0xc5af('0x63')]({'plain':!![]});interaction_log[_0xc5af('0x20')](_0xc5af('0x71'),_0x3d27f0[_0xc5af('0x60')]['id'],_0x3d27f0['user'][_0xc5af('0x36')],_0x3d27f0[_0xc5af('0x60')][_0xc5af('0x72')],_0x5332a3['interaction']['id'],_0x3d27f0[_0xc5af('0x56')]?JSON[_0xc5af('0x24')](_0x3d27f0[_0xc5af('0x56')]):_0xc5af('0x73'));return respondWithRpcPromise(_0xc5af('0x74'),_0xc5af('0x75'),_0x5332a3);}return null;})[_0xc5af('0x1f')](function(_0x5436d0){if(_0x5436d0){_0x5436d0['message'][_0xc5af('0x6d')]=util['format']('SIP/%s',_0x3d27f0[_0xc5af('0x60')][_0xc5af('0x36')]);_0x5436d0[_0xc5af('0x26')]['channel']=_0x5332a3[_0xc5af('0x6e')];_0x5436d0[_0xc5af('0x26')]['event']=_0xc5af('0x31');respondWithRpcPromise(_0xc5af('0x6f'),_0xc5af('0x6f'),{'event':_0xc5af('0x76'),'message':_0x5436d0['message']},client9002);return _0x5332a3;}return null;})[_0xc5af('0x1f')](respondWithResult(_0x504cad,null))['catch'](handleError(_0x504cad,null));};exports['create']=function(_0x385428,_0x583d58){var _0x3e8e26;return db['FaxMessage'][_0xc5af('0x77')](_0x385428['body'],{})[_0xc5af('0x1f')](function(_0x557d69){_0x3e8e26=_0x557d69;return db[_0xc5af('0x62')][_0xc5af('0x78')]({'where':{'id':_0x3e8e26['ContactId']}});})[_0xc5af('0x1f')](function(_0x309782){if(_[_0xc5af('0x66')](_0x309782)){return;}else{_0x3e8e26[_0xc5af('0x5b')]=_0x309782['fax'];return db['Attachment']['findOne']({'where':{'id':_0x3e8e26[_0xc5af('0x79')]}});}})['then'](function(_0x32517c){return respondWithRpcPromise(_0xc5af('0x7a'),_0xc5af('0x7a'),{'FaxAccountId':_[_0xc5af('0x66')](_0x385428[_0xc5af('0x56')])?undefined:_0x385428[_0xc5af('0x56')]['FaxAccountId'],'path':_[_0xc5af('0x66')](_0x32517c)?undefined:util[_0xc5af('0x5e')](_0xc5af('0x7b'),_0x32517c['basename']),'fax':_[_0xc5af('0x66')](_0x3e8e26[_0xc5af('0x5b')])?undefined:_0x3e8e26['fax'],'AttachmentId':_0x3e8e26[_0xc5af('0x79')]},client9002);})[_0xc5af('0x1f')](respondWithResult(_0x583d58,0xc9))[_0xc5af('0x27')](handleError(_0x583d58,null));};exports['download']=function(_0x17f645,_0x4de4ea){var _0x2cadad=path[_0xc5af('0x7c')](config[_0xc5af('0x7d')],_0xc5af('0x7e'),_0xc5af('0x7f'),'attachments');return db['FaxMessage'][_0xc5af('0x55')]({'where':{'id':_0x17f645['params']['id']},'include':[{'model':db['Attachment'],'as':_0xc5af('0x80')}]})[_0xc5af('0x1f')](handleEntityNotFound(_0x4de4ea,null))['then'](function(_0xcfd691){if(_0xcfd691){return _0x4de4ea[_0xc5af('0x81')](path[_0xc5af('0x7c')](_0x2cadad,_0xcfd691[_0xc5af('0x80')][_0xc5af('0x82')]));}})[_0xc5af('0x27')](handleError(_0x4de4ea,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