Built motion from commit 1ea47bf4.|2.6.34
[motion2.git] / server / api / faxAccount / faxAccount.rpc.js
index 9ced740..640e4e5 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xfd86=['Contact\x20not\x20found','spread','autoclose','push','close','unmanaged','*,*,*,*','created','interaction','ContactId','AttachmentId','UserId','User','unshift','agent','queueId','name','waitForTheAssignedQueue','Start','startRouting','lodash','util','moment','bluebird','ioredis','../../mysqldb','../../config/utils','rpc','jayson/promise','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','stringify','error','code','message','request\x20sent','result','catch','GetFaxAccount','FaxAccount','raw','options','where','attributes','limit','include','map','model','NotifyFaxAccount','body','CmContact','describe','Sequelize','ValidationError','no\x20available\x20attributes','difference','createdAt','updatedAt','keys','CompanyId','ListId','isNil','from','from\x20is\x20mandatory','mapKey','mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','account','CmList','List','DESC','FaxApplication','Applications','get','applications','list','orderBy','priority','asc','Contacts','length','contact','fax','FaxInteraction','find','create'];(function(_0x498334,_0x27b6fe){var _0x13bb70=function(_0x4087b1){while(--_0x4087b1){_0x498334['push'](_0x498334['shift']());}};_0x13bb70(++_0x27b6fe);}(_0xfd86,0x194));var _0x6fd8=function(_0xccf869,_0x2556a5){_0xccf869=_0xccf869-0x0;var _0x21a9db=_0xfd86[_0xccf869];return _0x21a9db;};'use strict';var _=require(_0x6fd8('0x0'));var util=require(_0x6fd8('0x1'));var moment=require(_0x6fd8('0x2'));var BPromise=require(_0x6fd8('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x6fd8('0x4'));var db=require(_0x6fd8('0x5'))['db'];var utils=require(_0x6fd8('0x6'));var logger=require('../../config/logger')(_0x6fd8('0x7'));var config=require('../../config/environment');var jayson=require(_0x6fd8('0x8'));var client=jayson['client']['http']({'port':0x232c});config[_0x6fd8('0x9')]=_[_0x6fd8('0xa')](config['redis'],{'host':_0x6fd8('0xb'),'port':0x18eb});var socket=require(_0x6fd8('0xc'))(new Redis(config['redis']));require(_0x6fd8('0xd'))[_0x6fd8('0xe')](socket);function respondWithRpcPromise(_0x5f58a8,_0x53abc2,_0x40be00){return new BPromise(function(_0x135944,_0x5176a8){return client[_0x6fd8('0xf')](_0x5f58a8,_0x40be00)[_0x6fd8('0x10')](function(_0x154ec4){logger[_0x6fd8('0x11')](_0x6fd8('0x12'),_0x53abc2,'request\x20sent');logger[_0x6fd8('0x13')](_0x6fd8('0x14'),_0x53abc2,'request\x20sent',JSON[_0x6fd8('0x15')](_0x154ec4));if(_0x154ec4[_0x6fd8('0x16')]){if(_0x154ec4[_0x6fd8('0x16')][_0x6fd8('0x17')]===0x1f4){logger[_0x6fd8('0x16')](_0x6fd8('0x12'),_0x53abc2,_0x154ec4['error'][_0x6fd8('0x18')]);return _0x5176a8(_0x154ec4[_0x6fd8('0x16')][_0x6fd8('0x18')]);}logger[_0x6fd8('0x16')]('FaxAccount,\x20%s,\x20%s',_0x53abc2,_0x154ec4[_0x6fd8('0x16')][_0x6fd8('0x18')]);return _0x135944(_0x154ec4['error'][_0x6fd8('0x18')]);}else{logger['info']('FaxAccount,\x20%s,\x20%s',_0x53abc2,_0x6fd8('0x19'));_0x135944(_0x154ec4[_0x6fd8('0x1a')]['message']);}})[_0x6fd8('0x1b')](function(_0xce1da4){logger[_0x6fd8('0x16')]('FaxAccount,\x20%s,\x20%s',_0x53abc2,_0xce1da4);_0x5176a8(_0xce1da4);});});}exports[_0x6fd8('0x1c')]=function(_0x7a9e72){var _0x503781=this;return new Promise(function(_0x328ca9,_0x3f5166){return db[_0x6fd8('0x1d')]['findAll']({'raw':_0x7a9e72['options']?_0x7a9e72['options'][_0x6fd8('0x1e')]===undefined?!![]:![]:!![],'where':_0x7a9e72['options']?_0x7a9e72[_0x6fd8('0x1f')][_0x6fd8('0x20')]||null:null,'attributes':_0x7a9e72[_0x6fd8('0x1f')]?_0x7a9e72[_0x6fd8('0x1f')][_0x6fd8('0x21')]||null:null,'limit':_0x7a9e72['options']?_0x7a9e72[_0x6fd8('0x1f')][_0x6fd8('0x22')]||null:null,'include':_0x7a9e72[_0x6fd8('0x1f')]?_0x7a9e72[_0x6fd8('0x1f')][_0x6fd8('0x23')]?_[_0x6fd8('0x24')](_0x7a9e72[_0x6fd8('0x1f')][_0x6fd8('0x23')],function(_0x9b758e){return{'model':db[_0x9b758e[_0x6fd8('0x25')]],'as':_0x9b758e['as'],'attributes':_0x9b758e[_0x6fd8('0x21')],'include':_0x9b758e[_0x6fd8('0x23')]?_[_0x6fd8('0x24')](_0x9b758e[_0x6fd8('0x23')],function(_0x5cf478){return{'model':db[_0x5cf478[_0x6fd8('0x25')]],'as':_0x5cf478['as'],'attributes':_0x5cf478[_0x6fd8('0x21')],'include':_0x5cf478[_0x6fd8('0x23')]?_[_0x6fd8('0x24')](_0x5cf478[_0x6fd8('0x23')],function(_0x1cad0a){return{'model':db[_0x1cad0a[_0x6fd8('0x25')]],'as':_0x1cad0a['as'],'attributes':_0x1cad0a[_0x6fd8('0x21')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x5bc437){logger['info'](_0x6fd8('0x1c'),_0x7a9e72);logger[_0x6fd8('0x13')](_0x6fd8('0x1c'),_0x7a9e72,JSON['stringify'](_0x5bc437));_0x328ca9(_0x5bc437);})['catch'](function(_0x187086){logger[_0x6fd8('0x16')]('GetFaxAccount',_0x187086[_0x6fd8('0x18')],_0x7a9e72);_0x3f5166(_0x503781[_0x6fd8('0x16')](0x1f4,_0x187086['message']));});});};exports[_0x6fd8('0x26')]=function(_0x130bed,_0x12e361,_0x3b1900){var _0x323beb=this;return new Promise(function(_0x28d49f,_0x5dfb){var _0x1537df={'body':_0x130bed[_0x6fd8('0x27')],'channel':'fax'};var _0x178350=[];var _0x429b25=[];var _0x59225b={};return db[_0x6fd8('0x28')][_0x6fd8('0x29')]()[_0x6fd8('0x10')](function(_0x26c97d){if(!_0x26c97d){throw new db[(_0x6fd8('0x2a'))][(_0x6fd8('0x2b'))](_0x6fd8('0x2c'));}_0x178350=_[_0x6fd8('0x2d')](_['keys'](_0x26c97d),[_0x6fd8('0x2e'),_0x6fd8('0x2f')]);_0x429b25=_[_0x6fd8('0x2d')](_[_0x6fd8('0x30')](_0x26c97d),[_0x6fd8('0x2e'),'updatedAt',_0x6fd8('0x31'),_0x6fd8('0x32')]);if(_0x130bed[_0x6fd8('0x27')]['id']){delete _0x130bed[_0x6fd8('0x27')]['id'];}if(_[_0x6fd8('0x33')](_0x130bed[_0x6fd8('0x27')][_0x6fd8('0x34')])){throw new db[(_0x6fd8('0x2a'))][(_0x6fd8('0x2b'))](_0x6fd8('0x35'));}if(_['isNil'](_0x130bed[_0x6fd8('0x27')][_0x6fd8('0x27')])||_0x130bed[_0x6fd8('0x27')][_0x6fd8('0x27')]===''){throw new db[(_0x6fd8('0x2a'))][(_0x6fd8('0x2b'))]('body\x20is\x20mandatory\x20and\x20not\x20empty');}if(_[_0x6fd8('0x33')](_0x130bed['body'][_0x6fd8('0x36')])){throw new db['Sequelize'][(_0x6fd8('0x2b'))](_0x6fd8('0x37')+_0x429b25);}if(!_['includes'](_0x429b25,_0x130bed[_0x6fd8('0x27')]['mapKey'])){throw new db[(_0x6fd8('0x2a'))][(_0x6fd8('0x2b'))](_0x6fd8('0x38')+_0x429b25);}_0x59225b[_0x130bed[_0x6fd8('0x27')][_0x6fd8('0x36')]]=_0x130bed['body'][_0x6fd8('0x34')];})['then'](function(){return db[_0x6fd8('0x1d')]['find']({'where':{'id':_0x130bed[_0x6fd8('0x39')]['id']},'include':[{'model':db[_0x6fd8('0x3a')],'as':_0x6fd8('0x3b'),'include':[{'model':db['CmContact'],'as':'Contacts','where':_0x59225b,'limit':0x1,'order':[[_0x6fd8('0x2f'),_0x6fd8('0x3c')]]}]},{'model':db[_0x6fd8('0x3d')],'as':_0x6fd8('0x3e')}]});})['then'](function(_0x3f7d99){if(_0x3f7d99&&_0x3f7d99[_0x6fd8('0x3b')]){var _0x5e0d2b=_0x3f7d99[_0x6fd8('0x3f')]({'plain':!![]});_0x1537df['account']=_0x5e0d2b;_0x1537df[_0x6fd8('0x40')]=_0x5e0d2b[_0x6fd8('0x3e')];_0x1537df[_0x6fd8('0x41')]=_0x5e0d2b['List'];_0x1537df[_0x6fd8('0x40')]=_[_0x6fd8('0x42')](_0x1537df[_0x6fd8('0x40')],[_0x6fd8('0x43')],[_0x6fd8('0x44')]);if(_0x1537df[_0x6fd8('0x39')]['Applications']){delete _0x1537df[_0x6fd8('0x39')][_0x6fd8('0x3e')];}if(_0x1537df['account'][_0x6fd8('0x3b')]&&_0x1537df['account']['List'][_0x6fd8('0x45')][_0x6fd8('0x46')]){return _0x1537df[_0x6fd8('0x39')][_0x6fd8('0x3b')][_0x6fd8('0x45')][0x0];}var _0x494d54=_[_0x6fd8('0xa')](_0x130bed['body'],{'firstName':_0x130bed[_0x6fd8('0x27')][_0x6fd8('0x34')],'ListId':_0x5e0d2b[_0x6fd8('0x32')]});_0x494d54[_0x130bed[_0x6fd8('0x27')][_0x6fd8('0x36')]]=_0x130bed[_0x6fd8('0x27')]['from'];return db[_0x6fd8('0x28')]['create'](_0x494d54,{'fields':_0x178350,'raw':!![]});}})[_0x6fd8('0x10')](function(_0x3f0ca8){_0x1537df[_0x6fd8('0x47')]=_0x3f0ca8;if(_0x3f0ca8){var _0x3ffaab={'ContactId':_0x3f0ca8['id'],'FaxAccountId':_0x130bed[_0x6fd8('0x39')]['id'],'fax':_0x3f0ca8[_0x6fd8('0x48')]};return db[_0x6fd8('0x49')][_0x6fd8('0x4a')]({'where':{'ContactId':_0x3f0ca8['id'],'closed':![],'FaxAccountId':_0x130bed['account']['id']}})[_0x6fd8('0x10')](function(_0x55aed0){if(_0x55aed0){return[_0x55aed0,![]];}return db['FaxInteraction'][_0x6fd8('0x4b')](_0x3ffaab)[_0x6fd8('0x10')](function(_0x3c16f7){return[_0x3c16f7,!![]];});});}else{throw new Error(_0x6fd8('0x4c'));}})[_0x6fd8('0x4d')](function(_0x3b0949,_0x4a0071){var _0x38660a=_0x3b0949['get']({'plain':!![]});if(_0x4a0071){if(_0x1537df[_0x6fd8('0x39')][_0x6fd8('0x4e')]){_0x1537df[_0x6fd8('0x40')][_0x6fd8('0x4f')]({'id':0x0,'priority':_0x1537df[_0x6fd8('0x40')]['length']+0x1,'app':_0x6fd8('0x50'),'appdata':_0x6fd8('0x51'),'interval':_0x6fd8('0x52')});}_0x38660a[_0x6fd8('0x53')]=!![];}else{_0x38660a[_0x6fd8('0x53')]=![];}_0x1537df[_0x6fd8('0x54')]=_0x38660a;return db['FaxMessage'][_0x6fd8('0x4b')]({'body':_0x130bed[_0x6fd8('0x27')]['body'],'FaxAccountId':_0x130bed[_0x6fd8('0x39')]['id'],'FaxInteractionId':_0x3b0949['id'],'direction':'in','ContactId':_0x3b0949[_0x6fd8('0x55')],'AttachmentId':_0x130bed[_0x6fd8('0x27')][_0x6fd8('0x56')]});})[_0x6fd8('0x10')](function(_0x31e037){_0x1537df['message']=_0x31e037;if(!_0x1537df[_0x6fd8('0x54')][_0x6fd8('0x57')])return;return db[_0x6fd8('0x58')][_0x6fd8('0x4a')]({'attributes':['id','name'],'where':{'id':_0x1537df[_0x6fd8('0x54')][_0x6fd8('0x57')]}});})[_0x6fd8('0x10')](function(_0x458385){if(_0x458385){_0x1537df['applications'][_0x6fd8('0x59')]({'id':0x0,'priority':0x0,'app':_0x6fd8('0x5a'),'appdata':_0x458385['name']+','+(_0x1537df[_0x6fd8('0x39')]['waitForTheAssignedAgent']||0xa),'interval':_0x6fd8('0x52')});}if(!_0x1537df['interaction'][_0x6fd8('0x5b')])return;return db['FaxQueue'][_0x6fd8('0x4a')]({'attributes':['id',_0x6fd8('0x5c')],'where':{'id':_0x1537df[_0x6fd8('0x54')][_0x6fd8('0x5b')]}});})[_0x6fd8('0x10')](function(_0x1250cf){if(_0x1250cf){_0x1537df[_0x6fd8('0x40')][_0x6fd8('0x59')]({'id':0x0,'priority':0x1,'app':'queue','appdata':_0x1250cf['name']+','+(_0x1537df[_0x6fd8('0x39')][_0x6fd8('0x5d')]||0x12c),'interval':_0x6fd8('0x52')});}return respondWithRpcPromise(_0x6fd8('0x5e'),_0x6fd8('0x5f'),_0x1537df);})[_0x6fd8('0x10')](function(_0x436cbe){_0x28d49f(_0x436cbe);})[_0x6fd8('0x1b')](function(_0x344c8f){_0x5dfb(_0x323beb[_0x6fd8('0x16')](0x1f4,_0x344c8f[_0x6fd8('0x18')]));});});};
\ No newline at end of file
+var _0x4f6d=['DESC','FaxApplication','Applications','get','list','orderBy','applications','asc','contact','FaxInteraction','create','Contact\x20not\x20found','autoclose','push','length','unmanaged','*,*,*,*','created','interaction','AttachmentId','UserId','User','name','unshift','agent','waitForTheAssignedAgent','queueId','FaxQueue','queue','waitForTheAssignedQueue','Start','startRouting','util','moment','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','client','http','defaults','redis','socket.io-emitter','./faxAccount.socket','register','request','then','FaxAccount,\x20%s,\x20%s','request\x20sent','debug','FaxAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message','info','catch','GetFaxAccount','FaxAccount','findAll','options','raw','map','include','model','attributes','body','fax','CmContact','Sequelize','ValidationError','no\x20available\x20attributes','keys','updatedAt','difference','CompanyId','ListId','isNil','from\x20is\x20mandatory','mapKey','mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','includes','mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','from','find','account','CmList','List','Contacts'];(function(_0x46ca1c,_0x366258){var _0x23875a=function(_0x50f8fb){while(--_0x50f8fb){_0x46ca1c['push'](_0x46ca1c['shift']());}};_0x23875a(++_0x366258);}(_0x4f6d,0x18c));var _0xd4f6=function(_0x58d9ff,_0x1a97f6){_0x58d9ff=_0x58d9ff-0x0;var _0x2c3132=_0x4f6d[_0x58d9ff];return _0x2c3132;};'use strict';var _=require('lodash');var util=require(_0xd4f6('0x0'));var moment=require(_0xd4f6('0x1'));var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xd4f6('0x2'));var db=require(_0xd4f6('0x3'))['db'];var utils=require(_0xd4f6('0x4'));var logger=require(_0xd4f6('0x5'))(_0xd4f6('0x6'));var config=require('../../config/environment');var jayson=require(_0xd4f6('0x7'));var client=jayson[_0xd4f6('0x8')][_0xd4f6('0x9')]({'port':0x232c});config['redis']=_[_0xd4f6('0xa')](config[_0xd4f6('0xb')],{'host':'localhost','port':0x18eb});var socket=require(_0xd4f6('0xc'))(new Redis(config['redis']));require(_0xd4f6('0xd'))[_0xd4f6('0xe')](socket);function respondWithRpcPromise(_0x302bd7,_0x741d1b,_0x5486ea){return new BPromise(function(_0x4c6dbe,_0x14aadb){return client[_0xd4f6('0xf')](_0x302bd7,_0x5486ea)[_0xd4f6('0x10')](function(_0x2cd1ba){logger['info'](_0xd4f6('0x11'),_0x741d1b,_0xd4f6('0x12'));logger[_0xd4f6('0x13')](_0xd4f6('0x14'),_0x741d1b,_0xd4f6('0x12'),JSON[_0xd4f6('0x15')](_0x2cd1ba));if(_0x2cd1ba[_0xd4f6('0x16')]){if(_0x2cd1ba['error'][_0xd4f6('0x17')]===0x1f4){logger['error'](_0xd4f6('0x11'),_0x741d1b,_0x2cd1ba[_0xd4f6('0x16')][_0xd4f6('0x18')]);return _0x14aadb(_0x2cd1ba['error'][_0xd4f6('0x18')]);}logger['error'](_0xd4f6('0x11'),_0x741d1b,_0x2cd1ba[_0xd4f6('0x16')][_0xd4f6('0x18')]);return _0x4c6dbe(_0x2cd1ba[_0xd4f6('0x16')][_0xd4f6('0x18')]);}else{logger[_0xd4f6('0x19')](_0xd4f6('0x11'),_0x741d1b,_0xd4f6('0x12'));_0x4c6dbe(_0x2cd1ba['result'][_0xd4f6('0x18')]);}})[_0xd4f6('0x1a')](function(_0x3f7202){logger[_0xd4f6('0x16')](_0xd4f6('0x11'),_0x741d1b,_0x3f7202);_0x14aadb(_0x3f7202);});});}exports[_0xd4f6('0x1b')]=function(_0x1260dc){var _0x1ec432=this;return new Promise(function(_0x28250b,_0x190ddb){return db[_0xd4f6('0x1c')][_0xd4f6('0x1d')]({'raw':_0x1260dc[_0xd4f6('0x1e')]?_0x1260dc[_0xd4f6('0x1e')][_0xd4f6('0x1f')]===undefined?!![]:![]:!![],'where':_0x1260dc[_0xd4f6('0x1e')]?_0x1260dc['options']['where']||null:null,'attributes':_0x1260dc['options']?_0x1260dc[_0xd4f6('0x1e')]['attributes']||null:null,'limit':_0x1260dc[_0xd4f6('0x1e')]?_0x1260dc[_0xd4f6('0x1e')]['limit']||null:null,'include':_0x1260dc[_0xd4f6('0x1e')]?_0x1260dc['options']['include']?_[_0xd4f6('0x20')](_0x1260dc['options'][_0xd4f6('0x21')],function(_0x248068){return{'model':db[_0x248068[_0xd4f6('0x22')]],'as':_0x248068['as'],'attributes':_0x248068['attributes'],'include':_0x248068[_0xd4f6('0x21')]?_['map'](_0x248068['include'],function(_0x5cedef){return{'model':db[_0x5cedef[_0xd4f6('0x22')]],'as':_0x5cedef['as'],'attributes':_0x5cedef['attributes'],'include':_0x5cedef[_0xd4f6('0x21')]?_['map'](_0x5cedef[_0xd4f6('0x21')],function(_0x57eaa1){return{'model':db[_0x57eaa1['model']],'as':_0x57eaa1['as'],'attributes':_0x57eaa1[_0xd4f6('0x23')]};}):[]};}):[]};}):[]:[]})[_0xd4f6('0x10')](function(_0x5893bf){logger[_0xd4f6('0x19')](_0xd4f6('0x1b'),_0x1260dc);logger[_0xd4f6('0x13')](_0xd4f6('0x1b'),_0x1260dc,JSON['stringify'](_0x5893bf));_0x28250b(_0x5893bf);})['catch'](function(_0x2b983e){logger['error']('GetFaxAccount',_0x2b983e[_0xd4f6('0x18')],_0x1260dc);_0x190ddb(_0x1ec432[_0xd4f6('0x16')](0x1f4,_0x2b983e[_0xd4f6('0x18')]));});});};exports['NotifyFaxAccount']=function(_0x386461,_0x5f1e92,_0x5904dc){var _0x98c6a4=this;return new Promise(function(_0x46306b,_0x4f81c2){var _0x207396={'body':_0x386461[_0xd4f6('0x24')],'channel':_0xd4f6('0x25')};var _0x5c47dd=[];var _0x2c489e=[];var _0x2816fb={};return db[_0xd4f6('0x26')]['describe']()[_0xd4f6('0x10')](function(_0x372b53){if(!_0x372b53){throw new db[(_0xd4f6('0x27'))][(_0xd4f6('0x28'))](_0xd4f6('0x29'));}_0x5c47dd=_['difference'](_[_0xd4f6('0x2a')](_0x372b53),['createdAt',_0xd4f6('0x2b')]);_0x2c489e=_[_0xd4f6('0x2c')](_['keys'](_0x372b53),['createdAt','updatedAt',_0xd4f6('0x2d'),_0xd4f6('0x2e')]);if(_0x386461[_0xd4f6('0x24')]['id']){delete _0x386461[_0xd4f6('0x24')]['id'];}if(_[_0xd4f6('0x2f')](_0x386461[_0xd4f6('0x24')]['from'])){throw new db[(_0xd4f6('0x27'))][(_0xd4f6('0x28'))](_0xd4f6('0x30'));}if(_[_0xd4f6('0x2f')](_0x386461[_0xd4f6('0x24')][_0xd4f6('0x24')])||_0x386461['body'][_0xd4f6('0x24')]===''){throw new db['Sequelize'][(_0xd4f6('0x28'))]('body\x20is\x20mandatory\x20and\x20not\x20empty');}if(_[_0xd4f6('0x2f')](_0x386461[_0xd4f6('0x24')][_0xd4f6('0x31')])){throw new db[(_0xd4f6('0x27'))][(_0xd4f6('0x28'))](_0xd4f6('0x32')+_0x2c489e);}if(!_[_0xd4f6('0x33')](_0x2c489e,_0x386461[_0xd4f6('0x24')][_0xd4f6('0x31')])){throw new db['Sequelize'][(_0xd4f6('0x28'))](_0xd4f6('0x34')+_0x2c489e);}_0x2816fb[_0x386461[_0xd4f6('0x24')][_0xd4f6('0x31')]]=_0x386461['body'][_0xd4f6('0x35')];})[_0xd4f6('0x10')](function(){return db['FaxAccount'][_0xd4f6('0x36')]({'where':{'id':_0x386461[_0xd4f6('0x37')]['id']},'include':[{'model':db[_0xd4f6('0x38')],'as':_0xd4f6('0x39'),'include':[{'model':db[_0xd4f6('0x26')],'as':_0xd4f6('0x3a'),'where':_0x2816fb,'limit':0x1,'order':[[_0xd4f6('0x2b'),_0xd4f6('0x3b')]]}]},{'model':db[_0xd4f6('0x3c')],'as':_0xd4f6('0x3d')}]});})[_0xd4f6('0x10')](function(_0x502e16){if(_0x502e16&&_0x502e16[_0xd4f6('0x39')]){var _0x25f8fb=_0x502e16[_0xd4f6('0x3e')]({'plain':!![]});_0x207396[_0xd4f6('0x37')]=_0x25f8fb;_0x207396['applications']=_0x25f8fb[_0xd4f6('0x3d')];_0x207396[_0xd4f6('0x3f')]=_0x25f8fb[_0xd4f6('0x39')];_0x207396['applications']=_[_0xd4f6('0x40')](_0x207396[_0xd4f6('0x41')],['priority'],[_0xd4f6('0x42')]);if(_0x207396[_0xd4f6('0x37')][_0xd4f6('0x3d')]){delete _0x207396[_0xd4f6('0x37')][_0xd4f6('0x3d')];}if(_0x207396[_0xd4f6('0x37')][_0xd4f6('0x39')]&&_0x207396[_0xd4f6('0x37')][_0xd4f6('0x39')][_0xd4f6('0x3a')]['length']){return _0x207396[_0xd4f6('0x37')][_0xd4f6('0x39')][_0xd4f6('0x3a')][0x0];}var _0x218f45=_[_0xd4f6('0xa')](_0x386461[_0xd4f6('0x24')],{'firstName':_0x386461[_0xd4f6('0x24')]['from'],'ListId':_0x25f8fb['ListId']});_0x218f45[_0x386461[_0xd4f6('0x24')][_0xd4f6('0x31')]]=_0x386461[_0xd4f6('0x24')][_0xd4f6('0x35')];return db[_0xd4f6('0x26')]['create'](_0x218f45,{'fields':_0x5c47dd,'raw':!![]});}})[_0xd4f6('0x10')](function(_0x53abe6){_0x207396[_0xd4f6('0x43')]=_0x53abe6;if(_0x53abe6){var _0x2af531={'ContactId':_0x53abe6['id'],'FaxAccountId':_0x386461[_0xd4f6('0x37')]['id'],'fax':_0x53abe6[_0xd4f6('0x25')]};return db[_0xd4f6('0x44')][_0xd4f6('0x36')]({'where':{'ContactId':_0x53abe6['id'],'closed':![],'FaxAccountId':_0x386461[_0xd4f6('0x37')]['id']}})[_0xd4f6('0x10')](function(_0x2eab71){if(_0x2eab71){return[_0x2eab71,![]];}return db[_0xd4f6('0x44')][_0xd4f6('0x45')](_0x2af531)[_0xd4f6('0x10')](function(_0x1e4c35){return[_0x1e4c35,!![]];});});}else{throw new Error(_0xd4f6('0x46'));}})['spread'](function(_0xc8ca2e,_0x2e6f66){var _0x14e390=_0xc8ca2e[_0xd4f6('0x3e')]({'plain':!![]});if(_0x2e6f66){if(_0x207396[_0xd4f6('0x37')][_0xd4f6('0x47')]){_0x207396[_0xd4f6('0x41')][_0xd4f6('0x48')]({'id':0x0,'priority':_0x207396[_0xd4f6('0x41')][_0xd4f6('0x49')]+0x1,'app':'close','appdata':_0xd4f6('0x4a'),'interval':_0xd4f6('0x4b')});}_0x14e390['created']=!![];}else{_0x14e390[_0xd4f6('0x4c')]=![];}_0x207396[_0xd4f6('0x4d')]=_0x14e390;return db['FaxMessage'][_0xd4f6('0x45')]({'body':_0x386461[_0xd4f6('0x24')][_0xd4f6('0x24')],'FaxAccountId':_0x386461[_0xd4f6('0x37')]['id'],'FaxInteractionId':_0xc8ca2e['id'],'direction':'in','ContactId':_0xc8ca2e['ContactId'],'AttachmentId':_0x386461[_0xd4f6('0x24')][_0xd4f6('0x4e')]});})[_0xd4f6('0x10')](function(_0x416643){_0x207396[_0xd4f6('0x18')]=_0x416643;if(!_0x207396[_0xd4f6('0x4d')][_0xd4f6('0x4f')])return;return db[_0xd4f6('0x50')][_0xd4f6('0x36')]({'attributes':['id',_0xd4f6('0x51')],'where':{'id':_0x207396[_0xd4f6('0x4d')][_0xd4f6('0x4f')]}});})['then'](function(_0xd9ae90){if(_0xd9ae90){_0x207396[_0xd4f6('0x41')][_0xd4f6('0x52')]({'id':0x0,'priority':0x0,'app':_0xd4f6('0x53'),'appdata':_0xd9ae90[_0xd4f6('0x51')]+','+(_0x207396[_0xd4f6('0x37')][_0xd4f6('0x54')]||0xa),'interval':'*,*,*,*'});}if(!_0x207396[_0xd4f6('0x4d')][_0xd4f6('0x55')])return;return db[_0xd4f6('0x56')][_0xd4f6('0x36')]({'attributes':['id',_0xd4f6('0x51')],'where':{'id':_0x207396[_0xd4f6('0x4d')][_0xd4f6('0x55')]}});})[_0xd4f6('0x10')](function(_0x1177f5){if(_0x1177f5){_0x207396[_0xd4f6('0x41')][_0xd4f6('0x52')]({'id':0x0,'priority':0x1,'app':_0xd4f6('0x57'),'appdata':_0x1177f5['name']+','+(_0x207396[_0xd4f6('0x37')][_0xd4f6('0x58')]||0x12c),'interval':_0xd4f6('0x4b')});}return respondWithRpcPromise(_0xd4f6('0x59'),_0xd4f6('0x5a'),_0x207396);})[_0xd4f6('0x10')](function(_0x234783){_0x46306b(_0x234783);})['catch'](function(_0x6a417f){_0x4f81c2(_0x98c6a4['error'](0x1f4,_0x6a417f[_0xd4f6('0x18')]));});});};
\ No newline at end of file