Built motion from commit 5b761a7b.|2.5.36
[motion2.git] / server / api / faxMessage / faxMessage.controller.js
index 2bf65b8..c2322bd 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xd824=['attributes','fields','length','hasOwnProperty','nolimit','limit','order','sort','where','filters','pick','merge','type','VIRTUAL','options','FaxMessage','includeAll','include','findAll','rows','show','params','find','update','body','describe','../../config/logger','fax-interactions','accept','fax','read','readAt','format','YYYY-MM-DD\x20HH:mm:ss','UserId','CmContact','Contact','get','FaxInteraction','isNil','interaction','user','null','acceptMessage','manual','interface','SIP/%s','channel','event','EventManager','acceptmessage','reject','agent','role','RejectMessage','rejectMessage','rejectmessage','create','findOne','Attachment','AttachmentId','FaxAccountId','basename','download','root','server','files','attachments','html-pdf','eml-format','fast-json-patch','request-promise','moment','bluebird','mustache','util','to-csv','squel','crypto','jsforce','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','api','../../config/utils','../../config/environment','redis','defaults','localhost','./faxMessage.socket','register','client','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','status','end','json','count','offset','set','apply','save','destroy','stack','name','send','map','rawAttributes','fieldName','model','keys','query','intersection'];(function(_0x2a5b9d,_0x15b6e3){var _0xfeb230=function(_0x354767){while(--_0x354767){_0x2a5b9d['push'](_0x2a5b9d['shift']());}};_0xfeb230(++_0x15b6e3);}(_0xd824,0xc2));var _0x4d82=function(_0x40a045,_0x516f0e){_0x40a045=_0x40a045-0x0;var _0x1a687c=_0xd824[_0x40a045];return _0x1a687c;};'use strict';var pdf=require(_0x4d82('0x0'));var emlformat=require(_0x4d82('0x1'));var rimraf=require('rimraf');var zipdir=require('zip-dir');var jsonpatch=require(_0x4d82('0x2'));var rp=require(_0x4d82('0x3'));var moment=require(_0x4d82('0x4'));var BPromise=require(_0x4d82('0x5'));var Mustache=require(_0x4d82('0x6'));var util=require(_0x4d82('0x7'));var path=require('path');var sox=require('sox');var csv=require(_0x4d82('0x8'));var ejs=require('ejs');var fs=require('fs');var _=require('lodash');var squel=require(_0x4d82('0x9'));var crypto=require(_0x4d82('0xa'));var jsforce=require(_0x4d82('0xb'));var deskjs=require('desk.js');var toCsv=require(_0x4d82('0x8'));var querystring=require('querystring');var Papa=require('papaparse');var Redis=require(_0x4d82('0xc'));var authService=require(_0x4d82('0xd'));var qs=require(_0x4d82('0xe'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x4d82('0xf'));var logger=require('../../config/logger')(_0x4d82('0x10'));var utils=require(_0x4d82('0x11'));var config=require(_0x4d82('0x12'));var licenseUtil=require('../../config/license/util');var db=require('../../mysqldb')['db'];config[_0x4d82('0x13')]=_[_0x4d82('0x14')](config[_0x4d82('0x13')],{'host':_0x4d82('0x15'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x4d82('0x13')]));require(_0x4d82('0x16'))[_0x4d82('0x17')](socket);var jayson=require('jayson/promise');var client=jayson[_0x4d82('0x18')]['http']({'port':0x232c});var client9002=jayson[_0x4d82('0x18')]['http']({'port':0x232a});function respondWithRpcPromise(_0x469e09,_0x496f3b,_0x474acf,_0xb1640d){return new BPromise(function(_0x461476,_0x1846e0){var _0x2648a8=_0xb1640d||client;return _0x2648a8[_0x4d82('0x19')](_0x469e09,_0x474acf)[_0x4d82('0x1a')](function(_0x217b72){logger[_0x4d82('0x1b')]('FaxMessage,\x20%s,\x20%s',_0x496f3b,_0x4d82('0x1c'));logger[_0x4d82('0x1d')](_0x4d82('0x1e'),_0x496f3b,_0x4d82('0x1c'),JSON[_0x4d82('0x1f')](_0x217b72));if(_0x217b72[_0x4d82('0x20')]){if(_0x217b72[_0x4d82('0x20')][_0x4d82('0x21')]===0x1f4){logger[_0x4d82('0x20')](_0x4d82('0x22'),_0x496f3b,_0x217b72[_0x4d82('0x20')]['message']);return _0x1846e0(_0x217b72[_0x4d82('0x20')][_0x4d82('0x23')]);}logger['error'](_0x4d82('0x22'),_0x496f3b,_0x217b72[_0x4d82('0x20')][_0x4d82('0x23')]);return _0x461476(_0x217b72[_0x4d82('0x20')][_0x4d82('0x23')]);}else{logger[_0x4d82('0x1b')](_0x4d82('0x22'),_0x496f3b,_0x4d82('0x1c'));_0x461476(_0x217b72[_0x4d82('0x24')][_0x4d82('0x23')]);}})[_0x4d82('0x25')](function(_0x395efc){logger[_0x4d82('0x20')](_0x4d82('0x22'),_0x496f3b,_0x395efc);_0x1846e0(_0x395efc);});});}function respondWithStatusCode(_0x1940ef,_0x4af6da){_0x4af6da=_0x4af6da||0xcc;return function(_0x5e0b03){if(_0x5e0b03){return _0x1940ef[_0x4d82('0x26')](_0x4af6da);}return _0x1940ef[_0x4d82('0x27')](_0x4af6da)[_0x4d82('0x28')]();};}function respondWithResult(_0x3348d9,_0x5cbd7e){_0x5cbd7e=_0x5cbd7e||0xc8;return function(_0x19d3a9){if(_0x19d3a9){return _0x3348d9[_0x4d82('0x27')](_0x5cbd7e)[_0x4d82('0x29')](_0x19d3a9);}};}function respondWithFilteredResult(_0x11d022,_0x5ce98b){return function(_0x4081f6){if(_0x4081f6){var _0x4a7444=_0x4081f6[_0x4d82('0x2a')],_0x4d9ac4=_0x5ce98b[_0x4d82('0x2b')],_0x487581=_0x5ce98b[_0x4d82('0x2b')]+_0x5ce98b['limit'],_0x52533b;if(_0x487581>=_0x4a7444){_0x487581=_0x4a7444;_0x52533b=0xc8;}else{_0x52533b=0xce;}_0x11d022[_0x4d82('0x27')](_0x52533b);return _0x11d022[_0x4d82('0x2c')]('Content-Range',_0x4d9ac4+'-'+_0x487581+'/'+_0x4a7444)['json'](_0x4081f6);}return null;};}function patchUpdates(_0x26b25b){return function(_0x46a058){try{jsonpatch[_0x4d82('0x2d')](_0x46a058,_0x26b25b,!![]);}catch(_0x175961){return BPromise['reject'](_0x175961);}return _0x46a058[_0x4d82('0x2e')]();};}function saveUpdates(_0x59cd4f,_0x266fe1){return function(_0x45c325){if(_0x45c325){return _0x45c325['update'](_0x59cd4f)['then'](function(_0x42071e){return _0x42071e;});}return null;};}function removeEntity(_0x3e04e2,_0x23156b){return function(_0x2e475d){if(_0x2e475d){return _0x2e475d[_0x4d82('0x2f')]()[_0x4d82('0x1a')](function(){_0x3e04e2[_0x4d82('0x27')](0xcc)[_0x4d82('0x28')]();});}};}function handleEntityNotFound(_0x26499c,_0x384fef){return function(_0x4f6d9a){if(!_0x4f6d9a){_0x26499c[_0x4d82('0x26')](0x194);}return _0x4f6d9a;};}function handleError(_0x2520cf,_0x34bd5f){_0x34bd5f=_0x34bd5f||0x1f4;return function(_0x5878c5){logger[_0x4d82('0x20')](_0x5878c5[_0x4d82('0x30')]);if(_0x5878c5['name']){delete _0x5878c5[_0x4d82('0x31')];}_0x2520cf[_0x4d82('0x27')](_0x34bd5f)[_0x4d82('0x32')](_0x5878c5);};}exports['index']=function(_0x66d780,_0x220f4f){var _0x591526={},_0x203f79={},_0x50bb5b={'count':0x0,'rows':[]};var _0x17e787=_[_0x4d82('0x33')](db['FaxMessage'][_0x4d82('0x34')],function(_0x57d9b5){return{'name':_0x57d9b5[_0x4d82('0x35')],'type':_0x57d9b5['type']['key']};});_0x203f79[_0x4d82('0x36')]=_['map'](_0x17e787,_0x4d82('0x31'));_0x203f79['query']=_[_0x4d82('0x37')](_0x66d780[_0x4d82('0x38')]);_0x203f79['filters']=_[_0x4d82('0x39')](_0x203f79['model'],_0x203f79[_0x4d82('0x38')]);_0x591526[_0x4d82('0x3a')]=_['intersection'](_0x203f79[_0x4d82('0x36')],qs['fields'](_0x66d780[_0x4d82('0x38')][_0x4d82('0x3b')]));_0x591526[_0x4d82('0x3a')]=_0x591526[_0x4d82('0x3a')][_0x4d82('0x3c')]?_0x591526[_0x4d82('0x3a')]:_0x203f79['model'];if(!_0x66d780[_0x4d82('0x38')][_0x4d82('0x3d')](_0x4d82('0x3e'))){_0x591526[_0x4d82('0x3f')]=qs[_0x4d82('0x3f')](_0x66d780[_0x4d82('0x38')][_0x4d82('0x3f')]);_0x591526['offset']=qs[_0x4d82('0x2b')](_0x66d780[_0x4d82('0x38')][_0x4d82('0x2b')]);}_0x591526[_0x4d82('0x40')]=qs[_0x4d82('0x41')](_0x66d780['query'][_0x4d82('0x41')]);_0x591526[_0x4d82('0x42')]=qs[_0x4d82('0x43')](_[_0x4d82('0x44')](_0x66d780[_0x4d82('0x38')],_0x203f79[_0x4d82('0x43')]),_0x17e787);if(_0x66d780[_0x4d82('0x38')]['filter']){_0x591526[_0x4d82('0x42')]=_[_0x4d82('0x45')](_0x591526['where'],{'$or':_[_0x4d82('0x33')](_0x17e787,function(_0x5b6eb3){if(_0x5b6eb3[_0x4d82('0x46')]!==_0x4d82('0x47')){var _0x5c46cd={};_0x5c46cd[_0x5b6eb3[_0x4d82('0x31')]]={'$like':'%'+_0x66d780[_0x4d82('0x38')]['filter']+'%'};return _0x5c46cd;}})});}_0x591526=_[_0x4d82('0x45')]({},_0x591526,_0x66d780[_0x4d82('0x48')]);var _0x41d9d9={'where':_0x591526['where']};return db[_0x4d82('0x49')][_0x4d82('0x2a')](_0x41d9d9)['then'](function(_0x56fc2b){_0x50bb5b[_0x4d82('0x2a')]=_0x56fc2b;if(_0x66d780[_0x4d82('0x38')][_0x4d82('0x4a')]){_0x591526[_0x4d82('0x4b')]=[{'all':!![]}];}return db[_0x4d82('0x49')][_0x4d82('0x4c')](_0x591526);})[_0x4d82('0x1a')](function(_0x4fd80c){_0x50bb5b[_0x4d82('0x4d')]=_0x4fd80c;return _0x50bb5b;})[_0x4d82('0x1a')](respondWithFilteredResult(_0x220f4f,_0x591526))[_0x4d82('0x25')](handleError(_0x220f4f,null));};exports[_0x4d82('0x4e')]=function(_0x50a85f,_0x5d3e60){var _0x59d92f={'raw':!![],'where':{'id':_0x50a85f[_0x4d82('0x4f')]['id']}},_0x4111e1={};_0x4111e1[_0x4d82('0x36')]=_[_0x4d82('0x37')](db[_0x4d82('0x49')][_0x4d82('0x34')]);_0x4111e1['query']=_[_0x4d82('0x37')](_0x50a85f[_0x4d82('0x38')]);_0x4111e1[_0x4d82('0x43')]=_[_0x4d82('0x39')](_0x4111e1[_0x4d82('0x36')],_0x4111e1[_0x4d82('0x38')]);_0x59d92f[_0x4d82('0x3a')]=_[_0x4d82('0x39')](_0x4111e1[_0x4d82('0x36')],qs['fields'](_0x50a85f[_0x4d82('0x38')][_0x4d82('0x3b')]));_0x59d92f[_0x4d82('0x3a')]=_0x59d92f[_0x4d82('0x3a')][_0x4d82('0x3c')]?_0x59d92f[_0x4d82('0x3a')]:_0x4111e1['model'];if(_0x50a85f['query'][_0x4d82('0x4a')]){_0x59d92f[_0x4d82('0x4b')]=[{'all':!![]}];}_0x59d92f=_[_0x4d82('0x45')]({},_0x59d92f,_0x50a85f[_0x4d82('0x48')]);return db[_0x4d82('0x49')][_0x4d82('0x50')](_0x59d92f)[_0x4d82('0x1a')](handleEntityNotFound(_0x5d3e60,null))[_0x4d82('0x1a')](respondWithResult(_0x5d3e60,null))[_0x4d82('0x25')](handleError(_0x5d3e60,null));};exports[_0x4d82('0x51')]=function(_0x367c82,_0x146407){if(_0x367c82['body']['id']){delete _0x367c82[_0x4d82('0x52')]['id'];}return db['FaxMessage']['find']({'where':{'id':_0x367c82[_0x4d82('0x4f')]['id']}})[_0x4d82('0x1a')](handleEntityNotFound(_0x146407,null))[_0x4d82('0x1a')](saveUpdates(_0x367c82['body'],null))[_0x4d82('0x1a')](respondWithResult(_0x146407,null))[_0x4d82('0x25')](handleError(_0x146407,null));};exports[_0x4d82('0x2f')]=function(_0x1625fb,_0x4aaa65){return db[_0x4d82('0x49')][_0x4d82('0x50')]({'where':{'id':_0x1625fb[_0x4d82('0x4f')]['id']}})[_0x4d82('0x1a')](handleEntityNotFound(_0x4aaa65,null))[_0x4d82('0x1a')](removeEntity(_0x4aaa65,null))['catch'](handleError(_0x4aaa65,null));};exports[_0x4d82('0x53')]=function(_0x3297ce,_0x1f9935){return db['FaxMessage'][_0x4d82('0x53')]()[_0x4d82('0x1a')](respondWithResult(_0x1f9935,null))[_0x4d82('0x25')](handleError(_0x1f9935,null));};var interaction_log=require(_0x4d82('0x54'))(_0x4d82('0x55'));exports[_0x4d82('0x56')]=function(_0x9a125a,_0x58b87c,_0x5dc2c7){var _0x2113b3={'agent':{},'channel':_0x4d82('0x57')};if(_0x9a125a[_0x4d82('0x52')]['id']){delete _0x9a125a['body']['id'];}_0x9a125a[_0x4d82('0x52')][_0x4d82('0x58')]=!![];_0x9a125a[_0x4d82('0x52')][_0x4d82('0x59')]=moment()[_0x4d82('0x5a')](_0x4d82('0x5b'));_0x9a125a[_0x4d82('0x52')][_0x4d82('0x5c')]=_0x9a125a[_0x4d82('0x52')][_0x4d82('0x5c')]||_0x9a125a['user']['id'];_0x2113b3['agent']['id']=_0x9a125a[_0x4d82('0x52')][_0x4d82('0x5c')];return db[_0x4d82('0x49')]['find']({'where':{'id':_0x9a125a[_0x4d82('0x4f')]['id'],'UserId':null},'include':[{'model':db[_0x4d82('0x5d')],'as':_0x4d82('0x5e')}]})[_0x4d82('0x1a')](handleEntityNotFound(_0x58b87c,null))[_0x4d82('0x1a')](saveUpdates(_0x9a125a[_0x4d82('0x52')],null))[_0x4d82('0x1a')](function(_0x2a890c){if(_0x2a890c){_0x2113b3['message']=_0x2a890c[_0x4d82('0x5f')]({'plain':!![]});return db[_0x4d82('0x60')][_0x4d82('0x50')]({'where':{'id':_0x2a890c['FaxInteractionId']}});}return null;})['then'](handleEntityNotFound(_0x58b87c,null))[_0x4d82('0x1a')](function(_0xc5b353){if(_0xc5b353){return _0xc5b353[_0x4d82('0x51')]({'UserId':_0x9a125a[_0x4d82('0x52')][_0x4d82('0x5c')],'read1stAt':_[_0x4d82('0x61')](_0xc5b353['read1stAt'])?moment()[_0x4d82('0x5a')](_0x4d82('0x5b')):undefined});}return null;})[_0x4d82('0x1a')](function(_0x5a405b){if(_0x5a405b){_0x2113b3[_0x4d82('0x62')]=_0x5a405b[_0x4d82('0x5f')]({'plain':!![]});interaction_log[_0x4d82('0x1b')]('[FAXMESSAGE:ACCEPT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s',_0x9a125a[_0x4d82('0x63')]['id'],_0x9a125a[_0x4d82('0x63')]['name'],_0x9a125a[_0x4d82('0x63')]['role'],_0x2113b3[_0x4d82('0x62')]['id'],_0x9a125a['body']?JSON['stringify'](_0x9a125a[_0x4d82('0x52')]):_0x4d82('0x64'));return respondWithRpcPromise('AcceptMessage',_0x4d82('0x65'),_0x2113b3);}return null;})['then'](function(_0x4f235f){if(_0x4f235f){if(_0x9a125a['body'][_0x4d82('0x66')]){_0x2113b3[_0x4d82('0x23')][_0x4d82('0x67')]=util[_0x4d82('0x5a')](_0x4d82('0x68'),_0x9a125a[_0x4d82('0x63')][_0x4d82('0x31')]);_0x2113b3[_0x4d82('0x23')][_0x4d82('0x69')]=_0x2113b3[_0x4d82('0x69')];_0x2113b3[_0x4d82('0x23')][_0x4d82('0x6a')]=_0x4d82('0x56');return respondWithRpcPromise(_0x4d82('0x6b'),_0x4d82('0x6b'),{'event':_0x4d82('0x6c'),'message':_0x2113b3[_0x4d82('0x23')]},client9002)[_0x4d82('0x1a')](function(){return _0x2113b3;});}return _0x2113b3;}return null;})['then'](respondWithResult(_0x58b87c,null))['catch'](handleError(_0x58b87c,null));};var interaction_log=require(_0x4d82('0x54'))('fax-interactions');exports[_0x4d82('0x6d')]=function(_0x47644d,_0x1934de,_0x27b75b){var _0x2daa19={'agent':{},'channel':_0x4d82('0x57')};if(_0x47644d['body']['id']){delete _0x47644d[_0x4d82('0x52')]['id'];}_0x47644d[_0x4d82('0x52')]['UserId']=_0x47644d[_0x4d82('0x52')][_0x4d82('0x5c')]||_0x47644d[_0x4d82('0x63')]['id'];_0x2daa19[_0x4d82('0x6e')]['id']=_0x47644d[_0x4d82('0x52')][_0x4d82('0x5c')];return db[_0x4d82('0x49')][_0x4d82('0x50')]({'where':{'id':_0x47644d['params']['id'],'UserId':null}})['then'](handleEntityNotFound(_0x1934de,null))['then'](function(_0x59aefd){if(_0x59aefd){_0x2daa19['message']=_0x59aefd[_0x4d82('0x5f')]({'plain':!![]});return db[_0x4d82('0x60')][_0x4d82('0x50')]({'where':{'id':_0x59aefd['FaxInteractionId']}});}return null;})[_0x4d82('0x1a')](handleEntityNotFound(_0x1934de,null))[_0x4d82('0x1a')](function(_0x40590d){if(_0x40590d){_0x2daa19[_0x4d82('0x62')]=_0x40590d[_0x4d82('0x5f')]({'plain':!![]});interaction_log['info']('[FAXMESSAGE:REJECT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s',_0x47644d[_0x4d82('0x63')]['id'],_0x47644d[_0x4d82('0x63')][_0x4d82('0x31')],_0x47644d[_0x4d82('0x63')][_0x4d82('0x6f')],_0x2daa19[_0x4d82('0x62')]['id'],_0x47644d['body']?JSON[_0x4d82('0x1f')](_0x47644d['body']):_0x4d82('0x64'));return respondWithRpcPromise(_0x4d82('0x70'),_0x4d82('0x71'),_0x2daa19);}return null;})[_0x4d82('0x1a')](function(_0x1e8e5d){if(_0x1e8e5d){_0x1e8e5d['message'][_0x4d82('0x67')]=util[_0x4d82('0x5a')](_0x4d82('0x68'),_0x47644d[_0x4d82('0x63')][_0x4d82('0x31')]);_0x1e8e5d[_0x4d82('0x23')][_0x4d82('0x69')]=_0x2daa19[_0x4d82('0x69')];_0x1e8e5d[_0x4d82('0x23')][_0x4d82('0x6a')]=_0x4d82('0x6d');respondWithRpcPromise('EventManager',_0x4d82('0x6b'),{'event':_0x4d82('0x72'),'message':_0x1e8e5d[_0x4d82('0x23')]},client9002);return _0x2daa19;}return null;})[_0x4d82('0x1a')](respondWithResult(_0x1934de,null))[_0x4d82('0x25')](handleError(_0x1934de,null));};exports[_0x4d82('0x73')]=function(_0x2c01ad,_0x5541f8){var _0x184e69;return db[_0x4d82('0x49')]['create'](_0x2c01ad[_0x4d82('0x52')],{})['then'](function(_0x634bfb){_0x184e69=_0x634bfb;return db['CmContact'][_0x4d82('0x74')]({'where':{'id':_0x184e69['ContactId']}});})[_0x4d82('0x1a')](function(_0xd083e1){if(_[_0x4d82('0x61')](_0xd083e1)){return;}else{_0x184e69['fax']=_0xd083e1[_0x4d82('0x57')];return db[_0x4d82('0x75')]['findOne']({'where':{'id':_0x184e69[_0x4d82('0x76')]}});}})[_0x4d82('0x1a')](function(_0x18cc5f){return respondWithRpcPromise('SendFax','SendFax',{'FaxAccountId':_[_0x4d82('0x61')](_0x2c01ad[_0x4d82('0x52')])?undefined:_0x2c01ad[_0x4d82('0x52')][_0x4d82('0x77')],'path':_[_0x4d82('0x61')](_0x18cc5f)?undefined:util[_0x4d82('0x5a')]('/var/opt/motion2/server/files/attachments/%s',_0x18cc5f[_0x4d82('0x78')]),'fax':_[_0x4d82('0x61')](_0x184e69['fax'])?undefined:_0x184e69[_0x4d82('0x57')],'AttachmentId':_0x184e69[_0x4d82('0x76')]},client9002);})[_0x4d82('0x1a')](respondWithResult(_0x5541f8,0xc9))['catch'](handleError(_0x5541f8,null));};exports[_0x4d82('0x79')]=function(_0x2f32f3,_0x11a37c){var _0x1ba673=path['join'](config[_0x4d82('0x7a')],_0x4d82('0x7b'),_0x4d82('0x7c'),_0x4d82('0x7d'));return db['FaxMessage'][_0x4d82('0x50')]({'where':{'id':_0x2f32f3['params']['id']},'include':[{'model':db['Attachment'],'as':_0x4d82('0x75')}]})[_0x4d82('0x1a')](handleEntityNotFound(_0x11a37c,null))[_0x4d82('0x1a')](function(_0x3f9408){if(_0x3f9408){return _0x11a37c[_0x4d82('0x79')](path['join'](_0x1ba673,_0x3f9408[_0x4d82('0x75')][_0x4d82('0x78')]));}})['catch'](handleError(_0x11a37c,null));};
\ No newline at end of file
+var _0x44ff=['get','FaxInteractionId','[FAXMESSAGE:ACCEPT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','user','role','interaction','null','acceptMessage','SELECT\x20*\x20FROM\x20cm_contacts\x20WHERE\x20id\x20=\x20','ContactId','sequelize','Sequelize','QueryTypes','SELECT','contact','User','agent','fullname','email','manual','interface','SIP/%s','channel','motionChannel','event','acceptmessage','[FAXMESSAGE:REJECT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','RejectMessage','rejectMessage','internal','EventManager','rejectmessage','create','isNil','Attachment','findOne','AttachmentId','SendFax','FaxAccountId','basename','root','files','download','join','eml-format','rimraf','fast-json-patch','request-promise','moment','bluebird','mustache','path','sox','to-csv','ejs','fs-extra','lodash','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','api','../../config/utils','../../config/environment','../../config/license/util','redis','defaults','localhost','socket.io-emitter','./faxMessage.socket','jayson/promise','client','http','request','info','FaxMessage,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','catch','sendStatus','status','end','json','offset','limit','undefined','count','set','Content-Range','apply','reject','save','update','then','destroy','stack','send','index','FaxMessage','rawAttributes','fieldName','type','map','name','query','filters','intersection','model','fields','attributes','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','options','includeAll','include','findAll','show','params','keys','length','find','body','describe','../../config/logger','fax-interactions','accept','fax','readAt','format','UserId'];(function(_0x5e25b1,_0x290128){var _0x2043f6=function(_0x1c4376){while(--_0x1c4376){_0x5e25b1['push'](_0x5e25b1['shift']());}};_0x2043f6(++_0x290128);}(_0x44ff,0x14c));var _0xf44f=function(_0x337229,_0x390e5e){_0x337229=_0x337229-0x0;var _0x5c639a=_0x44ff[_0x337229];return _0x5c639a;};'use strict';var emlformat=require(_0xf44f('0x0'));var rimraf=require(_0xf44f('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0xf44f('0x2'));var rp=require(_0xf44f('0x3'));var moment=require(_0xf44f('0x4'));var BPromise=require(_0xf44f('0x5'));var Mustache=require(_0xf44f('0x6'));var util=require('util');var path=require(_0xf44f('0x7'));var sox=require(_0xf44f('0x8'));var csv=require(_0xf44f('0x9'));var ejs=require(_0xf44f('0xa'));var fs=require('fs');var fs_extra=require(_0xf44f('0xb'));var _=require(_0xf44f('0xc'));var squel=require('squel');var crypto=require(_0xf44f('0xd'));var jsforce=require(_0xf44f('0xe'));var deskjs=require(_0xf44f('0xf'));var toCsv=require(_0xf44f('0x9'));var querystring=require(_0xf44f('0x10'));var Papa=require(_0xf44f('0x11'));var Redis=require(_0xf44f('0x12'));var authService=require(_0xf44f('0x13'));var qs=require(_0xf44f('0x14'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xf44f('0x15'));var logger=require('../../config/logger')(_0xf44f('0x16'));var utils=require(_0xf44f('0x17'));var config=require(_0xf44f('0x18'));var licenseUtil=require(_0xf44f('0x19'));var db=require('../../mysqldb')['db'];config[_0xf44f('0x1a')]=_[_0xf44f('0x1b')](config['redis'],{'host':_0xf44f('0x1c'),'port':0x18eb});var socket=require(_0xf44f('0x1d'))(new Redis(config['redis']));require(_0xf44f('0x1e'))['register'](socket);var jayson=require(_0xf44f('0x1f'));var client=jayson[_0xf44f('0x20')][_0xf44f('0x21')]({'port':0x232c});var client9002=jayson['client'][_0xf44f('0x21')]({'port':0x232a});function respondWithRpcPromise(_0x376b0e,_0x104283,_0x22157f,_0x1abbdc){return new BPromise(function(_0x1554dc,_0x58029a){var _0x1f567a=_0x1abbdc||client;return _0x1f567a[_0xf44f('0x22')](_0x376b0e,_0x22157f)['then'](function(_0x54f924){logger[_0xf44f('0x23')](_0xf44f('0x24'),_0x104283,_0xf44f('0x25'));logger['debug']('FaxMessage,\x20%s,\x20%s,\x20%s',_0x104283,_0xf44f('0x25'),JSON[_0xf44f('0x26')](_0x54f924));if(_0x54f924[_0xf44f('0x27')]){if(_0x54f924[_0xf44f('0x27')][_0xf44f('0x28')]===0x1f4){logger[_0xf44f('0x27')]('FaxMessage,\x20%s,\x20%s',_0x104283,_0x54f924['error'][_0xf44f('0x29')]);return _0x58029a(_0x54f924[_0xf44f('0x27')][_0xf44f('0x29')]);}logger['error'](_0xf44f('0x24'),_0x104283,_0x54f924[_0xf44f('0x27')][_0xf44f('0x29')]);return _0x1554dc(_0x54f924[_0xf44f('0x27')]['message']);}else{logger[_0xf44f('0x23')](_0xf44f('0x24'),_0x104283,'request\x20sent');_0x1554dc(_0x54f924['result'][_0xf44f('0x29')]);}})[_0xf44f('0x2a')](function(_0x1f657e){logger[_0xf44f('0x27')]('FaxMessage,\x20%s,\x20%s',_0x104283,_0x1f657e);_0x58029a(_0x1f657e);});});}function respondWithStatusCode(_0x110140,_0x17e72f){_0x17e72f=_0x17e72f||0xcc;return function(_0x437c81){if(_0x437c81){return _0x110140[_0xf44f('0x2b')](_0x17e72f);}return _0x110140[_0xf44f('0x2c')](_0x17e72f)[_0xf44f('0x2d')]();};}function respondWithResult(_0x5b5dc6,_0x4b3323){_0x4b3323=_0x4b3323||0xc8;return function(_0x4d1e18){if(_0x4d1e18){return _0x5b5dc6[_0xf44f('0x2c')](_0x4b3323)[_0xf44f('0x2e')](_0x4d1e18);}};}function respondWithFilteredResult(_0x2e0df4,_0x540e55){return function(_0x3e916a){if(_0x3e916a){var _0x23b6f3=typeof _0x540e55[_0xf44f('0x2f')]==='undefined'&&typeof _0x540e55[_0xf44f('0x30')]===_0xf44f('0x31');var _0x35eb4b=_0x3e916a['count'];var _0x40a432=_0x23b6f3?0x0:_0x540e55[_0xf44f('0x2f')];var _0x2d9aed=_0x23b6f3?_0x3e916a[_0xf44f('0x32')]:_0x540e55[_0xf44f('0x2f')]+_0x540e55[_0xf44f('0x30')];var _0x35bbbc;if(_0x2d9aed>=_0x35eb4b){_0x2d9aed=_0x35eb4b;_0x35bbbc=0xc8;}else{_0x35bbbc=0xce;}_0x2e0df4['status'](_0x35bbbc);return _0x2e0df4[_0xf44f('0x33')](_0xf44f('0x34'),_0x40a432+'-'+_0x2d9aed+'/'+_0x35eb4b)[_0xf44f('0x2e')](_0x3e916a);}return null;};}function patchUpdates(_0x51e0f7){return function(_0x30244c){try{jsonpatch[_0xf44f('0x35')](_0x30244c,_0x51e0f7,!![]);}catch(_0x146242){return BPromise[_0xf44f('0x36')](_0x146242);}return _0x30244c[_0xf44f('0x37')]();};}function saveUpdates(_0x32e77d,_0x434cc6){return function(_0x40a9ef){if(_0x40a9ef){return _0x40a9ef[_0xf44f('0x38')](_0x32e77d)[_0xf44f('0x39')](function(_0x3cfc23){return _0x3cfc23;});}return null;};}function removeEntity(_0x58bdb3,_0x1d971a){return function(_0x5adf51){if(_0x5adf51){return _0x5adf51[_0xf44f('0x3a')]()[_0xf44f('0x39')](function(){_0x58bdb3[_0xf44f('0x2c')](0xcc)['end']();});}};}function handleEntityNotFound(_0x2e8641,_0x3d55fe){return function(_0x3e1cd2){if(!_0x3e1cd2){_0x2e8641[_0xf44f('0x2b')](0x194);}return _0x3e1cd2;};}function handleError(_0x31095d,_0x3dbb31){_0x3dbb31=_0x3dbb31||0x1f4;return function(_0x452f83){logger[_0xf44f('0x27')](_0x452f83[_0xf44f('0x3b')]);if(_0x452f83['name']){delete _0x452f83['name'];}_0x31095d[_0xf44f('0x2c')](_0x3dbb31)[_0xf44f('0x3c')](_0x452f83);};}exports[_0xf44f('0x3d')]=function(_0x404011,_0x325bd9){var _0x4e5c13={},_0x147700={},_0x1d24e9={'count':0x0,'rows':[]};var _0x5363ed=_['map'](db[_0xf44f('0x3e')][_0xf44f('0x3f')],function(_0x5a0715){return{'name':_0x5a0715[_0xf44f('0x40')],'type':_0x5a0715[_0xf44f('0x41')]['key']};});_0x147700['model']=_[_0xf44f('0x42')](_0x5363ed,_0xf44f('0x43'));_0x147700['query']=_['keys'](_0x404011[_0xf44f('0x44')]);_0x147700[_0xf44f('0x45')]=_[_0xf44f('0x46')](_0x147700[_0xf44f('0x47')],_0x147700['query']);_0x4e5c13['attributes']=_[_0xf44f('0x46')](_0x147700[_0xf44f('0x47')],qs[_0xf44f('0x48')](_0x404011[_0xf44f('0x44')][_0xf44f('0x48')]));_0x4e5c13[_0xf44f('0x49')]=_0x4e5c13[_0xf44f('0x49')]['length']?_0x4e5c13['attributes']:_0x147700[_0xf44f('0x47')];if(!_0x404011[_0xf44f('0x44')]['hasOwnProperty'](_0xf44f('0x4a'))){_0x4e5c13[_0xf44f('0x30')]=qs[_0xf44f('0x30')](_0x404011[_0xf44f('0x44')][_0xf44f('0x30')]);_0x4e5c13[_0xf44f('0x2f')]=qs[_0xf44f('0x2f')](_0x404011['query']['offset']);}_0x4e5c13[_0xf44f('0x4b')]=qs[_0xf44f('0x4c')](_0x404011['query'][_0xf44f('0x4c')]);_0x4e5c13[_0xf44f('0x4d')]=qs[_0xf44f('0x45')](_[_0xf44f('0x4e')](_0x404011['query'],_0x147700[_0xf44f('0x45')]),_0x5363ed);if(_0x404011[_0xf44f('0x44')][_0xf44f('0x4f')]){_0x4e5c13[_0xf44f('0x4d')]=_[_0xf44f('0x50')](_0x4e5c13['where'],{'$or':_[_0xf44f('0x42')](_0x5363ed,function(_0x7d24b5){if(_0x7d24b5[_0xf44f('0x41')]!==_0xf44f('0x51')){var _0xcbaed={};_0xcbaed[_0x7d24b5['name']]={'$like':'%'+_0x404011[_0xf44f('0x44')][_0xf44f('0x4f')]+'%'};return _0xcbaed;}})});}_0x4e5c13=_[_0xf44f('0x50')]({},_0x4e5c13,_0x404011[_0xf44f('0x52')]);var _0x324d02={'where':_0x4e5c13[_0xf44f('0x4d')]};return db['FaxMessage'][_0xf44f('0x32')](_0x324d02)['then'](function(_0x118c1b){_0x1d24e9[_0xf44f('0x32')]=_0x118c1b;if(_0x404011['query'][_0xf44f('0x53')]){_0x4e5c13[_0xf44f('0x54')]=[{'all':!![]}];}return db[_0xf44f('0x3e')][_0xf44f('0x55')](_0x4e5c13);})[_0xf44f('0x39')](function(_0x14fe14){_0x1d24e9['rows']=_0x14fe14;return _0x1d24e9;})[_0xf44f('0x39')](respondWithFilteredResult(_0x325bd9,_0x4e5c13))[_0xf44f('0x2a')](handleError(_0x325bd9,null));};exports[_0xf44f('0x56')]=function(_0x490e42,_0x36921e){var _0x2b5752={'raw':!![],'where':{'id':_0x490e42[_0xf44f('0x57')]['id']}},_0x1f5fa5={};_0x1f5fa5[_0xf44f('0x47')]=_[_0xf44f('0x58')](db['FaxMessage']['rawAttributes']);_0x1f5fa5[_0xf44f('0x44')]=_['keys'](_0x490e42[_0xf44f('0x44')]);_0x1f5fa5[_0xf44f('0x45')]=_[_0xf44f('0x46')](_0x1f5fa5[_0xf44f('0x47')],_0x1f5fa5[_0xf44f('0x44')]);_0x2b5752[_0xf44f('0x49')]=_[_0xf44f('0x46')](_0x1f5fa5[_0xf44f('0x47')],qs[_0xf44f('0x48')](_0x490e42[_0xf44f('0x44')][_0xf44f('0x48')]));_0x2b5752[_0xf44f('0x49')]=_0x2b5752[_0xf44f('0x49')][_0xf44f('0x59')]?_0x2b5752['attributes']:_0x1f5fa5[_0xf44f('0x47')];if(_0x490e42['query']['includeAll']){_0x2b5752[_0xf44f('0x54')]=[{'all':!![]}];}_0x2b5752=_[_0xf44f('0x50')]({},_0x2b5752,_0x490e42['options']);return db[_0xf44f('0x3e')][_0xf44f('0x5a')](_0x2b5752)[_0xf44f('0x39')](handleEntityNotFound(_0x36921e,null))[_0xf44f('0x39')](respondWithResult(_0x36921e,null))[_0xf44f('0x2a')](handleError(_0x36921e,null));};exports['update']=function(_0x344139,_0xb09b29){if(_0x344139[_0xf44f('0x5b')]['id']){delete _0x344139[_0xf44f('0x5b')]['id'];}return db[_0xf44f('0x3e')][_0xf44f('0x5a')]({'where':{'id':_0x344139[_0xf44f('0x57')]['id']}})[_0xf44f('0x39')](handleEntityNotFound(_0xb09b29,null))[_0xf44f('0x39')](saveUpdates(_0x344139[_0xf44f('0x5b')],null))[_0xf44f('0x39')](respondWithResult(_0xb09b29,null))[_0xf44f('0x2a')](handleError(_0xb09b29,null));};exports[_0xf44f('0x3a')]=function(_0x5cb854,_0xd11037){return db[_0xf44f('0x3e')][_0xf44f('0x5a')]({'where':{'id':_0x5cb854['params']['id']}})[_0xf44f('0x39')](handleEntityNotFound(_0xd11037,null))[_0xf44f('0x39')](removeEntity(_0xd11037,null))['catch'](handleError(_0xd11037,null));};exports[_0xf44f('0x5c')]=function(_0x440f6d,_0x1378d1){return db[_0xf44f('0x3e')][_0xf44f('0x5c')]()['then'](respondWithResult(_0x1378d1,null))[_0xf44f('0x2a')](handleError(_0x1378d1,null));};var interaction_log=require(_0xf44f('0x5d'))(_0xf44f('0x5e'));exports[_0xf44f('0x5f')]=function(_0x16b379,_0x29a7d4,_0x6dbf9e){var _0x5c5716={'agent':{},'channel':_0xf44f('0x60')};if(_0x16b379[_0xf44f('0x5b')]['id']){delete _0x16b379[_0xf44f('0x5b')]['id'];}_0x16b379[_0xf44f('0x5b')]['read']=!![];_0x16b379['body'][_0xf44f('0x61')]=moment()[_0xf44f('0x62')]('YYYY-MM-DD\x20HH:mm:ss');_0x16b379[_0xf44f('0x5b')][_0xf44f('0x63')]=_0x16b379[_0xf44f('0x5b')][_0xf44f('0x63')]||_0x16b379['user']['id'];_0x5c5716['agent']['id']=_0x16b379[_0xf44f('0x5b')][_0xf44f('0x63')];return db['FaxMessage'][_0xf44f('0x5a')]({'where':{'id':_0x16b379[_0xf44f('0x57')]['id'],'UserId':null}})['then'](handleEntityNotFound(_0x29a7d4,null))['then'](saveUpdates(_0x16b379[_0xf44f('0x5b')],null))['then'](function(_0x4af685){if(_0x4af685){_0x5c5716[_0xf44f('0x29')]=_0x4af685[_0xf44f('0x64')]({'plain':!![]});return db['FaxInteraction'][_0xf44f('0x5a')]({'where':{'id':_0x4af685[_0xf44f('0x65')]}});}return null;})[_0xf44f('0x39')](handleEntityNotFound(_0x29a7d4,null))['then'](function(_0x3024c4){if(_0x3024c4){return _0x3024c4['update']({'UserId':_0x16b379[_0xf44f('0x5b')][_0xf44f('0x63')],'read1stAt':_['isNil'](_0x3024c4['read1stAt'])?moment()[_0xf44f('0x62')]('YYYY-MM-DD\x20HH:mm:ss'):undefined});}return null;})[_0xf44f('0x39')](function(_0x40932a){if(_0x40932a){_0x5c5716['interaction']=_0x40932a[_0xf44f('0x64')]({'plain':!![]});interaction_log[_0xf44f('0x23')](_0xf44f('0x66'),_0x16b379[_0xf44f('0x67')]['id'],_0x16b379[_0xf44f('0x67')][_0xf44f('0x43')],_0x16b379['user'][_0xf44f('0x68')],_0x5c5716[_0xf44f('0x69')]['id'],_0x16b379['body']?JSON[_0xf44f('0x26')](_0x16b379[_0xf44f('0x5b')]):_0xf44f('0x6a'));return respondWithRpcPromise('AcceptMessage',_0xf44f('0x6b'),_0x5c5716);}return null;})[_0xf44f('0x39')](function(_0x1a042f){var _0x5defe3=_0xf44f('0x6c')+_0x1a042f[_0xf44f('0x29')][_0xf44f('0x6d')];return db[_0xf44f('0x6e')][_0xf44f('0x44')](_0x5defe3,{'type':db[_0xf44f('0x6f')][_0xf44f('0x70')][_0xf44f('0x71')],'raw':!![]})[_0xf44f('0x39')](function(_0x4f9c59){return _0x4f9c59;});})[_0xf44f('0x39')](function(_0x47aa6a){if(_0x47aa6a){_0x5c5716['message'][_0xf44f('0x72')]=_0x47aa6a[0x0];if(!_0x16b379[_0xf44f('0x5b')][_0xf44f('0x63')])return;return db[_0xf44f('0x73')]['find']({'where':{'id':_0x16b379[_0xf44f('0x5b')]['UserId'],'role':_0xf44f('0x74')},'attributes':['id',_0xf44f('0x43'),_0xf44f('0x75'),_0xf44f('0x76'),'internal'],'raw':!![]});}return null;})['then'](function(_0x271a15){if(!_0x271a15)return null;_0x5c5716[_0xf44f('0x29')][_0xf44f('0x74')]=_0x271a15;return _0x5c5716;})[_0xf44f('0x39')](function(_0x5529cc){if(_0x5529cc){if(_0x16b379[_0xf44f('0x5b')][_0xf44f('0x77')]){_0x5c5716[_0xf44f('0x29')][_0xf44f('0x78')]=util[_0xf44f('0x62')](_0xf44f('0x79'),_0x16b379[_0xf44f('0x67')]['name']);_0x5c5716[_0xf44f('0x29')][_0xf44f('0x7a')]=_0x5c5716[_0xf44f('0x7a')];_0x5c5716[_0xf44f('0x29')][_0xf44f('0x7b')]=_0x5c5716[_0xf44f('0x7a')];_0x5c5716[_0xf44f('0x29')][_0xf44f('0x7c')]=_0xf44f('0x5f');return respondWithRpcPromise('EventManager','EventManager',{'event':_0xf44f('0x7d'),'message':_0x5c5716['message']},client9002)['then'](function(){return _0x5c5716;});}return _0x5c5716;}return null;})[_0xf44f('0x39')](respondWithResult(_0x29a7d4,null))[_0xf44f('0x2a')](handleError(_0x29a7d4,null));};var interaction_log=require(_0xf44f('0x5d'))(_0xf44f('0x5e'));exports[_0xf44f('0x36')]=function(_0x2b2ce5,_0x397f7f,_0x3f2273){var _0x3646cd={'agent':{},'channel':_0xf44f('0x60')};if(_0x2b2ce5[_0xf44f('0x5b')]['id']){delete _0x2b2ce5['body']['id'];}_0x2b2ce5[_0xf44f('0x5b')]['UserId']=_0x2b2ce5[_0xf44f('0x5b')]['UserId']||_0x2b2ce5[_0xf44f('0x67')]['id'];_0x3646cd[_0xf44f('0x74')]['id']=_0x2b2ce5['body'][_0xf44f('0x63')];return db[_0xf44f('0x3e')][_0xf44f('0x5a')]({'where':{'id':_0x2b2ce5[_0xf44f('0x57')]['id'],'UserId':null}})[_0xf44f('0x39')](handleEntityNotFound(_0x397f7f,null))['then'](function(_0x3060a7){if(_0x3060a7){_0x3646cd[_0xf44f('0x29')]=_0x3060a7[_0xf44f('0x64')]({'plain':!![]});return db['FaxInteraction'][_0xf44f('0x5a')]({'where':{'id':_0x3060a7[_0xf44f('0x65')]}});}return null;})[_0xf44f('0x39')](handleEntityNotFound(_0x397f7f,null))['then'](function(_0x1e099e){if(_0x1e099e){_0x3646cd[_0xf44f('0x69')]=_0x1e099e[_0xf44f('0x64')]({'plain':!![]});interaction_log[_0xf44f('0x23')](_0xf44f('0x7e'),_0x2b2ce5[_0xf44f('0x67')]['id'],_0x2b2ce5['user']['name'],_0x2b2ce5[_0xf44f('0x67')][_0xf44f('0x68')],_0x3646cd[_0xf44f('0x69')]['id'],_0x2b2ce5[_0xf44f('0x5b')]?JSON[_0xf44f('0x26')](_0x2b2ce5[_0xf44f('0x5b')]):_0xf44f('0x6a'));return respondWithRpcPromise(_0xf44f('0x7f'),_0xf44f('0x80'),_0x3646cd);}return null;})[_0xf44f('0x39')](function(_0x9d7f4a){var _0x387bfe=_0xf44f('0x6c')+_0x9d7f4a[_0xf44f('0x29')][_0xf44f('0x6d')];return db['sequelize']['query'](_0x387bfe,{'type':db[_0xf44f('0x6f')][_0xf44f('0x70')][_0xf44f('0x71')],'raw':!![]})[_0xf44f('0x39')](function(_0x9c52e7){return _0x9c52e7;});})[_0xf44f('0x39')](function(_0x283359){if(_0x283359){_0x3646cd[_0xf44f('0x29')]['contact']=_0x283359[0x0];if(!_0x2b2ce5['body'][_0xf44f('0x63')])return;return db['User'][_0xf44f('0x5a')]({'where':{'id':_0x2b2ce5[_0xf44f('0x5b')][_0xf44f('0x63')],'role':'agent'},'attributes':['id',_0xf44f('0x43'),_0xf44f('0x75'),'email',_0xf44f('0x81')],'raw':!![]});}return null;})[_0xf44f('0x39')](function(_0x31023d){if(!_0x31023d)return null;_0x3646cd[_0xf44f('0x29')][_0xf44f('0x74')]=_0x31023d;return _0x3646cd;})[_0xf44f('0x39')](function(_0x3672b4){if(_0x3672b4){_0x3672b4[_0xf44f('0x29')][_0xf44f('0x78')]=util[_0xf44f('0x62')](_0xf44f('0x79'),_0x2b2ce5[_0xf44f('0x67')][_0xf44f('0x43')]);_0x3672b4['message'][_0xf44f('0x7a')]=_0x3646cd['channel'];_0x3672b4[_0xf44f('0x29')][_0xf44f('0x7b')]=_0x3646cd[_0xf44f('0x7a')];_0x3672b4[_0xf44f('0x29')][_0xf44f('0x7c')]='reject';respondWithRpcPromise(_0xf44f('0x82'),_0xf44f('0x82'),{'event':_0xf44f('0x83'),'message':_0x3672b4[_0xf44f('0x29')]},client9002);return _0x3646cd;}return null;})[_0xf44f('0x39')](respondWithResult(_0x397f7f,null))['catch'](handleError(_0x397f7f,null));};exports['create']=function(_0x150792,_0x3d4436){var _0x349f46;return db['FaxMessage'][_0xf44f('0x84')](_0x150792[_0xf44f('0x5b')],{})[_0xf44f('0x39')](function(_0x51ed74){_0x349f46=_0x51ed74;return db['CmContact']['findOne']({'where':{'id':_0x349f46[_0xf44f('0x6d')]}});})['then'](function(_0x51199f){if(_[_0xf44f('0x85')](_0x51199f)){return;}else{_0x349f46[_0xf44f('0x60')]=_0x51199f[_0xf44f('0x60')];return db[_0xf44f('0x86')][_0xf44f('0x87')]({'where':{'id':_0x349f46[_0xf44f('0x88')]}});}})['then'](function(_0x349b74){return respondWithRpcPromise(_0xf44f('0x89'),_0xf44f('0x89'),{'FaxAccountId':_['isNil'](_0x150792[_0xf44f('0x5b')])?undefined:_0x150792['body'][_0xf44f('0x8a')],'path':_[_0xf44f('0x85')](_0x349b74)?undefined:util[_0xf44f('0x62')]('/var/opt/motion2/server/files/attachments/%s',_0x349b74[_0xf44f('0x8b')]),'fax':_[_0xf44f('0x85')](_0x349f46['fax'])?undefined:_0x349f46[_0xf44f('0x60')],'AttachmentId':_0x349f46['AttachmentId']},client9002);})[_0xf44f('0x39')](respondWithResult(_0x3d4436,0xc9))[_0xf44f('0x2a')](handleError(_0x3d4436,null));};exports['download']=function(_0x493b0f,_0x21a618){var _0x3e3a7b=path['join'](config[_0xf44f('0x8c')],'server',_0xf44f('0x8d'),'attachments');return db['FaxMessage'][_0xf44f('0x5a')]({'where':{'id':_0x493b0f[_0xf44f('0x57')]['id']},'include':[{'model':db['Attachment'],'as':_0xf44f('0x86')}]})[_0xf44f('0x39')](handleEntityNotFound(_0x21a618,null))['then'](function(_0x449771){if(_0x449771){return _0x21a618[_0xf44f('0x8e')](path[_0xf44f('0x8f')](_0x3e3a7b,_0x449771[_0xf44f('0x86')][_0xf44f('0x8b')]));}})[_0xf44f('0x2a')](handleError(_0x21a618,null));};
\ No newline at end of file