Built motion from commit da24aabd.|2.6.20
[motion2.git] / server / api / faxAccount / faxAccount.rpc.js
index ff34925..f530479 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x088b=['orderBy','asc','length','defaults','create','contact','Contact\x20not\x20found','spread','autoclose','push','close','*,*,*,*','created','interaction','ContactId','AttachmentId','UserId','User','name','unshift','agent','queueId','FaxQueue','startRouting','lodash','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','http','redis','socket.io-emitter','./faxAccount.socket','request','then','info','FaxAccount,\x20%s,\x20%s','request\x20sent','debug','FaxAccount,\x20%s,\x20%s,\x20%s','stringify','error','message','result','options','attributes','limit','include','map','model','GetFaxAccount','catch','NotifyFaxAccount','fax','Sequelize','ValidationError','difference','keys','createdAt','CompanyId','ListId','body','isNil','from','from\x20is\x20mandatory','body\x20is\x20mandatory\x20and\x20not\x20empty','mapKey','mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','FaxAccount','find','account','CmList','List','CmContact','Contacts','updatedAt','FaxApplication','Applications','get','applications','list'];(function(_0x3e1415,_0x2ad5ee){var _0x2e1ec7=function(_0x4beb31){while(--_0x4beb31){_0x3e1415['push'](_0x3e1415['shift']());}};_0x2e1ec7(++_0x2ad5ee);}(_0x088b,0xc8));var _0xb088=function(_0x4279e1,_0x39cda4){_0x4279e1=_0x4279e1-0x0;var _0x1e33ea=_0x088b[_0x4279e1];return _0x1e33ea;};'use strict';var _=require(_0xb088('0x0'));var util=require('util');var moment=require(_0xb088('0x1'));var BPromise=require(_0xb088('0x2'));var rs=require(_0xb088('0x3'));var fs=require('fs');var Redis=require(_0xb088('0x4'));var db=require(_0xb088('0x5'))['db'];var utils=require(_0xb088('0x6'));var logger=require(_0xb088('0x7'))(_0xb088('0x8'));var config=require(_0xb088('0x9'));var jayson=require(_0xb088('0xa'));var client=jayson['client'][_0xb088('0xb')]({'port':0x232c});config[_0xb088('0xc')]=_['defaults'](config[_0xb088('0xc')],{'host':'localhost','port':0x18eb});var socket=require(_0xb088('0xd'))(new Redis(config[_0xb088('0xc')]));require(_0xb088('0xe'))['register'](socket);function respondWithRpcPromise(_0x1e5d57,_0x482c14,_0x2fefc7){return new BPromise(function(_0x4fa1e4,_0x555a97){return client[_0xb088('0xf')](_0x1e5d57,_0x2fefc7)[_0xb088('0x10')](function(_0x51ea01){logger[_0xb088('0x11')](_0xb088('0x12'),_0x482c14,_0xb088('0x13'));logger[_0xb088('0x14')](_0xb088('0x15'),_0x482c14,_0xb088('0x13'),JSON[_0xb088('0x16')](_0x51ea01));if(_0x51ea01[_0xb088('0x17')]){if(_0x51ea01[_0xb088('0x17')]['code']===0x1f4){logger[_0xb088('0x17')](_0xb088('0x12'),_0x482c14,_0x51ea01[_0xb088('0x17')][_0xb088('0x18')]);return _0x555a97(_0x51ea01[_0xb088('0x17')][_0xb088('0x18')]);}logger[_0xb088('0x17')]('FaxAccount,\x20%s,\x20%s',_0x482c14,_0x51ea01['error'][_0xb088('0x18')]);return _0x4fa1e4(_0x51ea01['error'][_0xb088('0x18')]);}else{logger[_0xb088('0x11')](_0xb088('0x12'),_0x482c14,'request\x20sent');_0x4fa1e4(_0x51ea01[_0xb088('0x19')][_0xb088('0x18')]);}})['catch'](function(_0xcebe48){logger[_0xb088('0x17')](_0xb088('0x12'),_0x482c14,_0xcebe48);_0x555a97(_0xcebe48);});});}exports['GetFaxAccount']=function(_0x82157b){var _0x13a619=this;return new Promise(function(_0x27c881,_0x37b6be){return db['FaxAccount']['findAll']({'raw':_0x82157b[_0xb088('0x1a')]?_0x82157b[_0xb088('0x1a')]['raw']===undefined?!![]:![]:!![],'where':_0x82157b[_0xb088('0x1a')]?_0x82157b['options']['where']||null:null,'attributes':_0x82157b[_0xb088('0x1a')]?_0x82157b[_0xb088('0x1a')][_0xb088('0x1b')]||null:null,'limit':_0x82157b[_0xb088('0x1a')]?_0x82157b[_0xb088('0x1a')][_0xb088('0x1c')]||null:null,'include':_0x82157b['options']?_0x82157b[_0xb088('0x1a')][_0xb088('0x1d')]?_[_0xb088('0x1e')](_0x82157b[_0xb088('0x1a')][_0xb088('0x1d')],function(_0x4c0028){return{'model':db[_0x4c0028['model']],'as':_0x4c0028['as'],'attributes':_0x4c0028[_0xb088('0x1b')],'include':_0x4c0028[_0xb088('0x1d')]?_[_0xb088('0x1e')](_0x4c0028['include'],function(_0x49618e){return{'model':db[_0x49618e[_0xb088('0x1f')]],'as':_0x49618e['as'],'attributes':_0x49618e[_0xb088('0x1b')],'include':_0x49618e[_0xb088('0x1d')]?_[_0xb088('0x1e')](_0x49618e[_0xb088('0x1d')],function(_0x4cd8ef){return{'model':db[_0x4cd8ef['model']],'as':_0x4cd8ef['as'],'attributes':_0x4cd8ef['attributes']};}):[]};}):[]};}):[]:[]})[_0xb088('0x10')](function(_0x1680d4){logger[_0xb088('0x11')](_0xb088('0x20'),_0x82157b);logger[_0xb088('0x14')]('GetFaxAccount',_0x82157b,JSON[_0xb088('0x16')](_0x1680d4));_0x27c881(_0x1680d4);})[_0xb088('0x21')](function(_0x170040){logger[_0xb088('0x17')](_0xb088('0x20'),_0x170040[_0xb088('0x18')],_0x82157b);_0x37b6be(_0x13a619['error'](0x1f4,_0x170040[_0xb088('0x18')]));});});};exports[_0xb088('0x22')]=function(_0x4c6171,_0x9ea8ef,_0x2a597b){var _0x4447f2=this;return new Promise(function(_0x2e344d,_0x3e76c7){var _0x2c8fc6={'body':_0x4c6171['body'],'channel':_0xb088('0x23')};var _0x221211=[];var _0x50cbe0=[];var _0x117125={};return db['CmContact']['describe']()['then'](function(_0x53940f){if(!_0x53940f){throw new db[(_0xb088('0x24'))][(_0xb088('0x25'))]('no\x20available\x20attributes');}_0x221211=_[_0xb088('0x26')](_[_0xb088('0x27')](_0x53940f),[_0xb088('0x28'),'updatedAt']);_0x50cbe0=_[_0xb088('0x26')](_['keys'](_0x53940f),[_0xb088('0x28'),'updatedAt',_0xb088('0x29'),_0xb088('0x2a')]);if(_0x4c6171['body']['id']){delete _0x4c6171[_0xb088('0x2b')]['id'];}if(_[_0xb088('0x2c')](_0x4c6171[_0xb088('0x2b')][_0xb088('0x2d')])){throw new db[(_0xb088('0x24'))][(_0xb088('0x25'))](_0xb088('0x2e'));}if(_[_0xb088('0x2c')](_0x4c6171[_0xb088('0x2b')][_0xb088('0x2b')])||_0x4c6171[_0xb088('0x2b')][_0xb088('0x2b')]===''){throw new db[(_0xb088('0x24'))][(_0xb088('0x25'))](_0xb088('0x2f'));}if(_[_0xb088('0x2c')](_0x4c6171[_0xb088('0x2b')][_0xb088('0x30')])){throw new db['Sequelize'][(_0xb088('0x25'))](_0xb088('0x31')+_0x50cbe0);}if(!_['includes'](_0x50cbe0,_0x4c6171[_0xb088('0x2b')][_0xb088('0x30')])){throw new db[(_0xb088('0x24'))][(_0xb088('0x25'))](_0xb088('0x32')+_0x50cbe0);}_0x117125[_0x4c6171[_0xb088('0x2b')]['mapKey']]=_0x4c6171[_0xb088('0x2b')][_0xb088('0x2d')];})['then'](function(){return db[_0xb088('0x33')][_0xb088('0x34')]({'where':{'id':_0x4c6171[_0xb088('0x35')]['id']},'include':[{'model':db[_0xb088('0x36')],'as':_0xb088('0x37'),'include':[{'model':db[_0xb088('0x38')],'as':_0xb088('0x39'),'where':_0x117125,'limit':0x1,'order':[[_0xb088('0x3a'),'DESC']]}]},{'model':db[_0xb088('0x3b')],'as':_0xb088('0x3c')}]});})[_0xb088('0x10')](function(_0xc5909f){if(_0xc5909f&&_0xc5909f['List']){var _0x5644f6=_0xc5909f[_0xb088('0x3d')]({'plain':!![]});_0x2c8fc6['account']=_0x5644f6;_0x2c8fc6[_0xb088('0x3e')]=_0x5644f6[_0xb088('0x3c')];_0x2c8fc6[_0xb088('0x3f')]=_0x5644f6[_0xb088('0x37')];_0x2c8fc6['applications']=_[_0xb088('0x40')](_0x2c8fc6[_0xb088('0x3e')],['priority'],[_0xb088('0x41')]);if(_0x2c8fc6[_0xb088('0x35')][_0xb088('0x3c')]){delete _0x2c8fc6[_0xb088('0x35')][_0xb088('0x3c')];}if(_0x2c8fc6[_0xb088('0x35')]['List']&&_0x2c8fc6['account'][_0xb088('0x37')]['Contacts'][_0xb088('0x42')]){return _0x2c8fc6['account']['List'][_0xb088('0x39')][0x0];}var _0x454148=_[_0xb088('0x43')](_0x4c6171[_0xb088('0x2b')],{'firstName':_0x4c6171[_0xb088('0x2b')][_0xb088('0x2d')],'ListId':_0x5644f6[_0xb088('0x2a')]});_0x454148[_0x4c6171[_0xb088('0x2b')][_0xb088('0x30')]]=_0x4c6171['body'][_0xb088('0x2d')];return db['CmContact'][_0xb088('0x44')](_0x454148,{'fields':_0x221211,'raw':!![]});}})[_0xb088('0x10')](function(_0x95bb31){_0x2c8fc6[_0xb088('0x45')]=_0x95bb31;if(_0x95bb31){var _0x1f98e5={'ContactId':_0x95bb31['id'],'FaxAccountId':_0x4c6171[_0xb088('0x35')]['id'],'fax':_0x95bb31['fax']};return db['FaxInteraction'][_0xb088('0x34')]({'where':{'ContactId':_0x95bb31['id'],'closed':![],'FaxAccountId':_0x4c6171['account']['id']}})[_0xb088('0x10')](function(_0x104e08){if(_0x104e08){return[_0x104e08,![]];}return db['FaxInteraction'][_0xb088('0x44')](_0x1f98e5)[_0xb088('0x10')](function(_0x41594c){return[_0x41594c,!![]];});});}else{throw new Error(_0xb088('0x46'));}})[_0xb088('0x47')](function(_0x39d0dc,_0x4f8b71){var _0x38fa5c=_0x39d0dc[_0xb088('0x3d')]({'plain':!![]});if(_0x4f8b71){if(_0x2c8fc6[_0xb088('0x35')][_0xb088('0x48')]){_0x2c8fc6[_0xb088('0x3e')][_0xb088('0x49')]({'id':0x0,'priority':_0x2c8fc6[_0xb088('0x3e')][_0xb088('0x42')]+0x1,'app':_0xb088('0x4a'),'appdata':'unmanaged','interval':_0xb088('0x4b')});}_0x38fa5c[_0xb088('0x4c')]=!![];}else{_0x38fa5c['created']=![];}_0x2c8fc6[_0xb088('0x4d')]=_0x38fa5c;return db['FaxMessage'][_0xb088('0x44')]({'body':_0x4c6171[_0xb088('0x2b')]['body'],'FaxAccountId':_0x4c6171[_0xb088('0x35')]['id'],'FaxInteractionId':_0x39d0dc['id'],'direction':'in','ContactId':_0x39d0dc[_0xb088('0x4e')],'AttachmentId':_0x4c6171[_0xb088('0x2b')][_0xb088('0x4f')]});})['then'](function(_0x119c82){_0x2c8fc6[_0xb088('0x18')]=_0x119c82;if(!_0x2c8fc6[_0xb088('0x4d')][_0xb088('0x50')])return;return db[_0xb088('0x51')][_0xb088('0x34')]({'attributes':['id',_0xb088('0x52')],'where':{'id':_0x2c8fc6[_0xb088('0x4d')][_0xb088('0x50')]}});})[_0xb088('0x10')](function(_0x5594a7){if(_0x5594a7){_0x2c8fc6[_0xb088('0x3e')][_0xb088('0x53')]({'id':0x0,'priority':0x0,'app':_0xb088('0x54'),'appdata':_0x5594a7[_0xb088('0x52')]+','+(_0x2c8fc6['account']['waitForTheAssignedAgent']||0xa),'interval':_0xb088('0x4b')});}if(!_0x2c8fc6[_0xb088('0x4d')][_0xb088('0x55')])return;return db[_0xb088('0x56')][_0xb088('0x34')]({'attributes':['id','name'],'where':{'id':_0x2c8fc6[_0xb088('0x4d')][_0xb088('0x55')]}});})['then'](function(_0x2f7458){if(_0x2f7458){_0x2c8fc6[_0xb088('0x3e')][_0xb088('0x53')]({'id':0x0,'priority':0x1,'app':'queue','appdata':_0x2f7458[_0xb088('0x52')]+','+(_0x2c8fc6['account']['waitForTheAssignedQueue']||0x12c),'interval':_0xb088('0x4b')});}return respondWithRpcPromise('Start',_0xb088('0x57'),_0x2c8fc6);})[_0xb088('0x10')](function(_0x184b08){_0x2e344d(_0x184b08);})[_0xb088('0x21')](function(_0x4351b2){_0x3e76c7(_0x4447f2[_0xb088('0x17')](0x1f4,_0x4351b2[_0xb088('0x18')]));});});};
\ No newline at end of file
+var _0x93ef=['autoclose','push','close','unmanaged','*,*,*,*','created','FaxMessage','AttachmentId','User','find','name','interaction','UserId','unshift','agent','waitForTheAssignedAgent','FaxQueue','queueId','queue','waitForTheAssignedQueue','Start','startRouting','lodash','util','moment','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','jayson/promise','client','http','redis','localhost','register','request','then','info','FaxAccount,\x20%s,\x20%s','request\x20sent','FaxAccount,\x20%s,\x20%s,\x20%s','error','code','message','result','catch','FaxAccount','findAll','options','raw','where','limit','include','map','model','attributes','GetFaxAccount','debug','stringify','body','fax','describe','ValidationError','difference','keys','createdAt','updatedAt','CompanyId','ListId','from','from\x20is\x20mandatory','Sequelize','body\x20is\x20mandatory\x20and\x20not\x20empty','isNil','mapKey','mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','includes','account','CmList','List','CmContact','Contacts','DESC','FaxApplication','Applications','get','applications','list','asc','length','defaults','create','contact','FaxInteraction','Contact\x20not\x20found'];(function(_0x122ef9,_0x451d2a){var _0x42fba0=function(_0x17c9d3){while(--_0x17c9d3){_0x122ef9['push'](_0x122ef9['shift']());}};_0x42fba0(++_0x451d2a);}(_0x93ef,0xd8));var _0xf93e=function(_0x38f3a9,_0x67f305){_0x38f3a9=_0x38f3a9-0x0;var _0x1623e6=_0x93ef[_0x38f3a9];return _0x1623e6;};'use strict';var _=require(_0xf93e('0x0'));var util=require(_0xf93e('0x1'));var moment=require(_0xf93e('0x2'));var BPromise=require('bluebird');var rs=require(_0xf93e('0x3'));var fs=require('fs');var Redis=require(_0xf93e('0x4'));var db=require(_0xf93e('0x5'))['db'];var utils=require(_0xf93e('0x6'));var logger=require(_0xf93e('0x7'))('rpc');var config=require(_0xf93e('0x8'));var jayson=require(_0xf93e('0x9'));var client=jayson[_0xf93e('0xa')][_0xf93e('0xb')]({'port':0x232c});config[_0xf93e('0xc')]=_['defaults'](config[_0xf93e('0xc')],{'host':_0xf93e('0xd'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xf93e('0xc')]));require('./faxAccount.socket')[_0xf93e('0xe')](socket);function respondWithRpcPromise(_0x11e242,_0x333b4e,_0x459820){return new BPromise(function(_0x1b0a1f,_0x9e3b2){return client[_0xf93e('0xf')](_0x11e242,_0x459820)[_0xf93e('0x10')](function(_0xa0804a){logger[_0xf93e('0x11')](_0xf93e('0x12'),_0x333b4e,_0xf93e('0x13'));logger['debug'](_0xf93e('0x14'),_0x333b4e,'request\x20sent',JSON['stringify'](_0xa0804a));if(_0xa0804a['error']){if(_0xa0804a[_0xf93e('0x15')][_0xf93e('0x16')]===0x1f4){logger[_0xf93e('0x15')](_0xf93e('0x12'),_0x333b4e,_0xa0804a['error'][_0xf93e('0x17')]);return _0x9e3b2(_0xa0804a[_0xf93e('0x15')][_0xf93e('0x17')]);}logger[_0xf93e('0x15')]('FaxAccount,\x20%s,\x20%s',_0x333b4e,_0xa0804a['error'][_0xf93e('0x17')]);return _0x1b0a1f(_0xa0804a[_0xf93e('0x15')][_0xf93e('0x17')]);}else{logger['info'](_0xf93e('0x12'),_0x333b4e,'request\x20sent');_0x1b0a1f(_0xa0804a[_0xf93e('0x18')][_0xf93e('0x17')]);}})[_0xf93e('0x19')](function(_0x15ed6b){logger[_0xf93e('0x15')](_0xf93e('0x12'),_0x333b4e,_0x15ed6b);_0x9e3b2(_0x15ed6b);});});}exports['GetFaxAccount']=function(_0x35a93b){var _0x1a559b=this;return new Promise(function(_0x187836,_0x2acdd3){return db[_0xf93e('0x1a')][_0xf93e('0x1b')]({'raw':_0x35a93b['options']?_0x35a93b[_0xf93e('0x1c')][_0xf93e('0x1d')]===undefined?!![]:![]:!![],'where':_0x35a93b[_0xf93e('0x1c')]?_0x35a93b['options'][_0xf93e('0x1e')]||null:null,'attributes':_0x35a93b[_0xf93e('0x1c')]?_0x35a93b['options']['attributes']||null:null,'limit':_0x35a93b[_0xf93e('0x1c')]?_0x35a93b[_0xf93e('0x1c')][_0xf93e('0x1f')]||null:null,'include':_0x35a93b[_0xf93e('0x1c')]?_0x35a93b[_0xf93e('0x1c')][_0xf93e('0x20')]?_[_0xf93e('0x21')](_0x35a93b[_0xf93e('0x1c')][_0xf93e('0x20')],function(_0x56abf4){return{'model':db[_0x56abf4[_0xf93e('0x22')]],'as':_0x56abf4['as'],'attributes':_0x56abf4[_0xf93e('0x23')],'include':_0x56abf4[_0xf93e('0x20')]?_[_0xf93e('0x21')](_0x56abf4['include'],function(_0x5b75bb){return{'model':db[_0x5b75bb['model']],'as':_0x5b75bb['as'],'attributes':_0x5b75bb['attributes'],'include':_0x5b75bb[_0xf93e('0x20')]?_[_0xf93e('0x21')](_0x5b75bb['include'],function(_0x183b37){return{'model':db[_0x183b37['model']],'as':_0x183b37['as'],'attributes':_0x183b37[_0xf93e('0x23')]};}):[]};}):[]};}):[]:[]})[_0xf93e('0x10')](function(_0x32b90f){logger[_0xf93e('0x11')](_0xf93e('0x24'),_0x35a93b);logger[_0xf93e('0x25')](_0xf93e('0x24'),_0x35a93b,JSON[_0xf93e('0x26')](_0x32b90f));_0x187836(_0x32b90f);})[_0xf93e('0x19')](function(_0x2f7856){logger[_0xf93e('0x15')](_0xf93e('0x24'),_0x2f7856[_0xf93e('0x17')],_0x35a93b);_0x2acdd3(_0x1a559b[_0xf93e('0x15')](0x1f4,_0x2f7856[_0xf93e('0x17')]));});});};exports['NotifyFaxAccount']=function(_0x5d2696,_0x2d4438,_0x136d08){var _0xe1e315=this;return new Promise(function(_0x119407,_0x5756c1){var _0x520b8f={'body':_0x5d2696[_0xf93e('0x27')],'channel':_0xf93e('0x28')};var _0x295ed0=[];var _0x3ca58b=[];var _0x4d59f8={};return db['CmContact'][_0xf93e('0x29')]()[_0xf93e('0x10')](function(_0x1e6790){if(!_0x1e6790){throw new db['Sequelize'][(_0xf93e('0x2a'))]('no\x20available\x20attributes');}_0x295ed0=_[_0xf93e('0x2b')](_[_0xf93e('0x2c')](_0x1e6790),[_0xf93e('0x2d'),_0xf93e('0x2e')]);_0x3ca58b=_[_0xf93e('0x2b')](_[_0xf93e('0x2c')](_0x1e6790),[_0xf93e('0x2d'),'updatedAt',_0xf93e('0x2f'),_0xf93e('0x30')]);if(_0x5d2696['body']['id']){delete _0x5d2696['body']['id'];}if(_['isNil'](_0x5d2696[_0xf93e('0x27')][_0xf93e('0x31')])){throw new db['Sequelize'][(_0xf93e('0x2a'))](_0xf93e('0x32'));}if(_['isNil'](_0x5d2696[_0xf93e('0x27')]['body'])||_0x5d2696[_0xf93e('0x27')][_0xf93e('0x27')]===''){throw new db[(_0xf93e('0x33'))]['ValidationError'](_0xf93e('0x34'));}if(_[_0xf93e('0x35')](_0x5d2696['body'][_0xf93e('0x36')])){throw new db[(_0xf93e('0x33'))][(_0xf93e('0x2a'))](_0xf93e('0x37')+_0x3ca58b);}if(!_[_0xf93e('0x38')](_0x3ca58b,_0x5d2696[_0xf93e('0x27')][_0xf93e('0x36')])){throw new db[(_0xf93e('0x33'))][(_0xf93e('0x2a'))]('mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20'+_0x3ca58b);}_0x4d59f8[_0x5d2696['body'][_0xf93e('0x36')]]=_0x5d2696[_0xf93e('0x27')][_0xf93e('0x31')];})['then'](function(){return db['FaxAccount']['find']({'where':{'id':_0x5d2696[_0xf93e('0x39')]['id']},'include':[{'model':db[_0xf93e('0x3a')],'as':_0xf93e('0x3b'),'include':[{'model':db[_0xf93e('0x3c')],'as':_0xf93e('0x3d'),'where':_0x4d59f8,'limit':0x1,'order':[[_0xf93e('0x2e'),_0xf93e('0x3e')]]}]},{'model':db[_0xf93e('0x3f')],'as':_0xf93e('0x40')}]});})['then'](function(_0x3f9957){if(_0x3f9957&&_0x3f9957['List']){var _0x1e9171=_0x3f9957[_0xf93e('0x41')]({'plain':!![]});_0x520b8f['account']=_0x1e9171;_0x520b8f[_0xf93e('0x42')]=_0x1e9171[_0xf93e('0x40')];_0x520b8f[_0xf93e('0x43')]=_0x1e9171[_0xf93e('0x3b')];_0x520b8f[_0xf93e('0x42')]=_['orderBy'](_0x520b8f[_0xf93e('0x42')],['priority'],[_0xf93e('0x44')]);if(_0x520b8f[_0xf93e('0x39')][_0xf93e('0x40')]){delete _0x520b8f[_0xf93e('0x39')][_0xf93e('0x40')];}if(_0x520b8f['account']['List']&&_0x520b8f['account'][_0xf93e('0x3b')][_0xf93e('0x3d')][_0xf93e('0x45')]){return _0x520b8f[_0xf93e('0x39')][_0xf93e('0x3b')][_0xf93e('0x3d')][0x0];}var _0x5a3c01=_[_0xf93e('0x46')](_0x5d2696[_0xf93e('0x27')],{'firstName':_0x5d2696['body']['from'],'ListId':_0x1e9171[_0xf93e('0x30')]});_0x5a3c01[_0x5d2696[_0xf93e('0x27')][_0xf93e('0x36')]]=_0x5d2696[_0xf93e('0x27')][_0xf93e('0x31')];return db[_0xf93e('0x3c')][_0xf93e('0x47')](_0x5a3c01,{'fields':_0x295ed0,'raw':!![]});}})[_0xf93e('0x10')](function(_0x3def7d){_0x520b8f[_0xf93e('0x48')]=_0x3def7d;if(_0x3def7d){var _0x363aa9={'ContactId':_0x3def7d['id'],'FaxAccountId':_0x5d2696[_0xf93e('0x39')]['id'],'fax':_0x3def7d[_0xf93e('0x28')]};return db['FaxInteraction']['find']({'where':{'ContactId':_0x3def7d['id'],'closed':![],'FaxAccountId':_0x5d2696[_0xf93e('0x39')]['id']}})[_0xf93e('0x10')](function(_0x2dc18b){if(_0x2dc18b){return[_0x2dc18b,![]];}return db[_0xf93e('0x49')][_0xf93e('0x47')](_0x363aa9)['then'](function(_0x2aa4ef){return[_0x2aa4ef,!![]];});});}else{throw new Error(_0xf93e('0x4a'));}})['spread'](function(_0x171952,_0x5caf5a){var _0x49b17c=_0x171952[_0xf93e('0x41')]({'plain':!![]});if(_0x5caf5a){if(_0x520b8f[_0xf93e('0x39')][_0xf93e('0x4b')]){_0x520b8f['applications'][_0xf93e('0x4c')]({'id':0x0,'priority':_0x520b8f['applications']['length']+0x1,'app':_0xf93e('0x4d'),'appdata':_0xf93e('0x4e'),'interval':_0xf93e('0x4f')});}_0x49b17c[_0xf93e('0x50')]=!![];}else{_0x49b17c[_0xf93e('0x50')]=![];}_0x520b8f['interaction']=_0x49b17c;return db[_0xf93e('0x51')][_0xf93e('0x47')]({'body':_0x5d2696[_0xf93e('0x27')][_0xf93e('0x27')],'FaxAccountId':_0x5d2696[_0xf93e('0x39')]['id'],'FaxInteractionId':_0x171952['id'],'direction':'in','ContactId':_0x171952['ContactId'],'AttachmentId':_0x5d2696[_0xf93e('0x27')][_0xf93e('0x52')]});})[_0xf93e('0x10')](function(_0x193090){_0x520b8f['message']=_0x193090;if(!_0x520b8f['interaction']['UserId'])return;return db[_0xf93e('0x53')][_0xf93e('0x54')]({'attributes':['id',_0xf93e('0x55')],'where':{'id':_0x520b8f[_0xf93e('0x56')][_0xf93e('0x57')]}});})[_0xf93e('0x10')](function(_0x4afd19){if(_0x4afd19){_0x520b8f[_0xf93e('0x42')][_0xf93e('0x58')]({'id':0x0,'priority':0x0,'app':_0xf93e('0x59'),'appdata':_0x4afd19[_0xf93e('0x55')]+','+(_0x520b8f[_0xf93e('0x39')][_0xf93e('0x5a')]||0xa),'interval':_0xf93e('0x4f')});}if(!_0x520b8f[_0xf93e('0x56')]['queueId'])return;return db[_0xf93e('0x5b')]['find']({'attributes':['id',_0xf93e('0x55')],'where':{'id':_0x520b8f['interaction'][_0xf93e('0x5c')]}});})[_0xf93e('0x10')](function(_0xdd07c9){if(_0xdd07c9){_0x520b8f[_0xf93e('0x42')][_0xf93e('0x58')]({'id':0x0,'priority':0x1,'app':_0xf93e('0x5d'),'appdata':_0xdd07c9[_0xf93e('0x55')]+','+(_0x520b8f['account'][_0xf93e('0x5e')]||0x12c),'interval':_0xf93e('0x4f')});}return respondWithRpcPromise(_0xf93e('0x5f'),_0xf93e('0x60'),_0x520b8f);})[_0xf93e('0x10')](function(_0x5bc44f){_0x119407(_0x5bc44f);})[_0xf93e('0x19')](function(_0x1ddaf6){_0x5756c1(_0xe1e315['error'](0x1f4,_0x1ddaf6[_0xf93e('0x17')]));});});};
\ No newline at end of file