Built motion from commit 4d4d9a88.|2.6.26
[motion2.git] / server / api / faxAccount / faxAccount.rpc.js
index 51020eb..3519f13 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xf26d=['push','close','unmanaged','*,*,*,*','created','interaction','FaxMessage','ContactId','AttachmentId','UserId','User','unshift','agent','name','waitForTheAssignedAgent','queueId','FaxQueue','waitForTheAssignedQueue','Start','startRouting','lodash','bluebird','randomstring','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','jayson/promise','client','defaults','redis','localhost','socket.io-emitter','./faxAccount.socket','register','request','then','info','FaxAccount,\x20%s,\x20%s','request\x20sent','debug','FaxAccount,\x20%s,\x20%s,\x20%s','error','code','message','result','catch','GetFaxAccount','FaxAccount','findAll','options','raw','where','attributes','limit','include','map','model','stringify','NotifyFaxAccount','body','fax','Sequelize','ValidationError','difference','keys','createdAt','CompanyId','ListId','from','from\x20is\x20mandatory','isNil','body\x20is\x20mandatory\x20and\x20not\x20empty','mapKey','find','CmList','List','CmContact','Contacts','DESC','FaxApplication','get','applications','Applications','list','orderBy','asc','account','length','create','contact','FaxInteraction','Contact\x20not\x20found','spread','autoclose'];(function(_0x3029f6,_0x2cedd6){var _0xbf8840=function(_0x37466a){while(--_0x37466a){_0x3029f6['push'](_0x3029f6['shift']());}};_0xbf8840(++_0x2cedd6);}(_0xf26d,0x131));var _0xdf26=function(_0x797e40,_0x49a4d5){_0x797e40=_0x797e40-0x0;var _0x3c5bfc=_0xf26d[_0x797e40];return _0x3c5bfc;};'use strict';var _=require(_0xdf26('0x0'));var util=require('util');var moment=require('moment');var BPromise=require(_0xdf26('0x1'));var rs=require(_0xdf26('0x2'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0xdf26('0x3'))['db'];var utils=require(_0xdf26('0x4'));var logger=require(_0xdf26('0x5'))('rpc');var config=require(_0xdf26('0x6'));var jayson=require(_0xdf26('0x7'));var client=jayson[_0xdf26('0x8')]['http']({'port':0x232c});config['redis']=_[_0xdf26('0x9')](config[_0xdf26('0xa')],{'host':_0xdf26('0xb'),'port':0x18eb});var socket=require(_0xdf26('0xc'))(new Redis(config[_0xdf26('0xa')]));require(_0xdf26('0xd'))[_0xdf26('0xe')](socket);function respondWithRpcPromise(_0x19e0e4,_0xd2e63f,_0x1cb572){return new BPromise(function(_0x2301d0,_0x7473fa){return client[_0xdf26('0xf')](_0x19e0e4,_0x1cb572)[_0xdf26('0x10')](function(_0x257e6f){logger[_0xdf26('0x11')](_0xdf26('0x12'),_0xd2e63f,_0xdf26('0x13'));logger[_0xdf26('0x14')](_0xdf26('0x15'),_0xd2e63f,_0xdf26('0x13'),JSON['stringify'](_0x257e6f));if(_0x257e6f[_0xdf26('0x16')]){if(_0x257e6f[_0xdf26('0x16')][_0xdf26('0x17')]===0x1f4){logger[_0xdf26('0x16')]('FaxAccount,\x20%s,\x20%s',_0xd2e63f,_0x257e6f[_0xdf26('0x16')][_0xdf26('0x18')]);return _0x7473fa(_0x257e6f[_0xdf26('0x16')][_0xdf26('0x18')]);}logger['error'](_0xdf26('0x12'),_0xd2e63f,_0x257e6f[_0xdf26('0x16')][_0xdf26('0x18')]);return _0x2301d0(_0x257e6f[_0xdf26('0x16')][_0xdf26('0x18')]);}else{logger[_0xdf26('0x11')](_0xdf26('0x12'),_0xd2e63f,_0xdf26('0x13'));_0x2301d0(_0x257e6f[_0xdf26('0x19')]['message']);}})[_0xdf26('0x1a')](function(_0x3dafa2){logger['error'](_0xdf26('0x12'),_0xd2e63f,_0x3dafa2);_0x7473fa(_0x3dafa2);});});}exports[_0xdf26('0x1b')]=function(_0x1b5fd8){var _0x3075fc=this;return new Promise(function(_0x2b4f2a,_0x27abe3){return db[_0xdf26('0x1c')][_0xdf26('0x1d')]({'raw':_0x1b5fd8['options']?_0x1b5fd8[_0xdf26('0x1e')][_0xdf26('0x1f')]===undefined?!![]:![]:!![],'where':_0x1b5fd8['options']?_0x1b5fd8[_0xdf26('0x1e')][_0xdf26('0x20')]||null:null,'attributes':_0x1b5fd8[_0xdf26('0x1e')]?_0x1b5fd8[_0xdf26('0x1e')][_0xdf26('0x21')]||null:null,'limit':_0x1b5fd8[_0xdf26('0x1e')]?_0x1b5fd8[_0xdf26('0x1e')][_0xdf26('0x22')]||null:null,'include':_0x1b5fd8[_0xdf26('0x1e')]?_0x1b5fd8[_0xdf26('0x1e')][_0xdf26('0x23')]?_[_0xdf26('0x24')](_0x1b5fd8[_0xdf26('0x1e')]['include'],function(_0x1efb8b){return{'model':db[_0x1efb8b['model']],'as':_0x1efb8b['as'],'attributes':_0x1efb8b[_0xdf26('0x21')],'include':_0x1efb8b[_0xdf26('0x23')]?_['map'](_0x1efb8b[_0xdf26('0x23')],function(_0x3a2107){return{'model':db[_0x3a2107[_0xdf26('0x25')]],'as':_0x3a2107['as'],'attributes':_0x3a2107[_0xdf26('0x21')],'include':_0x3a2107[_0xdf26('0x23')]?_[_0xdf26('0x24')](_0x3a2107[_0xdf26('0x23')],function(_0x465848){return{'model':db[_0x465848[_0xdf26('0x25')]],'as':_0x465848['as'],'attributes':_0x465848['attributes']};}):[]};}):[]};}):[]:[]})[_0xdf26('0x10')](function(_0xeee33){logger['info']('GetFaxAccount',_0x1b5fd8);logger[_0xdf26('0x14')](_0xdf26('0x1b'),_0x1b5fd8,JSON[_0xdf26('0x26')](_0xeee33));_0x2b4f2a(_0xeee33);})[_0xdf26('0x1a')](function(_0x33a49e){logger[_0xdf26('0x16')]('GetFaxAccount',_0x33a49e['message'],_0x1b5fd8);_0x27abe3(_0x3075fc[_0xdf26('0x16')](0x1f4,_0x33a49e[_0xdf26('0x18')]));});});};exports[_0xdf26('0x27')]=function(_0x1024e3,_0x3debf1,_0x457b3c){var _0x4be833=this;return new Promise(function(_0x49dccc,_0x274640){var _0x241897={'body':_0x1024e3[_0xdf26('0x28')],'channel':_0xdf26('0x29')};var _0x5819a2=[];var _0x2cbadb=[];var _0x17405b={};return db['CmContact']['describe']()[_0xdf26('0x10')](function(_0x371a6a){if(!_0x371a6a){throw new db[(_0xdf26('0x2a'))][(_0xdf26('0x2b'))]('no\x20available\x20attributes');}_0x5819a2=_[_0xdf26('0x2c')](_[_0xdf26('0x2d')](_0x371a6a),[_0xdf26('0x2e'),'updatedAt']);_0x2cbadb=_[_0xdf26('0x2c')](_[_0xdf26('0x2d')](_0x371a6a),[_0xdf26('0x2e'),'updatedAt',_0xdf26('0x2f'),_0xdf26('0x30')]);if(_0x1024e3[_0xdf26('0x28')]['id']){delete _0x1024e3[_0xdf26('0x28')]['id'];}if(_['isNil'](_0x1024e3[_0xdf26('0x28')][_0xdf26('0x31')])){throw new db[(_0xdf26('0x2a'))][(_0xdf26('0x2b'))](_0xdf26('0x32'));}if(_[_0xdf26('0x33')](_0x1024e3['body'][_0xdf26('0x28')])||_0x1024e3[_0xdf26('0x28')][_0xdf26('0x28')]===''){throw new db[(_0xdf26('0x2a'))]['ValidationError'](_0xdf26('0x34'));}if(_['isNil'](_0x1024e3[_0xdf26('0x28')][_0xdf26('0x35')])){throw new db[(_0xdf26('0x2a'))][(_0xdf26('0x2b'))]('mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20'+_0x2cbadb);}if(!_['includes'](_0x2cbadb,_0x1024e3[_0xdf26('0x28')][_0xdf26('0x35')])){throw new db[(_0xdf26('0x2a'))][(_0xdf26('0x2b'))]('mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20'+_0x2cbadb);}_0x17405b[_0x1024e3[_0xdf26('0x28')][_0xdf26('0x35')]]=_0x1024e3[_0xdf26('0x28')][_0xdf26('0x31')];})[_0xdf26('0x10')](function(){return db[_0xdf26('0x1c')][_0xdf26('0x36')]({'where':{'id':_0x1024e3['account']['id']},'include':[{'model':db[_0xdf26('0x37')],'as':_0xdf26('0x38'),'include':[{'model':db[_0xdf26('0x39')],'as':_0xdf26('0x3a'),'where':_0x17405b,'limit':0x1,'order':[['updatedAt',_0xdf26('0x3b')]]}]},{'model':db[_0xdf26('0x3c')],'as':'Applications'}]});})[_0xdf26('0x10')](function(_0x46d58b){if(_0x46d58b&&_0x46d58b[_0xdf26('0x38')]){var _0x43c5ce=_0x46d58b[_0xdf26('0x3d')]({'plain':!![]});_0x241897['account']=_0x43c5ce;_0x241897[_0xdf26('0x3e')]=_0x43c5ce[_0xdf26('0x3f')];_0x241897[_0xdf26('0x40')]=_0x43c5ce[_0xdf26('0x38')];_0x241897[_0xdf26('0x3e')]=_[_0xdf26('0x41')](_0x241897[_0xdf26('0x3e')],['priority'],[_0xdf26('0x42')]);if(_0x241897['account'][_0xdf26('0x3f')]){delete _0x241897[_0xdf26('0x43')][_0xdf26('0x3f')];}if(_0x241897[_0xdf26('0x43')]['List']&&_0x241897['account'][_0xdf26('0x38')]['Contacts'][_0xdf26('0x44')]){return _0x241897[_0xdf26('0x43')]['List'][_0xdf26('0x3a')][0x0];}var _0xdfed45=_[_0xdf26('0x9')](_0x1024e3[_0xdf26('0x28')],{'firstName':_0x1024e3[_0xdf26('0x28')]['from'],'ListId':_0x43c5ce[_0xdf26('0x30')]});_0xdfed45[_0x1024e3[_0xdf26('0x28')][_0xdf26('0x35')]]=_0x1024e3['body']['from'];return db['CmContact'][_0xdf26('0x45')](_0xdfed45,{'fields':_0x5819a2,'raw':!![]});}})[_0xdf26('0x10')](function(_0x41243d){_0x241897[_0xdf26('0x46')]=_0x41243d;if(_0x41243d){var _0x4790b5={'ContactId':_0x41243d['id'],'FaxAccountId':_0x1024e3[_0xdf26('0x43')]['id'],'fax':_0x41243d[_0xdf26('0x29')]};return db[_0xdf26('0x47')][_0xdf26('0x36')]({'where':{'ContactId':_0x41243d['id'],'closed':![],'FaxAccountId':_0x1024e3[_0xdf26('0x43')]['id']}})[_0xdf26('0x10')](function(_0x402045){if(_0x402045){return[_0x402045,![]];}return db['FaxInteraction'][_0xdf26('0x45')](_0x4790b5)[_0xdf26('0x10')](function(_0x363b8b){return[_0x363b8b,!![]];});});}else{throw new Error(_0xdf26('0x48'));}})[_0xdf26('0x49')](function(_0x426beb,_0x13cf6e){var _0x42d1d0=_0x426beb[_0xdf26('0x3d')]({'plain':!![]});if(_0x13cf6e){if(_0x241897['account'][_0xdf26('0x4a')]){_0x241897[_0xdf26('0x3e')][_0xdf26('0x4b')]({'id':0x0,'priority':_0x241897[_0xdf26('0x3e')][_0xdf26('0x44')]+0x1,'app':_0xdf26('0x4c'),'appdata':_0xdf26('0x4d'),'interval':_0xdf26('0x4e')});}_0x42d1d0[_0xdf26('0x4f')]=!![];}else{_0x42d1d0['created']=![];}_0x241897[_0xdf26('0x50')]=_0x42d1d0;return db[_0xdf26('0x51')][_0xdf26('0x45')]({'body':_0x1024e3[_0xdf26('0x28')][_0xdf26('0x28')],'FaxAccountId':_0x1024e3[_0xdf26('0x43')]['id'],'FaxInteractionId':_0x426beb['id'],'direction':'in','ContactId':_0x426beb[_0xdf26('0x52')],'AttachmentId':_0x1024e3['body'][_0xdf26('0x53')]});})[_0xdf26('0x10')](function(_0x143ba0){_0x241897[_0xdf26('0x18')]=_0x143ba0;if(!_0x241897[_0xdf26('0x50')][_0xdf26('0x54')])return;return db[_0xdf26('0x55')][_0xdf26('0x36')]({'attributes':['id','name'],'where':{'id':_0x241897[_0xdf26('0x50')][_0xdf26('0x54')]}});})[_0xdf26('0x10')](function(_0x72b94e){if(_0x72b94e){_0x241897[_0xdf26('0x3e')][_0xdf26('0x56')]({'id':0x0,'priority':0x0,'app':_0xdf26('0x57'),'appdata':_0x72b94e[_0xdf26('0x58')]+','+(_0x241897[_0xdf26('0x43')][_0xdf26('0x59')]||0xa),'interval':_0xdf26('0x4e')});}if(!_0x241897[_0xdf26('0x50')][_0xdf26('0x5a')])return;return db[_0xdf26('0x5b')][_0xdf26('0x36')]({'attributes':['id',_0xdf26('0x58')],'where':{'id':_0x241897['interaction'][_0xdf26('0x5a')]}});})[_0xdf26('0x10')](function(_0x20275f){if(_0x20275f){_0x241897[_0xdf26('0x3e')][_0xdf26('0x56')]({'id':0x0,'priority':0x1,'app':'queue','appdata':_0x20275f[_0xdf26('0x58')]+','+(_0x241897[_0xdf26('0x43')][_0xdf26('0x5c')]||0x12c),'interval':_0xdf26('0x4e')});}return respondWithRpcPromise(_0xdf26('0x5d'),_0xdf26('0x5e'),_0x241897);})[_0xdf26('0x10')](function(_0x330ebf){_0x49dccc(_0x330ebf);})[_0xdf26('0x1a')](function(_0x401635){_0x274640(_0x4be833[_0xdf26('0x16')](0x1f4,_0x401635['message']));});});};
\ No newline at end of file
+var _0x95a6=['find','CmList','List','Contacts','DESC','FaxApplication','get','account','applications','Applications','list','orderBy','priority','asc','length','defaults','ListId','create','contact','FaxInteraction','Contact\x20not\x20found','autoclose','push','close','unmanaged','*,*,*,*','created','interaction','FaxMessage','ContactId','AttachmentId','UserId','User','name','unshift','agent','queueId','FaxQueue','queue','startRouting','lodash','util','bluebird','randomstring','ioredis','../../config/logger','rpc','jayson/promise','http','socket.io-emitter','redis','./faxAccount.socket','register','request','then','info','FaxAccount,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code','message','result','catch','GetFaxAccount','FaxAccount','findAll','options','raw','limit','map','include','model','attributes','CmContact','Sequelize','ValidationError','no\x20available\x20attributes','difference','keys','createdAt','updatedAt','CompanyId','body','isNil','from','from\x20is\x20mandatory','body\x20is\x20mandatory\x20and\x20not\x20empty','mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','includes','mapKey'];(function(_0x27b2b1,_0x23466d){var _0x44640e=function(_0x4e9adc){while(--_0x4e9adc){_0x27b2b1['push'](_0x27b2b1['shift']());}};_0x44640e(++_0x23466d);}(_0x95a6,0x13c));var _0x695a=function(_0x5d0a9a,_0x23792e){_0x5d0a9a=_0x5d0a9a-0x0;var _0x340ada=_0x95a6[_0x5d0a9a];return _0x340ada;};'use strict';var _=require(_0x695a('0x0'));var util=require(_0x695a('0x1'));var moment=require('moment');var BPromise=require(_0x695a('0x2'));var rs=require(_0x695a('0x3'));var fs=require('fs');var Redis=require(_0x695a('0x4'));var db=require('../../mysqldb')['db'];var utils=require('../../config/utils');var logger=require(_0x695a('0x5'))(_0x695a('0x6'));var config=require('../../config/environment');var jayson=require(_0x695a('0x7'));var client=jayson['client'][_0x695a('0x8')]({'port':0x232c});config['redis']=_['defaults'](config['redis'],{'host':'localhost','port':0x18eb});var socket=require(_0x695a('0x9'))(new Redis(config[_0x695a('0xa')]));require(_0x695a('0xb'))[_0x695a('0xc')](socket);function respondWithRpcPromise(_0xbb81a5,_0x2e47a5,_0x5e09d1){return new BPromise(function(_0x4fca11,_0x15c113){return client[_0x695a('0xd')](_0xbb81a5,_0x5e09d1)[_0x695a('0xe')](function(_0x2b9f3f){logger[_0x695a('0xf')](_0x695a('0x10'),_0x2e47a5,_0x695a('0x11'));logger[_0x695a('0x12')]('FaxAccount,\x20%s,\x20%s,\x20%s',_0x2e47a5,'request\x20sent',JSON[_0x695a('0x13')](_0x2b9f3f));if(_0x2b9f3f[_0x695a('0x14')]){if(_0x2b9f3f[_0x695a('0x14')][_0x695a('0x15')]===0x1f4){logger[_0x695a('0x14')](_0x695a('0x10'),_0x2e47a5,_0x2b9f3f[_0x695a('0x14')][_0x695a('0x16')]);return _0x15c113(_0x2b9f3f[_0x695a('0x14')]['message']);}logger['error'](_0x695a('0x10'),_0x2e47a5,_0x2b9f3f[_0x695a('0x14')][_0x695a('0x16')]);return _0x4fca11(_0x2b9f3f[_0x695a('0x14')]['message']);}else{logger[_0x695a('0xf')]('FaxAccount,\x20%s,\x20%s',_0x2e47a5,_0x695a('0x11'));_0x4fca11(_0x2b9f3f[_0x695a('0x17')]['message']);}})[_0x695a('0x18')](function(_0x2af595){logger[_0x695a('0x14')]('FaxAccount,\x20%s,\x20%s',_0x2e47a5,_0x2af595);_0x15c113(_0x2af595);});});}exports[_0x695a('0x19')]=function(_0x346828){var _0xd26442=this;return new Promise(function(_0x1b6435,_0x1d0efc){return db[_0x695a('0x1a')][_0x695a('0x1b')]({'raw':_0x346828[_0x695a('0x1c')]?_0x346828[_0x695a('0x1c')][_0x695a('0x1d')]===undefined?!![]:![]:!![],'where':_0x346828[_0x695a('0x1c')]?_0x346828[_0x695a('0x1c')]['where']||null:null,'attributes':_0x346828[_0x695a('0x1c')]?_0x346828[_0x695a('0x1c')]['attributes']||null:null,'limit':_0x346828[_0x695a('0x1c')]?_0x346828[_0x695a('0x1c')][_0x695a('0x1e')]||null:null,'include':_0x346828[_0x695a('0x1c')]?_0x346828[_0x695a('0x1c')]['include']?_[_0x695a('0x1f')](_0x346828[_0x695a('0x1c')][_0x695a('0x20')],function(_0x2ce238){return{'model':db[_0x2ce238[_0x695a('0x21')]],'as':_0x2ce238['as'],'attributes':_0x2ce238[_0x695a('0x22')],'include':_0x2ce238[_0x695a('0x20')]?_[_0x695a('0x1f')](_0x2ce238['include'],function(_0x3508dc){return{'model':db[_0x3508dc[_0x695a('0x21')]],'as':_0x3508dc['as'],'attributes':_0x3508dc['attributes'],'include':_0x3508dc[_0x695a('0x20')]?_[_0x695a('0x1f')](_0x3508dc[_0x695a('0x20')],function(_0x587261){return{'model':db[_0x587261[_0x695a('0x21')]],'as':_0x587261['as'],'attributes':_0x587261[_0x695a('0x22')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x3e0c83){logger[_0x695a('0xf')](_0x695a('0x19'),_0x346828);logger[_0x695a('0x12')](_0x695a('0x19'),_0x346828,JSON[_0x695a('0x13')](_0x3e0c83));_0x1b6435(_0x3e0c83);})[_0x695a('0x18')](function(_0x43d3a1){logger[_0x695a('0x14')](_0x695a('0x19'),_0x43d3a1[_0x695a('0x16')],_0x346828);_0x1d0efc(_0xd26442[_0x695a('0x14')](0x1f4,_0x43d3a1['message']));});});};exports['NotifyFaxAccount']=function(_0xf67f0,_0xd6ed0f,_0x5cafcb){var _0x3d1e11=this;return new Promise(function(_0x55df3f,_0xce6ed4){var _0xd60d30={'body':_0xf67f0['body'],'channel':'fax'};var _0x2d0a09=[];var _0x39d4d9=[];var _0x40c29d={};return db[_0x695a('0x23')]['describe']()[_0x695a('0xe')](function(_0xadfd2e){if(!_0xadfd2e){throw new db[(_0x695a('0x24'))][(_0x695a('0x25'))](_0x695a('0x26'));}_0x2d0a09=_[_0x695a('0x27')](_[_0x695a('0x28')](_0xadfd2e),[_0x695a('0x29'),_0x695a('0x2a')]);_0x39d4d9=_[_0x695a('0x27')](_[_0x695a('0x28')](_0xadfd2e),['createdAt',_0x695a('0x2a'),_0x695a('0x2b'),'ListId']);if(_0xf67f0[_0x695a('0x2c')]['id']){delete _0xf67f0['body']['id'];}if(_[_0x695a('0x2d')](_0xf67f0[_0x695a('0x2c')][_0x695a('0x2e')])){throw new db[(_0x695a('0x24'))][(_0x695a('0x25'))](_0x695a('0x2f'));}if(_[_0x695a('0x2d')](_0xf67f0[_0x695a('0x2c')]['body'])||_0xf67f0['body'][_0x695a('0x2c')]===''){throw new db[(_0x695a('0x24'))]['ValidationError'](_0x695a('0x30'));}if(_[_0x695a('0x2d')](_0xf67f0[_0x695a('0x2c')]['mapKey'])){throw new db[(_0x695a('0x24'))][(_0x695a('0x25'))](_0x695a('0x31')+_0x39d4d9);}if(!_[_0x695a('0x32')](_0x39d4d9,_0xf67f0['body'][_0x695a('0x33')])){throw new db['Sequelize'][(_0x695a('0x25'))]('mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20'+_0x39d4d9);}_0x40c29d[_0xf67f0[_0x695a('0x2c')]['mapKey']]=_0xf67f0[_0x695a('0x2c')][_0x695a('0x2e')];})[_0x695a('0xe')](function(){return db[_0x695a('0x1a')][_0x695a('0x34')]({'where':{'id':_0xf67f0['account']['id']},'include':[{'model':db[_0x695a('0x35')],'as':_0x695a('0x36'),'include':[{'model':db[_0x695a('0x23')],'as':_0x695a('0x37'),'where':_0x40c29d,'limit':0x1,'order':[[_0x695a('0x2a'),_0x695a('0x38')]]}]},{'model':db[_0x695a('0x39')],'as':'Applications'}]});})['then'](function(_0x21f778){if(_0x21f778&&_0x21f778['List']){var _0x1cebe1=_0x21f778[_0x695a('0x3a')]({'plain':!![]});_0xd60d30[_0x695a('0x3b')]=_0x1cebe1;_0xd60d30[_0x695a('0x3c')]=_0x1cebe1[_0x695a('0x3d')];_0xd60d30[_0x695a('0x3e')]=_0x1cebe1[_0x695a('0x36')];_0xd60d30[_0x695a('0x3c')]=_[_0x695a('0x3f')](_0xd60d30['applications'],[_0x695a('0x40')],[_0x695a('0x41')]);if(_0xd60d30[_0x695a('0x3b')]['Applications']){delete _0xd60d30['account'][_0x695a('0x3d')];}if(_0xd60d30[_0x695a('0x3b')][_0x695a('0x36')]&&_0xd60d30[_0x695a('0x3b')][_0x695a('0x36')][_0x695a('0x37')][_0x695a('0x42')]){return _0xd60d30[_0x695a('0x3b')]['List'][_0x695a('0x37')][0x0];}var _0x4a7996=_[_0x695a('0x43')](_0xf67f0[_0x695a('0x2c')],{'firstName':_0xf67f0[_0x695a('0x2c')][_0x695a('0x2e')],'ListId':_0x1cebe1[_0x695a('0x44')]});_0x4a7996[_0xf67f0['body'][_0x695a('0x33')]]=_0xf67f0[_0x695a('0x2c')][_0x695a('0x2e')];return db[_0x695a('0x23')][_0x695a('0x45')](_0x4a7996,{'fields':_0x2d0a09,'raw':!![]});}})[_0x695a('0xe')](function(_0x4ed560){_0xd60d30[_0x695a('0x46')]=_0x4ed560;if(_0x4ed560){var _0x502b13={'ContactId':_0x4ed560['id'],'FaxAccountId':_0xf67f0['account']['id'],'fax':_0x4ed560['fax']};return db['FaxInteraction'][_0x695a('0x34')]({'where':{'ContactId':_0x4ed560['id'],'closed':![],'FaxAccountId':_0xf67f0[_0x695a('0x3b')]['id']}})[_0x695a('0xe')](function(_0x3fb68a){if(_0x3fb68a){return[_0x3fb68a,![]];}return db[_0x695a('0x47')][_0x695a('0x45')](_0x502b13)[_0x695a('0xe')](function(_0x73acd6){return[_0x73acd6,!![]];});});}else{throw new Error(_0x695a('0x48'));}})['spread'](function(_0x3f904f,_0x4e078a){var _0x34a598=_0x3f904f[_0x695a('0x3a')]({'plain':!![]});if(_0x4e078a){if(_0xd60d30[_0x695a('0x3b')][_0x695a('0x49')]){_0xd60d30[_0x695a('0x3c')][_0x695a('0x4a')]({'id':0x0,'priority':_0xd60d30['applications'][_0x695a('0x42')]+0x1,'app':_0x695a('0x4b'),'appdata':_0x695a('0x4c'),'interval':_0x695a('0x4d')});}_0x34a598[_0x695a('0x4e')]=!![];}else{_0x34a598[_0x695a('0x4e')]=![];}_0xd60d30[_0x695a('0x4f')]=_0x34a598;return db[_0x695a('0x50')][_0x695a('0x45')]({'body':_0xf67f0['body'][_0x695a('0x2c')],'FaxAccountId':_0xf67f0[_0x695a('0x3b')]['id'],'FaxInteractionId':_0x3f904f['id'],'direction':'in','ContactId':_0x3f904f[_0x695a('0x51')],'AttachmentId':_0xf67f0[_0x695a('0x2c')][_0x695a('0x52')]});})['then'](function(_0x2bb2b5){_0xd60d30[_0x695a('0x16')]=_0x2bb2b5;if(!_0xd60d30[_0x695a('0x4f')][_0x695a('0x53')])return;return db[_0x695a('0x54')]['find']({'attributes':['id',_0x695a('0x55')],'where':{'id':_0xd60d30[_0x695a('0x4f')][_0x695a('0x53')]}});})[_0x695a('0xe')](function(_0x5bc0a7){if(_0x5bc0a7){_0xd60d30[_0x695a('0x3c')][_0x695a('0x56')]({'id':0x0,'priority':0x0,'app':_0x695a('0x57'),'appdata':_0x5bc0a7[_0x695a('0x55')]+','+(_0xd60d30[_0x695a('0x3b')]['waitForTheAssignedAgent']||0xa),'interval':'*,*,*,*'});}if(!_0xd60d30[_0x695a('0x4f')][_0x695a('0x58')])return;return db[_0x695a('0x59')]['find']({'attributes':['id','name'],'where':{'id':_0xd60d30[_0x695a('0x4f')]['queueId']}});})[_0x695a('0xe')](function(_0x395fd4){if(_0x395fd4){_0xd60d30[_0x695a('0x3c')][_0x695a('0x56')]({'id':0x0,'priority':0x1,'app':_0x695a('0x5a'),'appdata':_0x395fd4[_0x695a('0x55')]+','+(_0xd60d30[_0x695a('0x3b')]['waitForTheAssignedQueue']||0x12c),'interval':'*,*,*,*'});}return respondWithRpcPromise('Start',_0x695a('0x5b'),_0xd60d30);})['then'](function(_0x584192){_0x55df3f(_0x584192);})[_0x695a('0x18')](function(_0x1dee8b){_0xce6ed4(_0x3d1e11[_0x695a('0x14')](0x1f4,_0x1dee8b[_0x695a('0x16')]));});});};
\ No newline at end of file