Built motion from commit 953226e6.|2.6.32
[motion2.git] / server / api / faxMessage / faxMessage.controller.js
index 7771fea..fa4bb25 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xf0c9=['download','root','files','attachments','Attachment','join','util','path','ioredis','../../components/parsers/qs','../../config/logger','../../config/environment','redis','defaults','localhost','register','jayson/promise','client','http','fax-interactions','then','info','FaxMessage,\x20%s,\x20%s','debug','FaxMessage,\x20%s,\x20%s,\x20%s','request\x20sent','error','code','message','catch','json','undefined','count','offset','status','set','Content-Range','update','end','sendStatus','stack','name','send','FaxMessage','fieldName','type','key','model','query','filters','intersection','attributes','fields','hasOwnProperty','limit','order','sort','filter','where','merge','map','VIRTUAL','options','includeAll','include','findAll','show','params','keys','rawAttributes','length','find','body','destroy','describe','sms','acceptMessage','fax','reject','UserId','user','agent','get','FaxInteraction','[FAXMESSAGE:REJECT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','role','stringify','null','RejectMessage','rejectMessage','ContactId','sequelize','QueryTypes','SELECT','contact','User','fullname','email','internal','interface','format','SIP/%s','channel','motionChannel','EventManager','rejectmessage','create','CmContact','findOne','isNil','AttachmentId','SendFax','FaxAccountId','/var/opt/motion2/server/files/attachments/%s','basename'];(function(_0x596284,_0x1cd02b){var _0x5313c6=function(_0x77db49){while(--_0x77db49){_0x596284['push'](_0x596284['shift']());}};_0x5313c6(++_0x1cd02b);}(_0xf0c9,0x15f));var _0x9f0c=function(_0x317c38,_0x9d154d){_0x317c38=_0x317c38-0x0;var _0x304c05=_0xf0c9[_0x317c38];return _0x304c05;};'use strict';var util=require(_0x9f0c('0x0'));var path=require(_0x9f0c('0x1'));var _=require('lodash');var Redis=require(_0x9f0c('0x2'));var interactionService=require('../../components/interaction/service');var qs=require(_0x9f0c('0x3'));var logger=require(_0x9f0c('0x4'))('api');var config=require(_0x9f0c('0x5'));var db=require('../../mysqldb')['db'];config[_0x9f0c('0x6')]=_[_0x9f0c('0x7')](config[_0x9f0c('0x6')],{'host':_0x9f0c('0x8'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x9f0c('0x6')]));require('./faxMessage.socket')[_0x9f0c('0x9')](socket);var jayson=require(_0x9f0c('0xa'));var client=jayson[_0x9f0c('0xb')]['http']({'port':0x232c});var client9002=jayson['client'][_0x9f0c('0xc')]({'port':0x232a});var interaction_log=require(_0x9f0c('0x4'))(_0x9f0c('0xd'));function respondWithRpcPromise(_0x3fa6cb,_0x3e87f0,_0x353d84,_0x26a9a6){return new Promise(function(_0x1e8a02,_0x3694a9){var _0x1694b1=_0x26a9a6||client;return _0x1694b1['request'](_0x3fa6cb,_0x353d84)[_0x9f0c('0xe')](function(_0x471d91){logger[_0x9f0c('0xf')](_0x9f0c('0x10'),_0x3e87f0,'request\x20sent');logger[_0x9f0c('0x11')](_0x9f0c('0x12'),_0x3e87f0,_0x9f0c('0x13'),JSON['stringify'](_0x471d91));if(_0x471d91['error']){if(_0x471d91[_0x9f0c('0x14')][_0x9f0c('0x15')]===0x1f4){logger[_0x9f0c('0x14')](_0x9f0c('0x10'),_0x3e87f0,_0x471d91[_0x9f0c('0x14')][_0x9f0c('0x16')]);return _0x3694a9(_0x471d91[_0x9f0c('0x14')][_0x9f0c('0x16')]);}logger[_0x9f0c('0x14')](_0x9f0c('0x10'),_0x3e87f0,_0x471d91[_0x9f0c('0x14')][_0x9f0c('0x16')]);return _0x1e8a02(_0x471d91[_0x9f0c('0x14')][_0x9f0c('0x16')]);}else{logger[_0x9f0c('0xf')](_0x9f0c('0x10'),_0x3e87f0,_0x9f0c('0x13'));_0x1e8a02(_0x471d91['result'][_0x9f0c('0x16')]);}})[_0x9f0c('0x17')](function(_0x473795){logger['error'](_0x9f0c('0x10'),_0x3e87f0,_0x473795);_0x3694a9(_0x473795);});});}function respondWithResult(_0x8d0a5a,_0x589793){_0x589793=_0x589793||0xc8;return function(_0x4e2974){if(_0x4e2974){return _0x8d0a5a['status'](_0x589793)[_0x9f0c('0x18')](_0x4e2974);}};}function respondWithFilteredResult(_0x125265,_0x597b86){return function(_0x4f1eec){if(_0x4f1eec){var _0x218256=typeof _0x597b86['offset']===_0x9f0c('0x19')&&typeof _0x597b86['limit']===_0x9f0c('0x19');var _0x5a8a5d=_0x4f1eec[_0x9f0c('0x1a')];var _0x3509d4=_0x218256?0x0:_0x597b86[_0x9f0c('0x1b')];var _0x4b51df=_0x218256?_0x4f1eec[_0x9f0c('0x1a')]:_0x597b86['offset']+_0x597b86['limit'];var _0x27ac6e;if(_0x4b51df>=_0x5a8a5d){_0x4b51df=_0x5a8a5d;_0x27ac6e=0xc8;}else{_0x27ac6e=0xce;}_0x125265[_0x9f0c('0x1c')](_0x27ac6e);return _0x125265[_0x9f0c('0x1d')](_0x9f0c('0x1e'),_0x3509d4+'-'+_0x4b51df+'/'+_0x5a8a5d)[_0x9f0c('0x18')](_0x4f1eec);}return null;};}function saveUpdates(_0x3a44c2){return function(_0x2e80e4){if(_0x2e80e4){return _0x2e80e4[_0x9f0c('0x1f')](_0x3a44c2)[_0x9f0c('0xe')](function(_0x986138){return _0x986138;});}return null;};}function removeEntity(_0x5221ce){return function(_0x22772f){if(_0x22772f){return _0x22772f['destroy']()[_0x9f0c('0xe')](function(){_0x5221ce['status'](0xcc)[_0x9f0c('0x20')]();});}};}function handleEntityNotFound(_0x515065){return function(_0x327f13){if(!_0x327f13){_0x515065[_0x9f0c('0x21')](0x194);}return _0x327f13;};}function handleError(_0x3db569,_0x20b5e8){_0x20b5e8=_0x20b5e8||0x1f4;return function(_0x5635e2){logger[_0x9f0c('0x14')](_0x5635e2[_0x9f0c('0x22')]);if(_0x5635e2[_0x9f0c('0x23')]){delete _0x5635e2[_0x9f0c('0x23')];}_0x3db569[_0x9f0c('0x1c')](_0x20b5e8)[_0x9f0c('0x24')](_0x5635e2);};}exports['index']=function(_0x49ed54,_0x5cb4f9){var _0x4484a4={},_0x590ae9={},_0x5c77bb={'count':0x0,'rows':[]};var _0x33beb7=_['map'](db[_0x9f0c('0x25')]['rawAttributes'],function(_0x10d378){return{'name':_0x10d378[_0x9f0c('0x26')],'type':_0x10d378[_0x9f0c('0x27')][_0x9f0c('0x28')]};});_0x590ae9[_0x9f0c('0x29')]=_['map'](_0x33beb7,_0x9f0c('0x23'));_0x590ae9[_0x9f0c('0x2a')]=_['keys'](_0x49ed54[_0x9f0c('0x2a')]);_0x590ae9[_0x9f0c('0x2b')]=_[_0x9f0c('0x2c')](_0x590ae9[_0x9f0c('0x29')],_0x590ae9[_0x9f0c('0x2a')]);_0x4484a4[_0x9f0c('0x2d')]=_[_0x9f0c('0x2c')](_0x590ae9['model'],qs[_0x9f0c('0x2e')](_0x49ed54[_0x9f0c('0x2a')][_0x9f0c('0x2e')]));_0x4484a4[_0x9f0c('0x2d')]=_0x4484a4['attributes']['length']?_0x4484a4[_0x9f0c('0x2d')]:_0x590ae9[_0x9f0c('0x29')];if(!_0x49ed54['query'][_0x9f0c('0x2f')]('nolimit')){_0x4484a4[_0x9f0c('0x30')]=qs[_0x9f0c('0x30')](_0x49ed54['query'][_0x9f0c('0x30')]);_0x4484a4[_0x9f0c('0x1b')]=qs['offset'](_0x49ed54[_0x9f0c('0x2a')][_0x9f0c('0x1b')]);}_0x4484a4[_0x9f0c('0x31')]=qs[_0x9f0c('0x32')](_0x49ed54[_0x9f0c('0x2a')][_0x9f0c('0x32')]);_0x4484a4['where']=qs['filters'](_['pick'](_0x49ed54[_0x9f0c('0x2a')],_0x590ae9[_0x9f0c('0x2b')]),_0x33beb7);if(_0x49ed54[_0x9f0c('0x2a')][_0x9f0c('0x33')]){_0x4484a4[_0x9f0c('0x34')]=_[_0x9f0c('0x35')](_0x4484a4[_0x9f0c('0x34')],{'$or':_[_0x9f0c('0x36')](_0x33beb7,function(_0x32d8f8){if(_0x32d8f8[_0x9f0c('0x27')]!==_0x9f0c('0x37')){var _0x5d74c0={};_0x5d74c0[_0x32d8f8['name']]={'$like':'%'+_0x49ed54[_0x9f0c('0x2a')][_0x9f0c('0x33')]+'%'};return _0x5d74c0;}})});}_0x4484a4=_[_0x9f0c('0x35')]({},_0x4484a4,_0x49ed54[_0x9f0c('0x38')]);var _0x10ebe3={'where':_0x4484a4[_0x9f0c('0x34')]};return db[_0x9f0c('0x25')][_0x9f0c('0x1a')](_0x10ebe3)['then'](function(_0x459214){_0x5c77bb['count']=_0x459214;if(_0x49ed54[_0x9f0c('0x2a')][_0x9f0c('0x39')]){_0x4484a4[_0x9f0c('0x3a')]=[{'all':!![]}];}return db['FaxMessage'][_0x9f0c('0x3b')](_0x4484a4);})[_0x9f0c('0xe')](function(_0x12a939){_0x5c77bb['rows']=_0x12a939;return _0x5c77bb;})[_0x9f0c('0xe')](respondWithFilteredResult(_0x5cb4f9,_0x4484a4))['catch'](handleError(_0x5cb4f9,null));};exports[_0x9f0c('0x3c')]=function(_0x2f0f88,_0x242cf7){var _0xfe3c00={'raw':!![],'where':{'id':_0x2f0f88[_0x9f0c('0x3d')]['id']}},_0x38b8f7={};_0x38b8f7[_0x9f0c('0x29')]=_[_0x9f0c('0x3e')](db['FaxMessage'][_0x9f0c('0x3f')]);_0x38b8f7['query']=_[_0x9f0c('0x3e')](_0x2f0f88[_0x9f0c('0x2a')]);_0x38b8f7[_0x9f0c('0x2b')]=_[_0x9f0c('0x2c')](_0x38b8f7[_0x9f0c('0x29')],_0x38b8f7[_0x9f0c('0x2a')]);_0xfe3c00[_0x9f0c('0x2d')]=_[_0x9f0c('0x2c')](_0x38b8f7['model'],qs['fields'](_0x2f0f88[_0x9f0c('0x2a')]['fields']));_0xfe3c00[_0x9f0c('0x2d')]=_0xfe3c00[_0x9f0c('0x2d')][_0x9f0c('0x40')]?_0xfe3c00[_0x9f0c('0x2d')]:_0x38b8f7[_0x9f0c('0x29')];if(_0x2f0f88[_0x9f0c('0x2a')][_0x9f0c('0x39')]){_0xfe3c00[_0x9f0c('0x3a')]=[{'all':!![]}];}_0xfe3c00=_[_0x9f0c('0x35')]({},_0xfe3c00,_0x2f0f88[_0x9f0c('0x38')]);return db[_0x9f0c('0x25')][_0x9f0c('0x41')](_0xfe3c00)[_0x9f0c('0xe')](handleEntityNotFound(_0x242cf7,null))['then'](respondWithResult(_0x242cf7,null))[_0x9f0c('0x17')](handleError(_0x242cf7,null));};exports['update']=function(_0x26a95a,_0x20cf3d){if(_0x26a95a[_0x9f0c('0x42')]['id']){delete _0x26a95a['body']['id'];}return db[_0x9f0c('0x25')][_0x9f0c('0x41')]({'where':{'id':_0x26a95a['params']['id']}})[_0x9f0c('0xe')](handleEntityNotFound(_0x20cf3d,null))['then'](saveUpdates(_0x26a95a[_0x9f0c('0x42')],null))[_0x9f0c('0xe')](respondWithResult(_0x20cf3d,null))[_0x9f0c('0x17')](handleError(_0x20cf3d,null));};exports[_0x9f0c('0x43')]=function(_0x5efc5c,_0x21e4ce){return db[_0x9f0c('0x25')][_0x9f0c('0x41')]({'where':{'id':_0x5efc5c[_0x9f0c('0x3d')]['id']}})[_0x9f0c('0xe')](handleEntityNotFound(_0x21e4ce,null))[_0x9f0c('0xe')](removeEntity(_0x21e4ce,null))[_0x9f0c('0x17')](handleError(_0x21e4ce,null));};exports[_0x9f0c('0x44')]=function(_0x3a4a3a,_0x41cf25){return db[_0x9f0c('0x25')]['describe']()[_0x9f0c('0xe')](respondWithResult(_0x41cf25,null))[_0x9f0c('0x17')](handleError(_0x41cf25,null));};exports['accept']=function(_0x43161c,_0x2f575b){var _0x3cd93a=_0x9f0c('0x45');return interactionService[_0x9f0c('0x46')](_0x43161c,_0x3cd93a)[_0x9f0c('0xe')](respondWithResult(_0x2f575b,null))[_0x9f0c('0x17')](handleError(_0x2f575b,null));};exports['accept']=function(_0x4389ed,_0x2a8659){var _0x4efd2d=_0x9f0c('0x47');return interactionService['acceptMessage'](_0x4389ed,_0x4efd2d)[_0x9f0c('0xe')](respondWithResult(_0x2a8659,null))[_0x9f0c('0x17')](handleError(_0x2a8659,null));};exports[_0x9f0c('0x48')]=function(_0xdff421,_0x21df33){var _0x348bb8={'agent':{},'channel':_0x9f0c('0x47')};if(_0xdff421[_0x9f0c('0x42')]['id']){delete _0xdff421['body']['id'];}_0xdff421[_0x9f0c('0x42')][_0x9f0c('0x49')]=_0xdff421[_0x9f0c('0x42')]['UserId']||_0xdff421[_0x9f0c('0x4a')]['id'];_0x348bb8[_0x9f0c('0x4b')]['id']=_0xdff421[_0x9f0c('0x42')][_0x9f0c('0x49')];return db[_0x9f0c('0x25')][_0x9f0c('0x41')]({'where':{'id':_0xdff421[_0x9f0c('0x3d')]['id'],'UserId':null}})['then'](handleEntityNotFound(_0x21df33,null))['then'](function(_0x17a738){if(_0x17a738){_0x348bb8[_0x9f0c('0x16')]=_0x17a738[_0x9f0c('0x4c')]({'plain':!![]});return db[_0x9f0c('0x4d')][_0x9f0c('0x41')]({'where':{'id':_0x17a738['FaxInteractionId']}});}return null;})[_0x9f0c('0xe')](handleEntityNotFound(_0x21df33,null))[_0x9f0c('0xe')](function(_0x435c03){if(_0x435c03){_0x348bb8['interaction']=_0x435c03[_0x9f0c('0x4c')]({'plain':!![]});interaction_log[_0x9f0c('0xf')](_0x9f0c('0x4e'),_0xdff421[_0x9f0c('0x4a')]['id'],_0xdff421[_0x9f0c('0x4a')][_0x9f0c('0x23')],_0xdff421['user'][_0x9f0c('0x4f')],_0x348bb8['interaction']['id'],_0xdff421[_0x9f0c('0x42')]?JSON[_0x9f0c('0x50')](_0xdff421['body']):_0x9f0c('0x51'));return respondWithRpcPromise(_0x9f0c('0x52'),_0x9f0c('0x53'),_0x348bb8);}return null;})[_0x9f0c('0xe')](function(_0x2d8e52){var _0x4a4637='SELECT\x20*\x20FROM\x20cm_contacts\x20WHERE\x20id\x20=\x20'+_0x2d8e52[_0x9f0c('0x16')][_0x9f0c('0x54')];return db[_0x9f0c('0x55')]['query'](_0x4a4637,{'type':db['Sequelize'][_0x9f0c('0x56')][_0x9f0c('0x57')],'raw':!![]})[_0x9f0c('0xe')](function(_0x4394eb){return _0x4394eb;});})[_0x9f0c('0xe')](function(_0x192e0e){if(_0x192e0e){_0x348bb8['message'][_0x9f0c('0x58')]=_0x192e0e[0x0];if(!_0xdff421[_0x9f0c('0x42')][_0x9f0c('0x49')])return;return db[_0x9f0c('0x59')][_0x9f0c('0x41')]({'where':{'id':_0xdff421[_0x9f0c('0x42')][_0x9f0c('0x49')],'role':_0x9f0c('0x4b')},'attributes':['id',_0x9f0c('0x23'),_0x9f0c('0x5a'),_0x9f0c('0x5b'),_0x9f0c('0x5c')],'raw':!![]});}return null;})[_0x9f0c('0xe')](function(_0x142db4){if(!_0x142db4)return null;_0x348bb8['message']['agent']=_0x142db4;return _0x348bb8;})[_0x9f0c('0xe')](function(_0x45ac82){if(_0x45ac82){_0x45ac82[_0x9f0c('0x16')][_0x9f0c('0x5d')]=util[_0x9f0c('0x5e')](_0x9f0c('0x5f'),_0xdff421[_0x9f0c('0x4a')][_0x9f0c('0x23')]);_0x45ac82['message'][_0x9f0c('0x60')]=_0x348bb8['channel'];_0x45ac82[_0x9f0c('0x16')][_0x9f0c('0x61')]=_0x348bb8['channel'];_0x45ac82['message']['event']=_0x9f0c('0x48');respondWithRpcPromise(_0x9f0c('0x62'),'EventManager',{'event':_0x9f0c('0x63'),'message':_0x45ac82[_0x9f0c('0x16')]},client9002);return _0x348bb8;}return null;})['then'](respondWithResult(_0x21df33,null))['catch'](handleError(_0x21df33,null));};exports[_0x9f0c('0x64')]=function(_0xc06307,_0x5cf07e){var _0x222525;return db[_0x9f0c('0x25')]['create'](_0xc06307[_0x9f0c('0x42')],{})[_0x9f0c('0xe')](function(_0x45d208){_0x222525=_0x45d208;return db[_0x9f0c('0x65')][_0x9f0c('0x66')]({'where':{'id':_0x222525['ContactId']}});})['then'](function(_0xbc0f5b){if(_[_0x9f0c('0x67')](_0xbc0f5b)){return;}else{_0x222525[_0x9f0c('0x47')]=_0xbc0f5b[_0x9f0c('0x47')];return db['Attachment'][_0x9f0c('0x66')]({'where':{'id':_0x222525[_0x9f0c('0x68')]}});}})[_0x9f0c('0xe')](function(_0x477889){return respondWithRpcPromise('SendFax',_0x9f0c('0x69'),{'FaxAccountId':_[_0x9f0c('0x67')](_0xc06307[_0x9f0c('0x42')])?undefined:_0xc06307[_0x9f0c('0x42')][_0x9f0c('0x6a')],'path':_[_0x9f0c('0x67')](_0x477889)?undefined:util[_0x9f0c('0x5e')](_0x9f0c('0x6b'),_0x477889[_0x9f0c('0x6c')]),'fax':_[_0x9f0c('0x67')](_0x222525[_0x9f0c('0x47')])?undefined:_0x222525[_0x9f0c('0x47')],'AttachmentId':_0x222525[_0x9f0c('0x68')]},client9002);})[_0x9f0c('0xe')](respondWithResult(_0x5cf07e,0xc9))[_0x9f0c('0x17')](handleError(_0x5cf07e,null));};exports[_0x9f0c('0x6d')]=function(_0x16ef9d,_0x11bad7){var _0x4eb1f5=path['join'](config[_0x9f0c('0x6e')],'server',_0x9f0c('0x6f'),_0x9f0c('0x70'));return db['FaxMessage'][_0x9f0c('0x41')]({'where':{'id':_0x16ef9d[_0x9f0c('0x3d')]['id']},'include':[{'model':db[_0x9f0c('0x71')],'as':_0x9f0c('0x71')}]})[_0x9f0c('0xe')](handleEntityNotFound(_0x11bad7,null))['then'](function(_0x5e6f27){if(_0x5e6f27){return _0x11bad7['download'](path[_0x9f0c('0x72')](_0x4eb1f5,_0x5e6f27[_0x9f0c('0x71')][_0x9f0c('0x6c')]));}})[_0x9f0c('0x17')](handleError(_0x11bad7,null));};
\ No newline at end of file
+var _0xfa76=['role','null','SELECT\x20*\x20FROM\x20cm_contacts\x20WHERE\x20id\x20=\x20','sequelize','QueryTypes','SELECT','User','fullname','email','interface','format','SIP/%s','channel','motionChannel','event','EventManager','rejectmessage','create','CmContact','findOne','ContactId','Attachment','AttachmentId','SendFax','isNil','/var/opt/motion2/server/files/attachments/%s','basename','download','join','server','files','attachments','path','lodash','ioredis','../../components/interaction/service','../../components/parsers/qs','api','../../config/environment','../../mysqldb','redis','localhost','./faxMessage.socket','jayson/promise','client','then','info','FaxMessage,\x20%s,\x20%s','request\x20sent','FaxMessage,\x20%s,\x20%s,\x20%s','stringify','error','message','result','catch','status','offset','limit','undefined','count','set','json','destroy','end','stack','name','send','index','map','FaxMessage','type','key','model','query','keys','filters','intersection','fields','attributes','length','hasOwnProperty','order','sort','where','pick','filter','merge','VIRTUAL','options','findAll','rows','show','params','rawAttributes','find','update','body','describe','sms','acceptMessage','accept','fax','reject','UserId','agent','get','FaxInteraction','FaxInteractionId','interaction','[FAXMESSAGE:REJECT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','user'];(function(_0x17d9e3,_0x1f969c){var _0x14192d=function(_0x159745){while(--_0x159745){_0x17d9e3['push'](_0x17d9e3['shift']());}};_0x14192d(++_0x1f969c);}(_0xfa76,0x1dc));var _0x6fa7=function(_0x7d2300,_0x4612f6){_0x7d2300=_0x7d2300-0x0;var _0x2f23b0=_0xfa76[_0x7d2300];return _0x2f23b0;};'use strict';var util=require('util');var path=require(_0x6fa7('0x0'));var _=require(_0x6fa7('0x1'));var Redis=require(_0x6fa7('0x2'));var interactionService=require(_0x6fa7('0x3'));var qs=require(_0x6fa7('0x4'));var logger=require('../../config/logger')(_0x6fa7('0x5'));var config=require(_0x6fa7('0x6'));var db=require(_0x6fa7('0x7'))['db'];config[_0x6fa7('0x8')]=_['defaults'](config[_0x6fa7('0x8')],{'host':_0x6fa7('0x9'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require(_0x6fa7('0xa'))['register'](socket);var jayson=require(_0x6fa7('0xb'));var client=jayson[_0x6fa7('0xc')]['http']({'port':0x232c});var client9002=jayson['client']['http']({'port':0x232a});var interaction_log=require('../../config/logger')('fax-interactions');function respondWithRpcPromise(_0x304eab,_0x2d0425,_0x1af04c,_0x5a8380){return new Promise(function(_0x553dcb,_0x4b5199){var _0x51040e=_0x5a8380||client;return _0x51040e['request'](_0x304eab,_0x1af04c)[_0x6fa7('0xd')](function(_0x2792ae){logger[_0x6fa7('0xe')](_0x6fa7('0xf'),_0x2d0425,_0x6fa7('0x10'));logger['debug'](_0x6fa7('0x11'),_0x2d0425,_0x6fa7('0x10'),JSON[_0x6fa7('0x12')](_0x2792ae));if(_0x2792ae[_0x6fa7('0x13')]){if(_0x2792ae[_0x6fa7('0x13')]['code']===0x1f4){logger[_0x6fa7('0x13')](_0x6fa7('0xf'),_0x2d0425,_0x2792ae['error'][_0x6fa7('0x14')]);return _0x4b5199(_0x2792ae['error'][_0x6fa7('0x14')]);}logger[_0x6fa7('0x13')]('FaxMessage,\x20%s,\x20%s',_0x2d0425,_0x2792ae[_0x6fa7('0x13')]['message']);return _0x553dcb(_0x2792ae[_0x6fa7('0x13')]['message']);}else{logger['info'](_0x6fa7('0xf'),_0x2d0425,_0x6fa7('0x10'));_0x553dcb(_0x2792ae[_0x6fa7('0x15')][_0x6fa7('0x14')]);}})[_0x6fa7('0x16')](function(_0x1c6a68){logger[_0x6fa7('0x13')](_0x6fa7('0xf'),_0x2d0425,_0x1c6a68);_0x4b5199(_0x1c6a68);});});}function respondWithResult(_0x22dc46,_0x5dab65){_0x5dab65=_0x5dab65||0xc8;return function(_0x1acdd4){if(_0x1acdd4){return _0x22dc46[_0x6fa7('0x17')](_0x5dab65)['json'](_0x1acdd4);}};}function respondWithFilteredResult(_0x4027f0,_0x3c2b81){return function(_0x4fc9a7){if(_0x4fc9a7){var _0x3a9805=typeof _0x3c2b81[_0x6fa7('0x18')]==='undefined'&&typeof _0x3c2b81[_0x6fa7('0x19')]===_0x6fa7('0x1a');var _0x20924b=_0x4fc9a7[_0x6fa7('0x1b')];var _0x29bfda=_0x3a9805?0x0:_0x3c2b81[_0x6fa7('0x18')];var _0x3afd49=_0x3a9805?_0x4fc9a7[_0x6fa7('0x1b')]:_0x3c2b81[_0x6fa7('0x18')]+_0x3c2b81['limit'];var _0x38e1cd;if(_0x3afd49>=_0x20924b){_0x3afd49=_0x20924b;_0x38e1cd=0xc8;}else{_0x38e1cd=0xce;}_0x4027f0['status'](_0x38e1cd);return _0x4027f0[_0x6fa7('0x1c')]('Content-Range',_0x29bfda+'-'+_0x3afd49+'/'+_0x20924b)[_0x6fa7('0x1d')](_0x4fc9a7);}return null;};}function saveUpdates(_0x2db283){return function(_0x14d607){if(_0x14d607){return _0x14d607['update'](_0x2db283)[_0x6fa7('0xd')](function(_0x2514d5){return _0x2514d5;});}return null;};}function removeEntity(_0x154397){return function(_0x2429a2){if(_0x2429a2){return _0x2429a2[_0x6fa7('0x1e')]()['then'](function(){_0x154397['status'](0xcc)[_0x6fa7('0x1f')]();});}};}function handleEntityNotFound(_0x3e2082){return function(_0x4be0e7){if(!_0x4be0e7){_0x3e2082['sendStatus'](0x194);}return _0x4be0e7;};}function handleError(_0x697d9a,_0x412f7b){_0x412f7b=_0x412f7b||0x1f4;return function(_0x461d06){logger['error'](_0x461d06[_0x6fa7('0x20')]);if(_0x461d06[_0x6fa7('0x21')]){delete _0x461d06[_0x6fa7('0x21')];}_0x697d9a[_0x6fa7('0x17')](_0x412f7b)[_0x6fa7('0x22')](_0x461d06);};}exports[_0x6fa7('0x23')]=function(_0x49638d,_0x1a3781){var _0x1afcbb={},_0x153a33={},_0x115902={'count':0x0,'rows':[]};var _0x385fc8=_[_0x6fa7('0x24')](db[_0x6fa7('0x25')]['rawAttributes'],function(_0x25f659){return{'name':_0x25f659['fieldName'],'type':_0x25f659[_0x6fa7('0x26')][_0x6fa7('0x27')]};});_0x153a33[_0x6fa7('0x28')]=_[_0x6fa7('0x24')](_0x385fc8,_0x6fa7('0x21'));_0x153a33[_0x6fa7('0x29')]=_[_0x6fa7('0x2a')](_0x49638d[_0x6fa7('0x29')]);_0x153a33[_0x6fa7('0x2b')]=_[_0x6fa7('0x2c')](_0x153a33[_0x6fa7('0x28')],_0x153a33[_0x6fa7('0x29')]);_0x1afcbb['attributes']=_['intersection'](_0x153a33[_0x6fa7('0x28')],qs[_0x6fa7('0x2d')](_0x49638d[_0x6fa7('0x29')]['fields']));_0x1afcbb[_0x6fa7('0x2e')]=_0x1afcbb[_0x6fa7('0x2e')][_0x6fa7('0x2f')]?_0x1afcbb[_0x6fa7('0x2e')]:_0x153a33[_0x6fa7('0x28')];if(!_0x49638d[_0x6fa7('0x29')][_0x6fa7('0x30')]('nolimit')){_0x1afcbb[_0x6fa7('0x19')]=qs['limit'](_0x49638d[_0x6fa7('0x29')]['limit']);_0x1afcbb['offset']=qs[_0x6fa7('0x18')](_0x49638d['query'][_0x6fa7('0x18')]);}_0x1afcbb[_0x6fa7('0x31')]=qs[_0x6fa7('0x32')](_0x49638d[_0x6fa7('0x29')][_0x6fa7('0x32')]);_0x1afcbb[_0x6fa7('0x33')]=qs[_0x6fa7('0x2b')](_[_0x6fa7('0x34')](_0x49638d[_0x6fa7('0x29')],_0x153a33[_0x6fa7('0x2b')]),_0x385fc8);if(_0x49638d[_0x6fa7('0x29')][_0x6fa7('0x35')]){_0x1afcbb['where']=_[_0x6fa7('0x36')](_0x1afcbb['where'],{'$or':_[_0x6fa7('0x24')](_0x385fc8,function(_0x40c74b){if(_0x40c74b['type']!==_0x6fa7('0x37')){var _0x224ba4={};_0x224ba4[_0x40c74b[_0x6fa7('0x21')]]={'$like':'%'+_0x49638d[_0x6fa7('0x29')][_0x6fa7('0x35')]+'%'};return _0x224ba4;}})});}_0x1afcbb=_[_0x6fa7('0x36')]({},_0x1afcbb,_0x49638d[_0x6fa7('0x38')]);var _0x75ff2c={'where':_0x1afcbb[_0x6fa7('0x33')]};return db[_0x6fa7('0x25')]['count'](_0x75ff2c)[_0x6fa7('0xd')](function(_0xe05467){_0x115902[_0x6fa7('0x1b')]=_0xe05467;if(_0x49638d[_0x6fa7('0x29')]['includeAll']){_0x1afcbb['include']=[{'all':!![]}];}return db['FaxMessage'][_0x6fa7('0x39')](_0x1afcbb);})[_0x6fa7('0xd')](function(_0x107707){_0x115902[_0x6fa7('0x3a')]=_0x107707;return _0x115902;})[_0x6fa7('0xd')](respondWithFilteredResult(_0x1a3781,_0x1afcbb))['catch'](handleError(_0x1a3781,null));};exports[_0x6fa7('0x3b')]=function(_0x466fdb,_0x43326e){var _0x416b80={'raw':!![],'where':{'id':_0x466fdb[_0x6fa7('0x3c')]['id']}},_0x262c5e={};_0x262c5e[_0x6fa7('0x28')]=_[_0x6fa7('0x2a')](db[_0x6fa7('0x25')][_0x6fa7('0x3d')]);_0x262c5e[_0x6fa7('0x29')]=_[_0x6fa7('0x2a')](_0x466fdb[_0x6fa7('0x29')]);_0x262c5e['filters']=_[_0x6fa7('0x2c')](_0x262c5e[_0x6fa7('0x28')],_0x262c5e['query']);_0x416b80[_0x6fa7('0x2e')]=_[_0x6fa7('0x2c')](_0x262c5e[_0x6fa7('0x28')],qs['fields'](_0x466fdb['query'][_0x6fa7('0x2d')]));_0x416b80[_0x6fa7('0x2e')]=_0x416b80[_0x6fa7('0x2e')][_0x6fa7('0x2f')]?_0x416b80[_0x6fa7('0x2e')]:_0x262c5e[_0x6fa7('0x28')];if(_0x466fdb[_0x6fa7('0x29')]['includeAll']){_0x416b80['include']=[{'all':!![]}];}_0x416b80=_[_0x6fa7('0x36')]({},_0x416b80,_0x466fdb[_0x6fa7('0x38')]);return db[_0x6fa7('0x25')][_0x6fa7('0x3e')](_0x416b80)[_0x6fa7('0xd')](handleEntityNotFound(_0x43326e,null))[_0x6fa7('0xd')](respondWithResult(_0x43326e,null))[_0x6fa7('0x16')](handleError(_0x43326e,null));};exports[_0x6fa7('0x3f')]=function(_0x5f4e82,_0x5b5c17){if(_0x5f4e82[_0x6fa7('0x40')]['id']){delete _0x5f4e82[_0x6fa7('0x40')]['id'];}return db['FaxMessage'][_0x6fa7('0x3e')]({'where':{'id':_0x5f4e82[_0x6fa7('0x3c')]['id']}})[_0x6fa7('0xd')](handleEntityNotFound(_0x5b5c17,null))[_0x6fa7('0xd')](saveUpdates(_0x5f4e82[_0x6fa7('0x40')],null))['then'](respondWithResult(_0x5b5c17,null))[_0x6fa7('0x16')](handleError(_0x5b5c17,null));};exports[_0x6fa7('0x1e')]=function(_0x4bf32e,_0x250cee){return db[_0x6fa7('0x25')][_0x6fa7('0x3e')]({'where':{'id':_0x4bf32e[_0x6fa7('0x3c')]['id']}})['then'](handleEntityNotFound(_0x250cee,null))[_0x6fa7('0xd')](removeEntity(_0x250cee,null))[_0x6fa7('0x16')](handleError(_0x250cee,null));};exports[_0x6fa7('0x41')]=function(_0x41a54c,_0x4a258e){return db['FaxMessage'][_0x6fa7('0x41')]()[_0x6fa7('0xd')](respondWithResult(_0x4a258e,null))['catch'](handleError(_0x4a258e,null));};exports['accept']=function(_0x46b3a3,_0x599ad2){var _0x5bf3ff=_0x6fa7('0x42');return interactionService[_0x6fa7('0x43')](_0x46b3a3,_0x5bf3ff)[_0x6fa7('0xd')](respondWithResult(_0x599ad2,null))[_0x6fa7('0x16')](handleError(_0x599ad2,null));};exports[_0x6fa7('0x44')]=function(_0x1c166e,_0x5e1098){var _0x15e7ea=_0x6fa7('0x45');return interactionService['acceptMessage'](_0x1c166e,_0x15e7ea)[_0x6fa7('0xd')](respondWithResult(_0x5e1098,null))[_0x6fa7('0x16')](handleError(_0x5e1098,null));};exports[_0x6fa7('0x46')]=function(_0x5ceb1e,_0x384195){var _0x44992d={'agent':{},'channel':_0x6fa7('0x45')};if(_0x5ceb1e[_0x6fa7('0x40')]['id']){delete _0x5ceb1e[_0x6fa7('0x40')]['id'];}_0x5ceb1e[_0x6fa7('0x40')][_0x6fa7('0x47')]=_0x5ceb1e[_0x6fa7('0x40')][_0x6fa7('0x47')]||_0x5ceb1e['user']['id'];_0x44992d[_0x6fa7('0x48')]['id']=_0x5ceb1e[_0x6fa7('0x40')][_0x6fa7('0x47')];return db['FaxMessage'][_0x6fa7('0x3e')]({'where':{'id':_0x5ceb1e[_0x6fa7('0x3c')]['id'],'UserId':null}})[_0x6fa7('0xd')](handleEntityNotFound(_0x384195,null))['then'](function(_0x37c8b9){if(_0x37c8b9){_0x44992d[_0x6fa7('0x14')]=_0x37c8b9[_0x6fa7('0x49')]({'plain':!![]});return db[_0x6fa7('0x4a')]['find']({'where':{'id':_0x37c8b9[_0x6fa7('0x4b')]}});}return null;})[_0x6fa7('0xd')](handleEntityNotFound(_0x384195,null))[_0x6fa7('0xd')](function(_0xc89fe7){if(_0xc89fe7){_0x44992d[_0x6fa7('0x4c')]=_0xc89fe7[_0x6fa7('0x49')]({'plain':!![]});interaction_log[_0x6fa7('0xe')](_0x6fa7('0x4d'),_0x5ceb1e[_0x6fa7('0x4e')]['id'],_0x5ceb1e[_0x6fa7('0x4e')][_0x6fa7('0x21')],_0x5ceb1e['user'][_0x6fa7('0x4f')],_0x44992d['interaction']['id'],_0x5ceb1e[_0x6fa7('0x40')]?JSON[_0x6fa7('0x12')](_0x5ceb1e['body']):_0x6fa7('0x50'));return respondWithRpcPromise('RejectMessage','rejectMessage',_0x44992d);}return null;})['then'](function(_0x4498a9){var _0x531cfb=_0x6fa7('0x51')+_0x4498a9['message']['ContactId'];return db[_0x6fa7('0x52')]['query'](_0x531cfb,{'type':db['Sequelize'][_0x6fa7('0x53')][_0x6fa7('0x54')],'raw':!![]})['then'](function(_0x68eb77){return _0x68eb77;});})[_0x6fa7('0xd')](function(_0x325a9b){if(_0x325a9b){_0x44992d[_0x6fa7('0x14')]['contact']=_0x325a9b[0x0];if(!_0x5ceb1e[_0x6fa7('0x40')]['UserId'])return;return db[_0x6fa7('0x55')][_0x6fa7('0x3e')]({'where':{'id':_0x5ceb1e['body'][_0x6fa7('0x47')],'role':_0x6fa7('0x48')},'attributes':['id',_0x6fa7('0x21'),_0x6fa7('0x56'),_0x6fa7('0x57'),'internal'],'raw':!![]});}return null;})[_0x6fa7('0xd')](function(_0x363011){if(!_0x363011)return null;_0x44992d[_0x6fa7('0x14')][_0x6fa7('0x48')]=_0x363011;return _0x44992d;})['then'](function(_0x330f66){if(_0x330f66){_0x330f66[_0x6fa7('0x14')][_0x6fa7('0x58')]=util[_0x6fa7('0x59')](_0x6fa7('0x5a'),_0x5ceb1e[_0x6fa7('0x4e')][_0x6fa7('0x21')]);_0x330f66[_0x6fa7('0x14')][_0x6fa7('0x5b')]=_0x44992d[_0x6fa7('0x5b')];_0x330f66[_0x6fa7('0x14')][_0x6fa7('0x5c')]=_0x44992d['channel'];_0x330f66[_0x6fa7('0x14')][_0x6fa7('0x5d')]=_0x6fa7('0x46');respondWithRpcPromise(_0x6fa7('0x5e'),_0x6fa7('0x5e'),{'event':_0x6fa7('0x5f'),'message':_0x330f66[_0x6fa7('0x14')]},client9002);return _0x44992d;}return null;})[_0x6fa7('0xd')](respondWithResult(_0x384195,null))[_0x6fa7('0x16')](handleError(_0x384195,null));};exports[_0x6fa7('0x60')]=function(_0x5234a6,_0x469441){var _0x2021f0;return db['FaxMessage'][_0x6fa7('0x60')](_0x5234a6[_0x6fa7('0x40')],{})[_0x6fa7('0xd')](function(_0xaf422b){_0x2021f0=_0xaf422b;return db[_0x6fa7('0x61')][_0x6fa7('0x62')]({'where':{'id':_0x2021f0[_0x6fa7('0x63')]}});})[_0x6fa7('0xd')](function(_0x1dba55){if(_['isNil'](_0x1dba55)){return;}else{_0x2021f0[_0x6fa7('0x45')]=_0x1dba55['fax'];return db[_0x6fa7('0x64')][_0x6fa7('0x62')]({'where':{'id':_0x2021f0[_0x6fa7('0x65')]}});}})[_0x6fa7('0xd')](function(_0x143380){return respondWithRpcPromise(_0x6fa7('0x66'),_0x6fa7('0x66'),{'FaxAccountId':_['isNil'](_0x5234a6[_0x6fa7('0x40')])?undefined:_0x5234a6[_0x6fa7('0x40')]['FaxAccountId'],'path':_[_0x6fa7('0x67')](_0x143380)?undefined:util[_0x6fa7('0x59')](_0x6fa7('0x68'),_0x143380[_0x6fa7('0x69')]),'fax':_[_0x6fa7('0x67')](_0x2021f0['fax'])?undefined:_0x2021f0['fax'],'AttachmentId':_0x2021f0['AttachmentId']},client9002);})[_0x6fa7('0xd')](respondWithResult(_0x469441,0xc9))['catch'](handleError(_0x469441,null));};exports[_0x6fa7('0x6a')]=function(_0x2ab967,_0x3f5e4b){var _0x419d70=path[_0x6fa7('0x6b')](config['root'],_0x6fa7('0x6c'),_0x6fa7('0x6d'),_0x6fa7('0x6e'));return db[_0x6fa7('0x25')][_0x6fa7('0x3e')]({'where':{'id':_0x2ab967[_0x6fa7('0x3c')]['id']},'include':[{'model':db[_0x6fa7('0x64')],'as':_0x6fa7('0x64')}]})[_0x6fa7('0xd')](handleEntityNotFound(_0x3f5e4b,null))[_0x6fa7('0xd')](function(_0x20d7a2){if(_0x20d7a2){return _0x3f5e4b['download'](path[_0x6fa7('0x6b')](_0x419d70,_0x20d7a2[_0x6fa7('0x64')][_0x6fa7('0x69')]));}})[_0x6fa7('0x16')](handleError(_0x3f5e4b,null));};
\ No newline at end of file