Built motion from commit ded33658aad58fc8de845a8299a9db59a88cc353. Version 3.0.0...
[motion-next.git] / server / api / mailAccount / mailAccount.rpc.js
index 61f175e..65382d3 100644 (file)
@@ -1 +1 @@
-const a397_0x3fa5=['model','Smtp','CompanyId','./mailAccount.socket','../../rediscache','MailAccount,\x20%s,\x20%s','MailInteraction','findOne','client','CmContact','CmList','waitForTheAssignedAgent','omit','info','inReplyTo','MailServerOut','attachments','list','rpc','length','startRouting','update','close','then','generate','GetMailAccount','YYYY-MM-DD\x20HH:mm:ss','mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','catch','message','defaults','debug','attach','applications','difference','interaction','User','map','messageId','register','push','randomstring','include','../../config/logger','stringify','attributes','MailAccount','priority','body','limit','error','Applications','MailAccount,\x20%s,\x20%s,\x20%s','format','http','mapKey','agent','options','subject','request','Start','code','bcc','*,*,*,*','Attachments','Messages','originTo','result','UserId','keys','Contacts','unshift','orderBy','MailApplication','autoclose','account','from','isNil','get','ListId','mail','contact','originCc','ShowMailAccount','moment','create','List','request\x20sent','updatedAt','raw','lodash'];(function(_0x12ff30,_0x3fa567){const _0x4b057e=function(_0xe3d41e){while(--_0xe3d41e){_0x12ff30['push'](_0x12ff30['shift']());}};_0x4b057e(++_0x3fa567);}(a397_0x3fa5,0xd6));const a397_0x4b05=function(_0x12ff30,_0x3fa567){_0x12ff30=_0x12ff30-0x0;let _0x4b057e=a397_0x3fa5[_0x12ff30];return _0x4b057e;};const _0x32daef=a397_0x4b05;'use strict';const _=require(_0x32daef('0x3a')),db=require('../../mysqldb')['db'],logger=require(_0x32daef('0xb'))(_0x32daef('0x4d')),{getSocket}=require(_0x32daef('0x3f')),socket=getSocket(),rs=require(_0x32daef('0x9')),moment=require(_0x32daef('0x34')),jayson=require('jayson/promise'),client=jayson[_0x32daef('0x43')][_0x32daef('0x16')]({'port':0x232c});require(_0x32daef('0x3e'))[_0x32daef('0x7')](socket);function respondWithRpcPromise(_0xe3d41e,_0x3bd385,_0x2f4a0d){return new Promise(function(_0x4a855b,_0x4adc07){const _0x338885=a397_0x4b05;return client[_0x338885('0x1b')](_0xe3d41e,_0x2f4a0d)[_0x338885('0x52')](function(_0x2a5702){const _0x2ef81a=_0x338885;logger[_0x2ef81a('0x48')](_0x2ef81a('0x40'),_0x3bd385,_0x2ef81a('0x37')),logger[_0x2ef81a('0x5a')](_0x2ef81a('0x14'),_0x3bd385,_0x2ef81a('0x37'),JSON['stringify'](_0x2a5702));if(_0x2a5702['error']){if(_0x2a5702[_0x2ef81a('0x12')][_0x2ef81a('0x1d')]===0x1f4)return logger['error'](_0x2ef81a('0x40'),_0x3bd385,_0x2a5702[_0x2ef81a('0x12')][_0x2ef81a('0x58')]),_0x4adc07(_0x2a5702[_0x2ef81a('0x12')][_0x2ef81a('0x58')]);return logger[_0x2ef81a('0x12')](_0x2ef81a('0x40'),_0x3bd385,_0x2a5702[_0x2ef81a('0x12')][_0x2ef81a('0x58')]),_0x4a855b(_0x2a5702[_0x2ef81a('0x12')][_0x2ef81a('0x58')]);}else logger[_0x2ef81a('0x48')]('MailAccount,\x20%s,\x20%s',_0x3bd385,'request\x20sent'),_0x4a855b(_0x2a5702[_0x2ef81a('0x23')][_0x2ef81a('0x58')]);})['catch'](function(_0x43e7e5){const _0x10bc2c=_0x338885;logger[_0x10bc2c('0x12')]('MailAccount,\x20%s,\x20%s',_0x3bd385,_0x43e7e5),_0x4adc07(_0x43e7e5);});});}exports[_0x32daef('0x54')]=function(_0x85ecc){const _0x335366=this;return new Promise(function(_0x311560,_0x2f01d7){const _0x46d8c0=a397_0x4b05;return db[_0x46d8c0('0xe')]['findAll']({'raw':_0x85ecc[_0x46d8c0('0x19')]?_0x85ecc[_0x46d8c0('0x19')][_0x46d8c0('0x39')]===undefined?!![]:![]:!![],'where':_0x85ecc[_0x46d8c0('0x19')]?_0x85ecc['options']['where']||null:null,'attributes':_0x85ecc[_0x46d8c0('0x19')]?_0x85ecc[_0x46d8c0('0x19')][_0x46d8c0('0xd')]||null:null,'limit':_0x85ecc['options']?_0x85ecc['options'][_0x46d8c0('0x11')]||null:null,'include':_0x85ecc[_0x46d8c0('0x19')]?_0x85ecc[_0x46d8c0('0x19')][_0x46d8c0('0xa')]?_[_0x46d8c0('0x5')](_0x85ecc[_0x46d8c0('0x19')][_0x46d8c0('0xa')],function(_0x59d7ab){const _0x5cf1e9=_0x46d8c0;return{'model':db[_0x59d7ab[_0x5cf1e9('0x3b')]],'as':_0x59d7ab['as'],'attributes':_0x59d7ab[_0x5cf1e9('0xd')],'include':_0x59d7ab['include']?_[_0x5cf1e9('0x5')](_0x59d7ab[_0x5cf1e9('0xa')],function(_0x1e997b){const _0x2cb647=_0x5cf1e9;return{'model':db[_0x1e997b[_0x2cb647('0x3b')]],'as':_0x1e997b['as'],'attributes':_0x1e997b[_0x2cb647('0xd')],'include':_0x1e997b['include']?_[_0x2cb647('0x5')](_0x1e997b['include'],function(_0x27d8c2){const _0x3e5f8f=_0x2cb647;return{'model':db[_0x27d8c2[_0x3e5f8f('0x3b')]],'as':_0x27d8c2['as'],'attributes':_0x27d8c2[_0x3e5f8f('0xd')]};}):[]};}):[]};}):[]:[]})[_0x46d8c0('0x52')](function(_0x23f85c){const _0x22a184=_0x46d8c0;logger[_0x22a184('0x48')](_0x22a184('0x54'),_0x85ecc),logger[_0x22a184('0x5a')](_0x22a184('0x54'),_0x85ecc,JSON[_0x22a184('0xc')](_0x23f85c)),_0x311560(_0x23f85c);})[_0x46d8c0('0x57')](function(_0x9b5f9d){const _0x4cc3da=_0x46d8c0;logger[_0x4cc3da('0x12')](_0x4cc3da('0x54'),_0x9b5f9d[_0x4cc3da('0x58')],_0x85ecc),_0x2f01d7(_0x335366['error'](0x1f4,_0x9b5f9d[_0x4cc3da('0x58')]));});});},exports[_0x32daef('0x33')]=function(_0x1b0213){const _0x3da2d6=this;return new Promise(function(_0x154f77,_0x586dac){const _0x567aed=a397_0x4b05;return db[_0x567aed('0xe')][_0x567aed('0x42')]({'raw':_0x1b0213['options']?_0x1b0213['options']['raw']===undefined?!![]:![]:!![],'where':_0x1b0213['options']?_0x1b0213[_0x567aed('0x19')]['where']||null:null,'attributes':_0x1b0213['options']?_0x1b0213[_0x567aed('0x19')][_0x567aed('0xd')]||null:null,'include':_0x1b0213[_0x567aed('0x19')]?_0x1b0213[_0x567aed('0x19')]['include']?_['map'](_0x1b0213['options'][_0x567aed('0xa')],function(_0x3e271d){const _0x1641f6=_0x567aed;return{'model':db[_0x3e271d[_0x1641f6('0x3b')]],'as':_0x3e271d['as'],'attributes':_0x3e271d[_0x1641f6('0xd')],'include':_0x3e271d[_0x1641f6('0xa')]?_[_0x1641f6('0x5')](_0x3e271d[_0x1641f6('0xa')],function(_0x7d1384){const _0x39d367=_0x1641f6;return{'model':db[_0x7d1384[_0x39d367('0x3b')]],'as':_0x7d1384['as'],'attributes':_0x7d1384[_0x39d367('0xd')],'include':_0x7d1384['include']?_[_0x39d367('0x5')](_0x7d1384[_0x39d367('0xa')],function(_0x1a5f48){const _0x5b2956=_0x39d367;return{'model':db[_0x1a5f48[_0x5b2956('0x3b')]],'as':_0x1a5f48['as'],'attributes':_0x1a5f48['attributes']};}):[]};}):[]};}):[]:[]})['then'](function(_0x195787){const _0x842b9d=_0x567aed;logger[_0x842b9d('0x48')](_0x842b9d('0x33'),_0x1b0213),logger[_0x842b9d('0x5a')]('ShowMailAccount',_0x1b0213,JSON['stringify'](_0x195787)),_0x154f77(_0x195787);})[_0x567aed('0x57')](function(_0x5ad647){const _0x1ec42f=_0x567aed;logger[_0x1ec42f('0x12')](_0x1ec42f('0x33'),_0x5ad647['message'],_0x1b0213),_0x586dac(_0x3da2d6[_0x1ec42f('0x12')](0x1f4,_0x5ad647['message']));});});},exports['NotifyMailAccount']=function(_0x53cd30){const _0xa3a666=this;return new Promise(function(_0x38f9f3,_0x2c33aa){const _0x502833=a397_0x4b05,_0xc64d23={'body':_0x53cd30[_0x502833('0x10')],'channel':_0x502833('0x30')},_0x8df9be=_[_0x502833('0x2')](_[_0x502833('0x25')](db[_0x502833('0x44')]['rawAttributes']),['createdAt',_0x502833('0x38'),_0x502833('0x3d'),'ListId']);let _0x2ac9d9=![];_0x53cd30['body']['id']&&delete _0x53cd30[_0x502833('0x10')]['id'];if(_['isNil'](_0x53cd30[_0x502833('0x10')][_0x502833('0x2c')]))return _0x2c33aa(_0xa3a666[_0x502833('0x12')](0x1f4,'from\x20is\x20mandatory'));if(_[_0x502833('0x2d')](_0x53cd30[_0x502833('0x10')]['body'])||_0x53cd30[_0x502833('0x10')][_0x502833('0x10')]==='')return _0x2c33aa(_0xa3a666[_0x502833('0x12')](0x1f4,'body\x20is\x20mandatory\x20and\x20not\x20empty'));if(_[_0x502833('0x2d')](_0x53cd30[_0x502833('0x10')][_0x502833('0x17')]))return _0x2c33aa(_0xa3a666[_0x502833('0x12')](0x1f4,_0x502833('0x56')+_0x8df9be));if(!_['includes'](_0x8df9be,_0x53cd30[_0x502833('0x10')]['mapKey']))return _0x2c33aa(_0xa3a666[_0x502833('0x12')](0x1f4,'mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20'+_0x8df9be));const _0xe40e90={};return _0xe40e90[_0x53cd30[_0x502833('0x10')][_0x502833('0x17')]]=_0x53cd30[_0x502833('0x10')][_0x502833('0x2c')],db[_0x502833('0xe')]['findOne']({'where':{'id':_0x53cd30['account']['id']},'include':[{'model':db[_0x502833('0x45')],'as':_0x502833('0x36'),'include':[{'model':db[_0x502833('0x44')],'as':_0x502833('0x26'),'where':_0xe40e90,'limit':0x1,'order':[[_0x502833('0x38'),'DESC']]}]},{'model':db[_0x502833('0x29')],'as':_0x502833('0x13')},{'model':db[_0x502833('0x4a')],'as':_0x502833('0x3c')}]})['then'](function(_0x24e9c8){const _0x344eae=_0x502833;if(_0x24e9c8&&_0x24e9c8[_0x344eae('0x36')]){const _0x2bd605=_0x24e9c8[_0x344eae('0x2e')]({'plain':!![]});_0xc64d23[_0x344eae('0x2b')]=_[_0x344eae('0x47')](_0x2bd605,[_0x344eae('0x13'),_0x344eae('0x36')]),_0xc64d23['applications']=_0x2bd605['Applications'],_0xc64d23[_0x344eae('0x4c')]=_0x2bd605[_0x344eae('0x36')],_0xc64d23['applications']=_[_0x344eae('0x28')](_0xc64d23['applications'],[_0x344eae('0xf')],['asc']);_0xc64d23['account']&&_0xc64d23[_0x344eae('0x2b')][_0x344eae('0x2a')]&&_0xc64d23[_0x344eae('0x1')][_0x344eae('0x8')]({'id':0x0,'priority':_0xc64d23[_0x344eae('0x1')][_0x344eae('0x4e')]+0x1,'app':_0x344eae('0x51'),'appdata':_0x344eae('0x2a'),'interval':_0x344eae('0x1f')});_0xc64d23[_0x344eae('0x2b')][_0x344eae('0x13')]&&delete _0xc64d23['account'][_0x344eae('0x13')];_0xc64d23[_0x344eae('0x2b')][_0x344eae('0x36')]&&delete _0xc64d23[_0x344eae('0x2b')][_0x344eae('0x36')];if(_0x2bd605[_0x344eae('0x36')]['Contacts'][_0x344eae('0x4e')])return _0x2bd605[_0x344eae('0x36')][_0x344eae('0x26')][0x0];const _0x34cce5=_[_0x344eae('0x59')](_0x53cd30['body'],{'firstName':_0x53cd30[_0x344eae('0x10')][_0x344eae('0x2c')],'ListId':_0x2bd605[_0x344eae('0x2f')]});return _0x34cce5[_0x53cd30[_0x344eae('0x10')][_0x344eae('0x17')]]=_0x53cd30[_0x344eae('0x10')][_0x344eae('0x2c')],db[_0x344eae('0x44')][_0x344eae('0x35')](_0x34cce5);}else throw new Error('List\x20not\x20found');})[_0x502833('0x52')](function(_0x533336){const _0xec123d=_0x502833;_0xc64d23[_0xec123d('0x31')]=_0x533336;if(_0x533336){!_0x53cd30['body']['message']['messageId']&&(_0x53cd30['body'][_0xec123d('0x58')][_0xec123d('0x6')]=rs[_0xec123d('0x53')]()+'\x20'+_0x53cd30['body'][_0xec123d('0x58')][_0xec123d('0x2c')]);const _0x519cf8={'ContactId':_0x533336['id'],'MailAccountId':_0x53cd30[_0xec123d('0x2b')]['id'],'inReplyTo':_0x53cd30[_0xec123d('0x10')][_0xec123d('0x58')][_0xec123d('0x6')],'to':_0x53cd30[_0xec123d('0x10')][_0xec123d('0x58')][_0xec123d('0x2c')],'cc':_0x53cd30[_0xec123d('0x10')][_0xec123d('0x58')]['cc'],'subject':_0x53cd30['body'][_0xec123d('0x58')][_0xec123d('0x1a')],'attach':_0x53cd30[_0xec123d('0x10')]['message'][_0xec123d('0x0')],'lastMsgAt':moment()[_0xec123d('0x15')](_0xec123d('0x55')),'lastMsgDirection':'in','lastMsgBody':_0x53cd30[_0xec123d('0x10')][_0xec123d('0x10')]};return db[_0xec123d('0x41')][_0xec123d('0x42')]({'where':{'closed':![],'MailAccountId':_0x53cd30[_0xec123d('0x2b')]['id']},'include':[{'model':db['MailMessage'],'as':_0xec123d('0x21'),'attributes':[_0xec123d('0x6')],'where':{'messageId':_0x53cd30[_0xec123d('0x10')]['message'][_0xec123d('0x49')]}}]})[_0xec123d('0x52')](function(_0x4d926e){const _0x1e9082=_0xec123d;if(_0x4d926e)return[_0x4d926e,![]];return db[_0x1e9082('0x41')][_0x1e9082('0x35')](_0x519cf8)[_0x1e9082('0x52')](function(_0x3a019f){return[_0x3a019f,!![]];});});}else throw new Error('Contact\x20not\x20found');})['then'](function([_0x505517,_0x26b656]){const _0x319393=_0x502833;if(_0x505517)return _0x2ac9d9=_0x26b656,!_0x26b656?_0x505517[_0x319393('0x50')]({'inReplyTo':_0x53cd30[_0x319393('0x10')][_0x319393('0x58')]['messageId'],'to':_0x53cd30[_0x319393('0x10')][_0x319393('0x58')][_0x319393('0x2c')],'cc':_0x53cd30[_0x319393('0x10')][_0x319393('0x58')]['cc'],'subject':_0x53cd30[_0x319393('0x10')][_0x319393('0x58')]['subject'],'attach':_0x505517[_0x319393('0x0')]?_0x505517['attach']:_0x53cd30[_0x319393('0x10')][_0x319393('0x58')]['attach'],'substatus':null,'substatusAt':moment()[_0x319393('0x15')](_0x319393('0x55')),'lastMsgAt':moment()[_0x319393('0x15')](_0x319393('0x55')),'lastMsgDirection':'in','lastMsgBody':_0x53cd30['body'][_0x319393('0x10')]}):_0x505517;})[_0x502833('0x52')](function(_0x15c267){const _0x2449e4=_0x502833;return _0xc64d23[_0x2449e4('0x3')]=_0x15c267[_0x2449e4('0x2e')]({'plain':!![]}),_0xc64d23[_0x2449e4('0x3')]['created']=_0x2ac9d9,db['MailMessage'][_0x2449e4('0x35')]({'body':_0x53cd30[_0x2449e4('0x10')][_0x2449e4('0x10')],'MailAccountId':_0x53cd30['account']['id'],'MailInteractionId':_0x15c267['id'],'direction':'in','ContactId':_0xc64d23[_0x2449e4('0x31')]['id'],'messageId':_0x53cd30[_0x2449e4('0x10')][_0x2449e4('0x58')]['messageId'],'from':_0x53cd30['body'][_0x2449e4('0x58')][_0x2449e4('0x2c')],'to':_0x53cd30['body']['message']['to'],'cc':_0x53cd30[_0x2449e4('0x10')][_0x2449e4('0x58')]['cc'],'subject':_0x53cd30[_0x2449e4('0x10')]['message'][_0x2449e4('0x1a')],'attach':_0x53cd30['body'][_0x2449e4('0x58')][_0x2449e4('0x0')],'Attachments':_0x53cd30['body']['message'][_0x2449e4('0x4b')],'originTo':_0x53cd30[_0x2449e4('0x10')][_0x2449e4('0x58')][_0x2449e4('0x22')],'originCc':_0x53cd30[_0x2449e4('0x10')]['message'][_0x2449e4('0x32')],'bcc':_0x53cd30[_0x2449e4('0x10')][_0x2449e4('0x58')][_0x2449e4('0x1e')]},{'include':[{'model':db['Attachment'],'as':_0x2449e4('0x20')}]});})[_0x502833('0x52')](function(_0x54ac22){const _0x31159e=_0x502833;_0xc64d23[_0x31159e('0x58')]=_0x54ac22;if(_0xc64d23[_0x31159e('0x3')][_0x31159e('0x24')])return db[_0x31159e('0x4')][_0x31159e('0x42')]({'attributes':['id','name'],'where':{'id':_0xc64d23[_0x31159e('0x3')][_0x31159e('0x24')]}})['then'](function(_0x3b9865){const _0xc9ba6f=_0x31159e;return _0x3b9865&&_0xc64d23[_0xc9ba6f('0x1')][_0xc9ba6f('0x27')]({'id':0x0,'priority':0x0,'app':_0xc9ba6f('0x18'),'appdata':_0x3b9865['name']+','+(_0xc64d23[_0xc9ba6f('0x2b')][_0xc9ba6f('0x46')]||0xa),'interval':_0xc9ba6f('0x1f')}),respondWithRpcPromise(_0xc9ba6f('0x1c'),_0xc9ba6f('0x4f'),_0xc64d23);});return respondWithRpcPromise('Start',_0x31159e('0x4f'),_0xc64d23);})[_0x502833('0x52')](function(_0x4adcea){_0x38f9f3(_0x4adcea);})['catch'](function(_0x1a519d){const _0x54c76d=_0x502833;_0x2c33aa(_0xa3a666[_0x54c76d('0x12')](0x1f4,_0x1a519d['message']));});});};
\ No newline at end of file
+const a397_0x34d2=['include','register','body\x20is\x20mandatory\x20and\x20not\x20empty','mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','attributes','findOne','request','debug','updatedAt','message','UserId','update','priority','client','Messages','limit','Attachments','keys','waitForTheAssignedAgent','raw','applications','info','push','YYYY-MM-DD\x20HH:mm:ss','mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','MailInteraction','catch','omit','../../config/logger','stringify','../../rediscache','Applications','model','then','from','account','mail','CompanyId','CmContact','MailServerOut','from\x20is\x20mandatory','MailMessage','Contact\x20not\x20found','list','interaction','map','./mailAccount.socket','*,*,*,*','Smtp','Start','request\x20sent','rpc','Contacts','ListId','close','body','where','includes','orderBy','GetMailAccount','get','format','DESC','subject','code','isNil','randomstring','difference','error','name','messageId','options','inReplyTo','length','ShowMailAccount','startRouting','create','bcc','jayson/promise','MailAccount,\x20%s,\x20%s','generate','mapKey','attach','contact','originTo','MailAccount','originCc','asc','rawAttributes','result','moment','findAll','defaults','NotifyMailAccount','autoclose','List'];(function(_0x289251,_0x34d240){const _0x279f61=function(_0x826612){while(--_0x826612){_0x289251['push'](_0x289251['shift']());}};_0x279f61(++_0x34d240);}(a397_0x34d2,0xa2));const a397_0x279f=function(_0x289251,_0x34d240){_0x289251=_0x289251-0x0;let _0x279f61=a397_0x34d2[_0x289251];return _0x279f61;};const _0x535acc=a397_0x279f;'use strict';const _=require('lodash'),db=require('../../mysqldb')['db'],logger=require(_0x535acc('0x3a'))(_0x535acc('0x51')),{getSocket}=require(_0x535acc('0x3c')),socket=getSocket(),rs=require(_0x535acc('0x0')),moment=require(_0x535acc('0x18')),jayson=require(_0x535acc('0xc')),client=jayson[_0x535acc('0x2b')]['http']({'port':0x232c});require(_0x535acc('0x4c'))[_0x535acc('0x1f')](socket);function respondWithRpcPromise(_0x826612,_0x1fcc4a,_0x73ad1a){return new Promise(function(_0x12b4c7,_0x4389f0){const _0x2e8dfc=a397_0x279f;return client[_0x2e8dfc('0x24')](_0x826612,_0x73ad1a)[_0x2e8dfc('0x3f')](function(_0x2f80da){const _0x3a8603=_0x2e8dfc;logger[_0x3a8603('0x33')](_0x3a8603('0xd'),_0x1fcc4a,_0x3a8603('0x50')),logger[_0x3a8603('0x25')]('MailAccount,\x20%s,\x20%s,\x20%s',_0x1fcc4a,_0x3a8603('0x50'),JSON[_0x3a8603('0x3b')](_0x2f80da));if(_0x2f80da[_0x3a8603('0x2')]){if(_0x2f80da[_0x3a8603('0x2')][_0x3a8603('0x5e')]===0x1f4)return logger[_0x3a8603('0x2')](_0x3a8603('0xd'),_0x1fcc4a,_0x2f80da[_0x3a8603('0x2')][_0x3a8603('0x27')]),_0x4389f0(_0x2f80da[_0x3a8603('0x2')][_0x3a8603('0x27')]);return logger[_0x3a8603('0x2')]('MailAccount,\x20%s,\x20%s',_0x1fcc4a,_0x2f80da[_0x3a8603('0x2')][_0x3a8603('0x27')]),_0x12b4c7(_0x2f80da[_0x3a8603('0x2')][_0x3a8603('0x27')]);}else logger[_0x3a8603('0x33')]('MailAccount,\x20%s,\x20%s',_0x1fcc4a,_0x3a8603('0x50')),_0x12b4c7(_0x2f80da[_0x3a8603('0x17')]['message']);})[_0x2e8dfc('0x38')](function(_0x27dde0){const _0x362834=_0x2e8dfc;logger[_0x362834('0x2')](_0x362834('0xd'),_0x1fcc4a,_0x27dde0),_0x4389f0(_0x27dde0);});});}exports['GetMailAccount']=function(_0x4e8c49){const _0x58482a=this;return new Promise(function(_0x918c5c,_0x5f475f){const _0x1d85e6=a397_0x279f;return db[_0x1d85e6('0x13')][_0x1d85e6('0x19')]({'raw':_0x4e8c49[_0x1d85e6('0x5')]?_0x4e8c49['options'][_0x1d85e6('0x31')]===undefined?!![]:![]:!![],'where':_0x4e8c49[_0x1d85e6('0x5')]?_0x4e8c49[_0x1d85e6('0x5')][_0x1d85e6('0x56')]||null:null,'attributes':_0x4e8c49[_0x1d85e6('0x5')]?_0x4e8c49[_0x1d85e6('0x5')][_0x1d85e6('0x22')]||null:null,'limit':_0x4e8c49[_0x1d85e6('0x5')]?_0x4e8c49['options'][_0x1d85e6('0x2d')]||null:null,'include':_0x4e8c49[_0x1d85e6('0x5')]?_0x4e8c49[_0x1d85e6('0x5')]['include']?_[_0x1d85e6('0x4b')](_0x4e8c49['options']['include'],function(_0x50fde5){const _0x2b4017=_0x1d85e6;return{'model':db[_0x50fde5[_0x2b4017('0x3e')]],'as':_0x50fde5['as'],'attributes':_0x50fde5['attributes'],'include':_0x50fde5['include']?_['map'](_0x50fde5['include'],function(_0x4c398c){const _0x15c59b=_0x2b4017;return{'model':db[_0x4c398c[_0x15c59b('0x3e')]],'as':_0x4c398c['as'],'attributes':_0x4c398c['attributes'],'include':_0x4c398c[_0x15c59b('0x1e')]?_[_0x15c59b('0x4b')](_0x4c398c[_0x15c59b('0x1e')],function(_0x96cf89){const _0x4c24c9=_0x15c59b;return{'model':db[_0x96cf89[_0x4c24c9('0x3e')]],'as':_0x96cf89['as'],'attributes':_0x96cf89[_0x4c24c9('0x22')]};}):[]};}):[]};}):[]:[]})[_0x1d85e6('0x3f')](function(_0x4cbce4){const _0x186df0=_0x1d85e6;logger[_0x186df0('0x33')](_0x186df0('0x59'),_0x4e8c49),logger[_0x186df0('0x25')](_0x186df0('0x59'),_0x4e8c49,JSON[_0x186df0('0x3b')](_0x4cbce4)),_0x918c5c(_0x4cbce4);})[_0x1d85e6('0x38')](function(_0x265a81){const _0x364799=_0x1d85e6;logger['error'](_0x364799('0x59'),_0x265a81[_0x364799('0x27')],_0x4e8c49),_0x5f475f(_0x58482a[_0x364799('0x2')](0x1f4,_0x265a81['message']));});});},exports[_0x535acc('0x8')]=function(_0x26b60e){const _0x463e4a=this;return new Promise(function(_0xe0dad7,_0x259ed1){const _0x5e97c0=a397_0x279f;return db['MailAccount'][_0x5e97c0('0x23')]({'raw':_0x26b60e[_0x5e97c0('0x5')]?_0x26b60e[_0x5e97c0('0x5')][_0x5e97c0('0x31')]===undefined?!![]:![]:!![],'where':_0x26b60e[_0x5e97c0('0x5')]?_0x26b60e['options'][_0x5e97c0('0x56')]||null:null,'attributes':_0x26b60e['options']?_0x26b60e[_0x5e97c0('0x5')]['attributes']||null:null,'include':_0x26b60e['options']?_0x26b60e[_0x5e97c0('0x5')][_0x5e97c0('0x1e')]?_[_0x5e97c0('0x4b')](_0x26b60e[_0x5e97c0('0x5')]['include'],function(_0x1c25be){const _0x4d468e=_0x5e97c0;return{'model':db[_0x1c25be['model']],'as':_0x1c25be['as'],'attributes':_0x1c25be['attributes'],'include':_0x1c25be[_0x4d468e('0x1e')]?_[_0x4d468e('0x4b')](_0x1c25be[_0x4d468e('0x1e')],function(_0x8b8dc6){const _0x7f9785=_0x4d468e;return{'model':db[_0x8b8dc6[_0x7f9785('0x3e')]],'as':_0x8b8dc6['as'],'attributes':_0x8b8dc6['attributes'],'include':_0x8b8dc6['include']?_[_0x7f9785('0x4b')](_0x8b8dc6[_0x7f9785('0x1e')],function(_0x475f73){const _0x1f589e=_0x7f9785;return{'model':db[_0x475f73[_0x1f589e('0x3e')]],'as':_0x475f73['as'],'attributes':_0x475f73[_0x1f589e('0x22')]};}):[]};}):[]};}):[]:[]})[_0x5e97c0('0x3f')](function(_0x18cbad){const _0x3836a8=_0x5e97c0;logger['info']('ShowMailAccount',_0x26b60e),logger[_0x3836a8('0x25')](_0x3836a8('0x8'),_0x26b60e,JSON['stringify'](_0x18cbad)),_0xe0dad7(_0x18cbad);})[_0x5e97c0('0x38')](function(_0x4339bc){const _0x461d80=_0x5e97c0;logger[_0x461d80('0x2')](_0x461d80('0x8'),_0x4339bc[_0x461d80('0x27')],_0x26b60e),_0x259ed1(_0x463e4a[_0x461d80('0x2')](0x1f4,_0x4339bc[_0x461d80('0x27')]));});});},exports[_0x535acc('0x1b')]=function(_0x2f9eb8){const _0x50adb3=this;return new Promise(function(_0x2bd479,_0x53c63e){const _0x1b786f=a397_0x279f,_0x27d02d={'body':_0x2f9eb8[_0x1b786f('0x55')],'channel':_0x1b786f('0x42')},_0x53f54d=_[_0x1b786f('0x1')](_[_0x1b786f('0x2f')](db[_0x1b786f('0x44')][_0x1b786f('0x16')]),['createdAt',_0x1b786f('0x26'),_0x1b786f('0x43'),_0x1b786f('0x53')]);let _0x58d2e0=![];_0x2f9eb8[_0x1b786f('0x55')]['id']&&delete _0x2f9eb8[_0x1b786f('0x55')]['id'];if(_[_0x1b786f('0x5f')](_0x2f9eb8[_0x1b786f('0x55')][_0x1b786f('0x40')]))return _0x53c63e(_0x50adb3[_0x1b786f('0x2')](0x1f4,_0x1b786f('0x46')));if(_[_0x1b786f('0x5f')](_0x2f9eb8[_0x1b786f('0x55')][_0x1b786f('0x55')])||_0x2f9eb8[_0x1b786f('0x55')][_0x1b786f('0x55')]==='')return _0x53c63e(_0x50adb3[_0x1b786f('0x2')](0x1f4,_0x1b786f('0x20')));if(_[_0x1b786f('0x5f')](_0x2f9eb8['body'][_0x1b786f('0xf')]))return _0x53c63e(_0x50adb3[_0x1b786f('0x2')](0x1f4,_0x1b786f('0x21')+_0x53f54d));if(!_[_0x1b786f('0x57')](_0x53f54d,_0x2f9eb8[_0x1b786f('0x55')][_0x1b786f('0xf')]))return _0x53c63e(_0x50adb3['error'](0x1f4,_0x1b786f('0x36')+_0x53f54d));const _0x3466a2={};return _0x3466a2[_0x2f9eb8[_0x1b786f('0x55')][_0x1b786f('0xf')]]=_0x2f9eb8[_0x1b786f('0x55')]['from'],db['MailAccount'][_0x1b786f('0x23')]({'where':{'id':_0x2f9eb8[_0x1b786f('0x41')]['id']},'include':[{'model':db['CmList'],'as':_0x1b786f('0x1d'),'include':[{'model':db[_0x1b786f('0x44')],'as':_0x1b786f('0x52'),'where':_0x3466a2,'limit':0x1,'order':[[_0x1b786f('0x26'),_0x1b786f('0x5c')]]}]},{'model':db['MailApplication'],'as':'Applications'},{'model':db[_0x1b786f('0x45')],'as':_0x1b786f('0x4e')}]})['then'](function(_0x43d270){const _0x1d81a0=_0x1b786f;if(_0x43d270&&_0x43d270['List']){const _0x11c087=_0x43d270[_0x1d81a0('0x5a')]({'plain':!![]});_0x27d02d[_0x1d81a0('0x41')]=_[_0x1d81a0('0x39')](_0x11c087,[_0x1d81a0('0x3d'),_0x1d81a0('0x1d')]),_0x27d02d['applications']=_0x11c087[_0x1d81a0('0x3d')],_0x27d02d[_0x1d81a0('0x49')]=_0x11c087[_0x1d81a0('0x1d')],_0x27d02d[_0x1d81a0('0x32')]=_[_0x1d81a0('0x58')](_0x27d02d['applications'],[_0x1d81a0('0x2a')],[_0x1d81a0('0x15')]);_0x27d02d[_0x1d81a0('0x41')]&&_0x27d02d[_0x1d81a0('0x41')][_0x1d81a0('0x1c')]&&_0x27d02d[_0x1d81a0('0x32')][_0x1d81a0('0x34')]({'id':0x0,'priority':_0x27d02d[_0x1d81a0('0x32')]['length']+0x1,'app':_0x1d81a0('0x54'),'appdata':_0x1d81a0('0x1c'),'interval':'*,*,*,*'});_0x27d02d[_0x1d81a0('0x41')][_0x1d81a0('0x3d')]&&delete _0x27d02d[_0x1d81a0('0x41')][_0x1d81a0('0x3d')];_0x27d02d[_0x1d81a0('0x41')]['List']&&delete _0x27d02d['account'][_0x1d81a0('0x1d')];if(_0x11c087[_0x1d81a0('0x1d')][_0x1d81a0('0x52')][_0x1d81a0('0x7')])return _0x11c087[_0x1d81a0('0x1d')]['Contacts'][0x0];const _0x3b2f2a=_[_0x1d81a0('0x1a')](_0x2f9eb8[_0x1d81a0('0x55')],{'firstName':_0x2f9eb8[_0x1d81a0('0x55')][_0x1d81a0('0x40')],'ListId':_0x11c087['ListId']});return _0x3b2f2a[_0x2f9eb8[_0x1d81a0('0x55')][_0x1d81a0('0xf')]]=_0x2f9eb8[_0x1d81a0('0x55')][_0x1d81a0('0x40')],db[_0x1d81a0('0x44')]['create'](_0x3b2f2a);}else throw new Error('List\x20not\x20found');})[_0x1b786f('0x3f')](function(_0x495998){const _0x264c02=_0x1b786f;_0x27d02d[_0x264c02('0x11')]=_0x495998;if(_0x495998){!_0x2f9eb8[_0x264c02('0x55')][_0x264c02('0x27')][_0x264c02('0x4')]&&(_0x2f9eb8['body'][_0x264c02('0x27')]['messageId']=rs[_0x264c02('0xe')]()+'\x20'+_0x2f9eb8['body'][_0x264c02('0x27')][_0x264c02('0x40')]);const _0x3ab3b6={'ContactId':_0x495998['id'],'MailAccountId':_0x2f9eb8[_0x264c02('0x41')]['id'],'inReplyTo':_0x2f9eb8['body'][_0x264c02('0x27')][_0x264c02('0x4')],'to':_0x2f9eb8[_0x264c02('0x55')][_0x264c02('0x27')][_0x264c02('0x40')],'cc':_0x2f9eb8['body']['message']['cc'],'subject':_0x2f9eb8[_0x264c02('0x55')][_0x264c02('0x27')][_0x264c02('0x5d')],'attach':_0x2f9eb8[_0x264c02('0x55')][_0x264c02('0x27')][_0x264c02('0x10')],'lastMsgAt':moment()['format'](_0x264c02('0x35')),'lastMsgDirection':'in','lastMsgBody':_0x2f9eb8[_0x264c02('0x55')][_0x264c02('0x55')]};return db[_0x264c02('0x37')][_0x264c02('0x23')]({'where':{'closed':![],'MailAccountId':_0x2f9eb8[_0x264c02('0x41')]['id']},'include':[{'model':db[_0x264c02('0x47')],'as':_0x264c02('0x2c'),'attributes':[_0x264c02('0x4')],'where':{'messageId':_0x2f9eb8[_0x264c02('0x55')]['message'][_0x264c02('0x6')]}}]})['then'](function(_0x1f4a75){const _0x3c57e4=_0x264c02;if(_0x1f4a75)return[_0x1f4a75,![]];return db[_0x3c57e4('0x37')][_0x3c57e4('0xa')](_0x3ab3b6)[_0x3c57e4('0x3f')](function(_0x1088a5){return[_0x1088a5,!![]];});});}else throw new Error(_0x264c02('0x48'));})[_0x1b786f('0x3f')](function([_0x3f0a96,_0x230588]){const _0x4453ab=_0x1b786f;if(_0x3f0a96)return _0x58d2e0=_0x230588,!_0x230588?_0x3f0a96[_0x4453ab('0x29')]({'inReplyTo':_0x2f9eb8[_0x4453ab('0x55')][_0x4453ab('0x27')][_0x4453ab('0x4')],'to':_0x2f9eb8['body'][_0x4453ab('0x27')][_0x4453ab('0x40')],'cc':_0x2f9eb8[_0x4453ab('0x55')]['message']['cc'],'subject':_0x2f9eb8[_0x4453ab('0x55')][_0x4453ab('0x27')]['subject'],'attach':_0x3f0a96[_0x4453ab('0x10')]?_0x3f0a96[_0x4453ab('0x10')]:_0x2f9eb8['body']['message']['attach'],'substatus':null,'substatusAt':moment()[_0x4453ab('0x5b')](_0x4453ab('0x35')),'lastMsgAt':moment()[_0x4453ab('0x5b')](_0x4453ab('0x35')),'lastMsgDirection':'in','lastMsgBody':_0x2f9eb8[_0x4453ab('0x55')][_0x4453ab('0x55')]}):_0x3f0a96;})[_0x1b786f('0x3f')](function(_0x2c89fe){const _0x53ead4=_0x1b786f;return _0x27d02d[_0x53ead4('0x4a')]=_0x2c89fe[_0x53ead4('0x5a')]({'plain':!![]}),_0x27d02d[_0x53ead4('0x4a')]['created']=_0x58d2e0,db['MailMessage'][_0x53ead4('0xa')]({'body':_0x2f9eb8['body']['body'],'MailAccountId':_0x2f9eb8['account']['id'],'MailInteractionId':_0x2c89fe['id'],'direction':'in','ContactId':_0x27d02d[_0x53ead4('0x11')]['id'],'messageId':_0x2f9eb8[_0x53ead4('0x55')][_0x53ead4('0x27')]['messageId'],'from':_0x2f9eb8[_0x53ead4('0x55')]['message'][_0x53ead4('0x40')],'to':_0x2f9eb8[_0x53ead4('0x55')][_0x53ead4('0x27')]['to'],'cc':_0x2f9eb8['body'][_0x53ead4('0x27')]['cc'],'subject':_0x2f9eb8[_0x53ead4('0x55')][_0x53ead4('0x27')]['subject'],'attach':_0x2f9eb8[_0x53ead4('0x55')][_0x53ead4('0x27')][_0x53ead4('0x10')],'Attachments':_0x2f9eb8[_0x53ead4('0x55')][_0x53ead4('0x27')]['attachments'],'originTo':_0x2f9eb8['body']['message'][_0x53ead4('0x12')],'originCc':_0x2f9eb8[_0x53ead4('0x55')][_0x53ead4('0x27')][_0x53ead4('0x14')],'bcc':_0x2f9eb8[_0x53ead4('0x55')][_0x53ead4('0x27')][_0x53ead4('0xb')]},{'include':[{'model':db['Attachment'],'as':_0x53ead4('0x2e')}]});})[_0x1b786f('0x3f')](function(_0x40efc4){const _0x2aa3d6=_0x1b786f;_0x27d02d[_0x2aa3d6('0x27')]=_0x40efc4;if(_0x27d02d['interaction']['UserId'])return db['User']['findOne']({'attributes':['id',_0x2aa3d6('0x3')],'where':{'id':_0x27d02d[_0x2aa3d6('0x4a')][_0x2aa3d6('0x28')]}})[_0x2aa3d6('0x3f')](function(_0x17e677){const _0x1b8c8f=_0x2aa3d6;return _0x17e677&&_0x27d02d[_0x1b8c8f('0x32')]['unshift']({'id':0x0,'priority':0x0,'app':'agent','appdata':_0x17e677[_0x1b8c8f('0x3')]+','+(_0x27d02d[_0x1b8c8f('0x41')][_0x1b8c8f('0x30')]||0xa),'interval':_0x1b8c8f('0x4d')}),respondWithRpcPromise(_0x1b8c8f('0x4f'),_0x1b8c8f('0x9'),_0x27d02d);});return respondWithRpcPromise(_0x2aa3d6('0x4f'),'startRouting',_0x27d02d);})[_0x1b786f('0x3f')](function(_0x17d5cd){_0x2bd479(_0x17d5cd);})[_0x1b786f('0x38')](function(_0x2b0a97){const _0x332e3e=_0x1b786f;_0x53c63e(_0x50adb3[_0x332e3e('0x2')](0x1f4,_0x2b0a97['message']));});});};
\ No newline at end of file