Built motion from commit (unavailable).|2.5.31
[motion2.git] / server / api / faxAccount / faxAccount.rpc.js
index e26c64c..9cc70bc 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x71f7=['where','attributes','limit','include','model','map','then','NotifyFaxAccount','body','fax','CmContact','describe','Sequelize','ValidationError','no\x20available\x20attributes','difference','keys','createdAt','updatedAt','CompanyId','ListId','body\x20is\x20mandatory\x20and\x20not\x20empty','mapKey','mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','includes','find','account','CmList','Contacts','DESC','FaxApplication','List','get','applications','list','orderBy','priority','asc','Applications','length','create','FaxInteraction','Contact\x20not\x20found','push','close','unmanaged','*,*,*,*','created','interaction','FaxMessage','ContactId','AttachmentId','UserId','User','agent','name','waitForTheAssignedAgent','Start','startRouting','lodash','util','bluebird','randomstring','ioredis','rpc','jayson/promise','client','http','redis','defaults','localhost','socket.io-emitter','./faxAccount.socket','register','request','info','request\x20sent','debug','FaxAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','FaxAccount,\x20%s,\x20%s','message','result','catch','GetFaxAccount','FaxAccount','findAll','options','raw'];(function(_0x1694f5,_0x49b7c3){var _0x5b4321=function(_0x58c183){while(--_0x58c183){_0x1694f5['push'](_0x1694f5['shift']());}};_0x5b4321(++_0x49b7c3);}(_0x71f7,0x1a7));var _0x771f=function(_0x8cd896,_0x1b28ba){_0x8cd896=_0x8cd896-0x0;var _0xc4af92=_0x71f7[_0x8cd896];return _0xc4af92;};'use strict';var _=require(_0x771f('0x0'));var util=require(_0x771f('0x1'));var moment=require('moment');var BPromise=require(_0x771f('0x2'));var rs=require(_0x771f('0x3'));var fs=require('fs');var Redis=require(_0x771f('0x4'));var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0x771f('0x5'));var config=require('../../config/environment');var jayson=require(_0x771f('0x6'));var client=jayson[_0x771f('0x7')][_0x771f('0x8')]({'port':0x232c});config[_0x771f('0x9')]=_[_0x771f('0xa')](config[_0x771f('0x9')],{'host':_0x771f('0xb'),'port':0x18eb});var socket=require(_0x771f('0xc'))(new Redis(config[_0x771f('0x9')]));require(_0x771f('0xd'))[_0x771f('0xe')](socket);function respondWithRpcPromise(_0xa1508d,_0x1847f8,_0x72a1a0){return new BPromise(function(_0x29a041,_0x3a49ae){return client[_0x771f('0xf')](_0xa1508d,_0x72a1a0)['then'](function(_0x59af22){logger[_0x771f('0x10')]('FaxAccount,\x20%s,\x20%s',_0x1847f8,_0x771f('0x11'));logger[_0x771f('0x12')](_0x771f('0x13'),_0x1847f8,'request\x20sent',JSON[_0x771f('0x14')](_0x59af22));if(_0x59af22[_0x771f('0x15')]){if(_0x59af22[_0x771f('0x15')][_0x771f('0x16')]===0x1f4){logger[_0x771f('0x15')](_0x771f('0x17'),_0x1847f8,_0x59af22[_0x771f('0x15')][_0x771f('0x18')]);return _0x3a49ae(_0x59af22[_0x771f('0x15')][_0x771f('0x18')]);}logger['error'](_0x771f('0x17'),_0x1847f8,_0x59af22[_0x771f('0x15')][_0x771f('0x18')]);return _0x29a041(_0x59af22[_0x771f('0x15')][_0x771f('0x18')]);}else{logger[_0x771f('0x10')]('FaxAccount,\x20%s,\x20%s',_0x1847f8,_0x771f('0x11'));_0x29a041(_0x59af22[_0x771f('0x19')][_0x771f('0x18')]);}})[_0x771f('0x1a')](function(_0xdfc895){logger[_0x771f('0x15')](_0x771f('0x17'),_0x1847f8,_0xdfc895);_0x3a49ae(_0xdfc895);});});}exports[_0x771f('0x1b')]=function(_0x16f227){var _0xbff02a=this;return new Promise(function(_0x490816,_0x36c565){return db[_0x771f('0x1c')][_0x771f('0x1d')]({'raw':_0x16f227[_0x771f('0x1e')]?_0x16f227[_0x771f('0x1e')][_0x771f('0x1f')]===undefined?!![]:![]:!![],'where':_0x16f227[_0x771f('0x1e')]?_0x16f227[_0x771f('0x1e')][_0x771f('0x20')]||null:null,'attributes':_0x16f227[_0x771f('0x1e')]?_0x16f227[_0x771f('0x1e')][_0x771f('0x21')]||null:null,'limit':_0x16f227[_0x771f('0x1e')]?_0x16f227[_0x771f('0x1e')][_0x771f('0x22')]||null:null,'include':_0x16f227['options']?_0x16f227[_0x771f('0x1e')][_0x771f('0x23')]?_['map'](_0x16f227[_0x771f('0x1e')]['include'],function(_0x3162af){return{'model':db[_0x3162af[_0x771f('0x24')]],'as':_0x3162af['as'],'attributes':_0x3162af[_0x771f('0x21')],'include':_0x3162af[_0x771f('0x23')]?_['map'](_0x3162af[_0x771f('0x23')],function(_0x557ce1){return{'model':db[_0x557ce1[_0x771f('0x24')]],'as':_0x557ce1['as'],'attributes':_0x557ce1[_0x771f('0x21')],'include':_0x557ce1['include']?_[_0x771f('0x25')](_0x557ce1[_0x771f('0x23')],function(_0x2b7e95){return{'model':db[_0x2b7e95['model']],'as':_0x2b7e95['as'],'attributes':_0x2b7e95['attributes']};}):[]};}):[]};}):[]:[]})[_0x771f('0x26')](function(_0x18f821){logger['info']('GetFaxAccount',_0x16f227);logger[_0x771f('0x12')]('GetFaxAccount',_0x16f227,JSON[_0x771f('0x14')](_0x18f821));_0x490816(_0x18f821);})['catch'](function(_0x3c0853){logger[_0x771f('0x15')](_0x771f('0x1b'),_0x3c0853['message'],_0x16f227);_0x36c565(_0xbff02a[_0x771f('0x15')](0x1f4,_0x3c0853[_0x771f('0x18')]));});});};exports[_0x771f('0x27')]=function(_0x4a4c4a,_0x3cf9e1,_0x2b3ef8){var _0x586075=this;return new Promise(function(_0x4935c7,_0x380dc6){var _0x572f34={'body':_0x4a4c4a[_0x771f('0x28')],'channel':_0x771f('0x29')};var _0xed3bb8=[];var _0x3f3ab2=[];var _0x1ac4dc={};return db[_0x771f('0x2a')][_0x771f('0x2b')]()[_0x771f('0x26')](function(_0x2f3d50){if(!_0x2f3d50){throw new db[(_0x771f('0x2c'))][(_0x771f('0x2d'))](_0x771f('0x2e'));}_0xed3bb8=_[_0x771f('0x2f')](_[_0x771f('0x30')](_0x2f3d50),[_0x771f('0x31'),'updatedAt']);_0x3f3ab2=_[_0x771f('0x2f')](_[_0x771f('0x30')](_0x2f3d50),['createdAt',_0x771f('0x32'),_0x771f('0x33'),_0x771f('0x34')]);if(_0x4a4c4a['body']['id']){delete _0x4a4c4a[_0x771f('0x28')]['id'];}if(_['isNil'](_0x4a4c4a['body']['from'])){throw new db[(_0x771f('0x2c'))]['ValidationError']('from\x20is\x20mandatory');}if(_['isNil'](_0x4a4c4a[_0x771f('0x28')][_0x771f('0x28')])||_0x4a4c4a[_0x771f('0x28')][_0x771f('0x28')]===''){throw new db[(_0x771f('0x2c'))][(_0x771f('0x2d'))](_0x771f('0x35'));}if(_['isNil'](_0x4a4c4a[_0x771f('0x28')][_0x771f('0x36')])){throw new db['Sequelize'][(_0x771f('0x2d'))](_0x771f('0x37')+_0x3f3ab2);}if(!_[_0x771f('0x38')](_0x3f3ab2,_0x4a4c4a[_0x771f('0x28')][_0x771f('0x36')])){throw new db['Sequelize'][(_0x771f('0x2d'))]('mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20'+_0x3f3ab2);}_0x1ac4dc[_0x4a4c4a[_0x771f('0x28')][_0x771f('0x36')]]=_0x4a4c4a['body']['from'];})['then'](function(){return db[_0x771f('0x1c')][_0x771f('0x39')]({'where':{'id':_0x4a4c4a[_0x771f('0x3a')]['id']},'include':[{'model':db[_0x771f('0x3b')],'as':'List','include':[{'model':db[_0x771f('0x2a')],'as':_0x771f('0x3c'),'where':_0x1ac4dc,'limit':0x1,'order':[['updatedAt',_0x771f('0x3d')]]}]},{'model':db[_0x771f('0x3e')],'as':'Applications'}]});})[_0x771f('0x26')](function(_0x3d9476){if(_0x3d9476&&_0x3d9476[_0x771f('0x3f')]){var _0x5b941f=_0x3d9476[_0x771f('0x40')]({'plain':!![]});_0x572f34[_0x771f('0x3a')]=_0x5b941f;_0x572f34[_0x771f('0x41')]=_0x5b941f['Applications'];_0x572f34[_0x771f('0x42')]=_0x5b941f[_0x771f('0x3f')];_0x572f34[_0x771f('0x41')]=_[_0x771f('0x43')](_0x572f34[_0x771f('0x41')],[_0x771f('0x44')],[_0x771f('0x45')]);if(_0x572f34[_0x771f('0x3a')][_0x771f('0x46')]){delete _0x572f34[_0x771f('0x3a')][_0x771f('0x46')];}if(_0x572f34['account']['List']&&_0x572f34[_0x771f('0x3a')]['List'][_0x771f('0x3c')][_0x771f('0x47')]){return _0x572f34[_0x771f('0x3a')][_0x771f('0x3f')][_0x771f('0x3c')][0x0];}var _0x4db24e=_['defaults'](_0x4a4c4a['body'],{'firstName':_0x4a4c4a[_0x771f('0x28')]['from'],'ListId':_0x5b941f[_0x771f('0x34')]});_0x4db24e[_0x4a4c4a[_0x771f('0x28')][_0x771f('0x36')]]=_0x4a4c4a[_0x771f('0x28')]['from'];return db[_0x771f('0x2a')][_0x771f('0x48')](_0x4db24e,{'fields':_0xed3bb8,'raw':!![]});}})[_0x771f('0x26')](function(_0x276c66){_0x572f34['contact']=_0x276c66;if(_0x276c66){var _0x40f775={'ContactId':_0x276c66['id'],'FaxAccountId':_0x4a4c4a[_0x771f('0x3a')]['id'],'fax':_0x276c66['fax']};return db['FaxInteraction']['find']({'where':{'ContactId':_0x276c66['id'],'closed':![],'FaxAccountId':_0x4a4c4a['account']['id']}})['then'](function(_0x4e48ca){if(_0x4e48ca){return[_0x4e48ca,![]];}return db[_0x771f('0x49')]['create'](_0x40f775)[_0x771f('0x26')](function(_0x576d39){return[_0x576d39,!![]];});});}else{throw new Error(_0x771f('0x4a'));}})['spread'](function(_0x460d01,_0x2f344c){var _0xef3e47=_0x460d01[_0x771f('0x40')]({'plain':!![]});if(_0x2f344c){if(_0x572f34['account']['autoclose']){_0x572f34[_0x771f('0x41')][_0x771f('0x4b')]({'id':0x0,'priority':_0x572f34['applications']['length']+0x1,'app':_0x771f('0x4c'),'appdata':_0x771f('0x4d'),'interval':_0x771f('0x4e')});}_0xef3e47[_0x771f('0x4f')]=!![];}else{_0xef3e47[_0x771f('0x4f')]=![];}_0x572f34[_0x771f('0x50')]=_0xef3e47;return db[_0x771f('0x51')][_0x771f('0x48')]({'body':_0x4a4c4a[_0x771f('0x28')][_0x771f('0x28')],'FaxAccountId':_0x4a4c4a['account']['id'],'FaxInteractionId':_0x460d01['id'],'direction':'in','ContactId':_0x460d01[_0x771f('0x52')],'AttachmentId':_0x4a4c4a[_0x771f('0x28')][_0x771f('0x53')]});})['then'](function(_0xf11165){_0x572f34[_0x771f('0x18')]=_0xf11165;if(_0x572f34[_0x771f('0x50')][_0x771f('0x54')]){return db[_0x771f('0x55')][_0x771f('0x39')]({'attributes':['id','name'],'where':{'id':_0x572f34[_0x771f('0x50')][_0x771f('0x54')]}})['then'](function(_0x9d8c58){if(_0x9d8c58){_0x572f34[_0x771f('0x41')]['unshift']({'id':0x0,'priority':0x0,'app':_0x771f('0x56'),'appdata':_0x9d8c58[_0x771f('0x57')]+','+(_0x572f34[_0x771f('0x3a')][_0x771f('0x58')]||0xa),'interval':'*,*,*,*'});}return respondWithRpcPromise(_0x771f('0x59'),_0x771f('0x5a'),_0x572f34);});}return respondWithRpcPromise(_0x771f('0x59'),_0x771f('0x5a'),_0x572f34);})[_0x771f('0x26')](function(_0xb2d590){_0x4935c7(_0xb2d590);})[_0x771f('0x1a')](function(_0x363b92){_0x380dc6(_0x586075['error'](0x1f4,_0x363b92[_0x771f('0x18')]));});});};
\ No newline at end of file
+var _0x3f91=['request\x20sent','error','code','message','info','result','catch','GetFaxAccount','findAll','options','raw','include','map','model','attributes','then','NotifyFaxAccount','body','fax','CmContact','describe','Sequelize','ValidationError','keys','createdAt','CompanyId','ListId','from','from\x20is\x20mandatory','isNil','body\x20is\x20mandatory\x20and\x20not\x20empty','mapKey','includes','mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','FaxAccount','find','account','CmList','List','Contacts','updatedAt','DESC','FaxApplication','get','applications','Applications','list','priority','length','create','contact','FaxInteraction','Contact\x20not\x20found','spread','autoclose','close','unmanaged','*,*,*,*','created','interaction','ContactId','AttachmentId','UserId','User','unshift','Start','startRouting','moment','bluebird','randomstring','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','redis','defaults','localhost','socket.io-emitter','./faxAccount.socket','register','request','FaxAccount,\x20%s,\x20%s','debug','FaxAccount,\x20%s,\x20%s,\x20%s'];(function(_0x383cbc,_0xeaa783){var _0x48d876=function(_0x266321){while(--_0x266321){_0x383cbc['push'](_0x383cbc['shift']());}};_0x48d876(++_0xeaa783);}(_0x3f91,0x99));var _0x13f9=function(_0x17b6e3,_0x4522ed){_0x17b6e3=_0x17b6e3-0x0;var _0x3906f3=_0x3f91[_0x17b6e3];return _0x3906f3;};'use strict';var _=require('lodash');var util=require('util');var moment=require(_0x13f9('0x0'));var BPromise=require(_0x13f9('0x1'));var rs=require(_0x13f9('0x2'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x13f9('0x3'))['db'];var utils=require(_0x13f9('0x4'));var logger=require(_0x13f9('0x5'))(_0x13f9('0x6'));var config=require(_0x13f9('0x7'));var jayson=require(_0x13f9('0x8'));var client=jayson['client']['http']({'port':0x232c});config[_0x13f9('0x9')]=_[_0x13f9('0xa')](config[_0x13f9('0x9')],{'host':_0x13f9('0xb'),'port':0x18eb});var socket=require(_0x13f9('0xc'))(new Redis(config[_0x13f9('0x9')]));require(_0x13f9('0xd'))[_0x13f9('0xe')](socket);function respondWithRpcPromise(_0x2fc598,_0x115cb7,_0x56f492){return new BPromise(function(_0x13d79a,_0x1fb558){return client[_0x13f9('0xf')](_0x2fc598,_0x56f492)['then'](function(_0x36cc63){logger['info'](_0x13f9('0x10'),_0x115cb7,'request\x20sent');logger[_0x13f9('0x11')](_0x13f9('0x12'),_0x115cb7,_0x13f9('0x13'),JSON['stringify'](_0x36cc63));if(_0x36cc63[_0x13f9('0x14')]){if(_0x36cc63[_0x13f9('0x14')][_0x13f9('0x15')]===0x1f4){logger[_0x13f9('0x14')](_0x13f9('0x10'),_0x115cb7,_0x36cc63['error']['message']);return _0x1fb558(_0x36cc63[_0x13f9('0x14')][_0x13f9('0x16')]);}logger[_0x13f9('0x14')](_0x13f9('0x10'),_0x115cb7,_0x36cc63['error']['message']);return _0x13d79a(_0x36cc63[_0x13f9('0x14')][_0x13f9('0x16')]);}else{logger[_0x13f9('0x17')](_0x13f9('0x10'),_0x115cb7,_0x13f9('0x13'));_0x13d79a(_0x36cc63[_0x13f9('0x18')][_0x13f9('0x16')]);}})[_0x13f9('0x19')](function(_0x5c2da2){logger['error'](_0x13f9('0x10'),_0x115cb7,_0x5c2da2);_0x1fb558(_0x5c2da2);});});}exports[_0x13f9('0x1a')]=function(_0x5dc95e){var _0x15ecc3=this;return new Promise(function(_0x3f5226,_0xf06a13){return db['FaxAccount'][_0x13f9('0x1b')]({'raw':_0x5dc95e['options']?_0x5dc95e[_0x13f9('0x1c')][_0x13f9('0x1d')]===undefined?!![]:![]:!![],'where':_0x5dc95e['options']?_0x5dc95e[_0x13f9('0x1c')]['where']||null:null,'attributes':_0x5dc95e[_0x13f9('0x1c')]?_0x5dc95e[_0x13f9('0x1c')]['attributes']||null:null,'limit':_0x5dc95e['options']?_0x5dc95e[_0x13f9('0x1c')]['limit']||null:null,'include':_0x5dc95e[_0x13f9('0x1c')]?_0x5dc95e[_0x13f9('0x1c')][_0x13f9('0x1e')]?_[_0x13f9('0x1f')](_0x5dc95e[_0x13f9('0x1c')][_0x13f9('0x1e')],function(_0x292d26){return{'model':db[_0x292d26[_0x13f9('0x20')]],'as':_0x292d26['as'],'attributes':_0x292d26[_0x13f9('0x21')],'include':_0x292d26['include']?_['map'](_0x292d26[_0x13f9('0x1e')],function(_0x76700f){return{'model':db[_0x76700f[_0x13f9('0x20')]],'as':_0x76700f['as'],'attributes':_0x76700f[_0x13f9('0x21')],'include':_0x76700f[_0x13f9('0x1e')]?_[_0x13f9('0x1f')](_0x76700f[_0x13f9('0x1e')],function(_0x54e108){return{'model':db[_0x54e108['model']],'as':_0x54e108['as'],'attributes':_0x54e108[_0x13f9('0x21')]};}):[]};}):[]};}):[]:[]})[_0x13f9('0x22')](function(_0x3f03e7){logger['info'](_0x13f9('0x1a'),_0x5dc95e);logger[_0x13f9('0x11')]('GetFaxAccount',_0x5dc95e,JSON['stringify'](_0x3f03e7));_0x3f5226(_0x3f03e7);})['catch'](function(_0xd30005){logger[_0x13f9('0x14')](_0x13f9('0x1a'),_0xd30005[_0x13f9('0x16')],_0x5dc95e);_0xf06a13(_0x15ecc3[_0x13f9('0x14')](0x1f4,_0xd30005[_0x13f9('0x16')]));});});};exports[_0x13f9('0x23')]=function(_0xf67ec3,_0x172f6a,_0xf0c1a1){var _0x5306c8=this;return new Promise(function(_0x33026f,_0x2eb84d){var _0x415f87={'body':_0xf67ec3[_0x13f9('0x24')],'channel':_0x13f9('0x25')};var _0x3ba5e6=[];var _0xb14908=[];var _0x603ed5={};return db[_0x13f9('0x26')][_0x13f9('0x27')]()['then'](function(_0x209c63){if(!_0x209c63){throw new db[(_0x13f9('0x28'))][(_0x13f9('0x29'))]('no\x20available\x20attributes');}_0x3ba5e6=_['difference'](_[_0x13f9('0x2a')](_0x209c63),[_0x13f9('0x2b'),'updatedAt']);_0xb14908=_['difference'](_[_0x13f9('0x2a')](_0x209c63),['createdAt','updatedAt',_0x13f9('0x2c'),_0x13f9('0x2d')]);if(_0xf67ec3[_0x13f9('0x24')]['id']){delete _0xf67ec3['body']['id'];}if(_['isNil'](_0xf67ec3[_0x13f9('0x24')][_0x13f9('0x2e')])){throw new db[(_0x13f9('0x28'))][(_0x13f9('0x29'))](_0x13f9('0x2f'));}if(_[_0x13f9('0x30')](_0xf67ec3['body'][_0x13f9('0x24')])||_0xf67ec3['body'][_0x13f9('0x24')]===''){throw new db['Sequelize'][(_0x13f9('0x29'))](_0x13f9('0x31'));}if(_[_0x13f9('0x30')](_0xf67ec3[_0x13f9('0x24')][_0x13f9('0x32')])){throw new db[(_0x13f9('0x28'))]['ValidationError']('mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20'+_0xb14908);}if(!_[_0x13f9('0x33')](_0xb14908,_0xf67ec3[_0x13f9('0x24')][_0x13f9('0x32')])){throw new db[(_0x13f9('0x28'))][(_0x13f9('0x29'))](_0x13f9('0x34')+_0xb14908);}_0x603ed5[_0xf67ec3['body'][_0x13f9('0x32')]]=_0xf67ec3[_0x13f9('0x24')]['from'];})[_0x13f9('0x22')](function(){return db[_0x13f9('0x35')][_0x13f9('0x36')]({'where':{'id':_0xf67ec3[_0x13f9('0x37')]['id']},'include':[{'model':db[_0x13f9('0x38')],'as':_0x13f9('0x39'),'include':[{'model':db[_0x13f9('0x26')],'as':_0x13f9('0x3a'),'where':_0x603ed5,'limit':0x1,'order':[[_0x13f9('0x3b'),_0x13f9('0x3c')]]}]},{'model':db[_0x13f9('0x3d')],'as':'Applications'}]});})[_0x13f9('0x22')](function(_0x1e8542){if(_0x1e8542&&_0x1e8542[_0x13f9('0x39')]){var _0x2d96bd=_0x1e8542[_0x13f9('0x3e')]({'plain':!![]});_0x415f87['account']=_0x2d96bd;_0x415f87[_0x13f9('0x3f')]=_0x2d96bd[_0x13f9('0x40')];_0x415f87[_0x13f9('0x41')]=_0x2d96bd[_0x13f9('0x39')];_0x415f87['applications']=_['orderBy'](_0x415f87[_0x13f9('0x3f')],[_0x13f9('0x42')],['asc']);if(_0x415f87[_0x13f9('0x37')]['Applications']){delete _0x415f87[_0x13f9('0x37')][_0x13f9('0x40')];}if(_0x415f87[_0x13f9('0x37')][_0x13f9('0x39')]&&_0x415f87['account'][_0x13f9('0x39')][_0x13f9('0x3a')][_0x13f9('0x43')]){return _0x415f87[_0x13f9('0x37')][_0x13f9('0x39')][_0x13f9('0x3a')][0x0];}var _0x137148=_['defaults'](_0xf67ec3[_0x13f9('0x24')],{'firstName':_0xf67ec3[_0x13f9('0x24')][_0x13f9('0x2e')],'ListId':_0x2d96bd[_0x13f9('0x2d')]});_0x137148[_0xf67ec3['body'][_0x13f9('0x32')]]=_0xf67ec3[_0x13f9('0x24')][_0x13f9('0x2e')];return db[_0x13f9('0x26')][_0x13f9('0x44')](_0x137148,{'fields':_0x3ba5e6,'raw':!![]});}})[_0x13f9('0x22')](function(_0x44ea69){_0x415f87[_0x13f9('0x45')]=_0x44ea69;if(_0x44ea69){var _0x7a6cc4={'ContactId':_0x44ea69['id'],'FaxAccountId':_0xf67ec3[_0x13f9('0x37')]['id'],'fax':_0x44ea69[_0x13f9('0x25')]};return db[_0x13f9('0x46')][_0x13f9('0x36')]({'where':{'ContactId':_0x44ea69['id'],'closed':![],'FaxAccountId':_0xf67ec3[_0x13f9('0x37')]['id']}})[_0x13f9('0x22')](function(_0x46f997){if(_0x46f997){return[_0x46f997,![]];}return db[_0x13f9('0x46')][_0x13f9('0x44')](_0x7a6cc4)['then'](function(_0xce91b5){return[_0xce91b5,!![]];});});}else{throw new Error(_0x13f9('0x47'));}})[_0x13f9('0x48')](function(_0x4a9e52,_0x437ed2){var _0x431c15=_0x4a9e52['get']({'plain':!![]});if(_0x437ed2){if(_0x415f87[_0x13f9('0x37')][_0x13f9('0x49')]){_0x415f87[_0x13f9('0x3f')]['push']({'id':0x0,'priority':_0x415f87[_0x13f9('0x3f')][_0x13f9('0x43')]+0x1,'app':_0x13f9('0x4a'),'appdata':_0x13f9('0x4b'),'interval':_0x13f9('0x4c')});}_0x431c15[_0x13f9('0x4d')]=!![];}else{_0x431c15[_0x13f9('0x4d')]=![];}_0x415f87[_0x13f9('0x4e')]=_0x431c15;return db['FaxMessage'][_0x13f9('0x44')]({'body':_0xf67ec3['body'][_0x13f9('0x24')],'FaxAccountId':_0xf67ec3[_0x13f9('0x37')]['id'],'FaxInteractionId':_0x4a9e52['id'],'direction':'in','ContactId':_0x4a9e52[_0x13f9('0x4f')],'AttachmentId':_0xf67ec3['body'][_0x13f9('0x50')]});})[_0x13f9('0x22')](function(_0x34dada){_0x415f87[_0x13f9('0x16')]=_0x34dada;if(_0x415f87[_0x13f9('0x4e')][_0x13f9('0x51')]){return db[_0x13f9('0x52')][_0x13f9('0x36')]({'attributes':['id','name'],'where':{'id':_0x415f87[_0x13f9('0x4e')][_0x13f9('0x51')]}})[_0x13f9('0x22')](function(_0x537dd9){if(_0x537dd9){_0x415f87[_0x13f9('0x3f')][_0x13f9('0x53')]({'id':0x0,'priority':0x0,'app':'agent','appdata':_0x537dd9['name']+','+(_0x415f87[_0x13f9('0x37')]['waitForTheAssignedAgent']||0xa),'interval':_0x13f9('0x4c')});}return respondWithRpcPromise(_0x13f9('0x54'),_0x13f9('0x55'),_0x415f87);});}return respondWithRpcPromise('Start','startRouting',_0x415f87);})[_0x13f9('0x22')](function(_0x4003f7){_0x33026f(_0x4003f7);})[_0x13f9('0x19')](function(_0x1f6336){_0x2eb84d(_0x5306c8[_0x13f9('0x14')](0x1f4,_0x1f6336[_0x13f9('0x16')]));});});};
\ No newline at end of file