Built motion from commit (unavailable).|2.5.0
[motion2.git] / server / api / faxAccount / faxAccount.rpc.js
index 89df4be..3c745e2 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x0ead=['catch','GetFaxAccount','FaxAccount','options','raw','where','attributes','limit','include','map','model','body','fax','CmContact','describe','Sequelize','keys','createdAt','updatedAt','difference','isNil','from','from\x20is\x20mandatory','body\x20is\x20mandatory\x20and\x20not\x20empty','mapKey','ValidationError','mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','includes','mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','find','List','Contacts','FaxApplication','get','account','applications','Applications','list','orderBy','priority','asc','length','defaults','ListId','create','FaxInteraction','Contact\x20not\x20found','push','close','unmanaged','*,*,*,*','created','interaction','ContactId','AttachmentId','UserId','name','unshift','waitForTheAssignedAgent','Start','startRouting','lodash','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','rpc','../../config/environment','jayson/promise','http','redis','localhost','socket.io-emitter','./faxAccount.socket','register','request','then','request\x20sent','debug','FaxAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message','FaxAccount,\x20%s,\x20%s','info','result'];(function(_0x21f9fc,_0x33b8f2){var _0x1b5af9=function(_0x506f67){while(--_0x506f67){_0x21f9fc['push'](_0x21f9fc['shift']());}};_0x1b5af9(++_0x33b8f2);}(_0x0ead,0x1a1));var _0xd0ea=function(_0x34f369,_0x5d537f){_0x34f369=_0x34f369-0x0;var _0x39a295=_0x0ead[_0x34f369];return _0x39a295;};'use strict';var _=require(_0xd0ea('0x0'));var util=require('util');var moment=require(_0xd0ea('0x1'));var BPromise=require(_0xd0ea('0x2'));var rs=require(_0xd0ea('0x3'));var fs=require('fs');var Redis=require(_0xd0ea('0x4'));var db=require(_0xd0ea('0x5'))['db'];var utils=require(_0xd0ea('0x6'));var logger=require('../../config/logger')(_0xd0ea('0x7'));var config=require(_0xd0ea('0x8'));var jayson=require(_0xd0ea('0x9'));var client=jayson['client'][_0xd0ea('0xa')]({'port':0x232c});config[_0xd0ea('0xb')]=_['defaults'](config[_0xd0ea('0xb')],{'host':_0xd0ea('0xc'),'port':0x18eb});var socket=require(_0xd0ea('0xd'))(new Redis(config[_0xd0ea('0xb')]));require(_0xd0ea('0xe'))[_0xd0ea('0xf')](socket);function respondWithRpcPromise(_0x3a239c,_0x560161,_0x42491){return new BPromise(function(_0x1568fa,_0x5c7b0b){return client[_0xd0ea('0x10')](_0x3a239c,_0x42491)[_0xd0ea('0x11')](function(_0x819e2b){logger['info']('FaxAccount,\x20%s,\x20%s',_0x560161,_0xd0ea('0x12'));logger[_0xd0ea('0x13')](_0xd0ea('0x14'),_0x560161,_0xd0ea('0x12'),JSON[_0xd0ea('0x15')](_0x819e2b));if(_0x819e2b[_0xd0ea('0x16')]){if(_0x819e2b[_0xd0ea('0x16')][_0xd0ea('0x17')]===0x1f4){logger['error']('FaxAccount,\x20%s,\x20%s',_0x560161,_0x819e2b[_0xd0ea('0x16')][_0xd0ea('0x18')]);return _0x5c7b0b(_0x819e2b[_0xd0ea('0x16')]['message']);}logger[_0xd0ea('0x16')](_0xd0ea('0x19'),_0x560161,_0x819e2b[_0xd0ea('0x16')][_0xd0ea('0x18')]);return _0x1568fa(_0x819e2b[_0xd0ea('0x16')][_0xd0ea('0x18')]);}else{logger[_0xd0ea('0x1a')](_0xd0ea('0x19'),_0x560161,_0xd0ea('0x12'));_0x1568fa(_0x819e2b[_0xd0ea('0x1b')][_0xd0ea('0x18')]);}})[_0xd0ea('0x1c')](function(_0x2fd250){logger[_0xd0ea('0x16')](_0xd0ea('0x19'),_0x560161,_0x2fd250);_0x5c7b0b(_0x2fd250);});});}exports[_0xd0ea('0x1d')]=function(_0x465777){var _0x3fca0b=this;return new Promise(function(_0x19e955,_0x1662d8){return db[_0xd0ea('0x1e')]['findAll']({'raw':_0x465777['options']?_0x465777[_0xd0ea('0x1f')][_0xd0ea('0x20')]===undefined?!![]:![]:!![],'where':_0x465777[_0xd0ea('0x1f')]?_0x465777[_0xd0ea('0x1f')][_0xd0ea('0x21')]||null:null,'attributes':_0x465777['options']?_0x465777['options'][_0xd0ea('0x22')]||null:null,'limit':_0x465777[_0xd0ea('0x1f')]?_0x465777[_0xd0ea('0x1f')][_0xd0ea('0x23')]||null:null,'include':_0x465777[_0xd0ea('0x1f')]?_0x465777[_0xd0ea('0x1f')][_0xd0ea('0x24')]?_[_0xd0ea('0x25')](_0x465777[_0xd0ea('0x1f')][_0xd0ea('0x24')],function(_0x43eec4){return{'model':db[_0x43eec4[_0xd0ea('0x26')]],'as':_0x43eec4['as'],'attributes':_0x43eec4[_0xd0ea('0x22')],'include':_0x43eec4[_0xd0ea('0x24')]?_[_0xd0ea('0x25')](_0x43eec4[_0xd0ea('0x24')],function(_0x3211dd){return{'model':db[_0x3211dd[_0xd0ea('0x26')]],'as':_0x3211dd['as'],'attributes':_0x3211dd[_0xd0ea('0x22')],'include':_0x3211dd[_0xd0ea('0x24')]?_['map'](_0x3211dd['include'],function(_0x25f032){return{'model':db[_0x25f032[_0xd0ea('0x26')]],'as':_0x25f032['as'],'attributes':_0x25f032[_0xd0ea('0x22')]};}):[]};}):[]};}):[]:[]})[_0xd0ea('0x11')](function(_0x16c6e3){logger[_0xd0ea('0x1a')](_0xd0ea('0x1d'),_0x465777);logger[_0xd0ea('0x13')](_0xd0ea('0x1d'),_0x465777,JSON[_0xd0ea('0x15')](_0x16c6e3));_0x19e955(_0x16c6e3);})['catch'](function(_0x32adf6){logger['error']('GetFaxAccount',_0x32adf6[_0xd0ea('0x18')],_0x465777);_0x1662d8(_0x3fca0b[_0xd0ea('0x16')](0x1f4,_0x32adf6[_0xd0ea('0x18')]));});});};exports['NotifyFaxAccount']=function(_0x556877,_0x4ccf32,_0x1d359a){var _0x495c90=this;return new Promise(function(_0x4e744c,_0x19d9e6){var _0x32efca={'body':_0x556877[_0xd0ea('0x27')],'channel':_0xd0ea('0x28')};var _0x45d738=[];var _0x17b34f=[];var _0x2c9410={};return db[_0xd0ea('0x29')][_0xd0ea('0x2a')]()[_0xd0ea('0x11')](function(_0x21f290){if(!_0x21f290){throw new db[(_0xd0ea('0x2b'))]['ValidationError']('no\x20available\x20attributes');}_0x45d738=_['difference'](_[_0xd0ea('0x2c')](_0x21f290),[_0xd0ea('0x2d'),_0xd0ea('0x2e')]);_0x17b34f=_[_0xd0ea('0x2f')](_['keys'](_0x21f290),[_0xd0ea('0x2d'),'updatedAt','CompanyId','ListId']);if(_0x556877['body']['id']){delete _0x556877[_0xd0ea('0x27')]['id'];}if(_[_0xd0ea('0x30')](_0x556877[_0xd0ea('0x27')][_0xd0ea('0x31')])){throw new db[(_0xd0ea('0x2b'))]['ValidationError'](_0xd0ea('0x32'));}if(_[_0xd0ea('0x30')](_0x556877[_0xd0ea('0x27')][_0xd0ea('0x27')])||_0x556877[_0xd0ea('0x27')]['body']===''){throw new db[(_0xd0ea('0x2b'))]['ValidationError'](_0xd0ea('0x33'));}if(_['isNil'](_0x556877[_0xd0ea('0x27')][_0xd0ea('0x34')])){throw new db[(_0xd0ea('0x2b'))][(_0xd0ea('0x35'))](_0xd0ea('0x36')+_0x17b34f);}if(!_[_0xd0ea('0x37')](_0x17b34f,_0x556877['body'][_0xd0ea('0x34')])){throw new db['Sequelize'][(_0xd0ea('0x35'))](_0xd0ea('0x38')+_0x17b34f);}_0x2c9410[_0x556877[_0xd0ea('0x27')]['mapKey']]=_0x556877['body'][_0xd0ea('0x31')];})[_0xd0ea('0x11')](function(){return db['FaxAccount'][_0xd0ea('0x39')]({'where':{'id':_0x556877['account']['id']},'include':[{'model':db['CmList'],'as':_0xd0ea('0x3a'),'include':[{'model':db['CmContact'],'as':_0xd0ea('0x3b'),'where':_0x2c9410,'limit':0x1,'order':[[_0xd0ea('0x2e'),'DESC']]}]},{'model':db[_0xd0ea('0x3c')],'as':'Applications'}]});})[_0xd0ea('0x11')](function(_0x50381b){if(_0x50381b&&_0x50381b['List']){var _0x401768=_0x50381b[_0xd0ea('0x3d')]({'plain':!![]});_0x32efca[_0xd0ea('0x3e')]=_0x401768;_0x32efca[_0xd0ea('0x3f')]=_0x401768[_0xd0ea('0x40')];_0x32efca[_0xd0ea('0x41')]=_0x401768[_0xd0ea('0x3a')];_0x32efca['applications']=_[_0xd0ea('0x42')](_0x32efca[_0xd0ea('0x3f')],[_0xd0ea('0x43')],[_0xd0ea('0x44')]);if(_0x32efca[_0xd0ea('0x3e')][_0xd0ea('0x40')]){delete _0x32efca[_0xd0ea('0x3e')]['Applications'];}if(_0x32efca[_0xd0ea('0x3e')][_0xd0ea('0x3a')]&&_0x32efca[_0xd0ea('0x3e')][_0xd0ea('0x3a')]['Contacts'][_0xd0ea('0x45')]){return _0x32efca[_0xd0ea('0x3e')][_0xd0ea('0x3a')][_0xd0ea('0x3b')][0x0];}var _0x4fd51a=_[_0xd0ea('0x46')](_0x556877['body'],{'firstName':_0x556877[_0xd0ea('0x27')]['from'],'ListId':_0x401768[_0xd0ea('0x47')]});_0x4fd51a[_0x556877[_0xd0ea('0x27')]['mapKey']]=_0x556877[_0xd0ea('0x27')]['from'];return db['CmContact'][_0xd0ea('0x48')](_0x4fd51a,{'fields':_0x45d738,'raw':!![]});}})[_0xd0ea('0x11')](function(_0x328af9){_0x32efca['contact']=_0x328af9;if(_0x328af9){var _0x7976cd={'ContactId':_0x328af9['id'],'FaxAccountId':_0x556877[_0xd0ea('0x3e')]['id'],'fax':_0x328af9[_0xd0ea('0x28')]};return db[_0xd0ea('0x49')][_0xd0ea('0x39')]({'where':{'ContactId':_0x328af9['id'],'closed':![],'FaxAccountId':_0x556877['account']['id']}})[_0xd0ea('0x11')](function(_0x20ab48){if(_0x20ab48){return[_0x20ab48,![]];}return db[_0xd0ea('0x49')][_0xd0ea('0x48')](_0x7976cd)[_0xd0ea('0x11')](function(_0x4536e2){return[_0x4536e2,!![]];});});}else{throw new Error(_0xd0ea('0x4a'));}})['spread'](function(_0xe5530b,_0x124907){var _0x4875f3=_0xe5530b['get']({'plain':!![]});if(_0x124907){if(_0x32efca[_0xd0ea('0x3e')]['autoclose']){_0x32efca[_0xd0ea('0x3f')][_0xd0ea('0x4b')]({'id':0x0,'priority':_0x32efca[_0xd0ea('0x3f')]['length']+0x1,'app':_0xd0ea('0x4c'),'appdata':_0xd0ea('0x4d'),'interval':_0xd0ea('0x4e')});}_0x4875f3[_0xd0ea('0x4f')]=!![];}else{_0x4875f3[_0xd0ea('0x4f')]=![];}_0x32efca[_0xd0ea('0x50')]=_0x4875f3;return db['FaxMessage'][_0xd0ea('0x48')]({'body':_0x556877[_0xd0ea('0x27')]['body'],'FaxAccountId':_0x556877['account']['id'],'FaxInteractionId':_0xe5530b['id'],'direction':'in','ContactId':_0xe5530b[_0xd0ea('0x51')],'AttachmentId':_0x556877[_0xd0ea('0x27')][_0xd0ea('0x52')]});})[_0xd0ea('0x11')](function(_0x1b4799){_0x32efca[_0xd0ea('0x18')]=_0x1b4799;if(_0x32efca[_0xd0ea('0x50')][_0xd0ea('0x53')]){return db['User']['find']({'attributes':['id',_0xd0ea('0x54')],'where':{'id':_0x32efca[_0xd0ea('0x50')][_0xd0ea('0x53')]}})[_0xd0ea('0x11')](function(_0x2495c9){if(_0x2495c9){_0x32efca[_0xd0ea('0x3f')][_0xd0ea('0x55')]({'id':0x0,'priority':0x0,'app':'agent','appdata':_0x2495c9[_0xd0ea('0x54')]+','+(_0x32efca[_0xd0ea('0x3e')][_0xd0ea('0x56')]||0xa),'interval':'*,*,*,*'});}return respondWithRpcPromise(_0xd0ea('0x57'),_0xd0ea('0x58'),_0x32efca);});}return respondWithRpcPromise(_0xd0ea('0x57'),_0xd0ea('0x58'),_0x32efca);})['then'](function(_0x237ddc){_0x4e744c(_0x237ddc);})[_0xd0ea('0x1c')](function(_0x1459e5){_0x19d9e6(_0x495c90['error'](0x1f4,_0x1459e5['message']));});});};
\ No newline at end of file
+var _0xa991=['keys','createdAt','updatedAt','CompanyId','isNil','from','Sequelize','from\x20is\x20mandatory','body\x20is\x20mandatory\x20and\x20not\x20empty','mapKey','mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','includes','mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','account','CmList','List','Contacts','DESC','FaxApplication','Applications','get','applications','list','priority','defaults','ListId','create','contact','fax','FaxInteraction','find','Contact\x20not\x20found','autoclose','push','length','close','unmanaged','*,*,*,*','created','interaction','FaxMessage','ContactId','AttachmentId','User','name','UserId','agent','waitForTheAssignedAgent','Start','startRouting','lodash','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis','socket.io-emitter','./faxAccount.socket','register','request','info','request\x20sent','stringify','error','FaxAccount,\x20%s,\x20%s','message','GetFaxAccount','FaxAccount','findAll','options','raw','where','map','include','attributes','model','debug','catch','NotifyFaxAccount','body','CmContact','then','ValidationError','difference'];(function(_0xc6f2df,_0x222595){var _0x1c853b=function(_0x588dc7){while(--_0x588dc7){_0xc6f2df['push'](_0xc6f2df['shift']());}};_0x1c853b(++_0x222595);}(_0xa991,0x143));var _0x1a99=function(_0x42cae2,_0x284ef8){_0x42cae2=_0x42cae2-0x0;var _0x5f256f=_0xa991[_0x42cae2];return _0x5f256f;};'use strict';var _=require(_0x1a99('0x0'));var util=require('util');var moment=require(_0x1a99('0x1'));var BPromise=require(_0x1a99('0x2'));var rs=require(_0x1a99('0x3'));var fs=require('fs');var Redis=require(_0x1a99('0x4'));var db=require(_0x1a99('0x5'))['db'];var utils=require('../../config/utils');var logger=require(_0x1a99('0x6'))(_0x1a99('0x7'));var config=require(_0x1a99('0x8'));var jayson=require(_0x1a99('0x9'));var client=jayson[_0x1a99('0xa')][_0x1a99('0xb')]({'port':0x232c});config[_0x1a99('0xc')]=_['defaults'](config[_0x1a99('0xc')],{'host':'localhost','port':0x18eb});var socket=require(_0x1a99('0xd'))(new Redis(config[_0x1a99('0xc')]));require(_0x1a99('0xe'))[_0x1a99('0xf')](socket);function respondWithRpcPromise(_0x12b8f7,_0x1ba9b2,_0x48f59b){return new BPromise(function(_0x22016d,_0x2e7899){return client[_0x1a99('0x10')](_0x12b8f7,_0x48f59b)['then'](function(_0x33260c){logger[_0x1a99('0x11')]('FaxAccount,\x20%s,\x20%s',_0x1ba9b2,_0x1a99('0x12'));logger['debug']('FaxAccount,\x20%s,\x20%s,\x20%s',_0x1ba9b2,_0x1a99('0x12'),JSON[_0x1a99('0x13')](_0x33260c));if(_0x33260c[_0x1a99('0x14')]){if(_0x33260c[_0x1a99('0x14')]['code']===0x1f4){logger[_0x1a99('0x14')](_0x1a99('0x15'),_0x1ba9b2,_0x33260c[_0x1a99('0x14')][_0x1a99('0x16')]);return _0x2e7899(_0x33260c[_0x1a99('0x14')]['message']);}logger[_0x1a99('0x14')]('FaxAccount,\x20%s,\x20%s',_0x1ba9b2,_0x33260c[_0x1a99('0x14')][_0x1a99('0x16')]);return _0x22016d(_0x33260c[_0x1a99('0x14')][_0x1a99('0x16')]);}else{logger[_0x1a99('0x11')](_0x1a99('0x15'),_0x1ba9b2,'request\x20sent');_0x22016d(_0x33260c['result'][_0x1a99('0x16')]);}})['catch'](function(_0x780b3e){logger[_0x1a99('0x14')](_0x1a99('0x15'),_0x1ba9b2,_0x780b3e);_0x2e7899(_0x780b3e);});});}exports[_0x1a99('0x17')]=function(_0x468e8d){var _0x1d55ed=this;return new Promise(function(_0x42422f,_0x4f6087){return db[_0x1a99('0x18')][_0x1a99('0x19')]({'raw':_0x468e8d[_0x1a99('0x1a')]?_0x468e8d[_0x1a99('0x1a')][_0x1a99('0x1b')]===undefined?!![]:![]:!![],'where':_0x468e8d['options']?_0x468e8d[_0x1a99('0x1a')][_0x1a99('0x1c')]||null:null,'attributes':_0x468e8d[_0x1a99('0x1a')]?_0x468e8d[_0x1a99('0x1a')]['attributes']||null:null,'limit':_0x468e8d[_0x1a99('0x1a')]?_0x468e8d[_0x1a99('0x1a')]['limit']||null:null,'include':_0x468e8d[_0x1a99('0x1a')]?_0x468e8d[_0x1a99('0x1a')]['include']?_[_0x1a99('0x1d')](_0x468e8d[_0x1a99('0x1a')][_0x1a99('0x1e')],function(_0x54faf6){return{'model':db[_0x54faf6['model']],'as':_0x54faf6['as'],'attributes':_0x54faf6[_0x1a99('0x1f')],'include':_0x54faf6['include']?_[_0x1a99('0x1d')](_0x54faf6[_0x1a99('0x1e')],function(_0x227b05){return{'model':db[_0x227b05[_0x1a99('0x20')]],'as':_0x227b05['as'],'attributes':_0x227b05[_0x1a99('0x1f')],'include':_0x227b05[_0x1a99('0x1e')]?_[_0x1a99('0x1d')](_0x227b05[_0x1a99('0x1e')],function(_0x66b7a4){return{'model':db[_0x66b7a4[_0x1a99('0x20')]],'as':_0x66b7a4['as'],'attributes':_0x66b7a4['attributes']};}):[]};}):[]};}):[]:[]})['then'](function(_0x388e5e){logger[_0x1a99('0x11')]('GetFaxAccount',_0x468e8d);logger[_0x1a99('0x21')](_0x1a99('0x17'),_0x468e8d,JSON[_0x1a99('0x13')](_0x388e5e));_0x42422f(_0x388e5e);})[_0x1a99('0x22')](function(_0x25fc25){logger[_0x1a99('0x14')]('GetFaxAccount',_0x25fc25['message'],_0x468e8d);_0x4f6087(_0x1d55ed[_0x1a99('0x14')](0x1f4,_0x25fc25[_0x1a99('0x16')]));});});};exports[_0x1a99('0x23')]=function(_0x2df23c,_0x5490c4,_0x338436){var _0x46c18c=this;return new Promise(function(_0x23d616,_0x31f949){var _0x156f09={'body':_0x2df23c[_0x1a99('0x24')],'channel':'fax'};var _0x474c45=[];var _0x5162e8=[];var _0x3e0bff={};return db[_0x1a99('0x25')]['describe']()[_0x1a99('0x26')](function(_0x48cc4a){if(!_0x48cc4a){throw new db['Sequelize'][(_0x1a99('0x27'))]('no\x20available\x20attributes');}_0x474c45=_[_0x1a99('0x28')](_[_0x1a99('0x29')](_0x48cc4a),[_0x1a99('0x2a'),_0x1a99('0x2b')]);_0x5162e8=_[_0x1a99('0x28')](_[_0x1a99('0x29')](_0x48cc4a),[_0x1a99('0x2a'),_0x1a99('0x2b'),_0x1a99('0x2c'),'ListId']);if(_0x2df23c[_0x1a99('0x24')]['id']){delete _0x2df23c[_0x1a99('0x24')]['id'];}if(_[_0x1a99('0x2d')](_0x2df23c[_0x1a99('0x24')][_0x1a99('0x2e')])){throw new db[(_0x1a99('0x2f'))][(_0x1a99('0x27'))](_0x1a99('0x30'));}if(_['isNil'](_0x2df23c[_0x1a99('0x24')][_0x1a99('0x24')])||_0x2df23c[_0x1a99('0x24')]['body']===''){throw new db[(_0x1a99('0x2f'))][(_0x1a99('0x27'))](_0x1a99('0x31'));}if(_[_0x1a99('0x2d')](_0x2df23c['body'][_0x1a99('0x32')])){throw new db[(_0x1a99('0x2f'))][(_0x1a99('0x27'))](_0x1a99('0x33')+_0x5162e8);}if(!_[_0x1a99('0x34')](_0x5162e8,_0x2df23c['body'][_0x1a99('0x32')])){throw new db[(_0x1a99('0x2f'))][(_0x1a99('0x27'))](_0x1a99('0x35')+_0x5162e8);}_0x3e0bff[_0x2df23c[_0x1a99('0x24')]['mapKey']]=_0x2df23c[_0x1a99('0x24')][_0x1a99('0x2e')];})['then'](function(){return db['FaxAccount']['find']({'where':{'id':_0x2df23c[_0x1a99('0x36')]['id']},'include':[{'model':db[_0x1a99('0x37')],'as':_0x1a99('0x38'),'include':[{'model':db['CmContact'],'as':_0x1a99('0x39'),'where':_0x3e0bff,'limit':0x1,'order':[['updatedAt',_0x1a99('0x3a')]]}]},{'model':db[_0x1a99('0x3b')],'as':_0x1a99('0x3c')}]});})[_0x1a99('0x26')](function(_0x6dd134){if(_0x6dd134&&_0x6dd134[_0x1a99('0x38')]){var _0x269d78=_0x6dd134[_0x1a99('0x3d')]({'plain':!![]});_0x156f09[_0x1a99('0x36')]=_0x269d78;_0x156f09[_0x1a99('0x3e')]=_0x269d78[_0x1a99('0x3c')];_0x156f09[_0x1a99('0x3f')]=_0x269d78[_0x1a99('0x38')];_0x156f09[_0x1a99('0x3e')]=_['orderBy'](_0x156f09['applications'],[_0x1a99('0x40')],['asc']);if(_0x156f09[_0x1a99('0x36')][_0x1a99('0x3c')]){delete _0x156f09['account']['Applications'];}if(_0x156f09[_0x1a99('0x36')][_0x1a99('0x38')]&&_0x156f09[_0x1a99('0x36')][_0x1a99('0x38')][_0x1a99('0x39')]['length']){return _0x156f09['account'][_0x1a99('0x38')][_0x1a99('0x39')][0x0];}var _0x1d9ca5=_[_0x1a99('0x41')](_0x2df23c[_0x1a99('0x24')],{'firstName':_0x2df23c['body'][_0x1a99('0x2e')],'ListId':_0x269d78[_0x1a99('0x42')]});_0x1d9ca5[_0x2df23c[_0x1a99('0x24')][_0x1a99('0x32')]]=_0x2df23c['body'][_0x1a99('0x2e')];return db[_0x1a99('0x25')][_0x1a99('0x43')](_0x1d9ca5,{'fields':_0x474c45,'raw':!![]});}})['then'](function(_0x50a753){_0x156f09[_0x1a99('0x44')]=_0x50a753;if(_0x50a753){var _0x349c30={'ContactId':_0x50a753['id'],'FaxAccountId':_0x2df23c[_0x1a99('0x36')]['id'],'fax':_0x50a753[_0x1a99('0x45')]};return db[_0x1a99('0x46')][_0x1a99('0x47')]({'where':{'ContactId':_0x50a753['id'],'closed':![],'FaxAccountId':_0x2df23c['account']['id']}})[_0x1a99('0x26')](function(_0x549b40){if(_0x549b40){return[_0x549b40,![]];}return db['FaxInteraction'][_0x1a99('0x43')](_0x349c30)['then'](function(_0x2f5260){return[_0x2f5260,!![]];});});}else{throw new Error(_0x1a99('0x48'));}})['spread'](function(_0x3ae641,_0x2e478f){var _0x527aeb=_0x3ae641['get']({'plain':!![]});if(_0x2e478f){if(_0x156f09['account'][_0x1a99('0x49')]){_0x156f09[_0x1a99('0x3e')][_0x1a99('0x4a')]({'id':0x0,'priority':_0x156f09['applications'][_0x1a99('0x4b')]+0x1,'app':_0x1a99('0x4c'),'appdata':_0x1a99('0x4d'),'interval':_0x1a99('0x4e')});}_0x527aeb['created']=!![];}else{_0x527aeb[_0x1a99('0x4f')]=![];}_0x156f09[_0x1a99('0x50')]=_0x527aeb;return db[_0x1a99('0x51')][_0x1a99('0x43')]({'body':_0x2df23c[_0x1a99('0x24')]['body'],'FaxAccountId':_0x2df23c[_0x1a99('0x36')]['id'],'FaxInteractionId':_0x3ae641['id'],'direction':'in','ContactId':_0x3ae641[_0x1a99('0x52')],'AttachmentId':_0x2df23c['body'][_0x1a99('0x53')]});})[_0x1a99('0x26')](function(_0x6be549){_0x156f09[_0x1a99('0x16')]=_0x6be549;if(_0x156f09[_0x1a99('0x50')]['UserId']){return db[_0x1a99('0x54')]['find']({'attributes':['id',_0x1a99('0x55')],'where':{'id':_0x156f09['interaction'][_0x1a99('0x56')]}})[_0x1a99('0x26')](function(_0x4544c7){if(_0x4544c7){_0x156f09[_0x1a99('0x3e')]['unshift']({'id':0x0,'priority':0x0,'app':_0x1a99('0x57'),'appdata':_0x4544c7[_0x1a99('0x55')]+','+(_0x156f09['account'][_0x1a99('0x58')]||0xa),'interval':_0x1a99('0x4e')});}return respondWithRpcPromise(_0x1a99('0x59'),_0x1a99('0x5a'),_0x156f09);});}return respondWithRpcPromise(_0x1a99('0x59'),_0x1a99('0x5a'),_0x156f09);})[_0x1a99('0x26')](function(_0x522088){_0x23d616(_0x522088);})['catch'](function(_0x132e33){_0x31f949(_0x46c18c[_0x1a99('0x14')](0x1f4,_0x132e33[_0x1a99('0x16')]));});});};
\ No newline at end of file