Built motion from commit e1760111.|2.6.18
[motion2.git] / server / api / faxAccount / faxAccount.rpc.js
index 6ec1a4f..1600aa7 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x250a=['describe','Sequelize','ValidationError','no\x20available\x20attributes','difference','keys','createdAt','updatedAt','CompanyId','from','from\x20is\x20mandatory','isNil','body\x20is\x20mandatory\x20and\x20not\x20empty','mapKey','includes','mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','find','account','CmList','Contacts','DESC','Applications','List','get','list','applications','orderBy','priority','asc','ListId','FaxInteraction','create','spread','autoclose','push','close','unmanaged','*,*,*,*','created','FaxMessage','AttachmentId','interaction','UserId','User','name','unshift','waitForTheAssignedAgent','Start','startRouting','moment','bluebird','randomstring','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','http','redis','defaults','localhost','./faxAccount.socket','register','then','FaxAccount,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code','message','info','result','catch','GetFaxAccount','findAll','options','where','attributes','limit','include','map','model','NotifyFaxAccount','body','fax','CmContact'];(function(_0x451130,_0x595ee2){var _0x68c08e=function(_0x23fe84){while(--_0x23fe84){_0x451130['push'](_0x451130['shift']());}};_0x68c08e(++_0x595ee2);}(_0x250a,0x18d));var _0xa250=function(_0xb0f7c3,_0x4eae95){_0xb0f7c3=_0xb0f7c3-0x0;var _0x28ea68=_0x250a[_0xb0f7c3];return _0x28ea68;};'use strict';var _=require('lodash');var util=require('util');var moment=require(_0xa250('0x0'));var BPromise=require(_0xa250('0x1'));var rs=require(_0xa250('0x2'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0xa250('0x3'))['db'];var utils=require(_0xa250('0x4'));var logger=require(_0xa250('0x5'))(_0xa250('0x6'));var config=require('../../config/environment');var jayson=require(_0xa250('0x7'));var client=jayson['client'][_0xa250('0x8')]({'port':0x232c});config[_0xa250('0x9')]=_[_0xa250('0xa')](config[_0xa250('0x9')],{'host':_0xa250('0xb'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xa250('0x9')]));require(_0xa250('0xc'))[_0xa250('0xd')](socket);function respondWithRpcPromise(_0x4d6e19,_0x577f3b,_0xb95704){return new BPromise(function(_0xaa0b40,_0x4bff74){return client['request'](_0x4d6e19,_0xb95704)[_0xa250('0xe')](function(_0x2843fa){logger['info'](_0xa250('0xf'),_0x577f3b,_0xa250('0x10'));logger[_0xa250('0x11')]('FaxAccount,\x20%s,\x20%s,\x20%s',_0x577f3b,'request\x20sent',JSON[_0xa250('0x12')](_0x2843fa));if(_0x2843fa[_0xa250('0x13')]){if(_0x2843fa[_0xa250('0x13')][_0xa250('0x14')]===0x1f4){logger[_0xa250('0x13')](_0xa250('0xf'),_0x577f3b,_0x2843fa[_0xa250('0x13')][_0xa250('0x15')]);return _0x4bff74(_0x2843fa[_0xa250('0x13')][_0xa250('0x15')]);}logger[_0xa250('0x13')](_0xa250('0xf'),_0x577f3b,_0x2843fa['error'][_0xa250('0x15')]);return _0xaa0b40(_0x2843fa[_0xa250('0x13')][_0xa250('0x15')]);}else{logger[_0xa250('0x16')](_0xa250('0xf'),_0x577f3b,'request\x20sent');_0xaa0b40(_0x2843fa[_0xa250('0x17')]['message']);}})[_0xa250('0x18')](function(_0x3fb569){logger['error'](_0xa250('0xf'),_0x577f3b,_0x3fb569);_0x4bff74(_0x3fb569);});});}exports[_0xa250('0x19')]=function(_0x2004d1){var _0x140759=this;return new Promise(function(_0x240b12,_0x57c710){return db['FaxAccount'][_0xa250('0x1a')]({'raw':_0x2004d1[_0xa250('0x1b')]?_0x2004d1[_0xa250('0x1b')]['raw']===undefined?!![]:![]:!![],'where':_0x2004d1[_0xa250('0x1b')]?_0x2004d1['options'][_0xa250('0x1c')]||null:null,'attributes':_0x2004d1[_0xa250('0x1b')]?_0x2004d1[_0xa250('0x1b')][_0xa250('0x1d')]||null:null,'limit':_0x2004d1['options']?_0x2004d1[_0xa250('0x1b')][_0xa250('0x1e')]||null:null,'include':_0x2004d1[_0xa250('0x1b')]?_0x2004d1['options'][_0xa250('0x1f')]?_[_0xa250('0x20')](_0x2004d1[_0xa250('0x1b')][_0xa250('0x1f')],function(_0x7122a5){return{'model':db[_0x7122a5[_0xa250('0x21')]],'as':_0x7122a5['as'],'attributes':_0x7122a5['attributes'],'include':_0x7122a5['include']?_[_0xa250('0x20')](_0x7122a5[_0xa250('0x1f')],function(_0x397fcd){return{'model':db[_0x397fcd[_0xa250('0x21')]],'as':_0x397fcd['as'],'attributes':_0x397fcd[_0xa250('0x1d')],'include':_0x397fcd[_0xa250('0x1f')]?_[_0xa250('0x20')](_0x397fcd[_0xa250('0x1f')],function(_0x4d66a8){return{'model':db[_0x4d66a8['model']],'as':_0x4d66a8['as'],'attributes':_0x4d66a8[_0xa250('0x1d')]};}):[]};}):[]};}):[]:[]})['then'](function(_0xf334dd){logger[_0xa250('0x16')](_0xa250('0x19'),_0x2004d1);logger[_0xa250('0x11')](_0xa250('0x19'),_0x2004d1,JSON[_0xa250('0x12')](_0xf334dd));_0x240b12(_0xf334dd);})['catch'](function(_0x597eaa){logger[_0xa250('0x13')](_0xa250('0x19'),_0x597eaa['message'],_0x2004d1);_0x57c710(_0x140759[_0xa250('0x13')](0x1f4,_0x597eaa[_0xa250('0x15')]));});});};exports[_0xa250('0x22')]=function(_0x150357,_0x2fb070,_0x2f1be9){var _0x1903e6=this;return new Promise(function(_0x3e419c,_0x2a241c){var _0x9211f0={'body':_0x150357[_0xa250('0x23')],'channel':_0xa250('0x24')};var _0x375d85=[];var _0x28e907=[];var _0x2e5fc3={};return db[_0xa250('0x25')][_0xa250('0x26')]()['then'](function(_0x5dc357){if(!_0x5dc357){throw new db[(_0xa250('0x27'))][(_0xa250('0x28'))](_0xa250('0x29'));}_0x375d85=_[_0xa250('0x2a')](_[_0xa250('0x2b')](_0x5dc357),[_0xa250('0x2c'),'updatedAt']);_0x28e907=_['difference'](_[_0xa250('0x2b')](_0x5dc357),[_0xa250('0x2c'),_0xa250('0x2d'),_0xa250('0x2e'),'ListId']);if(_0x150357['body']['id']){delete _0x150357['body']['id'];}if(_['isNil'](_0x150357[_0xa250('0x23')][_0xa250('0x2f')])){throw new db[(_0xa250('0x27'))][(_0xa250('0x28'))](_0xa250('0x30'));}if(_[_0xa250('0x31')](_0x150357[_0xa250('0x23')][_0xa250('0x23')])||_0x150357['body']['body']===''){throw new db['Sequelize'][(_0xa250('0x28'))](_0xa250('0x32'));}if(_[_0xa250('0x31')](_0x150357[_0xa250('0x23')][_0xa250('0x33')])){throw new db[(_0xa250('0x27'))][(_0xa250('0x28'))]('mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20'+_0x28e907);}if(!_[_0xa250('0x34')](_0x28e907,_0x150357['body'][_0xa250('0x33')])){throw new db[(_0xa250('0x27'))][(_0xa250('0x28'))](_0xa250('0x35')+_0x28e907);}_0x2e5fc3[_0x150357[_0xa250('0x23')][_0xa250('0x33')]]=_0x150357[_0xa250('0x23')][_0xa250('0x2f')];})[_0xa250('0xe')](function(){return db['FaxAccount'][_0xa250('0x36')]({'where':{'id':_0x150357[_0xa250('0x37')]['id']},'include':[{'model':db[_0xa250('0x38')],'as':'List','include':[{'model':db[_0xa250('0x25')],'as':_0xa250('0x39'),'where':_0x2e5fc3,'limit':0x1,'order':[[_0xa250('0x2d'),_0xa250('0x3a')]]}]},{'model':db['FaxApplication'],'as':_0xa250('0x3b')}]});})[_0xa250('0xe')](function(_0x312429){if(_0x312429&&_0x312429[_0xa250('0x3c')]){var _0x2ec2ab=_0x312429[_0xa250('0x3d')]({'plain':!![]});_0x9211f0[_0xa250('0x37')]=_0x2ec2ab;_0x9211f0['applications']=_0x2ec2ab[_0xa250('0x3b')];_0x9211f0[_0xa250('0x3e')]=_0x2ec2ab[_0xa250('0x3c')];_0x9211f0[_0xa250('0x3f')]=_[_0xa250('0x40')](_0x9211f0[_0xa250('0x3f')],[_0xa250('0x41')],[_0xa250('0x42')]);if(_0x9211f0[_0xa250('0x37')][_0xa250('0x3b')]){delete _0x9211f0[_0xa250('0x37')]['Applications'];}if(_0x9211f0[_0xa250('0x37')][_0xa250('0x3c')]&&_0x9211f0[_0xa250('0x37')][_0xa250('0x3c')][_0xa250('0x39')]['length']){return _0x9211f0['account'][_0xa250('0x3c')][_0xa250('0x39')][0x0];}var _0x16b7d0=_['defaults'](_0x150357[_0xa250('0x23')],{'firstName':_0x150357['body']['from'],'ListId':_0x2ec2ab[_0xa250('0x43')]});_0x16b7d0[_0x150357[_0xa250('0x23')]['mapKey']]=_0x150357['body'][_0xa250('0x2f')];return db['CmContact']['create'](_0x16b7d0,{'fields':_0x375d85,'raw':!![]});}})[_0xa250('0xe')](function(_0x565f2a){_0x9211f0['contact']=_0x565f2a;if(_0x565f2a){var _0x266746={'ContactId':_0x565f2a['id'],'FaxAccountId':_0x150357[_0xa250('0x37')]['id'],'fax':_0x565f2a[_0xa250('0x24')]};return db[_0xa250('0x44')]['find']({'where':{'ContactId':_0x565f2a['id'],'closed':![],'FaxAccountId':_0x150357[_0xa250('0x37')]['id']}})['then'](function(_0x5f582b){if(_0x5f582b){return[_0x5f582b,![]];}return db['FaxInteraction'][_0xa250('0x45')](_0x266746)[_0xa250('0xe')](function(_0xbc6940){return[_0xbc6940,!![]];});});}else{throw new Error('Contact\x20not\x20found');}})[_0xa250('0x46')](function(_0x25a4f3,_0x1af033){var _0x5cb567=_0x25a4f3[_0xa250('0x3d')]({'plain':!![]});if(_0x1af033){if(_0x9211f0[_0xa250('0x37')][_0xa250('0x47')]){_0x9211f0[_0xa250('0x3f')][_0xa250('0x48')]({'id':0x0,'priority':_0x9211f0[_0xa250('0x3f')]['length']+0x1,'app':_0xa250('0x49'),'appdata':_0xa250('0x4a'),'interval':_0xa250('0x4b')});}_0x5cb567['created']=!![];}else{_0x5cb567[_0xa250('0x4c')]=![];}_0x9211f0['interaction']=_0x5cb567;return db[_0xa250('0x4d')]['create']({'body':_0x150357[_0xa250('0x23')][_0xa250('0x23')],'FaxAccountId':_0x150357['account']['id'],'FaxInteractionId':_0x25a4f3['id'],'direction':'in','ContactId':_0x25a4f3['ContactId'],'AttachmentId':_0x150357[_0xa250('0x23')][_0xa250('0x4e')]});})[_0xa250('0xe')](function(_0x226d9f){_0x9211f0[_0xa250('0x15')]=_0x226d9f;if(_0x9211f0[_0xa250('0x4f')][_0xa250('0x50')]){return db[_0xa250('0x51')][_0xa250('0x36')]({'attributes':['id',_0xa250('0x52')],'where':{'id':_0x9211f0[_0xa250('0x4f')][_0xa250('0x50')]}})[_0xa250('0xe')](function(_0x2b0e8a){if(_0x2b0e8a){_0x9211f0[_0xa250('0x3f')][_0xa250('0x53')]({'id':0x0,'priority':0x0,'app':'agent','appdata':_0x2b0e8a[_0xa250('0x52')]+','+(_0x9211f0['account'][_0xa250('0x54')]||0xa),'interval':_0xa250('0x4b')});}return respondWithRpcPromise(_0xa250('0x55'),'startRouting',_0x9211f0);});}return respondWithRpcPromise('Start',_0xa250('0x56'),_0x9211f0);})[_0xa250('0xe')](function(_0x4e1204){_0x3e419c(_0x4e1204);})['catch'](function(_0x5e5a36){_0x2a241c(_0x1903e6['error'](0x1f4,_0x5e5a36[_0xa250('0x15')]));});});};
\ No newline at end of file
+var _0x6bf3=['from\x20is\x20mandatory','isNil','mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','includes','mapKey','find','CmList','List','Contacts','DESC','FaxApplication','Applications','get','account','applications','orderBy','priority','asc','length','create','contact','Contact\x20not\x20found','spread','push','close','unmanaged','created','interaction','AttachmentId','User','name','unshift','agent','waitForTheAssignedAgent','*,*,*,*','startRouting','Start','lodash','util','ioredis','../../config/utils','../../config/logger','rpc','../../config/environment','client','http','redis','defaults','localhost','socket.io-emitter','./faxAccount.socket','register','request','then','info','FaxAccount,\x20%s,\x20%s','debug','FaxAccount,\x20%s,\x20%s,\x20%s','request\x20sent','error','message','result','GetFaxAccount','findAll','options','attributes','limit','include','map','stringify','catch','body','fax','CmContact','describe','Sequelize','ValidationError','no\x20available\x20attributes','difference','createdAt','updatedAt','CompanyId','ListId','from'];(function(_0x138adb,_0x193fee){var _0x1b27f2=function(_0x5e97a2){while(--_0x5e97a2){_0x138adb['push'](_0x138adb['shift']());}};_0x1b27f2(++_0x193fee);}(_0x6bf3,0x1c9));var _0x36bf=function(_0x4734a0,_0x2fd639){_0x4734a0=_0x4734a0-0x0;var _0x4d02b0=_0x6bf3[_0x4734a0];return _0x4d02b0;};'use strict';var _=require(_0x36bf('0x0'));var util=require(_0x36bf('0x1'));var moment=require('moment');var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x36bf('0x2'));var db=require('../../mysqldb')['db'];var utils=require(_0x36bf('0x3'));var logger=require(_0x36bf('0x4'))(_0x36bf('0x5'));var config=require(_0x36bf('0x6'));var jayson=require('jayson/promise');var client=jayson[_0x36bf('0x7')][_0x36bf('0x8')]({'port':0x232c});config[_0x36bf('0x9')]=_[_0x36bf('0xa')](config[_0x36bf('0x9')],{'host':_0x36bf('0xb'),'port':0x18eb});var socket=require(_0x36bf('0xc'))(new Redis(config[_0x36bf('0x9')]));require(_0x36bf('0xd'))[_0x36bf('0xe')](socket);function respondWithRpcPromise(_0x8ef6bf,_0x5301cd,_0x2ebffc){return new BPromise(function(_0x196a8f,_0x5a1599){return client[_0x36bf('0xf')](_0x8ef6bf,_0x2ebffc)[_0x36bf('0x10')](function(_0x1f7855){logger[_0x36bf('0x11')](_0x36bf('0x12'),_0x5301cd,'request\x20sent');logger[_0x36bf('0x13')](_0x36bf('0x14'),_0x5301cd,_0x36bf('0x15'),JSON['stringify'](_0x1f7855));if(_0x1f7855[_0x36bf('0x16')]){if(_0x1f7855['error']['code']===0x1f4){logger[_0x36bf('0x16')](_0x36bf('0x12'),_0x5301cd,_0x1f7855['error'][_0x36bf('0x17')]);return _0x5a1599(_0x1f7855[_0x36bf('0x16')][_0x36bf('0x17')]);}logger[_0x36bf('0x16')](_0x36bf('0x12'),_0x5301cd,_0x1f7855[_0x36bf('0x16')][_0x36bf('0x17')]);return _0x196a8f(_0x1f7855[_0x36bf('0x16')][_0x36bf('0x17')]);}else{logger[_0x36bf('0x11')](_0x36bf('0x12'),_0x5301cd,'request\x20sent');_0x196a8f(_0x1f7855[_0x36bf('0x18')][_0x36bf('0x17')]);}})['catch'](function(_0x567d41){logger[_0x36bf('0x16')](_0x36bf('0x12'),_0x5301cd,_0x567d41);_0x5a1599(_0x567d41);});});}exports[_0x36bf('0x19')]=function(_0x2943b0){var _0x415213=this;return new Promise(function(_0x3eab27,_0x28c80c){return db['FaxAccount'][_0x36bf('0x1a')]({'raw':_0x2943b0['options']?_0x2943b0[_0x36bf('0x1b')]['raw']===undefined?!![]:![]:!![],'where':_0x2943b0['options']?_0x2943b0['options']['where']||null:null,'attributes':_0x2943b0[_0x36bf('0x1b')]?_0x2943b0[_0x36bf('0x1b')][_0x36bf('0x1c')]||null:null,'limit':_0x2943b0[_0x36bf('0x1b')]?_0x2943b0[_0x36bf('0x1b')][_0x36bf('0x1d')]||null:null,'include':_0x2943b0['options']?_0x2943b0[_0x36bf('0x1b')][_0x36bf('0x1e')]?_[_0x36bf('0x1f')](_0x2943b0[_0x36bf('0x1b')]['include'],function(_0x207c00){return{'model':db[_0x207c00['model']],'as':_0x207c00['as'],'attributes':_0x207c00[_0x36bf('0x1c')],'include':_0x207c00[_0x36bf('0x1e')]?_[_0x36bf('0x1f')](_0x207c00[_0x36bf('0x1e')],function(_0x5c4cf5){return{'model':db[_0x5c4cf5['model']],'as':_0x5c4cf5['as'],'attributes':_0x5c4cf5[_0x36bf('0x1c')],'include':_0x5c4cf5['include']?_[_0x36bf('0x1f')](_0x5c4cf5['include'],function(_0x5b8ea1){return{'model':db[_0x5b8ea1['model']],'as':_0x5b8ea1['as'],'attributes':_0x5b8ea1[_0x36bf('0x1c')]};}):[]};}):[]};}):[]:[]})[_0x36bf('0x10')](function(_0x2d1b40){logger[_0x36bf('0x11')]('GetFaxAccount',_0x2943b0);logger['debug'](_0x36bf('0x19'),_0x2943b0,JSON[_0x36bf('0x20')](_0x2d1b40));_0x3eab27(_0x2d1b40);})[_0x36bf('0x21')](function(_0x284cc7){logger[_0x36bf('0x16')](_0x36bf('0x19'),_0x284cc7['message'],_0x2943b0);_0x28c80c(_0x415213[_0x36bf('0x16')](0x1f4,_0x284cc7[_0x36bf('0x17')]));});});};exports['NotifyFaxAccount']=function(_0x29c938,_0x1c79ad,_0x5e0121){var _0x12d5c0=this;return new Promise(function(_0xf376bf,_0x16dda3){var _0x43607d={'body':_0x29c938[_0x36bf('0x22')],'channel':_0x36bf('0x23')};var _0x4179ab=[];var _0x3334cc=[];var _0x510cab={};return db[_0x36bf('0x24')][_0x36bf('0x25')]()[_0x36bf('0x10')](function(_0x10d3af){if(!_0x10d3af){throw new db[(_0x36bf('0x26'))][(_0x36bf('0x27'))](_0x36bf('0x28'));}_0x4179ab=_[_0x36bf('0x29')](_['keys'](_0x10d3af),[_0x36bf('0x2a'),_0x36bf('0x2b')]);_0x3334cc=_['difference'](_['keys'](_0x10d3af),[_0x36bf('0x2a'),_0x36bf('0x2b'),_0x36bf('0x2c'),_0x36bf('0x2d')]);if(_0x29c938[_0x36bf('0x22')]['id']){delete _0x29c938[_0x36bf('0x22')]['id'];}if(_['isNil'](_0x29c938[_0x36bf('0x22')][_0x36bf('0x2e')])){throw new db['Sequelize'][(_0x36bf('0x27'))](_0x36bf('0x2f'));}if(_[_0x36bf('0x30')](_0x29c938[_0x36bf('0x22')][_0x36bf('0x22')])||_0x29c938[_0x36bf('0x22')][_0x36bf('0x22')]===''){throw new db[(_0x36bf('0x26'))][(_0x36bf('0x27'))]('body\x20is\x20mandatory\x20and\x20not\x20empty');}if(_['isNil'](_0x29c938[_0x36bf('0x22')]['mapKey'])){throw new db['Sequelize'][(_0x36bf('0x27'))](_0x36bf('0x31')+_0x3334cc);}if(!_[_0x36bf('0x32')](_0x3334cc,_0x29c938['body'][_0x36bf('0x33')])){throw new db[(_0x36bf('0x26'))][(_0x36bf('0x27'))]('mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20'+_0x3334cc);}_0x510cab[_0x29c938[_0x36bf('0x22')][_0x36bf('0x33')]]=_0x29c938[_0x36bf('0x22')][_0x36bf('0x2e')];})[_0x36bf('0x10')](function(){return db['FaxAccount'][_0x36bf('0x34')]({'where':{'id':_0x29c938['account']['id']},'include':[{'model':db[_0x36bf('0x35')],'as':_0x36bf('0x36'),'include':[{'model':db['CmContact'],'as':_0x36bf('0x37'),'where':_0x510cab,'limit':0x1,'order':[[_0x36bf('0x2b'),_0x36bf('0x38')]]}]},{'model':db[_0x36bf('0x39')],'as':_0x36bf('0x3a')}]});})[_0x36bf('0x10')](function(_0x2e3340){if(_0x2e3340&&_0x2e3340[_0x36bf('0x36')]){var _0x29bab8=_0x2e3340[_0x36bf('0x3b')]({'plain':!![]});_0x43607d[_0x36bf('0x3c')]=_0x29bab8;_0x43607d[_0x36bf('0x3d')]=_0x29bab8[_0x36bf('0x3a')];_0x43607d['list']=_0x29bab8['List'];_0x43607d[_0x36bf('0x3d')]=_[_0x36bf('0x3e')](_0x43607d[_0x36bf('0x3d')],[_0x36bf('0x3f')],[_0x36bf('0x40')]);if(_0x43607d[_0x36bf('0x3c')][_0x36bf('0x3a')]){delete _0x43607d[_0x36bf('0x3c')]['Applications'];}if(_0x43607d[_0x36bf('0x3c')][_0x36bf('0x36')]&&_0x43607d[_0x36bf('0x3c')][_0x36bf('0x36')][_0x36bf('0x37')][_0x36bf('0x41')]){return _0x43607d['account'][_0x36bf('0x36')][_0x36bf('0x37')][0x0];}var _0x10408f=_[_0x36bf('0xa')](_0x29c938['body'],{'firstName':_0x29c938['body']['from'],'ListId':_0x29bab8[_0x36bf('0x2d')]});_0x10408f[_0x29c938[_0x36bf('0x22')][_0x36bf('0x33')]]=_0x29c938['body'][_0x36bf('0x2e')];return db[_0x36bf('0x24')][_0x36bf('0x42')](_0x10408f,{'fields':_0x4179ab,'raw':!![]});}})[_0x36bf('0x10')](function(_0x105870){_0x43607d[_0x36bf('0x43')]=_0x105870;if(_0x105870){var _0x384a33={'ContactId':_0x105870['id'],'FaxAccountId':_0x29c938[_0x36bf('0x3c')]['id'],'fax':_0x105870[_0x36bf('0x23')]};return db['FaxInteraction'][_0x36bf('0x34')]({'where':{'ContactId':_0x105870['id'],'closed':![],'FaxAccountId':_0x29c938[_0x36bf('0x3c')]['id']}})[_0x36bf('0x10')](function(_0x3188b7){if(_0x3188b7){return[_0x3188b7,![]];}return db['FaxInteraction'][_0x36bf('0x42')](_0x384a33)[_0x36bf('0x10')](function(_0x4a4f23){return[_0x4a4f23,!![]];});});}else{throw new Error(_0x36bf('0x44'));}})[_0x36bf('0x45')](function(_0x17eb65,_0x10f0d5){var _0x45ddba=_0x17eb65[_0x36bf('0x3b')]({'plain':!![]});if(_0x10f0d5){if(_0x43607d['account']['autoclose']){_0x43607d[_0x36bf('0x3d')][_0x36bf('0x46')]({'id':0x0,'priority':_0x43607d['applications'][_0x36bf('0x41')]+0x1,'app':_0x36bf('0x47'),'appdata':_0x36bf('0x48'),'interval':'*,*,*,*'});}_0x45ddba[_0x36bf('0x49')]=!![];}else{_0x45ddba[_0x36bf('0x49')]=![];}_0x43607d[_0x36bf('0x4a')]=_0x45ddba;return db['FaxMessage'][_0x36bf('0x42')]({'body':_0x29c938[_0x36bf('0x22')]['body'],'FaxAccountId':_0x29c938['account']['id'],'FaxInteractionId':_0x17eb65['id'],'direction':'in','ContactId':_0x17eb65['ContactId'],'AttachmentId':_0x29c938[_0x36bf('0x22')][_0x36bf('0x4b')]});})['then'](function(_0x590d17){_0x43607d[_0x36bf('0x17')]=_0x590d17;if(_0x43607d['interaction']['UserId']){return db[_0x36bf('0x4c')]['find']({'attributes':['id',_0x36bf('0x4d')],'where':{'id':_0x43607d[_0x36bf('0x4a')]['UserId']}})[_0x36bf('0x10')](function(_0x7852d4){if(_0x7852d4){_0x43607d[_0x36bf('0x3d')][_0x36bf('0x4e')]({'id':0x0,'priority':0x0,'app':_0x36bf('0x4f'),'appdata':_0x7852d4[_0x36bf('0x4d')]+','+(_0x43607d[_0x36bf('0x3c')][_0x36bf('0x50')]||0xa),'interval':_0x36bf('0x51')});}return respondWithRpcPromise('Start',_0x36bf('0x52'),_0x43607d);});}return respondWithRpcPromise(_0x36bf('0x53'),_0x36bf('0x52'),_0x43607d);})[_0x36bf('0x10')](function(_0x457554){_0xf376bf(_0x457554);})[_0x36bf('0x21')](function(_0x6b2427){_0x16dda3(_0x12d5c0['error'](0x1f4,_0x6b2427[_0x36bf('0x17')]));});});};
\ No newline at end of file