Built motion from commit 4d4d9a88.|2.6.26
[motion2.git] / server / api / mailAccount / mailAccount.rpc.js
index 6839b5a..537d377 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xf006=['agent','waitForTheAssignedAgent','MailQueue','queueId','queue','waitForTheAssignedQueue','Start','startRouting','bluebird','randomstring','../../mysqldb','rpc','client','http','redis','socket.io-emitter','./mailAccount.socket','register','request','then','info','request\x20sent','debug','MailAccount,\x20%s,\x20%s,\x20%s','stringify','error','message','MailAccount,\x20%s,\x20%s','result','catch','GetMailAccount','MailAccount','raw','options','attributes','limit','map','include','model','find','where','setDataValue','getSmtpOptions','ShowMailAccount','NotifyMailAccount','body','mail','difference','rawAttributes','createdAt','updatedAt','CompanyId','isNil','from','from\x20is\x20mandatory','body\x20is\x20mandatory\x20and\x20not\x20empty','includes','mapKey','account','List','CmContact','Contacts','DESC','MailApplication','Applications','MailServerOut','CloudProvider','omit','smtpOptions','applications','orderBy','priority','autoclose','push','length','close','*,*,*,*','defaults','ListId','create','contact','messageId','subject','format','YYYY-MM-DD\x20HH:mm:ss','MailInteraction','Messages','inReplyTo','Contact\x20not\x20found','update','attach','get','interaction','created','MailMessage','attachments','originTo','originCc','bcc','ChatWebsiteId','ChatOfflineMessageId','Attachment','UserId','User','name','unshift'];(function(_0x1070b5,_0x3398bc){var _0x1eee10=function(_0x2bfffe){while(--_0x2bfffe){_0x1070b5['push'](_0x1070b5['shift']());}};_0x1eee10(++_0x3398bc);}(_0xf006,0x146));var _0x6f00=function(_0x40edf5,_0x468936){_0x40edf5=_0x40edf5-0x0;var _0x267c71=_0xf006[_0x40edf5];return _0x267c71;};'use strict';var _=require('lodash');var moment=require('moment');var BPromise=require(_0x6f00('0x0'));var rs=require(_0x6f00('0x1'));var Redis=require('ioredis');var db=require(_0x6f00('0x2'))['db'];var logger=require('../../config/logger')(_0x6f00('0x3'));var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson[_0x6f00('0x4')][_0x6f00('0x5')]({'port':0x232c});config[_0x6f00('0x6')]=_['defaults'](config[_0x6f00('0x6')],{'host':'localhost','port':0x18eb});var socket=require(_0x6f00('0x7'))(new Redis(config[_0x6f00('0x6')]));require(_0x6f00('0x8'))[_0x6f00('0x9')](socket);function respondWithRpcPromise(_0x286d32,_0x3001c6,_0x44b63c){return new BPromise(function(_0x1e0720,_0x2aa181){return client[_0x6f00('0xa')](_0x286d32,_0x44b63c)[_0x6f00('0xb')](function(_0x13b052){logger[_0x6f00('0xc')]('MailAccount,\x20%s,\x20%s',_0x3001c6,_0x6f00('0xd'));logger[_0x6f00('0xe')](_0x6f00('0xf'),_0x3001c6,_0x6f00('0xd'),JSON[_0x6f00('0x10')](_0x13b052));if(_0x13b052['error']){if(_0x13b052[_0x6f00('0x11')]['code']===0x1f4){logger[_0x6f00('0x11')]('MailAccount,\x20%s,\x20%s',_0x3001c6,_0x13b052[_0x6f00('0x11')][_0x6f00('0x12')]);return _0x2aa181(_0x13b052[_0x6f00('0x11')][_0x6f00('0x12')]);}logger[_0x6f00('0x11')](_0x6f00('0x13'),_0x3001c6,_0x13b052[_0x6f00('0x11')][_0x6f00('0x12')]);return _0x1e0720(_0x13b052[_0x6f00('0x11')]['message']);}else{logger[_0x6f00('0xc')]('MailAccount,\x20%s,\x20%s',_0x3001c6,'request\x20sent');_0x1e0720(_0x13b052[_0x6f00('0x14')][_0x6f00('0x12')]);}})[_0x6f00('0x15')](function(_0x340f78){logger[_0x6f00('0x11')](_0x6f00('0x13'),_0x3001c6,_0x340f78);_0x2aa181(_0x340f78);});});}exports[_0x6f00('0x16')]=function(_0x295640){var _0x9844bf=this;return new Promise(function(_0x198cc7,_0x2d807f){return db[_0x6f00('0x17')]['findAll']({'raw':_0x295640['options']?_0x295640['options'][_0x6f00('0x18')]===undefined?!![]:![]:!![],'where':_0x295640[_0x6f00('0x19')]?_0x295640[_0x6f00('0x19')]['where']||null:null,'attributes':_0x295640[_0x6f00('0x19')]?_0x295640[_0x6f00('0x19')][_0x6f00('0x1a')]||null:null,'limit':_0x295640[_0x6f00('0x19')]?_0x295640[_0x6f00('0x19')][_0x6f00('0x1b')]||null:null,'include':_0x295640[_0x6f00('0x19')]?_0x295640[_0x6f00('0x19')]['include']?_[_0x6f00('0x1c')](_0x295640[_0x6f00('0x19')][_0x6f00('0x1d')],function(_0x4d41ef){return{'model':db[_0x4d41ef[_0x6f00('0x1e')]],'as':_0x4d41ef['as'],'attributes':_0x4d41ef['attributes'],'include':_0x4d41ef[_0x6f00('0x1d')]?_['map'](_0x4d41ef[_0x6f00('0x1d')],function(_0x39375d){return{'model':db[_0x39375d[_0x6f00('0x1e')]],'as':_0x39375d['as'],'attributes':_0x39375d[_0x6f00('0x1a')],'include':_0x39375d[_0x6f00('0x1d')]?_['map'](_0x39375d[_0x6f00('0x1d')],function(_0x25cc71){return{'model':db[_0x25cc71[_0x6f00('0x1e')]],'as':_0x25cc71['as'],'attributes':_0x25cc71[_0x6f00('0x1a')]};}):[]};}):[]};}):[]:[]})[_0x6f00('0xb')](function(_0x235a86){logger[_0x6f00('0xc')](_0x6f00('0x16'),_0x295640);logger[_0x6f00('0xe')](_0x6f00('0x16'),_0x295640,JSON[_0x6f00('0x10')](_0x235a86));_0x198cc7(_0x235a86);})[_0x6f00('0x15')](function(_0x29555d){logger[_0x6f00('0x11')]('GetMailAccount',_0x29555d['message'],_0x295640);_0x2d807f(_0x9844bf['error'](0x1f4,_0x29555d['message']));});});};exports['ShowMailAccount']=function(_0x4edc83){var _0xc5ad42=this;return new Promise(function(_0x56338c,_0x3c0e5d){return db[_0x6f00('0x17')][_0x6f00('0x1f')]({'raw':_0x4edc83[_0x6f00('0x19')]?_0x4edc83[_0x6f00('0x19')][_0x6f00('0x18')]===undefined?!![]:![]:!![],'where':_0x4edc83['options']?_0x4edc83[_0x6f00('0x19')][_0x6f00('0x20')]||null:null,'attributes':_0x4edc83[_0x6f00('0x19')]?_0x4edc83[_0x6f00('0x19')][_0x6f00('0x1a')]||null:null,'include':_0x4edc83['options']?_0x4edc83['options']['include']?_[_0x6f00('0x1c')](_0x4edc83[_0x6f00('0x19')][_0x6f00('0x1d')],function(_0x27ebb4){return{'model':db[_0x27ebb4[_0x6f00('0x1e')]],'as':_0x27ebb4['as'],'attributes':_0x27ebb4['attributes'],'include':_0x27ebb4[_0x6f00('0x1d')]?_[_0x6f00('0x1c')](_0x27ebb4[_0x6f00('0x1d')],function(_0x4646dc){return{'model':db[_0x4646dc[_0x6f00('0x1e')]],'as':_0x4646dc['as'],'attributes':_0x4646dc[_0x6f00('0x1a')],'include':_0x4646dc[_0x6f00('0x1d')]?_['map'](_0x4646dc[_0x6f00('0x1d')],function(_0x1dee52){return{'model':db[_0x1dee52[_0x6f00('0x1e')]],'as':_0x1dee52['as'],'attributes':_0x1dee52['attributes']};}):[]};}):[]};}):[]:[]})[_0x6f00('0xb')](function(_0x389ff9){if(_0x4edc83[_0x6f00('0x19')]['smtp']===!![])_0x389ff9[_0x6f00('0x21')]('smtpOptions',_0x389ff9[_0x6f00('0x22')]());logger['info'](_0x6f00('0x23'),_0x4edc83);logger[_0x6f00('0xe')](_0x6f00('0x23'),_0x4edc83,JSON[_0x6f00('0x10')](_0x389ff9));_0x56338c(_0x389ff9);})['catch'](function(_0xcfcc78){logger['error'](_0x6f00('0x23'),_0xcfcc78['message'],_0x4edc83);_0x3c0e5d(_0xc5ad42[_0x6f00('0x11')](0x1f4,_0xcfcc78[_0x6f00('0x12')]));});});};exports[_0x6f00('0x24')]=function(_0x1ed015){var _0x57c72d=this;return new Promise(function(_0x53dc8c,_0x2e745c){var _0x51bfbd={'body':_0x1ed015[_0x6f00('0x25')],'channel':_0x6f00('0x26')};var _0x4a70ea=_[_0x6f00('0x27')](_['keys'](db['CmContact'][_0x6f00('0x28')]),[_0x6f00('0x29'),_0x6f00('0x2a'),_0x6f00('0x2b'),'ListId']);var _0x38ee25=![];if(_0x1ed015[_0x6f00('0x25')]['id']){delete _0x1ed015[_0x6f00('0x25')]['id'];}if(_[_0x6f00('0x2c')](_0x1ed015[_0x6f00('0x25')][_0x6f00('0x2d')])){return _0x2e745c(_0x57c72d['error'](0x1f4,_0x6f00('0x2e')));}if(_[_0x6f00('0x2c')](_0x1ed015[_0x6f00('0x25')][_0x6f00('0x25')])||_0x1ed015[_0x6f00('0x25')][_0x6f00('0x25')]===''){return _0x2e745c(_0x57c72d['error'](0x1f4,_0x6f00('0x2f')));}if(_[_0x6f00('0x2c')](_0x1ed015[_0x6f00('0x25')]['mapKey'])){return _0x2e745c(_0x57c72d[_0x6f00('0x11')](0x1f4,'mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20'+_0x4a70ea));}if(!_[_0x6f00('0x30')](_0x4a70ea,_0x1ed015[_0x6f00('0x25')]['mapKey'])){return _0x2e745c(_0x57c72d[_0x6f00('0x11')](0x1f4,'mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20'+_0x4a70ea));}var _0xadd6d8={};_0xadd6d8[_0x1ed015[_0x6f00('0x25')][_0x6f00('0x31')]]=_0x1ed015[_0x6f00('0x25')]['from'];return db[_0x6f00('0x17')]['find']({'where':{'id':_0x1ed015[_0x6f00('0x32')]['id']},'include':[{'model':db['CmList'],'as':_0x6f00('0x33'),'include':[{'model':db[_0x6f00('0x34')],'as':_0x6f00('0x35'),'where':_0xadd6d8,'limit':0x1,'order':[[_0x6f00('0x2a'),_0x6f00('0x36')]]}]},{'model':db[_0x6f00('0x37')],'as':_0x6f00('0x38')},{'model':db[_0x6f00('0x39')],'as':'Smtp','include':[{'model':db[_0x6f00('0x3a')],'as':'CloudProvider'}]}]})[_0x6f00('0xb')](function(_0x31fb17){if(_0x31fb17&&_0x31fb17[_0x6f00('0x33')]){var _0x5eec08=_0x31fb17['get']({'plain':!![]});_0x51bfbd[_0x6f00('0x32')]=_[_0x6f00('0x3b')](_0x5eec08,['Applications',_0x6f00('0x33')]);_0x51bfbd['account'][_0x6f00('0x3c')]=_0x31fb17['getSmtpOptions']();_0x51bfbd[_0x6f00('0x3d')]=_0x5eec08[_0x6f00('0x38')];_0x51bfbd['list']=_0x5eec08['List'];_0x51bfbd[_0x6f00('0x3d')]=_[_0x6f00('0x3e')](_0x51bfbd['applications'],[_0x6f00('0x3f')],['asc']);if(_0x51bfbd[_0x6f00('0x32')]&&_0x51bfbd[_0x6f00('0x32')][_0x6f00('0x40')]){_0x51bfbd[_0x6f00('0x3d')][_0x6f00('0x41')]({'id':0x0,'priority':_0x51bfbd[_0x6f00('0x3d')][_0x6f00('0x42')]+0x1,'app':_0x6f00('0x43'),'appdata':_0x6f00('0x40'),'interval':_0x6f00('0x44')});}if(_0x51bfbd[_0x6f00('0x32')][_0x6f00('0x38')]){delete _0x51bfbd[_0x6f00('0x32')][_0x6f00('0x38')];}if(_0x51bfbd[_0x6f00('0x32')][_0x6f00('0x33')]){delete _0x51bfbd[_0x6f00('0x32')][_0x6f00('0x33')];}if(_0x5eec08[_0x6f00('0x33')][_0x6f00('0x35')]['length']){return _0x5eec08['List'][_0x6f00('0x35')][0x0];}var _0x5eda94=_[_0x6f00('0x45')](_0x1ed015[_0x6f00('0x25')],{'firstName':_0x1ed015['body'][_0x6f00('0x2d')],'ListId':_0x5eec08[_0x6f00('0x46')]});_0x5eda94[_0x1ed015[_0x6f00('0x25')]['mapKey']]=_0x1ed015[_0x6f00('0x25')]['from'];return db[_0x6f00('0x34')][_0x6f00('0x47')](_0x5eda94);}else{throw new Error('List\x20not\x20found');}})[_0x6f00('0xb')](function(_0x28677d){_0x51bfbd[_0x6f00('0x48')]=_0x28677d;if(_0x28677d){if(!_0x1ed015[_0x6f00('0x25')][_0x6f00('0x12')][_0x6f00('0x49')]){_0x1ed015[_0x6f00('0x25')]['message']['messageId']=rs['generate']()+'\x20'+_0x1ed015['body'][_0x6f00('0x12')][_0x6f00('0x2d')];}var _0x5bbfdb={'ContactId':_0x28677d['id'],'MailAccountId':_0x1ed015['account']['id'],'inReplyTo':_0x1ed015[_0x6f00('0x25')][_0x6f00('0x12')][_0x6f00('0x49')],'to':_0x1ed015[_0x6f00('0x25')]['message'][_0x6f00('0x2d')],'cc':_0x1ed015['body']['message']['cc'],'subject':_0x1ed015[_0x6f00('0x25')][_0x6f00('0x12')][_0x6f00('0x4a')],'attach':_0x1ed015[_0x6f00('0x25')][_0x6f00('0x12')]['attach'],'lastMsgAt':moment()[_0x6f00('0x4b')](_0x6f00('0x4c')),'lastMsgDirection':'in'};return db[_0x6f00('0x4d')][_0x6f00('0x1f')]({'where':{'closed':![],'MailAccountId':_0x1ed015['account']['id']},'include':[{'model':db['MailMessage'],'as':_0x6f00('0x4e'),'attributes':['messageId'],'where':{'messageId':_0x1ed015[_0x6f00('0x25')][_0x6f00('0x12')][_0x6f00('0x4f')]}}]})[_0x6f00('0xb')](function(_0x53e55c){if(_0x53e55c){return[_0x53e55c,![]];}return db['MailInteraction'][_0x6f00('0x47')](_0x5bbfdb)[_0x6f00('0xb')](function(_0x4ff6dc){return[_0x4ff6dc,!![]];});});}else{throw new Error(_0x6f00('0x50'));}})['spread'](function(_0x14554c,_0x37af94){if(_0x14554c){_0x38ee25=_0x37af94;if(!_0x37af94){return _0x14554c[_0x6f00('0x51')]({'inReplyTo':_0x1ed015[_0x6f00('0x25')][_0x6f00('0x12')]['messageId'],'to':_0x1ed015['body']['message'][_0x6f00('0x2d')],'cc':_0x1ed015[_0x6f00('0x25')]['message']['cc'],'subject':_0x1ed015['body'][_0x6f00('0x12')][_0x6f00('0x4a')],'attach':_0x14554c['attach']?_0x14554c['attach']:_0x1ed015[_0x6f00('0x25')][_0x6f00('0x12')][_0x6f00('0x52')],'substatus':null,'substatusAt':moment()[_0x6f00('0x4b')](_0x6f00('0x4c')),'lastMsgAt':moment()[_0x6f00('0x4b')](_0x6f00('0x4c')),'lastMsgDirection':'in'});}else{return _0x14554c;}}})[_0x6f00('0xb')](function(_0x5ee0b6){_0x51bfbd['interaction']=_0x5ee0b6[_0x6f00('0x53')]({'plain':!![]});_0x51bfbd[_0x6f00('0x54')][_0x6f00('0x55')]=_0x38ee25;return db[_0x6f00('0x56')][_0x6f00('0x47')]({'body':_0x1ed015[_0x6f00('0x25')][_0x6f00('0x25')],'MailAccountId':_0x1ed015[_0x6f00('0x32')]['id'],'MailInteractionId':_0x5ee0b6['id'],'direction':'in','ContactId':_0x51bfbd[_0x6f00('0x48')]['id'],'messageId':_0x1ed015[_0x6f00('0x25')][_0x6f00('0x12')][_0x6f00('0x49')],'from':_0x1ed015[_0x6f00('0x25')][_0x6f00('0x12')][_0x6f00('0x2d')],'to':_0x1ed015[_0x6f00('0x25')][_0x6f00('0x12')]['to'],'cc':_0x1ed015['body']['message']['cc'],'subject':_0x1ed015[_0x6f00('0x25')]['message'][_0x6f00('0x4a')],'attach':_0x1ed015[_0x6f00('0x25')][_0x6f00('0x12')][_0x6f00('0x52')],'Attachments':_0x1ed015[_0x6f00('0x25')]['message'][_0x6f00('0x57')],'originTo':_0x1ed015[_0x6f00('0x25')][_0x6f00('0x12')][_0x6f00('0x58')],'originCc':_0x1ed015[_0x6f00('0x25')][_0x6f00('0x12')][_0x6f00('0x59')],'bcc':_0x1ed015[_0x6f00('0x25')][_0x6f00('0x12')][_0x6f00('0x5a')],'ChatWebsiteId':_0x1ed015[_0x6f00('0x25')]['message'][_0x6f00('0x5b')]||null,'originChannel':_0x1ed015[_0x6f00('0x25')][_0x6f00('0x12')]['originChannel']||'Email','ChatOfflineMessageId':_0x1ed015[_0x6f00('0x25')][_0x6f00('0x12')][_0x6f00('0x5c')]||null},{'include':[{'model':db[_0x6f00('0x5d')],'as':'Attachments'}]});})['then'](function(_0x4cb62d){_0x51bfbd['message']=_0x4cb62d;if(!_0x51bfbd[_0x6f00('0x54')][_0x6f00('0x5e')]){return;}return db[_0x6f00('0x5f')][_0x6f00('0x1f')]({'attributes':['id',_0x6f00('0x60')],'where':{'id':_0x51bfbd['interaction'][_0x6f00('0x5e')]}});})[_0x6f00('0xb')](function(_0x538143){if(_0x538143){_0x51bfbd[_0x6f00('0x3d')][_0x6f00('0x61')]({'id':0x0,'priority':0x0,'app':_0x6f00('0x62'),'appdata':_0x538143[_0x6f00('0x60')]+','+(_0x51bfbd[_0x6f00('0x32')][_0x6f00('0x63')]||0xa),'interval':_0x6f00('0x44')});}if(!_0x51bfbd[_0x6f00('0x54')]['queueId']){return;}return db[_0x6f00('0x64')]['find']({'attributes':['id',_0x6f00('0x60')],'where':{'id':_0x51bfbd[_0x6f00('0x54')][_0x6f00('0x65')]}});})[_0x6f00('0xb')](function(_0x1ad295){if(_0x1ad295){_0x51bfbd[_0x6f00('0x3d')][_0x6f00('0x61')]({'id':0x0,'priority':0x1,'app':_0x6f00('0x66'),'appdata':_0x1ad295[_0x6f00('0x60')]+','+(_0x51bfbd[_0x6f00('0x32')][_0x6f00('0x67')]||0x12c),'interval':_0x6f00('0x44')});}return respondWithRpcPromise(_0x6f00('0x68'),_0x6f00('0x69'),_0x51bfbd);})['then'](function(_0x3ba021){_0x53dc8c(_0x3ba021);})[_0x6f00('0x15')](function(_0x1be439){_0x2e745c(_0x57c72d['error'](0x1f4,_0x1be439[_0x6f00('0x12')]));});});};
\ No newline at end of file
+var _0xf767=['MailQueue','queue','waitForTheAssignedQueue','Start','startRouting','moment','bluebird','randomstring','ioredis','../../mysqldb','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','GetMailAccount','MailAccount','options','where','limit','map','model','attributes','include','debug','ShowMailAccount','find','raw','smtp','setDataValue','getSmtpOptions','catch','NotifyMailAccount','body','mail','difference','keys','CmContact','rawAttributes','createdAt','updatedAt','CompanyId','ListId','isNil','from','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','account','List','Contacts','MailApplication','Applications','MailServerOut','Smtp','CloudProvider','get','omit','smtpOptions','applications','list','orderBy','priority','autoclose','push','close','*,*,*,*','length','create','contact','messageId','generate','format','YYYY-MM-DD\x20HH:mm:ss','MailInteraction','MailMessage','spread','update','subject','attach','interaction','created','originTo','originCc','bcc','ChatWebsiteId','originChannel','Email','ChatOfflineMessageId','Attachment','Attachments','UserId','unshift','name','queueId'];(function(_0x46b057,_0x25aa56){var _0x25cf84=function(_0x324ba6){while(--_0x324ba6){_0x46b057['push'](_0x46b057['shift']());}};_0x25cf84(++_0x25aa56);}(_0xf767,0x76));var _0x7f76=function(_0x8de54f,_0x271987){_0x8de54f=_0x8de54f-0x0;var _0x14cba4=_0xf767[_0x8de54f];return _0x14cba4;};'use strict';var _=require('lodash');var moment=require(_0x7f76('0x0'));var BPromise=require(_0x7f76('0x1'));var rs=require(_0x7f76('0x2'));var Redis=require(_0x7f76('0x3'));var db=require(_0x7f76('0x4'))['db'];var logger=require('../../config/logger')(_0x7f76('0x5'));var config=require(_0x7f76('0x6'));var jayson=require(_0x7f76('0x7'));var client=jayson[_0x7f76('0x8')]['http']({'port':0x232c});config[_0x7f76('0x9')]=_[_0x7f76('0xa')](config[_0x7f76('0x9')],{'host':_0x7f76('0xb'),'port':0x18eb});var socket=require(_0x7f76('0xc'))(new Redis(config['redis']));require(_0x7f76('0xd'))[_0x7f76('0xe')](socket);function respondWithRpcPromise(_0x35d28d,_0x15dcd9,_0x4c5f88){return new BPromise(function(_0x247403,_0x5dc8aa){return client[_0x7f76('0xf')](_0x35d28d,_0x4c5f88)[_0x7f76('0x10')](function(_0x4dbc83){logger[_0x7f76('0x11')](_0x7f76('0x12'),_0x15dcd9,_0x7f76('0x13'));logger['debug'](_0x7f76('0x14'),_0x15dcd9,_0x7f76('0x13'),JSON[_0x7f76('0x15')](_0x4dbc83));if(_0x4dbc83[_0x7f76('0x16')]){if(_0x4dbc83[_0x7f76('0x16')]['code']===0x1f4){logger[_0x7f76('0x16')]('MailAccount,\x20%s,\x20%s',_0x15dcd9,_0x4dbc83[_0x7f76('0x16')][_0x7f76('0x17')]);return _0x5dc8aa(_0x4dbc83['error']['message']);}logger['error'](_0x7f76('0x12'),_0x15dcd9,_0x4dbc83[_0x7f76('0x16')][_0x7f76('0x17')]);return _0x247403(_0x4dbc83['error'][_0x7f76('0x17')]);}else{logger['info'](_0x7f76('0x12'),_0x15dcd9,_0x7f76('0x13'));_0x247403(_0x4dbc83[_0x7f76('0x18')]['message']);}})['catch'](function(_0x494537){logger['error']('MailAccount,\x20%s,\x20%s',_0x15dcd9,_0x494537);_0x5dc8aa(_0x494537);});});}exports[_0x7f76('0x19')]=function(_0xdb1407){var _0x2b2e32=this;return new Promise(function(_0x21c2ca,_0x54610a){return db[_0x7f76('0x1a')]['findAll']({'raw':_0xdb1407[_0x7f76('0x1b')]?_0xdb1407[_0x7f76('0x1b')]['raw']===undefined?!![]:![]:!![],'where':_0xdb1407['options']?_0xdb1407[_0x7f76('0x1b')][_0x7f76('0x1c')]||null:null,'attributes':_0xdb1407['options']?_0xdb1407[_0x7f76('0x1b')]['attributes']||null:null,'limit':_0xdb1407[_0x7f76('0x1b')]?_0xdb1407[_0x7f76('0x1b')][_0x7f76('0x1d')]||null:null,'include':_0xdb1407[_0x7f76('0x1b')]?_0xdb1407[_0x7f76('0x1b')]['include']?_[_0x7f76('0x1e')](_0xdb1407['options']['include'],function(_0x197519){return{'model':db[_0x197519[_0x7f76('0x1f')]],'as':_0x197519['as'],'attributes':_0x197519[_0x7f76('0x20')],'include':_0x197519['include']?_[_0x7f76('0x1e')](_0x197519[_0x7f76('0x21')],function(_0x3e624d){return{'model':db[_0x3e624d[_0x7f76('0x1f')]],'as':_0x3e624d['as'],'attributes':_0x3e624d[_0x7f76('0x20')],'include':_0x3e624d['include']?_[_0x7f76('0x1e')](_0x3e624d[_0x7f76('0x21')],function(_0x523d7a){return{'model':db[_0x523d7a['model']],'as':_0x523d7a['as'],'attributes':_0x523d7a[_0x7f76('0x20')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x1dd664){logger[_0x7f76('0x11')](_0x7f76('0x19'),_0xdb1407);logger[_0x7f76('0x22')](_0x7f76('0x19'),_0xdb1407,JSON[_0x7f76('0x15')](_0x1dd664));_0x21c2ca(_0x1dd664);})['catch'](function(_0x3570ec){logger[_0x7f76('0x16')](_0x7f76('0x19'),_0x3570ec[_0x7f76('0x17')],_0xdb1407);_0x54610a(_0x2b2e32['error'](0x1f4,_0x3570ec[_0x7f76('0x17')]));});});};exports[_0x7f76('0x23')]=function(_0x3aacba){var _0x4d7a2f=this;return new Promise(function(_0x208ced,_0x419dad){return db[_0x7f76('0x1a')][_0x7f76('0x24')]({'raw':_0x3aacba[_0x7f76('0x1b')]?_0x3aacba[_0x7f76('0x1b')][_0x7f76('0x25')]===undefined?!![]:![]:!![],'where':_0x3aacba[_0x7f76('0x1b')]?_0x3aacba[_0x7f76('0x1b')][_0x7f76('0x1c')]||null:null,'attributes':_0x3aacba[_0x7f76('0x1b')]?_0x3aacba[_0x7f76('0x1b')][_0x7f76('0x20')]||null:null,'include':_0x3aacba['options']?_0x3aacba[_0x7f76('0x1b')][_0x7f76('0x21')]?_[_0x7f76('0x1e')](_0x3aacba[_0x7f76('0x1b')][_0x7f76('0x21')],function(_0x20c260){return{'model':db[_0x20c260[_0x7f76('0x1f')]],'as':_0x20c260['as'],'attributes':_0x20c260[_0x7f76('0x20')],'include':_0x20c260['include']?_[_0x7f76('0x1e')](_0x20c260['include'],function(_0x5e9a68){return{'model':db[_0x5e9a68[_0x7f76('0x1f')]],'as':_0x5e9a68['as'],'attributes':_0x5e9a68['attributes'],'include':_0x5e9a68[_0x7f76('0x21')]?_[_0x7f76('0x1e')](_0x5e9a68['include'],function(_0x3dbcc3){return{'model':db[_0x3dbcc3['model']],'as':_0x3dbcc3['as'],'attributes':_0x3dbcc3['attributes']};}):[]};}):[]};}):[]:[]})[_0x7f76('0x10')](function(_0x205223){if(_0x3aacba[_0x7f76('0x1b')][_0x7f76('0x26')]===!![])_0x205223[_0x7f76('0x27')]('smtpOptions',_0x205223[_0x7f76('0x28')]());logger[_0x7f76('0x11')]('ShowMailAccount',_0x3aacba);logger['debug'](_0x7f76('0x23'),_0x3aacba,JSON['stringify'](_0x205223));_0x208ced(_0x205223);})[_0x7f76('0x29')](function(_0x17dfb3){logger[_0x7f76('0x16')]('ShowMailAccount',_0x17dfb3[_0x7f76('0x17')],_0x3aacba);_0x419dad(_0x4d7a2f[_0x7f76('0x16')](0x1f4,_0x17dfb3[_0x7f76('0x17')]));});});};exports[_0x7f76('0x2a')]=function(_0x1ed18a){var _0x438de8=this;return new Promise(function(_0x58649f,_0x518ced){var _0x218370={'body':_0x1ed18a[_0x7f76('0x2b')],'channel':_0x7f76('0x2c')};var _0x331f75=_[_0x7f76('0x2d')](_[_0x7f76('0x2e')](db[_0x7f76('0x2f')][_0x7f76('0x30')]),[_0x7f76('0x31'),_0x7f76('0x32'),_0x7f76('0x33'),_0x7f76('0x34')]);var _0x3229b9=![];if(_0x1ed18a[_0x7f76('0x2b')]['id']){delete _0x1ed18a[_0x7f76('0x2b')]['id'];}if(_[_0x7f76('0x35')](_0x1ed18a[_0x7f76('0x2b')][_0x7f76('0x36')])){return _0x518ced(_0x438de8['error'](0x1f4,_0x7f76('0x37')));}if(_[_0x7f76('0x35')](_0x1ed18a[_0x7f76('0x2b')]['body'])||_0x1ed18a['body'][_0x7f76('0x2b')]===''){return _0x518ced(_0x438de8['error'](0x1f4,_0x7f76('0x38')));}if(_['isNil'](_0x1ed18a['body'][_0x7f76('0x39')])){return _0x518ced(_0x438de8[_0x7f76('0x16')](0x1f4,_0x7f76('0x3a')+_0x331f75));}if(!_[_0x7f76('0x3b')](_0x331f75,_0x1ed18a[_0x7f76('0x2b')][_0x7f76('0x39')])){return _0x518ced(_0x438de8[_0x7f76('0x16')](0x1f4,_0x7f76('0x3c')+_0x331f75));}var _0x71f722={};_0x71f722[_0x1ed18a[_0x7f76('0x2b')][_0x7f76('0x39')]]=_0x1ed18a[_0x7f76('0x2b')][_0x7f76('0x36')];return db[_0x7f76('0x1a')]['find']({'where':{'id':_0x1ed18a[_0x7f76('0x3d')]['id']},'include':[{'model':db['CmList'],'as':_0x7f76('0x3e'),'include':[{'model':db[_0x7f76('0x2f')],'as':_0x7f76('0x3f'),'where':_0x71f722,'limit':0x1,'order':[[_0x7f76('0x32'),'DESC']]}]},{'model':db[_0x7f76('0x40')],'as':_0x7f76('0x41')},{'model':db[_0x7f76('0x42')],'as':_0x7f76('0x43'),'include':[{'model':db['CloudProvider'],'as':_0x7f76('0x44')}]}]})[_0x7f76('0x10')](function(_0x53f77a){if(_0x53f77a&&_0x53f77a[_0x7f76('0x3e')]){var _0x364fea=_0x53f77a[_0x7f76('0x45')]({'plain':!![]});_0x218370['account']=_[_0x7f76('0x46')](_0x364fea,[_0x7f76('0x41'),_0x7f76('0x3e')]);_0x218370[_0x7f76('0x3d')][_0x7f76('0x47')]=_0x53f77a[_0x7f76('0x28')]();_0x218370[_0x7f76('0x48')]=_0x364fea[_0x7f76('0x41')];_0x218370[_0x7f76('0x49')]=_0x364fea[_0x7f76('0x3e')];_0x218370[_0x7f76('0x48')]=_[_0x7f76('0x4a')](_0x218370['applications'],[_0x7f76('0x4b')],['asc']);if(_0x218370[_0x7f76('0x3d')]&&_0x218370[_0x7f76('0x3d')][_0x7f76('0x4c')]){_0x218370['applications'][_0x7f76('0x4d')]({'id':0x0,'priority':_0x218370[_0x7f76('0x48')]['length']+0x1,'app':_0x7f76('0x4e'),'appdata':_0x7f76('0x4c'),'interval':_0x7f76('0x4f')});}if(_0x218370[_0x7f76('0x3d')][_0x7f76('0x41')]){delete _0x218370[_0x7f76('0x3d')][_0x7f76('0x41')];}if(_0x218370[_0x7f76('0x3d')][_0x7f76('0x3e')]){delete _0x218370['account']['List'];}if(_0x364fea[_0x7f76('0x3e')][_0x7f76('0x3f')][_0x7f76('0x50')]){return _0x364fea[_0x7f76('0x3e')][_0x7f76('0x3f')][0x0];}var _0x33b0ae=_[_0x7f76('0xa')](_0x1ed18a[_0x7f76('0x2b')],{'firstName':_0x1ed18a[_0x7f76('0x2b')]['from'],'ListId':_0x364fea[_0x7f76('0x34')]});_0x33b0ae[_0x1ed18a[_0x7f76('0x2b')][_0x7f76('0x39')]]=_0x1ed18a[_0x7f76('0x2b')][_0x7f76('0x36')];return db[_0x7f76('0x2f')][_0x7f76('0x51')](_0x33b0ae);}else{throw new Error('List\x20not\x20found');}})[_0x7f76('0x10')](function(_0x52b523){_0x218370[_0x7f76('0x52')]=_0x52b523;if(_0x52b523){if(!_0x1ed18a[_0x7f76('0x2b')][_0x7f76('0x17')][_0x7f76('0x53')]){_0x1ed18a[_0x7f76('0x2b')][_0x7f76('0x17')][_0x7f76('0x53')]=rs[_0x7f76('0x54')]()+'\x20'+_0x1ed18a['body']['message'][_0x7f76('0x36')];}var _0x4529b0={'ContactId':_0x52b523['id'],'MailAccountId':_0x1ed18a[_0x7f76('0x3d')]['id'],'inReplyTo':_0x1ed18a[_0x7f76('0x2b')][_0x7f76('0x17')][_0x7f76('0x53')],'to':_0x1ed18a[_0x7f76('0x2b')][_0x7f76('0x17')]['from'],'cc':_0x1ed18a['body'][_0x7f76('0x17')]['cc'],'subject':_0x1ed18a[_0x7f76('0x2b')][_0x7f76('0x17')]['subject'],'attach':_0x1ed18a[_0x7f76('0x2b')][_0x7f76('0x17')]['attach'],'lastMsgAt':moment()[_0x7f76('0x55')](_0x7f76('0x56')),'lastMsgDirection':'in'};return db[_0x7f76('0x57')][_0x7f76('0x24')]({'where':{'closed':![],'MailAccountId':_0x1ed18a[_0x7f76('0x3d')]['id']},'include':[{'model':db[_0x7f76('0x58')],'as':'Messages','attributes':[_0x7f76('0x53')],'where':{'messageId':_0x1ed18a['body'][_0x7f76('0x17')]['inReplyTo']}}]})[_0x7f76('0x10')](function(_0x5f3db2){if(_0x5f3db2){return[_0x5f3db2,![]];}return db[_0x7f76('0x57')][_0x7f76('0x51')](_0x4529b0)[_0x7f76('0x10')](function(_0x3e83d2){return[_0x3e83d2,!![]];});});}else{throw new Error('Contact\x20not\x20found');}})[_0x7f76('0x59')](function(_0x20264e,_0x46b15b){if(_0x20264e){_0x3229b9=_0x46b15b;if(!_0x46b15b){return _0x20264e[_0x7f76('0x5a')]({'inReplyTo':_0x1ed18a[_0x7f76('0x2b')]['message'][_0x7f76('0x53')],'to':_0x1ed18a['body'][_0x7f76('0x17')]['from'],'cc':_0x1ed18a[_0x7f76('0x2b')][_0x7f76('0x17')]['cc'],'subject':_0x1ed18a['body'][_0x7f76('0x17')][_0x7f76('0x5b')],'attach':_0x20264e[_0x7f76('0x5c')]?_0x20264e[_0x7f76('0x5c')]:_0x1ed18a[_0x7f76('0x2b')][_0x7f76('0x17')][_0x7f76('0x5c')],'substatus':null,'substatusAt':moment()[_0x7f76('0x55')](_0x7f76('0x56')),'lastMsgAt':moment()[_0x7f76('0x55')](_0x7f76('0x56')),'lastMsgDirection':'in'});}else{return _0x20264e;}}})[_0x7f76('0x10')](function(_0xb0be79){_0x218370[_0x7f76('0x5d')]=_0xb0be79['get']({'plain':!![]});_0x218370[_0x7f76('0x5d')][_0x7f76('0x5e')]=_0x3229b9;return db['MailMessage'][_0x7f76('0x51')]({'body':_0x1ed18a[_0x7f76('0x2b')][_0x7f76('0x2b')],'MailAccountId':_0x1ed18a[_0x7f76('0x3d')]['id'],'MailInteractionId':_0xb0be79['id'],'direction':'in','ContactId':_0x218370[_0x7f76('0x52')]['id'],'messageId':_0x1ed18a[_0x7f76('0x2b')][_0x7f76('0x17')][_0x7f76('0x53')],'from':_0x1ed18a[_0x7f76('0x2b')][_0x7f76('0x17')][_0x7f76('0x36')],'to':_0x1ed18a[_0x7f76('0x2b')][_0x7f76('0x17')]['to'],'cc':_0x1ed18a[_0x7f76('0x2b')]['message']['cc'],'subject':_0x1ed18a[_0x7f76('0x2b')][_0x7f76('0x17')]['subject'],'attach':_0x1ed18a['body']['message'][_0x7f76('0x5c')],'Attachments':_0x1ed18a[_0x7f76('0x2b')][_0x7f76('0x17')]['attachments'],'originTo':_0x1ed18a[_0x7f76('0x2b')][_0x7f76('0x17')][_0x7f76('0x5f')],'originCc':_0x1ed18a[_0x7f76('0x2b')][_0x7f76('0x17')][_0x7f76('0x60')],'bcc':_0x1ed18a[_0x7f76('0x2b')][_0x7f76('0x17')][_0x7f76('0x61')],'ChatWebsiteId':_0x1ed18a['body'][_0x7f76('0x17')][_0x7f76('0x62')]||null,'originChannel':_0x1ed18a[_0x7f76('0x2b')][_0x7f76('0x17')][_0x7f76('0x63')]||_0x7f76('0x64'),'ChatOfflineMessageId':_0x1ed18a[_0x7f76('0x2b')]['message'][_0x7f76('0x65')]||null},{'include':[{'model':db[_0x7f76('0x66')],'as':_0x7f76('0x67')}]});})[_0x7f76('0x10')](function(_0x43d856){_0x218370['message']=_0x43d856;if(!_0x218370[_0x7f76('0x5d')][_0x7f76('0x68')]){return;}return db['User']['find']({'attributes':['id','name'],'where':{'id':_0x218370[_0x7f76('0x5d')][_0x7f76('0x68')]}});})[_0x7f76('0x10')](function(_0x8d6dec){if(_0x8d6dec){_0x218370[_0x7f76('0x48')][_0x7f76('0x69')]({'id':0x0,'priority':0x0,'app':'agent','appdata':_0x8d6dec[_0x7f76('0x6a')]+','+(_0x218370[_0x7f76('0x3d')]['waitForTheAssignedAgent']||0xa),'interval':_0x7f76('0x4f')});}if(!_0x218370[_0x7f76('0x5d')][_0x7f76('0x6b')]){return;}return db[_0x7f76('0x6c')][_0x7f76('0x24')]({'attributes':['id',_0x7f76('0x6a')],'where':{'id':_0x218370[_0x7f76('0x5d')]['queueId']}});})[_0x7f76('0x10')](function(_0x428865){if(_0x428865){_0x218370['applications'][_0x7f76('0x69')]({'id':0x0,'priority':0x1,'app':_0x7f76('0x6d'),'appdata':_0x428865['name']+','+(_0x218370[_0x7f76('0x3d')][_0x7f76('0x6e')]||0x12c),'interval':_0x7f76('0x4f')});}return respondWithRpcPromise(_0x7f76('0x6f'),_0x7f76('0x70'),_0x218370);})[_0x7f76('0x10')](function(_0x37afb1){_0x58649f(_0x37afb1);})[_0x7f76('0x29')](function(_0x95d3a8){_0x518ced(_0x438de8[_0x7f76('0x16')](0x1f4,_0x95d3a8[_0x7f76('0x17')]));});});};
\ No newline at end of file