Built motion from commit 980b26c3.|2.6.29
[motion2.git] / server / api / mailAccount / mailAccount.rpc.js
index 9fd96ba..e4c9ce2 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x3c17=['findAll','options','raw','attributes','limit','include','model','map','ShowMailAccount','where','smtp','setDataValue','smtpOptions','getSmtpOptions','NotifyMailAccount','body','difference','rawAttributes','createdAt','updatedAt','CompanyId','ListId','isNil','from\x20is\x20mandatory','body\x20is\x20mandatory\x20and\x20not\x20empty','mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','includes','mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','mapKey','from','find','account','CmList','List','Contacts','DESC','MailApplication','Applications','MailServerOut','Smtp','CloudProvider','get','omit','applications','list','asc','close','autoclose','length','CmContact','contact','messageId','generate','attach','YYYY-MM-DD\x20HH:mm:ss','MailInteraction','MailMessage','Messages','inReplyTo','Contact\x20not\x20found','spread','update','subject','format','interaction','created','attachments','originCc','ChatWebsiteId','originChannel','Email','ChatOfflineMessageId','Attachment','Attachments','User','name','UserId','waitForTheAssignedAgent','*,*,*,*','queueId','MailQueue','waitForTheAssignedQueue','Start','startRouting','lodash','bluebird','ioredis','../../mysqldb','../../config/logger','../../config/environment','jayson/promise','client','http','defaults','localhost','socket.io-emitter','redis','request','then','MailAccount,\x20%s,\x20%s','request\x20sent','debug','MailAccount,\x20%s,\x20%s,\x20%s','stringify','error','message','info','result','catch','GetMailAccount','MailAccount'];(function(_0x485038,_0x3e26e8){var _0xa87ace=function(_0x1cf247){while(--_0x1cf247){_0x485038['push'](_0x485038['shift']());}};_0xa87ace(++_0x3e26e8);}(_0x3c17,0x1a1));var _0x73c1=function(_0x6c993a,_0x5ea3ab){_0x6c993a=_0x6c993a-0x0;var _0x27f547=_0x3c17[_0x6c993a];return _0x27f547;};'use strict';var _=require(_0x73c1('0x0'));var moment=require('moment');var BPromise=require(_0x73c1('0x1'));var rs=require('randomstring');var Redis=require(_0x73c1('0x2'));var db=require(_0x73c1('0x3'))['db'];var logger=require(_0x73c1('0x4'))('rpc');var config=require(_0x73c1('0x5'));var jayson=require(_0x73c1('0x6'));var client=jayson[_0x73c1('0x7')][_0x73c1('0x8')]({'port':0x232c});config['redis']=_[_0x73c1('0x9')](config['redis'],{'host':_0x73c1('0xa'),'port':0x18eb});var socket=require(_0x73c1('0xb'))(new Redis(config[_0x73c1('0xc')]));require('./mailAccount.socket')['register'](socket);function respondWithRpcPromise(_0x176227,_0x2eb6fe,_0x400875){return new BPromise(function(_0x16c774,_0x2b2578){return client[_0x73c1('0xd')](_0x176227,_0x400875)[_0x73c1('0xe')](function(_0x4e5bc6){logger['info'](_0x73c1('0xf'),_0x2eb6fe,_0x73c1('0x10'));logger[_0x73c1('0x11')](_0x73c1('0x12'),_0x2eb6fe,'request\x20sent',JSON[_0x73c1('0x13')](_0x4e5bc6));if(_0x4e5bc6['error']){if(_0x4e5bc6[_0x73c1('0x14')]['code']===0x1f4){logger[_0x73c1('0x14')](_0x73c1('0xf'),_0x2eb6fe,_0x4e5bc6['error']['message']);return _0x2b2578(_0x4e5bc6[_0x73c1('0x14')]['message']);}logger[_0x73c1('0x14')]('MailAccount,\x20%s,\x20%s',_0x2eb6fe,_0x4e5bc6[_0x73c1('0x14')]['message']);return _0x16c774(_0x4e5bc6[_0x73c1('0x14')][_0x73c1('0x15')]);}else{logger[_0x73c1('0x16')](_0x73c1('0xf'),_0x2eb6fe,_0x73c1('0x10'));_0x16c774(_0x4e5bc6[_0x73c1('0x17')][_0x73c1('0x15')]);}})[_0x73c1('0x18')](function(_0x1ce19e){logger['error'](_0x73c1('0xf'),_0x2eb6fe,_0x1ce19e);_0x2b2578(_0x1ce19e);});});}exports[_0x73c1('0x19')]=function(_0x28df60){var _0x121bef=this;return new Promise(function(_0x4b1b94,_0x3fbaea){return db[_0x73c1('0x1a')][_0x73c1('0x1b')]({'raw':_0x28df60[_0x73c1('0x1c')]?_0x28df60[_0x73c1('0x1c')][_0x73c1('0x1d')]===undefined?!![]:![]:!![],'where':_0x28df60[_0x73c1('0x1c')]?_0x28df60[_0x73c1('0x1c')]['where']||null:null,'attributes':_0x28df60[_0x73c1('0x1c')]?_0x28df60[_0x73c1('0x1c')][_0x73c1('0x1e')]||null:null,'limit':_0x28df60['options']?_0x28df60[_0x73c1('0x1c')][_0x73c1('0x1f')]||null:null,'include':_0x28df60[_0x73c1('0x1c')]?_0x28df60[_0x73c1('0x1c')][_0x73c1('0x20')]?_['map'](_0x28df60[_0x73c1('0x1c')]['include'],function(_0x54feeb){return{'model':db[_0x54feeb[_0x73c1('0x21')]],'as':_0x54feeb['as'],'attributes':_0x54feeb[_0x73c1('0x1e')],'include':_0x54feeb[_0x73c1('0x20')]?_[_0x73c1('0x22')](_0x54feeb[_0x73c1('0x20')],function(_0x30ec73){return{'model':db[_0x30ec73[_0x73c1('0x21')]],'as':_0x30ec73['as'],'attributes':_0x30ec73[_0x73c1('0x1e')],'include':_0x30ec73[_0x73c1('0x20')]?_[_0x73c1('0x22')](_0x30ec73[_0x73c1('0x20')],function(_0x460b69){return{'model':db[_0x460b69[_0x73c1('0x21')]],'as':_0x460b69['as'],'attributes':_0x460b69[_0x73c1('0x1e')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x2b2996){logger[_0x73c1('0x16')](_0x73c1('0x19'),_0x28df60);logger[_0x73c1('0x11')](_0x73c1('0x19'),_0x28df60,JSON[_0x73c1('0x13')](_0x2b2996));_0x4b1b94(_0x2b2996);})[_0x73c1('0x18')](function(_0x45c411){logger[_0x73c1('0x14')]('GetMailAccount',_0x45c411['message'],_0x28df60);_0x3fbaea(_0x121bef[_0x73c1('0x14')](0x1f4,_0x45c411[_0x73c1('0x15')]));});});};exports[_0x73c1('0x23')]=function(_0x2a9ff8){var _0x52a05e=this;return new Promise(function(_0x3e54b2,_0x11432d){return db[_0x73c1('0x1a')]['find']({'raw':_0x2a9ff8[_0x73c1('0x1c')]?_0x2a9ff8[_0x73c1('0x1c')][_0x73c1('0x1d')]===undefined?!![]:![]:!![],'where':_0x2a9ff8[_0x73c1('0x1c')]?_0x2a9ff8[_0x73c1('0x1c')][_0x73c1('0x24')]||null:null,'attributes':_0x2a9ff8['options']?_0x2a9ff8[_0x73c1('0x1c')][_0x73c1('0x1e')]||null:null,'include':_0x2a9ff8[_0x73c1('0x1c')]?_0x2a9ff8[_0x73c1('0x1c')][_0x73c1('0x20')]?_[_0x73c1('0x22')](_0x2a9ff8[_0x73c1('0x1c')][_0x73c1('0x20')],function(_0x3103ec){return{'model':db[_0x3103ec[_0x73c1('0x21')]],'as':_0x3103ec['as'],'attributes':_0x3103ec['attributes'],'include':_0x3103ec[_0x73c1('0x20')]?_['map'](_0x3103ec[_0x73c1('0x20')],function(_0x25e2f6){return{'model':db[_0x25e2f6[_0x73c1('0x21')]],'as':_0x25e2f6['as'],'attributes':_0x25e2f6[_0x73c1('0x1e')],'include':_0x25e2f6['include']?_['map'](_0x25e2f6['include'],function(_0x26ab79){return{'model':db[_0x26ab79['model']],'as':_0x26ab79['as'],'attributes':_0x26ab79[_0x73c1('0x1e')]};}):[]};}):[]};}):[]:[]})[_0x73c1('0xe')](function(_0x2dcdc4){if(_0x2a9ff8[_0x73c1('0x1c')][_0x73c1('0x25')]===!![])_0x2dcdc4[_0x73c1('0x26')](_0x73c1('0x27'),_0x2dcdc4[_0x73c1('0x28')]());logger[_0x73c1('0x16')](_0x73c1('0x23'),_0x2a9ff8);logger[_0x73c1('0x11')]('ShowMailAccount',_0x2a9ff8,JSON[_0x73c1('0x13')](_0x2dcdc4));_0x3e54b2(_0x2dcdc4);})[_0x73c1('0x18')](function(_0x4728e2){logger[_0x73c1('0x14')](_0x73c1('0x23'),_0x4728e2[_0x73c1('0x15')],_0x2a9ff8);_0x11432d(_0x52a05e['error'](0x1f4,_0x4728e2[_0x73c1('0x15')]));});});};exports[_0x73c1('0x29')]=function(_0x3c6b35){var _0x2411bb=this;return new Promise(function(_0x21feb9,_0x20668f){var _0x4d87fb={'body':_0x3c6b35[_0x73c1('0x2a')],'channel':'mail'};var _0x3fdc4f=_[_0x73c1('0x2b')](_['keys'](db['CmContact'][_0x73c1('0x2c')]),[_0x73c1('0x2d'),_0x73c1('0x2e'),_0x73c1('0x2f'),_0x73c1('0x30')]);var _0x282b73=![];if(_0x3c6b35['body']['id']){delete _0x3c6b35['body']['id'];}if(_[_0x73c1('0x31')](_0x3c6b35[_0x73c1('0x2a')]['from'])){return _0x20668f(_0x2411bb['error'](0x1f4,_0x73c1('0x32')));}if(_['isNil'](_0x3c6b35[_0x73c1('0x2a')][_0x73c1('0x2a')])||_0x3c6b35[_0x73c1('0x2a')][_0x73c1('0x2a')]===''){return _0x20668f(_0x2411bb[_0x73c1('0x14')](0x1f4,_0x73c1('0x33')));}if(_[_0x73c1('0x31')](_0x3c6b35[_0x73c1('0x2a')]['mapKey'])){return _0x20668f(_0x2411bb['error'](0x1f4,_0x73c1('0x34')+_0x3fdc4f));}if(!_[_0x73c1('0x35')](_0x3fdc4f,_0x3c6b35[_0x73c1('0x2a')]['mapKey'])){return _0x20668f(_0x2411bb[_0x73c1('0x14')](0x1f4,_0x73c1('0x36')+_0x3fdc4f));}var _0x3c504d={};_0x3c504d[_0x3c6b35[_0x73c1('0x2a')][_0x73c1('0x37')]]=_0x3c6b35[_0x73c1('0x2a')][_0x73c1('0x38')];return db[_0x73c1('0x1a')][_0x73c1('0x39')]({'where':{'id':_0x3c6b35[_0x73c1('0x3a')]['id']},'include':[{'model':db[_0x73c1('0x3b')],'as':_0x73c1('0x3c'),'include':[{'model':db['CmContact'],'as':_0x73c1('0x3d'),'where':_0x3c504d,'limit':0x1,'order':[['updatedAt',_0x73c1('0x3e')]]}]},{'model':db[_0x73c1('0x3f')],'as':_0x73c1('0x40')},{'model':db[_0x73c1('0x41')],'as':_0x73c1('0x42'),'include':[{'model':db[_0x73c1('0x43')],'as':'CloudProvider'}]}]})[_0x73c1('0xe')](function(_0x2ccd11){if(_0x2ccd11&&_0x2ccd11[_0x73c1('0x3c')]){var _0x4c1f5f=_0x2ccd11[_0x73c1('0x44')]({'plain':!![]});_0x4d87fb[_0x73c1('0x3a')]=_[_0x73c1('0x45')](_0x4c1f5f,[_0x73c1('0x40'),_0x73c1('0x3c')]);_0x4d87fb[_0x73c1('0x3a')][_0x73c1('0x27')]=_0x2ccd11[_0x73c1('0x28')]();_0x4d87fb[_0x73c1('0x46')]=_0x4c1f5f['Applications'];_0x4d87fb[_0x73c1('0x47')]=_0x4c1f5f['List'];_0x4d87fb['applications']=_['orderBy'](_0x4d87fb['applications'],['priority'],[_0x73c1('0x48')]);if(_0x4d87fb['account']&&_0x4d87fb[_0x73c1('0x3a')]['autoclose']){_0x4d87fb['applications']['push']({'id':0x0,'priority':_0x4d87fb[_0x73c1('0x46')]['length']+0x1,'app':_0x73c1('0x49'),'appdata':_0x73c1('0x4a'),'interval':'*,*,*,*'});}if(_0x4d87fb[_0x73c1('0x3a')][_0x73c1('0x40')]){delete _0x4d87fb[_0x73c1('0x3a')][_0x73c1('0x40')];}if(_0x4d87fb[_0x73c1('0x3a')][_0x73c1('0x3c')]){delete _0x4d87fb[_0x73c1('0x3a')][_0x73c1('0x3c')];}if(_0x4c1f5f[_0x73c1('0x3c')][_0x73c1('0x3d')][_0x73c1('0x4b')]){return _0x4c1f5f[_0x73c1('0x3c')][_0x73c1('0x3d')][0x0];}var _0x2cb41b=_[_0x73c1('0x9')](_0x3c6b35[_0x73c1('0x2a')],{'firstName':_0x3c6b35[_0x73c1('0x2a')][_0x73c1('0x38')],'ListId':_0x4c1f5f[_0x73c1('0x30')]});_0x2cb41b[_0x3c6b35[_0x73c1('0x2a')][_0x73c1('0x37')]]=_0x3c6b35['body']['from'];return db[_0x73c1('0x4c')]['create'](_0x2cb41b);}else{throw new Error('List\x20not\x20found');}})[_0x73c1('0xe')](function(_0x854ef6){_0x4d87fb[_0x73c1('0x4d')]=_0x854ef6;if(_0x854ef6){if(!_0x3c6b35[_0x73c1('0x2a')][_0x73c1('0x15')][_0x73c1('0x4e')]){_0x3c6b35[_0x73c1('0x2a')][_0x73c1('0x15')][_0x73c1('0x4e')]=rs[_0x73c1('0x4f')]()+'\x20'+_0x3c6b35[_0x73c1('0x2a')][_0x73c1('0x15')]['from'];}var _0x385817={'ContactId':_0x854ef6['id'],'MailAccountId':_0x3c6b35[_0x73c1('0x3a')]['id'],'inReplyTo':_0x3c6b35[_0x73c1('0x2a')]['message'][_0x73c1('0x4e')],'to':_0x3c6b35[_0x73c1('0x2a')][_0x73c1('0x15')]['from'],'cc':_0x3c6b35['body']['message']['cc'],'subject':_0x3c6b35[_0x73c1('0x2a')][_0x73c1('0x15')]['subject'],'attach':_0x3c6b35[_0x73c1('0x2a')][_0x73c1('0x15')][_0x73c1('0x50')],'lastMsgAt':moment()['format'](_0x73c1('0x51')),'lastMsgDirection':'in'};return db[_0x73c1('0x52')][_0x73c1('0x39')]({'where':{'closed':![],'MailAccountId':_0x3c6b35[_0x73c1('0x3a')]['id']},'include':[{'model':db[_0x73c1('0x53')],'as':_0x73c1('0x54'),'attributes':[_0x73c1('0x4e')],'where':{'messageId':_0x3c6b35[_0x73c1('0x2a')][_0x73c1('0x15')][_0x73c1('0x55')]}}]})[_0x73c1('0xe')](function(_0x1575f4){if(_0x1575f4){return[_0x1575f4,![]];}return db[_0x73c1('0x52')]['create'](_0x385817)[_0x73c1('0xe')](function(_0x5517e3){return[_0x5517e3,!![]];});});}else{throw new Error(_0x73c1('0x56'));}})[_0x73c1('0x57')](function(_0x595086,_0x2295c5){if(_0x595086){_0x282b73=_0x2295c5;if(!_0x2295c5){return _0x595086[_0x73c1('0x58')]({'inReplyTo':_0x3c6b35['body'][_0x73c1('0x15')]['messageId'],'to':_0x3c6b35[_0x73c1('0x2a')][_0x73c1('0x15')][_0x73c1('0x38')],'cc':_0x3c6b35[_0x73c1('0x2a')][_0x73c1('0x15')]['cc'],'subject':_0x3c6b35[_0x73c1('0x2a')][_0x73c1('0x15')][_0x73c1('0x59')],'attach':_0x595086[_0x73c1('0x50')]?_0x595086[_0x73c1('0x50')]:_0x3c6b35['body'][_0x73c1('0x15')][_0x73c1('0x50')],'substatus':null,'substatusAt':moment()[_0x73c1('0x5a')](_0x73c1('0x51')),'lastMsgAt':moment()['format']('YYYY-MM-DD\x20HH:mm:ss'),'lastMsgDirection':'in'});}else{return _0x595086;}}})[_0x73c1('0xe')](function(_0x466f4d){_0x4d87fb[_0x73c1('0x5b')]=_0x466f4d[_0x73c1('0x44')]({'plain':!![]});_0x4d87fb[_0x73c1('0x5b')][_0x73c1('0x5c')]=_0x282b73;return db[_0x73c1('0x53')]['create']({'body':_0x3c6b35[_0x73c1('0x2a')]['body'],'MailAccountId':_0x3c6b35[_0x73c1('0x3a')]['id'],'MailInteractionId':_0x466f4d['id'],'direction':'in','ContactId':_0x4d87fb[_0x73c1('0x4d')]['id'],'messageId':_0x3c6b35['body'][_0x73c1('0x15')][_0x73c1('0x4e')],'from':_0x3c6b35[_0x73c1('0x2a')][_0x73c1('0x15')]['from'],'to':_0x3c6b35[_0x73c1('0x2a')][_0x73c1('0x15')]['to'],'cc':_0x3c6b35['body']['message']['cc'],'subject':_0x3c6b35[_0x73c1('0x2a')][_0x73c1('0x15')]['subject'],'attach':_0x3c6b35['body'][_0x73c1('0x15')][_0x73c1('0x50')],'Attachments':_0x3c6b35[_0x73c1('0x2a')][_0x73c1('0x15')][_0x73c1('0x5d')],'originTo':_0x3c6b35[_0x73c1('0x2a')][_0x73c1('0x15')]['originTo'],'originCc':_0x3c6b35['body'][_0x73c1('0x15')][_0x73c1('0x5e')],'bcc':_0x3c6b35[_0x73c1('0x2a')][_0x73c1('0x15')]['bcc'],'ChatWebsiteId':_0x3c6b35['body'][_0x73c1('0x15')][_0x73c1('0x5f')]||null,'originChannel':_0x3c6b35[_0x73c1('0x2a')][_0x73c1('0x15')][_0x73c1('0x60')]||_0x73c1('0x61'),'ChatOfflineMessageId':_0x3c6b35[_0x73c1('0x2a')][_0x73c1('0x15')][_0x73c1('0x62')]||null},{'include':[{'model':db[_0x73c1('0x63')],'as':_0x73c1('0x64')}]});})[_0x73c1('0xe')](function(_0xa8ed18){_0x4d87fb[_0x73c1('0x15')]=_0xa8ed18;if(!_0x4d87fb[_0x73c1('0x5b')]['UserId']){return;}return db[_0x73c1('0x65')]['find']({'attributes':['id',_0x73c1('0x66')],'where':{'id':_0x4d87fb['interaction'][_0x73c1('0x67')]}});})[_0x73c1('0xe')](function(_0x3ae4d7){if(_0x3ae4d7){_0x4d87fb[_0x73c1('0x46')]['unshift']({'id':0x0,'priority':0x0,'app':'agent','appdata':_0x3ae4d7[_0x73c1('0x66')]+','+(_0x4d87fb[_0x73c1('0x3a')][_0x73c1('0x68')]||0xa),'interval':_0x73c1('0x69')});}if(!_0x4d87fb[_0x73c1('0x5b')][_0x73c1('0x6a')]){return;}return db[_0x73c1('0x6b')][_0x73c1('0x39')]({'attributes':['id',_0x73c1('0x66')],'where':{'id':_0x4d87fb['interaction'][_0x73c1('0x6a')]}});})[_0x73c1('0xe')](function(_0x281310){if(_0x281310){_0x4d87fb[_0x73c1('0x46')]['unshift']({'id':0x0,'priority':0x1,'app':'queue','appdata':_0x281310[_0x73c1('0x66')]+','+(_0x4d87fb[_0x73c1('0x3a')][_0x73c1('0x6c')]||0x12c),'interval':_0x73c1('0x69')});}return respondWithRpcPromise(_0x73c1('0x6d'),_0x73c1('0x6e'),_0x4d87fb);})[_0x73c1('0xe')](function(_0x5458e1){_0x21feb9(_0x5458e1);})[_0x73c1('0x18')](function(_0x1040b4){_0x20668f(_0x2411bb[_0x73c1('0x14')](0x1f4,_0x1040b4[_0x73c1('0x15')]));});});};
\ No newline at end of file
+var _0xdbf5=['ShowMailAccount','NotifyMailAccount','difference','CmContact','rawAttributes','updatedAt','CompanyId','ListId','body','isNil','from','body\x20is\x20mandatory\x20and\x20not\x20empty','mapKey','mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','includes','List','DESC','Applications','MailServerOut','CloudProvider','omit','account','getSmtpOptions','applications','orderBy','priority','asc','autoclose','push','length','close','*,*,*,*','Contacts','List\x20not\x20found','messageId','subject','attach','format','YYYY-MM-DD\x20HH:mm:ss','find','MailMessage','Messages','inReplyTo','MailInteraction','create','Contact\x20not\x20found','spread','update','interaction','get','created','contact','originTo','originCc','ChatWebsiteId','originChannel','Attachment','Attachments','UserId','User','name','unshift','waitForTheAssignedAgent','queueId','MailQueue','queue','waitForTheAssignedQueue','Start','startRouting','moment','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis','defaults','localhost','socket.io-emitter','./mailAccount.socket','request','info','debug','request\x20sent','stringify','error','code','message','MailAccount,\x20%s,\x20%s','result','catch','MailAccount','findAll','options','raw','where','attributes','limit','include','map','model','then','GetMailAccount','smtp','setDataValue','smtpOptions'];(function(_0x17d9e3,_0x1f969c){var _0x14192d=function(_0x159745){while(--_0x159745){_0x17d9e3['push'](_0x17d9e3['shift']());}};_0x14192d(++_0x1f969c);}(_0xdbf5,0x18c));var _0x5dbf=function(_0xcb5a67,_0x5b9971){_0xcb5a67=_0xcb5a67-0x0;var _0x348a6b=_0xdbf5[_0xcb5a67];return _0x348a6b;};'use strict';var _=require('lodash');var moment=require(_0x5dbf('0x0'));var BPromise=require('bluebird');var rs=require('randomstring');var Redis=require(_0x5dbf('0x1'));var db=require(_0x5dbf('0x2'))['db'];var logger=require(_0x5dbf('0x3'))(_0x5dbf('0x4'));var config=require(_0x5dbf('0x5'));var jayson=require(_0x5dbf('0x6'));var client=jayson[_0x5dbf('0x7')][_0x5dbf('0x8')]({'port':0x232c});config[_0x5dbf('0x9')]=_[_0x5dbf('0xa')](config[_0x5dbf('0x9')],{'host':_0x5dbf('0xb'),'port':0x18eb});var socket=require(_0x5dbf('0xc'))(new Redis(config['redis']));require(_0x5dbf('0xd'))['register'](socket);function respondWithRpcPromise(_0x1f9510,_0x3bec50,_0x264007){return new BPromise(function(_0x1813bb,_0x4efed3){return client[_0x5dbf('0xe')](_0x1f9510,_0x264007)['then'](function(_0x5433f4){logger[_0x5dbf('0xf')]('MailAccount,\x20%s,\x20%s',_0x3bec50,'request\x20sent');logger[_0x5dbf('0x10')]('MailAccount,\x20%s,\x20%s,\x20%s',_0x3bec50,_0x5dbf('0x11'),JSON[_0x5dbf('0x12')](_0x5433f4));if(_0x5433f4[_0x5dbf('0x13')]){if(_0x5433f4[_0x5dbf('0x13')][_0x5dbf('0x14')]===0x1f4){logger['error']('MailAccount,\x20%s,\x20%s',_0x3bec50,_0x5433f4[_0x5dbf('0x13')][_0x5dbf('0x15')]);return _0x4efed3(_0x5433f4['error'][_0x5dbf('0x15')]);}logger[_0x5dbf('0x13')](_0x5dbf('0x16'),_0x3bec50,_0x5433f4[_0x5dbf('0x13')][_0x5dbf('0x15')]);return _0x1813bb(_0x5433f4[_0x5dbf('0x13')][_0x5dbf('0x15')]);}else{logger['info']('MailAccount,\x20%s,\x20%s',_0x3bec50,_0x5dbf('0x11'));_0x1813bb(_0x5433f4[_0x5dbf('0x17')][_0x5dbf('0x15')]);}})[_0x5dbf('0x18')](function(_0x20c2b0){logger['error'](_0x5dbf('0x16'),_0x3bec50,_0x20c2b0);_0x4efed3(_0x20c2b0);});});}exports['GetMailAccount']=function(_0x565efa){var _0x577ca2=this;return new Promise(function(_0x23d1e7,_0x3cedac){return db[_0x5dbf('0x19')][_0x5dbf('0x1a')]({'raw':_0x565efa[_0x5dbf('0x1b')]?_0x565efa['options'][_0x5dbf('0x1c')]===undefined?!![]:![]:!![],'where':_0x565efa['options']?_0x565efa[_0x5dbf('0x1b')][_0x5dbf('0x1d')]||null:null,'attributes':_0x565efa[_0x5dbf('0x1b')]?_0x565efa[_0x5dbf('0x1b')][_0x5dbf('0x1e')]||null:null,'limit':_0x565efa[_0x5dbf('0x1b')]?_0x565efa['options'][_0x5dbf('0x1f')]||null:null,'include':_0x565efa[_0x5dbf('0x1b')]?_0x565efa[_0x5dbf('0x1b')][_0x5dbf('0x20')]?_[_0x5dbf('0x21')](_0x565efa[_0x5dbf('0x1b')][_0x5dbf('0x20')],function(_0x20ab1b){return{'model':db[_0x20ab1b[_0x5dbf('0x22')]],'as':_0x20ab1b['as'],'attributes':_0x20ab1b[_0x5dbf('0x1e')],'include':_0x20ab1b[_0x5dbf('0x20')]?_[_0x5dbf('0x21')](_0x20ab1b[_0x5dbf('0x20')],function(_0x407741){return{'model':db[_0x407741[_0x5dbf('0x22')]],'as':_0x407741['as'],'attributes':_0x407741[_0x5dbf('0x1e')],'include':_0x407741[_0x5dbf('0x20')]?_[_0x5dbf('0x21')](_0x407741[_0x5dbf('0x20')],function(_0x22ec42){return{'model':db[_0x22ec42[_0x5dbf('0x22')]],'as':_0x22ec42['as'],'attributes':_0x22ec42[_0x5dbf('0x1e')]};}):[]};}):[]};}):[]:[]})[_0x5dbf('0x23')](function(_0x5768b7){logger[_0x5dbf('0xf')](_0x5dbf('0x24'),_0x565efa);logger[_0x5dbf('0x10')](_0x5dbf('0x24'),_0x565efa,JSON[_0x5dbf('0x12')](_0x5768b7));_0x23d1e7(_0x5768b7);})[_0x5dbf('0x18')](function(_0x2a65c5){logger[_0x5dbf('0x13')](_0x5dbf('0x24'),_0x2a65c5[_0x5dbf('0x15')],_0x565efa);_0x3cedac(_0x577ca2[_0x5dbf('0x13')](0x1f4,_0x2a65c5['message']));});});};exports['ShowMailAccount']=function(_0xf429ae){var _0x19015a=this;return new Promise(function(_0x2cb2dc,_0x3b73ad){return db[_0x5dbf('0x19')]['find']({'raw':_0xf429ae['options']?_0xf429ae[_0x5dbf('0x1b')][_0x5dbf('0x1c')]===undefined?!![]:![]:!![],'where':_0xf429ae['options']?_0xf429ae[_0x5dbf('0x1b')][_0x5dbf('0x1d')]||null:null,'attributes':_0xf429ae[_0x5dbf('0x1b')]?_0xf429ae[_0x5dbf('0x1b')][_0x5dbf('0x1e')]||null:null,'include':_0xf429ae['options']?_0xf429ae[_0x5dbf('0x1b')][_0x5dbf('0x20')]?_[_0x5dbf('0x21')](_0xf429ae[_0x5dbf('0x1b')][_0x5dbf('0x20')],function(_0x4e4518){return{'model':db[_0x4e4518[_0x5dbf('0x22')]],'as':_0x4e4518['as'],'attributes':_0x4e4518[_0x5dbf('0x1e')],'include':_0x4e4518[_0x5dbf('0x20')]?_[_0x5dbf('0x21')](_0x4e4518['include'],function(_0x381987){return{'model':db[_0x381987[_0x5dbf('0x22')]],'as':_0x381987['as'],'attributes':_0x381987[_0x5dbf('0x1e')],'include':_0x381987[_0x5dbf('0x20')]?_[_0x5dbf('0x21')](_0x381987[_0x5dbf('0x20')],function(_0x1aeb02){return{'model':db[_0x1aeb02[_0x5dbf('0x22')]],'as':_0x1aeb02['as'],'attributes':_0x1aeb02[_0x5dbf('0x1e')]};}):[]};}):[]};}):[]:[]})[_0x5dbf('0x23')](function(_0x1ba835){if(_0xf429ae['options'][_0x5dbf('0x25')]===!![])_0x1ba835[_0x5dbf('0x26')](_0x5dbf('0x27'),_0x1ba835['getSmtpOptions']());logger[_0x5dbf('0xf')](_0x5dbf('0x28'),_0xf429ae);logger[_0x5dbf('0x10')]('ShowMailAccount',_0xf429ae,JSON[_0x5dbf('0x12')](_0x1ba835));_0x2cb2dc(_0x1ba835);})[_0x5dbf('0x18')](function(_0x9bd4c0){logger['error'](_0x5dbf('0x28'),_0x9bd4c0[_0x5dbf('0x15')],_0xf429ae);_0x3b73ad(_0x19015a[_0x5dbf('0x13')](0x1f4,_0x9bd4c0[_0x5dbf('0x15')]));});});};exports[_0x5dbf('0x29')]=function(_0x6ebcc6){var _0x321ae3=this;return new Promise(function(_0x2ed355,_0x4b71c1){var _0x5be96b={'body':_0x6ebcc6['body'],'channel':'mail'};var _0x28b28f=_[_0x5dbf('0x2a')](_['keys'](db[_0x5dbf('0x2b')][_0x5dbf('0x2c')]),['createdAt',_0x5dbf('0x2d'),_0x5dbf('0x2e'),_0x5dbf('0x2f')]);var _0x2ee6b9=![];if(_0x6ebcc6[_0x5dbf('0x30')]['id']){delete _0x6ebcc6[_0x5dbf('0x30')]['id'];}if(_[_0x5dbf('0x31')](_0x6ebcc6[_0x5dbf('0x30')][_0x5dbf('0x32')])){return _0x4b71c1(_0x321ae3[_0x5dbf('0x13')](0x1f4,'from\x20is\x20mandatory'));}if(_[_0x5dbf('0x31')](_0x6ebcc6[_0x5dbf('0x30')][_0x5dbf('0x30')])||_0x6ebcc6['body'][_0x5dbf('0x30')]===''){return _0x4b71c1(_0x321ae3[_0x5dbf('0x13')](0x1f4,_0x5dbf('0x33')));}if(_[_0x5dbf('0x31')](_0x6ebcc6['body'][_0x5dbf('0x34')])){return _0x4b71c1(_0x321ae3['error'](0x1f4,_0x5dbf('0x35')+_0x28b28f));}if(!_[_0x5dbf('0x36')](_0x28b28f,_0x6ebcc6[_0x5dbf('0x30')][_0x5dbf('0x34')])){return _0x4b71c1(_0x321ae3['error'](0x1f4,'mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20'+_0x28b28f));}var _0x118ae6={};_0x118ae6[_0x6ebcc6[_0x5dbf('0x30')][_0x5dbf('0x34')]]=_0x6ebcc6['body'][_0x5dbf('0x32')];return db['MailAccount']['find']({'where':{'id':_0x6ebcc6['account']['id']},'include':[{'model':db['CmList'],'as':_0x5dbf('0x37'),'include':[{'model':db[_0x5dbf('0x2b')],'as':'Contacts','where':_0x118ae6,'limit':0x1,'order':[[_0x5dbf('0x2d'),_0x5dbf('0x38')]]}]},{'model':db['MailApplication'],'as':_0x5dbf('0x39')},{'model':db[_0x5dbf('0x3a')],'as':'Smtp','include':[{'model':db[_0x5dbf('0x3b')],'as':'CloudProvider'}]}]})['then'](function(_0x337897){if(_0x337897&&_0x337897[_0x5dbf('0x37')]){var _0x17a1c0=_0x337897['get']({'plain':!![]});_0x5be96b['account']=_[_0x5dbf('0x3c')](_0x17a1c0,[_0x5dbf('0x39'),_0x5dbf('0x37')]);_0x5be96b[_0x5dbf('0x3d')][_0x5dbf('0x27')]=_0x337897[_0x5dbf('0x3e')]();_0x5be96b[_0x5dbf('0x3f')]=_0x17a1c0[_0x5dbf('0x39')];_0x5be96b['list']=_0x17a1c0[_0x5dbf('0x37')];_0x5be96b[_0x5dbf('0x3f')]=_[_0x5dbf('0x40')](_0x5be96b[_0x5dbf('0x3f')],[_0x5dbf('0x41')],[_0x5dbf('0x42')]);if(_0x5be96b[_0x5dbf('0x3d')]&&_0x5be96b['account'][_0x5dbf('0x43')]){_0x5be96b['applications'][_0x5dbf('0x44')]({'id':0x0,'priority':_0x5be96b[_0x5dbf('0x3f')][_0x5dbf('0x45')]+0x1,'app':_0x5dbf('0x46'),'appdata':_0x5dbf('0x43'),'interval':_0x5dbf('0x47')});}if(_0x5be96b[_0x5dbf('0x3d')]['Applications']){delete _0x5be96b['account']['Applications'];}if(_0x5be96b[_0x5dbf('0x3d')][_0x5dbf('0x37')]){delete _0x5be96b[_0x5dbf('0x3d')]['List'];}if(_0x17a1c0['List'][_0x5dbf('0x48')][_0x5dbf('0x45')]){return _0x17a1c0[_0x5dbf('0x37')]['Contacts'][0x0];}var _0x2c9876=_['defaults'](_0x6ebcc6[_0x5dbf('0x30')],{'firstName':_0x6ebcc6[_0x5dbf('0x30')][_0x5dbf('0x32')],'ListId':_0x17a1c0['ListId']});_0x2c9876[_0x6ebcc6['body'][_0x5dbf('0x34')]]=_0x6ebcc6[_0x5dbf('0x30')][_0x5dbf('0x32')];return db[_0x5dbf('0x2b')]['create'](_0x2c9876);}else{throw new Error(_0x5dbf('0x49'));}})[_0x5dbf('0x23')](function(_0x478cc1){_0x5be96b['contact']=_0x478cc1;if(_0x478cc1){if(!_0x6ebcc6[_0x5dbf('0x30')][_0x5dbf('0x15')][_0x5dbf('0x4a')]){_0x6ebcc6[_0x5dbf('0x30')][_0x5dbf('0x15')][_0x5dbf('0x4a')]=rs['generate']()+'\x20'+_0x6ebcc6[_0x5dbf('0x30')]['message']['from'];}var _0x4f1b40={'ContactId':_0x478cc1['id'],'MailAccountId':_0x6ebcc6[_0x5dbf('0x3d')]['id'],'inReplyTo':_0x6ebcc6['body'][_0x5dbf('0x15')][_0x5dbf('0x4a')],'to':_0x6ebcc6[_0x5dbf('0x30')][_0x5dbf('0x15')][_0x5dbf('0x32')],'cc':_0x6ebcc6[_0x5dbf('0x30')][_0x5dbf('0x15')]['cc'],'subject':_0x6ebcc6[_0x5dbf('0x30')][_0x5dbf('0x15')][_0x5dbf('0x4b')],'attach':_0x6ebcc6[_0x5dbf('0x30')][_0x5dbf('0x15')][_0x5dbf('0x4c')],'lastMsgAt':moment()[_0x5dbf('0x4d')](_0x5dbf('0x4e')),'lastMsgDirection':'in'};return db['MailInteraction'][_0x5dbf('0x4f')]({'where':{'closed':![],'MailAccountId':_0x6ebcc6['account']['id']},'include':[{'model':db[_0x5dbf('0x50')],'as':_0x5dbf('0x51'),'attributes':[_0x5dbf('0x4a')],'where':{'messageId':_0x6ebcc6[_0x5dbf('0x30')]['message'][_0x5dbf('0x52')]}}]})[_0x5dbf('0x23')](function(_0x4362c6){if(_0x4362c6){return[_0x4362c6,![]];}return db[_0x5dbf('0x53')][_0x5dbf('0x54')](_0x4f1b40)[_0x5dbf('0x23')](function(_0x52efd7){return[_0x52efd7,!![]];});});}else{throw new Error(_0x5dbf('0x55'));}})[_0x5dbf('0x56')](function(_0x3b0465,_0x18bc53){if(_0x3b0465){_0x2ee6b9=_0x18bc53;if(!_0x18bc53){return _0x3b0465[_0x5dbf('0x57')]({'inReplyTo':_0x6ebcc6[_0x5dbf('0x30')][_0x5dbf('0x15')][_0x5dbf('0x4a')],'to':_0x6ebcc6[_0x5dbf('0x30')][_0x5dbf('0x15')][_0x5dbf('0x32')],'cc':_0x6ebcc6[_0x5dbf('0x30')]['message']['cc'],'subject':_0x6ebcc6['body'][_0x5dbf('0x15')][_0x5dbf('0x4b')],'attach':_0x3b0465[_0x5dbf('0x4c')]?_0x3b0465[_0x5dbf('0x4c')]:_0x6ebcc6[_0x5dbf('0x30')][_0x5dbf('0x15')][_0x5dbf('0x4c')],'substatus':null,'substatusAt':moment()[_0x5dbf('0x4d')](_0x5dbf('0x4e')),'lastMsgAt':moment()['format']('YYYY-MM-DD\x20HH:mm:ss'),'lastMsgDirection':'in'});}else{return _0x3b0465;}}})['then'](function(_0x4f4aa3){_0x5be96b[_0x5dbf('0x58')]=_0x4f4aa3[_0x5dbf('0x59')]({'plain':!![]});_0x5be96b[_0x5dbf('0x58')][_0x5dbf('0x5a')]=_0x2ee6b9;return db[_0x5dbf('0x50')][_0x5dbf('0x54')]({'body':_0x6ebcc6['body']['body'],'MailAccountId':_0x6ebcc6[_0x5dbf('0x3d')]['id'],'MailInteractionId':_0x4f4aa3['id'],'direction':'in','ContactId':_0x5be96b[_0x5dbf('0x5b')]['id'],'messageId':_0x6ebcc6['body'][_0x5dbf('0x15')][_0x5dbf('0x4a')],'from':_0x6ebcc6[_0x5dbf('0x30')][_0x5dbf('0x15')]['from'],'to':_0x6ebcc6[_0x5dbf('0x30')][_0x5dbf('0x15')]['to'],'cc':_0x6ebcc6[_0x5dbf('0x30')][_0x5dbf('0x15')]['cc'],'subject':_0x6ebcc6[_0x5dbf('0x30')]['message'][_0x5dbf('0x4b')],'attach':_0x6ebcc6[_0x5dbf('0x30')][_0x5dbf('0x15')][_0x5dbf('0x4c')],'Attachments':_0x6ebcc6['body'][_0x5dbf('0x15')]['attachments'],'originTo':_0x6ebcc6[_0x5dbf('0x30')][_0x5dbf('0x15')][_0x5dbf('0x5c')],'originCc':_0x6ebcc6['body'][_0x5dbf('0x15')][_0x5dbf('0x5d')],'bcc':_0x6ebcc6[_0x5dbf('0x30')][_0x5dbf('0x15')]['bcc'],'ChatWebsiteId':_0x6ebcc6[_0x5dbf('0x30')][_0x5dbf('0x15')][_0x5dbf('0x5e')]||null,'originChannel':_0x6ebcc6[_0x5dbf('0x30')][_0x5dbf('0x15')][_0x5dbf('0x5f')]||'Email','ChatOfflineMessageId':_0x6ebcc6[_0x5dbf('0x30')][_0x5dbf('0x15')]['ChatOfflineMessageId']||null},{'include':[{'model':db[_0x5dbf('0x60')],'as':_0x5dbf('0x61')}]});})[_0x5dbf('0x23')](function(_0x3457de){_0x5be96b[_0x5dbf('0x15')]=_0x3457de;if(!_0x5be96b[_0x5dbf('0x58')][_0x5dbf('0x62')]){return;}return db[_0x5dbf('0x63')][_0x5dbf('0x4f')]({'attributes':['id',_0x5dbf('0x64')],'where':{'id':_0x5be96b[_0x5dbf('0x58')][_0x5dbf('0x62')]}});})[_0x5dbf('0x23')](function(_0x248c1d){if(_0x248c1d){_0x5be96b[_0x5dbf('0x3f')][_0x5dbf('0x65')]({'id':0x0,'priority':0x0,'app':'agent','appdata':_0x248c1d[_0x5dbf('0x64')]+','+(_0x5be96b[_0x5dbf('0x3d')][_0x5dbf('0x66')]||0xa),'interval':_0x5dbf('0x47')});}if(!_0x5be96b['interaction'][_0x5dbf('0x67')]){return;}return db[_0x5dbf('0x68')][_0x5dbf('0x4f')]({'attributes':['id',_0x5dbf('0x64')],'where':{'id':_0x5be96b[_0x5dbf('0x58')]['queueId']}});})[_0x5dbf('0x23')](function(_0x1ba14c){if(_0x1ba14c){_0x5be96b['applications']['unshift']({'id':0x0,'priority':0x1,'app':_0x5dbf('0x69'),'appdata':_0x1ba14c[_0x5dbf('0x64')]+','+(_0x5be96b[_0x5dbf('0x3d')][_0x5dbf('0x6a')]||0x12c),'interval':_0x5dbf('0x47')});}return respondWithRpcPromise(_0x5dbf('0x6b'),_0x5dbf('0x6c'),_0x5be96b);})['then'](function(_0x310078){_0x2ed355(_0x310078);})[_0x5dbf('0x18')](function(_0x25c831){_0x4b71c1(_0x321ae3[_0x5dbf('0x13')](0x1f4,_0x25c831[_0x5dbf('0x15')]));});});};
\ No newline at end of file