Built motion from commit f738f9592c388b9f9eb3948f400a5c9d717a3561. Version 3.0.0...
[motion-next.git] / server / api / mailAccount / mailAccount.rpc.js
index 659e193..295af05 100644 (file)
@@ -1 +1 @@
-const a479_0x5adf=['rpc','Messages','attach','agent','code','*,*,*,*','interaction','mail','MailAccount','MailApplication','model','Contacts','UserId','keys','DESC','findAll','MailAccount,\x20%s,\x20%s','attachments','startRouting','MailMessage','../../config/logger','close','omit','Attachment','catch','GetMailAccount','Contact\x20not\x20found','orderBy','MailAccount,\x20%s,\x20%s,\x20%s','originTo','MailInteraction','created','info','ListId','options','YYYY-MM-DD\x20HH:mm:ss','findOne','where','includes','waitForTheAssignedAgent','include','./mailAccount.socket','register','NotifyMailAccount','subject','priority','CmList','updatedAt','result','autoclose','account','get','Applications','then','messageId','length','CompanyId','body','request\x20sent','List\x20not\x20found','map','message','Smtp','attributes','mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','client','isNil','limit','Start','contact','originCc','rawAttributes','push','User','raw','from','mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','Attachments','../../rediscache','http','stringify','name','jayson/promise','randomstring','asc','difference','ShowMailAccount','CmContact','List','create','error','../../mysqldb','from\x20is\x20mandatory','applications','format','list','generate','mapKey','bcc'];(function(_0x36ce74,_0x134545){const _0x5adf95=function(_0x5260ba){while(--_0x5260ba){_0x36ce74['push'](_0x36ce74['shift']());}};_0x5adf95(++_0x134545);}(a479_0x5adf,0x17c));const a479_0x5260=function(_0x36ce74,_0x134545){_0x36ce74=_0x36ce74-0x92;let _0x5adf95=a479_0x5adf[_0x36ce74];return _0x5adf95;};const a479_0x28f242=a479_0x5260;'use strict';const _=require('lodash'),db=require(a479_0x28f242(0x9a))['db'],logger=require(a479_0x28f242(0xb6))(a479_0x28f242(0xa2)),{getSocket}=require(a479_0x28f242(0xf0)),socket=getSocket(),rs=require(a479_0x28f242(0x92)),moment=require('moment'),jayson=require(a479_0x28f242(0xf4)),client=jayson[a479_0x28f242(0xe3)][a479_0x28f242(0xf1)]({'port':0x232c});require(a479_0x28f242(0xcb))[a479_0x28f242(0xcc)](socket);function respondWithRpcPromise(_0x50e895,_0x2a919c,_0x4fe7f2){return new Promise(function(_0x3f6024,_0x42b2ed){return client['request'](_0x50e895,_0x4fe7f2)['then'](function(_0x907aa7){const _0x56d8f7=a479_0x5260;logger[_0x56d8f7(0xc2)]('MailAccount,\x20%s,\x20%s',_0x2a919c,_0x56d8f7(0xdc)),logger['debug'](_0x56d8f7(0xbe),_0x2a919c,_0x56d8f7(0xdc),JSON['stringify'](_0x907aa7));if(_0x907aa7[_0x56d8f7(0x99)]){if(_0x907aa7[_0x56d8f7(0x99)][_0x56d8f7(0xa6)]===0x1f4)return logger[_0x56d8f7(0x99)](_0x56d8f7(0xb2),_0x2a919c,_0x907aa7[_0x56d8f7(0x99)][_0x56d8f7(0xdf)]),_0x42b2ed(_0x907aa7[_0x56d8f7(0x99)][_0x56d8f7(0xdf)]);return logger['error'](_0x56d8f7(0xb2),_0x2a919c,_0x907aa7[_0x56d8f7(0x99)][_0x56d8f7(0xdf)]),_0x3f6024(_0x907aa7[_0x56d8f7(0x99)]['message']);}else logger[_0x56d8f7(0xc2)](_0x56d8f7(0xb2),_0x2a919c,'request\x20sent'),_0x3f6024(_0x907aa7[_0x56d8f7(0xd2)][_0x56d8f7(0xdf)]);})['catch'](function(_0x4b2e61){const _0x2e0799=a479_0x5260;logger[_0x2e0799(0x99)](_0x2e0799(0xb2),_0x2a919c,_0x4b2e61),_0x42b2ed(_0x4b2e61);});});}exports['GetMailAccount']=function(_0x4e0ddb){const _0x1847de=this;return new Promise(function(_0x2c68fc,_0x173817){const _0x11aa54=a479_0x5260;return db['MailAccount'][_0x11aa54(0xb1)]({'raw':_0x4e0ddb['options']?_0x4e0ddb[_0x11aa54(0xc4)][_0x11aa54(0xec)]===undefined?!![]:![]:!![],'where':_0x4e0ddb[_0x11aa54(0xc4)]?_0x4e0ddb[_0x11aa54(0xc4)][_0x11aa54(0xc7)]||null:null,'attributes':_0x4e0ddb[_0x11aa54(0xc4)]?_0x4e0ddb['options']['attributes']||null:null,'limit':_0x4e0ddb[_0x11aa54(0xc4)]?_0x4e0ddb[_0x11aa54(0xc4)][_0x11aa54(0xe5)]||null:null,'include':_0x4e0ddb['options']?_0x4e0ddb[_0x11aa54(0xc4)][_0x11aa54(0xca)]?_[_0x11aa54(0xde)](_0x4e0ddb[_0x11aa54(0xc4)][_0x11aa54(0xca)],function(_0x5ae2d7){const _0x1c5a7b=_0x11aa54;return{'model':db[_0x5ae2d7[_0x1c5a7b(0xac)]],'as':_0x5ae2d7['as'],'attributes':_0x5ae2d7[_0x1c5a7b(0xe1)],'include':_0x5ae2d7[_0x1c5a7b(0xca)]?_[_0x1c5a7b(0xde)](_0x5ae2d7[_0x1c5a7b(0xca)],function(_0x422216){const _0x565910=_0x1c5a7b;return{'model':db[_0x422216['model']],'as':_0x422216['as'],'attributes':_0x422216[_0x565910(0xe1)],'include':_0x422216[_0x565910(0xca)]?_[_0x565910(0xde)](_0x422216['include'],function(_0xad7130){const _0x2072cf=_0x565910;return{'model':db[_0xad7130[_0x2072cf(0xac)]],'as':_0xad7130['as'],'attributes':_0xad7130['attributes']};}):[]};}):[]};}):[]:[]})[_0x11aa54(0xd7)](function(_0x4a01d1){const _0x3fe85d=_0x11aa54;logger['info']('GetMailAccount',_0x4e0ddb),logger['debug'](_0x3fe85d(0xbb),_0x4e0ddb,JSON['stringify'](_0x4a01d1)),_0x2c68fc(_0x4a01d1);})[_0x11aa54(0xba)](function(_0x5f2ca5){const _0x11e02e=_0x11aa54;logger['error'](_0x11e02e(0xbb),_0x5f2ca5[_0x11e02e(0xdf)],_0x4e0ddb),_0x173817(_0x1847de[_0x11e02e(0x99)](0x1f4,_0x5f2ca5[_0x11e02e(0xdf)]));});});},exports[a479_0x28f242(0x95)]=function(_0x141780){const _0x373b6c=this;return new Promise(function(_0x1542ed,_0x157cfe){const _0x1dc1ed=a479_0x5260;return db[_0x1dc1ed(0xaa)][_0x1dc1ed(0xc6)]({'raw':_0x141780['options']?_0x141780[_0x1dc1ed(0xc4)][_0x1dc1ed(0xec)]===undefined?!![]:![]:!![],'where':_0x141780[_0x1dc1ed(0xc4)]?_0x141780['options'][_0x1dc1ed(0xc7)]||null:null,'attributes':_0x141780[_0x1dc1ed(0xc4)]?_0x141780['options']['attributes']||null:null,'include':_0x141780[_0x1dc1ed(0xc4)]?_0x141780[_0x1dc1ed(0xc4)][_0x1dc1ed(0xca)]?_[_0x1dc1ed(0xde)](_0x141780['options']['include'],function(_0x20ce94){const _0x5734ad=_0x1dc1ed;return{'model':db[_0x20ce94[_0x5734ad(0xac)]],'as':_0x20ce94['as'],'attributes':_0x20ce94[_0x5734ad(0xe1)],'include':_0x20ce94[_0x5734ad(0xca)]?_[_0x5734ad(0xde)](_0x20ce94[_0x5734ad(0xca)],function(_0x302763){const _0x57ee80=_0x5734ad;return{'model':db[_0x302763[_0x57ee80(0xac)]],'as':_0x302763['as'],'attributes':_0x302763[_0x57ee80(0xe1)],'include':_0x302763[_0x57ee80(0xca)]?_[_0x57ee80(0xde)](_0x302763[_0x57ee80(0xca)],function(_0x3663eb){const _0x2a567f=_0x57ee80;return{'model':db[_0x3663eb[_0x2a567f(0xac)]],'as':_0x3663eb['as'],'attributes':_0x3663eb['attributes']};}):[]};}):[]};}):[]:[]})[_0x1dc1ed(0xd7)](function(_0x146ba7){const _0xdbcea9=_0x1dc1ed;logger[_0xdbcea9(0xc2)]('ShowMailAccount',_0x141780),logger['debug'](_0xdbcea9(0x95),_0x141780,JSON[_0xdbcea9(0xf2)](_0x146ba7)),_0x1542ed(_0x146ba7);})['catch'](function(_0x377f24){const _0x32b44f=_0x1dc1ed;logger[_0x32b44f(0x99)](_0x32b44f(0x95),_0x377f24['message'],_0x141780),_0x157cfe(_0x373b6c[_0x32b44f(0x99)](0x1f4,_0x377f24[_0x32b44f(0xdf)]));});});},exports[a479_0x28f242(0xcd)]=function(_0x178e0e){const _0x26a004=this;return new Promise(function(_0x1aa9df,_0x1b3de7){const _0xd61772=a479_0x5260,_0x50b600={'body':_0x178e0e[_0xd61772(0xdb)],'channel':_0xd61772(0xa9)},_0x5660df=_[_0xd61772(0x94)](_[_0xd61772(0xaf)](db['CmContact'][_0xd61772(0xe9)]),['createdAt','updatedAt',_0xd61772(0xda),'ListId']);let _0x544168=![];_0x178e0e[_0xd61772(0xdb)]['id']&&delete _0x178e0e[_0xd61772(0xdb)]['id'];if(_['isNil'](_0x178e0e['body'][_0xd61772(0xed)]))return _0x1b3de7(_0x26a004['error'](0x1f4,_0xd61772(0x9b)));if(_['isNil'](_0x178e0e[_0xd61772(0xdb)]['body'])||_0x178e0e[_0xd61772(0xdb)]['body']==='')return _0x1b3de7(_0x26a004[_0xd61772(0x99)](0x1f4,'body\x20is\x20mandatory\x20and\x20not\x20empty'));if(_[_0xd61772(0xe4)](_0x178e0e[_0xd61772(0xdb)][_0xd61772(0xa0)]))return _0x1b3de7(_0x26a004[_0xd61772(0x99)](0x1f4,_0xd61772(0xe2)+_0x5660df));if(!_[_0xd61772(0xc8)](_0x5660df,_0x178e0e[_0xd61772(0xdb)][_0xd61772(0xa0)]))return _0x1b3de7(_0x26a004['error'](0x1f4,_0xd61772(0xee)+_0x5660df));const _0x17ab61={};return _0x17ab61[_0x178e0e[_0xd61772(0xdb)][_0xd61772(0xa0)]]=_0x178e0e[_0xd61772(0xdb)][_0xd61772(0xed)],db['MailAccount'][_0xd61772(0xc6)]({'where':{'id':_0x178e0e[_0xd61772(0xd4)]['id']},'include':[{'model':db[_0xd61772(0xd0)],'as':_0xd61772(0x97),'include':[{'model':db[_0xd61772(0x96)],'as':_0xd61772(0xad),'where':_0x17ab61,'limit':0x1,'order':[[_0xd61772(0xd1),_0xd61772(0xb0)]]}]},{'model':db[_0xd61772(0xab)],'as':'Applications'},{'model':db['MailServerOut'],'as':_0xd61772(0xe0)}]})[_0xd61772(0xd7)](function(_0x30c642){const _0x2b5f56=_0xd61772;if(_0x30c642&&_0x30c642[_0x2b5f56(0x97)]){const _0x3ef70f=_0x30c642[_0x2b5f56(0xd5)]({'plain':!![]});_0x50b600[_0x2b5f56(0xd4)]=_[_0x2b5f56(0xb8)](_0x3ef70f,[_0x2b5f56(0xd6),'List']),_0x50b600['applications']=_0x3ef70f[_0x2b5f56(0xd6)],_0x50b600[_0x2b5f56(0x9e)]=_0x3ef70f['List'],_0x50b600['applications']=_[_0x2b5f56(0xbd)](_0x50b600[_0x2b5f56(0x9c)],[_0x2b5f56(0xcf)],[_0x2b5f56(0x93)]);_0x50b600[_0x2b5f56(0xd4)]&&_0x50b600[_0x2b5f56(0xd4)]['autoclose']&&_0x50b600['applications'][_0x2b5f56(0xea)]({'id':0x0,'priority':_0x50b600[_0x2b5f56(0x9c)][_0x2b5f56(0xd9)]+0x1,'app':_0x2b5f56(0xb7),'appdata':_0x2b5f56(0xd3),'interval':'*,*,*,*'});_0x50b600[_0x2b5f56(0xd4)][_0x2b5f56(0xd6)]&&delete _0x50b600[_0x2b5f56(0xd4)][_0x2b5f56(0xd6)];_0x50b600['account'][_0x2b5f56(0x97)]&&delete _0x50b600[_0x2b5f56(0xd4)]['List'];if(_0x3ef70f[_0x2b5f56(0x97)][_0x2b5f56(0xad)][_0x2b5f56(0xd9)])return _0x3ef70f[_0x2b5f56(0x97)]['Contacts'][0x0];const _0x189809=_['defaults'](_0x178e0e[_0x2b5f56(0xdb)],{'firstName':_0x178e0e[_0x2b5f56(0xdb)]['from'],'ListId':_0x3ef70f[_0x2b5f56(0xc3)]});return _0x189809[_0x178e0e[_0x2b5f56(0xdb)][_0x2b5f56(0xa0)]]=_0x178e0e[_0x2b5f56(0xdb)][_0x2b5f56(0xed)],db[_0x2b5f56(0x96)][_0x2b5f56(0x98)](_0x189809);}else throw new Error(_0x2b5f56(0xdd));})['then'](function(_0xa760e4){const _0xa754c0=_0xd61772;_0x50b600[_0xa754c0(0xe7)]=_0xa760e4;if(_0xa760e4){!_0x178e0e[_0xa754c0(0xdb)]['message'][_0xa754c0(0xd8)]&&(_0x178e0e[_0xa754c0(0xdb)][_0xa754c0(0xdf)][_0xa754c0(0xd8)]=rs[_0xa754c0(0x9f)]()+'\x20'+_0x178e0e[_0xa754c0(0xdb)][_0xa754c0(0xdf)][_0xa754c0(0xed)]);const _0x6b69fe={'ContactId':_0xa760e4['id'],'MailAccountId':_0x178e0e['account']['id'],'inReplyTo':_0x178e0e['body'][_0xa754c0(0xdf)]['messageId'],'to':_0x178e0e[_0xa754c0(0xdb)][_0xa754c0(0xdf)]['from'],'cc':_0x178e0e[_0xa754c0(0xdb)][_0xa754c0(0xdf)]['cc'],'subject':_0x178e0e[_0xa754c0(0xdb)][_0xa754c0(0xdf)]['subject'],'attach':_0x178e0e['body'][_0xa754c0(0xdf)][_0xa754c0(0xa4)],'lastMsgAt':moment()[_0xa754c0(0x9d)](_0xa754c0(0xc5)),'lastMsgDirection':'in','lastMsgBody':_0x178e0e[_0xa754c0(0xdb)][_0xa754c0(0xdb)]};return db[_0xa754c0(0xc0)][_0xa754c0(0xc6)]({'where':{'closed':![],'MailAccountId':_0x178e0e['account']['id']},'include':[{'model':db[_0xa754c0(0xb5)],'as':_0xa754c0(0xa3),'attributes':[_0xa754c0(0xd8)],'where':{'messageId':_0x178e0e['body'][_0xa754c0(0xdf)]['inReplyTo']}}]})[_0xa754c0(0xd7)](function(_0x40e539){const _0x4f6da6=_0xa754c0;if(_0x40e539)return[_0x40e539,![]];return db['MailInteraction'][_0x4f6da6(0x98)](_0x6b69fe)[_0x4f6da6(0xd7)](function(_0x3e5928){return[_0x3e5928,!![]];});});}else throw new Error(_0xa754c0(0xbc));})[_0xd61772(0xd7)](function([_0x576ef8,_0x312865]){const _0x4b437f=_0xd61772;if(_0x576ef8)return _0x544168=_0x312865,!_0x312865?_0x576ef8['update']({'inReplyTo':_0x178e0e[_0x4b437f(0xdb)][_0x4b437f(0xdf)][_0x4b437f(0xd8)],'to':_0x178e0e[_0x4b437f(0xdb)][_0x4b437f(0xdf)][_0x4b437f(0xed)],'cc':_0x178e0e[_0x4b437f(0xdb)][_0x4b437f(0xdf)]['cc'],'subject':_0x178e0e[_0x4b437f(0xdb)][_0x4b437f(0xdf)]['subject'],'attach':_0x576ef8[_0x4b437f(0xa4)]?_0x576ef8[_0x4b437f(0xa4)]:_0x178e0e[_0x4b437f(0xdb)][_0x4b437f(0xdf)][_0x4b437f(0xa4)],'substatus':null,'substatusAt':moment()['format']('YYYY-MM-DD\x20HH:mm:ss'),'lastMsgAt':moment()[_0x4b437f(0x9d)](_0x4b437f(0xc5)),'lastMsgDirection':'in','lastMsgBody':_0x178e0e[_0x4b437f(0xdb)][_0x4b437f(0xdb)]}):_0x576ef8;})['then'](function(_0x4d4df7){const _0x39d1df=_0xd61772;return _0x50b600[_0x39d1df(0xa8)]=_0x4d4df7[_0x39d1df(0xd5)]({'plain':!![]}),_0x50b600['interaction'][_0x39d1df(0xc1)]=_0x544168,db[_0x39d1df(0xb5)]['create']({'body':_0x178e0e['body']['body'],'MailAccountId':_0x178e0e['account']['id'],'MailInteractionId':_0x4d4df7['id'],'direction':'in','ContactId':_0x50b600['contact']['id'],'messageId':_0x178e0e[_0x39d1df(0xdb)][_0x39d1df(0xdf)][_0x39d1df(0xd8)],'from':_0x178e0e[_0x39d1df(0xdb)][_0x39d1df(0xdf)]['from'],'to':_0x178e0e['body']['message']['to'],'cc':_0x178e0e[_0x39d1df(0xdb)]['message']['cc'],'subject':_0x178e0e['body'][_0x39d1df(0xdf)][_0x39d1df(0xce)],'attach':_0x178e0e[_0x39d1df(0xdb)]['message'][_0x39d1df(0xa4)],'Attachments':_0x178e0e['body'][_0x39d1df(0xdf)][_0x39d1df(0xb3)],'originTo':_0x178e0e[_0x39d1df(0xdb)]['message'][_0x39d1df(0xbf)],'originCc':_0x178e0e['body'][_0x39d1df(0xdf)][_0x39d1df(0xe8)],'bcc':_0x178e0e[_0x39d1df(0xdb)]['message'][_0x39d1df(0xa1)]},{'include':[{'model':db[_0x39d1df(0xb9)],'as':_0x39d1df(0xef)}]});})[_0xd61772(0xd7)](function(_0x2dae74){const _0x102eb4=_0xd61772;_0x50b600[_0x102eb4(0xdf)]=_0x2dae74;if(_0x50b600[_0x102eb4(0xa8)][_0x102eb4(0xae)])return db[_0x102eb4(0xeb)]['findOne']({'attributes':['id',_0x102eb4(0xf3)],'where':{'id':_0x50b600[_0x102eb4(0xa8)][_0x102eb4(0xae)]}})[_0x102eb4(0xd7)](function(_0x7e43f8){const _0xe5f438=_0x102eb4;return _0x7e43f8&&_0x50b600['applications']['unshift']({'id':0x0,'priority':0x0,'app':_0xe5f438(0xa5),'appdata':_0x7e43f8['name']+','+(_0x50b600[_0xe5f438(0xd4)][_0xe5f438(0xc9)]||0xa),'interval':_0xe5f438(0xa7)}),respondWithRpcPromise(_0xe5f438(0xe6),_0xe5f438(0xb4),_0x50b600);});return respondWithRpcPromise(_0x102eb4(0xe6),_0x102eb4(0xb4),_0x50b600);})[_0xd61772(0xd7)](function(_0x58a79e){_0x1aa9df(_0x58a79e);})['catch'](function(_0x3c05a1){const _0x1b7966=_0xd61772;_0x1b3de7(_0x26a004[_0x1b7966(0x99)](0x1f4,_0x3c05a1[_0x1b7966(0xdf)]));});});};
\ No newline at end of file
+const a479_0x1c2b=['UserId','name','subject','then','MailApplication','request\x20sent','length','Applications','raw','findAll','lodash','CmContact','stringify','model','MailMessage','MailAccount,\x20%s,\x20%s,\x20%s','omit','bcc','originTo','contact','created','applications','DESC','Attachment','orderBy','push','CompanyId','mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','List\x20not\x20found','defaults','GetMailAccount','body\x20is\x20mandatory\x20and\x20not\x20empty','keys','rpc','findOne','attachments','error','Contact\x20not\x20found','list','update','../../rediscache','ShowMailAccount','difference','options','get','request','../../mysqldb','where','autoclose','from','format','catch','asc','unshift','agent','include','mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','Attachments','from\x20is\x20mandatory','*,*,*,*','generate','MailAccount','waitForTheAssignedAgent','account','attach','MailAccount,\x20%s,\x20%s','attributes','MailInteraction','jayson/promise','originCc','register','result','http','close','CmList','MailServerOut','create','isNil','info','message','mapKey','Smtp','YYYY-MM-DD\x20HH:mm:ss','interaction','Contacts','NotifyMailAccount','ListId','../../config/logger','debug','List','map','body','messageId','startRouting','Start'];(function(_0x12e873,_0x361e2b){const _0x1c2b5a=function(_0x4f274f){while(--_0x4f274f){_0x12e873['push'](_0x12e873['shift']());}};_0x1c2b5a(++_0x361e2b);}(a479_0x1c2b,0x112));const a479_0x4f27=function(_0x12e873,_0x361e2b){_0x12e873=_0x12e873-0x86;let _0x1c2b5a=a479_0x1c2b[_0x12e873];return _0x1c2b5a;};const a479_0x231cc2=a479_0x4f27;'use strict';const _=require(a479_0x231cc2(0x9b)),db=require(a479_0x231cc2(0xbf))['db'],logger=require(a479_0x231cc2(0x89))(a479_0x231cc2(0xb2)),{getSocket}=require(a479_0x231cc2(0xb9)),socket=getSocket(),rs=require('randomstring'),moment=require('moment'),jayson=require(a479_0x231cc2(0xd5)),client=jayson['client'][a479_0x231cc2(0xd9)]({'port':0x232c});require('./mailAccount.socket')[a479_0x231cc2(0xd7)](socket);function respondWithRpcPromise(_0x1ebdcc,_0xb13193,_0x51590b){return new Promise(function(_0xd98d5b,_0x1e2fe1){const _0x23891a=a479_0x4f27;return client[_0x23891a(0xbe)](_0x1ebdcc,_0x51590b)[_0x23891a(0x94)](function(_0x3dc44b){const _0x311c88=_0x23891a;logger['info'](_0x311c88(0xd2),_0xb13193,'request\x20sent'),logger['debug'](_0x311c88(0xa0),_0xb13193,'request\x20sent',JSON[_0x311c88(0x9d)](_0x3dc44b));if(_0x3dc44b[_0x311c88(0xb5)]){if(_0x3dc44b[_0x311c88(0xb5)]['code']===0x1f4)return logger[_0x311c88(0xb5)](_0x311c88(0xd2),_0xb13193,_0x3dc44b[_0x311c88(0xb5)][_0x311c88(0xe0)]),_0x1e2fe1(_0x3dc44b[_0x311c88(0xb5)]['message']);return logger['error'](_0x311c88(0xd2),_0xb13193,_0x3dc44b['error'][_0x311c88(0xe0)]),_0xd98d5b(_0x3dc44b[_0x311c88(0xb5)][_0x311c88(0xe0)]);}else logger[_0x311c88(0xdf)](_0x311c88(0xd2),_0xb13193,_0x311c88(0x96)),_0xd98d5b(_0x3dc44b[_0x311c88(0xd8)][_0x311c88(0xe0)]);})[_0x23891a(0xc4)](function(_0x40dc37){const _0x472dee=_0x23891a;logger[_0x472dee(0xb5)](_0x472dee(0xd2),_0xb13193,_0x40dc37),_0x1e2fe1(_0x40dc37);});});}exports[a479_0x231cc2(0xaf)]=function(_0x2d8241){const _0x4ad4bc=this;return new Promise(function(_0x35bf0f,_0xea2d6c){const _0x1f959f=a479_0x4f27;return db[_0x1f959f(0xce)][_0x1f959f(0x9a)]({'raw':_0x2d8241[_0x1f959f(0xbc)]?_0x2d8241[_0x1f959f(0xbc)][_0x1f959f(0x99)]===undefined?!![]:![]:!![],'where':_0x2d8241[_0x1f959f(0xbc)]?_0x2d8241[_0x1f959f(0xbc)][_0x1f959f(0xc0)]||null:null,'attributes':_0x2d8241['options']?_0x2d8241[_0x1f959f(0xbc)][_0x1f959f(0xd3)]||null:null,'limit':_0x2d8241['options']?_0x2d8241['options']['limit']||null:null,'include':_0x2d8241[_0x1f959f(0xbc)]?_0x2d8241[_0x1f959f(0xbc)][_0x1f959f(0xc8)]?_[_0x1f959f(0x8c)](_0x2d8241[_0x1f959f(0xbc)]['include'],function(_0x1a4bd8){const _0x33b119=_0x1f959f;return{'model':db[_0x1a4bd8[_0x33b119(0x9e)]],'as':_0x1a4bd8['as'],'attributes':_0x1a4bd8[_0x33b119(0xd3)],'include':_0x1a4bd8['include']?_['map'](_0x1a4bd8[_0x33b119(0xc8)],function(_0x201725){const _0x1ad9ff=_0x33b119;return{'model':db[_0x201725[_0x1ad9ff(0x9e)]],'as':_0x201725['as'],'attributes':_0x201725[_0x1ad9ff(0xd3)],'include':_0x201725[_0x1ad9ff(0xc8)]?_[_0x1ad9ff(0x8c)](_0x201725[_0x1ad9ff(0xc8)],function(_0x5e2a7d){const _0x1b6d69=_0x1ad9ff;return{'model':db[_0x5e2a7d[_0x1b6d69(0x9e)]],'as':_0x5e2a7d['as'],'attributes':_0x5e2a7d['attributes']};}):[]};}):[]};}):[]:[]})[_0x1f959f(0x94)](function(_0x248142){const _0x240809=_0x1f959f;logger[_0x240809(0xdf)]('GetMailAccount',_0x2d8241),logger[_0x240809(0x8a)]('GetMailAccount',_0x2d8241,JSON[_0x240809(0x9d)](_0x248142)),_0x35bf0f(_0x248142);})[_0x1f959f(0xc4)](function(_0x4e10f0){const _0x2c132c=_0x1f959f;logger[_0x2c132c(0xb5)](_0x2c132c(0xaf),_0x4e10f0[_0x2c132c(0xe0)],_0x2d8241),_0xea2d6c(_0x4ad4bc[_0x2c132c(0xb5)](0x1f4,_0x4e10f0[_0x2c132c(0xe0)]));});});},exports['ShowMailAccount']=function(_0x1cd6dc){const _0x4d85b3=this;return new Promise(function(_0x573f70,_0x3b45ad){const _0x2e6eba=a479_0x4f27;return db[_0x2e6eba(0xce)][_0x2e6eba(0xb3)]({'raw':_0x1cd6dc[_0x2e6eba(0xbc)]?_0x1cd6dc[_0x2e6eba(0xbc)][_0x2e6eba(0x99)]===undefined?!![]:![]:!![],'where':_0x1cd6dc['options']?_0x1cd6dc[_0x2e6eba(0xbc)][_0x2e6eba(0xc0)]||null:null,'attributes':_0x1cd6dc[_0x2e6eba(0xbc)]?_0x1cd6dc['options']['attributes']||null:null,'include':_0x1cd6dc['options']?_0x1cd6dc[_0x2e6eba(0xbc)][_0x2e6eba(0xc8)]?_[_0x2e6eba(0x8c)](_0x1cd6dc[_0x2e6eba(0xbc)][_0x2e6eba(0xc8)],function(_0x189f0c){const _0x3ccc62=_0x2e6eba;return{'model':db[_0x189f0c[_0x3ccc62(0x9e)]],'as':_0x189f0c['as'],'attributes':_0x189f0c['attributes'],'include':_0x189f0c['include']?_['map'](_0x189f0c[_0x3ccc62(0xc8)],function(_0x157cc8){const _0x384efb=_0x3ccc62;return{'model':db[_0x157cc8[_0x384efb(0x9e)]],'as':_0x157cc8['as'],'attributes':_0x157cc8[_0x384efb(0xd3)],'include':_0x157cc8[_0x384efb(0xc8)]?_[_0x384efb(0x8c)](_0x157cc8[_0x384efb(0xc8)],function(_0x4be83b){const _0x424061=_0x384efb;return{'model':db[_0x4be83b[_0x424061(0x9e)]],'as':_0x4be83b['as'],'attributes':_0x4be83b['attributes']};}):[]};}):[]};}):[]:[]})[_0x2e6eba(0x94)](function(_0x22d47d){const _0x2361b9=_0x2e6eba;logger[_0x2361b9(0xdf)](_0x2361b9(0xba),_0x1cd6dc),logger[_0x2361b9(0x8a)](_0x2361b9(0xba),_0x1cd6dc,JSON[_0x2361b9(0x9d)](_0x22d47d)),_0x573f70(_0x22d47d);})[_0x2e6eba(0xc4)](function(_0x48eeb2){const _0x36f39e=_0x2e6eba;logger[_0x36f39e(0xb5)](_0x36f39e(0xba),_0x48eeb2[_0x36f39e(0xe0)],_0x1cd6dc),_0x3b45ad(_0x4d85b3['error'](0x1f4,_0x48eeb2[_0x36f39e(0xe0)]));});});},exports[a479_0x231cc2(0x87)]=function(_0xd83c1b){const _0x19be1f=this;return new Promise(function(_0x470058,_0x286647){const _0x1bbb49=a479_0x4f27,_0x5c1a62={'body':_0xd83c1b[_0x1bbb49(0x8d)],'channel':'mail'},_0x1aa13c=_[_0x1bbb49(0xbb)](_[_0x1bbb49(0xb1)](db[_0x1bbb49(0x9c)]['rawAttributes']),['createdAt','updatedAt',_0x1bbb49(0xab),_0x1bbb49(0x88)]);let _0x11eeba=![];_0xd83c1b['body']['id']&&delete _0xd83c1b[_0x1bbb49(0x8d)]['id'];if(_['isNil'](_0xd83c1b['body'][_0x1bbb49(0xc2)]))return _0x286647(_0x19be1f[_0x1bbb49(0xb5)](0x1f4,_0x1bbb49(0xcb)));if(_[_0x1bbb49(0xde)](_0xd83c1b['body'][_0x1bbb49(0x8d)])||_0xd83c1b[_0x1bbb49(0x8d)][_0x1bbb49(0x8d)]==='')return _0x286647(_0x19be1f[_0x1bbb49(0xb5)](0x1f4,_0x1bbb49(0xb0)));if(_[_0x1bbb49(0xde)](_0xd83c1b['body'][_0x1bbb49(0xe1)]))return _0x286647(_0x19be1f['error'](0x1f4,_0x1bbb49(0xac)+_0x1aa13c));if(!_['includes'](_0x1aa13c,_0xd83c1b[_0x1bbb49(0x8d)][_0x1bbb49(0xe1)]))return _0x286647(_0x19be1f[_0x1bbb49(0xb5)](0x1f4,_0x1bbb49(0xc9)+_0x1aa13c));const _0x505f2a={};return _0x505f2a[_0xd83c1b[_0x1bbb49(0x8d)][_0x1bbb49(0xe1)]]=_0xd83c1b[_0x1bbb49(0x8d)][_0x1bbb49(0xc2)],db[_0x1bbb49(0xce)][_0x1bbb49(0xb3)]({'where':{'id':_0xd83c1b[_0x1bbb49(0xd0)]['id']},'include':[{'model':db[_0x1bbb49(0xdb)],'as':_0x1bbb49(0x8b),'include':[{'model':db[_0x1bbb49(0x9c)],'as':_0x1bbb49(0x86),'where':_0x505f2a,'limit':0x1,'order':[['updatedAt',_0x1bbb49(0xa7)]]}]},{'model':db[_0x1bbb49(0x95)],'as':'Applications'},{'model':db[_0x1bbb49(0xdc)],'as':_0x1bbb49(0xe2)}]})['then'](function(_0x575398){const _0x342fb2=_0x1bbb49;if(_0x575398&&_0x575398['List']){const _0x275030=_0x575398[_0x342fb2(0xbd)]({'plain':!![]});_0x5c1a62['account']=_[_0x342fb2(0xa1)](_0x275030,['Applications','List']),_0x5c1a62[_0x342fb2(0xa6)]=_0x275030['Applications'],_0x5c1a62[_0x342fb2(0xb7)]=_0x275030[_0x342fb2(0x8b)],_0x5c1a62['applications']=_[_0x342fb2(0xa9)](_0x5c1a62['applications'],['priority'],[_0x342fb2(0xc5)]);_0x5c1a62[_0x342fb2(0xd0)]&&_0x5c1a62[_0x342fb2(0xd0)]['autoclose']&&_0x5c1a62[_0x342fb2(0xa6)][_0x342fb2(0xaa)]({'id':0x0,'priority':_0x5c1a62[_0x342fb2(0xa6)][_0x342fb2(0x97)]+0x1,'app':_0x342fb2(0xda),'appdata':_0x342fb2(0xc1),'interval':'*,*,*,*'});_0x5c1a62['account']['Applications']&&delete _0x5c1a62['account'][_0x342fb2(0x98)];_0x5c1a62[_0x342fb2(0xd0)][_0x342fb2(0x8b)]&&delete _0x5c1a62[_0x342fb2(0xd0)][_0x342fb2(0x8b)];if(_0x275030['List'][_0x342fb2(0x86)][_0x342fb2(0x97)])return _0x275030[_0x342fb2(0x8b)][_0x342fb2(0x86)][0x0];const _0x522a2b=_[_0x342fb2(0xae)](_0xd83c1b[_0x342fb2(0x8d)],{'firstName':_0xd83c1b[_0x342fb2(0x8d)][_0x342fb2(0xc2)],'ListId':_0x275030[_0x342fb2(0x88)]});return _0x522a2b[_0xd83c1b[_0x342fb2(0x8d)]['mapKey']]=_0xd83c1b[_0x342fb2(0x8d)][_0x342fb2(0xc2)],db[_0x342fb2(0x9c)][_0x342fb2(0xdd)](_0x522a2b);}else throw new Error(_0x342fb2(0xad));})['then'](function(_0x583581){const _0x33038d=_0x1bbb49;_0x5c1a62[_0x33038d(0xa4)]=_0x583581;if(_0x583581){!_0xd83c1b[_0x33038d(0x8d)][_0x33038d(0xe0)][_0x33038d(0x8e)]&&(_0xd83c1b[_0x33038d(0x8d)][_0x33038d(0xe0)]['messageId']=rs[_0x33038d(0xcd)]()+'\x20'+_0xd83c1b[_0x33038d(0x8d)][_0x33038d(0xe0)][_0x33038d(0xc2)]);const _0x42a0fa={'ContactId':_0x583581['id'],'MailAccountId':_0xd83c1b[_0x33038d(0xd0)]['id'],'inReplyTo':_0xd83c1b[_0x33038d(0x8d)][_0x33038d(0xe0)][_0x33038d(0x8e)],'to':_0xd83c1b['body'][_0x33038d(0xe0)][_0x33038d(0xc2)],'cc':_0xd83c1b['body'][_0x33038d(0xe0)]['cc'],'subject':_0xd83c1b[_0x33038d(0x8d)]['message'][_0x33038d(0x93)],'attach':_0xd83c1b[_0x33038d(0x8d)]['message']['attach'],'lastMsgAt':moment()['format'](_0x33038d(0xe3)),'lastMsgDirection':'in','lastMsgBody':_0xd83c1b['body']['body']};return db[_0x33038d(0xd4)][_0x33038d(0xb3)]({'where':{'closed':![],'MailAccountId':_0xd83c1b['account']['id']},'include':[{'model':db['MailMessage'],'as':'Messages','attributes':[_0x33038d(0x8e)],'where':{'messageId':_0xd83c1b[_0x33038d(0x8d)][_0x33038d(0xe0)]['inReplyTo']}}]})['then'](function(_0x4ebe4a){const _0x11b4bd=_0x33038d;if(_0x4ebe4a)return[_0x4ebe4a,![]];return db[_0x11b4bd(0xd4)][_0x11b4bd(0xdd)](_0x42a0fa)[_0x11b4bd(0x94)](function(_0x36747b){return[_0x36747b,!![]];});});}else throw new Error(_0x33038d(0xb6));})[_0x1bbb49(0x94)](function([_0x2177da,_0x53fab2]){const _0x4ae6a9=_0x1bbb49;if(_0x2177da)return _0x11eeba=_0x53fab2,!_0x53fab2?_0x2177da[_0x4ae6a9(0xb8)]({'inReplyTo':_0xd83c1b[_0x4ae6a9(0x8d)][_0x4ae6a9(0xe0)][_0x4ae6a9(0x8e)],'to':_0xd83c1b[_0x4ae6a9(0x8d)][_0x4ae6a9(0xe0)][_0x4ae6a9(0xc2)],'cc':_0xd83c1b[_0x4ae6a9(0x8d)][_0x4ae6a9(0xe0)]['cc'],'subject':_0xd83c1b[_0x4ae6a9(0x8d)][_0x4ae6a9(0xe0)][_0x4ae6a9(0x93)],'attach':_0x2177da[_0x4ae6a9(0xd1)]?_0x2177da['attach']:_0xd83c1b[_0x4ae6a9(0x8d)][_0x4ae6a9(0xe0)][_0x4ae6a9(0xd1)],'substatus':null,'substatusAt':moment()[_0x4ae6a9(0xc3)](_0x4ae6a9(0xe3)),'lastMsgAt':moment()[_0x4ae6a9(0xc3)](_0x4ae6a9(0xe3)),'lastMsgDirection':'in','lastMsgBody':_0xd83c1b['body'][_0x4ae6a9(0x8d)]}):_0x2177da;})[_0x1bbb49(0x94)](function(_0x4d3b9f){const _0x480841=_0x1bbb49;return _0x5c1a62['interaction']=_0x4d3b9f[_0x480841(0xbd)]({'plain':!![]}),_0x5c1a62[_0x480841(0xe4)][_0x480841(0xa5)]=_0x11eeba,db[_0x480841(0x9f)][_0x480841(0xdd)]({'body':_0xd83c1b[_0x480841(0x8d)][_0x480841(0x8d)],'MailAccountId':_0xd83c1b[_0x480841(0xd0)]['id'],'MailInteractionId':_0x4d3b9f['id'],'direction':'in','ContactId':_0x5c1a62['contact']['id'],'messageId':_0xd83c1b[_0x480841(0x8d)][_0x480841(0xe0)][_0x480841(0x8e)],'from':_0xd83c1b[_0x480841(0x8d)][_0x480841(0xe0)]['from'],'to':_0xd83c1b[_0x480841(0x8d)]['message']['to'],'cc':_0xd83c1b['body'][_0x480841(0xe0)]['cc'],'subject':_0xd83c1b[_0x480841(0x8d)][_0x480841(0xe0)][_0x480841(0x93)],'attach':_0xd83c1b[_0x480841(0x8d)][_0x480841(0xe0)][_0x480841(0xd1)],'Attachments':_0xd83c1b[_0x480841(0x8d)][_0x480841(0xe0)][_0x480841(0xb4)],'originTo':_0xd83c1b['body'][_0x480841(0xe0)][_0x480841(0xa3)],'originCc':_0xd83c1b[_0x480841(0x8d)][_0x480841(0xe0)][_0x480841(0xd6)],'bcc':_0xd83c1b['body']['message'][_0x480841(0xa2)]},{'include':[{'model':db[_0x480841(0xa8)],'as':_0x480841(0xca)}]});})[_0x1bbb49(0x94)](function(_0x517275){const _0x4410ba=_0x1bbb49;_0x5c1a62[_0x4410ba(0xe0)]=_0x517275;if(_0x5c1a62['interaction'][_0x4410ba(0x91)])return db['User'][_0x4410ba(0xb3)]({'attributes':['id',_0x4410ba(0x92)],'where':{'id':_0x5c1a62[_0x4410ba(0xe4)]['UserId']}})['then'](function(_0x249c9e){const _0xba6100=_0x4410ba;return _0x249c9e&&_0x5c1a62[_0xba6100(0xa6)][_0xba6100(0xc6)]({'id':0x0,'priority':0x0,'app':_0xba6100(0xc7),'appdata':_0x249c9e[_0xba6100(0x92)]+','+(_0x5c1a62[_0xba6100(0xd0)][_0xba6100(0xcf)]||0xa),'interval':_0xba6100(0xcc)}),respondWithRpcPromise(_0xba6100(0x90),'startRouting',_0x5c1a62);});return respondWithRpcPromise(_0x4410ba(0x90),_0x4410ba(0x8f),_0x5c1a62);})[_0x1bbb49(0x94)](function(_0x33b8dd){_0x470058(_0x33b8dd);})[_0x1bbb49(0xc4)](function(_0x49ea2b){_0x286647(_0x19be1f['error'](0x1f4,_0x49ea2b['message']));});});};
\ No newline at end of file