Built motion from commit 1fa89557.|2.6.10
[motion2.git] / server / api / faxMessage / faxMessage.controller.js
index b541b3e..95faff8 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x8f55=['fax-interactions','accept','fax','read','format','user','get','FaxInteractionId','update','UserId','isNil','read1stAt','YYYY-MM-DD\x20HH:mm:ss','interaction','role','null','acceptMessage','SELECT\x20*\x20FROM\x20cm_contacts\x20WHERE\x20id\x20=\x20','ContactId','Sequelize','QueryTypes','SELECT','User','agent','fullname','email','internal','manual','interface','SIP/%s','channel','event','EventManager','acceptmessage','FaxInteraction','[FAXMESSAGE:REJECT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','RejectMessage','rejectMessage','sequelize','contact','motionChannel','rejectmessage','create','findOne','AttachmentId','SendFax','FaxAccountId','/var/opt/motion2/server/files/attachments/%s','basename','download','join','server','attachments','Attachment','eml-format','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','ejs','fs-extra','squel','crypto','jsforce','desk.js','to-csv','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','defaults','redis','localhost','socket.io-emitter','./faxMessage.socket','register','jayson/promise','client','request','then','request\x20sent','debug','FaxMessage,\x20%s,\x20%s,\x20%s','stringify','error','message','FaxMessage,\x20%s,\x20%s','info','result','catch','sendStatus','status','json','offset','undefined','limit','set','apply','reject','save','end','stack','name','send','index','map','FaxMessage','rawAttributes','fieldName','keys','query','filters','intersection','model','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','type','VIRTUAL','filter','merge','count','includeAll','findAll','rows','show','params','include','options','find','body','destroy','describe'];(function(_0x3ad818,_0x3dea92){var _0x4762ca=function(_0x25a988){while(--_0x25a988){_0x3ad818['push'](_0x3ad818['shift']());}};_0x4762ca(++_0x3dea92);}(_0x8f55,0x1f2));var _0x58f5=function(_0x20a584,_0xe384a5){_0x20a584=_0x20a584-0x0;var _0x4b41a8=_0x8f55[_0x20a584];return _0x4b41a8;};'use strict';var emlformat=require(_0x58f5('0x0'));var rimraf=require('rimraf');var zipdir=require('zip-dir');var jsonpatch=require(_0x58f5('0x1'));var rp=require(_0x58f5('0x2'));var moment=require(_0x58f5('0x3'));var BPromise=require(_0x58f5('0x4'));var Mustache=require(_0x58f5('0x5'));var util=require(_0x58f5('0x6'));var path=require(_0x58f5('0x7'));var sox=require(_0x58f5('0x8'));var csv=require('to-csv');var ejs=require(_0x58f5('0x9'));var fs=require('fs');var fs_extra=require(_0x58f5('0xa'));var _=require('lodash');var squel=require(_0x58f5('0xb'));var crypto=require(_0x58f5('0xc'));var jsforce=require(_0x58f5('0xd'));var deskjs=require(_0x58f5('0xe'));var toCsv=require(_0x58f5('0xf'));var querystring=require(_0x58f5('0x10'));var Papa=require(_0x58f5('0x11'));var Redis=require(_0x58f5('0x12'));var authService=require(_0x58f5('0x13'));var qs=require(_0x58f5('0x14'));var as=require(_0x58f5('0x15'));var hardwareService=require(_0x58f5('0x16'));var logger=require(_0x58f5('0x17'))('api');var utils=require(_0x58f5('0x18'));var config=require(_0x58f5('0x19'));var licenseUtil=require('../../config/license/util');var db=require('../../mysqldb')['db'];config['redis']=_[_0x58f5('0x1a')](config[_0x58f5('0x1b')],{'host':_0x58f5('0x1c'),'port':0x18eb});var socket=require(_0x58f5('0x1d'))(new Redis(config['redis']));require(_0x58f5('0x1e'))[_0x58f5('0x1f')](socket);var jayson=require(_0x58f5('0x20'));var client=jayson[_0x58f5('0x21')]['http']({'port':0x232c});var client9002=jayson['client']['http']({'port':0x232a});function respondWithRpcPromise(_0x1d8e57,_0x227ae3,_0x811812,_0x52ccab){return new BPromise(function(_0x2aa508,_0x10a890){var _0x2cb5af=_0x52ccab||client;return _0x2cb5af[_0x58f5('0x22')](_0x1d8e57,_0x811812)[_0x58f5('0x23')](function(_0x4d8e91){logger['info']('FaxMessage,\x20%s,\x20%s',_0x227ae3,_0x58f5('0x24'));logger[_0x58f5('0x25')](_0x58f5('0x26'),_0x227ae3,'request\x20sent',JSON[_0x58f5('0x27')](_0x4d8e91));if(_0x4d8e91['error']){if(_0x4d8e91[_0x58f5('0x28')]['code']===0x1f4){logger[_0x58f5('0x28')]('FaxMessage,\x20%s,\x20%s',_0x227ae3,_0x4d8e91[_0x58f5('0x28')][_0x58f5('0x29')]);return _0x10a890(_0x4d8e91['error'][_0x58f5('0x29')]);}logger[_0x58f5('0x28')](_0x58f5('0x2a'),_0x227ae3,_0x4d8e91['error'][_0x58f5('0x29')]);return _0x2aa508(_0x4d8e91[_0x58f5('0x28')][_0x58f5('0x29')]);}else{logger[_0x58f5('0x2b')](_0x58f5('0x2a'),_0x227ae3,_0x58f5('0x24'));_0x2aa508(_0x4d8e91[_0x58f5('0x2c')][_0x58f5('0x29')]);}})[_0x58f5('0x2d')](function(_0x24c0af){logger[_0x58f5('0x28')](_0x58f5('0x2a'),_0x227ae3,_0x24c0af);_0x10a890(_0x24c0af);});});}function respondWithStatusCode(_0x435c93,_0x3c04ed){_0x3c04ed=_0x3c04ed||0xcc;return function(_0x4d37ef){if(_0x4d37ef){return _0x435c93[_0x58f5('0x2e')](_0x3c04ed);}return _0x435c93['status'](_0x3c04ed)['end']();};}function respondWithResult(_0x5bac79,_0x265c6e){_0x265c6e=_0x265c6e||0xc8;return function(_0x2ea4d2){if(_0x2ea4d2){return _0x5bac79[_0x58f5('0x2f')](_0x265c6e)[_0x58f5('0x30')](_0x2ea4d2);}};}function respondWithFilteredResult(_0x1aa853,_0x1e20d3){return function(_0x5548b3){if(_0x5548b3){var _0x342f81=typeof _0x1e20d3[_0x58f5('0x31')]===_0x58f5('0x32')&&typeof _0x1e20d3[_0x58f5('0x33')]===_0x58f5('0x32');var _0x394024=_0x5548b3['count'];var _0x1d3c56=_0x342f81?0x0:_0x1e20d3[_0x58f5('0x31')];var _0x5ea31c=_0x342f81?_0x5548b3['count']:_0x1e20d3[_0x58f5('0x31')]+_0x1e20d3[_0x58f5('0x33')];var _0x3224d1;if(_0x5ea31c>=_0x394024){_0x5ea31c=_0x394024;_0x3224d1=0xc8;}else{_0x3224d1=0xce;}_0x1aa853[_0x58f5('0x2f')](_0x3224d1);return _0x1aa853[_0x58f5('0x34')]('Content-Range',_0x1d3c56+'-'+_0x5ea31c+'/'+_0x394024)['json'](_0x5548b3);}return null;};}function patchUpdates(_0x1964d9){return function(_0xf2a9ac){try{jsonpatch[_0x58f5('0x35')](_0xf2a9ac,_0x1964d9,!![]);}catch(_0x3a4b56){return BPromise[_0x58f5('0x36')](_0x3a4b56);}return _0xf2a9ac[_0x58f5('0x37')]();};}function saveUpdates(_0xa34382,_0x1072dc){return function(_0x340415){if(_0x340415){return _0x340415['update'](_0xa34382)['then'](function(_0x34ebf5){return _0x34ebf5;});}return null;};}function removeEntity(_0x32cb34,_0x415217){return function(_0x33ab2a){if(_0x33ab2a){return _0x33ab2a['destroy']()['then'](function(){_0x32cb34[_0x58f5('0x2f')](0xcc)[_0x58f5('0x38')]();});}};}function handleEntityNotFound(_0x9152af,_0x4ae66b){return function(_0x4c64c2){if(!_0x4c64c2){_0x9152af['sendStatus'](0x194);}return _0x4c64c2;};}function handleError(_0x16e778,_0x4f9b3a){_0x4f9b3a=_0x4f9b3a||0x1f4;return function(_0x541b11){logger[_0x58f5('0x28')](_0x541b11[_0x58f5('0x39')]);if(_0x541b11[_0x58f5('0x3a')]){delete _0x541b11[_0x58f5('0x3a')];}_0x16e778['status'](_0x4f9b3a)[_0x58f5('0x3b')](_0x541b11);};}exports[_0x58f5('0x3c')]=function(_0x3a746c,_0x5559b3){var _0x5ccc24={},_0xc38960={},_0x116f40={'count':0x0,'rows':[]};var _0x2e51e9=_[_0x58f5('0x3d')](db[_0x58f5('0x3e')][_0x58f5('0x3f')],function(_0x3316e7){return{'name':_0x3316e7[_0x58f5('0x40')],'type':_0x3316e7['type']['key']};});_0xc38960['model']=_[_0x58f5('0x3d')](_0x2e51e9,'name');_0xc38960['query']=_[_0x58f5('0x41')](_0x3a746c[_0x58f5('0x42')]);_0xc38960[_0x58f5('0x43')]=_[_0x58f5('0x44')](_0xc38960[_0x58f5('0x45')],_0xc38960[_0x58f5('0x42')]);_0x5ccc24[_0x58f5('0x46')]=_['intersection'](_0xc38960[_0x58f5('0x45')],qs[_0x58f5('0x47')](_0x3a746c[_0x58f5('0x42')][_0x58f5('0x47')]));_0x5ccc24[_0x58f5('0x46')]=_0x5ccc24[_0x58f5('0x46')][_0x58f5('0x48')]?_0x5ccc24[_0x58f5('0x46')]:_0xc38960[_0x58f5('0x45')];if(!_0x3a746c[_0x58f5('0x42')][_0x58f5('0x49')](_0x58f5('0x4a'))){_0x5ccc24[_0x58f5('0x33')]=qs['limit'](_0x3a746c[_0x58f5('0x42')][_0x58f5('0x33')]);_0x5ccc24[_0x58f5('0x31')]=qs[_0x58f5('0x31')](_0x3a746c[_0x58f5('0x42')][_0x58f5('0x31')]);}_0x5ccc24[_0x58f5('0x4b')]=qs[_0x58f5('0x4c')](_0x3a746c['query']['sort']);_0x5ccc24[_0x58f5('0x4d')]=qs[_0x58f5('0x43')](_['pick'](_0x3a746c[_0x58f5('0x42')],_0xc38960[_0x58f5('0x43')]),_0x2e51e9);if(_0x3a746c[_0x58f5('0x42')]['filter']){_0x5ccc24[_0x58f5('0x4d')]=_['merge'](_0x5ccc24[_0x58f5('0x4d')],{'$or':_['map'](_0x2e51e9,function(_0x5c0330){if(_0x5c0330[_0x58f5('0x4e')]!==_0x58f5('0x4f')){var _0x5b86ed={};_0x5b86ed[_0x5c0330[_0x58f5('0x3a')]]={'$like':'%'+_0x3a746c[_0x58f5('0x42')][_0x58f5('0x50')]+'%'};return _0x5b86ed;}})});}_0x5ccc24=_[_0x58f5('0x51')]({},_0x5ccc24,_0x3a746c['options']);var _0x6d5d17={'where':_0x5ccc24['where']};return db['FaxMessage'][_0x58f5('0x52')](_0x6d5d17)[_0x58f5('0x23')](function(_0x15d486){_0x116f40[_0x58f5('0x52')]=_0x15d486;if(_0x3a746c[_0x58f5('0x42')][_0x58f5('0x53')]){_0x5ccc24['include']=[{'all':!![]}];}return db[_0x58f5('0x3e')][_0x58f5('0x54')](_0x5ccc24);})[_0x58f5('0x23')](function(_0x493a7f){_0x116f40[_0x58f5('0x55')]=_0x493a7f;return _0x116f40;})[_0x58f5('0x23')](respondWithFilteredResult(_0x5559b3,_0x5ccc24))[_0x58f5('0x2d')](handleError(_0x5559b3,null));};exports[_0x58f5('0x56')]=function(_0x3a2150,_0x1c8871){var _0x19a41e={'raw':!![],'where':{'id':_0x3a2150[_0x58f5('0x57')]['id']}},_0x2083e8={};_0x2083e8[_0x58f5('0x45')]=_[_0x58f5('0x41')](db['FaxMessage'][_0x58f5('0x3f')]);_0x2083e8[_0x58f5('0x42')]=_[_0x58f5('0x41')](_0x3a2150['query']);_0x2083e8[_0x58f5('0x43')]=_['intersection'](_0x2083e8['model'],_0x2083e8[_0x58f5('0x42')]);_0x19a41e[_0x58f5('0x46')]=_[_0x58f5('0x44')](_0x2083e8[_0x58f5('0x45')],qs[_0x58f5('0x47')](_0x3a2150[_0x58f5('0x42')][_0x58f5('0x47')]));_0x19a41e[_0x58f5('0x46')]=_0x19a41e[_0x58f5('0x46')][_0x58f5('0x48')]?_0x19a41e[_0x58f5('0x46')]:_0x2083e8[_0x58f5('0x45')];if(_0x3a2150[_0x58f5('0x42')]['includeAll']){_0x19a41e[_0x58f5('0x58')]=[{'all':!![]}];}_0x19a41e=_['merge']({},_0x19a41e,_0x3a2150[_0x58f5('0x59')]);return db[_0x58f5('0x3e')][_0x58f5('0x5a')](_0x19a41e)['then'](handleEntityNotFound(_0x1c8871,null))[_0x58f5('0x23')](respondWithResult(_0x1c8871,null))[_0x58f5('0x2d')](handleError(_0x1c8871,null));};exports['update']=function(_0x4b0c89,_0x4bdf2d){if(_0x4b0c89[_0x58f5('0x5b')]['id']){delete _0x4b0c89['body']['id'];}return db['FaxMessage'][_0x58f5('0x5a')]({'where':{'id':_0x4b0c89[_0x58f5('0x57')]['id']}})[_0x58f5('0x23')](handleEntityNotFound(_0x4bdf2d,null))[_0x58f5('0x23')](saveUpdates(_0x4b0c89['body'],null))['then'](respondWithResult(_0x4bdf2d,null))[_0x58f5('0x2d')](handleError(_0x4bdf2d,null));};exports[_0x58f5('0x5c')]=function(_0x2896e8,_0x4d6ceb){return db[_0x58f5('0x3e')][_0x58f5('0x5a')]({'where':{'id':_0x2896e8['params']['id']}})[_0x58f5('0x23')](handleEntityNotFound(_0x4d6ceb,null))['then'](removeEntity(_0x4d6ceb,null))[_0x58f5('0x2d')](handleError(_0x4d6ceb,null));};exports[_0x58f5('0x5d')]=function(_0x446ea6,_0x5cc949){return db['FaxMessage'][_0x58f5('0x5d')]()[_0x58f5('0x23')](respondWithResult(_0x5cc949,null))[_0x58f5('0x2d')](handleError(_0x5cc949,null));};var interaction_log=require(_0x58f5('0x17'))(_0x58f5('0x5e'));exports[_0x58f5('0x5f')]=function(_0xdd9965,_0xfcda5a,_0x4ee10c){var _0x4bde33={'agent':{},'channel':_0x58f5('0x60')};if(_0xdd9965[_0x58f5('0x5b')]['id']){delete _0xdd9965[_0x58f5('0x5b')]['id'];}_0xdd9965[_0x58f5('0x5b')][_0x58f5('0x61')]=!![];_0xdd9965[_0x58f5('0x5b')]['readAt']=moment()[_0x58f5('0x62')]('YYYY-MM-DD\x20HH:mm:ss');_0xdd9965[_0x58f5('0x5b')]['UserId']=_0xdd9965[_0x58f5('0x5b')]['UserId']||_0xdd9965[_0x58f5('0x63')]['id'];_0x4bde33['agent']['id']=_0xdd9965[_0x58f5('0x5b')]['UserId'];return db[_0x58f5('0x3e')][_0x58f5('0x5a')]({'where':{'id':_0xdd9965['params']['id'],'UserId':null}})[_0x58f5('0x23')](handleEntityNotFound(_0xfcda5a,null))[_0x58f5('0x23')](saveUpdates(_0xdd9965[_0x58f5('0x5b')],null))[_0x58f5('0x23')](function(_0x16da85){if(_0x16da85){_0x4bde33[_0x58f5('0x29')]=_0x16da85[_0x58f5('0x64')]({'plain':!![]});return db['FaxInteraction'][_0x58f5('0x5a')]({'where':{'id':_0x16da85[_0x58f5('0x65')]}});}return null;})[_0x58f5('0x23')](handleEntityNotFound(_0xfcda5a,null))[_0x58f5('0x23')](function(_0x1b3494){if(_0x1b3494){return _0x1b3494[_0x58f5('0x66')]({'UserId':_0xdd9965[_0x58f5('0x5b')][_0x58f5('0x67')],'read1stAt':_[_0x58f5('0x68')](_0x1b3494[_0x58f5('0x69')])?moment()[_0x58f5('0x62')](_0x58f5('0x6a')):undefined});}return null;})[_0x58f5('0x23')](function(_0xbaf42b){if(_0xbaf42b){_0x4bde33[_0x58f5('0x6b')]=_0xbaf42b[_0x58f5('0x64')]({'plain':!![]});interaction_log[_0x58f5('0x2b')]('[FAXMESSAGE:ACCEPT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s',_0xdd9965[_0x58f5('0x63')]['id'],_0xdd9965[_0x58f5('0x63')]['name'],_0xdd9965[_0x58f5('0x63')][_0x58f5('0x6c')],_0x4bde33[_0x58f5('0x6b')]['id'],_0xdd9965[_0x58f5('0x5b')]?JSON[_0x58f5('0x27')](_0xdd9965[_0x58f5('0x5b')]):_0x58f5('0x6d'));return respondWithRpcPromise('AcceptMessage',_0x58f5('0x6e'),_0x4bde33);}return null;})[_0x58f5('0x23')](function(_0x5e8c6c){var _0x157c47=_0x58f5('0x6f')+_0x5e8c6c[_0x58f5('0x29')][_0x58f5('0x70')];return db['sequelize'][_0x58f5('0x42')](_0x157c47,{'type':db[_0x58f5('0x71')][_0x58f5('0x72')][_0x58f5('0x73')],'raw':!![]})[_0x58f5('0x23')](function(_0x11a673){return _0x11a673;});})[_0x58f5('0x23')](function(_0x810988){if(_0x810988){_0x4bde33['message']['contact']=_0x810988[0x0];if(!_0xdd9965[_0x58f5('0x5b')][_0x58f5('0x67')])return;return db[_0x58f5('0x74')][_0x58f5('0x5a')]({'where':{'id':_0xdd9965[_0x58f5('0x5b')][_0x58f5('0x67')],'role':_0x58f5('0x75')},'attributes':['id',_0x58f5('0x3a'),_0x58f5('0x76'),_0x58f5('0x77'),_0x58f5('0x78')],'raw':!![]});}return null;})['then'](function(_0x51bf4a){if(!_0x51bf4a)return null;_0x4bde33[_0x58f5('0x29')]['agent']=_0x51bf4a;return _0x4bde33;})[_0x58f5('0x23')](function(_0x3beb5b){if(_0x3beb5b){if(_0xdd9965[_0x58f5('0x5b')][_0x58f5('0x79')]){_0x4bde33[_0x58f5('0x29')][_0x58f5('0x7a')]=util[_0x58f5('0x62')](_0x58f5('0x7b'),_0xdd9965['user'][_0x58f5('0x3a')]);_0x4bde33[_0x58f5('0x29')][_0x58f5('0x7c')]=_0x4bde33['channel'];_0x4bde33[_0x58f5('0x29')]['motionChannel']=_0x4bde33[_0x58f5('0x7c')];_0x4bde33['message'][_0x58f5('0x7d')]=_0x58f5('0x5f');return respondWithRpcPromise('EventManager',_0x58f5('0x7e'),{'event':_0x58f5('0x7f'),'message':_0x4bde33[_0x58f5('0x29')]},client9002)[_0x58f5('0x23')](function(){return _0x4bde33;});}return _0x4bde33;}return null;})[_0x58f5('0x23')](respondWithResult(_0xfcda5a,null))['catch'](handleError(_0xfcda5a,null));};var interaction_log=require(_0x58f5('0x17'))('fax-interactions');exports[_0x58f5('0x36')]=function(_0x36d5b3,_0x34320b,_0x4720de){var _0x573156={'agent':{},'channel':_0x58f5('0x60')};if(_0x36d5b3[_0x58f5('0x5b')]['id']){delete _0x36d5b3['body']['id'];}_0x36d5b3[_0x58f5('0x5b')][_0x58f5('0x67')]=_0x36d5b3[_0x58f5('0x5b')][_0x58f5('0x67')]||_0x36d5b3['user']['id'];_0x573156[_0x58f5('0x75')]['id']=_0x36d5b3[_0x58f5('0x5b')]['UserId'];return db[_0x58f5('0x3e')][_0x58f5('0x5a')]({'where':{'id':_0x36d5b3[_0x58f5('0x57')]['id'],'UserId':null}})['then'](handleEntityNotFound(_0x34320b,null))['then'](function(_0x32e828){if(_0x32e828){_0x573156[_0x58f5('0x29')]=_0x32e828[_0x58f5('0x64')]({'plain':!![]});return db[_0x58f5('0x80')][_0x58f5('0x5a')]({'where':{'id':_0x32e828['FaxInteractionId']}});}return null;})[_0x58f5('0x23')](handleEntityNotFound(_0x34320b,null))[_0x58f5('0x23')](function(_0x22ef7b){if(_0x22ef7b){_0x573156[_0x58f5('0x6b')]=_0x22ef7b[_0x58f5('0x64')]({'plain':!![]});interaction_log[_0x58f5('0x2b')](_0x58f5('0x81'),_0x36d5b3[_0x58f5('0x63')]['id'],_0x36d5b3[_0x58f5('0x63')][_0x58f5('0x3a')],_0x36d5b3['user']['role'],_0x573156[_0x58f5('0x6b')]['id'],_0x36d5b3[_0x58f5('0x5b')]?JSON['stringify'](_0x36d5b3['body']):_0x58f5('0x6d'));return respondWithRpcPromise(_0x58f5('0x82'),_0x58f5('0x83'),_0x573156);}return null;})[_0x58f5('0x23')](function(_0x1161a0){var _0x1718e9='SELECT\x20*\x20FROM\x20cm_contacts\x20WHERE\x20id\x20=\x20'+_0x1161a0[_0x58f5('0x29')][_0x58f5('0x70')];return db[_0x58f5('0x84')][_0x58f5('0x42')](_0x1718e9,{'type':db[_0x58f5('0x71')]['QueryTypes'][_0x58f5('0x73')],'raw':!![]})[_0x58f5('0x23')](function(_0x433a94){return _0x433a94;});})['then'](function(_0x54b86c){if(_0x54b86c){_0x573156[_0x58f5('0x29')][_0x58f5('0x85')]=_0x54b86c[0x0];if(!_0x36d5b3[_0x58f5('0x5b')][_0x58f5('0x67')])return;return db[_0x58f5('0x74')]['find']({'where':{'id':_0x36d5b3[_0x58f5('0x5b')][_0x58f5('0x67')],'role':_0x58f5('0x75')},'attributes':['id',_0x58f5('0x3a'),_0x58f5('0x76'),_0x58f5('0x77'),'internal'],'raw':!![]});}return null;})['then'](function(_0x391d17){if(!_0x391d17)return null;_0x573156[_0x58f5('0x29')][_0x58f5('0x75')]=_0x391d17;return _0x573156;})[_0x58f5('0x23')](function(_0x3c160f){if(_0x3c160f){_0x3c160f[_0x58f5('0x29')][_0x58f5('0x7a')]=util[_0x58f5('0x62')](_0x58f5('0x7b'),_0x36d5b3[_0x58f5('0x63')][_0x58f5('0x3a')]);_0x3c160f[_0x58f5('0x29')][_0x58f5('0x7c')]=_0x573156['channel'];_0x3c160f['message'][_0x58f5('0x86')]=_0x573156['channel'];_0x3c160f[_0x58f5('0x29')]['event']='reject';respondWithRpcPromise('EventManager','EventManager',{'event':_0x58f5('0x87'),'message':_0x3c160f['message']},client9002);return _0x573156;}return null;})['then'](respondWithResult(_0x34320b,null))[_0x58f5('0x2d')](handleError(_0x34320b,null));};exports[_0x58f5('0x88')]=function(_0x29313e,_0x23c3e5){var _0x378485;return db['FaxMessage'][_0x58f5('0x88')](_0x29313e[_0x58f5('0x5b')],{})[_0x58f5('0x23')](function(_0x2cb91e){_0x378485=_0x2cb91e;return db['CmContact'][_0x58f5('0x89')]({'where':{'id':_0x378485['ContactId']}});})[_0x58f5('0x23')](function(_0x431f89){if(_[_0x58f5('0x68')](_0x431f89)){return;}else{_0x378485[_0x58f5('0x60')]=_0x431f89[_0x58f5('0x60')];return db['Attachment'][_0x58f5('0x89')]({'where':{'id':_0x378485[_0x58f5('0x8a')]}});}})[_0x58f5('0x23')](function(_0x1f11e6){return respondWithRpcPromise(_0x58f5('0x8b'),_0x58f5('0x8b'),{'FaxAccountId':_[_0x58f5('0x68')](_0x29313e[_0x58f5('0x5b')])?undefined:_0x29313e[_0x58f5('0x5b')][_0x58f5('0x8c')],'path':_[_0x58f5('0x68')](_0x1f11e6)?undefined:util[_0x58f5('0x62')](_0x58f5('0x8d'),_0x1f11e6[_0x58f5('0x8e')]),'fax':_['isNil'](_0x378485[_0x58f5('0x60')])?undefined:_0x378485[_0x58f5('0x60')],'AttachmentId':_0x378485[_0x58f5('0x8a')]},client9002);})[_0x58f5('0x23')](respondWithResult(_0x23c3e5,0xc9))['catch'](handleError(_0x23c3e5,null));};exports[_0x58f5('0x8f')]=function(_0x4f66b6,_0x487ac7){var _0x3c0f1e=path[_0x58f5('0x90')](config['root'],_0x58f5('0x91'),'files',_0x58f5('0x92'));return db[_0x58f5('0x3e')]['find']({'where':{'id':_0x4f66b6['params']['id']},'include':[{'model':db[_0x58f5('0x93')],'as':'Attachment'}]})[_0x58f5('0x23')](handleEntityNotFound(_0x487ac7,null))[_0x58f5('0x23')](function(_0x4b398a){if(_0x4b398a){return _0x487ac7[_0x58f5('0x8f')](path[_0x58f5('0x90')](_0x3c0f1e,_0x4b398a[_0x58f5('0x93')][_0x58f5('0x8e')]));}})['catch'](handleError(_0x487ac7,null));};
\ No newline at end of file
+var _0x209c=['[FAXMESSAGE:ACCEPT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','user','role','null','acceptMessage','SELECT\x20*\x20FROM\x20cm_contacts\x20WHERE\x20id\x20=\x20','ContactId','sequelize','SELECT','contact','User','fullname','email','internal','manual','interface','SIP/%s','channel','motionChannel','event','EventManager','get','FaxInteractionId','RejectMessage','rejectMessage','QueryTypes','reject','rejectmessage','create','CmContact','findOne','isNil','Attachment','SendFax','FaxAccountId','/var/opt/motion2/server/files/attachments/%s','basename','AttachmentId','join','root','server','files','attachments','download','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','bluebird','mustache','util','path','sox','ejs','fs-extra','lodash','squel','crypto','to-csv','querystring','papaparse','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/license/util','../../mysqldb','redis','defaults','socket.io-emitter','./faxMessage.socket','jayson/promise','client','http','then','info','request\x20sent','debug','FaxMessage,\x20%s,\x20%s,\x20%s','stringify','code','error','FaxMessage,\x20%s,\x20%s','message','result','catch','sendStatus','status','undefined','limit','count','offset','set','save','stack','name','send','index','map','fieldName','type','model','query','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','where','pick','filter','merge','VIRTUAL','includeAll','include','FaxMessage','findAll','show','params','keys','rawAttributes','options','update','body','find','destroy','describe','fax-interactions','accept','fax','read','readAt','format','YYYY-MM-DD\x20HH:mm:ss','UserId','agent','FaxInteraction','interaction'];(function(_0x385f81,_0x394333){var _0x390b9e=function(_0x5541b7){while(--_0x5541b7){_0x385f81['push'](_0x385f81['shift']());}};_0x390b9e(++_0x394333);}(_0x209c,0xba));var _0xc209=function(_0x1f2ede,_0x1e686c){_0x1f2ede=_0x1f2ede-0x0;var _0x1f74ba=_0x209c[_0x1f2ede];return _0x1f74ba;};'use strict';var emlformat=require(_0xc209('0x0'));var rimraf=require(_0xc209('0x1'));var zipdir=require(_0xc209('0x2'));var jsonpatch=require(_0xc209('0x3'));var rp=require(_0xc209('0x4'));var moment=require('moment');var BPromise=require(_0xc209('0x5'));var Mustache=require(_0xc209('0x6'));var util=require(_0xc209('0x7'));var path=require(_0xc209('0x8'));var sox=require(_0xc209('0x9'));var csv=require('to-csv');var ejs=require(_0xc209('0xa'));var fs=require('fs');var fs_extra=require(_0xc209('0xb'));var _=require(_0xc209('0xc'));var squel=require(_0xc209('0xd'));var crypto=require(_0xc209('0xe'));var jsforce=require('jsforce');var deskjs=require('desk.js');var toCsv=require(_0xc209('0xf'));var querystring=require(_0xc209('0x10'));var Papa=require(_0xc209('0x11'));var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require(_0xc209('0x12'));var as=require(_0xc209('0x13'));var hardwareService=require(_0xc209('0x14'));var logger=require(_0xc209('0x15'))(_0xc209('0x16'));var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require(_0xc209('0x17'));var db=require(_0xc209('0x18'))['db'];config[_0xc209('0x19')]=_[_0xc209('0x1a')](config[_0xc209('0x19')],{'host':'localhost','port':0x18eb});var socket=require(_0xc209('0x1b'))(new Redis(config[_0xc209('0x19')]));require(_0xc209('0x1c'))['register'](socket);var jayson=require(_0xc209('0x1d'));var client=jayson[_0xc209('0x1e')][_0xc209('0x1f')]({'port':0x232c});var client9002=jayson[_0xc209('0x1e')][_0xc209('0x1f')]({'port':0x232a});function respondWithRpcPromise(_0x5e5805,_0x41bcf6,_0x5504cb,_0x55ef20){return new BPromise(function(_0x4a46fc,_0x201db4){var _0xe0f1db=_0x55ef20||client;return _0xe0f1db['request'](_0x5e5805,_0x5504cb)[_0xc209('0x20')](function(_0x282b8f){logger[_0xc209('0x21')]('FaxMessage,\x20%s,\x20%s',_0x41bcf6,_0xc209('0x22'));logger[_0xc209('0x23')](_0xc209('0x24'),_0x41bcf6,'request\x20sent',JSON[_0xc209('0x25')](_0x282b8f));if(_0x282b8f['error']){if(_0x282b8f['error'][_0xc209('0x26')]===0x1f4){logger[_0xc209('0x27')](_0xc209('0x28'),_0x41bcf6,_0x282b8f[_0xc209('0x27')][_0xc209('0x29')]);return _0x201db4(_0x282b8f['error'][_0xc209('0x29')]);}logger[_0xc209('0x27')]('FaxMessage,\x20%s,\x20%s',_0x41bcf6,_0x282b8f['error'][_0xc209('0x29')]);return _0x4a46fc(_0x282b8f[_0xc209('0x27')][_0xc209('0x29')]);}else{logger[_0xc209('0x21')](_0xc209('0x28'),_0x41bcf6,_0xc209('0x22'));_0x4a46fc(_0x282b8f[_0xc209('0x2a')][_0xc209('0x29')]);}})[_0xc209('0x2b')](function(_0x34bb3a){logger['error'](_0xc209('0x28'),_0x41bcf6,_0x34bb3a);_0x201db4(_0x34bb3a);});});}function respondWithStatusCode(_0x148563,_0x3bd872){_0x3bd872=_0x3bd872||0xcc;return function(_0x3a4e76){if(_0x3a4e76){return _0x148563[_0xc209('0x2c')](_0x3bd872);}return _0x148563[_0xc209('0x2d')](_0x3bd872)['end']();};}function respondWithResult(_0x4ddfd5,_0x565fe3){_0x565fe3=_0x565fe3||0xc8;return function(_0x1e7134){if(_0x1e7134){return _0x4ddfd5[_0xc209('0x2d')](_0x565fe3)['json'](_0x1e7134);}};}function respondWithFilteredResult(_0x37d535,_0x5ab9cf){return function(_0x1d326f){if(_0x1d326f){var _0x281b3a=typeof _0x5ab9cf['offset']===_0xc209('0x2e')&&typeof _0x5ab9cf[_0xc209('0x2f')]===_0xc209('0x2e');var _0x565af0=_0x1d326f[_0xc209('0x30')];var _0x8782cf=_0x281b3a?0x0:_0x5ab9cf[_0xc209('0x31')];var _0x5c4acc=_0x281b3a?_0x1d326f[_0xc209('0x30')]:_0x5ab9cf[_0xc209('0x31')]+_0x5ab9cf[_0xc209('0x2f')];var _0x20d016;if(_0x5c4acc>=_0x565af0){_0x5c4acc=_0x565af0;_0x20d016=0xc8;}else{_0x20d016=0xce;}_0x37d535[_0xc209('0x2d')](_0x20d016);return _0x37d535[_0xc209('0x32')]('Content-Range',_0x8782cf+'-'+_0x5c4acc+'/'+_0x565af0)['json'](_0x1d326f);}return null;};}function patchUpdates(_0x4220a9){return function(_0x18cb32){try{jsonpatch['apply'](_0x18cb32,_0x4220a9,!![]);}catch(_0x384d73){return BPromise['reject'](_0x384d73);}return _0x18cb32[_0xc209('0x33')]();};}function saveUpdates(_0x3bb9b7,_0x37aaf1){return function(_0xecba7a){if(_0xecba7a){return _0xecba7a['update'](_0x3bb9b7)[_0xc209('0x20')](function(_0x3ca488){return _0x3ca488;});}return null;};}function removeEntity(_0x405a28,_0x12f08f){return function(_0x57bef9){if(_0x57bef9){return _0x57bef9['destroy']()[_0xc209('0x20')](function(){_0x405a28['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x1c7c59,_0x423e82){return function(_0x448b2a){if(!_0x448b2a){_0x1c7c59[_0xc209('0x2c')](0x194);}return _0x448b2a;};}function handleError(_0x5bab54,_0x398e45){_0x398e45=_0x398e45||0x1f4;return function(_0x1d4a25){logger[_0xc209('0x27')](_0x1d4a25[_0xc209('0x34')]);if(_0x1d4a25['name']){delete _0x1d4a25[_0xc209('0x35')];}_0x5bab54[_0xc209('0x2d')](_0x398e45)[_0xc209('0x36')](_0x1d4a25);};}exports[_0xc209('0x37')]=function(_0x5ce5b1,_0x1a7681){var _0x9f4486={},_0x26b066={},_0x1eaa1d={'count':0x0,'rows':[]};var _0x423466=_[_0xc209('0x38')](db['FaxMessage']['rawAttributes'],function(_0x1128bb){return{'name':_0x1128bb[_0xc209('0x39')],'type':_0x1128bb[_0xc209('0x3a')]['key']};});_0x26b066[_0xc209('0x3b')]=_[_0xc209('0x38')](_0x423466,_0xc209('0x35'));_0x26b066[_0xc209('0x3c')]=_['keys'](_0x5ce5b1[_0xc209('0x3c')]);_0x26b066[_0xc209('0x3d')]=_[_0xc209('0x3e')](_0x26b066[_0xc209('0x3b')],_0x26b066[_0xc209('0x3c')]);_0x9f4486[_0xc209('0x3f')]=_['intersection'](_0x26b066[_0xc209('0x3b')],qs['fields'](_0x5ce5b1[_0xc209('0x3c')][_0xc209('0x40')]));_0x9f4486['attributes']=_0x9f4486['attributes'][_0xc209('0x41')]?_0x9f4486[_0xc209('0x3f')]:_0x26b066[_0xc209('0x3b')];if(!_0x5ce5b1[_0xc209('0x3c')][_0xc209('0x42')](_0xc209('0x43'))){_0x9f4486[_0xc209('0x2f')]=qs[_0xc209('0x2f')](_0x5ce5b1['query'][_0xc209('0x2f')]);_0x9f4486['offset']=qs[_0xc209('0x31')](_0x5ce5b1[_0xc209('0x3c')][_0xc209('0x31')]);}_0x9f4486['order']=qs['sort'](_0x5ce5b1[_0xc209('0x3c')]['sort']);_0x9f4486[_0xc209('0x44')]=qs[_0xc209('0x3d')](_[_0xc209('0x45')](_0x5ce5b1[_0xc209('0x3c')],_0x26b066['filters']),_0x423466);if(_0x5ce5b1[_0xc209('0x3c')][_0xc209('0x46')]){_0x9f4486['where']=_[_0xc209('0x47')](_0x9f4486[_0xc209('0x44')],{'$or':_[_0xc209('0x38')](_0x423466,function(_0x1eb1cb){if(_0x1eb1cb[_0xc209('0x3a')]!==_0xc209('0x48')){var _0x50c347={};_0x50c347[_0x1eb1cb[_0xc209('0x35')]]={'$like':'%'+_0x5ce5b1[_0xc209('0x3c')][_0xc209('0x46')]+'%'};return _0x50c347;}})});}_0x9f4486=_[_0xc209('0x47')]({},_0x9f4486,_0x5ce5b1['options']);var _0x28a4dc={'where':_0x9f4486[_0xc209('0x44')]};return db['FaxMessage'][_0xc209('0x30')](_0x28a4dc)['then'](function(_0xe319f7){_0x1eaa1d[_0xc209('0x30')]=_0xe319f7;if(_0x5ce5b1['query'][_0xc209('0x49')]){_0x9f4486[_0xc209('0x4a')]=[{'all':!![]}];}return db[_0xc209('0x4b')][_0xc209('0x4c')](_0x9f4486);})['then'](function(_0x26081e){_0x1eaa1d['rows']=_0x26081e;return _0x1eaa1d;})['then'](respondWithFilteredResult(_0x1a7681,_0x9f4486))[_0xc209('0x2b')](handleError(_0x1a7681,null));};exports[_0xc209('0x4d')]=function(_0x396f18,_0x5e692e){var _0x18cfcf={'raw':!![],'where':{'id':_0x396f18[_0xc209('0x4e')]['id']}},_0xf69bef={};_0xf69bef['model']=_[_0xc209('0x4f')](db[_0xc209('0x4b')][_0xc209('0x50')]);_0xf69bef[_0xc209('0x3c')]=_[_0xc209('0x4f')](_0x396f18[_0xc209('0x3c')]);_0xf69bef[_0xc209('0x3d')]=_['intersection'](_0xf69bef['model'],_0xf69bef['query']);_0x18cfcf[_0xc209('0x3f')]=_[_0xc209('0x3e')](_0xf69bef[_0xc209('0x3b')],qs[_0xc209('0x40')](_0x396f18['query']['fields']));_0x18cfcf[_0xc209('0x3f')]=_0x18cfcf[_0xc209('0x3f')]['length']?_0x18cfcf[_0xc209('0x3f')]:_0xf69bef[_0xc209('0x3b')];if(_0x396f18['query']['includeAll']){_0x18cfcf[_0xc209('0x4a')]=[{'all':!![]}];}_0x18cfcf=_[_0xc209('0x47')]({},_0x18cfcf,_0x396f18[_0xc209('0x51')]);return db[_0xc209('0x4b')]['find'](_0x18cfcf)['then'](handleEntityNotFound(_0x5e692e,null))[_0xc209('0x20')](respondWithResult(_0x5e692e,null))[_0xc209('0x2b')](handleError(_0x5e692e,null));};exports[_0xc209('0x52')]=function(_0x29ef18,_0x1b4418){if(_0x29ef18[_0xc209('0x53')]['id']){delete _0x29ef18[_0xc209('0x53')]['id'];}return db[_0xc209('0x4b')][_0xc209('0x54')]({'where':{'id':_0x29ef18[_0xc209('0x4e')]['id']}})['then'](handleEntityNotFound(_0x1b4418,null))[_0xc209('0x20')](saveUpdates(_0x29ef18[_0xc209('0x53')],null))['then'](respondWithResult(_0x1b4418,null))[_0xc209('0x2b')](handleError(_0x1b4418,null));};exports[_0xc209('0x55')]=function(_0x5f1ba3,_0x42675b){return db[_0xc209('0x4b')][_0xc209('0x54')]({'where':{'id':_0x5f1ba3[_0xc209('0x4e')]['id']}})[_0xc209('0x20')](handleEntityNotFound(_0x42675b,null))[_0xc209('0x20')](removeEntity(_0x42675b,null))['catch'](handleError(_0x42675b,null));};exports['describe']=function(_0x21c93d,_0x90a749){return db['FaxMessage'][_0xc209('0x56')]()[_0xc209('0x20')](respondWithResult(_0x90a749,null))[_0xc209('0x2b')](handleError(_0x90a749,null));};var interaction_log=require(_0xc209('0x15'))(_0xc209('0x57'));exports[_0xc209('0x58')]=function(_0xd8d434,_0x297fb2,_0x17fb61){var _0x16d28b={'agent':{},'channel':_0xc209('0x59')};if(_0xd8d434['body']['id']){delete _0xd8d434['body']['id'];}_0xd8d434[_0xc209('0x53')][_0xc209('0x5a')]=!![];_0xd8d434['body'][_0xc209('0x5b')]=moment()[_0xc209('0x5c')](_0xc209('0x5d'));_0xd8d434[_0xc209('0x53')][_0xc209('0x5e')]=_0xd8d434['body'][_0xc209('0x5e')]||_0xd8d434['user']['id'];_0x16d28b[_0xc209('0x5f')]['id']=_0xd8d434['body'][_0xc209('0x5e')];return db[_0xc209('0x4b')][_0xc209('0x54')]({'where':{'id':_0xd8d434[_0xc209('0x4e')]['id'],'UserId':null}})[_0xc209('0x20')](handleEntityNotFound(_0x297fb2,null))[_0xc209('0x20')](saveUpdates(_0xd8d434['body'],null))[_0xc209('0x20')](function(_0x4b07bc){if(_0x4b07bc){_0x16d28b['message']=_0x4b07bc['get']({'plain':!![]});return db[_0xc209('0x60')][_0xc209('0x54')]({'where':{'id':_0x4b07bc['FaxInteractionId']}});}return null;})[_0xc209('0x20')](handleEntityNotFound(_0x297fb2,null))[_0xc209('0x20')](function(_0x5a9a19){if(_0x5a9a19){return _0x5a9a19[_0xc209('0x52')]({'UserId':_0xd8d434['body'][_0xc209('0x5e')],'read1stAt':_['isNil'](_0x5a9a19['read1stAt'])?moment()[_0xc209('0x5c')](_0xc209('0x5d')):undefined});}return null;})['then'](function(_0x54f4a0){if(_0x54f4a0){_0x16d28b[_0xc209('0x61')]=_0x54f4a0['get']({'plain':!![]});interaction_log[_0xc209('0x21')](_0xc209('0x62'),_0xd8d434[_0xc209('0x63')]['id'],_0xd8d434['user'][_0xc209('0x35')],_0xd8d434['user'][_0xc209('0x64')],_0x16d28b['interaction']['id'],_0xd8d434[_0xc209('0x53')]?JSON[_0xc209('0x25')](_0xd8d434[_0xc209('0x53')]):_0xc209('0x65'));return respondWithRpcPromise('AcceptMessage',_0xc209('0x66'),_0x16d28b);}return null;})['then'](function(_0x236d31){var _0xf48b2=_0xc209('0x67')+_0x236d31[_0xc209('0x29')][_0xc209('0x68')];return db[_0xc209('0x69')]['query'](_0xf48b2,{'type':db['Sequelize']['QueryTypes'][_0xc209('0x6a')],'raw':!![]})[_0xc209('0x20')](function(_0x5eac15){return _0x5eac15;});})[_0xc209('0x20')](function(_0x4db6b8){if(_0x4db6b8){_0x16d28b['message'][_0xc209('0x6b')]=_0x4db6b8[0x0];if(!_0xd8d434[_0xc209('0x53')][_0xc209('0x5e')])return;return db[_0xc209('0x6c')]['find']({'where':{'id':_0xd8d434[_0xc209('0x53')][_0xc209('0x5e')],'role':_0xc209('0x5f')},'attributes':['id',_0xc209('0x35'),_0xc209('0x6d'),_0xc209('0x6e'),_0xc209('0x6f')],'raw':!![]});}return null;})[_0xc209('0x20')](function(_0xb1cf61){if(!_0xb1cf61)return null;_0x16d28b[_0xc209('0x29')][_0xc209('0x5f')]=_0xb1cf61;return _0x16d28b;})[_0xc209('0x20')](function(_0x40a96f){if(_0x40a96f){if(_0xd8d434[_0xc209('0x53')][_0xc209('0x70')]){_0x16d28b[_0xc209('0x29')][_0xc209('0x71')]=util[_0xc209('0x5c')](_0xc209('0x72'),_0xd8d434[_0xc209('0x63')][_0xc209('0x35')]);_0x16d28b['message']['channel']=_0x16d28b[_0xc209('0x73')];_0x16d28b[_0xc209('0x29')][_0xc209('0x74')]=_0x16d28b['channel'];_0x16d28b[_0xc209('0x29')][_0xc209('0x75')]=_0xc209('0x58');return respondWithRpcPromise(_0xc209('0x76'),_0xc209('0x76'),{'event':'acceptmessage','message':_0x16d28b[_0xc209('0x29')]},client9002)[_0xc209('0x20')](function(){return _0x16d28b;});}return _0x16d28b;}return null;})[_0xc209('0x20')](respondWithResult(_0x297fb2,null))[_0xc209('0x2b')](handleError(_0x297fb2,null));};var interaction_log=require(_0xc209('0x15'))(_0xc209('0x57'));exports['reject']=function(_0x56a3a2,_0x5457c3,_0xfd9f33){var _0x1548c4={'agent':{},'channel':'fax'};if(_0x56a3a2[_0xc209('0x53')]['id']){delete _0x56a3a2[_0xc209('0x53')]['id'];}_0x56a3a2['body'][_0xc209('0x5e')]=_0x56a3a2[_0xc209('0x53')][_0xc209('0x5e')]||_0x56a3a2[_0xc209('0x63')]['id'];_0x1548c4[_0xc209('0x5f')]['id']=_0x56a3a2['body'][_0xc209('0x5e')];return db[_0xc209('0x4b')]['find']({'where':{'id':_0x56a3a2['params']['id'],'UserId':null}})[_0xc209('0x20')](handleEntityNotFound(_0x5457c3,null))['then'](function(_0x1574b7){if(_0x1574b7){_0x1548c4[_0xc209('0x29')]=_0x1574b7[_0xc209('0x77')]({'plain':!![]});return db[_0xc209('0x60')][_0xc209('0x54')]({'where':{'id':_0x1574b7[_0xc209('0x78')]}});}return null;})[_0xc209('0x20')](handleEntityNotFound(_0x5457c3,null))[_0xc209('0x20')](function(_0x3f56e7){if(_0x3f56e7){_0x1548c4['interaction']=_0x3f56e7[_0xc209('0x77')]({'plain':!![]});interaction_log[_0xc209('0x21')]('[FAXMESSAGE:REJECT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s',_0x56a3a2['user']['id'],_0x56a3a2[_0xc209('0x63')][_0xc209('0x35')],_0x56a3a2[_0xc209('0x63')][_0xc209('0x64')],_0x1548c4[_0xc209('0x61')]['id'],_0x56a3a2[_0xc209('0x53')]?JSON[_0xc209('0x25')](_0x56a3a2['body']):'null');return respondWithRpcPromise(_0xc209('0x79'),_0xc209('0x7a'),_0x1548c4);}return null;})[_0xc209('0x20')](function(_0x420bb6){var _0x4c4418=_0xc209('0x67')+_0x420bb6[_0xc209('0x29')][_0xc209('0x68')];return db[_0xc209('0x69')][_0xc209('0x3c')](_0x4c4418,{'type':db['Sequelize'][_0xc209('0x7b')][_0xc209('0x6a')],'raw':!![]})[_0xc209('0x20')](function(_0x2e7b3b){return _0x2e7b3b;});})[_0xc209('0x20')](function(_0x43e944){if(_0x43e944){_0x1548c4[_0xc209('0x29')]['contact']=_0x43e944[0x0];if(!_0x56a3a2[_0xc209('0x53')][_0xc209('0x5e')])return;return db[_0xc209('0x6c')][_0xc209('0x54')]({'where':{'id':_0x56a3a2[_0xc209('0x53')]['UserId'],'role':_0xc209('0x5f')},'attributes':['id',_0xc209('0x35'),_0xc209('0x6d'),_0xc209('0x6e'),'internal'],'raw':!![]});}return null;})['then'](function(_0xee1d26){if(!_0xee1d26)return null;_0x1548c4[_0xc209('0x29')][_0xc209('0x5f')]=_0xee1d26;return _0x1548c4;})[_0xc209('0x20')](function(_0x30fb01){if(_0x30fb01){_0x30fb01[_0xc209('0x29')][_0xc209('0x71')]=util[_0xc209('0x5c')](_0xc209('0x72'),_0x56a3a2['user'][_0xc209('0x35')]);_0x30fb01[_0xc209('0x29')][_0xc209('0x73')]=_0x1548c4[_0xc209('0x73')];_0x30fb01[_0xc209('0x29')][_0xc209('0x74')]=_0x1548c4[_0xc209('0x73')];_0x30fb01[_0xc209('0x29')][_0xc209('0x75')]=_0xc209('0x7c');respondWithRpcPromise('EventManager',_0xc209('0x76'),{'event':_0xc209('0x7d'),'message':_0x30fb01['message']},client9002);return _0x1548c4;}return null;})[_0xc209('0x20')](respondWithResult(_0x5457c3,null))[_0xc209('0x2b')](handleError(_0x5457c3,null));};exports[_0xc209('0x7e')]=function(_0x14952b,_0x4fc1e8){var _0x2dea34;return db[_0xc209('0x4b')][_0xc209('0x7e')](_0x14952b[_0xc209('0x53')],{})['then'](function(_0x28a0c6){_0x2dea34=_0x28a0c6;return db[_0xc209('0x7f')][_0xc209('0x80')]({'where':{'id':_0x2dea34['ContactId']}});})[_0xc209('0x20')](function(_0x3c43b3){if(_[_0xc209('0x81')](_0x3c43b3)){return;}else{_0x2dea34[_0xc209('0x59')]=_0x3c43b3[_0xc209('0x59')];return db[_0xc209('0x82')]['findOne']({'where':{'id':_0x2dea34['AttachmentId']}});}})['then'](function(_0x32f88a){return respondWithRpcPromise(_0xc209('0x83'),_0xc209('0x83'),{'FaxAccountId':_[_0xc209('0x81')](_0x14952b[_0xc209('0x53')])?undefined:_0x14952b[_0xc209('0x53')][_0xc209('0x84')],'path':_[_0xc209('0x81')](_0x32f88a)?undefined:util[_0xc209('0x5c')](_0xc209('0x85'),_0x32f88a[_0xc209('0x86')]),'fax':_[_0xc209('0x81')](_0x2dea34[_0xc209('0x59')])?undefined:_0x2dea34['fax'],'AttachmentId':_0x2dea34[_0xc209('0x87')]},client9002);})[_0xc209('0x20')](respondWithResult(_0x4fc1e8,0xc9))[_0xc209('0x2b')](handleError(_0x4fc1e8,null));};exports['download']=function(_0x4b2e66,_0x501608){var _0x2b0077=path[_0xc209('0x88')](config[_0xc209('0x89')],_0xc209('0x8a'),_0xc209('0x8b'),_0xc209('0x8c'));return db[_0xc209('0x4b')][_0xc209('0x54')]({'where':{'id':_0x4b2e66['params']['id']},'include':[{'model':db[_0xc209('0x82')],'as':'Attachment'}]})['then'](handleEntityNotFound(_0x501608,null))[_0xc209('0x20')](function(_0x2d4ec3){if(_0x2d4ec3){return _0x501608[_0xc209('0x8d')](path['join'](_0x2b0077,_0x2d4ec3[_0xc209('0x82')][_0xc209('0x86')]));}})[_0xc209('0x2b')](handleError(_0x501608,null));};
\ No newline at end of file