Built motion from commit da617fac.|2.6.6
[motion2.git] / server / api / faxMessage / faxMessage.controller.js
index 33f1ea0..41e2455 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x282b=['info','debug','FaxMessage,\x20%s,\x20%s,\x20%s','stringify','error','code','message','FaxMessage,\x20%s,\x20%s','request\x20sent','catch','sendStatus','status','offset','limit','set','json','apply','save','update','destroy','end','stack','name','index','FaxMessage','rawAttributes','fieldName','model','map','query','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','filter','merge','VIRTUAL','options','count','includeAll','rows','show','params','keys','filters','include','body','find','describe','fax-interactions','fax','read','readAt','UserId','agent','Contact','FaxInteractionId','isNil','read1stAt','format','interaction','[FAXMESSAGE:ACCEPT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','user','role','null','AcceptMessage','acceptMessage','manual','interface','SIP/%s','channel','event','accept','EventManager','get','FaxInteraction','[FAXMESSAGE:REJECT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','RejectMessage','rejectMessage','reject','rejectmessage','create','CmContact','ContactId','findOne','AttachmentId','SendFax','FaxAccountId','/var/opt/motion2/server/files/attachments/%s','basename','download','join','root','server','files','attachments','Attachment','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','bluebird','util','path','sox','to-csv','ejs','lodash','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','redis','defaults','localhost','socket.io-emitter','./faxMessage.socket','jayson/promise','client','request','then'];(function(_0x130d82,_0x25f49b){var _0x112070=function(_0x5795ee){while(--_0x5795ee){_0x130d82['push'](_0x130d82['shift']());}};_0x112070(++_0x25f49b);}(_0x282b,0xec));var _0xb282=function(_0x535f62,_0xe6f8ee){_0x535f62=_0x535f62-0x0;var _0x4e5cfb=_0x282b[_0x535f62];return _0x4e5cfb;};'use strict';var pdf=require(_0xb282('0x0'));var emlformat=require(_0xb282('0x1'));var rimraf=require(_0xb282('0x2'));var zipdir=require(_0xb282('0x3'));var jsonpatch=require(_0xb282('0x4'));var rp=require('request-promise');var moment=require('moment');var BPromise=require(_0xb282('0x5'));var Mustache=require('mustache');var util=require(_0xb282('0x6'));var path=require(_0xb282('0x7'));var sox=require(_0xb282('0x8'));var csv=require(_0xb282('0x9'));var ejs=require(_0xb282('0xa'));var fs=require('fs');var _=require(_0xb282('0xb'));var squel=require('squel');var crypto=require('crypto');var jsforce=require(_0xb282('0xc'));var deskjs=require(_0xb282('0xd'));var toCsv=require('to-csv');var querystring=require(_0xb282('0xe'));var Papa=require(_0xb282('0xf'));var Redis=require(_0xb282('0x10'));var authService=require(_0xb282('0x11'));var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xb282('0x12'));var logger=require(_0xb282('0x13'))(_0xb282('0x14'));var utils=require(_0xb282('0x15'));var config=require(_0xb282('0x16'));var licenseUtil=require('../../config/license/util');var db=require('../../mysqldb')['db'];config[_0xb282('0x17')]=_[_0xb282('0x18')](config[_0xb282('0x17')],{'host':_0xb282('0x19'),'port':0x18eb});var socket=require(_0xb282('0x1a'))(new Redis(config['redis']));require(_0xb282('0x1b'))['register'](socket);var jayson=require(_0xb282('0x1c'));var client=jayson[_0xb282('0x1d')]['http']({'port':0x232c});var client9002=jayson['client']['http']({'port':0x232a});function respondWithRpcPromise(_0x13cea1,_0x350676,_0x7c20df,_0xbb182){return new BPromise(function(_0x438a05,_0x5307ed){var _0x191a31=_0xbb182||client;return _0x191a31[_0xb282('0x1e')](_0x13cea1,_0x7c20df)[_0xb282('0x1f')](function(_0x45b070){logger[_0xb282('0x20')]('FaxMessage,\x20%s,\x20%s',_0x350676,'request\x20sent');logger[_0xb282('0x21')](_0xb282('0x22'),_0x350676,'request\x20sent',JSON[_0xb282('0x23')](_0x45b070));if(_0x45b070[_0xb282('0x24')]){if(_0x45b070[_0xb282('0x24')][_0xb282('0x25')]===0x1f4){logger[_0xb282('0x24')]('FaxMessage,\x20%s,\x20%s',_0x350676,_0x45b070[_0xb282('0x24')][_0xb282('0x26')]);return _0x5307ed(_0x45b070[_0xb282('0x24')]['message']);}logger[_0xb282('0x24')](_0xb282('0x27'),_0x350676,_0x45b070[_0xb282('0x24')][_0xb282('0x26')]);return _0x438a05(_0x45b070[_0xb282('0x24')]['message']);}else{logger['info'](_0xb282('0x27'),_0x350676,_0xb282('0x28'));_0x438a05(_0x45b070['result']['message']);}})[_0xb282('0x29')](function(_0x114f77){logger[_0xb282('0x24')](_0xb282('0x27'),_0x350676,_0x114f77);_0x5307ed(_0x114f77);});});}function respondWithStatusCode(_0x211cc1,_0x2b1303){_0x2b1303=_0x2b1303||0xcc;return function(_0x5b1d3d){if(_0x5b1d3d){return _0x211cc1[_0xb282('0x2a')](_0x2b1303);}return _0x211cc1[_0xb282('0x2b')](_0x2b1303)['end']();};}function respondWithResult(_0x22d895,_0x38a1f8){_0x38a1f8=_0x38a1f8||0xc8;return function(_0x2a4491){if(_0x2a4491){return _0x22d895[_0xb282('0x2b')](_0x38a1f8)['json'](_0x2a4491);}};}function respondWithFilteredResult(_0x1520b1,_0x1fb89f){return function(_0xe337b8){if(_0xe337b8){var _0x433ad5=_0xe337b8['count'],_0x4cee93=_0x1fb89f[_0xb282('0x2c')],_0xfddd2e=_0x1fb89f[_0xb282('0x2c')]+_0x1fb89f[_0xb282('0x2d')],_0x22f657;if(_0xfddd2e>=_0x433ad5){_0xfddd2e=_0x433ad5;_0x22f657=0xc8;}else{_0x22f657=0xce;}_0x1520b1[_0xb282('0x2b')](_0x22f657);return _0x1520b1[_0xb282('0x2e')]('Content-Range',_0x4cee93+'-'+_0xfddd2e+'/'+_0x433ad5)[_0xb282('0x2f')](_0xe337b8);}return null;};}function patchUpdates(_0x4acd96){return function(_0x4b7660){try{jsonpatch[_0xb282('0x30')](_0x4b7660,_0x4acd96,!![]);}catch(_0x687829){return BPromise['reject'](_0x687829);}return _0x4b7660[_0xb282('0x31')]();};}function saveUpdates(_0x548bca,_0x26d6ff){return function(_0x2aff13){if(_0x2aff13){return _0x2aff13[_0xb282('0x32')](_0x548bca)[_0xb282('0x1f')](function(_0x1c58c2){return _0x1c58c2;});}return null;};}function removeEntity(_0x1b740c,_0x50bf75){return function(_0x15e083){if(_0x15e083){return _0x15e083[_0xb282('0x33')]()['then'](function(){_0x1b740c['status'](0xcc)[_0xb282('0x34')]();});}};}function handleEntityNotFound(_0x271643,_0x170527){return function(_0x50efa2){if(!_0x50efa2){_0x271643['sendStatus'](0x194);}return _0x50efa2;};}function handleError(_0x4ad54b,_0x27073b){_0x27073b=_0x27073b||0x1f4;return function(_0x2a7362){logger[_0xb282('0x24')](_0x2a7362[_0xb282('0x35')]);if(_0x2a7362[_0xb282('0x36')]){delete _0x2a7362[_0xb282('0x36')];}_0x4ad54b[_0xb282('0x2b')](_0x27073b)['send'](_0x2a7362);};}exports[_0xb282('0x37')]=function(_0x5c2d92,_0x439eb4){var _0x45f9d9={},_0x3514cf={},_0x4f6cf1={'count':0x0,'rows':[]};var _0x11a477=_['map'](db[_0xb282('0x38')][_0xb282('0x39')],function(_0x1deac2){return{'name':_0x1deac2[_0xb282('0x3a')],'type':_0x1deac2['type']['key']};});_0x3514cf[_0xb282('0x3b')]=_[_0xb282('0x3c')](_0x11a477,_0xb282('0x36'));_0x3514cf[_0xb282('0x3d')]=_['keys'](_0x5c2d92[_0xb282('0x3d')]);_0x3514cf['filters']=_[_0xb282('0x3e')](_0x3514cf[_0xb282('0x3b')],_0x3514cf['query']);_0x45f9d9[_0xb282('0x3f')]=_[_0xb282('0x3e')](_0x3514cf[_0xb282('0x3b')],qs[_0xb282('0x40')](_0x5c2d92[_0xb282('0x3d')][_0xb282('0x40')]));_0x45f9d9[_0xb282('0x3f')]=_0x45f9d9[_0xb282('0x3f')][_0xb282('0x41')]?_0x45f9d9[_0xb282('0x3f')]:_0x3514cf[_0xb282('0x3b')];if(!_0x5c2d92[_0xb282('0x3d')][_0xb282('0x42')](_0xb282('0x43'))){_0x45f9d9[_0xb282('0x2d')]=qs[_0xb282('0x2d')](_0x5c2d92[_0xb282('0x3d')][_0xb282('0x2d')]);_0x45f9d9['offset']=qs[_0xb282('0x2c')](_0x5c2d92['query'][_0xb282('0x2c')]);}_0x45f9d9[_0xb282('0x44')]=qs[_0xb282('0x45')](_0x5c2d92[_0xb282('0x3d')][_0xb282('0x45')]);_0x45f9d9[_0xb282('0x46')]=qs['filters'](_['pick'](_0x5c2d92[_0xb282('0x3d')],_0x3514cf['filters']),_0x11a477);if(_0x5c2d92[_0xb282('0x3d')][_0xb282('0x47')]){_0x45f9d9['where']=_[_0xb282('0x48')](_0x45f9d9[_0xb282('0x46')],{'$or':_[_0xb282('0x3c')](_0x11a477,function(_0x5189bc){if(_0x5189bc['type']!==_0xb282('0x49')){var _0x5abc74={};_0x5abc74[_0x5189bc[_0xb282('0x36')]]={'$like':'%'+_0x5c2d92[_0xb282('0x3d')][_0xb282('0x47')]+'%'};return _0x5abc74;}})});}_0x45f9d9=_[_0xb282('0x48')]({},_0x45f9d9,_0x5c2d92[_0xb282('0x4a')]);var _0x99a380={'where':_0x45f9d9['where']};return db[_0xb282('0x38')][_0xb282('0x4b')](_0x99a380)[_0xb282('0x1f')](function(_0x5862e5){_0x4f6cf1[_0xb282('0x4b')]=_0x5862e5;if(_0x5c2d92['query'][_0xb282('0x4c')]){_0x45f9d9['include']=[{'all':!![]}];}return db[_0xb282('0x38')]['findAll'](_0x45f9d9);})['then'](function(_0x54170e){_0x4f6cf1[_0xb282('0x4d')]=_0x54170e;return _0x4f6cf1;})[_0xb282('0x1f')](respondWithFilteredResult(_0x439eb4,_0x45f9d9))[_0xb282('0x29')](handleError(_0x439eb4,null));};exports[_0xb282('0x4e')]=function(_0x4a2d0e,_0x4825f7){var _0x57e527={'raw':!![],'where':{'id':_0x4a2d0e[_0xb282('0x4f')]['id']}},_0x40080e={};_0x40080e[_0xb282('0x3b')]=_[_0xb282('0x50')](db['FaxMessage'][_0xb282('0x39')]);_0x40080e[_0xb282('0x3d')]=_['keys'](_0x4a2d0e[_0xb282('0x3d')]);_0x40080e[_0xb282('0x51')]=_[_0xb282('0x3e')](_0x40080e[_0xb282('0x3b')],_0x40080e[_0xb282('0x3d')]);_0x57e527['attributes']=_[_0xb282('0x3e')](_0x40080e[_0xb282('0x3b')],qs[_0xb282('0x40')](_0x4a2d0e[_0xb282('0x3d')][_0xb282('0x40')]));_0x57e527[_0xb282('0x3f')]=_0x57e527['attributes'][_0xb282('0x41')]?_0x57e527['attributes']:_0x40080e[_0xb282('0x3b')];if(_0x4a2d0e[_0xb282('0x3d')]['includeAll']){_0x57e527[_0xb282('0x52')]=[{'all':!![]}];}_0x57e527=_[_0xb282('0x48')]({},_0x57e527,_0x4a2d0e[_0xb282('0x4a')]);return db['FaxMessage']['find'](_0x57e527)[_0xb282('0x1f')](handleEntityNotFound(_0x4825f7,null))[_0xb282('0x1f')](respondWithResult(_0x4825f7,null))[_0xb282('0x29')](handleError(_0x4825f7,null));};exports['update']=function(_0x2d3839,_0x50944f){if(_0x2d3839[_0xb282('0x53')]['id']){delete _0x2d3839[_0xb282('0x53')]['id'];}return db['FaxMessage'][_0xb282('0x54')]({'where':{'id':_0x2d3839['params']['id']}})[_0xb282('0x1f')](handleEntityNotFound(_0x50944f,null))[_0xb282('0x1f')](saveUpdates(_0x2d3839[_0xb282('0x53')],null))[_0xb282('0x1f')](respondWithResult(_0x50944f,null))[_0xb282('0x29')](handleError(_0x50944f,null));};exports[_0xb282('0x33')]=function(_0x54828e,_0x46cef8){return db['FaxMessage'][_0xb282('0x54')]({'where':{'id':_0x54828e[_0xb282('0x4f')]['id']}})['then'](handleEntityNotFound(_0x46cef8,null))['then'](removeEntity(_0x46cef8,null))[_0xb282('0x29')](handleError(_0x46cef8,null));};exports[_0xb282('0x55')]=function(_0x14b501,_0x5225d7){return db['FaxMessage'][_0xb282('0x55')]()[_0xb282('0x1f')](respondWithResult(_0x5225d7,null))[_0xb282('0x29')](handleError(_0x5225d7,null));};var interaction_log=require('../../config/logger')(_0xb282('0x56'));exports['accept']=function(_0x152e90,_0x1de487,_0x6b7f07){var _0x27bac8={'agent':{},'channel':_0xb282('0x57')};if(_0x152e90[_0xb282('0x53')]['id']){delete _0x152e90[_0xb282('0x53')]['id'];}_0x152e90['body'][_0xb282('0x58')]=!![];_0x152e90[_0xb282('0x53')][_0xb282('0x59')]=moment()['format']('YYYY-MM-DD\x20HH:mm:ss');_0x152e90[_0xb282('0x53')][_0xb282('0x5a')]=_0x152e90[_0xb282('0x53')]['UserId']||_0x152e90['user']['id'];_0x27bac8[_0xb282('0x5b')]['id']=_0x152e90[_0xb282('0x53')]['UserId'];return db[_0xb282('0x38')][_0xb282('0x54')]({'where':{'id':_0x152e90[_0xb282('0x4f')]['id'],'UserId':null},'include':[{'model':db['CmContact'],'as':_0xb282('0x5c')}]})[_0xb282('0x1f')](handleEntityNotFound(_0x1de487,null))['then'](saveUpdates(_0x152e90[_0xb282('0x53')],null))[_0xb282('0x1f')](function(_0x33b5ec){if(_0x33b5ec){_0x27bac8[_0xb282('0x26')]=_0x33b5ec['get']({'plain':!![]});return db['FaxInteraction'][_0xb282('0x54')]({'where':{'id':_0x33b5ec[_0xb282('0x5d')]}});}return null;})['then'](handleEntityNotFound(_0x1de487,null))[_0xb282('0x1f')](function(_0x1b0e1f){if(_0x1b0e1f){return _0x1b0e1f[_0xb282('0x32')]({'UserId':_0x152e90[_0xb282('0x53')][_0xb282('0x5a')],'read1stAt':_[_0xb282('0x5e')](_0x1b0e1f[_0xb282('0x5f')])?moment()[_0xb282('0x60')]('YYYY-MM-DD\x20HH:mm:ss'):undefined});}return null;})[_0xb282('0x1f')](function(_0xb22721){if(_0xb22721){_0x27bac8[_0xb282('0x61')]=_0xb22721['get']({'plain':!![]});interaction_log[_0xb282('0x20')](_0xb282('0x62'),_0x152e90['user']['id'],_0x152e90['user'][_0xb282('0x36')],_0x152e90[_0xb282('0x63')][_0xb282('0x64')],_0x27bac8[_0xb282('0x61')]['id'],_0x152e90[_0xb282('0x53')]?JSON[_0xb282('0x23')](_0x152e90[_0xb282('0x53')]):_0xb282('0x65'));return respondWithRpcPromise(_0xb282('0x66'),_0xb282('0x67'),_0x27bac8);}return null;})[_0xb282('0x1f')](function(_0x3a6712){if(_0x3a6712){if(_0x152e90[_0xb282('0x53')][_0xb282('0x68')]){_0x27bac8[_0xb282('0x26')][_0xb282('0x69')]=util['format'](_0xb282('0x6a'),_0x152e90[_0xb282('0x63')][_0xb282('0x36')]);_0x27bac8[_0xb282('0x26')][_0xb282('0x6b')]=_0x27bac8[_0xb282('0x6b')];_0x27bac8[_0xb282('0x26')][_0xb282('0x6c')]=_0xb282('0x6d');return respondWithRpcPromise(_0xb282('0x6e'),_0xb282('0x6e'),{'event':'acceptmessage','message':_0x27bac8[_0xb282('0x26')]},client9002)[_0xb282('0x1f')](function(){return _0x27bac8;});}return _0x27bac8;}return null;})[_0xb282('0x1f')](respondWithResult(_0x1de487,null))[_0xb282('0x29')](handleError(_0x1de487,null));};var interaction_log=require(_0xb282('0x13'))('fax-interactions');exports['reject']=function(_0x37432b,_0x21166a,_0x711d07){var _0x449adc={'agent':{},'channel':_0xb282('0x57')};if(_0x37432b[_0xb282('0x53')]['id']){delete _0x37432b[_0xb282('0x53')]['id'];}_0x37432b['body']['UserId']=_0x37432b[_0xb282('0x53')][_0xb282('0x5a')]||_0x37432b['user']['id'];_0x449adc['agent']['id']=_0x37432b[_0xb282('0x53')][_0xb282('0x5a')];return db[_0xb282('0x38')][_0xb282('0x54')]({'where':{'id':_0x37432b[_0xb282('0x4f')]['id'],'UserId':null}})[_0xb282('0x1f')](handleEntityNotFound(_0x21166a,null))[_0xb282('0x1f')](function(_0x502447){if(_0x502447){_0x449adc[_0xb282('0x26')]=_0x502447[_0xb282('0x6f')]({'plain':!![]});return db[_0xb282('0x70')][_0xb282('0x54')]({'where':{'id':_0x502447[_0xb282('0x5d')]}});}return null;})[_0xb282('0x1f')](handleEntityNotFound(_0x21166a,null))[_0xb282('0x1f')](function(_0x3c37e0){if(_0x3c37e0){_0x449adc[_0xb282('0x61')]=_0x3c37e0[_0xb282('0x6f')]({'plain':!![]});interaction_log['info'](_0xb282('0x71'),_0x37432b[_0xb282('0x63')]['id'],_0x37432b[_0xb282('0x63')][_0xb282('0x36')],_0x37432b[_0xb282('0x63')][_0xb282('0x64')],_0x449adc[_0xb282('0x61')]['id'],_0x37432b[_0xb282('0x53')]?JSON['stringify'](_0x37432b[_0xb282('0x53')]):_0xb282('0x65'));return respondWithRpcPromise(_0xb282('0x72'),_0xb282('0x73'),_0x449adc);}return null;})[_0xb282('0x1f')](function(_0x2cdceb){if(_0x2cdceb){_0x2cdceb['message'][_0xb282('0x69')]=util[_0xb282('0x60')](_0xb282('0x6a'),_0x37432b['user'][_0xb282('0x36')]);_0x2cdceb[_0xb282('0x26')]['channel']=_0x449adc[_0xb282('0x6b')];_0x2cdceb[_0xb282('0x26')][_0xb282('0x6c')]=_0xb282('0x74');respondWithRpcPromise(_0xb282('0x6e'),_0xb282('0x6e'),{'event':_0xb282('0x75'),'message':_0x2cdceb['message']},client9002);return _0x449adc;}return null;})['then'](respondWithResult(_0x21166a,null))[_0xb282('0x29')](handleError(_0x21166a,null));};exports['create']=function(_0x174db3,_0x45b772){var _0x3ca8d9;return db[_0xb282('0x38')][_0xb282('0x76')](_0x174db3['body'],{})[_0xb282('0x1f')](function(_0x1fb9c2){_0x3ca8d9=_0x1fb9c2;return db[_0xb282('0x77')]['findOne']({'where':{'id':_0x3ca8d9[_0xb282('0x78')]}});})[_0xb282('0x1f')](function(_0x37c951){if(_[_0xb282('0x5e')](_0x37c951)){return;}else{_0x3ca8d9[_0xb282('0x57')]=_0x37c951[_0xb282('0x57')];return db['Attachment'][_0xb282('0x79')]({'where':{'id':_0x3ca8d9[_0xb282('0x7a')]}});}})[_0xb282('0x1f')](function(_0x2b8ff2){return respondWithRpcPromise('SendFax',_0xb282('0x7b'),{'FaxAccountId':_[_0xb282('0x5e')](_0x174db3[_0xb282('0x53')])?undefined:_0x174db3[_0xb282('0x53')][_0xb282('0x7c')],'path':_[_0xb282('0x5e')](_0x2b8ff2)?undefined:util[_0xb282('0x60')](_0xb282('0x7d'),_0x2b8ff2[_0xb282('0x7e')]),'fax':_[_0xb282('0x5e')](_0x3ca8d9[_0xb282('0x57')])?undefined:_0x3ca8d9['fax'],'AttachmentId':_0x3ca8d9[_0xb282('0x7a')]},client9002);})[_0xb282('0x1f')](respondWithResult(_0x45b772,0xc9))['catch'](handleError(_0x45b772,null));};exports[_0xb282('0x7f')]=function(_0x401a3b,_0x357327){var _0x14deef=path[_0xb282('0x80')](config[_0xb282('0x81')],_0xb282('0x82'),_0xb282('0x83'),_0xb282('0x84'));return db[_0xb282('0x38')]['find']({'where':{'id':_0x401a3b[_0xb282('0x4f')]['id']},'include':[{'model':db[_0xb282('0x85')],'as':_0xb282('0x85')}]})[_0xb282('0x1f')](handleEntityNotFound(_0x357327,null))[_0xb282('0x1f')](function(_0x14ad32){if(_0x14ad32){return _0x357327[_0xb282('0x7f')](path[_0xb282('0x80')](_0x14deef,_0x14ad32[_0xb282('0x85')][_0xb282('0x7e')]));}})[_0xb282('0x29')](handleError(_0x357327,null));};
\ No newline at end of file
+var _0x71ff=['attributes','fields','hasOwnProperty','nolimit','sort','where','pick','filter','merge','options','include','findAll','rows','show','length','includeAll','find','update','body','params','describe','fax-interactions','accept','fax','read','YYYY-MM-DD\x20HH:mm:ss','UserId','user','get','FaxInteraction','FaxInteractionId','isNil','read1stAt','interaction','[FAXMESSAGE:ACCEPT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','role','null','AcceptMessage','acceptMessage','SELECT\x20*\x20FROM\x20cm_contacts\x20WHERE\x20id\x20=\x20','ContactId','sequelize','Sequelize','QueryTypes','SELECT','contact','email','internal','agent','SIP/%s','channel','event','EventManager','acceptmessage','reject','[FAXMESSAGE:REJECT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','RejectMessage','User','interface','motionChannel','create','CmContact','findOne','Attachment','SendFax','FaxAccountId','format','/var/opt/motion2/server/files/attachments/%s','basename','download','join','root','server','attachments','eml-format','request-promise','moment','bluebird','util','sox','ejs','fs-extra','lodash','squel','jsforce','desk.js','to-csv','papaparse','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','socket.io-emitter','./faxMessage.socket','jayson/promise','client','http','request','then','info','request\x20sent','debug','FaxMessage,\x20%s,\x20%s,\x20%s','stringify','error','code','FaxMessage,\x20%s,\x20%s','message','result','catch','sendStatus','end','json','offset','undefined','count','limit','status','set','Content-Range','apply','destroy','stack','name','index','FaxMessage','rawAttributes','fieldName','type','model','map','keys','query','filters','intersection'];(function(_0x352041,_0x170746){var _0x38be0b=function(_0x5b5e00){while(--_0x5b5e00){_0x352041['push'](_0x352041['shift']());}};_0x38be0b(++_0x170746);}(_0x71ff,0x1f4));var _0xf71f=function(_0x2cae8e,_0x32a809){_0x2cae8e=_0x2cae8e-0x0;var _0x59fd42=_0x71ff[_0x2cae8e];return _0x59fd42;};'use strict';var emlformat=require(_0xf71f('0x0'));var rimraf=require('rimraf');var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require(_0xf71f('0x1'));var moment=require(_0xf71f('0x2'));var BPromise=require(_0xf71f('0x3'));var Mustache=require('mustache');var util=require(_0xf71f('0x4'));var path=require('path');var sox=require(_0xf71f('0x5'));var csv=require('to-csv');var ejs=require(_0xf71f('0x6'));var fs=require('fs');var fs_extra=require(_0xf71f('0x7'));var _=require(_0xf71f('0x8'));var squel=require(_0xf71f('0x9'));var crypto=require('crypto');var jsforce=require(_0xf71f('0xa'));var deskjs=require(_0xf71f('0xb'));var toCsv=require(_0xf71f('0xc'));var querystring=require('querystring');var Papa=require(_0xf71f('0xd'));var Redis=require(_0xf71f('0xe'));var authService=require(_0xf71f('0xf'));var qs=require('../../components/parsers/qs');var as=require(_0xf71f('0x10'));var hardwareService=require('../../config/license/hardware');var logger=require(_0xf71f('0x11'))(_0xf71f('0x12'));var utils=require(_0xf71f('0x13'));var config=require(_0xf71f('0x14'));var licenseUtil=require(_0xf71f('0x15'));var db=require(_0xf71f('0x16'))['db'];config[_0xf71f('0x17')]=_[_0xf71f('0x18')](config[_0xf71f('0x17')],{'host':'localhost','port':0x18eb});var socket=require(_0xf71f('0x19'))(new Redis(config['redis']));require(_0xf71f('0x1a'))['register'](socket);var jayson=require(_0xf71f('0x1b'));var client=jayson[_0xf71f('0x1c')][_0xf71f('0x1d')]({'port':0x232c});var client9002=jayson[_0xf71f('0x1c')][_0xf71f('0x1d')]({'port':0x232a});function respondWithRpcPromise(_0x331b04,_0x32bbe9,_0x5aeb92,_0x29d3ad){return new BPromise(function(_0x424b0a,_0x3c0a5c){var _0x53bb93=_0x29d3ad||client;return _0x53bb93[_0xf71f('0x1e')](_0x331b04,_0x5aeb92)[_0xf71f('0x1f')](function(_0x2b9944){logger[_0xf71f('0x20')]('FaxMessage,\x20%s,\x20%s',_0x32bbe9,_0xf71f('0x21'));logger[_0xf71f('0x22')](_0xf71f('0x23'),_0x32bbe9,_0xf71f('0x21'),JSON[_0xf71f('0x24')](_0x2b9944));if(_0x2b9944['error']){if(_0x2b9944[_0xf71f('0x25')][_0xf71f('0x26')]===0x1f4){logger['error'](_0xf71f('0x27'),_0x32bbe9,_0x2b9944['error'][_0xf71f('0x28')]);return _0x3c0a5c(_0x2b9944[_0xf71f('0x25')][_0xf71f('0x28')]);}logger[_0xf71f('0x25')](_0xf71f('0x27'),_0x32bbe9,_0x2b9944[_0xf71f('0x25')]['message']);return _0x424b0a(_0x2b9944[_0xf71f('0x25')][_0xf71f('0x28')]);}else{logger[_0xf71f('0x20')](_0xf71f('0x27'),_0x32bbe9,_0xf71f('0x21'));_0x424b0a(_0x2b9944[_0xf71f('0x29')][_0xf71f('0x28')]);}})[_0xf71f('0x2a')](function(_0x35896e){logger[_0xf71f('0x25')](_0xf71f('0x27'),_0x32bbe9,_0x35896e);_0x3c0a5c(_0x35896e);});});}function respondWithStatusCode(_0x1a37ab,_0x5dc1b0){_0x5dc1b0=_0x5dc1b0||0xcc;return function(_0x31d272){if(_0x31d272){return _0x1a37ab[_0xf71f('0x2b')](_0x5dc1b0);}return _0x1a37ab['status'](_0x5dc1b0)[_0xf71f('0x2c')]();};}function respondWithResult(_0x1968af,_0x3eb8c0){_0x3eb8c0=_0x3eb8c0||0xc8;return function(_0x526e21){if(_0x526e21){return _0x1968af['status'](_0x3eb8c0)[_0xf71f('0x2d')](_0x526e21);}};}function respondWithFilteredResult(_0x3a7c0f,_0x47ccf9){return function(_0x3441eb){if(_0x3441eb){var _0x2f67c7=typeof _0x47ccf9[_0xf71f('0x2e')]==='undefined'&&typeof _0x47ccf9['limit']===_0xf71f('0x2f');var _0x19c8e2=_0x3441eb[_0xf71f('0x30')];var _0x258509=_0x2f67c7?0x0:_0x47ccf9[_0xf71f('0x2e')];var _0x26f3aa=_0x2f67c7?_0x3441eb['count']:_0x47ccf9[_0xf71f('0x2e')]+_0x47ccf9[_0xf71f('0x31')];var _0x25b3e4;if(_0x26f3aa>=_0x19c8e2){_0x26f3aa=_0x19c8e2;_0x25b3e4=0xc8;}else{_0x25b3e4=0xce;}_0x3a7c0f[_0xf71f('0x32')](_0x25b3e4);return _0x3a7c0f[_0xf71f('0x33')](_0xf71f('0x34'),_0x258509+'-'+_0x26f3aa+'/'+_0x19c8e2)[_0xf71f('0x2d')](_0x3441eb);}return null;};}function patchUpdates(_0x1d191e){return function(_0x551a55){try{jsonpatch[_0xf71f('0x35')](_0x551a55,_0x1d191e,!![]);}catch(_0x23819b){return BPromise['reject'](_0x23819b);}return _0x551a55['save']();};}function saveUpdates(_0x39768b,_0x40a3d8){return function(_0x398b8e){if(_0x398b8e){return _0x398b8e['update'](_0x39768b)['then'](function(_0x2c7d76){return _0x2c7d76;});}return null;};}function removeEntity(_0x56329a,_0x5d36d4){return function(_0x58d89c){if(_0x58d89c){return _0x58d89c[_0xf71f('0x36')]()['then'](function(){_0x56329a[_0xf71f('0x32')](0xcc)[_0xf71f('0x2c')]();});}};}function handleEntityNotFound(_0x1d3bb2,_0xb174be){return function(_0x11d963){if(!_0x11d963){_0x1d3bb2['sendStatus'](0x194);}return _0x11d963;};}function handleError(_0x174ff1,_0x58fef1){_0x58fef1=_0x58fef1||0x1f4;return function(_0x1da1b2){logger[_0xf71f('0x25')](_0x1da1b2[_0xf71f('0x37')]);if(_0x1da1b2[_0xf71f('0x38')]){delete _0x1da1b2[_0xf71f('0x38')];}_0x174ff1[_0xf71f('0x32')](_0x58fef1)['send'](_0x1da1b2);};}exports[_0xf71f('0x39')]=function(_0x9b1e69,_0x264f7c){var _0x56672e={},_0x47d493={},_0x24d911={'count':0x0,'rows':[]};var _0x4eaa29=_['map'](db[_0xf71f('0x3a')][_0xf71f('0x3b')],function(_0x1d6922){return{'name':_0x1d6922[_0xf71f('0x3c')],'type':_0x1d6922[_0xf71f('0x3d')]['key']};});_0x47d493[_0xf71f('0x3e')]=_[_0xf71f('0x3f')](_0x4eaa29,_0xf71f('0x38'));_0x47d493['query']=_[_0xf71f('0x40')](_0x9b1e69[_0xf71f('0x41')]);_0x47d493[_0xf71f('0x42')]=_[_0xf71f('0x43')](_0x47d493[_0xf71f('0x3e')],_0x47d493[_0xf71f('0x41')]);_0x56672e[_0xf71f('0x44')]=_[_0xf71f('0x43')](_0x47d493['model'],qs[_0xf71f('0x45')](_0x9b1e69[_0xf71f('0x41')][_0xf71f('0x45')]));_0x56672e[_0xf71f('0x44')]=_0x56672e[_0xf71f('0x44')]['length']?_0x56672e[_0xf71f('0x44')]:_0x47d493[_0xf71f('0x3e')];if(!_0x9b1e69[_0xf71f('0x41')][_0xf71f('0x46')](_0xf71f('0x47'))){_0x56672e[_0xf71f('0x31')]=qs[_0xf71f('0x31')](_0x9b1e69[_0xf71f('0x41')][_0xf71f('0x31')]);_0x56672e[_0xf71f('0x2e')]=qs[_0xf71f('0x2e')](_0x9b1e69[_0xf71f('0x41')][_0xf71f('0x2e')]);}_0x56672e['order']=qs['sort'](_0x9b1e69['query'][_0xf71f('0x48')]);_0x56672e[_0xf71f('0x49')]=qs[_0xf71f('0x42')](_[_0xf71f('0x4a')](_0x9b1e69[_0xf71f('0x41')],_0x47d493[_0xf71f('0x42')]),_0x4eaa29);if(_0x9b1e69[_0xf71f('0x41')][_0xf71f('0x4b')]){_0x56672e['where']=_[_0xf71f('0x4c')](_0x56672e[_0xf71f('0x49')],{'$or':_[_0xf71f('0x3f')](_0x4eaa29,function(_0x32dcf6){if(_0x32dcf6[_0xf71f('0x3d')]!=='VIRTUAL'){var _0x43c5ea={};_0x43c5ea[_0x32dcf6[_0xf71f('0x38')]]={'$like':'%'+_0x9b1e69[_0xf71f('0x41')][_0xf71f('0x4b')]+'%'};return _0x43c5ea;}})});}_0x56672e=_[_0xf71f('0x4c')]({},_0x56672e,_0x9b1e69[_0xf71f('0x4d')]);var _0x504a64={'where':_0x56672e[_0xf71f('0x49')]};return db[_0xf71f('0x3a')][_0xf71f('0x30')](_0x504a64)['then'](function(_0x51c7e0){_0x24d911['count']=_0x51c7e0;if(_0x9b1e69[_0xf71f('0x41')]['includeAll']){_0x56672e[_0xf71f('0x4e')]=[{'all':!![]}];}return db[_0xf71f('0x3a')][_0xf71f('0x4f')](_0x56672e);})[_0xf71f('0x1f')](function(_0x5bcccd){_0x24d911[_0xf71f('0x50')]=_0x5bcccd;return _0x24d911;})[_0xf71f('0x1f')](respondWithFilteredResult(_0x264f7c,_0x56672e))[_0xf71f('0x2a')](handleError(_0x264f7c,null));};exports[_0xf71f('0x51')]=function(_0x50ae20,_0xb13352){var _0x106dd0={'raw':!![],'where':{'id':_0x50ae20['params']['id']}},_0x1af481={};_0x1af481[_0xf71f('0x3e')]=_[_0xf71f('0x40')](db['FaxMessage'][_0xf71f('0x3b')]);_0x1af481[_0xf71f('0x41')]=_[_0xf71f('0x40')](_0x50ae20[_0xf71f('0x41')]);_0x1af481[_0xf71f('0x42')]=_[_0xf71f('0x43')](_0x1af481[_0xf71f('0x3e')],_0x1af481['query']);_0x106dd0[_0xf71f('0x44')]=_[_0xf71f('0x43')](_0x1af481[_0xf71f('0x3e')],qs[_0xf71f('0x45')](_0x50ae20[_0xf71f('0x41')][_0xf71f('0x45')]));_0x106dd0[_0xf71f('0x44')]=_0x106dd0['attributes'][_0xf71f('0x52')]?_0x106dd0[_0xf71f('0x44')]:_0x1af481[_0xf71f('0x3e')];if(_0x50ae20[_0xf71f('0x41')][_0xf71f('0x53')]){_0x106dd0['include']=[{'all':!![]}];}_0x106dd0=_[_0xf71f('0x4c')]({},_0x106dd0,_0x50ae20[_0xf71f('0x4d')]);return db[_0xf71f('0x3a')][_0xf71f('0x54')](_0x106dd0)[_0xf71f('0x1f')](handleEntityNotFound(_0xb13352,null))[_0xf71f('0x1f')](respondWithResult(_0xb13352,null))[_0xf71f('0x2a')](handleError(_0xb13352,null));};exports[_0xf71f('0x55')]=function(_0x18bad8,_0x584582){if(_0x18bad8['body']['id']){delete _0x18bad8[_0xf71f('0x56')]['id'];}return db['FaxMessage'][_0xf71f('0x54')]({'where':{'id':_0x18bad8['params']['id']}})[_0xf71f('0x1f')](handleEntityNotFound(_0x584582,null))[_0xf71f('0x1f')](saveUpdates(_0x18bad8[_0xf71f('0x56')],null))[_0xf71f('0x1f')](respondWithResult(_0x584582,null))[_0xf71f('0x2a')](handleError(_0x584582,null));};exports[_0xf71f('0x36')]=function(_0x79808e,_0x2ffcc8){return db[_0xf71f('0x3a')][_0xf71f('0x54')]({'where':{'id':_0x79808e[_0xf71f('0x57')]['id']}})[_0xf71f('0x1f')](handleEntityNotFound(_0x2ffcc8,null))['then'](removeEntity(_0x2ffcc8,null))[_0xf71f('0x2a')](handleError(_0x2ffcc8,null));};exports[_0xf71f('0x58')]=function(_0x1b096c,_0x86293a){return db[_0xf71f('0x3a')][_0xf71f('0x58')]()['then'](respondWithResult(_0x86293a,null))['catch'](handleError(_0x86293a,null));};var interaction_log=require(_0xf71f('0x11'))(_0xf71f('0x59'));exports[_0xf71f('0x5a')]=function(_0x4d33cf,_0x2d1ab8,_0x229b1f){var _0x173e57={'agent':{},'channel':_0xf71f('0x5b')};if(_0x4d33cf[_0xf71f('0x56')]['id']){delete _0x4d33cf[_0xf71f('0x56')]['id'];}_0x4d33cf[_0xf71f('0x56')][_0xf71f('0x5c')]=!![];_0x4d33cf[_0xf71f('0x56')]['readAt']=moment()['format'](_0xf71f('0x5d'));_0x4d33cf[_0xf71f('0x56')][_0xf71f('0x5e')]=_0x4d33cf[_0xf71f('0x56')][_0xf71f('0x5e')]||_0x4d33cf[_0xf71f('0x5f')]['id'];_0x173e57['agent']['id']=_0x4d33cf[_0xf71f('0x56')][_0xf71f('0x5e')];return db[_0xf71f('0x3a')][_0xf71f('0x54')]({'where':{'id':_0x4d33cf[_0xf71f('0x57')]['id'],'UserId':null}})[_0xf71f('0x1f')](handleEntityNotFound(_0x2d1ab8,null))[_0xf71f('0x1f')](saveUpdates(_0x4d33cf[_0xf71f('0x56')],null))[_0xf71f('0x1f')](function(_0x3f233f){if(_0x3f233f){_0x173e57[_0xf71f('0x28')]=_0x3f233f[_0xf71f('0x60')]({'plain':!![]});return db[_0xf71f('0x61')][_0xf71f('0x54')]({'where':{'id':_0x3f233f[_0xf71f('0x62')]}});}return null;})['then'](handleEntityNotFound(_0x2d1ab8,null))['then'](function(_0x4f9c89){if(_0x4f9c89){return _0x4f9c89['update']({'UserId':_0x4d33cf['body']['UserId'],'read1stAt':_[_0xf71f('0x63')](_0x4f9c89[_0xf71f('0x64')])?moment()['format'](_0xf71f('0x5d')):undefined});}return null;})['then'](function(_0x210d7a){if(_0x210d7a){_0x173e57[_0xf71f('0x65')]=_0x210d7a['get']({'plain':!![]});interaction_log[_0xf71f('0x20')](_0xf71f('0x66'),_0x4d33cf[_0xf71f('0x5f')]['id'],_0x4d33cf[_0xf71f('0x5f')]['name'],_0x4d33cf['user'][_0xf71f('0x67')],_0x173e57[_0xf71f('0x65')]['id'],_0x4d33cf[_0xf71f('0x56')]?JSON[_0xf71f('0x24')](_0x4d33cf['body']):_0xf71f('0x68'));return respondWithRpcPromise(_0xf71f('0x69'),_0xf71f('0x6a'),_0x173e57);}return null;})[_0xf71f('0x1f')](function(_0xff666e){var _0x1310ae=_0xf71f('0x6b')+_0xff666e[_0xf71f('0x28')][_0xf71f('0x6c')];return db[_0xf71f('0x6d')][_0xf71f('0x41')](_0x1310ae,{'type':db[_0xf71f('0x6e')][_0xf71f('0x6f')][_0xf71f('0x70')],'raw':!![]})[_0xf71f('0x1f')](function(_0x494857){return _0x494857;});})[_0xf71f('0x1f')](function(_0x8be0a3){if(_0x8be0a3){_0x173e57[_0xf71f('0x28')][_0xf71f('0x71')]=_0x8be0a3[0x0];if(!_0x4d33cf[_0xf71f('0x56')][_0xf71f('0x5e')])return;return db['User'][_0xf71f('0x54')]({'where':{'id':_0x4d33cf['body'][_0xf71f('0x5e')],'role':'agent'},'attributes':['id',_0xf71f('0x38'),'fullname',_0xf71f('0x72'),_0xf71f('0x73')],'raw':!![]});}return null;})[_0xf71f('0x1f')](function(_0x3e68db){if(!_0x3e68db)return null;_0x173e57[_0xf71f('0x28')][_0xf71f('0x74')]=_0x3e68db;return _0x173e57;})[_0xf71f('0x1f')](function(_0x513759){if(_0x513759){if(_0x4d33cf[_0xf71f('0x56')]['manual']){_0x173e57[_0xf71f('0x28')]['interface']=util['format'](_0xf71f('0x75'),_0x4d33cf[_0xf71f('0x5f')][_0xf71f('0x38')]);_0x173e57['message'][_0xf71f('0x76')]=_0x173e57[_0xf71f('0x76')];_0x173e57[_0xf71f('0x28')]['motionChannel']=_0x173e57[_0xf71f('0x76')];_0x173e57['message'][_0xf71f('0x77')]=_0xf71f('0x5a');return respondWithRpcPromise(_0xf71f('0x78'),_0xf71f('0x78'),{'event':_0xf71f('0x79'),'message':_0x173e57[_0xf71f('0x28')]},client9002)[_0xf71f('0x1f')](function(){return _0x173e57;});}return _0x173e57;}return null;})[_0xf71f('0x1f')](respondWithResult(_0x2d1ab8,null))[_0xf71f('0x2a')](handleError(_0x2d1ab8,null));};var interaction_log=require(_0xf71f('0x11'))(_0xf71f('0x59'));exports[_0xf71f('0x7a')]=function(_0x403148,_0x271bac,_0x33e64a){var _0x29cf85={'agent':{},'channel':'fax'};if(_0x403148['body']['id']){delete _0x403148[_0xf71f('0x56')]['id'];}_0x403148[_0xf71f('0x56')][_0xf71f('0x5e')]=_0x403148[_0xf71f('0x56')]['UserId']||_0x403148[_0xf71f('0x5f')]['id'];_0x29cf85[_0xf71f('0x74')]['id']=_0x403148[_0xf71f('0x56')]['UserId'];return db[_0xf71f('0x3a')]['find']({'where':{'id':_0x403148[_0xf71f('0x57')]['id'],'UserId':null}})[_0xf71f('0x1f')](handleEntityNotFound(_0x271bac,null))[_0xf71f('0x1f')](function(_0x3c4f4e){if(_0x3c4f4e){_0x29cf85['message']=_0x3c4f4e['get']({'plain':!![]});return db['FaxInteraction'][_0xf71f('0x54')]({'where':{'id':_0x3c4f4e[_0xf71f('0x62')]}});}return null;})[_0xf71f('0x1f')](handleEntityNotFound(_0x271bac,null))[_0xf71f('0x1f')](function(_0xf68073){if(_0xf68073){_0x29cf85['interaction']=_0xf68073['get']({'plain':!![]});interaction_log[_0xf71f('0x20')](_0xf71f('0x7b'),_0x403148[_0xf71f('0x5f')]['id'],_0x403148[_0xf71f('0x5f')][_0xf71f('0x38')],_0x403148[_0xf71f('0x5f')][_0xf71f('0x67')],_0x29cf85['interaction']['id'],_0x403148[_0xf71f('0x56')]?JSON[_0xf71f('0x24')](_0x403148[_0xf71f('0x56')]):_0xf71f('0x68'));return respondWithRpcPromise(_0xf71f('0x7c'),'rejectMessage',_0x29cf85);}return null;})[_0xf71f('0x1f')](function(_0x2a4282){var _0x52ccbb=_0xf71f('0x6b')+_0x2a4282[_0xf71f('0x28')][_0xf71f('0x6c')];return db[_0xf71f('0x6d')][_0xf71f('0x41')](_0x52ccbb,{'type':db['Sequelize'][_0xf71f('0x6f')][_0xf71f('0x70')],'raw':!![]})['then'](function(_0x2abe35){return _0x2abe35;});})[_0xf71f('0x1f')](function(_0x1c023a){if(_0x1c023a){_0x29cf85[_0xf71f('0x28')]['contact']=_0x1c023a[0x0];if(!_0x403148['body'][_0xf71f('0x5e')])return;return db[_0xf71f('0x7d')]['find']({'where':{'id':_0x403148[_0xf71f('0x56')][_0xf71f('0x5e')],'role':_0xf71f('0x74')},'attributes':['id',_0xf71f('0x38'),'fullname',_0xf71f('0x72'),_0xf71f('0x73')],'raw':!![]});}return null;})[_0xf71f('0x1f')](function(_0x2db7be){if(!_0x2db7be)return null;_0x29cf85['message'][_0xf71f('0x74')]=_0x2db7be;return _0x29cf85;})['then'](function(_0x574db7){if(_0x574db7){_0x574db7[_0xf71f('0x28')][_0xf71f('0x7e')]=util['format'](_0xf71f('0x75'),_0x403148[_0xf71f('0x5f')][_0xf71f('0x38')]);_0x574db7[_0xf71f('0x28')][_0xf71f('0x76')]=_0x29cf85['channel'];_0x574db7[_0xf71f('0x28')][_0xf71f('0x7f')]=_0x29cf85[_0xf71f('0x76')];_0x574db7['message'][_0xf71f('0x77')]=_0xf71f('0x7a');respondWithRpcPromise(_0xf71f('0x78'),_0xf71f('0x78'),{'event':'rejectmessage','message':_0x574db7[_0xf71f('0x28')]},client9002);return _0x29cf85;}return null;})[_0xf71f('0x1f')](respondWithResult(_0x271bac,null))['catch'](handleError(_0x271bac,null));};exports[_0xf71f('0x80')]=function(_0x2d0f77,_0x59c197){var _0x3bcc33;return db[_0xf71f('0x3a')]['create'](_0x2d0f77[_0xf71f('0x56')],{})['then'](function(_0x3d21f7){_0x3bcc33=_0x3d21f7;return db[_0xf71f('0x81')][_0xf71f('0x82')]({'where':{'id':_0x3bcc33[_0xf71f('0x6c')]}});})[_0xf71f('0x1f')](function(_0x178da8){if(_[_0xf71f('0x63')](_0x178da8)){return;}else{_0x3bcc33[_0xf71f('0x5b')]=_0x178da8['fax'];return db[_0xf71f('0x83')][_0xf71f('0x82')]({'where':{'id':_0x3bcc33['AttachmentId']}});}})[_0xf71f('0x1f')](function(_0x625632){return respondWithRpcPromise('SendFax',_0xf71f('0x84'),{'FaxAccountId':_[_0xf71f('0x63')](_0x2d0f77[_0xf71f('0x56')])?undefined:_0x2d0f77[_0xf71f('0x56')][_0xf71f('0x85')],'path':_['isNil'](_0x625632)?undefined:util[_0xf71f('0x86')](_0xf71f('0x87'),_0x625632[_0xf71f('0x88')]),'fax':_[_0xf71f('0x63')](_0x3bcc33[_0xf71f('0x5b')])?undefined:_0x3bcc33[_0xf71f('0x5b')],'AttachmentId':_0x3bcc33['AttachmentId']},client9002);})[_0xf71f('0x1f')](respondWithResult(_0x59c197,0xc9))[_0xf71f('0x2a')](handleError(_0x59c197,null));};exports[_0xf71f('0x89')]=function(_0xc3d6df,_0x79989){var _0xbbd56c=path[_0xf71f('0x8a')](config[_0xf71f('0x8b')],_0xf71f('0x8c'),'files',_0xf71f('0x8d'));return db[_0xf71f('0x3a')]['find']({'where':{'id':_0xc3d6df['params']['id']},'include':[{'model':db['Attachment'],'as':'Attachment'}]})[_0xf71f('0x1f')](handleEntityNotFound(_0x79989,null))[_0xf71f('0x1f')](function(_0xcc9482){if(_0xcc9482){return _0x79989['download'](path[_0xf71f('0x8a')](_0xbbd56c,_0xcc9482[_0xf71f('0x83')][_0xf71f('0x88')]));}})[_0xf71f('0x2a')](handleError(_0x79989,null));};
\ No newline at end of file