Built motion from commit bab6f49e.|2.6.17
[motion2.git] / server / api / faxMessage / faxMessage.controller.js
index a83ff88..1e073aa 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xb7d0=['QueryTypes','SELECT','contact','User','agent','fullname','email','internal','interface','SIP/%s','channel','event','EventManager','fax','FaxInteractionId','[FAXMESSAGE:REJECT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','role','ContactId','CmContact','findOne','Attachment','AttachmentId','SendFax','FaxAccountId','/var/opt/motion2/server/files/attachments/%s','basename','download','root','server','files','attachments','join','rimraf','zip-dir','fast-json-patch','moment','bluebird','mustache','util','path','sox','ejs','fs-extra','lodash','squel','jsforce','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','./faxMessage.socket','client','http','then','info','debug','stringify','error','code','FaxMessage,\x20%s,\x20%s','message','request\x20sent','result','catch','sendStatus','status','json','limit','undefined','count','offset','set','Content-Range','apply','reject','save','update','destroy','end','stack','name','send','index','rawAttributes','fieldName','type','key','map','query','keys','filters','model','attributes','intersection','fields','length','hasOwnProperty','order','sort','pick','filter','where','VIRTUAL','options','FaxMessage','includeAll','include','findAll','rows','params','merge','body','find','describe','accept','readAt','format','UserId','get','isNil','YYYY-MM-DD\x20HH:mm:ss','interaction','[FAXMESSAGE:ACCEPT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','user','null','acceptMessage','SELECT\x20*\x20FROM\x20cm_contacts\x20WHERE\x20id\x20=\x20','sequelize','Sequelize'];(function(_0x5b644e,_0x2e5e07){var _0x49c6bf=function(_0x3032d9){while(--_0x3032d9){_0x5b644e['push'](_0x5b644e['shift']());}};_0x49c6bf(++_0x2e5e07);}(_0xb7d0,0xab));var _0x0b7d=function(_0x417955,_0x4ed8c8){_0x417955=_0x417955-0x0;var _0x3a94ef=_0xb7d0[_0x417955];return _0x3a94ef;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x0b7d('0x0'));var zipdir=require(_0x0b7d('0x1'));var jsonpatch=require(_0x0b7d('0x2'));var rp=require('request-promise');var moment=require(_0x0b7d('0x3'));var BPromise=require(_0x0b7d('0x4'));var Mustache=require(_0x0b7d('0x5'));var util=require(_0x0b7d('0x6'));var path=require(_0x0b7d('0x7'));var sox=require(_0x0b7d('0x8'));var csv=require('to-csv');var ejs=require(_0x0b7d('0x9'));var fs=require('fs');var fs_extra=require(_0x0b7d('0xa'));var _=require(_0x0b7d('0xb'));var squel=require(_0x0b7d('0xc'));var crypto=require('crypto');var jsforce=require(_0x0b7d('0xd'));var deskjs=require('desk.js');var toCsv=require('to-csv');var querystring=require(_0x0b7d('0xe'));var Papa=require(_0x0b7d('0xf'));var Redis=require('ioredis');var authService=require(_0x0b7d('0x10'));var qs=require(_0x0b7d('0x11'));var as=require(_0x0b7d('0x12'));var hardwareService=require(_0x0b7d('0x13'));var logger=require(_0x0b7d('0x14'))(_0x0b7d('0x15'));var utils=require(_0x0b7d('0x16'));var config=require(_0x0b7d('0x17'));var licenseUtil=require(_0x0b7d('0x18'));var db=require(_0x0b7d('0x19'))['db'];config[_0x0b7d('0x1a')]=_[_0x0b7d('0x1b')](config[_0x0b7d('0x1a')],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require(_0x0b7d('0x1c'))['register'](socket);var jayson=require('jayson/promise');var client=jayson[_0x0b7d('0x1d')][_0x0b7d('0x1e')]({'port':0x232c});var client9002=jayson[_0x0b7d('0x1d')][_0x0b7d('0x1e')]({'port':0x232a});function respondWithRpcPromise(_0x893369,_0x21812c,_0x367246,_0x2d941f){return new BPromise(function(_0x3cdefb,_0x2857fd){var _0x41a9e5=_0x2d941f||client;return _0x41a9e5['request'](_0x893369,_0x367246)[_0x0b7d('0x1f')](function(_0x74fbfe){logger[_0x0b7d('0x20')]('FaxMessage,\x20%s,\x20%s',_0x21812c,'request\x20sent');logger[_0x0b7d('0x21')]('FaxMessage,\x20%s,\x20%s,\x20%s',_0x21812c,'request\x20sent',JSON[_0x0b7d('0x22')](_0x74fbfe));if(_0x74fbfe[_0x0b7d('0x23')]){if(_0x74fbfe['error'][_0x0b7d('0x24')]===0x1f4){logger[_0x0b7d('0x23')](_0x0b7d('0x25'),_0x21812c,_0x74fbfe[_0x0b7d('0x23')][_0x0b7d('0x26')]);return _0x2857fd(_0x74fbfe[_0x0b7d('0x23')][_0x0b7d('0x26')]);}logger['error'](_0x0b7d('0x25'),_0x21812c,_0x74fbfe[_0x0b7d('0x23')][_0x0b7d('0x26')]);return _0x3cdefb(_0x74fbfe[_0x0b7d('0x23')][_0x0b7d('0x26')]);}else{logger[_0x0b7d('0x20')](_0x0b7d('0x25'),_0x21812c,_0x0b7d('0x27'));_0x3cdefb(_0x74fbfe[_0x0b7d('0x28')][_0x0b7d('0x26')]);}})[_0x0b7d('0x29')](function(_0x266a86){logger['error'](_0x0b7d('0x25'),_0x21812c,_0x266a86);_0x2857fd(_0x266a86);});});}function respondWithStatusCode(_0x54978a,_0x455d5c){_0x455d5c=_0x455d5c||0xcc;return function(_0x5b1946){if(_0x5b1946){return _0x54978a[_0x0b7d('0x2a')](_0x455d5c);}return _0x54978a[_0x0b7d('0x2b')](_0x455d5c)['end']();};}function respondWithResult(_0x29a350,_0xb2f851){_0xb2f851=_0xb2f851||0xc8;return function(_0x16e487){if(_0x16e487){return _0x29a350[_0x0b7d('0x2b')](_0xb2f851)[_0x0b7d('0x2c')](_0x16e487);}};}function respondWithFilteredResult(_0x51c35b,_0x1eeb1f){return function(_0x162247){if(_0x162247){var _0x342611=typeof _0x1eeb1f['offset']==='undefined'&&typeof _0x1eeb1f[_0x0b7d('0x2d')]===_0x0b7d('0x2e');var _0x1b3586=_0x162247[_0x0b7d('0x2f')];var _0x2b32b9=_0x342611?0x0:_0x1eeb1f['offset'];var _0x3e0dba=_0x342611?_0x162247[_0x0b7d('0x2f')]:_0x1eeb1f[_0x0b7d('0x30')]+_0x1eeb1f[_0x0b7d('0x2d')];var _0x21a947;if(_0x3e0dba>=_0x1b3586){_0x3e0dba=_0x1b3586;_0x21a947=0xc8;}else{_0x21a947=0xce;}_0x51c35b[_0x0b7d('0x2b')](_0x21a947);return _0x51c35b[_0x0b7d('0x31')](_0x0b7d('0x32'),_0x2b32b9+'-'+_0x3e0dba+'/'+_0x1b3586)[_0x0b7d('0x2c')](_0x162247);}return null;};}function patchUpdates(_0xa01217){return function(_0x5c0c65){try{jsonpatch[_0x0b7d('0x33')](_0x5c0c65,_0xa01217,!![]);}catch(_0xbf4428){return BPromise[_0x0b7d('0x34')](_0xbf4428);}return _0x5c0c65[_0x0b7d('0x35')]();};}function saveUpdates(_0x73f7db,_0x5d3e2e){return function(_0x4241ba){if(_0x4241ba){return _0x4241ba[_0x0b7d('0x36')](_0x73f7db)[_0x0b7d('0x1f')](function(_0x3da54d){return _0x3da54d;});}return null;};}function removeEntity(_0x154524,_0x14d943){return function(_0x41e685){if(_0x41e685){return _0x41e685[_0x0b7d('0x37')]()[_0x0b7d('0x1f')](function(){_0x154524['status'](0xcc)[_0x0b7d('0x38')]();});}};}function handleEntityNotFound(_0x388ee6,_0x392da6){return function(_0x1a8569){if(!_0x1a8569){_0x388ee6['sendStatus'](0x194);}return _0x1a8569;};}function handleError(_0x111176,_0x6296be){_0x6296be=_0x6296be||0x1f4;return function(_0x20def9){logger[_0x0b7d('0x23')](_0x20def9[_0x0b7d('0x39')]);if(_0x20def9[_0x0b7d('0x3a')]){delete _0x20def9[_0x0b7d('0x3a')];}_0x111176['status'](_0x6296be)[_0x0b7d('0x3b')](_0x20def9);};}exports[_0x0b7d('0x3c')]=function(_0x546dae,_0x17a28c){var _0x59098d={},_0x3f3442={},_0x2ebd2c={'count':0x0,'rows':[]};var _0x3c04c1=_['map'](db['FaxMessage'][_0x0b7d('0x3d')],function(_0x479884){return{'name':_0x479884[_0x0b7d('0x3e')],'type':_0x479884[_0x0b7d('0x3f')][_0x0b7d('0x40')]};});_0x3f3442['model']=_[_0x0b7d('0x41')](_0x3c04c1,_0x0b7d('0x3a'));_0x3f3442[_0x0b7d('0x42')]=_[_0x0b7d('0x43')](_0x546dae['query']);_0x3f3442[_0x0b7d('0x44')]=_['intersection'](_0x3f3442[_0x0b7d('0x45')],_0x3f3442[_0x0b7d('0x42')]);_0x59098d[_0x0b7d('0x46')]=_[_0x0b7d('0x47')](_0x3f3442['model'],qs['fields'](_0x546dae[_0x0b7d('0x42')][_0x0b7d('0x48')]));_0x59098d[_0x0b7d('0x46')]=_0x59098d[_0x0b7d('0x46')][_0x0b7d('0x49')]?_0x59098d['attributes']:_0x3f3442['model'];if(!_0x546dae[_0x0b7d('0x42')][_0x0b7d('0x4a')]('nolimit')){_0x59098d[_0x0b7d('0x2d')]=qs['limit'](_0x546dae[_0x0b7d('0x42')][_0x0b7d('0x2d')]);_0x59098d['offset']=qs[_0x0b7d('0x30')](_0x546dae['query'][_0x0b7d('0x30')]);}_0x59098d[_0x0b7d('0x4b')]=qs[_0x0b7d('0x4c')](_0x546dae[_0x0b7d('0x42')]['sort']);_0x59098d['where']=qs[_0x0b7d('0x44')](_[_0x0b7d('0x4d')](_0x546dae[_0x0b7d('0x42')],_0x3f3442[_0x0b7d('0x44')]),_0x3c04c1);if(_0x546dae['query'][_0x0b7d('0x4e')]){_0x59098d[_0x0b7d('0x4f')]=_['merge'](_0x59098d[_0x0b7d('0x4f')],{'$or':_['map'](_0x3c04c1,function(_0x41b012){if(_0x41b012['type']!==_0x0b7d('0x50')){var _0x10e3c6={};_0x10e3c6[_0x41b012[_0x0b7d('0x3a')]]={'$like':'%'+_0x546dae[_0x0b7d('0x42')]['filter']+'%'};return _0x10e3c6;}})});}_0x59098d=_['merge']({},_0x59098d,_0x546dae[_0x0b7d('0x51')]);var _0x12d810={'where':_0x59098d[_0x0b7d('0x4f')]};return db[_0x0b7d('0x52')][_0x0b7d('0x2f')](_0x12d810)[_0x0b7d('0x1f')](function(_0x5d9803){_0x2ebd2c[_0x0b7d('0x2f')]=_0x5d9803;if(_0x546dae['query'][_0x0b7d('0x53')]){_0x59098d[_0x0b7d('0x54')]=[{'all':!![]}];}return db[_0x0b7d('0x52')][_0x0b7d('0x55')](_0x59098d);})[_0x0b7d('0x1f')](function(_0x343c2c){_0x2ebd2c[_0x0b7d('0x56')]=_0x343c2c;return _0x2ebd2c;})['then'](respondWithFilteredResult(_0x17a28c,_0x59098d))[_0x0b7d('0x29')](handleError(_0x17a28c,null));};exports['show']=function(_0x195c2c,_0x29d76b){var _0x36d34f={'raw':!![],'where':{'id':_0x195c2c[_0x0b7d('0x57')]['id']}},_0x17557b={};_0x17557b['model']=_[_0x0b7d('0x43')](db[_0x0b7d('0x52')][_0x0b7d('0x3d')]);_0x17557b['query']=_['keys'](_0x195c2c[_0x0b7d('0x42')]);_0x17557b['filters']=_[_0x0b7d('0x47')](_0x17557b[_0x0b7d('0x45')],_0x17557b[_0x0b7d('0x42')]);_0x36d34f[_0x0b7d('0x46')]=_[_0x0b7d('0x47')](_0x17557b[_0x0b7d('0x45')],qs[_0x0b7d('0x48')](_0x195c2c[_0x0b7d('0x42')][_0x0b7d('0x48')]));_0x36d34f[_0x0b7d('0x46')]=_0x36d34f[_0x0b7d('0x46')]['length']?_0x36d34f[_0x0b7d('0x46')]:_0x17557b[_0x0b7d('0x45')];if(_0x195c2c[_0x0b7d('0x42')][_0x0b7d('0x53')]){_0x36d34f[_0x0b7d('0x54')]=[{'all':!![]}];}_0x36d34f=_[_0x0b7d('0x58')]({},_0x36d34f,_0x195c2c['options']);return db[_0x0b7d('0x52')]['find'](_0x36d34f)['then'](handleEntityNotFound(_0x29d76b,null))[_0x0b7d('0x1f')](respondWithResult(_0x29d76b,null))[_0x0b7d('0x29')](handleError(_0x29d76b,null));};exports[_0x0b7d('0x36')]=function(_0xc83ef1,_0x3c7bfb){if(_0xc83ef1[_0x0b7d('0x59')]['id']){delete _0xc83ef1[_0x0b7d('0x59')]['id'];}return db[_0x0b7d('0x52')][_0x0b7d('0x5a')]({'where':{'id':_0xc83ef1[_0x0b7d('0x57')]['id']}})[_0x0b7d('0x1f')](handleEntityNotFound(_0x3c7bfb,null))[_0x0b7d('0x1f')](saveUpdates(_0xc83ef1[_0x0b7d('0x59')],null))['then'](respondWithResult(_0x3c7bfb,null))[_0x0b7d('0x29')](handleError(_0x3c7bfb,null));};exports[_0x0b7d('0x37')]=function(_0x1c8c58,_0x731c61){return db[_0x0b7d('0x52')]['find']({'where':{'id':_0x1c8c58['params']['id']}})[_0x0b7d('0x1f')](handleEntityNotFound(_0x731c61,null))[_0x0b7d('0x1f')](removeEntity(_0x731c61,null))[_0x0b7d('0x29')](handleError(_0x731c61,null));};exports[_0x0b7d('0x5b')]=function(_0x11191e,_0x494601){return db['FaxMessage']['describe']()[_0x0b7d('0x1f')](respondWithResult(_0x494601,null))[_0x0b7d('0x29')](handleError(_0x494601,null));};var interaction_log=require(_0x0b7d('0x14'))('fax-interactions');exports[_0x0b7d('0x5c')]=function(_0x42d045,_0x107809,_0x1a534b){var _0x13a71b={'agent':{},'channel':'fax'};if(_0x42d045[_0x0b7d('0x59')]['id']){delete _0x42d045[_0x0b7d('0x59')]['id'];}_0x42d045[_0x0b7d('0x59')]['read']=!![];_0x42d045['body'][_0x0b7d('0x5d')]=moment()[_0x0b7d('0x5e')]('YYYY-MM-DD\x20HH:mm:ss');_0x42d045[_0x0b7d('0x59')][_0x0b7d('0x5f')]=_0x42d045['body'][_0x0b7d('0x5f')]||_0x42d045['user']['id'];_0x13a71b['agent']['id']=_0x42d045[_0x0b7d('0x59')][_0x0b7d('0x5f')];return db[_0x0b7d('0x52')]['find']({'where':{'id':_0x42d045[_0x0b7d('0x57')]['id'],'UserId':null}})[_0x0b7d('0x1f')](handleEntityNotFound(_0x107809,null))['then'](saveUpdates(_0x42d045['body'],null))[_0x0b7d('0x1f')](function(_0x50f481){if(_0x50f481){_0x13a71b['message']=_0x50f481[_0x0b7d('0x60')]({'plain':!![]});return db['FaxInteraction'][_0x0b7d('0x5a')]({'where':{'id':_0x50f481['FaxInteractionId']}});}return null;})[_0x0b7d('0x1f')](handleEntityNotFound(_0x107809,null))[_0x0b7d('0x1f')](function(_0x34c038){if(_0x34c038){return _0x34c038[_0x0b7d('0x36')]({'UserId':_0x42d045[_0x0b7d('0x59')]['UserId'],'read1stAt':_[_0x0b7d('0x61')](_0x34c038['read1stAt'])?moment()[_0x0b7d('0x5e')](_0x0b7d('0x62')):undefined});}return null;})[_0x0b7d('0x1f')](function(_0x3546a9){if(_0x3546a9){_0x13a71b[_0x0b7d('0x63')]=_0x3546a9[_0x0b7d('0x60')]({'plain':!![]});interaction_log[_0x0b7d('0x20')](_0x0b7d('0x64'),_0x42d045[_0x0b7d('0x65')]['id'],_0x42d045[_0x0b7d('0x65')][_0x0b7d('0x3a')],_0x42d045[_0x0b7d('0x65')]['role'],_0x13a71b['interaction']['id'],_0x42d045[_0x0b7d('0x59')]?JSON['stringify'](_0x42d045['body']):_0x0b7d('0x66'));return respondWithRpcPromise('AcceptMessage',_0x0b7d('0x67'),_0x13a71b);}return null;})['then'](function(_0x4dc0ed){var _0x56695b=_0x0b7d('0x68')+_0x4dc0ed[_0x0b7d('0x26')]['ContactId'];return db[_0x0b7d('0x69')]['query'](_0x56695b,{'type':db[_0x0b7d('0x6a')][_0x0b7d('0x6b')][_0x0b7d('0x6c')],'raw':!![]})[_0x0b7d('0x1f')](function(_0x3a0a90){return _0x3a0a90;});})[_0x0b7d('0x1f')](function(_0x8f11f5){if(_0x8f11f5){_0x13a71b[_0x0b7d('0x26')][_0x0b7d('0x6d')]=_0x8f11f5[0x0];if(!_0x42d045[_0x0b7d('0x59')][_0x0b7d('0x5f')])return;return db[_0x0b7d('0x6e')]['find']({'where':{'id':_0x42d045['body'][_0x0b7d('0x5f')],'role':_0x0b7d('0x6f')},'attributes':['id',_0x0b7d('0x3a'),_0x0b7d('0x70'),_0x0b7d('0x71'),_0x0b7d('0x72')],'raw':!![]});}return null;})[_0x0b7d('0x1f')](function(_0x5b6c40){if(!_0x5b6c40)return null;_0x13a71b['message'][_0x0b7d('0x6f')]=_0x5b6c40;return _0x13a71b;})[_0x0b7d('0x1f')](function(_0x368b5a){if(_0x368b5a){if(_0x42d045[_0x0b7d('0x59')]['manual']){_0x13a71b[_0x0b7d('0x26')][_0x0b7d('0x73')]=util['format'](_0x0b7d('0x74'),_0x42d045[_0x0b7d('0x65')][_0x0b7d('0x3a')]);_0x13a71b['message'][_0x0b7d('0x75')]=_0x13a71b[_0x0b7d('0x75')];_0x13a71b['message']['motionChannel']=_0x13a71b['channel'];_0x13a71b[_0x0b7d('0x26')][_0x0b7d('0x76')]=_0x0b7d('0x5c');return respondWithRpcPromise(_0x0b7d('0x77'),'EventManager',{'event':'acceptmessage','message':_0x13a71b[_0x0b7d('0x26')]},client9002)[_0x0b7d('0x1f')](function(){return _0x13a71b;});}return _0x13a71b;}return null;})[_0x0b7d('0x1f')](respondWithResult(_0x107809,null))[_0x0b7d('0x29')](handleError(_0x107809,null));};var interaction_log=require(_0x0b7d('0x14'))('fax-interactions');exports[_0x0b7d('0x34')]=function(_0x53b563,_0x4930c0,_0x2de5fa){var _0x12671e={'agent':{},'channel':_0x0b7d('0x78')};if(_0x53b563['body']['id']){delete _0x53b563[_0x0b7d('0x59')]['id'];}_0x53b563[_0x0b7d('0x59')][_0x0b7d('0x5f')]=_0x53b563[_0x0b7d('0x59')][_0x0b7d('0x5f')]||_0x53b563[_0x0b7d('0x65')]['id'];_0x12671e[_0x0b7d('0x6f')]['id']=_0x53b563[_0x0b7d('0x59')][_0x0b7d('0x5f')];return db[_0x0b7d('0x52')]['find']({'where':{'id':_0x53b563[_0x0b7d('0x57')]['id'],'UserId':null}})['then'](handleEntityNotFound(_0x4930c0,null))[_0x0b7d('0x1f')](function(_0xbb080f){if(_0xbb080f){_0x12671e[_0x0b7d('0x26')]=_0xbb080f[_0x0b7d('0x60')]({'plain':!![]});return db['FaxInteraction'][_0x0b7d('0x5a')]({'where':{'id':_0xbb080f[_0x0b7d('0x79')]}});}return null;})[_0x0b7d('0x1f')](handleEntityNotFound(_0x4930c0,null))['then'](function(_0x4066e9){if(_0x4066e9){_0x12671e['interaction']=_0x4066e9[_0x0b7d('0x60')]({'plain':!![]});interaction_log[_0x0b7d('0x20')](_0x0b7d('0x7a'),_0x53b563[_0x0b7d('0x65')]['id'],_0x53b563['user'][_0x0b7d('0x3a')],_0x53b563[_0x0b7d('0x65')][_0x0b7d('0x7b')],_0x12671e[_0x0b7d('0x63')]['id'],_0x53b563[_0x0b7d('0x59')]?JSON[_0x0b7d('0x22')](_0x53b563[_0x0b7d('0x59')]):_0x0b7d('0x66'));return respondWithRpcPromise('RejectMessage','rejectMessage',_0x12671e);}return null;})[_0x0b7d('0x1f')](function(_0x131c7b){var _0x119350=_0x0b7d('0x68')+_0x131c7b[_0x0b7d('0x26')][_0x0b7d('0x7c')];return db[_0x0b7d('0x69')]['query'](_0x119350,{'type':db[_0x0b7d('0x6a')][_0x0b7d('0x6b')][_0x0b7d('0x6c')],'raw':!![]})[_0x0b7d('0x1f')](function(_0x3862ef){return _0x3862ef;});})[_0x0b7d('0x1f')](function(_0x56aab3){if(_0x56aab3){_0x12671e[_0x0b7d('0x26')]['contact']=_0x56aab3[0x0];if(!_0x53b563[_0x0b7d('0x59')][_0x0b7d('0x5f')])return;return db[_0x0b7d('0x6e')][_0x0b7d('0x5a')]({'where':{'id':_0x53b563[_0x0b7d('0x59')]['UserId'],'role':_0x0b7d('0x6f')},'attributes':['id','name',_0x0b7d('0x70'),_0x0b7d('0x71'),_0x0b7d('0x72')],'raw':!![]});}return null;})[_0x0b7d('0x1f')](function(_0x4caee4){if(!_0x4caee4)return null;_0x12671e[_0x0b7d('0x26')][_0x0b7d('0x6f')]=_0x4caee4;return _0x12671e;})[_0x0b7d('0x1f')](function(_0x27a493){if(_0x27a493){_0x27a493[_0x0b7d('0x26')]['interface']=util[_0x0b7d('0x5e')](_0x0b7d('0x74'),_0x53b563[_0x0b7d('0x65')][_0x0b7d('0x3a')]);_0x27a493['message'][_0x0b7d('0x75')]=_0x12671e[_0x0b7d('0x75')];_0x27a493[_0x0b7d('0x26')]['motionChannel']=_0x12671e['channel'];_0x27a493[_0x0b7d('0x26')][_0x0b7d('0x76')]='reject';respondWithRpcPromise(_0x0b7d('0x77'),_0x0b7d('0x77'),{'event':'rejectmessage','message':_0x27a493['message']},client9002);return _0x12671e;}return null;})[_0x0b7d('0x1f')](respondWithResult(_0x4930c0,null))[_0x0b7d('0x29')](handleError(_0x4930c0,null));};exports['create']=function(_0x2b1780,_0x487f2c){var _0x44600f;return db[_0x0b7d('0x52')]['create'](_0x2b1780['body'],{})['then'](function(_0x55671a){_0x44600f=_0x55671a;return db[_0x0b7d('0x7d')][_0x0b7d('0x7e')]({'where':{'id':_0x44600f[_0x0b7d('0x7c')]}});})['then'](function(_0x3f9069){if(_[_0x0b7d('0x61')](_0x3f9069)){return;}else{_0x44600f[_0x0b7d('0x78')]=_0x3f9069[_0x0b7d('0x78')];return db[_0x0b7d('0x7f')]['findOne']({'where':{'id':_0x44600f[_0x0b7d('0x80')]}});}})['then'](function(_0x5b81af){return respondWithRpcPromise(_0x0b7d('0x81'),_0x0b7d('0x81'),{'FaxAccountId':_[_0x0b7d('0x61')](_0x2b1780[_0x0b7d('0x59')])?undefined:_0x2b1780[_0x0b7d('0x59')][_0x0b7d('0x82')],'path':_[_0x0b7d('0x61')](_0x5b81af)?undefined:util[_0x0b7d('0x5e')](_0x0b7d('0x83'),_0x5b81af[_0x0b7d('0x84')]),'fax':_[_0x0b7d('0x61')](_0x44600f['fax'])?undefined:_0x44600f[_0x0b7d('0x78')],'AttachmentId':_0x44600f['AttachmentId']},client9002);})[_0x0b7d('0x1f')](respondWithResult(_0x487f2c,0xc9))[_0x0b7d('0x29')](handleError(_0x487f2c,null));};exports[_0x0b7d('0x85')]=function(_0x545558,_0x2a812b){var _0x57d89b=path['join'](config[_0x0b7d('0x86')],_0x0b7d('0x87'),_0x0b7d('0x88'),_0x0b7d('0x89'));return db[_0x0b7d('0x52')]['find']({'where':{'id':_0x545558[_0x0b7d('0x57')]['id']},'include':[{'model':db[_0x0b7d('0x7f')],'as':_0x0b7d('0x7f')}]})[_0x0b7d('0x1f')](handleEntityNotFound(_0x2a812b,null))[_0x0b7d('0x1f')](function(_0x50b88d){if(_0x50b88d){return _0x2a812b['download'](path[_0x0b7d('0x8a')](_0x57d89b,_0x50b88d[_0x0b7d('0x7f')][_0x0b7d('0x84')]));}})[_0x0b7d('0x29')](handleError(_0x2a812b,null));};
\ No newline at end of file
+var _0xf9cf=['EventManager','rejectmessage','create','findOne','ContactId','Attachment','AttachmentId','SendFax','FaxAccountId','/var/opt/motion2/server/files/attachments/%s','download','join','root','files','basename','rimraf','fast-json-patch','request-promise','moment','bluebird','mustache','util','sox','to-csv','ejs','lodash','squel','crypto','jsforce','querystring','papaparse','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','localhost','socket.io-emitter','./faxMessage.socket','register','jayson/promise','client','http','request','then','info','request\x20sent','debug','stringify','code','error','FaxMessage,\x20%s,\x20%s','message','result','catch','sendStatus','status','end','offset','undefined','count','limit','json','reject','update','destroy','stack','name','index','map','FaxMessage','rawAttributes','type','model','query','keys','filters','attributes','intersection','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','options','includeAll','rows','show','params','include','find','body','describe','fax-interactions','accept','fax','read','readAt','format','YYYY-MM-DD\x20HH:mm:ss','UserId','user','agent','get','FaxInteractionId','isNil','read1stAt','[FAXMESSAGE:ACCEPT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','role','interaction','null','AcceptMessage','acceptMessage','sequelize','SELECT','contact','User','fullname','email','internal','manual','SIP/%s','channel','motionChannel','FaxInteraction','[FAXMESSAGE:REJECT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','RejectMessage','rejectMessage','SELECT\x20*\x20FROM\x20cm_contacts\x20WHERE\x20id\x20=\x20','Sequelize','QueryTypes','interface'];(function(_0x59aa93,_0x46ff65){var _0x3d2428=function(_0x201c56){while(--_0x201c56){_0x59aa93['push'](_0x59aa93['shift']());}};_0x3d2428(++_0x46ff65);}(_0xf9cf,0x1b9));var _0xff9c=function(_0xf47ff3,_0x2439eb){_0xf47ff3=_0xf47ff3-0x0;var _0x476dde=_0xf9cf[_0xf47ff3];return _0x476dde;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0xff9c('0x0'));var zipdir=require('zip-dir');var jsonpatch=require(_0xff9c('0x1'));var rp=require(_0xff9c('0x2'));var moment=require(_0xff9c('0x3'));var BPromise=require(_0xff9c('0x4'));var Mustache=require(_0xff9c('0x5'));var util=require(_0xff9c('0x6'));var path=require('path');var sox=require(_0xff9c('0x7'));var csv=require(_0xff9c('0x8'));var ejs=require(_0xff9c('0x9'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0xff9c('0xa'));var squel=require(_0xff9c('0xb'));var crypto=require(_0xff9c('0xc'));var jsforce=require(_0xff9c('0xd'));var deskjs=require('desk.js');var toCsv=require('to-csv');var querystring=require(_0xff9c('0xe'));var Papa=require(_0xff9c('0xf'));var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require('../../components/parsers/qs');var as=require(_0xff9c('0x10'));var hardwareService=require(_0xff9c('0x11'));var logger=require(_0xff9c('0x12'))(_0xff9c('0x13'));var utils=require(_0xff9c('0x14'));var config=require(_0xff9c('0x15'));var licenseUtil=require(_0xff9c('0x16'));var db=require(_0xff9c('0x17'))['db'];config[_0xff9c('0x18')]=_['defaults'](config[_0xff9c('0x18')],{'host':_0xff9c('0x19'),'port':0x18eb});var socket=require(_0xff9c('0x1a'))(new Redis(config[_0xff9c('0x18')]));require(_0xff9c('0x1b'))[_0xff9c('0x1c')](socket);var jayson=require(_0xff9c('0x1d'));var client=jayson['client']['http']({'port':0x232c});var client9002=jayson[_0xff9c('0x1e')][_0xff9c('0x1f')]({'port':0x232a});function respondWithRpcPromise(_0x2af068,_0x189484,_0x3b0ea3,_0xd19ba4){return new BPromise(function(_0x254a22,_0x2144ab){var _0x4ab37f=_0xd19ba4||client;return _0x4ab37f[_0xff9c('0x20')](_0x2af068,_0x3b0ea3)[_0xff9c('0x21')](function(_0x497425){logger[_0xff9c('0x22')]('FaxMessage,\x20%s,\x20%s',_0x189484,_0xff9c('0x23'));logger[_0xff9c('0x24')]('FaxMessage,\x20%s,\x20%s,\x20%s',_0x189484,'request\x20sent',JSON[_0xff9c('0x25')](_0x497425));if(_0x497425['error']){if(_0x497425['error'][_0xff9c('0x26')]===0x1f4){logger[_0xff9c('0x27')](_0xff9c('0x28'),_0x189484,_0x497425[_0xff9c('0x27')]['message']);return _0x2144ab(_0x497425[_0xff9c('0x27')]['message']);}logger[_0xff9c('0x27')]('FaxMessage,\x20%s,\x20%s',_0x189484,_0x497425[_0xff9c('0x27')]['message']);return _0x254a22(_0x497425['error'][_0xff9c('0x29')]);}else{logger[_0xff9c('0x22')]('FaxMessage,\x20%s,\x20%s',_0x189484,'request\x20sent');_0x254a22(_0x497425[_0xff9c('0x2a')][_0xff9c('0x29')]);}})[_0xff9c('0x2b')](function(_0x221495){logger[_0xff9c('0x27')]('FaxMessage,\x20%s,\x20%s',_0x189484,_0x221495);_0x2144ab(_0x221495);});});}function respondWithStatusCode(_0x23bc4a,_0x46c9cc){_0x46c9cc=_0x46c9cc||0xcc;return function(_0x4cf078){if(_0x4cf078){return _0x23bc4a[_0xff9c('0x2c')](_0x46c9cc);}return _0x23bc4a[_0xff9c('0x2d')](_0x46c9cc)[_0xff9c('0x2e')]();};}function respondWithResult(_0x272a8b,_0x2854df){_0x2854df=_0x2854df||0xc8;return function(_0xbfb2d6){if(_0xbfb2d6){return _0x272a8b[_0xff9c('0x2d')](_0x2854df)['json'](_0xbfb2d6);}};}function respondWithFilteredResult(_0x527305,_0x2b4dcb){return function(_0x160922){if(_0x160922){var _0x6ac171=typeof _0x2b4dcb[_0xff9c('0x2f')]===_0xff9c('0x30')&&typeof _0x2b4dcb['limit']==='undefined';var _0x28bf6e=_0x160922['count'];var _0x1b140d=_0x6ac171?0x0:_0x2b4dcb['offset'];var _0x2e10c9=_0x6ac171?_0x160922[_0xff9c('0x31')]:_0x2b4dcb['offset']+_0x2b4dcb[_0xff9c('0x32')];var _0x1d6627;if(_0x2e10c9>=_0x28bf6e){_0x2e10c9=_0x28bf6e;_0x1d6627=0xc8;}else{_0x1d6627=0xce;}_0x527305['status'](_0x1d6627);return _0x527305['set']('Content-Range',_0x1b140d+'-'+_0x2e10c9+'/'+_0x28bf6e)[_0xff9c('0x33')](_0x160922);}return null;};}function patchUpdates(_0x3b05e0){return function(_0x1338b7){try{jsonpatch['apply'](_0x1338b7,_0x3b05e0,!![]);}catch(_0x177e62){return BPromise[_0xff9c('0x34')](_0x177e62);}return _0x1338b7['save']();};}function saveUpdates(_0x35e904,_0x5c1602){return function(_0x4204e3){if(_0x4204e3){return _0x4204e3[_0xff9c('0x35')](_0x35e904)[_0xff9c('0x21')](function(_0x3ec2d2){return _0x3ec2d2;});}return null;};}function removeEntity(_0x161d4e,_0x206f3b){return function(_0x2c451a){if(_0x2c451a){return _0x2c451a[_0xff9c('0x36')]()['then'](function(){_0x161d4e[_0xff9c('0x2d')](0xcc)['end']();});}};}function handleEntityNotFound(_0x3099d3,_0x437b67){return function(_0x451b93){if(!_0x451b93){_0x3099d3[_0xff9c('0x2c')](0x194);}return _0x451b93;};}function handleError(_0x41dee9,_0x308080){_0x308080=_0x308080||0x1f4;return function(_0x3a0a5e){logger[_0xff9c('0x27')](_0x3a0a5e[_0xff9c('0x37')]);if(_0x3a0a5e[_0xff9c('0x38')]){delete _0x3a0a5e[_0xff9c('0x38')];}_0x41dee9[_0xff9c('0x2d')](_0x308080)['send'](_0x3a0a5e);};}exports[_0xff9c('0x39')]=function(_0x27714c,_0x32e466){var _0x3613ad={},_0x3a9433={},_0x29ce4f={'count':0x0,'rows':[]};var _0x5f35ee=_[_0xff9c('0x3a')](db[_0xff9c('0x3b')][_0xff9c('0x3c')],function(_0x452b7b){return{'name':_0x452b7b['fieldName'],'type':_0x452b7b[_0xff9c('0x3d')]['key']};});_0x3a9433[_0xff9c('0x3e')]=_[_0xff9c('0x3a')](_0x5f35ee,'name');_0x3a9433[_0xff9c('0x3f')]=_[_0xff9c('0x40')](_0x27714c[_0xff9c('0x3f')]);_0x3a9433[_0xff9c('0x41')]=_['intersection'](_0x3a9433[_0xff9c('0x3e')],_0x3a9433[_0xff9c('0x3f')]);_0x3613ad[_0xff9c('0x42')]=_[_0xff9c('0x43')](_0x3a9433[_0xff9c('0x3e')],qs[_0xff9c('0x44')](_0x27714c[_0xff9c('0x3f')]['fields']));_0x3613ad['attributes']=_0x3613ad['attributes'][_0xff9c('0x45')]?_0x3613ad[_0xff9c('0x42')]:_0x3a9433[_0xff9c('0x3e')];if(!_0x27714c['query'][_0xff9c('0x46')](_0xff9c('0x47'))){_0x3613ad['limit']=qs[_0xff9c('0x32')](_0x27714c['query']['limit']);_0x3613ad[_0xff9c('0x2f')]=qs[_0xff9c('0x2f')](_0x27714c[_0xff9c('0x3f')][_0xff9c('0x2f')]);}_0x3613ad[_0xff9c('0x48')]=qs['sort'](_0x27714c[_0xff9c('0x3f')][_0xff9c('0x49')]);_0x3613ad[_0xff9c('0x4a')]=qs[_0xff9c('0x41')](_[_0xff9c('0x4b')](_0x27714c['query'],_0x3a9433['filters']),_0x5f35ee);if(_0x27714c[_0xff9c('0x3f')][_0xff9c('0x4c')]){_0x3613ad[_0xff9c('0x4a')]=_[_0xff9c('0x4d')](_0x3613ad[_0xff9c('0x4a')],{'$or':_['map'](_0x5f35ee,function(_0x1a5e12){if(_0x1a5e12['type']!==_0xff9c('0x4e')){var _0x51cd63={};_0x51cd63[_0x1a5e12[_0xff9c('0x38')]]={'$like':'%'+_0x27714c[_0xff9c('0x3f')][_0xff9c('0x4c')]+'%'};return _0x51cd63;}})});}_0x3613ad=_['merge']({},_0x3613ad,_0x27714c[_0xff9c('0x4f')]);var _0x551766={'where':_0x3613ad[_0xff9c('0x4a')]};return db[_0xff9c('0x3b')]['count'](_0x551766)[_0xff9c('0x21')](function(_0x493a75){_0x29ce4f[_0xff9c('0x31')]=_0x493a75;if(_0x27714c[_0xff9c('0x3f')][_0xff9c('0x50')]){_0x3613ad['include']=[{'all':!![]}];}return db[_0xff9c('0x3b')]['findAll'](_0x3613ad);})['then'](function(_0x3806da){_0x29ce4f[_0xff9c('0x51')]=_0x3806da;return _0x29ce4f;})[_0xff9c('0x21')](respondWithFilteredResult(_0x32e466,_0x3613ad))[_0xff9c('0x2b')](handleError(_0x32e466,null));};exports[_0xff9c('0x52')]=function(_0x1d8cb9,_0x45fabf){var _0x1901f9={'raw':!![],'where':{'id':_0x1d8cb9[_0xff9c('0x53')]['id']}},_0x53d43c={};_0x53d43c[_0xff9c('0x3e')]=_[_0xff9c('0x40')](db[_0xff9c('0x3b')][_0xff9c('0x3c')]);_0x53d43c['query']=_[_0xff9c('0x40')](_0x1d8cb9[_0xff9c('0x3f')]);_0x53d43c[_0xff9c('0x41')]=_[_0xff9c('0x43')](_0x53d43c[_0xff9c('0x3e')],_0x53d43c[_0xff9c('0x3f')]);_0x1901f9[_0xff9c('0x42')]=_[_0xff9c('0x43')](_0x53d43c[_0xff9c('0x3e')],qs['fields'](_0x1d8cb9[_0xff9c('0x3f')]['fields']));_0x1901f9[_0xff9c('0x42')]=_0x1901f9['attributes'][_0xff9c('0x45')]?_0x1901f9[_0xff9c('0x42')]:_0x53d43c[_0xff9c('0x3e')];if(_0x1d8cb9[_0xff9c('0x3f')][_0xff9c('0x50')]){_0x1901f9[_0xff9c('0x54')]=[{'all':!![]}];}_0x1901f9=_[_0xff9c('0x4d')]({},_0x1901f9,_0x1d8cb9['options']);return db[_0xff9c('0x3b')][_0xff9c('0x55')](_0x1901f9)[_0xff9c('0x21')](handleEntityNotFound(_0x45fabf,null))['then'](respondWithResult(_0x45fabf,null))[_0xff9c('0x2b')](handleError(_0x45fabf,null));};exports[_0xff9c('0x35')]=function(_0x12dd03,_0x1be112){if(_0x12dd03[_0xff9c('0x56')]['id']){delete _0x12dd03['body']['id'];}return db[_0xff9c('0x3b')][_0xff9c('0x55')]({'where':{'id':_0x12dd03[_0xff9c('0x53')]['id']}})[_0xff9c('0x21')](handleEntityNotFound(_0x1be112,null))[_0xff9c('0x21')](saveUpdates(_0x12dd03[_0xff9c('0x56')],null))[_0xff9c('0x21')](respondWithResult(_0x1be112,null))[_0xff9c('0x2b')](handleError(_0x1be112,null));};exports['destroy']=function(_0x2857b5,_0x7c8637){return db['FaxMessage']['find']({'where':{'id':_0x2857b5[_0xff9c('0x53')]['id']}})[_0xff9c('0x21')](handleEntityNotFound(_0x7c8637,null))[_0xff9c('0x21')](removeEntity(_0x7c8637,null))[_0xff9c('0x2b')](handleError(_0x7c8637,null));};exports[_0xff9c('0x57')]=function(_0x6cc6d0,_0x1b3bc0){return db[_0xff9c('0x3b')][_0xff9c('0x57')]()[_0xff9c('0x21')](respondWithResult(_0x1b3bc0,null))[_0xff9c('0x2b')](handleError(_0x1b3bc0,null));};var interaction_log=require(_0xff9c('0x12'))(_0xff9c('0x58'));exports[_0xff9c('0x59')]=function(_0x406c84,_0x58e281,_0x2e9850){var _0x174661={'agent':{},'channel':_0xff9c('0x5a')};if(_0x406c84[_0xff9c('0x56')]['id']){delete _0x406c84[_0xff9c('0x56')]['id'];}_0x406c84[_0xff9c('0x56')][_0xff9c('0x5b')]=!![];_0x406c84[_0xff9c('0x56')][_0xff9c('0x5c')]=moment()[_0xff9c('0x5d')](_0xff9c('0x5e'));_0x406c84[_0xff9c('0x56')][_0xff9c('0x5f')]=_0x406c84[_0xff9c('0x56')][_0xff9c('0x5f')]||_0x406c84[_0xff9c('0x60')]['id'];_0x174661[_0xff9c('0x61')]['id']=_0x406c84[_0xff9c('0x56')][_0xff9c('0x5f')];return db['FaxMessage'][_0xff9c('0x55')]({'where':{'id':_0x406c84[_0xff9c('0x53')]['id'],'UserId':null}})['then'](handleEntityNotFound(_0x58e281,null))[_0xff9c('0x21')](saveUpdates(_0x406c84[_0xff9c('0x56')],null))['then'](function(_0x40d45a){if(_0x40d45a){_0x174661['message']=_0x40d45a[_0xff9c('0x62')]({'plain':!![]});return db['FaxInteraction']['find']({'where':{'id':_0x40d45a[_0xff9c('0x63')]}});}return null;})[_0xff9c('0x21')](handleEntityNotFound(_0x58e281,null))['then'](function(_0xe00aa9){if(_0xe00aa9){return _0xe00aa9['update']({'UserId':_0x406c84[_0xff9c('0x56')][_0xff9c('0x5f')],'read1stAt':_[_0xff9c('0x64')](_0xe00aa9[_0xff9c('0x65')])?moment()[_0xff9c('0x5d')](_0xff9c('0x5e')):undefined});}return null;})[_0xff9c('0x21')](function(_0xa2d9b){if(_0xa2d9b){_0x174661['interaction']=_0xa2d9b[_0xff9c('0x62')]({'plain':!![]});interaction_log[_0xff9c('0x22')](_0xff9c('0x66'),_0x406c84[_0xff9c('0x60')]['id'],_0x406c84[_0xff9c('0x60')][_0xff9c('0x38')],_0x406c84[_0xff9c('0x60')][_0xff9c('0x67')],_0x174661[_0xff9c('0x68')]['id'],_0x406c84[_0xff9c('0x56')]?JSON[_0xff9c('0x25')](_0x406c84[_0xff9c('0x56')]):_0xff9c('0x69'));return respondWithRpcPromise(_0xff9c('0x6a'),_0xff9c('0x6b'),_0x174661);}return null;})[_0xff9c('0x21')](function(_0x1d1244){var _0x1afca1='SELECT\x20*\x20FROM\x20cm_contacts\x20WHERE\x20id\x20=\x20'+_0x1d1244[_0xff9c('0x29')]['ContactId'];return db[_0xff9c('0x6c')][_0xff9c('0x3f')](_0x1afca1,{'type':db['Sequelize']['QueryTypes'][_0xff9c('0x6d')],'raw':!![]})[_0xff9c('0x21')](function(_0x4613e2){return _0x4613e2;});})[_0xff9c('0x21')](function(_0x4baf5b){if(_0x4baf5b){_0x174661['message'][_0xff9c('0x6e')]=_0x4baf5b[0x0];if(!_0x406c84['body'][_0xff9c('0x5f')])return;return db[_0xff9c('0x6f')]['find']({'where':{'id':_0x406c84['body']['UserId'],'role':'agent'},'attributes':['id',_0xff9c('0x38'),_0xff9c('0x70'),_0xff9c('0x71'),_0xff9c('0x72')],'raw':!![]});}return null;})[_0xff9c('0x21')](function(_0x3f498c){if(!_0x3f498c)return null;_0x174661[_0xff9c('0x29')][_0xff9c('0x61')]=_0x3f498c;return _0x174661;})[_0xff9c('0x21')](function(_0x4117ee){if(_0x4117ee){if(_0x406c84[_0xff9c('0x56')][_0xff9c('0x73')]){_0x174661[_0xff9c('0x29')]['interface']=util[_0xff9c('0x5d')](_0xff9c('0x74'),_0x406c84[_0xff9c('0x60')][_0xff9c('0x38')]);_0x174661['message']['channel']=_0x174661[_0xff9c('0x75')];_0x174661[_0xff9c('0x29')][_0xff9c('0x76')]=_0x174661['channel'];_0x174661[_0xff9c('0x29')]['event']=_0xff9c('0x59');return respondWithRpcPromise('EventManager','EventManager',{'event':'acceptmessage','message':_0x174661[_0xff9c('0x29')]},client9002)['then'](function(){return _0x174661;});}return _0x174661;}return null;})[_0xff9c('0x21')](respondWithResult(_0x58e281,null))['catch'](handleError(_0x58e281,null));};var interaction_log=require(_0xff9c('0x12'))(_0xff9c('0x58'));exports[_0xff9c('0x34')]=function(_0x44b68a,_0x327e0e,_0x1dac92){var _0x39cb9a={'agent':{},'channel':_0xff9c('0x5a')};if(_0x44b68a['body']['id']){delete _0x44b68a[_0xff9c('0x56')]['id'];}_0x44b68a['body'][_0xff9c('0x5f')]=_0x44b68a['body'][_0xff9c('0x5f')]||_0x44b68a['user']['id'];_0x39cb9a['agent']['id']=_0x44b68a['body'][_0xff9c('0x5f')];return db[_0xff9c('0x3b')][_0xff9c('0x55')]({'where':{'id':_0x44b68a[_0xff9c('0x53')]['id'],'UserId':null}})[_0xff9c('0x21')](handleEntityNotFound(_0x327e0e,null))[_0xff9c('0x21')](function(_0x427323){if(_0x427323){_0x39cb9a[_0xff9c('0x29')]=_0x427323[_0xff9c('0x62')]({'plain':!![]});return db[_0xff9c('0x77')]['find']({'where':{'id':_0x427323[_0xff9c('0x63')]}});}return null;})[_0xff9c('0x21')](handleEntityNotFound(_0x327e0e,null))[_0xff9c('0x21')](function(_0x3dfe01){if(_0x3dfe01){_0x39cb9a[_0xff9c('0x68')]=_0x3dfe01[_0xff9c('0x62')]({'plain':!![]});interaction_log[_0xff9c('0x22')](_0xff9c('0x78'),_0x44b68a[_0xff9c('0x60')]['id'],_0x44b68a[_0xff9c('0x60')][_0xff9c('0x38')],_0x44b68a[_0xff9c('0x60')][_0xff9c('0x67')],_0x39cb9a['interaction']['id'],_0x44b68a[_0xff9c('0x56')]?JSON[_0xff9c('0x25')](_0x44b68a[_0xff9c('0x56')]):_0xff9c('0x69'));return respondWithRpcPromise(_0xff9c('0x79'),_0xff9c('0x7a'),_0x39cb9a);}return null;})['then'](function(_0x324e57){var _0x2eff3a=_0xff9c('0x7b')+_0x324e57[_0xff9c('0x29')]['ContactId'];return db['sequelize']['query'](_0x2eff3a,{'type':db[_0xff9c('0x7c')][_0xff9c('0x7d')][_0xff9c('0x6d')],'raw':!![]})['then'](function(_0x26d6de){return _0x26d6de;});})[_0xff9c('0x21')](function(_0x4bf0a9){if(_0x4bf0a9){_0x39cb9a[_0xff9c('0x29')][_0xff9c('0x6e')]=_0x4bf0a9[0x0];if(!_0x44b68a['body']['UserId'])return;return db[_0xff9c('0x6f')][_0xff9c('0x55')]({'where':{'id':_0x44b68a[_0xff9c('0x56')][_0xff9c('0x5f')],'role':_0xff9c('0x61')},'attributes':['id','name','fullname','email',_0xff9c('0x72')],'raw':!![]});}return null;})['then'](function(_0x80046d){if(!_0x80046d)return null;_0x39cb9a[_0xff9c('0x29')][_0xff9c('0x61')]=_0x80046d;return _0x39cb9a;})[_0xff9c('0x21')](function(_0x385ef8){if(_0x385ef8){_0x385ef8[_0xff9c('0x29')][_0xff9c('0x7e')]=util[_0xff9c('0x5d')](_0xff9c('0x74'),_0x44b68a[_0xff9c('0x60')][_0xff9c('0x38')]);_0x385ef8['message']['channel']=_0x39cb9a[_0xff9c('0x75')];_0x385ef8['message']['motionChannel']=_0x39cb9a[_0xff9c('0x75')];_0x385ef8['message']['event']=_0xff9c('0x34');respondWithRpcPromise(_0xff9c('0x7f'),_0xff9c('0x7f'),{'event':_0xff9c('0x80'),'message':_0x385ef8['message']},client9002);return _0x39cb9a;}return null;})[_0xff9c('0x21')](respondWithResult(_0x327e0e,null))['catch'](handleError(_0x327e0e,null));};exports[_0xff9c('0x81')]=function(_0x5ea8ca,_0x4345bd){var _0x36fa9a;return db[_0xff9c('0x3b')]['create'](_0x5ea8ca[_0xff9c('0x56')],{})[_0xff9c('0x21')](function(_0x5604fc){_0x36fa9a=_0x5604fc;return db['CmContact'][_0xff9c('0x82')]({'where':{'id':_0x36fa9a[_0xff9c('0x83')]}});})['then'](function(_0x169de9){if(_[_0xff9c('0x64')](_0x169de9)){return;}else{_0x36fa9a['fax']=_0x169de9['fax'];return db[_0xff9c('0x84')][_0xff9c('0x82')]({'where':{'id':_0x36fa9a[_0xff9c('0x85')]}});}})['then'](function(_0x2e447f){return respondWithRpcPromise(_0xff9c('0x86'),_0xff9c('0x86'),{'FaxAccountId':_['isNil'](_0x5ea8ca[_0xff9c('0x56')])?undefined:_0x5ea8ca[_0xff9c('0x56')][_0xff9c('0x87')],'path':_[_0xff9c('0x64')](_0x2e447f)?undefined:util['format'](_0xff9c('0x88'),_0x2e447f['basename']),'fax':_['isNil'](_0x36fa9a[_0xff9c('0x5a')])?undefined:_0x36fa9a[_0xff9c('0x5a')],'AttachmentId':_0x36fa9a[_0xff9c('0x85')]},client9002);})[_0xff9c('0x21')](respondWithResult(_0x4345bd,0xc9))[_0xff9c('0x2b')](handleError(_0x4345bd,null));};exports[_0xff9c('0x89')]=function(_0x343c2d,_0x1c7908){var _0x9ec879=path[_0xff9c('0x8a')](config[_0xff9c('0x8b')],'server',_0xff9c('0x8c'),'attachments');return db['FaxMessage']['find']({'where':{'id':_0x343c2d[_0xff9c('0x53')]['id']},'include':[{'model':db[_0xff9c('0x84')],'as':_0xff9c('0x84')}]})['then'](handleEntityNotFound(_0x1c7908,null))['then'](function(_0xe800fe){if(_0xe800fe){return _0x1c7908['download'](path[_0xff9c('0x8a')](_0x9ec879,_0xe800fe[_0xff9c('0x84')][_0xff9c('0x8d')]));}})[_0xff9c('0x2b')](handleError(_0x1c7908,null));};
\ No newline at end of file