Built motion from commit (unavailable).|2.5.6
[motion2.git] / server / api / faxAccount / faxAccount.rpc.js
index f3a0387..565afb6 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xf641=['interaction','FaxMessage','ContactId','AttachmentId','UserId','User','name','unshift','agent','*,*,*,*','Start','startRouting','catch','lodash','util','bluebird','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis','socket.io-emitter','./faxAccount.socket','register','request','then','info','debug','FaxAccount,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','FaxAccount,\x20%s,\x20%s','result','GetFaxAccount','FaxAccount','findAll','options','raw','where','attributes','limit','include','model','message','NotifyFaxAccount','body','fax','CmContact','describe','Sequelize','ValidationError','difference','keys','createdAt','updatedAt','isNil','from','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','FaxApplication','get','Applications','list','applications','priority','asc','length','defaults','ListId','contact','FaxInteraction','find','create','Contact\x20not\x20found','spread','autoclose','push','close','unmanaged','created'];(function(_0x324111,_0x1b6daf){var _0x46e69b=function(_0x49e9c5){while(--_0x49e9c5){_0x324111['push'](_0x324111['shift']());}};_0x46e69b(++_0x1b6daf);}(_0xf641,0x17d));var _0x1f64=function(_0x35f2d6,_0x1eacc1){_0x35f2d6=_0x35f2d6-0x0;var _0x33a492=_0xf641[_0x35f2d6];return _0x33a492;};'use strict';var _=require(_0x1f64('0x0'));var util=require(_0x1f64('0x1'));var moment=require('moment');var BPromise=require(_0x1f64('0x2'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x1f64('0x3'));var db=require(_0x1f64('0x4'))['db'];var utils=require('../../config/utils');var logger=require(_0x1f64('0x5'))(_0x1f64('0x6'));var config=require(_0x1f64('0x7'));var jayson=require(_0x1f64('0x8'));var client=jayson[_0x1f64('0x9')][_0x1f64('0xa')]({'port':0x232c});config['redis']=_['defaults'](config[_0x1f64('0xb')],{'host':'localhost','port':0x18eb});var socket=require(_0x1f64('0xc'))(new Redis(config[_0x1f64('0xb')]));require(_0x1f64('0xd'))[_0x1f64('0xe')](socket);function respondWithRpcPromise(_0x595de1,_0x498c93,_0x11b966){return new BPromise(function(_0xbc2e15,_0x28805c){return client[_0x1f64('0xf')](_0x595de1,_0x11b966)[_0x1f64('0x10')](function(_0x7b8f98){logger[_0x1f64('0x11')]('FaxAccount,\x20%s,\x20%s',_0x498c93,'request\x20sent');logger[_0x1f64('0x12')](_0x1f64('0x13'),_0x498c93,_0x1f64('0x14'),JSON[_0x1f64('0x15')](_0x7b8f98));if(_0x7b8f98[_0x1f64('0x16')]){if(_0x7b8f98[_0x1f64('0x16')]['code']===0x1f4){logger['error'](_0x1f64('0x17'),_0x498c93,_0x7b8f98[_0x1f64('0x16')]['message']);return _0x28805c(_0x7b8f98[_0x1f64('0x16')]['message']);}logger['error'](_0x1f64('0x17'),_0x498c93,_0x7b8f98[_0x1f64('0x16')]['message']);return _0xbc2e15(_0x7b8f98[_0x1f64('0x16')]['message']);}else{logger[_0x1f64('0x11')]('FaxAccount,\x20%s,\x20%s',_0x498c93,'request\x20sent');_0xbc2e15(_0x7b8f98[_0x1f64('0x18')]['message']);}})['catch'](function(_0x4cbb1a){logger[_0x1f64('0x16')]('FaxAccount,\x20%s,\x20%s',_0x498c93,_0x4cbb1a);_0x28805c(_0x4cbb1a);});});}exports[_0x1f64('0x19')]=function(_0x12eadd){var _0x1b744f=this;return new Promise(function(_0x312189,_0x2bd5d6){return db[_0x1f64('0x1a')][_0x1f64('0x1b')]({'raw':_0x12eadd[_0x1f64('0x1c')]?_0x12eadd[_0x1f64('0x1c')][_0x1f64('0x1d')]===undefined?!![]:![]:!![],'where':_0x12eadd[_0x1f64('0x1c')]?_0x12eadd[_0x1f64('0x1c')][_0x1f64('0x1e')]||null:null,'attributes':_0x12eadd[_0x1f64('0x1c')]?_0x12eadd[_0x1f64('0x1c')][_0x1f64('0x1f')]||null:null,'limit':_0x12eadd['options']?_0x12eadd[_0x1f64('0x1c')][_0x1f64('0x20')]||null:null,'include':_0x12eadd[_0x1f64('0x1c')]?_0x12eadd['options']['include']?_['map'](_0x12eadd['options'][_0x1f64('0x21')],function(_0x4faf36){return{'model':db[_0x4faf36[_0x1f64('0x22')]],'as':_0x4faf36['as'],'attributes':_0x4faf36[_0x1f64('0x1f')],'include':_0x4faf36[_0x1f64('0x21')]?_['map'](_0x4faf36[_0x1f64('0x21')],function(_0x19660f){return{'model':db[_0x19660f[_0x1f64('0x22')]],'as':_0x19660f['as'],'attributes':_0x19660f['attributes'],'include':_0x19660f['include']?_['map'](_0x19660f[_0x1f64('0x21')],function(_0xf9da63){return{'model':db[_0xf9da63[_0x1f64('0x22')]],'as':_0xf9da63['as'],'attributes':_0xf9da63[_0x1f64('0x1f')]};}):[]};}):[]};}):[]:[]})[_0x1f64('0x10')](function(_0x2ef604){logger[_0x1f64('0x11')](_0x1f64('0x19'),_0x12eadd);logger[_0x1f64('0x12')]('GetFaxAccount',_0x12eadd,JSON[_0x1f64('0x15')](_0x2ef604));_0x312189(_0x2ef604);})['catch'](function(_0x1b52c){logger[_0x1f64('0x16')](_0x1f64('0x19'),_0x1b52c[_0x1f64('0x23')],_0x12eadd);_0x2bd5d6(_0x1b744f[_0x1f64('0x16')](0x1f4,_0x1b52c['message']));});});};exports[_0x1f64('0x24')]=function(_0x4cf4c0,_0x574b38,_0x2bf856){var _0x5ace16=this;return new Promise(function(_0x55cdf8,_0x59ea7c){var _0xe629be={'body':_0x4cf4c0[_0x1f64('0x25')],'channel':_0x1f64('0x26')};var _0x1243cc=[];var _0x5e31d9=[];var _0xba687d={};return db[_0x1f64('0x27')][_0x1f64('0x28')]()[_0x1f64('0x10')](function(_0x2663cd){if(!_0x2663cd){throw new db[(_0x1f64('0x29'))][(_0x1f64('0x2a'))]('no\x20available\x20attributes');}_0x1243cc=_[_0x1f64('0x2b')](_[_0x1f64('0x2c')](_0x2663cd),[_0x1f64('0x2d'),_0x1f64('0x2e')]);_0x5e31d9=_[_0x1f64('0x2b')](_[_0x1f64('0x2c')](_0x2663cd),[_0x1f64('0x2d'),_0x1f64('0x2e'),'CompanyId','ListId']);if(_0x4cf4c0[_0x1f64('0x25')]['id']){delete _0x4cf4c0[_0x1f64('0x25')]['id'];}if(_[_0x1f64('0x2f')](_0x4cf4c0[_0x1f64('0x25')][_0x1f64('0x30')])){throw new db[(_0x1f64('0x29'))]['ValidationError']('from\x20is\x20mandatory');}if(_[_0x1f64('0x2f')](_0x4cf4c0['body'][_0x1f64('0x25')])||_0x4cf4c0[_0x1f64('0x25')][_0x1f64('0x25')]===''){throw new db[(_0x1f64('0x29'))][(_0x1f64('0x2a'))](_0x1f64('0x31'));}if(_[_0x1f64('0x2f')](_0x4cf4c0['body'][_0x1f64('0x32')])){throw new db[(_0x1f64('0x29'))][(_0x1f64('0x2a'))](_0x1f64('0x33')+_0x5e31d9);}if(!_[_0x1f64('0x34')](_0x5e31d9,_0x4cf4c0[_0x1f64('0x25')]['mapKey'])){throw new db[(_0x1f64('0x29'))][(_0x1f64('0x2a'))](_0x1f64('0x35')+_0x5e31d9);}_0xba687d[_0x4cf4c0[_0x1f64('0x25')]['mapKey']]=_0x4cf4c0['body']['from'];})['then'](function(){return db[_0x1f64('0x1a')]['find']({'where':{'id':_0x4cf4c0[_0x1f64('0x36')]['id']},'include':[{'model':db[_0x1f64('0x37')],'as':_0x1f64('0x38'),'include':[{'model':db[_0x1f64('0x27')],'as':_0x1f64('0x39'),'where':_0xba687d,'limit':0x1,'order':[[_0x1f64('0x2e'),'DESC']]}]},{'model':db[_0x1f64('0x3a')],'as':'Applications'}]});})[_0x1f64('0x10')](function(_0x40bd6b){if(_0x40bd6b&&_0x40bd6b['List']){var _0x3c3b25=_0x40bd6b[_0x1f64('0x3b')]({'plain':!![]});_0xe629be[_0x1f64('0x36')]=_0x3c3b25;_0xe629be['applications']=_0x3c3b25[_0x1f64('0x3c')];_0xe629be[_0x1f64('0x3d')]=_0x3c3b25[_0x1f64('0x38')];_0xe629be['applications']=_['orderBy'](_0xe629be[_0x1f64('0x3e')],[_0x1f64('0x3f')],[_0x1f64('0x40')]);if(_0xe629be[_0x1f64('0x36')][_0x1f64('0x3c')]){delete _0xe629be[_0x1f64('0x36')][_0x1f64('0x3c')];}if(_0xe629be['account'][_0x1f64('0x38')]&&_0xe629be[_0x1f64('0x36')][_0x1f64('0x38')]['Contacts'][_0x1f64('0x41')]){return _0xe629be[_0x1f64('0x36')]['List']['Contacts'][0x0];}var _0x258804=_[_0x1f64('0x42')](_0x4cf4c0[_0x1f64('0x25')],{'firstName':_0x4cf4c0['body'][_0x1f64('0x30')],'ListId':_0x3c3b25[_0x1f64('0x43')]});_0x258804[_0x4cf4c0[_0x1f64('0x25')][_0x1f64('0x32')]]=_0x4cf4c0[_0x1f64('0x25')][_0x1f64('0x30')];return db[_0x1f64('0x27')]['create'](_0x258804,{'fields':_0x1243cc,'raw':!![]});}})[_0x1f64('0x10')](function(_0x18917e){_0xe629be[_0x1f64('0x44')]=_0x18917e;if(_0x18917e){var _0x293900={'ContactId':_0x18917e['id'],'FaxAccountId':_0x4cf4c0['account']['id'],'fax':_0x18917e[_0x1f64('0x26')]};return db[_0x1f64('0x45')][_0x1f64('0x46')]({'where':{'ContactId':_0x18917e['id'],'closed':![],'FaxAccountId':_0x4cf4c0[_0x1f64('0x36')]['id']}})[_0x1f64('0x10')](function(_0x3abe67){if(_0x3abe67){return[_0x3abe67,![]];}return db[_0x1f64('0x45')][_0x1f64('0x47')](_0x293900)[_0x1f64('0x10')](function(_0x2abefe){return[_0x2abefe,!![]];});});}else{throw new Error(_0x1f64('0x48'));}})[_0x1f64('0x49')](function(_0x1ec2b9,_0x521afb){var _0x16ece8=_0x1ec2b9[_0x1f64('0x3b')]({'plain':!![]});if(_0x521afb){if(_0xe629be[_0x1f64('0x36')][_0x1f64('0x4a')]){_0xe629be[_0x1f64('0x3e')][_0x1f64('0x4b')]({'id':0x0,'priority':_0xe629be[_0x1f64('0x3e')][_0x1f64('0x41')]+0x1,'app':_0x1f64('0x4c'),'appdata':_0x1f64('0x4d'),'interval':'*,*,*,*'});}_0x16ece8[_0x1f64('0x4e')]=!![];}else{_0x16ece8[_0x1f64('0x4e')]=![];}_0xe629be[_0x1f64('0x4f')]=_0x16ece8;return db[_0x1f64('0x50')][_0x1f64('0x47')]({'body':_0x4cf4c0[_0x1f64('0x25')][_0x1f64('0x25')],'FaxAccountId':_0x4cf4c0[_0x1f64('0x36')]['id'],'FaxInteractionId':_0x1ec2b9['id'],'direction':'in','ContactId':_0x1ec2b9[_0x1f64('0x51')],'AttachmentId':_0x4cf4c0[_0x1f64('0x25')][_0x1f64('0x52')]});})[_0x1f64('0x10')](function(_0xca1035){_0xe629be[_0x1f64('0x23')]=_0xca1035;if(_0xe629be['interaction'][_0x1f64('0x53')]){return db[_0x1f64('0x54')][_0x1f64('0x46')]({'attributes':['id',_0x1f64('0x55')],'where':{'id':_0xe629be[_0x1f64('0x4f')][_0x1f64('0x53')]}})[_0x1f64('0x10')](function(_0x5e97c1){if(_0x5e97c1){_0xe629be[_0x1f64('0x3e')][_0x1f64('0x56')]({'id':0x0,'priority':0x0,'app':_0x1f64('0x57'),'appdata':_0x5e97c1[_0x1f64('0x55')]+','+(_0xe629be['account']['waitForTheAssignedAgent']||0xa),'interval':_0x1f64('0x58')});}return respondWithRpcPromise(_0x1f64('0x59'),_0x1f64('0x5a'),_0xe629be);});}return respondWithRpcPromise(_0x1f64('0x59'),_0x1f64('0x5a'),_0xe629be);})[_0x1f64('0x10')](function(_0x892401){_0x55cdf8(_0x892401);})[_0x1f64('0x5b')](function(_0x282e4b){_0x59ea7c(_0x5ace16[_0x1f64('0x16')](0x1f4,_0x282e4b['message']));});});};
\ No newline at end of file
+var _0x5716=['attributes','limit','include','model','map','body','fax','CmContact','ValidationError','no\x20available\x20attributes','difference','keys','createdAt','updatedAt','CompanyId','ListId','from','Sequelize','from\x20is\x20mandatory','isNil','mapKey','mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','includes','mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','find','account','CmList','DESC','FaxApplication','get','applications','Applications','list','List','priority','asc','Contacts','length','contact','FaxInteraction','create','Contact\x20not\x20found','autoclose','close','unmanaged','created','interaction','FaxMessage','ContactId','AttachmentId','UserId','User','unshift','agent','name','waitForTheAssignedAgent','*,*,*,*','startRouting','Start','lodash','util','moment','ioredis','../../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','stringify','error','code','message','result','catch','GetFaxAccount','FaxAccount','findAll','options','where'];(function(_0x2c83b0,_0x2efc38){var _0x1470a0=function(_0x28b8e8){while(--_0x28b8e8){_0x2c83b0['push'](_0x2c83b0['shift']());}};_0x1470a0(++_0x2efc38);}(_0x5716,0x97));var _0x6571=function(_0x30bd4d,_0x50eb60){_0x30bd4d=_0x30bd4d-0x0;var _0x306915=_0x5716[_0x30bd4d];return _0x306915;};'use strict';var _=require(_0x6571('0x0'));var util=require(_0x6571('0x1'));var moment=require(_0x6571('0x2'));var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x6571('0x3'));var db=require(_0x6571('0x4'))['db'];var utils=require(_0x6571('0x5'));var logger=require(_0x6571('0x6'))('rpc');var config=require(_0x6571('0x7'));var jayson=require(_0x6571('0x8'));var client=jayson[_0x6571('0x9')]['http']({'port':0x232c});config['redis']=_[_0x6571('0xa')](config[_0x6571('0xb')],{'host':_0x6571('0xc'),'port':0x18eb});var socket=require(_0x6571('0xd'))(new Redis(config[_0x6571('0xb')]));require(_0x6571('0xe'))[_0x6571('0xf')](socket);function respondWithRpcPromise(_0xdfa02d,_0x2bbd12,_0x15f693){return new BPromise(function(_0x2413ee,_0x53ae1d){return client[_0x6571('0x10')](_0xdfa02d,_0x15f693)[_0x6571('0x11')](function(_0x54b3b0){logger[_0x6571('0x12')](_0x6571('0x13'),_0x2bbd12,_0x6571('0x14'));logger[_0x6571('0x15')]('FaxAccount,\x20%s,\x20%s,\x20%s',_0x2bbd12,'request\x20sent',JSON[_0x6571('0x16')](_0x54b3b0));if(_0x54b3b0[_0x6571('0x17')]){if(_0x54b3b0[_0x6571('0x17')][_0x6571('0x18')]===0x1f4){logger['error'](_0x6571('0x13'),_0x2bbd12,_0x54b3b0[_0x6571('0x17')]['message']);return _0x53ae1d(_0x54b3b0[_0x6571('0x17')]['message']);}logger[_0x6571('0x17')]('FaxAccount,\x20%s,\x20%s',_0x2bbd12,_0x54b3b0[_0x6571('0x17')][_0x6571('0x19')]);return _0x2413ee(_0x54b3b0[_0x6571('0x17')][_0x6571('0x19')]);}else{logger['info'](_0x6571('0x13'),_0x2bbd12,_0x6571('0x14'));_0x2413ee(_0x54b3b0[_0x6571('0x1a')][_0x6571('0x19')]);}})[_0x6571('0x1b')](function(_0x39d910){logger[_0x6571('0x17')]('FaxAccount,\x20%s,\x20%s',_0x2bbd12,_0x39d910);_0x53ae1d(_0x39d910);});});}exports[_0x6571('0x1c')]=function(_0x1ac3e2){var _0x6c6d97=this;return new Promise(function(_0x482754,_0x5cb1f4){return db[_0x6571('0x1d')][_0x6571('0x1e')]({'raw':_0x1ac3e2[_0x6571('0x1f')]?_0x1ac3e2['options']['raw']===undefined?!![]:![]:!![],'where':_0x1ac3e2[_0x6571('0x1f')]?_0x1ac3e2[_0x6571('0x1f')][_0x6571('0x20')]||null:null,'attributes':_0x1ac3e2[_0x6571('0x1f')]?_0x1ac3e2['options'][_0x6571('0x21')]||null:null,'limit':_0x1ac3e2['options']?_0x1ac3e2[_0x6571('0x1f')][_0x6571('0x22')]||null:null,'include':_0x1ac3e2[_0x6571('0x1f')]?_0x1ac3e2[_0x6571('0x1f')][_0x6571('0x23')]?_['map'](_0x1ac3e2[_0x6571('0x1f')][_0x6571('0x23')],function(_0x41059d){return{'model':db[_0x41059d[_0x6571('0x24')]],'as':_0x41059d['as'],'attributes':_0x41059d[_0x6571('0x21')],'include':_0x41059d['include']?_[_0x6571('0x25')](_0x41059d[_0x6571('0x23')],function(_0x400a50){return{'model':db[_0x400a50[_0x6571('0x24')]],'as':_0x400a50['as'],'attributes':_0x400a50[_0x6571('0x21')],'include':_0x400a50[_0x6571('0x23')]?_['map'](_0x400a50[_0x6571('0x23')],function(_0x382a7d){return{'model':db[_0x382a7d[_0x6571('0x24')]],'as':_0x382a7d['as'],'attributes':_0x382a7d[_0x6571('0x21')]};}):[]};}):[]};}):[]:[]})[_0x6571('0x11')](function(_0x34a2c1){logger[_0x6571('0x12')](_0x6571('0x1c'),_0x1ac3e2);logger[_0x6571('0x15')](_0x6571('0x1c'),_0x1ac3e2,JSON[_0x6571('0x16')](_0x34a2c1));_0x482754(_0x34a2c1);})[_0x6571('0x1b')](function(_0x5c6843){logger[_0x6571('0x17')](_0x6571('0x1c'),_0x5c6843['message'],_0x1ac3e2);_0x5cb1f4(_0x6c6d97[_0x6571('0x17')](0x1f4,_0x5c6843[_0x6571('0x19')]));});});};exports['NotifyFaxAccount']=function(_0x4618e0,_0x41036a,_0x5743a6){var _0x63a921=this;return new Promise(function(_0x3ec770,_0x4e962f){var _0x381897={'body':_0x4618e0[_0x6571('0x26')],'channel':_0x6571('0x27')};var _0xba886=[];var _0xf9d3cc=[];var _0x1ab647={};return db[_0x6571('0x28')]['describe']()[_0x6571('0x11')](function(_0x57e115){if(!_0x57e115){throw new db['Sequelize'][(_0x6571('0x29'))](_0x6571('0x2a'));}_0xba886=_[_0x6571('0x2b')](_[_0x6571('0x2c')](_0x57e115),[_0x6571('0x2d'),_0x6571('0x2e')]);_0xf9d3cc=_[_0x6571('0x2b')](_[_0x6571('0x2c')](_0x57e115),[_0x6571('0x2d'),_0x6571('0x2e'),_0x6571('0x2f'),_0x6571('0x30')]);if(_0x4618e0['body']['id']){delete _0x4618e0['body']['id'];}if(_['isNil'](_0x4618e0[_0x6571('0x26')][_0x6571('0x31')])){throw new db[(_0x6571('0x32'))]['ValidationError'](_0x6571('0x33'));}if(_[_0x6571('0x34')](_0x4618e0[_0x6571('0x26')]['body'])||_0x4618e0[_0x6571('0x26')][_0x6571('0x26')]===''){throw new db[(_0x6571('0x32'))]['ValidationError']('body\x20is\x20mandatory\x20and\x20not\x20empty');}if(_['isNil'](_0x4618e0[_0x6571('0x26')][_0x6571('0x35')])){throw new db[(_0x6571('0x32'))][(_0x6571('0x29'))](_0x6571('0x36')+_0xf9d3cc);}if(!_[_0x6571('0x37')](_0xf9d3cc,_0x4618e0[_0x6571('0x26')][_0x6571('0x35')])){throw new db[(_0x6571('0x32'))][(_0x6571('0x29'))](_0x6571('0x38')+_0xf9d3cc);}_0x1ab647[_0x4618e0['body']['mapKey']]=_0x4618e0[_0x6571('0x26')][_0x6571('0x31')];})['then'](function(){return db['FaxAccount'][_0x6571('0x39')]({'where':{'id':_0x4618e0[_0x6571('0x3a')]['id']},'include':[{'model':db[_0x6571('0x3b')],'as':'List','include':[{'model':db['CmContact'],'as':'Contacts','where':_0x1ab647,'limit':0x1,'order':[[_0x6571('0x2e'),_0x6571('0x3c')]]}]},{'model':db[_0x6571('0x3d')],'as':'Applications'}]});})['then'](function(_0x303cda){if(_0x303cda&&_0x303cda['List']){var _0x2c1285=_0x303cda[_0x6571('0x3e')]({'plain':!![]});_0x381897['account']=_0x2c1285;_0x381897[_0x6571('0x3f')]=_0x2c1285[_0x6571('0x40')];_0x381897[_0x6571('0x41')]=_0x2c1285[_0x6571('0x42')];_0x381897['applications']=_['orderBy'](_0x381897[_0x6571('0x3f')],[_0x6571('0x43')],[_0x6571('0x44')]);if(_0x381897['account'][_0x6571('0x40')]){delete _0x381897['account'][_0x6571('0x40')];}if(_0x381897['account']['List']&&_0x381897['account'][_0x6571('0x42')][_0x6571('0x45')][_0x6571('0x46')]){return _0x381897[_0x6571('0x3a')][_0x6571('0x42')]['Contacts'][0x0];}var _0x47aefa=_['defaults'](_0x4618e0['body'],{'firstName':_0x4618e0[_0x6571('0x26')][_0x6571('0x31')],'ListId':_0x2c1285[_0x6571('0x30')]});_0x47aefa[_0x4618e0[_0x6571('0x26')][_0x6571('0x35')]]=_0x4618e0[_0x6571('0x26')]['from'];return db[_0x6571('0x28')]['create'](_0x47aefa,{'fields':_0xba886,'raw':!![]});}})[_0x6571('0x11')](function(_0x5be6ac){_0x381897[_0x6571('0x47')]=_0x5be6ac;if(_0x5be6ac){var _0x5155df={'ContactId':_0x5be6ac['id'],'FaxAccountId':_0x4618e0[_0x6571('0x3a')]['id'],'fax':_0x5be6ac[_0x6571('0x27')]};return db[_0x6571('0x48')][_0x6571('0x39')]({'where':{'ContactId':_0x5be6ac['id'],'closed':![],'FaxAccountId':_0x4618e0[_0x6571('0x3a')]['id']}})['then'](function(_0x9003a1){if(_0x9003a1){return[_0x9003a1,![]];}return db[_0x6571('0x48')][_0x6571('0x49')](_0x5155df)[_0x6571('0x11')](function(_0x22643f){return[_0x22643f,!![]];});});}else{throw new Error(_0x6571('0x4a'));}})['spread'](function(_0x238d1b,_0x4b793f){var _0x386786=_0x238d1b[_0x6571('0x3e')]({'plain':!![]});if(_0x4b793f){if(_0x381897[_0x6571('0x3a')][_0x6571('0x4b')]){_0x381897[_0x6571('0x3f')]['push']({'id':0x0,'priority':_0x381897['applications']['length']+0x1,'app':_0x6571('0x4c'),'appdata':_0x6571('0x4d'),'interval':'*,*,*,*'});}_0x386786[_0x6571('0x4e')]=!![];}else{_0x386786['created']=![];}_0x381897[_0x6571('0x4f')]=_0x386786;return db[_0x6571('0x50')][_0x6571('0x49')]({'body':_0x4618e0[_0x6571('0x26')]['body'],'FaxAccountId':_0x4618e0[_0x6571('0x3a')]['id'],'FaxInteractionId':_0x238d1b['id'],'direction':'in','ContactId':_0x238d1b[_0x6571('0x51')],'AttachmentId':_0x4618e0[_0x6571('0x26')][_0x6571('0x52')]});})[_0x6571('0x11')](function(_0x1f5c95){_0x381897[_0x6571('0x19')]=_0x1f5c95;if(_0x381897['interaction'][_0x6571('0x53')]){return db[_0x6571('0x54')][_0x6571('0x39')]({'attributes':['id','name'],'where':{'id':_0x381897[_0x6571('0x4f')]['UserId']}})['then'](function(_0x1ffe99){if(_0x1ffe99){_0x381897['applications'][_0x6571('0x55')]({'id':0x0,'priority':0x0,'app':_0x6571('0x56'),'appdata':_0x1ffe99[_0x6571('0x57')]+','+(_0x381897[_0x6571('0x3a')][_0x6571('0x58')]||0xa),'interval':_0x6571('0x59')});}return respondWithRpcPromise('Start',_0x6571('0x5a'),_0x381897);});}return respondWithRpcPromise(_0x6571('0x5b'),_0x6571('0x5a'),_0x381897);})[_0x6571('0x11')](function(_0x124d72){_0x3ec770(_0x124d72);})[_0x6571('0x1b')](function(_0x2db5a0){_0x4e962f(_0x63a921[_0x6571('0x17')](0x1f4,_0x2db5a0[_0x6571('0x19')]));});});};
\ No newline at end of file