Built motion from commit da617fac.|2.6.6
[motion2.git] / server / api / faxMessage / faxMessage.controller.js
index 062bbd8..41e2455 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xfc50=['Attachment','request-promise','moment','bluebird','to-csv','ejs','lodash','squel','crypto','jsforce','desk.js','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/environment','../../mysqldb','redis','defaults','localhost','jayson/promise','client','http','request','FaxMessage,\x20%s,\x20%s','request\x20sent','debug','error','code','message','info','result','status','end','json','undefined','limit','count','offset','Content-Range','apply','reject','update','then','destroy','sendStatus','stack','name','index','map','FaxMessage','fieldName','type','key','model','query','filters','intersection','attributes','hasOwnProperty','sort','where','filter','merge','VIRTUAL','options','includeAll','include','rows','catch','params','rawAttributes','keys','fields','find','body','describe','fax','read','readAt','format','YYYY-MM-DD\x20HH:mm:ss','UserId','get','FaxInteraction','FaxInteractionId','isNil','read1stAt','interaction','[FAXMESSAGE:ACCEPT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','user','role','stringify','acceptMessage','SELECT\x20*\x20FROM\x20cm_contacts\x20WHERE\x20id\x20=\x20','ContactId','Sequelize','contact','User','fullname','email','internal','SIP/%s','channel','motionChannel','event','accept','EventManager','acceptmessage','agent','RejectMessage','rejectMessage','sequelize','QueryTypes','interface','rejectmessage','create','CmContact','findOne','AttachmentId','SendFax','FaxAccountId','/var/opt/motion2/server/files/attachments/%s','basename','download','join','root','server','files'];(function(_0xedd44e,_0x1f01a4){var _0x4ddcd6=function(_0x41bee2){while(--_0x41bee2){_0xedd44e['push'](_0xedd44e['shift']());}};_0x4ddcd6(++_0x1f01a4);}(_0xfc50,0x85));var _0x0fc5=function(_0x5b644e,_0x2e5e07){_0x5b644e=_0x5b644e-0x0;var _0x49c6bf=_0xfc50[_0x5b644e];return _0x49c6bf;};'use strict';var emlformat=require('eml-format');var rimraf=require('rimraf');var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require(_0x0fc5('0x0'));var moment=require(_0x0fc5('0x1'));var BPromise=require(_0x0fc5('0x2'));var Mustache=require('mustache');var util=require('util');var path=require('path');var sox=require('sox');var csv=require(_0x0fc5('0x3'));var ejs=require(_0x0fc5('0x4'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x0fc5('0x5'));var squel=require(_0x0fc5('0x6'));var crypto=require(_0x0fc5('0x7'));var jsforce=require(_0x0fc5('0x8'));var deskjs=require(_0x0fc5('0x9'));var toCsv=require(_0x0fc5('0x3'));var querystring=require('querystring');var Papa=require(_0x0fc5('0xa'));var Redis=require(_0x0fc5('0xb'));var authService=require(_0x0fc5('0xc'));var qs=require(_0x0fc5('0xd'));var as=require(_0x0fc5('0xe'));var hardwareService=require(_0x0fc5('0xf'));var logger=require(_0x0fc5('0x10'))('api');var utils=require('../../config/utils');var config=require(_0x0fc5('0x11'));var licenseUtil=require('../../config/license/util');var db=require(_0x0fc5('0x12'))['db'];config[_0x0fc5('0x13')]=_[_0x0fc5('0x14')](config[_0x0fc5('0x13')],{'host':_0x0fc5('0x15'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require('./faxMessage.socket')['register'](socket);var jayson=require(_0x0fc5('0x16'));var client=jayson[_0x0fc5('0x17')][_0x0fc5('0x18')]({'port':0x232c});var client9002=jayson[_0x0fc5('0x17')][_0x0fc5('0x18')]({'port':0x232a});function respondWithRpcPromise(_0x1b6c80,_0x2d7dad,_0x328eda,_0x4e1ad1){return new BPromise(function(_0x4a6847,_0x3a8c11){var _0x5b3a42=_0x4e1ad1||client;return _0x5b3a42[_0x0fc5('0x19')](_0x1b6c80,_0x328eda)['then'](function(_0x1acff2){logger['info'](_0x0fc5('0x1a'),_0x2d7dad,_0x0fc5('0x1b'));logger[_0x0fc5('0x1c')]('FaxMessage,\x20%s,\x20%s,\x20%s',_0x2d7dad,_0x0fc5('0x1b'),JSON['stringify'](_0x1acff2));if(_0x1acff2[_0x0fc5('0x1d')]){if(_0x1acff2[_0x0fc5('0x1d')][_0x0fc5('0x1e')]===0x1f4){logger[_0x0fc5('0x1d')](_0x0fc5('0x1a'),_0x2d7dad,_0x1acff2[_0x0fc5('0x1d')][_0x0fc5('0x1f')]);return _0x3a8c11(_0x1acff2[_0x0fc5('0x1d')][_0x0fc5('0x1f')]);}logger[_0x0fc5('0x1d')](_0x0fc5('0x1a'),_0x2d7dad,_0x1acff2['error'][_0x0fc5('0x1f')]);return _0x4a6847(_0x1acff2[_0x0fc5('0x1d')][_0x0fc5('0x1f')]);}else{logger[_0x0fc5('0x20')](_0x0fc5('0x1a'),_0x2d7dad,_0x0fc5('0x1b'));_0x4a6847(_0x1acff2[_0x0fc5('0x21')][_0x0fc5('0x1f')]);}})['catch'](function(_0xe41836){logger['error']('FaxMessage,\x20%s,\x20%s',_0x2d7dad,_0xe41836);_0x3a8c11(_0xe41836);});});}function respondWithStatusCode(_0x8004c6,_0x159c4e){_0x159c4e=_0x159c4e||0xcc;return function(_0x593b2e){if(_0x593b2e){return _0x8004c6['sendStatus'](_0x159c4e);}return _0x8004c6[_0x0fc5('0x22')](_0x159c4e)[_0x0fc5('0x23')]();};}function respondWithResult(_0x24a73a,_0x38d1bd){_0x38d1bd=_0x38d1bd||0xc8;return function(_0x2be52a){if(_0x2be52a){return _0x24a73a[_0x0fc5('0x22')](_0x38d1bd)[_0x0fc5('0x24')](_0x2be52a);}};}function respondWithFilteredResult(_0x35729e,_0x5b72e3){return function(_0x5d7bf0){if(_0x5d7bf0){var _0x43ab35=typeof _0x5b72e3['offset']===_0x0fc5('0x25')&&typeof _0x5b72e3[_0x0fc5('0x26')]===_0x0fc5('0x25');var _0x6e74f8=_0x5d7bf0[_0x0fc5('0x27')];var _0x5418ef=_0x43ab35?0x0:_0x5b72e3[_0x0fc5('0x28')];var _0x32f96c=_0x43ab35?_0x5d7bf0[_0x0fc5('0x27')]:_0x5b72e3[_0x0fc5('0x28')]+_0x5b72e3[_0x0fc5('0x26')];var _0xe6b5cd;if(_0x32f96c>=_0x6e74f8){_0x32f96c=_0x6e74f8;_0xe6b5cd=0xc8;}else{_0xe6b5cd=0xce;}_0x35729e[_0x0fc5('0x22')](_0xe6b5cd);return _0x35729e['set'](_0x0fc5('0x29'),_0x5418ef+'-'+_0x32f96c+'/'+_0x6e74f8)[_0x0fc5('0x24')](_0x5d7bf0);}return null;};}function patchUpdates(_0x3194e6){return function(_0x3e5970){try{jsonpatch[_0x0fc5('0x2a')](_0x3e5970,_0x3194e6,!![]);}catch(_0x3e3948){return BPromise[_0x0fc5('0x2b')](_0x3e3948);}return _0x3e5970['save']();};}function saveUpdates(_0x6ee3b4,_0x1ca3da){return function(_0x566288){if(_0x566288){return _0x566288[_0x0fc5('0x2c')](_0x6ee3b4)[_0x0fc5('0x2d')](function(_0x2fe782){return _0x2fe782;});}return null;};}function removeEntity(_0x573211,_0x2184ec){return function(_0x206eb0){if(_0x206eb0){return _0x206eb0[_0x0fc5('0x2e')]()['then'](function(){_0x573211[_0x0fc5('0x22')](0xcc)['end']();});}};}function handleEntityNotFound(_0x251f7a,_0x258598){return function(_0x45fb34){if(!_0x45fb34){_0x251f7a[_0x0fc5('0x2f')](0x194);}return _0x45fb34;};}function handleError(_0xa581f9,_0x4b123a){_0x4b123a=_0x4b123a||0x1f4;return function(_0x3a8b4e){logger[_0x0fc5('0x1d')](_0x3a8b4e[_0x0fc5('0x30')]);if(_0x3a8b4e[_0x0fc5('0x31')]){delete _0x3a8b4e[_0x0fc5('0x31')];}_0xa581f9[_0x0fc5('0x22')](_0x4b123a)['send'](_0x3a8b4e);};}exports[_0x0fc5('0x32')]=function(_0x9d4238,_0x2b38a1){var _0x425b26={},_0x1d15b2={},_0x45a44a={'count':0x0,'rows':[]};var _0x146979=_[_0x0fc5('0x33')](db[_0x0fc5('0x34')]['rawAttributes'],function(_0x590c7a){return{'name':_0x590c7a[_0x0fc5('0x35')],'type':_0x590c7a[_0x0fc5('0x36')][_0x0fc5('0x37')]};});_0x1d15b2[_0x0fc5('0x38')]=_[_0x0fc5('0x33')](_0x146979,_0x0fc5('0x31'));_0x1d15b2[_0x0fc5('0x39')]=_['keys'](_0x9d4238[_0x0fc5('0x39')]);_0x1d15b2[_0x0fc5('0x3a')]=_[_0x0fc5('0x3b')](_0x1d15b2[_0x0fc5('0x38')],_0x1d15b2['query']);_0x425b26[_0x0fc5('0x3c')]=_['intersection'](_0x1d15b2[_0x0fc5('0x38')],qs['fields'](_0x9d4238[_0x0fc5('0x39')]['fields']));_0x425b26[_0x0fc5('0x3c')]=_0x425b26[_0x0fc5('0x3c')]['length']?_0x425b26[_0x0fc5('0x3c')]:_0x1d15b2['model'];if(!_0x9d4238[_0x0fc5('0x39')][_0x0fc5('0x3d')]('nolimit')){_0x425b26['limit']=qs[_0x0fc5('0x26')](_0x9d4238[_0x0fc5('0x39')][_0x0fc5('0x26')]);_0x425b26[_0x0fc5('0x28')]=qs[_0x0fc5('0x28')](_0x9d4238['query'][_0x0fc5('0x28')]);}_0x425b26['order']=qs[_0x0fc5('0x3e')](_0x9d4238[_0x0fc5('0x39')]['sort']);_0x425b26[_0x0fc5('0x3f')]=qs[_0x0fc5('0x3a')](_['pick'](_0x9d4238['query'],_0x1d15b2['filters']),_0x146979);if(_0x9d4238[_0x0fc5('0x39')][_0x0fc5('0x40')]){_0x425b26['where']=_[_0x0fc5('0x41')](_0x425b26[_0x0fc5('0x3f')],{'$or':_[_0x0fc5('0x33')](_0x146979,function(_0x3ed2ea){if(_0x3ed2ea[_0x0fc5('0x36')]!==_0x0fc5('0x42')){var _0x30ef98={};_0x30ef98[_0x3ed2ea[_0x0fc5('0x31')]]={'$like':'%'+_0x9d4238['query'][_0x0fc5('0x40')]+'%'};return _0x30ef98;}})});}_0x425b26=_[_0x0fc5('0x41')]({},_0x425b26,_0x9d4238[_0x0fc5('0x43')]);var _0x16d157={'where':_0x425b26[_0x0fc5('0x3f')]};return db[_0x0fc5('0x34')][_0x0fc5('0x27')](_0x16d157)[_0x0fc5('0x2d')](function(_0x1abca0){_0x45a44a['count']=_0x1abca0;if(_0x9d4238[_0x0fc5('0x39')][_0x0fc5('0x44')]){_0x425b26[_0x0fc5('0x45')]=[{'all':!![]}];}return db[_0x0fc5('0x34')]['findAll'](_0x425b26);})[_0x0fc5('0x2d')](function(_0x5a27aa){_0x45a44a[_0x0fc5('0x46')]=_0x5a27aa;return _0x45a44a;})[_0x0fc5('0x2d')](respondWithFilteredResult(_0x2b38a1,_0x425b26))[_0x0fc5('0x47')](handleError(_0x2b38a1,null));};exports['show']=function(_0x5e7ae4,_0x252314){var _0x523805={'raw':!![],'where':{'id':_0x5e7ae4[_0x0fc5('0x48')]['id']}},_0x3d747d={};_0x3d747d['model']=_['keys'](db['FaxMessage'][_0x0fc5('0x49')]);_0x3d747d[_0x0fc5('0x39')]=_[_0x0fc5('0x4a')](_0x5e7ae4['query']);_0x3d747d[_0x0fc5('0x3a')]=_[_0x0fc5('0x3b')](_0x3d747d['model'],_0x3d747d['query']);_0x523805[_0x0fc5('0x3c')]=_[_0x0fc5('0x3b')](_0x3d747d[_0x0fc5('0x38')],qs[_0x0fc5('0x4b')](_0x5e7ae4[_0x0fc5('0x39')][_0x0fc5('0x4b')]));_0x523805['attributes']=_0x523805[_0x0fc5('0x3c')]['length']?_0x523805[_0x0fc5('0x3c')]:_0x3d747d[_0x0fc5('0x38')];if(_0x5e7ae4[_0x0fc5('0x39')][_0x0fc5('0x44')]){_0x523805['include']=[{'all':!![]}];}_0x523805=_[_0x0fc5('0x41')]({},_0x523805,_0x5e7ae4[_0x0fc5('0x43')]);return db[_0x0fc5('0x34')][_0x0fc5('0x4c')](_0x523805)['then'](handleEntityNotFound(_0x252314,null))[_0x0fc5('0x2d')](respondWithResult(_0x252314,null))[_0x0fc5('0x47')](handleError(_0x252314,null));};exports[_0x0fc5('0x2c')]=function(_0x37f7e6,_0x3aa214){if(_0x37f7e6[_0x0fc5('0x4d')]['id']){delete _0x37f7e6[_0x0fc5('0x4d')]['id'];}return db['FaxMessage'][_0x0fc5('0x4c')]({'where':{'id':_0x37f7e6[_0x0fc5('0x48')]['id']}})[_0x0fc5('0x2d')](handleEntityNotFound(_0x3aa214,null))[_0x0fc5('0x2d')](saveUpdates(_0x37f7e6[_0x0fc5('0x4d')],null))['then'](respondWithResult(_0x3aa214,null))[_0x0fc5('0x47')](handleError(_0x3aa214,null));};exports['destroy']=function(_0x1cb0d2,_0x49ede2){return db['FaxMessage']['find']({'where':{'id':_0x1cb0d2[_0x0fc5('0x48')]['id']}})[_0x0fc5('0x2d')](handleEntityNotFound(_0x49ede2,null))[_0x0fc5('0x2d')](removeEntity(_0x49ede2,null))[_0x0fc5('0x47')](handleError(_0x49ede2,null));};exports[_0x0fc5('0x4e')]=function(_0x473490,_0x4086ea){return db['FaxMessage'][_0x0fc5('0x4e')]()[_0x0fc5('0x2d')](respondWithResult(_0x4086ea,null))['catch'](handleError(_0x4086ea,null));};var interaction_log=require(_0x0fc5('0x10'))('fax-interactions');exports['accept']=function(_0x59f202,_0x200018,_0x1f2847){var _0x332b3f={'agent':{},'channel':_0x0fc5('0x4f')};if(_0x59f202[_0x0fc5('0x4d')]['id']){delete _0x59f202[_0x0fc5('0x4d')]['id'];}_0x59f202[_0x0fc5('0x4d')][_0x0fc5('0x50')]=!![];_0x59f202[_0x0fc5('0x4d')][_0x0fc5('0x51')]=moment()[_0x0fc5('0x52')](_0x0fc5('0x53'));_0x59f202[_0x0fc5('0x4d')]['UserId']=_0x59f202[_0x0fc5('0x4d')][_0x0fc5('0x54')]||_0x59f202['user']['id'];_0x332b3f['agent']['id']=_0x59f202['body'][_0x0fc5('0x54')];return db[_0x0fc5('0x34')][_0x0fc5('0x4c')]({'where':{'id':_0x59f202[_0x0fc5('0x48')]['id'],'UserId':null}})[_0x0fc5('0x2d')](handleEntityNotFound(_0x200018,null))[_0x0fc5('0x2d')](saveUpdates(_0x59f202[_0x0fc5('0x4d')],null))['then'](function(_0xa68ee1){if(_0xa68ee1){_0x332b3f[_0x0fc5('0x1f')]=_0xa68ee1[_0x0fc5('0x55')]({'plain':!![]});return db[_0x0fc5('0x56')][_0x0fc5('0x4c')]({'where':{'id':_0xa68ee1[_0x0fc5('0x57')]}});}return null;})['then'](handleEntityNotFound(_0x200018,null))['then'](function(_0x18f687){if(_0x18f687){return _0x18f687[_0x0fc5('0x2c')]({'UserId':_0x59f202[_0x0fc5('0x4d')]['UserId'],'read1stAt':_[_0x0fc5('0x58')](_0x18f687[_0x0fc5('0x59')])?moment()['format']('YYYY-MM-DD\x20HH:mm:ss'):undefined});}return null;})['then'](function(_0x43eb81){if(_0x43eb81){_0x332b3f[_0x0fc5('0x5a')]=_0x43eb81[_0x0fc5('0x55')]({'plain':!![]});interaction_log['info'](_0x0fc5('0x5b'),_0x59f202[_0x0fc5('0x5c')]['id'],_0x59f202['user'][_0x0fc5('0x31')],_0x59f202[_0x0fc5('0x5c')][_0x0fc5('0x5d')],_0x332b3f[_0x0fc5('0x5a')]['id'],_0x59f202['body']?JSON[_0x0fc5('0x5e')](_0x59f202['body']):'null');return respondWithRpcPromise('AcceptMessage',_0x0fc5('0x5f'),_0x332b3f);}return null;})[_0x0fc5('0x2d')](function(_0xa0c2f6){var _0x1d0f90=_0x0fc5('0x60')+_0xa0c2f6[_0x0fc5('0x1f')][_0x0fc5('0x61')];return db['sequelize'][_0x0fc5('0x39')](_0x1d0f90,{'type':db[_0x0fc5('0x62')]['QueryTypes']['SELECT'],'raw':!![]})[_0x0fc5('0x2d')](function(_0x61e5c7){return _0x61e5c7;});})[_0x0fc5('0x2d')](function(_0x252a4a){if(_0x252a4a){_0x332b3f[_0x0fc5('0x1f')][_0x0fc5('0x63')]=_0x252a4a[0x0];if(!_0x59f202[_0x0fc5('0x4d')][_0x0fc5('0x54')])return;return db[_0x0fc5('0x64')][_0x0fc5('0x4c')]({'where':{'id':_0x59f202['body']['UserId'],'role':'agent'},'attributes':['id',_0x0fc5('0x31'),_0x0fc5('0x65'),_0x0fc5('0x66'),_0x0fc5('0x67')],'raw':!![]});}return null;})[_0x0fc5('0x2d')](function(_0x163e7f){if(!_0x163e7f)return null;_0x332b3f[_0x0fc5('0x1f')]['agent']=_0x163e7f;return _0x332b3f;})[_0x0fc5('0x2d')](function(_0xfb0105){if(_0xfb0105){if(_0x59f202[_0x0fc5('0x4d')]['manual']){_0x332b3f[_0x0fc5('0x1f')]['interface']=util['format'](_0x0fc5('0x68'),_0x59f202[_0x0fc5('0x5c')][_0x0fc5('0x31')]);_0x332b3f[_0x0fc5('0x1f')][_0x0fc5('0x69')]=_0x332b3f['channel'];_0x332b3f['message'][_0x0fc5('0x6a')]=_0x332b3f[_0x0fc5('0x69')];_0x332b3f['message'][_0x0fc5('0x6b')]=_0x0fc5('0x6c');return respondWithRpcPromise('EventManager',_0x0fc5('0x6d'),{'event':_0x0fc5('0x6e'),'message':_0x332b3f[_0x0fc5('0x1f')]},client9002)['then'](function(){return _0x332b3f;});}return _0x332b3f;}return null;})[_0x0fc5('0x2d')](respondWithResult(_0x200018,null))['catch'](handleError(_0x200018,null));};var interaction_log=require(_0x0fc5('0x10'))('fax-interactions');exports[_0x0fc5('0x2b')]=function(_0x205a29,_0xa72d35,_0x43d8c){var _0x126b47={'agent':{},'channel':_0x0fc5('0x4f')};if(_0x205a29[_0x0fc5('0x4d')]['id']){delete _0x205a29[_0x0fc5('0x4d')]['id'];}_0x205a29[_0x0fc5('0x4d')][_0x0fc5('0x54')]=_0x205a29[_0x0fc5('0x4d')][_0x0fc5('0x54')]||_0x205a29[_0x0fc5('0x5c')]['id'];_0x126b47[_0x0fc5('0x6f')]['id']=_0x205a29[_0x0fc5('0x4d')]['UserId'];return db[_0x0fc5('0x34')][_0x0fc5('0x4c')]({'where':{'id':_0x205a29[_0x0fc5('0x48')]['id'],'UserId':null}})[_0x0fc5('0x2d')](handleEntityNotFound(_0xa72d35,null))[_0x0fc5('0x2d')](function(_0x217ce4){if(_0x217ce4){_0x126b47[_0x0fc5('0x1f')]=_0x217ce4[_0x0fc5('0x55')]({'plain':!![]});return db[_0x0fc5('0x56')][_0x0fc5('0x4c')]({'where':{'id':_0x217ce4[_0x0fc5('0x57')]}});}return null;})[_0x0fc5('0x2d')](handleEntityNotFound(_0xa72d35,null))[_0x0fc5('0x2d')](function(_0x54d999){if(_0x54d999){_0x126b47['interaction']=_0x54d999[_0x0fc5('0x55')]({'plain':!![]});interaction_log[_0x0fc5('0x20')]('[FAXMESSAGE:REJECT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s',_0x205a29['user']['id'],_0x205a29[_0x0fc5('0x5c')]['name'],_0x205a29['user'][_0x0fc5('0x5d')],_0x126b47[_0x0fc5('0x5a')]['id'],_0x205a29['body']?JSON[_0x0fc5('0x5e')](_0x205a29[_0x0fc5('0x4d')]):'null');return respondWithRpcPromise(_0x0fc5('0x70'),_0x0fc5('0x71'),_0x126b47);}return null;})[_0x0fc5('0x2d')](function(_0x16a442){var _0x126780=_0x0fc5('0x60')+_0x16a442[_0x0fc5('0x1f')][_0x0fc5('0x61')];return db[_0x0fc5('0x72')]['query'](_0x126780,{'type':db[_0x0fc5('0x62')][_0x0fc5('0x73')]['SELECT'],'raw':!![]})['then'](function(_0x4ef050){return _0x4ef050;});})[_0x0fc5('0x2d')](function(_0x550716){if(_0x550716){_0x126b47['message'][_0x0fc5('0x63')]=_0x550716[0x0];if(!_0x205a29[_0x0fc5('0x4d')]['UserId'])return;return db[_0x0fc5('0x64')][_0x0fc5('0x4c')]({'where':{'id':_0x205a29[_0x0fc5('0x4d')][_0x0fc5('0x54')],'role':_0x0fc5('0x6f')},'attributes':['id',_0x0fc5('0x31'),_0x0fc5('0x65'),_0x0fc5('0x66'),_0x0fc5('0x67')],'raw':!![]});}return null;})[_0x0fc5('0x2d')](function(_0x801764){if(!_0x801764)return null;_0x126b47[_0x0fc5('0x1f')]['agent']=_0x801764;return _0x126b47;})[_0x0fc5('0x2d')](function(_0x2faf73){if(_0x2faf73){_0x2faf73['message'][_0x0fc5('0x74')]=util['format'](_0x0fc5('0x68'),_0x205a29[_0x0fc5('0x5c')]['name']);_0x2faf73[_0x0fc5('0x1f')][_0x0fc5('0x69')]=_0x126b47[_0x0fc5('0x69')];_0x2faf73[_0x0fc5('0x1f')][_0x0fc5('0x6a')]=_0x126b47['channel'];_0x2faf73[_0x0fc5('0x1f')][_0x0fc5('0x6b')]=_0x0fc5('0x2b');respondWithRpcPromise(_0x0fc5('0x6d'),_0x0fc5('0x6d'),{'event':_0x0fc5('0x75'),'message':_0x2faf73[_0x0fc5('0x1f')]},client9002);return _0x126b47;}return null;})['then'](respondWithResult(_0xa72d35,null))[_0x0fc5('0x47')](handleError(_0xa72d35,null));};exports[_0x0fc5('0x76')]=function(_0x4631eb,_0x3d6b85){var _0x3acf54;return db['FaxMessage'][_0x0fc5('0x76')](_0x4631eb[_0x0fc5('0x4d')],{})[_0x0fc5('0x2d')](function(_0x5e9c0e){_0x3acf54=_0x5e9c0e;return db[_0x0fc5('0x77')]['findOne']({'where':{'id':_0x3acf54[_0x0fc5('0x61')]}});})[_0x0fc5('0x2d')](function(_0x553431){if(_[_0x0fc5('0x58')](_0x553431)){return;}else{_0x3acf54[_0x0fc5('0x4f')]=_0x553431['fax'];return db['Attachment'][_0x0fc5('0x78')]({'where':{'id':_0x3acf54[_0x0fc5('0x79')]}});}})[_0x0fc5('0x2d')](function(_0x23286c){return respondWithRpcPromise(_0x0fc5('0x7a'),_0x0fc5('0x7a'),{'FaxAccountId':_[_0x0fc5('0x58')](_0x4631eb[_0x0fc5('0x4d')])?undefined:_0x4631eb[_0x0fc5('0x4d')][_0x0fc5('0x7b')],'path':_[_0x0fc5('0x58')](_0x23286c)?undefined:util['format'](_0x0fc5('0x7c'),_0x23286c[_0x0fc5('0x7d')]),'fax':_['isNil'](_0x3acf54[_0x0fc5('0x4f')])?undefined:_0x3acf54['fax'],'AttachmentId':_0x3acf54[_0x0fc5('0x79')]},client9002);})[_0x0fc5('0x2d')](respondWithResult(_0x3d6b85,0xc9))[_0x0fc5('0x47')](handleError(_0x3d6b85,null));};exports[_0x0fc5('0x7e')]=function(_0x128b76,_0x2d1870){var _0x4477e7=path[_0x0fc5('0x7f')](config[_0x0fc5('0x80')],_0x0fc5('0x81'),_0x0fc5('0x82'),'attachments');return db[_0x0fc5('0x34')][_0x0fc5('0x4c')]({'where':{'id':_0x128b76[_0x0fc5('0x48')]['id']},'include':[{'model':db[_0x0fc5('0x83')],'as':_0x0fc5('0x83')}]})['then'](handleEntityNotFound(_0x2d1870,null))[_0x0fc5('0x2d')](function(_0x244683){if(_0x244683){return _0x2d1870[_0x0fc5('0x7e')](path[_0x0fc5('0x7f')](_0x4477e7,_0x244683['Attachment'][_0x0fc5('0x7d')]));}})[_0x0fc5('0x47')](handleError(_0x2d1870,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