Built motion from commit ffdca78c.|2.6.24
[motion2.git] / server / api / mailAccount / mailAccount.rpc.js
index 8f8bb47..25abaad 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xbd51=['message','info','result','GetMailAccount','MailAccount','findAll','options','raw','where','attributes','include','model','map','catch','ShowMailAccount','find','smtp','setDataValue','smtpOptions','getSmtpOptions','NotifyMailAccount','body','mail','CmContact','rawAttributes','createdAt','CompanyId','ListId','isNil','from\x20is\x20mandatory','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','CmList','Contacts','updatedAt','DESC','MailApplication','Applications','MailServerOut','Smtp','CloudProvider','List','get','omit','account','applications','orderBy','priority','asc','autoclose','push','length','close','*,*,*,*','defaults','from','create','List\x20not\x20found','contact','messageId','generate','format','YYYY-MM-DD\x20HH:mm:ss','MailMessage','inReplyTo','Contact\x20not\x20found','update','subject','attach','interaction','created','attachments','originTo','originCc','bcc','ChatWebsiteId','Email','ChatOfflineMessageId','Attachments','UserId','User','name','waitForTheAssignedAgent','queueId','unshift','queue','waitForTheAssignedQueue','Start','lodash','bluebird','randomstring','ioredis','../../mysqldb','client','http','redis','localhost','socket.io-emitter','./mailAccount.socket','request','then','MailAccount,\x20%s,\x20%s','debug','MailAccount,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code'];(function(_0x62c958,_0x2bfdbc){var _0x57ec61=function(_0x5c0094){while(--_0x5c0094){_0x62c958['push'](_0x62c958['shift']());}};_0x57ec61(++_0x2bfdbc);}(_0xbd51,0x1a8));var _0x1bd5=function(_0x478873,_0x9f241f){_0x478873=_0x478873-0x0;var _0x263e5e=_0xbd51[_0x478873];return _0x263e5e;};'use strict';var _=require(_0x1bd5('0x0'));var moment=require('moment');var BPromise=require(_0x1bd5('0x1'));var rs=require(_0x1bd5('0x2'));var Redis=require(_0x1bd5('0x3'));var db=require(_0x1bd5('0x4'))['db'];var logger=require('../../config/logger')('rpc');var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson[_0x1bd5('0x5')][_0x1bd5('0x6')]({'port':0x232c});config[_0x1bd5('0x7')]=_['defaults'](config[_0x1bd5('0x7')],{'host':_0x1bd5('0x8'),'port':0x18eb});var socket=require(_0x1bd5('0x9'))(new Redis(config[_0x1bd5('0x7')]));require(_0x1bd5('0xa'))['register'](socket);function respondWithRpcPromise(_0x36ef1a,_0x5c8e0d,_0x2bd975){return new BPromise(function(_0x28df8e,_0x3b868a){return client[_0x1bd5('0xb')](_0x36ef1a,_0x2bd975)[_0x1bd5('0xc')](function(_0x3e3d06){logger['info'](_0x1bd5('0xd'),_0x5c8e0d,'request\x20sent');logger[_0x1bd5('0xe')](_0x1bd5('0xf'),_0x5c8e0d,_0x1bd5('0x10'),JSON[_0x1bd5('0x11')](_0x3e3d06));if(_0x3e3d06[_0x1bd5('0x12')]){if(_0x3e3d06[_0x1bd5('0x12')][_0x1bd5('0x13')]===0x1f4){logger['error']('MailAccount,\x20%s,\x20%s',_0x5c8e0d,_0x3e3d06[_0x1bd5('0x12')][_0x1bd5('0x14')]);return _0x3b868a(_0x3e3d06[_0x1bd5('0x12')][_0x1bd5('0x14')]);}logger['error']('MailAccount,\x20%s,\x20%s',_0x5c8e0d,_0x3e3d06[_0x1bd5('0x12')][_0x1bd5('0x14')]);return _0x28df8e(_0x3e3d06[_0x1bd5('0x12')][_0x1bd5('0x14')]);}else{logger[_0x1bd5('0x15')](_0x1bd5('0xd'),_0x5c8e0d,_0x1bd5('0x10'));_0x28df8e(_0x3e3d06[_0x1bd5('0x16')][_0x1bd5('0x14')]);}})['catch'](function(_0x53ad5e){logger[_0x1bd5('0x12')](_0x1bd5('0xd'),_0x5c8e0d,_0x53ad5e);_0x3b868a(_0x53ad5e);});});}exports[_0x1bd5('0x17')]=function(_0xb95d4e){var _0x459649=this;return new Promise(function(_0x2ff39a,_0x3fbb39){return db[_0x1bd5('0x18')][_0x1bd5('0x19')]({'raw':_0xb95d4e[_0x1bd5('0x1a')]?_0xb95d4e[_0x1bd5('0x1a')][_0x1bd5('0x1b')]===undefined?!![]:![]:!![],'where':_0xb95d4e[_0x1bd5('0x1a')]?_0xb95d4e[_0x1bd5('0x1a')][_0x1bd5('0x1c')]||null:null,'attributes':_0xb95d4e[_0x1bd5('0x1a')]?_0xb95d4e[_0x1bd5('0x1a')][_0x1bd5('0x1d')]||null:null,'limit':_0xb95d4e['options']?_0xb95d4e[_0x1bd5('0x1a')]['limit']||null:null,'include':_0xb95d4e[_0x1bd5('0x1a')]?_0xb95d4e[_0x1bd5('0x1a')][_0x1bd5('0x1e')]?_['map'](_0xb95d4e[_0x1bd5('0x1a')]['include'],function(_0x2ed551){return{'model':db[_0x2ed551[_0x1bd5('0x1f')]],'as':_0x2ed551['as'],'attributes':_0x2ed551[_0x1bd5('0x1d')],'include':_0x2ed551[_0x1bd5('0x1e')]?_['map'](_0x2ed551[_0x1bd5('0x1e')],function(_0x69bb17){return{'model':db[_0x69bb17[_0x1bd5('0x1f')]],'as':_0x69bb17['as'],'attributes':_0x69bb17[_0x1bd5('0x1d')],'include':_0x69bb17['include']?_[_0x1bd5('0x20')](_0x69bb17[_0x1bd5('0x1e')],function(_0x3595e9){return{'model':db[_0x3595e9[_0x1bd5('0x1f')]],'as':_0x3595e9['as'],'attributes':_0x3595e9[_0x1bd5('0x1d')]};}):[]};}):[]};}):[]:[]})[_0x1bd5('0xc')](function(_0x4e72b2){logger[_0x1bd5('0x15')](_0x1bd5('0x17'),_0xb95d4e);logger[_0x1bd5('0xe')]('GetMailAccount',_0xb95d4e,JSON[_0x1bd5('0x11')](_0x4e72b2));_0x2ff39a(_0x4e72b2);})[_0x1bd5('0x21')](function(_0x345181){logger[_0x1bd5('0x12')](_0x1bd5('0x17'),_0x345181[_0x1bd5('0x14')],_0xb95d4e);_0x3fbb39(_0x459649['error'](0x1f4,_0x345181['message']));});});};exports[_0x1bd5('0x22')]=function(_0x305126){var _0x5542aa=this;return new Promise(function(_0x36649d,_0x198b88){return db[_0x1bd5('0x18')][_0x1bd5('0x23')]({'raw':_0x305126['options']?_0x305126[_0x1bd5('0x1a')][_0x1bd5('0x1b')]===undefined?!![]:![]:!![],'where':_0x305126[_0x1bd5('0x1a')]?_0x305126[_0x1bd5('0x1a')][_0x1bd5('0x1c')]||null:null,'attributes':_0x305126[_0x1bd5('0x1a')]?_0x305126[_0x1bd5('0x1a')][_0x1bd5('0x1d')]||null:null,'include':_0x305126['options']?_0x305126[_0x1bd5('0x1a')][_0x1bd5('0x1e')]?_[_0x1bd5('0x20')](_0x305126[_0x1bd5('0x1a')][_0x1bd5('0x1e')],function(_0x18a9db){return{'model':db[_0x18a9db[_0x1bd5('0x1f')]],'as':_0x18a9db['as'],'attributes':_0x18a9db['attributes'],'include':_0x18a9db[_0x1bd5('0x1e')]?_[_0x1bd5('0x20')](_0x18a9db[_0x1bd5('0x1e')],function(_0x2f5a48){return{'model':db[_0x2f5a48[_0x1bd5('0x1f')]],'as':_0x2f5a48['as'],'attributes':_0x2f5a48[_0x1bd5('0x1d')],'include':_0x2f5a48[_0x1bd5('0x1e')]?_['map'](_0x2f5a48['include'],function(_0x155e4c){return{'model':db[_0x155e4c[_0x1bd5('0x1f')]],'as':_0x155e4c['as'],'attributes':_0x155e4c[_0x1bd5('0x1d')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x4595a0){if(_0x305126['options'][_0x1bd5('0x24')]===!![])_0x4595a0[_0x1bd5('0x25')](_0x1bd5('0x26'),_0x4595a0[_0x1bd5('0x27')]());logger[_0x1bd5('0x15')](_0x1bd5('0x22'),_0x305126);logger[_0x1bd5('0xe')](_0x1bd5('0x22'),_0x305126,JSON['stringify'](_0x4595a0));_0x36649d(_0x4595a0);})[_0x1bd5('0x21')](function(_0x2978d8){logger['error'](_0x1bd5('0x22'),_0x2978d8[_0x1bd5('0x14')],_0x305126);_0x198b88(_0x5542aa[_0x1bd5('0x12')](0x1f4,_0x2978d8['message']));});});};exports[_0x1bd5('0x28')]=function(_0x53482){var _0x2997a2=this;return new Promise(function(_0x4074f1,_0x4e8ff7){var _0x305720={'body':_0x53482[_0x1bd5('0x29')],'channel':_0x1bd5('0x2a')};var _0x11e996=_['difference'](_['keys'](db[_0x1bd5('0x2b')][_0x1bd5('0x2c')]),[_0x1bd5('0x2d'),'updatedAt',_0x1bd5('0x2e'),_0x1bd5('0x2f')]);var _0x574d95=![];if(_0x53482[_0x1bd5('0x29')]['id']){delete _0x53482['body']['id'];}if(_[_0x1bd5('0x30')](_0x53482[_0x1bd5('0x29')]['from'])){return _0x4e8ff7(_0x2997a2[_0x1bd5('0x12')](0x1f4,_0x1bd5('0x31')));}if(_[_0x1bd5('0x30')](_0x53482[_0x1bd5('0x29')][_0x1bd5('0x29')])||_0x53482[_0x1bd5('0x29')][_0x1bd5('0x29')]===''){return _0x4e8ff7(_0x2997a2[_0x1bd5('0x12')](0x1f4,_0x1bd5('0x32')));}if(_[_0x1bd5('0x30')](_0x53482[_0x1bd5('0x29')][_0x1bd5('0x33')])){return _0x4e8ff7(_0x2997a2['error'](0x1f4,_0x1bd5('0x34')+_0x11e996));}if(!_[_0x1bd5('0x35')](_0x11e996,_0x53482[_0x1bd5('0x29')]['mapKey'])){return _0x4e8ff7(_0x2997a2[_0x1bd5('0x12')](0x1f4,_0x1bd5('0x36')+_0x11e996));}var _0x5bb8a6={};_0x5bb8a6[_0x53482[_0x1bd5('0x29')]['mapKey']]=_0x53482[_0x1bd5('0x29')]['from'];return db[_0x1bd5('0x18')][_0x1bd5('0x23')]({'where':{'id':_0x53482['account']['id']},'include':[{'model':db[_0x1bd5('0x37')],'as':'List','include':[{'model':db[_0x1bd5('0x2b')],'as':_0x1bd5('0x38'),'where':_0x5bb8a6,'limit':0x1,'order':[[_0x1bd5('0x39'),_0x1bd5('0x3a')]]}]},{'model':db[_0x1bd5('0x3b')],'as':_0x1bd5('0x3c')},{'model':db[_0x1bd5('0x3d')],'as':_0x1bd5('0x3e'),'include':[{'model':db['CloudProvider'],'as':_0x1bd5('0x3f')}]}]})[_0x1bd5('0xc')](function(_0x2a1ece){if(_0x2a1ece&&_0x2a1ece[_0x1bd5('0x40')]){var _0x34452a=_0x2a1ece[_0x1bd5('0x41')]({'plain':!![]});_0x305720['account']=_[_0x1bd5('0x42')](_0x34452a,[_0x1bd5('0x3c'),_0x1bd5('0x40')]);_0x305720[_0x1bd5('0x43')][_0x1bd5('0x26')]=_0x2a1ece[_0x1bd5('0x27')]();_0x305720[_0x1bd5('0x44')]=_0x34452a['Applications'];_0x305720['list']=_0x34452a[_0x1bd5('0x40')];_0x305720[_0x1bd5('0x44')]=_[_0x1bd5('0x45')](_0x305720['applications'],[_0x1bd5('0x46')],[_0x1bd5('0x47')]);if(_0x305720[_0x1bd5('0x43')]&&_0x305720[_0x1bd5('0x43')][_0x1bd5('0x48')]){_0x305720[_0x1bd5('0x44')][_0x1bd5('0x49')]({'id':0x0,'priority':_0x305720['applications'][_0x1bd5('0x4a')]+0x1,'app':_0x1bd5('0x4b'),'appdata':'autoclose','interval':_0x1bd5('0x4c')});}if(_0x305720['account'][_0x1bd5('0x3c')]){delete _0x305720['account'][_0x1bd5('0x3c')];}if(_0x305720[_0x1bd5('0x43')]['List']){delete _0x305720[_0x1bd5('0x43')][_0x1bd5('0x40')];}if(_0x34452a[_0x1bd5('0x40')][_0x1bd5('0x38')][_0x1bd5('0x4a')]){return _0x34452a[_0x1bd5('0x40')][_0x1bd5('0x38')][0x0];}var _0x51aebe=_[_0x1bd5('0x4d')](_0x53482['body'],{'firstName':_0x53482[_0x1bd5('0x29')][_0x1bd5('0x4e')],'ListId':_0x34452a[_0x1bd5('0x2f')]});_0x51aebe[_0x53482['body']['mapKey']]=_0x53482[_0x1bd5('0x29')][_0x1bd5('0x4e')];return db[_0x1bd5('0x2b')][_0x1bd5('0x4f')](_0x51aebe);}else{throw new Error(_0x1bd5('0x50'));}})[_0x1bd5('0xc')](function(_0x46e36c){_0x305720[_0x1bd5('0x51')]=_0x46e36c;if(_0x46e36c){if(!_0x53482[_0x1bd5('0x29')][_0x1bd5('0x14')]['messageId']){_0x53482[_0x1bd5('0x29')]['message'][_0x1bd5('0x52')]=rs[_0x1bd5('0x53')]()+'\x20'+_0x53482[_0x1bd5('0x29')]['message'][_0x1bd5('0x4e')];}var _0x17b3a9={'ContactId':_0x46e36c['id'],'MailAccountId':_0x53482[_0x1bd5('0x43')]['id'],'inReplyTo':_0x53482['body'][_0x1bd5('0x14')][_0x1bd5('0x52')],'to':_0x53482[_0x1bd5('0x29')][_0x1bd5('0x14')]['from'],'cc':_0x53482['body'][_0x1bd5('0x14')]['cc'],'subject':_0x53482[_0x1bd5('0x29')][_0x1bd5('0x14')]['subject'],'attach':_0x53482['body'][_0x1bd5('0x14')]['attach'],'lastMsgAt':moment()[_0x1bd5('0x54')](_0x1bd5('0x55')),'lastMsgDirection':'in'};return db['MailInteraction'][_0x1bd5('0x23')]({'where':{'closed':![],'MailAccountId':_0x53482['account']['id']},'include':[{'model':db[_0x1bd5('0x56')],'as':'Messages','attributes':[_0x1bd5('0x52')],'where':{'messageId':_0x53482[_0x1bd5('0x29')]['message'][_0x1bd5('0x57')]}}]})[_0x1bd5('0xc')](function(_0x47ca3f){if(_0x47ca3f){return[_0x47ca3f,![]];}return db['MailInteraction'][_0x1bd5('0x4f')](_0x17b3a9)[_0x1bd5('0xc')](function(_0x1a9ad2){return[_0x1a9ad2,!![]];});});}else{throw new Error(_0x1bd5('0x58'));}})['spread'](function(_0x551f22,_0x14dd41){if(_0x551f22){_0x574d95=_0x14dd41;if(!_0x14dd41){return _0x551f22[_0x1bd5('0x59')]({'inReplyTo':_0x53482[_0x1bd5('0x29')]['message'][_0x1bd5('0x52')],'to':_0x53482[_0x1bd5('0x29')]['message']['from'],'cc':_0x53482[_0x1bd5('0x29')][_0x1bd5('0x14')]['cc'],'subject':_0x53482[_0x1bd5('0x29')][_0x1bd5('0x14')][_0x1bd5('0x5a')],'attach':_0x551f22['attach']?_0x551f22[_0x1bd5('0x5b')]:_0x53482['body'][_0x1bd5('0x14')][_0x1bd5('0x5b')],'substatus':null,'substatusAt':moment()[_0x1bd5('0x54')](_0x1bd5('0x55')),'lastMsgAt':moment()['format']('YYYY-MM-DD\x20HH:mm:ss'),'lastMsgDirection':'in'});}else{return _0x551f22;}}})[_0x1bd5('0xc')](function(_0x36d62e){_0x305720[_0x1bd5('0x5c')]=_0x36d62e[_0x1bd5('0x41')]({'plain':!![]});_0x305720[_0x1bd5('0x5c')][_0x1bd5('0x5d')]=_0x574d95;return db[_0x1bd5('0x56')][_0x1bd5('0x4f')]({'body':_0x53482[_0x1bd5('0x29')][_0x1bd5('0x29')],'MailAccountId':_0x53482[_0x1bd5('0x43')]['id'],'MailInteractionId':_0x36d62e['id'],'direction':'in','ContactId':_0x305720[_0x1bd5('0x51')]['id'],'messageId':_0x53482[_0x1bd5('0x29')][_0x1bd5('0x14')][_0x1bd5('0x52')],'from':_0x53482[_0x1bd5('0x29')][_0x1bd5('0x14')][_0x1bd5('0x4e')],'to':_0x53482[_0x1bd5('0x29')][_0x1bd5('0x14')]['to'],'cc':_0x53482[_0x1bd5('0x29')][_0x1bd5('0x14')]['cc'],'subject':_0x53482[_0x1bd5('0x29')][_0x1bd5('0x14')]['subject'],'attach':_0x53482[_0x1bd5('0x29')][_0x1bd5('0x14')][_0x1bd5('0x5b')],'Attachments':_0x53482[_0x1bd5('0x29')][_0x1bd5('0x14')][_0x1bd5('0x5e')],'originTo':_0x53482[_0x1bd5('0x29')]['message'][_0x1bd5('0x5f')],'originCc':_0x53482[_0x1bd5('0x29')][_0x1bd5('0x14')][_0x1bd5('0x60')],'bcc':_0x53482['body'][_0x1bd5('0x14')][_0x1bd5('0x61')],'ChatWebsiteId':_0x53482[_0x1bd5('0x29')][_0x1bd5('0x14')][_0x1bd5('0x62')]||null,'originChannel':_0x53482[_0x1bd5('0x29')][_0x1bd5('0x14')]['originChannel']||_0x1bd5('0x63'),'ChatOfflineMessageId':_0x53482['body']['message'][_0x1bd5('0x64')]||null},{'include':[{'model':db['Attachment'],'as':_0x1bd5('0x65')}]});})[_0x1bd5('0xc')](function(_0x560f20){_0x305720[_0x1bd5('0x14')]=_0x560f20;if(!_0x305720[_0x1bd5('0x5c')][_0x1bd5('0x66')]){return;}return db[_0x1bd5('0x67')][_0x1bd5('0x23')]({'attributes':['id',_0x1bd5('0x68')],'where':{'id':_0x305720['interaction'][_0x1bd5('0x66')]}});})[_0x1bd5('0xc')](function(_0xdd5183){if(_0xdd5183){_0x305720[_0x1bd5('0x44')]['unshift']({'id':0x0,'priority':0x0,'app':'agent','appdata':_0xdd5183[_0x1bd5('0x68')]+','+(_0x305720[_0x1bd5('0x43')][_0x1bd5('0x69')]||0xa),'interval':_0x1bd5('0x4c')});}if(!_0x305720['interaction'][_0x1bd5('0x6a')]){return;}return db['MailQueue']['find']({'attributes':['id',_0x1bd5('0x68')],'where':{'id':_0x305720['interaction'][_0x1bd5('0x6a')]}});})[_0x1bd5('0xc')](function(_0x231556){if(_0x231556){_0x305720[_0x1bd5('0x44')][_0x1bd5('0x6b')]({'id':0x0,'priority':0x1,'app':_0x1bd5('0x6c'),'appdata':_0x231556[_0x1bd5('0x68')]+','+(_0x305720[_0x1bd5('0x43')][_0x1bd5('0x6d')]||0x12c),'interval':'*,*,*,*'});}return respondWithRpcPromise(_0x1bd5('0x6e'),'startRouting',_0x305720);})['then'](function(_0x59b491){_0x4074f1(_0x59b491);})[_0x1bd5('0x21')](function(_0x524b86){_0x4e8ff7(_0x2997a2[_0x1bd5('0x12')](0x1f4,_0x524b86[_0x1bd5('0x14')]));});});};
\ No newline at end of file
+var _0x8f9d=['generate','attach','format','MailMessage','Messages','inReplyTo','MailInteraction','Contact\x20not\x20found','spread','update','subject','YYYY-MM-DD\x20HH:mm:ss','interaction','created','attachments','originTo','originCc','bcc','ChatWebsiteId','originChannel','Email','ChatOfflineMessageId','Attachments','User','name','UserId','queueId','queue','waitForTheAssignedQueue','Start','startRouting','lodash','bluebird','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','jayson/promise','client','redis','defaults','localhost','socket.io-emitter','./mailAccount.socket','register','request','then','info','MailAccount,\x20%s,\x20%s','request\x20sent','MailAccount,\x20%s,\x20%s,\x20%s','stringify','error','message','result','catch','MailAccount','findAll','options','raw','where','attributes','limit','include','map','model','GetMailAccount','ShowMailAccount','find','smtp','setDataValue','smtpOptions','getSmtpOptions','debug','NotifyMailAccount','difference','keys','CmContact','rawAttributes','createdAt','updatedAt','CompanyId','ListId','body','isNil','from\x20is\x20mandatory','body\x20is\x20mandatory\x20and\x20not\x20empty','mapKey','mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','from','account','CmList','List','DESC','MailApplication','Applications','Smtp','get','omit','list','applications','orderBy','priority','asc','autoclose','push','length','close','*,*,*,*','Contacts','create','List\x20not\x20found','contact','messageId'];(function(_0xfa6ca2,_0x83d7){var _0x5b9d02=function(_0x269d79){while(--_0x269d79){_0xfa6ca2['push'](_0xfa6ca2['shift']());}};_0x5b9d02(++_0x83d7);}(_0x8f9d,0x93));var _0xd8f9=function(_0x321bb2,_0x202794){_0x321bb2=_0x321bb2-0x0;var _0x9c12ed=_0x8f9d[_0x321bb2];return _0x9c12ed;};'use strict';var _=require(_0xd8f9('0x0'));var moment=require('moment');var BPromise=require(_0xd8f9('0x1'));var rs=require('randomstring');var Redis=require(_0xd8f9('0x2'));var db=require(_0xd8f9('0x3'))['db'];var logger=require(_0xd8f9('0x4'))(_0xd8f9('0x5'));var config=require(_0xd8f9('0x6'));var jayson=require(_0xd8f9('0x7'));var client=jayson[_0xd8f9('0x8')]['http']({'port':0x232c});config[_0xd8f9('0x9')]=_[_0xd8f9('0xa')](config[_0xd8f9('0x9')],{'host':_0xd8f9('0xb'),'port':0x18eb});var socket=require(_0xd8f9('0xc'))(new Redis(config['redis']));require(_0xd8f9('0xd'))[_0xd8f9('0xe')](socket);function respondWithRpcPromise(_0x4957ae,_0x33c31e,_0x4ac0ea){return new BPromise(function(_0x5caee9,_0x421aca){return client[_0xd8f9('0xf')](_0x4957ae,_0x4ac0ea)[_0xd8f9('0x10')](function(_0x379359){logger[_0xd8f9('0x11')](_0xd8f9('0x12'),_0x33c31e,_0xd8f9('0x13'));logger['debug'](_0xd8f9('0x14'),_0x33c31e,'request\x20sent',JSON[_0xd8f9('0x15')](_0x379359));if(_0x379359[_0xd8f9('0x16')]){if(_0x379359[_0xd8f9('0x16')]['code']===0x1f4){logger[_0xd8f9('0x16')](_0xd8f9('0x12'),_0x33c31e,_0x379359[_0xd8f9('0x16')][_0xd8f9('0x17')]);return _0x421aca(_0x379359['error'][_0xd8f9('0x17')]);}logger[_0xd8f9('0x16')](_0xd8f9('0x12'),_0x33c31e,_0x379359[_0xd8f9('0x16')][_0xd8f9('0x17')]);return _0x5caee9(_0x379359[_0xd8f9('0x16')][_0xd8f9('0x17')]);}else{logger['info']('MailAccount,\x20%s,\x20%s',_0x33c31e,_0xd8f9('0x13'));_0x5caee9(_0x379359[_0xd8f9('0x18')]['message']);}})[_0xd8f9('0x19')](function(_0x47bdea){logger[_0xd8f9('0x16')]('MailAccount,\x20%s,\x20%s',_0x33c31e,_0x47bdea);_0x421aca(_0x47bdea);});});}exports['GetMailAccount']=function(_0x58956e){var _0xa3b0cd=this;return new Promise(function(_0x5d094d,_0x37a252){return db[_0xd8f9('0x1a')][_0xd8f9('0x1b')]({'raw':_0x58956e[_0xd8f9('0x1c')]?_0x58956e[_0xd8f9('0x1c')][_0xd8f9('0x1d')]===undefined?!![]:![]:!![],'where':_0x58956e['options']?_0x58956e[_0xd8f9('0x1c')][_0xd8f9('0x1e')]||null:null,'attributes':_0x58956e[_0xd8f9('0x1c')]?_0x58956e[_0xd8f9('0x1c')][_0xd8f9('0x1f')]||null:null,'limit':_0x58956e[_0xd8f9('0x1c')]?_0x58956e['options'][_0xd8f9('0x20')]||null:null,'include':_0x58956e[_0xd8f9('0x1c')]?_0x58956e[_0xd8f9('0x1c')][_0xd8f9('0x21')]?_[_0xd8f9('0x22')](_0x58956e['options'][_0xd8f9('0x21')],function(_0x1d6796){return{'model':db[_0x1d6796[_0xd8f9('0x23')]],'as':_0x1d6796['as'],'attributes':_0x1d6796[_0xd8f9('0x1f')],'include':_0x1d6796[_0xd8f9('0x21')]?_[_0xd8f9('0x22')](_0x1d6796[_0xd8f9('0x21')],function(_0x461880){return{'model':db[_0x461880['model']],'as':_0x461880['as'],'attributes':_0x461880[_0xd8f9('0x1f')],'include':_0x461880[_0xd8f9('0x21')]?_[_0xd8f9('0x22')](_0x461880['include'],function(_0x5bd32e){return{'model':db[_0x5bd32e['model']],'as':_0x5bd32e['as'],'attributes':_0x5bd32e[_0xd8f9('0x1f')]};}):[]};}):[]};}):[]:[]})[_0xd8f9('0x10')](function(_0x5050a4){logger[_0xd8f9('0x11')](_0xd8f9('0x24'),_0x58956e);logger['debug'](_0xd8f9('0x24'),_0x58956e,JSON[_0xd8f9('0x15')](_0x5050a4));_0x5d094d(_0x5050a4);})[_0xd8f9('0x19')](function(_0x4caa27){logger[_0xd8f9('0x16')]('GetMailAccount',_0x4caa27[_0xd8f9('0x17')],_0x58956e);_0x37a252(_0xa3b0cd[_0xd8f9('0x16')](0x1f4,_0x4caa27['message']));});});};exports[_0xd8f9('0x25')]=function(_0x54b8c1){var _0x340f0a=this;return new Promise(function(_0x45f8bf,_0x26b7ff){return db[_0xd8f9('0x1a')][_0xd8f9('0x26')]({'raw':_0x54b8c1[_0xd8f9('0x1c')]?_0x54b8c1[_0xd8f9('0x1c')]['raw']===undefined?!![]:![]:!![],'where':_0x54b8c1[_0xd8f9('0x1c')]?_0x54b8c1['options']['where']||null:null,'attributes':_0x54b8c1['options']?_0x54b8c1['options'][_0xd8f9('0x1f')]||null:null,'include':_0x54b8c1[_0xd8f9('0x1c')]?_0x54b8c1[_0xd8f9('0x1c')][_0xd8f9('0x21')]?_[_0xd8f9('0x22')](_0x54b8c1['options']['include'],function(_0x1d5c7d){return{'model':db[_0x1d5c7d[_0xd8f9('0x23')]],'as':_0x1d5c7d['as'],'attributes':_0x1d5c7d['attributes'],'include':_0x1d5c7d[_0xd8f9('0x21')]?_[_0xd8f9('0x22')](_0x1d5c7d[_0xd8f9('0x21')],function(_0x5cd7a7){return{'model':db[_0x5cd7a7['model']],'as':_0x5cd7a7['as'],'attributes':_0x5cd7a7['attributes'],'include':_0x5cd7a7['include']?_[_0xd8f9('0x22')](_0x5cd7a7[_0xd8f9('0x21')],function(_0x324541){return{'model':db[_0x324541[_0xd8f9('0x23')]],'as':_0x324541['as'],'attributes':_0x324541[_0xd8f9('0x1f')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x3333ea){if(_0x54b8c1[_0xd8f9('0x1c')][_0xd8f9('0x27')]===!![])_0x3333ea[_0xd8f9('0x28')](_0xd8f9('0x29'),_0x3333ea[_0xd8f9('0x2a')]());logger[_0xd8f9('0x11')](_0xd8f9('0x25'),_0x54b8c1);logger[_0xd8f9('0x2b')](_0xd8f9('0x25'),_0x54b8c1,JSON[_0xd8f9('0x15')](_0x3333ea));_0x45f8bf(_0x3333ea);})['catch'](function(_0x310836){logger[_0xd8f9('0x16')](_0xd8f9('0x25'),_0x310836[_0xd8f9('0x17')],_0x54b8c1);_0x26b7ff(_0x340f0a['error'](0x1f4,_0x310836[_0xd8f9('0x17')]));});});};exports[_0xd8f9('0x2c')]=function(_0x8d41c4){var _0x32159f=this;return new Promise(function(_0x1ab301,_0x23330a){var _0x597357={'body':_0x8d41c4['body'],'channel':'mail'};var _0x3c6643=_[_0xd8f9('0x2d')](_[_0xd8f9('0x2e')](db[_0xd8f9('0x2f')][_0xd8f9('0x30')]),[_0xd8f9('0x31'),_0xd8f9('0x32'),_0xd8f9('0x33'),_0xd8f9('0x34')]);var _0x5ed1b7=![];if(_0x8d41c4['body']['id']){delete _0x8d41c4[_0xd8f9('0x35')]['id'];}if(_[_0xd8f9('0x36')](_0x8d41c4[_0xd8f9('0x35')]['from'])){return _0x23330a(_0x32159f['error'](0x1f4,_0xd8f9('0x37')));}if(_[_0xd8f9('0x36')](_0x8d41c4[_0xd8f9('0x35')]['body'])||_0x8d41c4[_0xd8f9('0x35')][_0xd8f9('0x35')]===''){return _0x23330a(_0x32159f[_0xd8f9('0x16')](0x1f4,_0xd8f9('0x38')));}if(_[_0xd8f9('0x36')](_0x8d41c4[_0xd8f9('0x35')][_0xd8f9('0x39')])){return _0x23330a(_0x32159f[_0xd8f9('0x16')](0x1f4,_0xd8f9('0x3a')+_0x3c6643));}if(!_['includes'](_0x3c6643,_0x8d41c4['body']['mapKey'])){return _0x23330a(_0x32159f[_0xd8f9('0x16')](0x1f4,_0xd8f9('0x3b')+_0x3c6643));}var _0x2c2396={};_0x2c2396[_0x8d41c4[_0xd8f9('0x35')][_0xd8f9('0x39')]]=_0x8d41c4[_0xd8f9('0x35')][_0xd8f9('0x3c')];return db[_0xd8f9('0x1a')][_0xd8f9('0x26')]({'where':{'id':_0x8d41c4[_0xd8f9('0x3d')]['id']},'include':[{'model':db[_0xd8f9('0x3e')],'as':_0xd8f9('0x3f'),'include':[{'model':db[_0xd8f9('0x2f')],'as':'Contacts','where':_0x2c2396,'limit':0x1,'order':[[_0xd8f9('0x32'),_0xd8f9('0x40')]]}]},{'model':db[_0xd8f9('0x41')],'as':_0xd8f9('0x42')},{'model':db['MailServerOut'],'as':_0xd8f9('0x43'),'include':[{'model':db['CloudProvider'],'as':'CloudProvider'}]}]})[_0xd8f9('0x10')](function(_0x14e622){if(_0x14e622&&_0x14e622[_0xd8f9('0x3f')]){var _0x1361c4=_0x14e622[_0xd8f9('0x44')]({'plain':!![]});_0x597357[_0xd8f9('0x3d')]=_[_0xd8f9('0x45')](_0x1361c4,[_0xd8f9('0x42'),_0xd8f9('0x3f')]);_0x597357[_0xd8f9('0x3d')]['smtpOptions']=_0x14e622['getSmtpOptions']();_0x597357['applications']=_0x1361c4[_0xd8f9('0x42')];_0x597357[_0xd8f9('0x46')]=_0x1361c4['List'];_0x597357[_0xd8f9('0x47')]=_[_0xd8f9('0x48')](_0x597357[_0xd8f9('0x47')],[_0xd8f9('0x49')],[_0xd8f9('0x4a')]);if(_0x597357[_0xd8f9('0x3d')]&&_0x597357[_0xd8f9('0x3d')][_0xd8f9('0x4b')]){_0x597357['applications'][_0xd8f9('0x4c')]({'id':0x0,'priority':_0x597357[_0xd8f9('0x47')][_0xd8f9('0x4d')]+0x1,'app':_0xd8f9('0x4e'),'appdata':_0xd8f9('0x4b'),'interval':_0xd8f9('0x4f')});}if(_0x597357[_0xd8f9('0x3d')][_0xd8f9('0x42')]){delete _0x597357[_0xd8f9('0x3d')][_0xd8f9('0x42')];}if(_0x597357[_0xd8f9('0x3d')]['List']){delete _0x597357[_0xd8f9('0x3d')][_0xd8f9('0x3f')];}if(_0x1361c4[_0xd8f9('0x3f')][_0xd8f9('0x50')]['length']){return _0x1361c4[_0xd8f9('0x3f')][_0xd8f9('0x50')][0x0];}var _0x3ac9f6=_['defaults'](_0x8d41c4[_0xd8f9('0x35')],{'firstName':_0x8d41c4[_0xd8f9('0x35')][_0xd8f9('0x3c')],'ListId':_0x1361c4[_0xd8f9('0x34')]});_0x3ac9f6[_0x8d41c4['body'][_0xd8f9('0x39')]]=_0x8d41c4[_0xd8f9('0x35')]['from'];return db['CmContact'][_0xd8f9('0x51')](_0x3ac9f6);}else{throw new Error(_0xd8f9('0x52'));}})[_0xd8f9('0x10')](function(_0x5043f5){_0x597357[_0xd8f9('0x53')]=_0x5043f5;if(_0x5043f5){if(!_0x8d41c4['body'][_0xd8f9('0x17')]['messageId']){_0x8d41c4[_0xd8f9('0x35')][_0xd8f9('0x17')][_0xd8f9('0x54')]=rs[_0xd8f9('0x55')]()+'\x20'+_0x8d41c4['body'][_0xd8f9('0x17')][_0xd8f9('0x3c')];}var _0x10aa0a={'ContactId':_0x5043f5['id'],'MailAccountId':_0x8d41c4[_0xd8f9('0x3d')]['id'],'inReplyTo':_0x8d41c4[_0xd8f9('0x35')][_0xd8f9('0x17')][_0xd8f9('0x54')],'to':_0x8d41c4[_0xd8f9('0x35')]['message'][_0xd8f9('0x3c')],'cc':_0x8d41c4[_0xd8f9('0x35')][_0xd8f9('0x17')]['cc'],'subject':_0x8d41c4[_0xd8f9('0x35')][_0xd8f9('0x17')]['subject'],'attach':_0x8d41c4['body']['message'][_0xd8f9('0x56')],'lastMsgAt':moment()[_0xd8f9('0x57')]('YYYY-MM-DD\x20HH:mm:ss'),'lastMsgDirection':'in'};return db['MailInteraction'][_0xd8f9('0x26')]({'where':{'closed':![],'MailAccountId':_0x8d41c4[_0xd8f9('0x3d')]['id']},'include':[{'model':db[_0xd8f9('0x58')],'as':_0xd8f9('0x59'),'attributes':[_0xd8f9('0x54')],'where':{'messageId':_0x8d41c4[_0xd8f9('0x35')]['message'][_0xd8f9('0x5a')]}}]})[_0xd8f9('0x10')](function(_0x15d4e5){if(_0x15d4e5){return[_0x15d4e5,![]];}return db[_0xd8f9('0x5b')]['create'](_0x10aa0a)[_0xd8f9('0x10')](function(_0x1e7251){return[_0x1e7251,!![]];});});}else{throw new Error(_0xd8f9('0x5c'));}})[_0xd8f9('0x5d')](function(_0xf900a3,_0x156c68){if(_0xf900a3){_0x5ed1b7=_0x156c68;if(!_0x156c68){return _0xf900a3[_0xd8f9('0x5e')]({'inReplyTo':_0x8d41c4[_0xd8f9('0x35')][_0xd8f9('0x17')]['messageId'],'to':_0x8d41c4['body']['message'][_0xd8f9('0x3c')],'cc':_0x8d41c4[_0xd8f9('0x35')][_0xd8f9('0x17')]['cc'],'subject':_0x8d41c4[_0xd8f9('0x35')][_0xd8f9('0x17')][_0xd8f9('0x5f')],'attach':_0xf900a3[_0xd8f9('0x56')]?_0xf900a3[_0xd8f9('0x56')]:_0x8d41c4['body'][_0xd8f9('0x17')]['attach'],'substatus':null,'substatusAt':moment()[_0xd8f9('0x57')](_0xd8f9('0x60')),'lastMsgAt':moment()[_0xd8f9('0x57')](_0xd8f9('0x60')),'lastMsgDirection':'in'});}else{return _0xf900a3;}}})[_0xd8f9('0x10')](function(_0x19b6c0){_0x597357[_0xd8f9('0x61')]=_0x19b6c0[_0xd8f9('0x44')]({'plain':!![]});_0x597357['interaction'][_0xd8f9('0x62')]=_0x5ed1b7;return db['MailMessage'][_0xd8f9('0x51')]({'body':_0x8d41c4['body']['body'],'MailAccountId':_0x8d41c4[_0xd8f9('0x3d')]['id'],'MailInteractionId':_0x19b6c0['id'],'direction':'in','ContactId':_0x597357['contact']['id'],'messageId':_0x8d41c4['body'][_0xd8f9('0x17')][_0xd8f9('0x54')],'from':_0x8d41c4[_0xd8f9('0x35')][_0xd8f9('0x17')][_0xd8f9('0x3c')],'to':_0x8d41c4['body'][_0xd8f9('0x17')]['to'],'cc':_0x8d41c4[_0xd8f9('0x35')]['message']['cc'],'subject':_0x8d41c4[_0xd8f9('0x35')][_0xd8f9('0x17')][_0xd8f9('0x5f')],'attach':_0x8d41c4[_0xd8f9('0x35')]['message'][_0xd8f9('0x56')],'Attachments':_0x8d41c4['body'][_0xd8f9('0x17')][_0xd8f9('0x63')],'originTo':_0x8d41c4[_0xd8f9('0x35')][_0xd8f9('0x17')][_0xd8f9('0x64')],'originCc':_0x8d41c4[_0xd8f9('0x35')][_0xd8f9('0x17')][_0xd8f9('0x65')],'bcc':_0x8d41c4[_0xd8f9('0x35')][_0xd8f9('0x17')][_0xd8f9('0x66')],'ChatWebsiteId':_0x8d41c4[_0xd8f9('0x35')][_0xd8f9('0x17')][_0xd8f9('0x67')]||null,'originChannel':_0x8d41c4[_0xd8f9('0x35')][_0xd8f9('0x17')][_0xd8f9('0x68')]||_0xd8f9('0x69'),'ChatOfflineMessageId':_0x8d41c4['body'][_0xd8f9('0x17')][_0xd8f9('0x6a')]||null},{'include':[{'model':db['Attachment'],'as':_0xd8f9('0x6b')}]});})[_0xd8f9('0x10')](function(_0x3a3e83){_0x597357[_0xd8f9('0x17')]=_0x3a3e83;if(!_0x597357[_0xd8f9('0x61')]['UserId']){return;}return db[_0xd8f9('0x6c')]['find']({'attributes':['id',_0xd8f9('0x6d')],'where':{'id':_0x597357['interaction'][_0xd8f9('0x6e')]}});})[_0xd8f9('0x10')](function(_0x556bb2){if(_0x556bb2){_0x597357[_0xd8f9('0x47')]['unshift']({'id':0x0,'priority':0x0,'app':'agent','appdata':_0x556bb2[_0xd8f9('0x6d')]+','+(_0x597357['account']['waitForTheAssignedAgent']||0xa),'interval':_0xd8f9('0x4f')});}if(!_0x597357['interaction'][_0xd8f9('0x6f')]){return;}return db['MailQueue'][_0xd8f9('0x26')]({'attributes':['id',_0xd8f9('0x6d')],'where':{'id':_0x597357['interaction'][_0xd8f9('0x6f')]}});})[_0xd8f9('0x10')](function(_0x3754bd){if(_0x3754bd){_0x597357[_0xd8f9('0x47')]['unshift']({'id':0x0,'priority':0x1,'app':_0xd8f9('0x70'),'appdata':_0x3754bd[_0xd8f9('0x6d')]+','+(_0x597357[_0xd8f9('0x3d')][_0xd8f9('0x71')]||0x12c),'interval':_0xd8f9('0x4f')});}return respondWithRpcPromise(_0xd8f9('0x72'),_0xd8f9('0x73'),_0x597357);})[_0xd8f9('0x10')](function(_0x56e4b0){_0x1ab301(_0x56e4b0);})[_0xd8f9('0x19')](function(_0x3c0966){_0x23330a(_0x32159f['error'](0x1f4,_0x3c0966['message']));});});};
\ No newline at end of file