Built motion from commit 37e1ed56.|2.6.29
[motion2.git] / server / api / faxAccount / faxAccount.rpc.js
index 0130d39..1918060 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x8860=['where','attributes','include','map','model','NotifyFaxAccount','body','CmContact','describe','ValidationError','no\x20available\x20attributes','difference','keys','createdAt','updatedAt','CompanyId','ListId','isNil','from','from\x20is\x20mandatory','Sequelize','body\x20is\x20mandatory\x20and\x20not\x20empty','mapKey','mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','includes','find','CmList','List','Contacts','DESC','FaxApplication','Applications','account','applications','list','orderBy','priority','asc','create','fax','FaxInteraction','get','length','close','unmanaged','created','interaction','ContactId','AttachmentId','UserId','User','name','unshift','waitForTheAssignedAgent','queueId','queue','waitForTheAssignedQueue','*,*,*,*','Start','startRouting','lodash','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis','defaults','localhost','socket.io-emitter','./faxAccount.socket','register','then','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'];(function(_0x20a584,_0xe384a5){var _0x4b41a8=function(_0x2127c6){while(--_0x2127c6){_0x20a584['push'](_0x20a584['shift']());}};_0x4b41a8(++_0xe384a5);}(_0x8860,0x156));var _0x0886=function(_0x2de0a7,_0x38d3e7){_0x2de0a7=_0x2de0a7-0x0;var _0x429437=_0x8860[_0x2de0a7];return _0x429437;};'use strict';var _=require(_0x0886('0x0'));var util=require('util');var moment=require('moment');var BPromise=require(_0x0886('0x1'));var rs=require(_0x0886('0x2'));var fs=require('fs');var Redis=require(_0x0886('0x3'));var db=require(_0x0886('0x4'))['db'];var utils=require(_0x0886('0x5'));var logger=require(_0x0886('0x6'))(_0x0886('0x7'));var config=require(_0x0886('0x8'));var jayson=require(_0x0886('0x9'));var client=jayson[_0x0886('0xa')][_0x0886('0xb')]({'port':0x232c});config[_0x0886('0xc')]=_[_0x0886('0xd')](config['redis'],{'host':_0x0886('0xe'),'port':0x18eb});var socket=require(_0x0886('0xf'))(new Redis(config[_0x0886('0xc')]));require(_0x0886('0x10'))[_0x0886('0x11')](socket);function respondWithRpcPromise(_0x5e47f3,_0x269f02,_0xc6b286){return new BPromise(function(_0xac5c53,_0x4cd3f2){return client['request'](_0x5e47f3,_0xc6b286)[_0x0886('0x12')](function(_0x53a7f8){logger[_0x0886('0x13')]('FaxAccount,\x20%s,\x20%s',_0x269f02,_0x0886('0x14'));logger[_0x0886('0x15')](_0x0886('0x16'),_0x269f02,_0x0886('0x14'),JSON[_0x0886('0x17')](_0x53a7f8));if(_0x53a7f8[_0x0886('0x18')]){if(_0x53a7f8[_0x0886('0x18')][_0x0886('0x19')]===0x1f4){logger[_0x0886('0x18')](_0x0886('0x1a'),_0x269f02,_0x53a7f8[_0x0886('0x18')][_0x0886('0x1b')]);return _0x4cd3f2(_0x53a7f8['error'][_0x0886('0x1b')]);}logger[_0x0886('0x18')]('FaxAccount,\x20%s,\x20%s',_0x269f02,_0x53a7f8[_0x0886('0x18')][_0x0886('0x1b')]);return _0xac5c53(_0x53a7f8[_0x0886('0x18')]['message']);}else{logger[_0x0886('0x13')]('FaxAccount,\x20%s,\x20%s',_0x269f02,_0x0886('0x14'));_0xac5c53(_0x53a7f8[_0x0886('0x1c')][_0x0886('0x1b')]);}})[_0x0886('0x1d')](function(_0x4bac76){logger[_0x0886('0x18')](_0x0886('0x1a'),_0x269f02,_0x4bac76);_0x4cd3f2(_0x4bac76);});});}exports[_0x0886('0x1e')]=function(_0x2501d2){var _0x1f0669=this;return new Promise(function(_0x4de59a,_0x2fb27b){return db[_0x0886('0x1f')][_0x0886('0x20')]({'raw':_0x2501d2[_0x0886('0x21')]?_0x2501d2[_0x0886('0x21')]['raw']===undefined?!![]:![]:!![],'where':_0x2501d2[_0x0886('0x21')]?_0x2501d2[_0x0886('0x21')][_0x0886('0x22')]||null:null,'attributes':_0x2501d2[_0x0886('0x21')]?_0x2501d2[_0x0886('0x21')][_0x0886('0x23')]||null:null,'limit':_0x2501d2[_0x0886('0x21')]?_0x2501d2['options']['limit']||null:null,'include':_0x2501d2['options']?_0x2501d2['options'][_0x0886('0x24')]?_[_0x0886('0x25')](_0x2501d2[_0x0886('0x21')]['include'],function(_0x27c4da){return{'model':db[_0x27c4da[_0x0886('0x26')]],'as':_0x27c4da['as'],'attributes':_0x27c4da['attributes'],'include':_0x27c4da[_0x0886('0x24')]?_[_0x0886('0x25')](_0x27c4da[_0x0886('0x24')],function(_0x5fbfd4){return{'model':db[_0x5fbfd4[_0x0886('0x26')]],'as':_0x5fbfd4['as'],'attributes':_0x5fbfd4['attributes'],'include':_0x5fbfd4['include']?_[_0x0886('0x25')](_0x5fbfd4[_0x0886('0x24')],function(_0x3a46aa){return{'model':db[_0x3a46aa[_0x0886('0x26')]],'as':_0x3a46aa['as'],'attributes':_0x3a46aa[_0x0886('0x23')]};}):[]};}):[]};}):[]:[]})[_0x0886('0x12')](function(_0x279470){logger['info'](_0x0886('0x1e'),_0x2501d2);logger['debug'](_0x0886('0x1e'),_0x2501d2,JSON[_0x0886('0x17')](_0x279470));_0x4de59a(_0x279470);})[_0x0886('0x1d')](function(_0x9ffbc7){logger[_0x0886('0x18')](_0x0886('0x1e'),_0x9ffbc7[_0x0886('0x1b')],_0x2501d2);_0x2fb27b(_0x1f0669['error'](0x1f4,_0x9ffbc7[_0x0886('0x1b')]));});});};exports[_0x0886('0x27')]=function(_0x26b2ca,_0x43f5cd,_0x35ff1c){var _0x24a81c=this;return new Promise(function(_0x2a4891,_0x447f3b){var _0x61c5a9={'body':_0x26b2ca[_0x0886('0x28')],'channel':'fax'};var _0x2e0f21=[];var _0x2393e7=[];var _0x55f0f7={};return db[_0x0886('0x29')][_0x0886('0x2a')]()[_0x0886('0x12')](function(_0x443d8c){if(!_0x443d8c){throw new db['Sequelize'][(_0x0886('0x2b'))](_0x0886('0x2c'));}_0x2e0f21=_[_0x0886('0x2d')](_[_0x0886('0x2e')](_0x443d8c),[_0x0886('0x2f'),_0x0886('0x30')]);_0x2393e7=_[_0x0886('0x2d')](_[_0x0886('0x2e')](_0x443d8c),[_0x0886('0x2f'),_0x0886('0x30'),_0x0886('0x31'),_0x0886('0x32')]);if(_0x26b2ca[_0x0886('0x28')]['id']){delete _0x26b2ca['body']['id'];}if(_[_0x0886('0x33')](_0x26b2ca[_0x0886('0x28')][_0x0886('0x34')])){throw new db['Sequelize'][(_0x0886('0x2b'))](_0x0886('0x35'));}if(_[_0x0886('0x33')](_0x26b2ca[_0x0886('0x28')]['body'])||_0x26b2ca[_0x0886('0x28')]['body']===''){throw new db[(_0x0886('0x36'))][(_0x0886('0x2b'))](_0x0886('0x37'));}if(_[_0x0886('0x33')](_0x26b2ca[_0x0886('0x28')][_0x0886('0x38')])){throw new db[(_0x0886('0x36'))][(_0x0886('0x2b'))](_0x0886('0x39')+_0x2393e7);}if(!_[_0x0886('0x3a')](_0x2393e7,_0x26b2ca[_0x0886('0x28')][_0x0886('0x38')])){throw new db[(_0x0886('0x36'))]['ValidationError']('mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20'+_0x2393e7);}_0x55f0f7[_0x26b2ca[_0x0886('0x28')][_0x0886('0x38')]]=_0x26b2ca['body'][_0x0886('0x34')];})[_0x0886('0x12')](function(){return db[_0x0886('0x1f')][_0x0886('0x3b')]({'where':{'id':_0x26b2ca['account']['id']},'include':[{'model':db[_0x0886('0x3c')],'as':_0x0886('0x3d'),'include':[{'model':db[_0x0886('0x29')],'as':_0x0886('0x3e'),'where':_0x55f0f7,'limit':0x1,'order':[['updatedAt',_0x0886('0x3f')]]}]},{'model':db[_0x0886('0x40')],'as':_0x0886('0x41')}]});})[_0x0886('0x12')](function(_0x4a4076){if(_0x4a4076&&_0x4a4076[_0x0886('0x3d')]){var _0x513879=_0x4a4076['get']({'plain':!![]});_0x61c5a9[_0x0886('0x42')]=_0x513879;_0x61c5a9[_0x0886('0x43')]=_0x513879[_0x0886('0x41')];_0x61c5a9[_0x0886('0x44')]=_0x513879['List'];_0x61c5a9[_0x0886('0x43')]=_[_0x0886('0x45')](_0x61c5a9['applications'],[_0x0886('0x46')],[_0x0886('0x47')]);if(_0x61c5a9[_0x0886('0x42')][_0x0886('0x41')]){delete _0x61c5a9[_0x0886('0x42')][_0x0886('0x41')];}if(_0x61c5a9[_0x0886('0x42')]['List']&&_0x61c5a9[_0x0886('0x42')][_0x0886('0x3d')]['Contacts']['length']){return _0x61c5a9['account']['List'][_0x0886('0x3e')][0x0];}var _0x305cec=_[_0x0886('0xd')](_0x26b2ca[_0x0886('0x28')],{'firstName':_0x26b2ca[_0x0886('0x28')][_0x0886('0x34')],'ListId':_0x513879[_0x0886('0x32')]});_0x305cec[_0x26b2ca[_0x0886('0x28')][_0x0886('0x38')]]=_0x26b2ca[_0x0886('0x28')]['from'];return db[_0x0886('0x29')][_0x0886('0x48')](_0x305cec,{'fields':_0x2e0f21,'raw':!![]});}})['then'](function(_0x4c277a){_0x61c5a9['contact']=_0x4c277a;if(_0x4c277a){var _0x59b494={'ContactId':_0x4c277a['id'],'FaxAccountId':_0x26b2ca[_0x0886('0x42')]['id'],'fax':_0x4c277a[_0x0886('0x49')]};return db['FaxInteraction']['find']({'where':{'ContactId':_0x4c277a['id'],'closed':![],'FaxAccountId':_0x26b2ca[_0x0886('0x42')]['id']}})[_0x0886('0x12')](function(_0x40ea60){if(_0x40ea60){return[_0x40ea60,![]];}return db[_0x0886('0x4a')][_0x0886('0x48')](_0x59b494)[_0x0886('0x12')](function(_0x46eea6){return[_0x46eea6,!![]];});});}else{throw new Error('Contact\x20not\x20found');}})['spread'](function(_0x56fe44,_0x9a5ed8){var _0x46fe72=_0x56fe44[_0x0886('0x4b')]({'plain':!![]});if(_0x9a5ed8){if(_0x61c5a9[_0x0886('0x42')]['autoclose']){_0x61c5a9[_0x0886('0x43')]['push']({'id':0x0,'priority':_0x61c5a9[_0x0886('0x43')][_0x0886('0x4c')]+0x1,'app':_0x0886('0x4d'),'appdata':_0x0886('0x4e'),'interval':'*,*,*,*'});}_0x46fe72['created']=!![];}else{_0x46fe72[_0x0886('0x4f')]=![];}_0x61c5a9[_0x0886('0x50')]=_0x46fe72;return db['FaxMessage']['create']({'body':_0x26b2ca[_0x0886('0x28')]['body'],'FaxAccountId':_0x26b2ca[_0x0886('0x42')]['id'],'FaxInteractionId':_0x56fe44['id'],'direction':'in','ContactId':_0x56fe44[_0x0886('0x51')],'AttachmentId':_0x26b2ca[_0x0886('0x28')][_0x0886('0x52')]});})['then'](function(_0x2fd8ac){_0x61c5a9[_0x0886('0x1b')]=_0x2fd8ac;if(!_0x61c5a9[_0x0886('0x50')][_0x0886('0x53')])return;return db[_0x0886('0x54')]['find']({'attributes':['id',_0x0886('0x55')],'where':{'id':_0x61c5a9[_0x0886('0x50')][_0x0886('0x53')]}});})[_0x0886('0x12')](function(_0x20bac2){if(_0x20bac2){_0x61c5a9[_0x0886('0x43')][_0x0886('0x56')]({'id':0x0,'priority':0x0,'app':'agent','appdata':_0x20bac2[_0x0886('0x55')]+','+(_0x61c5a9[_0x0886('0x42')][_0x0886('0x57')]||0xa),'interval':'*,*,*,*'});}if(!_0x61c5a9['interaction'][_0x0886('0x58')])return;return db['FaxQueue'][_0x0886('0x3b')]({'attributes':['id','name'],'where':{'id':_0x61c5a9[_0x0886('0x50')][_0x0886('0x58')]}});})[_0x0886('0x12')](function(_0x318bde){if(_0x318bde){_0x61c5a9[_0x0886('0x43')][_0x0886('0x56')]({'id':0x0,'priority':0x1,'app':_0x0886('0x59'),'appdata':_0x318bde[_0x0886('0x55')]+','+(_0x61c5a9[_0x0886('0x42')][_0x0886('0x5a')]||0x12c),'interval':_0x0886('0x5b')});}return respondWithRpcPromise(_0x0886('0x5c'),_0x0886('0x5d'),_0x61c5a9);})[_0x0886('0x12')](function(_0x363111){_0x2a4891(_0x363111);})[_0x0886('0x1d')](function(_0x33f8cd){_0x447f3b(_0x24a81c[_0x0886('0x18')](0x1f4,_0x33f8cd[_0x0886('0x1b')]));});});};
\ No newline at end of file
+var _0xcf3f=['randomstring','ioredis','../../mysqldb','../../config/environment','jayson/promise','http','redis','defaults','localhost','socket.io-emitter','./faxAccount.socket','register','request','info','FaxAccount,\x20%s,\x20%s','request\x20sent','debug','error','code','message','result','catch','FaxAccount','findAll','options','raw','where','attributes','limit','include','map','model','then','GetFaxAccount','NotifyFaxAccount','body','fax','describe','Sequelize','ValidationError','difference','keys','createdAt','updatedAt','CompanyId','ListId','isNil','from\x20is\x20mandatory','body\x20is\x20mandatory\x20and\x20not\x20empty','mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','includes','mapKey','mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','find','account','List','CmContact','DESC','FaxApplication','get','applications','Applications','list','orderBy','priority','asc','length','Contacts','from','create','contact','FaxInteraction','spread','push','close','unmanaged','*,*,*,*','created','FaxMessage','ContactId','AttachmentId','interaction','UserId','User','name','unshift','agent','waitForTheAssignedAgent','queueId','FaxQueue','queue','Start','startRouting','util','moment'];(function(_0x5015d2,_0x32862a){var _0x25f5e1=function(_0x24454d){while(--_0x24454d){_0x5015d2['push'](_0x5015d2['shift']());}};_0x25f5e1(++_0x32862a);}(_0xcf3f,0x1d9));var _0xfcf3=function(_0x333ca0,_0x4a928e){_0x333ca0=_0x333ca0-0x0;var _0x4905e2=_0xcf3f[_0x333ca0];return _0x4905e2;};'use strict';var _=require('lodash');var util=require(_0xfcf3('0x0'));var moment=require(_0xfcf3('0x1'));var BPromise=require('bluebird');var rs=require(_0xfcf3('0x2'));var fs=require('fs');var Redis=require(_0xfcf3('0x3'));var db=require(_0xfcf3('0x4'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')('rpc');var config=require(_0xfcf3('0x5'));var jayson=require(_0xfcf3('0x6'));var client=jayson['client'][_0xfcf3('0x7')]({'port':0x232c});config[_0xfcf3('0x8')]=_[_0xfcf3('0x9')](config[_0xfcf3('0x8')],{'host':_0xfcf3('0xa'),'port':0x18eb});var socket=require(_0xfcf3('0xb'))(new Redis(config['redis']));require(_0xfcf3('0xc'))[_0xfcf3('0xd')](socket);function respondWithRpcPromise(_0x33acc6,_0x58f0d9,_0x5df5ac){return new BPromise(function(_0x1f451a,_0x188b2a){return client[_0xfcf3('0xe')](_0x33acc6,_0x5df5ac)['then'](function(_0x12fd9b){logger[_0xfcf3('0xf')](_0xfcf3('0x10'),_0x58f0d9,_0xfcf3('0x11'));logger[_0xfcf3('0x12')]('FaxAccount,\x20%s,\x20%s,\x20%s',_0x58f0d9,_0xfcf3('0x11'),JSON['stringify'](_0x12fd9b));if(_0x12fd9b[_0xfcf3('0x13')]){if(_0x12fd9b[_0xfcf3('0x13')][_0xfcf3('0x14')]===0x1f4){logger[_0xfcf3('0x13')](_0xfcf3('0x10'),_0x58f0d9,_0x12fd9b[_0xfcf3('0x13')][_0xfcf3('0x15')]);return _0x188b2a(_0x12fd9b[_0xfcf3('0x13')][_0xfcf3('0x15')]);}logger[_0xfcf3('0x13')](_0xfcf3('0x10'),_0x58f0d9,_0x12fd9b[_0xfcf3('0x13')][_0xfcf3('0x15')]);return _0x1f451a(_0x12fd9b[_0xfcf3('0x13')]['message']);}else{logger['info'](_0xfcf3('0x10'),_0x58f0d9,_0xfcf3('0x11'));_0x1f451a(_0x12fd9b[_0xfcf3('0x16')][_0xfcf3('0x15')]);}})[_0xfcf3('0x17')](function(_0x56b863){logger[_0xfcf3('0x13')](_0xfcf3('0x10'),_0x58f0d9,_0x56b863);_0x188b2a(_0x56b863);});});}exports['GetFaxAccount']=function(_0x4c4884){var _0x4cdcc1=this;return new Promise(function(_0x56718,_0x1c110b){return db[_0xfcf3('0x18')][_0xfcf3('0x19')]({'raw':_0x4c4884['options']?_0x4c4884[_0xfcf3('0x1a')][_0xfcf3('0x1b')]===undefined?!![]:![]:!![],'where':_0x4c4884[_0xfcf3('0x1a')]?_0x4c4884[_0xfcf3('0x1a')][_0xfcf3('0x1c')]||null:null,'attributes':_0x4c4884['options']?_0x4c4884[_0xfcf3('0x1a')][_0xfcf3('0x1d')]||null:null,'limit':_0x4c4884[_0xfcf3('0x1a')]?_0x4c4884[_0xfcf3('0x1a')][_0xfcf3('0x1e')]||null:null,'include':_0x4c4884[_0xfcf3('0x1a')]?_0x4c4884['options'][_0xfcf3('0x1f')]?_[_0xfcf3('0x20')](_0x4c4884[_0xfcf3('0x1a')]['include'],function(_0x2e15f2){return{'model':db[_0x2e15f2['model']],'as':_0x2e15f2['as'],'attributes':_0x2e15f2[_0xfcf3('0x1d')],'include':_0x2e15f2[_0xfcf3('0x1f')]?_[_0xfcf3('0x20')](_0x2e15f2[_0xfcf3('0x1f')],function(_0x180869){return{'model':db[_0x180869[_0xfcf3('0x21')]],'as':_0x180869['as'],'attributes':_0x180869['attributes'],'include':_0x180869[_0xfcf3('0x1f')]?_['map'](_0x180869['include'],function(_0x581464){return{'model':db[_0x581464[_0xfcf3('0x21')]],'as':_0x581464['as'],'attributes':_0x581464[_0xfcf3('0x1d')]};}):[]};}):[]};}):[]:[]})[_0xfcf3('0x22')](function(_0x1970e5){logger[_0xfcf3('0xf')](_0xfcf3('0x23'),_0x4c4884);logger[_0xfcf3('0x12')](_0xfcf3('0x23'),_0x4c4884,JSON['stringify'](_0x1970e5));_0x56718(_0x1970e5);})[_0xfcf3('0x17')](function(_0x1e2d70){logger[_0xfcf3('0x13')](_0xfcf3('0x23'),_0x1e2d70[_0xfcf3('0x15')],_0x4c4884);_0x1c110b(_0x4cdcc1[_0xfcf3('0x13')](0x1f4,_0x1e2d70['message']));});});};exports[_0xfcf3('0x24')]=function(_0x4af312,_0x1877a5,_0x545796){var _0x43ae79=this;return new Promise(function(_0x40c907,_0x1c6ae4){var _0x4e685c={'body':_0x4af312[_0xfcf3('0x25')],'channel':_0xfcf3('0x26')};var _0x35dec4=[];var _0x36faee=[];var _0x1c801c={};return db['CmContact'][_0xfcf3('0x27')]()[_0xfcf3('0x22')](function(_0x57bd7c){if(!_0x57bd7c){throw new db[(_0xfcf3('0x28'))][(_0xfcf3('0x29'))]('no\x20available\x20attributes');}_0x35dec4=_[_0xfcf3('0x2a')](_[_0xfcf3('0x2b')](_0x57bd7c),[_0xfcf3('0x2c'),_0xfcf3('0x2d')]);_0x36faee=_[_0xfcf3('0x2a')](_[_0xfcf3('0x2b')](_0x57bd7c),['createdAt',_0xfcf3('0x2d'),_0xfcf3('0x2e'),_0xfcf3('0x2f')]);if(_0x4af312[_0xfcf3('0x25')]['id']){delete _0x4af312[_0xfcf3('0x25')]['id'];}if(_[_0xfcf3('0x30')](_0x4af312[_0xfcf3('0x25')]['from'])){throw new db[(_0xfcf3('0x28'))][(_0xfcf3('0x29'))](_0xfcf3('0x31'));}if(_[_0xfcf3('0x30')](_0x4af312['body']['body'])||_0x4af312['body']['body']===''){throw new db[(_0xfcf3('0x28'))][(_0xfcf3('0x29'))](_0xfcf3('0x32'));}if(_[_0xfcf3('0x30')](_0x4af312[_0xfcf3('0x25')]['mapKey'])){throw new db[(_0xfcf3('0x28'))][(_0xfcf3('0x29'))](_0xfcf3('0x33')+_0x36faee);}if(!_[_0xfcf3('0x34')](_0x36faee,_0x4af312['body'][_0xfcf3('0x35')])){throw new db[(_0xfcf3('0x28'))]['ValidationError'](_0xfcf3('0x36')+_0x36faee);}_0x1c801c[_0x4af312['body']['mapKey']]=_0x4af312[_0xfcf3('0x25')]['from'];})[_0xfcf3('0x22')](function(){return db[_0xfcf3('0x18')][_0xfcf3('0x37')]({'where':{'id':_0x4af312[_0xfcf3('0x38')]['id']},'include':[{'model':db['CmList'],'as':_0xfcf3('0x39'),'include':[{'model':db[_0xfcf3('0x3a')],'as':'Contacts','where':_0x1c801c,'limit':0x1,'order':[[_0xfcf3('0x2d'),_0xfcf3('0x3b')]]}]},{'model':db[_0xfcf3('0x3c')],'as':'Applications'}]});})['then'](function(_0x1b93d7){if(_0x1b93d7&&_0x1b93d7[_0xfcf3('0x39')]){var _0x38d367=_0x1b93d7[_0xfcf3('0x3d')]({'plain':!![]});_0x4e685c[_0xfcf3('0x38')]=_0x38d367;_0x4e685c[_0xfcf3('0x3e')]=_0x38d367[_0xfcf3('0x3f')];_0x4e685c[_0xfcf3('0x40')]=_0x38d367[_0xfcf3('0x39')];_0x4e685c[_0xfcf3('0x3e')]=_[_0xfcf3('0x41')](_0x4e685c[_0xfcf3('0x3e')],[_0xfcf3('0x42')],[_0xfcf3('0x43')]);if(_0x4e685c[_0xfcf3('0x38')][_0xfcf3('0x3f')]){delete _0x4e685c['account'][_0xfcf3('0x3f')];}if(_0x4e685c[_0xfcf3('0x38')][_0xfcf3('0x39')]&&_0x4e685c[_0xfcf3('0x38')][_0xfcf3('0x39')]['Contacts'][_0xfcf3('0x44')]){return _0x4e685c[_0xfcf3('0x38')]['List'][_0xfcf3('0x45')][0x0];}var _0x4c9633=_[_0xfcf3('0x9')](_0x4af312[_0xfcf3('0x25')],{'firstName':_0x4af312[_0xfcf3('0x25')]['from'],'ListId':_0x38d367[_0xfcf3('0x2f')]});_0x4c9633[_0x4af312[_0xfcf3('0x25')][_0xfcf3('0x35')]]=_0x4af312['body'][_0xfcf3('0x46')];return db['CmContact'][_0xfcf3('0x47')](_0x4c9633,{'fields':_0x35dec4,'raw':!![]});}})[_0xfcf3('0x22')](function(_0x22470d){_0x4e685c[_0xfcf3('0x48')]=_0x22470d;if(_0x22470d){var _0x5b2150={'ContactId':_0x22470d['id'],'FaxAccountId':_0x4af312[_0xfcf3('0x38')]['id'],'fax':_0x22470d[_0xfcf3('0x26')]};return db[_0xfcf3('0x49')][_0xfcf3('0x37')]({'where':{'ContactId':_0x22470d['id'],'closed':![],'FaxAccountId':_0x4af312['account']['id']}})[_0xfcf3('0x22')](function(_0x1e3f11){if(_0x1e3f11){return[_0x1e3f11,![]];}return db[_0xfcf3('0x49')]['create'](_0x5b2150)[_0xfcf3('0x22')](function(_0x5387d5){return[_0x5387d5,!![]];});});}else{throw new Error('Contact\x20not\x20found');}})[_0xfcf3('0x4a')](function(_0x1a698c,_0x575ef6){var _0x9c035d=_0x1a698c[_0xfcf3('0x3d')]({'plain':!![]});if(_0x575ef6){if(_0x4e685c[_0xfcf3('0x38')]['autoclose']){_0x4e685c['applications'][_0xfcf3('0x4b')]({'id':0x0,'priority':_0x4e685c[_0xfcf3('0x3e')][_0xfcf3('0x44')]+0x1,'app':_0xfcf3('0x4c'),'appdata':_0xfcf3('0x4d'),'interval':_0xfcf3('0x4e')});}_0x9c035d[_0xfcf3('0x4f')]=!![];}else{_0x9c035d[_0xfcf3('0x4f')]=![];}_0x4e685c['interaction']=_0x9c035d;return db[_0xfcf3('0x50')]['create']({'body':_0x4af312[_0xfcf3('0x25')]['body'],'FaxAccountId':_0x4af312[_0xfcf3('0x38')]['id'],'FaxInteractionId':_0x1a698c['id'],'direction':'in','ContactId':_0x1a698c[_0xfcf3('0x51')],'AttachmentId':_0x4af312[_0xfcf3('0x25')][_0xfcf3('0x52')]});})[_0xfcf3('0x22')](function(_0x49815e){_0x4e685c[_0xfcf3('0x15')]=_0x49815e;if(!_0x4e685c[_0xfcf3('0x53')][_0xfcf3('0x54')])return;return db[_0xfcf3('0x55')]['find']({'attributes':['id',_0xfcf3('0x56')],'where':{'id':_0x4e685c['interaction'][_0xfcf3('0x54')]}});})['then'](function(_0x54de8b){if(_0x54de8b){_0x4e685c[_0xfcf3('0x3e')][_0xfcf3('0x57')]({'id':0x0,'priority':0x0,'app':_0xfcf3('0x58'),'appdata':_0x54de8b[_0xfcf3('0x56')]+','+(_0x4e685c[_0xfcf3('0x38')][_0xfcf3('0x59')]||0xa),'interval':'*,*,*,*'});}if(!_0x4e685c['interaction'][_0xfcf3('0x5a')])return;return db[_0xfcf3('0x5b')][_0xfcf3('0x37')]({'attributes':['id',_0xfcf3('0x56')],'where':{'id':_0x4e685c[_0xfcf3('0x53')][_0xfcf3('0x5a')]}});})[_0xfcf3('0x22')](function(_0x2615c9){if(_0x2615c9){_0x4e685c['applications'][_0xfcf3('0x57')]({'id':0x0,'priority':0x1,'app':_0xfcf3('0x5c'),'appdata':_0x2615c9[_0xfcf3('0x56')]+','+(_0x4e685c[_0xfcf3('0x38')]['waitForTheAssignedQueue']||0x12c),'interval':'*,*,*,*'});}return respondWithRpcPromise(_0xfcf3('0x5d'),_0xfcf3('0x5e'),_0x4e685c);})[_0xfcf3('0x22')](function(_0x30a381){_0x40c907(_0x30a381);})[_0xfcf3('0x17')](function(_0x5f5dd8){_0x1c6ae4(_0x43ae79['error'](0x1f4,_0x5f5dd8['message']));});});};
\ No newline at end of file