Built motion from commit (unavailable).|2.5.21
[motion2.git] / server / api / mailAccount / mailAccount.rpc.js
index d87f8a7..40fd11a 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xf527=['MailMessage','Messages','inReplyTo','create','Contact\x20not\x20found','spread','update','attach','YYYY-MM-DD\x20HH:mm:ss','originTo','originCc','bcc','ChatWebsiteId','originChannel','ChatOfflineMessageId','Attachment','Attachments','User','name','agent','waitForTheAssignedAgent','startRouting','Start','lodash','util','moment','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise','client','redis','defaults','localhost','socket.io-emitter','register','then','MailAccount,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code','message','info','result','catch','GetMailAccount','MailAccount','findAll','options','raw','limit','include','map','model','attributes','ShowMailAccount','find','where','NotifyMailAccount','mail','difference','keys','rawAttributes','createdAt','CompanyId','ListId','body','isNil','from','from\x20is\x20mandatory','body\x20is\x20mandatory\x20and\x20not\x20empty','mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','includes','mapKey','account','CmList','List','CmContact','Contacts','updatedAt','DESC','MailApplication','Applications','MailServerOut','get','applications','list','priority','asc','autoclose','length','close','*,*,*,*','List\x20not\x20found','contact','messageId','generate','subject','format'];(function(_0x47e309,_0x1e771a){var _0x2e1900=function(_0x407297){while(--_0x407297){_0x47e309['push'](_0x47e309['shift']());}};_0x2e1900(++_0x1e771a);}(_0xf527,0x7e));var _0x7f52=function(_0x377698,_0x2ca7af){_0x377698=_0x377698-0x0;var _0x32b07d=_0xf527[_0x377698];return _0x32b07d;};'use strict';var _=require(_0x7f52('0x0'));var util=require(_0x7f52('0x1'));var moment=require(_0x7f52('0x2'));var BPromise=require('bluebird');var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x7f52('0x3'));var db=require(_0x7f52('0x4'))['db'];var utils=require(_0x7f52('0x5'));var logger=require(_0x7f52('0x6'))(_0x7f52('0x7'));var config=require('../../config/environment');var jayson=require(_0x7f52('0x8'));var client=jayson[_0x7f52('0x9')]['http']({'port':0x232c});config[_0x7f52('0xa')]=_[_0x7f52('0xb')](config[_0x7f52('0xa')],{'host':_0x7f52('0xc'),'port':0x18eb});var socket=require(_0x7f52('0xd'))(new Redis(config[_0x7f52('0xa')]));require('./mailAccount.socket')[_0x7f52('0xe')](socket);function respondWithRpcPromise(_0xb8f5f8,_0x3af26c,_0x222bce){return new BPromise(function(_0x4220e0,_0x2cd44f){return client['request'](_0xb8f5f8,_0x222bce)[_0x7f52('0xf')](function(_0x4b9bb5){logger['info'](_0x7f52('0x10'),_0x3af26c,_0x7f52('0x11'));logger[_0x7f52('0x12')]('MailAccount,\x20%s,\x20%s,\x20%s',_0x3af26c,'request\x20sent',JSON[_0x7f52('0x13')](_0x4b9bb5));if(_0x4b9bb5[_0x7f52('0x14')]){if(_0x4b9bb5[_0x7f52('0x14')][_0x7f52('0x15')]===0x1f4){logger[_0x7f52('0x14')](_0x7f52('0x10'),_0x3af26c,_0x4b9bb5[_0x7f52('0x14')]['message']);return _0x2cd44f(_0x4b9bb5[_0x7f52('0x14')][_0x7f52('0x16')]);}logger[_0x7f52('0x14')]('MailAccount,\x20%s,\x20%s',_0x3af26c,_0x4b9bb5['error'][_0x7f52('0x16')]);return _0x4220e0(_0x4b9bb5[_0x7f52('0x14')]['message']);}else{logger[_0x7f52('0x17')](_0x7f52('0x10'),_0x3af26c,'request\x20sent');_0x4220e0(_0x4b9bb5[_0x7f52('0x18')][_0x7f52('0x16')]);}})[_0x7f52('0x19')](function(_0x2a99cb){logger[_0x7f52('0x14')](_0x7f52('0x10'),_0x3af26c,_0x2a99cb);_0x2cd44f(_0x2a99cb);});});}exports[_0x7f52('0x1a')]=function(_0x555b8e){var _0x40c365=this;return new Promise(function(_0x448500,_0x28f3d8){return db[_0x7f52('0x1b')][_0x7f52('0x1c')]({'raw':_0x555b8e[_0x7f52('0x1d')]?_0x555b8e['options'][_0x7f52('0x1e')]===undefined?!![]:![]:!![],'where':_0x555b8e['options']?_0x555b8e[_0x7f52('0x1d')]['where']||null:null,'attributes':_0x555b8e[_0x7f52('0x1d')]?_0x555b8e[_0x7f52('0x1d')]['attributes']||null:null,'limit':_0x555b8e['options']?_0x555b8e[_0x7f52('0x1d')][_0x7f52('0x1f')]||null:null,'include':_0x555b8e[_0x7f52('0x1d')]?_0x555b8e[_0x7f52('0x1d')][_0x7f52('0x20')]?_[_0x7f52('0x21')](_0x555b8e[_0x7f52('0x1d')][_0x7f52('0x20')],function(_0x356e45){return{'model':db[_0x356e45[_0x7f52('0x22')]],'as':_0x356e45['as'],'attributes':_0x356e45[_0x7f52('0x23')],'include':_0x356e45[_0x7f52('0x20')]?_[_0x7f52('0x21')](_0x356e45[_0x7f52('0x20')],function(_0x3d3edc){return{'model':db[_0x3d3edc[_0x7f52('0x22')]],'as':_0x3d3edc['as'],'attributes':_0x3d3edc['attributes'],'include':_0x3d3edc[_0x7f52('0x20')]?_['map'](_0x3d3edc['include'],function(_0x5b2ac5){return{'model':db[_0x5b2ac5[_0x7f52('0x22')]],'as':_0x5b2ac5['as'],'attributes':_0x5b2ac5[_0x7f52('0x23')]};}):[]};}):[]};}):[]:[]})[_0x7f52('0xf')](function(_0xd4684c){logger[_0x7f52('0x17')](_0x7f52('0x1a'),_0x555b8e);logger['debug'](_0x7f52('0x1a'),_0x555b8e,JSON['stringify'](_0xd4684c));_0x448500(_0xd4684c);})['catch'](function(_0x33aa38){logger['error'](_0x7f52('0x1a'),_0x33aa38[_0x7f52('0x16')],_0x555b8e);_0x28f3d8(_0x40c365[_0x7f52('0x14')](0x1f4,_0x33aa38[_0x7f52('0x16')]));});});};exports[_0x7f52('0x24')]=function(_0x5482a4){var _0x13e4ed=this;return new Promise(function(_0x57030e,_0x5c8fcf){return db['MailAccount'][_0x7f52('0x25')]({'raw':_0x5482a4[_0x7f52('0x1d')]?_0x5482a4['options'][_0x7f52('0x1e')]===undefined?!![]:![]:!![],'where':_0x5482a4[_0x7f52('0x1d')]?_0x5482a4[_0x7f52('0x1d')][_0x7f52('0x26')]||null:null,'attributes':_0x5482a4[_0x7f52('0x1d')]?_0x5482a4[_0x7f52('0x1d')][_0x7f52('0x23')]||null:null,'include':_0x5482a4[_0x7f52('0x1d')]?_0x5482a4[_0x7f52('0x1d')][_0x7f52('0x20')]?_[_0x7f52('0x21')](_0x5482a4[_0x7f52('0x1d')]['include'],function(_0x44e050){return{'model':db[_0x44e050[_0x7f52('0x22')]],'as':_0x44e050['as'],'attributes':_0x44e050[_0x7f52('0x23')],'include':_0x44e050[_0x7f52('0x20')]?_[_0x7f52('0x21')](_0x44e050[_0x7f52('0x20')],function(_0x177819){return{'model':db[_0x177819[_0x7f52('0x22')]],'as':_0x177819['as'],'attributes':_0x177819[_0x7f52('0x23')],'include':_0x177819[_0x7f52('0x20')]?_[_0x7f52('0x21')](_0x177819[_0x7f52('0x20')],function(_0x2defe2){return{'model':db[_0x2defe2['model']],'as':_0x2defe2['as'],'attributes':_0x2defe2['attributes']};}):[]};}):[]};}):[]:[]})[_0x7f52('0xf')](function(_0x82adef){logger[_0x7f52('0x17')](_0x7f52('0x24'),_0x5482a4);logger[_0x7f52('0x12')](_0x7f52('0x24'),_0x5482a4,JSON[_0x7f52('0x13')](_0x82adef));_0x57030e(_0x82adef);})[_0x7f52('0x19')](function(_0x51d42b){logger[_0x7f52('0x14')](_0x7f52('0x24'),_0x51d42b[_0x7f52('0x16')],_0x5482a4);_0x5c8fcf(_0x13e4ed[_0x7f52('0x14')](0x1f4,_0x51d42b['message']));});});};exports[_0x7f52('0x27')]=function(_0x390010){var _0x583e54=this;return new Promise(function(_0x252b4b,_0x3decfd){var _0x443467={'body':_0x390010['body'],'channel':_0x7f52('0x28')};var _0x473f67=_[_0x7f52('0x29')](_[_0x7f52('0x2a')](db['CmContact'][_0x7f52('0x2b')]),[_0x7f52('0x2c'),'updatedAt',_0x7f52('0x2d'),_0x7f52('0x2e')]);var _0x2e613c=![];if(_0x390010[_0x7f52('0x2f')]['id']){delete _0x390010[_0x7f52('0x2f')]['id'];}if(_[_0x7f52('0x30')](_0x390010[_0x7f52('0x2f')][_0x7f52('0x31')])){return _0x3decfd(_0x583e54[_0x7f52('0x14')](0x1f4,_0x7f52('0x32')));}if(_['isNil'](_0x390010[_0x7f52('0x2f')][_0x7f52('0x2f')])||_0x390010[_0x7f52('0x2f')][_0x7f52('0x2f')]===''){return _0x3decfd(_0x583e54[_0x7f52('0x14')](0x1f4,_0x7f52('0x33')));}if(_[_0x7f52('0x30')](_0x390010[_0x7f52('0x2f')]['mapKey'])){return _0x3decfd(_0x583e54[_0x7f52('0x14')](0x1f4,_0x7f52('0x34')+_0x473f67));}if(!_[_0x7f52('0x35')](_0x473f67,_0x390010['body'][_0x7f52('0x36')])){return _0x3decfd(_0x583e54[_0x7f52('0x14')](0x1f4,'mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20'+_0x473f67));}var _0x9bc2c={};_0x9bc2c[_0x390010[_0x7f52('0x2f')]['mapKey']]=_0x390010[_0x7f52('0x2f')]['from'];return db[_0x7f52('0x1b')]['find']({'where':{'id':_0x390010[_0x7f52('0x37')]['id']},'include':[{'model':db[_0x7f52('0x38')],'as':_0x7f52('0x39'),'include':[{'model':db[_0x7f52('0x3a')],'as':_0x7f52('0x3b'),'where':_0x9bc2c,'limit':0x1,'order':[[_0x7f52('0x3c'),_0x7f52('0x3d')]]}]},{'model':db[_0x7f52('0x3e')],'as':_0x7f52('0x3f')},{'model':db[_0x7f52('0x40')],'as':'Smtp'}]})[_0x7f52('0xf')](function(_0x499066){if(_0x499066&&_0x499066['List']){var _0x540c99=_0x499066[_0x7f52('0x41')]({'plain':!![]});_0x443467[_0x7f52('0x37')]=_['omit'](_0x540c99,['Applications',_0x7f52('0x39')]);_0x443467[_0x7f52('0x42')]=_0x540c99['Applications'];_0x443467[_0x7f52('0x43')]=_0x540c99['List'];_0x443467[_0x7f52('0x42')]=_['orderBy'](_0x443467[_0x7f52('0x42')],[_0x7f52('0x44')],[_0x7f52('0x45')]);if(_0x443467['account']&&_0x443467[_0x7f52('0x37')][_0x7f52('0x46')]){_0x443467[_0x7f52('0x42')]['push']({'id':0x0,'priority':_0x443467[_0x7f52('0x42')][_0x7f52('0x47')]+0x1,'app':_0x7f52('0x48'),'appdata':_0x7f52('0x46'),'interval':_0x7f52('0x49')});}if(_0x443467['account'][_0x7f52('0x3f')]){delete _0x443467['account']['Applications'];}if(_0x443467[_0x7f52('0x37')][_0x7f52('0x39')]){delete _0x443467['account']['List'];}if(_0x540c99[_0x7f52('0x39')][_0x7f52('0x3b')][_0x7f52('0x47')]){return _0x540c99[_0x7f52('0x39')][_0x7f52('0x3b')][0x0];}var _0x465cc3=_[_0x7f52('0xb')](_0x390010[_0x7f52('0x2f')],{'firstName':_0x390010[_0x7f52('0x2f')][_0x7f52('0x31')],'ListId':_0x540c99[_0x7f52('0x2e')]});_0x465cc3[_0x390010['body'][_0x7f52('0x36')]]=_0x390010[_0x7f52('0x2f')][_0x7f52('0x31')];return db[_0x7f52('0x3a')]['create'](_0x465cc3);}else{throw new Error(_0x7f52('0x4a'));}})[_0x7f52('0xf')](function(_0x457ee8){_0x443467[_0x7f52('0x4b')]=_0x457ee8;if(_0x457ee8){if(!_0x390010[_0x7f52('0x2f')]['message'][_0x7f52('0x4c')]){_0x390010[_0x7f52('0x2f')][_0x7f52('0x16')][_0x7f52('0x4c')]=rs[_0x7f52('0x4d')]()+'\x20'+_0x390010[_0x7f52('0x2f')]['message'][_0x7f52('0x31')];}var _0x167cc1={'ContactId':_0x457ee8['id'],'MailAccountId':_0x390010[_0x7f52('0x37')]['id'],'inReplyTo':_0x390010[_0x7f52('0x2f')][_0x7f52('0x16')][_0x7f52('0x4c')],'to':_0x390010['body'][_0x7f52('0x16')]['from'],'cc':_0x390010[_0x7f52('0x2f')][_0x7f52('0x16')]['cc'],'subject':_0x390010[_0x7f52('0x2f')][_0x7f52('0x16')][_0x7f52('0x4e')],'attach':_0x390010[_0x7f52('0x2f')][_0x7f52('0x16')]['attach'],'lastMsgAt':moment()[_0x7f52('0x4f')]('YYYY-MM-DD\x20HH:mm:ss'),'lastMsgDirection':'in'};return db['MailInteraction'][_0x7f52('0x25')]({'where':{'closed':![],'MailAccountId':_0x390010[_0x7f52('0x37')]['id']},'include':[{'model':db[_0x7f52('0x50')],'as':_0x7f52('0x51'),'attributes':[_0x7f52('0x4c')],'where':{'messageId':_0x390010[_0x7f52('0x2f')][_0x7f52('0x16')][_0x7f52('0x52')]}}]})['then'](function(_0xdaa0d){if(_0xdaa0d){return[_0xdaa0d,![]];}return db['MailInteraction'][_0x7f52('0x53')](_0x167cc1)[_0x7f52('0xf')](function(_0x3fb352){return[_0x3fb352,!![]];});});}else{throw new Error(_0x7f52('0x54'));}})[_0x7f52('0x55')](function(_0x326a01,_0x2a9747){if(_0x326a01){_0x2e613c=_0x2a9747;if(!_0x2a9747){return _0x326a01[_0x7f52('0x56')]({'inReplyTo':_0x390010['body'][_0x7f52('0x16')][_0x7f52('0x4c')],'to':_0x390010[_0x7f52('0x2f')]['message']['from'],'cc':_0x390010[_0x7f52('0x2f')][_0x7f52('0x16')]['cc'],'subject':_0x390010[_0x7f52('0x2f')]['message']['subject'],'attach':_0x326a01['attach']?_0x326a01[_0x7f52('0x57')]:_0x390010['body'][_0x7f52('0x16')][_0x7f52('0x57')],'substatus':null,'substatusAt':moment()[_0x7f52('0x4f')]('YYYY-MM-DD\x20HH:mm:ss'),'lastMsgAt':moment()['format'](_0x7f52('0x58')),'lastMsgDirection':'in'});}else{return _0x326a01;}}})[_0x7f52('0xf')](function(_0x4a367b){_0x443467['interaction']=_0x4a367b['get']({'plain':!![]});_0x443467['interaction']['created']=_0x2e613c;return db['MailMessage'][_0x7f52('0x53')]({'body':_0x390010[_0x7f52('0x2f')][_0x7f52('0x2f')],'MailAccountId':_0x390010[_0x7f52('0x37')]['id'],'MailInteractionId':_0x4a367b['id'],'direction':'in','ContactId':_0x443467[_0x7f52('0x4b')]['id'],'messageId':_0x390010[_0x7f52('0x2f')][_0x7f52('0x16')][_0x7f52('0x4c')],'from':_0x390010[_0x7f52('0x2f')][_0x7f52('0x16')][_0x7f52('0x31')],'to':_0x390010[_0x7f52('0x2f')][_0x7f52('0x16')]['to'],'cc':_0x390010[_0x7f52('0x2f')]['message']['cc'],'subject':_0x390010[_0x7f52('0x2f')][_0x7f52('0x16')]['subject'],'attach':_0x390010[_0x7f52('0x2f')][_0x7f52('0x16')]['attach'],'Attachments':_0x390010['body'][_0x7f52('0x16')]['attachments'],'originTo':_0x390010['body'][_0x7f52('0x16')][_0x7f52('0x59')],'originCc':_0x390010[_0x7f52('0x2f')][_0x7f52('0x16')][_0x7f52('0x5a')],'bcc':_0x390010[_0x7f52('0x2f')]['message'][_0x7f52('0x5b')],'ChatWebsiteId':_0x390010['body']['message'][_0x7f52('0x5c')]||null,'originChannel':_0x390010['body'][_0x7f52('0x16')][_0x7f52('0x5d')]||'Email','ChatOfflineMessageId':_0x390010['body'][_0x7f52('0x16')][_0x7f52('0x5e')]||null},{'include':[{'model':db[_0x7f52('0x5f')],'as':_0x7f52('0x60')}]});})[_0x7f52('0xf')](function(_0x47ff44){_0x443467['message']=_0x47ff44;if(_0x443467['interaction']['UserId']){return db[_0x7f52('0x61')]['find']({'attributes':['id',_0x7f52('0x62')],'where':{'id':_0x443467['interaction']['UserId']}})['then'](function(_0x2d7ce6){if(_0x2d7ce6){_0x443467[_0x7f52('0x42')]['unshift']({'id':0x0,'priority':0x0,'app':_0x7f52('0x63'),'appdata':_0x2d7ce6['name']+','+(_0x443467['account'][_0x7f52('0x64')]||0xa),'interval':_0x7f52('0x49')});}return respondWithRpcPromise('Start',_0x7f52('0x65'),_0x443467);});}return respondWithRpcPromise(_0x7f52('0x66'),_0x7f52('0x65'),_0x443467);})[_0x7f52('0xf')](function(_0x41fccf){_0x252b4b(_0x41fccf);})[_0x7f52('0x19')](function(_0x3013ff){_0x3decfd(_0x583e54[_0x7f52('0x14')](0x1f4,_0x3013ff[_0x7f52('0x16')]));});});};
\ No newline at end of file
+var _0x8ce3=['register','request','then','info','MailAccount,\x20%s,\x20%s','request\x20sent','debug','MailAccount,\x20%s,\x20%s,\x20%s','stringify','error','message','result','catch','MailAccount','findAll','options','raw','attributes','limit','include','map','model','GetMailAccount','ShowMailAccount','find','where','NotifyMailAccount','body','mail','difference','rawAttributes','createdAt','updatedAt','CompanyId','ListId','isNil','from\x20is\x20mandatory','body\x20is\x20mandatory\x20and\x20not\x20empty','mapKey','mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','includes','mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','from','CmList','CmContact','DESC','Applications','MailServerOut','List','get','account','list','applications','orderBy','priority','autoclose','push','*,*,*,*','Contacts','length','create','List\x20not\x20found','contact','messageId','generate','attach','format','MailInteraction','MailMessage','Messages','inReplyTo','Contact\x20not\x20found','spread','update','subject','YYYY-MM-DD\x20HH:mm:ss','interaction','created','attachments','originTo','originCc','bcc','Attachment','Attachments','UserId','User','name','waitForTheAssignedAgent','startRouting','Start','lodash','util','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','client','http','defaults','redis','localhost'];(function(_0xa3a40c,_0x531de5){var _0x48e2c4=function(_0x36b005){while(--_0x36b005){_0xa3a40c['push'](_0xa3a40c['shift']());}};_0x48e2c4(++_0x531de5);}(_0x8ce3,0xc3));var _0x38ce=function(_0x4320a7,_0x239a92){_0x4320a7=_0x4320a7-0x0;var _0x3700bf=_0x8ce3[_0x4320a7];return _0x3700bf;};'use strict';var _=require(_0x38ce('0x0'));var util=require(_0x38ce('0x1'));var moment=require('moment');var BPromise=require(_0x38ce('0x2'));var rs=require(_0x38ce('0x3'));var fs=require('fs');var Redis=require(_0x38ce('0x4'));var db=require(_0x38ce('0x5'))['db'];var utils=require(_0x38ce('0x6'));var logger=require(_0x38ce('0x7'))(_0x38ce('0x8'));var config=require(_0x38ce('0x9'));var jayson=require('jayson/promise');var client=jayson[_0x38ce('0xa')][_0x38ce('0xb')]({'port':0x232c});config['redis']=_[_0x38ce('0xc')](config[_0x38ce('0xd')],{'host':_0x38ce('0xe'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x38ce('0xd')]));require('./mailAccount.socket')[_0x38ce('0xf')](socket);function respondWithRpcPromise(_0x4bd97b,_0x133bd5,_0x31c2e1){return new BPromise(function(_0xa9931b,_0x2c0cab){return client[_0x38ce('0x10')](_0x4bd97b,_0x31c2e1)[_0x38ce('0x11')](function(_0x2a9045){logger[_0x38ce('0x12')](_0x38ce('0x13'),_0x133bd5,_0x38ce('0x14'));logger[_0x38ce('0x15')](_0x38ce('0x16'),_0x133bd5,_0x38ce('0x14'),JSON[_0x38ce('0x17')](_0x2a9045));if(_0x2a9045[_0x38ce('0x18')]){if(_0x2a9045[_0x38ce('0x18')]['code']===0x1f4){logger['error'](_0x38ce('0x13'),_0x133bd5,_0x2a9045[_0x38ce('0x18')][_0x38ce('0x19')]);return _0x2c0cab(_0x2a9045['error'][_0x38ce('0x19')]);}logger['error'](_0x38ce('0x13'),_0x133bd5,_0x2a9045[_0x38ce('0x18')]['message']);return _0xa9931b(_0x2a9045[_0x38ce('0x18')][_0x38ce('0x19')]);}else{logger[_0x38ce('0x12')]('MailAccount,\x20%s,\x20%s',_0x133bd5,_0x38ce('0x14'));_0xa9931b(_0x2a9045[_0x38ce('0x1a')][_0x38ce('0x19')]);}})[_0x38ce('0x1b')](function(_0x3166ab){logger[_0x38ce('0x18')](_0x38ce('0x13'),_0x133bd5,_0x3166ab);_0x2c0cab(_0x3166ab);});});}exports['GetMailAccount']=function(_0x2a9447){var _0x34a8c7=this;return new Promise(function(_0x280586,_0x303391){return db[_0x38ce('0x1c')][_0x38ce('0x1d')]({'raw':_0x2a9447[_0x38ce('0x1e')]?_0x2a9447[_0x38ce('0x1e')][_0x38ce('0x1f')]===undefined?!![]:![]:!![],'where':_0x2a9447[_0x38ce('0x1e')]?_0x2a9447[_0x38ce('0x1e')]['where']||null:null,'attributes':_0x2a9447[_0x38ce('0x1e')]?_0x2a9447[_0x38ce('0x1e')][_0x38ce('0x20')]||null:null,'limit':_0x2a9447[_0x38ce('0x1e')]?_0x2a9447['options'][_0x38ce('0x21')]||null:null,'include':_0x2a9447[_0x38ce('0x1e')]?_0x2a9447['options'][_0x38ce('0x22')]?_[_0x38ce('0x23')](_0x2a9447[_0x38ce('0x1e')]['include'],function(_0x4a7e8e){return{'model':db[_0x4a7e8e[_0x38ce('0x24')]],'as':_0x4a7e8e['as'],'attributes':_0x4a7e8e[_0x38ce('0x20')],'include':_0x4a7e8e[_0x38ce('0x22')]?_[_0x38ce('0x23')](_0x4a7e8e[_0x38ce('0x22')],function(_0x2a59fe){return{'model':db[_0x2a59fe[_0x38ce('0x24')]],'as':_0x2a59fe['as'],'attributes':_0x2a59fe[_0x38ce('0x20')],'include':_0x2a59fe[_0x38ce('0x22')]?_[_0x38ce('0x23')](_0x2a59fe[_0x38ce('0x22')],function(_0x381703){return{'model':db[_0x381703['model']],'as':_0x381703['as'],'attributes':_0x381703[_0x38ce('0x20')]};}):[]};}):[]};}):[]:[]})[_0x38ce('0x11')](function(_0x5b4a7a){logger[_0x38ce('0x12')](_0x38ce('0x25'),_0x2a9447);logger['debug'](_0x38ce('0x25'),_0x2a9447,JSON[_0x38ce('0x17')](_0x5b4a7a));_0x280586(_0x5b4a7a);})['catch'](function(_0x28d775){logger['error'](_0x38ce('0x25'),_0x28d775[_0x38ce('0x19')],_0x2a9447);_0x303391(_0x34a8c7[_0x38ce('0x18')](0x1f4,_0x28d775[_0x38ce('0x19')]));});});};exports[_0x38ce('0x26')]=function(_0x23019f){var _0x34262a=this;return new Promise(function(_0x2f5695,_0x4ec0d3){return db['MailAccount'][_0x38ce('0x27')]({'raw':_0x23019f[_0x38ce('0x1e')]?_0x23019f[_0x38ce('0x1e')][_0x38ce('0x1f')]===undefined?!![]:![]:!![],'where':_0x23019f[_0x38ce('0x1e')]?_0x23019f['options'][_0x38ce('0x28')]||null:null,'attributes':_0x23019f[_0x38ce('0x1e')]?_0x23019f[_0x38ce('0x1e')][_0x38ce('0x20')]||null:null,'include':_0x23019f[_0x38ce('0x1e')]?_0x23019f[_0x38ce('0x1e')][_0x38ce('0x22')]?_['map'](_0x23019f[_0x38ce('0x1e')][_0x38ce('0x22')],function(_0x5b8c69){return{'model':db[_0x5b8c69[_0x38ce('0x24')]],'as':_0x5b8c69['as'],'attributes':_0x5b8c69[_0x38ce('0x20')],'include':_0x5b8c69[_0x38ce('0x22')]?_[_0x38ce('0x23')](_0x5b8c69[_0x38ce('0x22')],function(_0x3d6838){return{'model':db[_0x3d6838[_0x38ce('0x24')]],'as':_0x3d6838['as'],'attributes':_0x3d6838[_0x38ce('0x20')],'include':_0x3d6838['include']?_[_0x38ce('0x23')](_0x3d6838[_0x38ce('0x22')],function(_0x2314a2){return{'model':db[_0x2314a2[_0x38ce('0x24')]],'as':_0x2314a2['as'],'attributes':_0x2314a2['attributes']};}):[]};}):[]};}):[]:[]})[_0x38ce('0x11')](function(_0x54a15a){logger[_0x38ce('0x12')](_0x38ce('0x26'),_0x23019f);logger[_0x38ce('0x15')](_0x38ce('0x26'),_0x23019f,JSON[_0x38ce('0x17')](_0x54a15a));_0x2f5695(_0x54a15a);})[_0x38ce('0x1b')](function(_0x4a6d2b){logger[_0x38ce('0x18')]('ShowMailAccount',_0x4a6d2b[_0x38ce('0x19')],_0x23019f);_0x4ec0d3(_0x34262a[_0x38ce('0x18')](0x1f4,_0x4a6d2b[_0x38ce('0x19')]));});});};exports[_0x38ce('0x29')]=function(_0x277e94){var _0x1476e9=this;return new Promise(function(_0x5209ee,_0x14fb63){var _0x1e0574={'body':_0x277e94[_0x38ce('0x2a')],'channel':_0x38ce('0x2b')};var _0xd4bfe9=_[_0x38ce('0x2c')](_['keys'](db['CmContact'][_0x38ce('0x2d')]),[_0x38ce('0x2e'),_0x38ce('0x2f'),_0x38ce('0x30'),_0x38ce('0x31')]);var _0x3966d2=![];if(_0x277e94[_0x38ce('0x2a')]['id']){delete _0x277e94['body']['id'];}if(_[_0x38ce('0x32')](_0x277e94[_0x38ce('0x2a')]['from'])){return _0x14fb63(_0x1476e9[_0x38ce('0x18')](0x1f4,_0x38ce('0x33')));}if(_[_0x38ce('0x32')](_0x277e94['body'][_0x38ce('0x2a')])||_0x277e94[_0x38ce('0x2a')][_0x38ce('0x2a')]===''){return _0x14fb63(_0x1476e9[_0x38ce('0x18')](0x1f4,_0x38ce('0x34')));}if(_[_0x38ce('0x32')](_0x277e94['body'][_0x38ce('0x35')])){return _0x14fb63(_0x1476e9[_0x38ce('0x18')](0x1f4,_0x38ce('0x36')+_0xd4bfe9));}if(!_[_0x38ce('0x37')](_0xd4bfe9,_0x277e94[_0x38ce('0x2a')][_0x38ce('0x35')])){return _0x14fb63(_0x1476e9['error'](0x1f4,_0x38ce('0x38')+_0xd4bfe9));}var _0x1847e5={};_0x1847e5[_0x277e94['body']['mapKey']]=_0x277e94['body'][_0x38ce('0x39')];return db[_0x38ce('0x1c')]['find']({'where':{'id':_0x277e94['account']['id']},'include':[{'model':db[_0x38ce('0x3a')],'as':'List','include':[{'model':db[_0x38ce('0x3b')],'as':'Contacts','where':_0x1847e5,'limit':0x1,'order':[[_0x38ce('0x2f'),_0x38ce('0x3c')]]}]},{'model':db['MailApplication'],'as':_0x38ce('0x3d')},{'model':db[_0x38ce('0x3e')],'as':'Smtp'}]})[_0x38ce('0x11')](function(_0x3bbd00){if(_0x3bbd00&&_0x3bbd00[_0x38ce('0x3f')]){var _0x5ce80e=_0x3bbd00[_0x38ce('0x40')]({'plain':!![]});_0x1e0574[_0x38ce('0x41')]=_['omit'](_0x5ce80e,[_0x38ce('0x3d'),_0x38ce('0x3f')]);_0x1e0574['applications']=_0x5ce80e[_0x38ce('0x3d')];_0x1e0574[_0x38ce('0x42')]=_0x5ce80e[_0x38ce('0x3f')];_0x1e0574[_0x38ce('0x43')]=_[_0x38ce('0x44')](_0x1e0574[_0x38ce('0x43')],[_0x38ce('0x45')],['asc']);if(_0x1e0574[_0x38ce('0x41')]&&_0x1e0574[_0x38ce('0x41')][_0x38ce('0x46')]){_0x1e0574[_0x38ce('0x43')][_0x38ce('0x47')]({'id':0x0,'priority':_0x1e0574[_0x38ce('0x43')]['length']+0x1,'app':'close','appdata':_0x38ce('0x46'),'interval':_0x38ce('0x48')});}if(_0x1e0574[_0x38ce('0x41')][_0x38ce('0x3d')]){delete _0x1e0574[_0x38ce('0x41')][_0x38ce('0x3d')];}if(_0x1e0574['account']['List']){delete _0x1e0574[_0x38ce('0x41')]['List'];}if(_0x5ce80e['List'][_0x38ce('0x49')][_0x38ce('0x4a')]){return _0x5ce80e[_0x38ce('0x3f')][_0x38ce('0x49')][0x0];}var _0xd031c0=_['defaults'](_0x277e94[_0x38ce('0x2a')],{'firstName':_0x277e94[_0x38ce('0x2a')][_0x38ce('0x39')],'ListId':_0x5ce80e[_0x38ce('0x31')]});_0xd031c0[_0x277e94[_0x38ce('0x2a')][_0x38ce('0x35')]]=_0x277e94[_0x38ce('0x2a')][_0x38ce('0x39')];return db[_0x38ce('0x3b')][_0x38ce('0x4b')](_0xd031c0);}else{throw new Error(_0x38ce('0x4c'));}})['then'](function(_0x5d1df1){_0x1e0574[_0x38ce('0x4d')]=_0x5d1df1;if(_0x5d1df1){if(!_0x277e94[_0x38ce('0x2a')][_0x38ce('0x19')][_0x38ce('0x4e')]){_0x277e94['body'][_0x38ce('0x19')][_0x38ce('0x4e')]=rs[_0x38ce('0x4f')]()+'\x20'+_0x277e94[_0x38ce('0x2a')][_0x38ce('0x19')][_0x38ce('0x39')];}var _0x1534ca={'ContactId':_0x5d1df1['id'],'MailAccountId':_0x277e94['account']['id'],'inReplyTo':_0x277e94[_0x38ce('0x2a')][_0x38ce('0x19')]['messageId'],'to':_0x277e94['body'][_0x38ce('0x19')][_0x38ce('0x39')],'cc':_0x277e94[_0x38ce('0x2a')]['message']['cc'],'subject':_0x277e94['body'][_0x38ce('0x19')]['subject'],'attach':_0x277e94[_0x38ce('0x2a')][_0x38ce('0x19')][_0x38ce('0x50')],'lastMsgAt':moment()[_0x38ce('0x51')]('YYYY-MM-DD\x20HH:mm:ss'),'lastMsgDirection':'in','lastMsgBody':_0x277e94[_0x38ce('0x2a')][_0x38ce('0x2a')]};return db[_0x38ce('0x52')]['find']({'where':{'closed':![],'MailAccountId':_0x277e94[_0x38ce('0x41')]['id']},'include':[{'model':db[_0x38ce('0x53')],'as':_0x38ce('0x54'),'attributes':['messageId'],'where':{'messageId':_0x277e94[_0x38ce('0x2a')]['message'][_0x38ce('0x55')]}}]})['then'](function(_0x146999){if(_0x146999){return[_0x146999,![]];}return db[_0x38ce('0x52')][_0x38ce('0x4b')](_0x1534ca)[_0x38ce('0x11')](function(_0x587e62){return[_0x587e62,!![]];});});}else{throw new Error(_0x38ce('0x56'));}})[_0x38ce('0x57')](function(_0x425002,_0x2ff08b){if(_0x425002){_0x3966d2=_0x2ff08b;if(!_0x2ff08b){return _0x425002[_0x38ce('0x58')]({'inReplyTo':_0x277e94[_0x38ce('0x2a')]['message'][_0x38ce('0x4e')],'to':_0x277e94['body'][_0x38ce('0x19')][_0x38ce('0x39')],'cc':_0x277e94[_0x38ce('0x2a')][_0x38ce('0x19')]['cc'],'subject':_0x277e94[_0x38ce('0x2a')][_0x38ce('0x19')][_0x38ce('0x59')],'attach':_0x425002[_0x38ce('0x50')]?_0x425002['attach']:_0x277e94[_0x38ce('0x2a')][_0x38ce('0x19')][_0x38ce('0x50')],'substatus':null,'substatusAt':moment()[_0x38ce('0x51')](_0x38ce('0x5a')),'lastMsgAt':moment()[_0x38ce('0x51')](_0x38ce('0x5a')),'lastMsgDirection':'in','lastMsgBody':_0x277e94[_0x38ce('0x2a')][_0x38ce('0x2a')]});}else{return _0x425002;}}})[_0x38ce('0x11')](function(_0x79b918){_0x1e0574[_0x38ce('0x5b')]=_0x79b918[_0x38ce('0x40')]({'plain':!![]});_0x1e0574[_0x38ce('0x5b')][_0x38ce('0x5c')]=_0x3966d2;return db[_0x38ce('0x53')][_0x38ce('0x4b')]({'body':_0x277e94[_0x38ce('0x2a')][_0x38ce('0x2a')],'MailAccountId':_0x277e94[_0x38ce('0x41')]['id'],'MailInteractionId':_0x79b918['id'],'direction':'in','ContactId':_0x1e0574['contact']['id'],'messageId':_0x277e94[_0x38ce('0x2a')][_0x38ce('0x19')][_0x38ce('0x4e')],'from':_0x277e94['body']['message'][_0x38ce('0x39')],'to':_0x277e94[_0x38ce('0x2a')]['message']['to'],'cc':_0x277e94[_0x38ce('0x2a')][_0x38ce('0x19')]['cc'],'subject':_0x277e94['body']['message'][_0x38ce('0x59')],'attach':_0x277e94[_0x38ce('0x2a')]['message'][_0x38ce('0x50')],'Attachments':_0x277e94[_0x38ce('0x2a')][_0x38ce('0x19')][_0x38ce('0x5d')],'originTo':_0x277e94[_0x38ce('0x2a')][_0x38ce('0x19')][_0x38ce('0x5e')],'originCc':_0x277e94[_0x38ce('0x2a')]['message'][_0x38ce('0x5f')],'bcc':_0x277e94[_0x38ce('0x2a')][_0x38ce('0x19')][_0x38ce('0x60')]},{'include':[{'model':db[_0x38ce('0x61')],'as':_0x38ce('0x62')}]});})[_0x38ce('0x11')](function(_0x595d81){_0x1e0574['message']=_0x595d81;if(_0x1e0574['interaction'][_0x38ce('0x63')]){return db[_0x38ce('0x64')][_0x38ce('0x27')]({'attributes':['id',_0x38ce('0x65')],'where':{'id':_0x1e0574[_0x38ce('0x5b')][_0x38ce('0x63')]}})[_0x38ce('0x11')](function(_0x4b2dfb){if(_0x4b2dfb){_0x1e0574[_0x38ce('0x43')]['unshift']({'id':0x0,'priority':0x0,'app':'agent','appdata':_0x4b2dfb['name']+','+(_0x1e0574[_0x38ce('0x41')][_0x38ce('0x66')]||0xa),'interval':_0x38ce('0x48')});}return respondWithRpcPromise('Start',_0x38ce('0x67'),_0x1e0574);});}return respondWithRpcPromise(_0x38ce('0x68'),_0x38ce('0x67'),_0x1e0574);})[_0x38ce('0x11')](function(_0x32a8e3){_0x5209ee(_0x32a8e3);})['catch'](function(_0x19b414){_0x14fb63(_0x1476e9['error'](0x1f4,_0x19b414[_0x38ce('0x19')]));});});};
\ No newline at end of file