Built motion from commit 1ea47bf4.|2.6.34
[motion2.git] / server / api / mailAccount / mailAccount.rpc.js
index 5f92d13..7bdf5d7 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x07e8=['Contacts','DESC','MailApplication','Applications','MailServerOut','Smtp','CloudProvider','List','list','applications','orderBy','priority','asc','autoclose','close','*,*,*,*','length','create','List\x20not\x20found','contact','messageId','generate','subject','format','MailInteraction','MailMessage','Messages','Contact\x20not\x20found','spread','update','attach','YYYY-MM-DD\x20HH:mm:ss','interaction','get','attachments','originTo','originCc','ChatWebsiteId','originChannel','Email','Attachment','UserId','unshift','name','queueId','MailQueue','queue','Start','startRouting','lodash','moment','bluebird','ioredis','../../config/logger','jayson/promise','client','http','defaults','redis','localhost','socket.io-emitter','register','request','then','info','MailAccount,\x20%s,\x20%s','request\x20sent','debug','MailAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','GetMailAccount','MailAccount','findAll','raw','options','where','attributes','limit','include','map','model','ShowMailAccount','find','smtp','setDataValue','smtpOptions','getSmtpOptions','NotifyMailAccount','body','mail','keys','CmContact','rawAttributes','createdAt','updatedAt','CompanyId','ListId','isNil','from','from\x20is\x20mandatory','mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20','includes','mapKey','mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','account','CmList'];(function(_0x413feb,_0x10477f){var _0x40ee88=function(_0x32a3f6){while(--_0x32a3f6){_0x413feb['push'](_0x413feb['shift']());}};_0x40ee88(++_0x10477f);}(_0x07e8,0x10f));var _0x807e=function(_0xc5aa42,_0x1bdaa2){_0xc5aa42=_0xc5aa42-0x0;var _0x221d83=_0x07e8[_0xc5aa42];return _0x221d83;};'use strict';var _=require(_0x807e('0x0'));var moment=require(_0x807e('0x1'));var BPromise=require(_0x807e('0x2'));var rs=require('randomstring');var Redis=require(_0x807e('0x3'));var db=require('../../mysqldb')['db'];var logger=require(_0x807e('0x4'))('rpc');var config=require('../../config/environment');var jayson=require(_0x807e('0x5'));var client=jayson[_0x807e('0x6')][_0x807e('0x7')]({'port':0x232c});config['redis']=_[_0x807e('0x8')](config[_0x807e('0x9')],{'host':_0x807e('0xa'),'port':0x18eb});var socket=require(_0x807e('0xb'))(new Redis(config[_0x807e('0x9')]));require('./mailAccount.socket')[_0x807e('0xc')](socket);function respondWithRpcPromise(_0x348133,_0x400374,_0x3c6c7a){return new BPromise(function(_0x1c2fdd,_0x45e953){return client[_0x807e('0xd')](_0x348133,_0x3c6c7a)[_0x807e('0xe')](function(_0x2521da){logger[_0x807e('0xf')](_0x807e('0x10'),_0x400374,_0x807e('0x11'));logger[_0x807e('0x12')](_0x807e('0x13'),_0x400374,'request\x20sent',JSON[_0x807e('0x14')](_0x2521da));if(_0x2521da[_0x807e('0x15')]){if(_0x2521da[_0x807e('0x15')][_0x807e('0x16')]===0x1f4){logger[_0x807e('0x15')](_0x807e('0x10'),_0x400374,_0x2521da[_0x807e('0x15')]['message']);return _0x45e953(_0x2521da['error'][_0x807e('0x17')]);}logger[_0x807e('0x15')](_0x807e('0x10'),_0x400374,_0x2521da[_0x807e('0x15')]['message']);return _0x1c2fdd(_0x2521da[_0x807e('0x15')][_0x807e('0x17')]);}else{logger[_0x807e('0xf')](_0x807e('0x10'),_0x400374,_0x807e('0x11'));_0x1c2fdd(_0x2521da[_0x807e('0x18')]['message']);}})[_0x807e('0x19')](function(_0x57af7a){logger[_0x807e('0x15')](_0x807e('0x10'),_0x400374,_0x57af7a);_0x45e953(_0x57af7a);});});}exports[_0x807e('0x1a')]=function(_0x45d67d){var _0x3fba0b=this;return new Promise(function(_0xad3e35,_0x1e39ef){return db[_0x807e('0x1b')][_0x807e('0x1c')]({'raw':_0x45d67d['options']?_0x45d67d['options'][_0x807e('0x1d')]===undefined?!![]:![]:!![],'where':_0x45d67d[_0x807e('0x1e')]?_0x45d67d[_0x807e('0x1e')][_0x807e('0x1f')]||null:null,'attributes':_0x45d67d[_0x807e('0x1e')]?_0x45d67d[_0x807e('0x1e')][_0x807e('0x20')]||null:null,'limit':_0x45d67d[_0x807e('0x1e')]?_0x45d67d['options'][_0x807e('0x21')]||null:null,'include':_0x45d67d[_0x807e('0x1e')]?_0x45d67d[_0x807e('0x1e')][_0x807e('0x22')]?_[_0x807e('0x23')](_0x45d67d[_0x807e('0x1e')]['include'],function(_0x277560){return{'model':db[_0x277560['model']],'as':_0x277560['as'],'attributes':_0x277560[_0x807e('0x20')],'include':_0x277560[_0x807e('0x22')]?_[_0x807e('0x23')](_0x277560['include'],function(_0x36bb30){return{'model':db[_0x36bb30[_0x807e('0x24')]],'as':_0x36bb30['as'],'attributes':_0x36bb30[_0x807e('0x20')],'include':_0x36bb30[_0x807e('0x22')]?_[_0x807e('0x23')](_0x36bb30[_0x807e('0x22')],function(_0x4cc948){return{'model':db[_0x4cc948[_0x807e('0x24')]],'as':_0x4cc948['as'],'attributes':_0x4cc948['attributes']};}):[]};}):[]};}):[]:[]})[_0x807e('0xe')](function(_0x285e27){logger[_0x807e('0xf')]('GetMailAccount',_0x45d67d);logger[_0x807e('0x12')](_0x807e('0x1a'),_0x45d67d,JSON['stringify'](_0x285e27));_0xad3e35(_0x285e27);})[_0x807e('0x19')](function(_0x11fc8d){logger['error'](_0x807e('0x1a'),_0x11fc8d[_0x807e('0x17')],_0x45d67d);_0x1e39ef(_0x3fba0b[_0x807e('0x15')](0x1f4,_0x11fc8d[_0x807e('0x17')]));});});};exports[_0x807e('0x25')]=function(_0x2a45d8){var _0x493c2a=this;return new Promise(function(_0x50a728,_0xc7c64c){return db[_0x807e('0x1b')][_0x807e('0x26')]({'raw':_0x2a45d8[_0x807e('0x1e')]?_0x2a45d8[_0x807e('0x1e')]['raw']===undefined?!![]:![]:!![],'where':_0x2a45d8['options']?_0x2a45d8[_0x807e('0x1e')][_0x807e('0x1f')]||null:null,'attributes':_0x2a45d8['options']?_0x2a45d8[_0x807e('0x1e')][_0x807e('0x20')]||null:null,'include':_0x2a45d8[_0x807e('0x1e')]?_0x2a45d8[_0x807e('0x1e')][_0x807e('0x22')]?_[_0x807e('0x23')](_0x2a45d8[_0x807e('0x1e')][_0x807e('0x22')],function(_0x1632a7){return{'model':db[_0x1632a7[_0x807e('0x24')]],'as':_0x1632a7['as'],'attributes':_0x1632a7['attributes'],'include':_0x1632a7[_0x807e('0x22')]?_[_0x807e('0x23')](_0x1632a7[_0x807e('0x22')],function(_0x498301){return{'model':db[_0x498301[_0x807e('0x24')]],'as':_0x498301['as'],'attributes':_0x498301[_0x807e('0x20')],'include':_0x498301[_0x807e('0x22')]?_['map'](_0x498301['include'],function(_0x266017){return{'model':db[_0x266017['model']],'as':_0x266017['as'],'attributes':_0x266017['attributes']};}):[]};}):[]};}):[]:[]})[_0x807e('0xe')](function(_0x703909){if(_0x2a45d8[_0x807e('0x1e')][_0x807e('0x27')]===!![])_0x703909[_0x807e('0x28')](_0x807e('0x29'),_0x703909[_0x807e('0x2a')]());logger[_0x807e('0xf')](_0x807e('0x25'),_0x2a45d8);logger['debug']('ShowMailAccount',_0x2a45d8,JSON[_0x807e('0x14')](_0x703909));_0x50a728(_0x703909);})['catch'](function(_0x2e3eb4){logger[_0x807e('0x15')](_0x807e('0x25'),_0x2e3eb4['message'],_0x2a45d8);_0xc7c64c(_0x493c2a[_0x807e('0x15')](0x1f4,_0x2e3eb4[_0x807e('0x17')]));});});};exports[_0x807e('0x2b')]=function(_0x160a5c){var _0x56d88b=this;return new Promise(function(_0x53a3d0,_0x3a8eae){var _0x4da2b5={'body':_0x160a5c[_0x807e('0x2c')],'channel':_0x807e('0x2d')};var _0x47d331=_['difference'](_[_0x807e('0x2e')](db[_0x807e('0x2f')][_0x807e('0x30')]),[_0x807e('0x31'),_0x807e('0x32'),_0x807e('0x33'),_0x807e('0x34')]);var _0x904874=![];if(_0x160a5c[_0x807e('0x2c')]['id']){delete _0x160a5c[_0x807e('0x2c')]['id'];}if(_[_0x807e('0x35')](_0x160a5c[_0x807e('0x2c')][_0x807e('0x36')])){return _0x3a8eae(_0x56d88b['error'](0x1f4,_0x807e('0x37')));}if(_['isNil'](_0x160a5c[_0x807e('0x2c')][_0x807e('0x2c')])||_0x160a5c['body'][_0x807e('0x2c')]===''){return _0x3a8eae(_0x56d88b[_0x807e('0x15')](0x1f4,'body\x20is\x20mandatory\x20and\x20not\x20empty'));}if(_['isNil'](_0x160a5c['body']['mapKey'])){return _0x3a8eae(_0x56d88b[_0x807e('0x15')](0x1f4,_0x807e('0x38')+_0x47d331));}if(!_[_0x807e('0x39')](_0x47d331,_0x160a5c[_0x807e('0x2c')][_0x807e('0x3a')])){return _0x3a8eae(_0x56d88b[_0x807e('0x15')](0x1f4,_0x807e('0x3b')+_0x47d331));}var _0x58185a={};_0x58185a[_0x160a5c['body']['mapKey']]=_0x160a5c[_0x807e('0x2c')][_0x807e('0x36')];return db[_0x807e('0x1b')][_0x807e('0x26')]({'where':{'id':_0x160a5c[_0x807e('0x3c')]['id']},'include':[{'model':db[_0x807e('0x3d')],'as':'List','include':[{'model':db[_0x807e('0x2f')],'as':_0x807e('0x3e'),'where':_0x58185a,'limit':0x1,'order':[[_0x807e('0x32'),_0x807e('0x3f')]]}]},{'model':db[_0x807e('0x40')],'as':_0x807e('0x41')},{'model':db[_0x807e('0x42')],'as':_0x807e('0x43'),'include':[{'model':db[_0x807e('0x44')],'as':_0x807e('0x44')}]}]})[_0x807e('0xe')](function(_0x5b41ac){if(_0x5b41ac&&_0x5b41ac['List']){var _0x2a353f=_0x5b41ac['get']({'plain':!![]});_0x4da2b5['account']=_['omit'](_0x2a353f,['Applications',_0x807e('0x45')]);_0x4da2b5['account'][_0x807e('0x29')]=_0x5b41ac[_0x807e('0x2a')]();_0x4da2b5['applications']=_0x2a353f[_0x807e('0x41')];_0x4da2b5[_0x807e('0x46')]=_0x2a353f[_0x807e('0x45')];_0x4da2b5[_0x807e('0x47')]=_[_0x807e('0x48')](_0x4da2b5[_0x807e('0x47')],[_0x807e('0x49')],[_0x807e('0x4a')]);if(_0x4da2b5[_0x807e('0x3c')]&&_0x4da2b5[_0x807e('0x3c')][_0x807e('0x4b')]){_0x4da2b5[_0x807e('0x47')]['push']({'id':0x0,'priority':_0x4da2b5['applications']['length']+0x1,'app':_0x807e('0x4c'),'appdata':_0x807e('0x4b'),'interval':_0x807e('0x4d')});}if(_0x4da2b5[_0x807e('0x3c')][_0x807e('0x41')]){delete _0x4da2b5[_0x807e('0x3c')][_0x807e('0x41')];}if(_0x4da2b5[_0x807e('0x3c')][_0x807e('0x45')]){delete _0x4da2b5[_0x807e('0x3c')][_0x807e('0x45')];}if(_0x2a353f['List'][_0x807e('0x3e')][_0x807e('0x4e')]){return _0x2a353f[_0x807e('0x45')]['Contacts'][0x0];}var _0x2f585d=_[_0x807e('0x8')](_0x160a5c[_0x807e('0x2c')],{'firstName':_0x160a5c[_0x807e('0x2c')]['from'],'ListId':_0x2a353f['ListId']});_0x2f585d[_0x160a5c[_0x807e('0x2c')]['mapKey']]=_0x160a5c[_0x807e('0x2c')]['from'];return db[_0x807e('0x2f')][_0x807e('0x4f')](_0x2f585d);}else{throw new Error(_0x807e('0x50'));}})[_0x807e('0xe')](function(_0x469c0e){_0x4da2b5[_0x807e('0x51')]=_0x469c0e;if(_0x469c0e){if(!_0x160a5c[_0x807e('0x2c')][_0x807e('0x17')][_0x807e('0x52')]){_0x160a5c[_0x807e('0x2c')][_0x807e('0x17')][_0x807e('0x52')]=rs[_0x807e('0x53')]()+'\x20'+_0x160a5c[_0x807e('0x2c')][_0x807e('0x17')][_0x807e('0x36')];}var _0x1532de={'ContactId':_0x469c0e['id'],'MailAccountId':_0x160a5c['account']['id'],'inReplyTo':_0x160a5c['body'][_0x807e('0x17')][_0x807e('0x52')],'to':_0x160a5c[_0x807e('0x2c')][_0x807e('0x17')][_0x807e('0x36')],'cc':_0x160a5c[_0x807e('0x2c')][_0x807e('0x17')]['cc'],'subject':_0x160a5c[_0x807e('0x2c')][_0x807e('0x17')][_0x807e('0x54')],'attach':_0x160a5c[_0x807e('0x2c')][_0x807e('0x17')]['attach'],'lastMsgAt':moment()[_0x807e('0x55')]('YYYY-MM-DD\x20HH:mm:ss'),'lastMsgDirection':'in'};return db[_0x807e('0x56')][_0x807e('0x26')]({'where':{'closed':![],'MailAccountId':_0x160a5c[_0x807e('0x3c')]['id']},'include':[{'model':db[_0x807e('0x57')],'as':_0x807e('0x58'),'attributes':[_0x807e('0x52')],'where':{'messageId':_0x160a5c['body'][_0x807e('0x17')]['inReplyTo']}}]})[_0x807e('0xe')](function(_0x4b2ab2){if(_0x4b2ab2){return[_0x4b2ab2,![]];}return db[_0x807e('0x56')][_0x807e('0x4f')](_0x1532de)['then'](function(_0x4bc144){return[_0x4bc144,!![]];});});}else{throw new Error(_0x807e('0x59'));}})[_0x807e('0x5a')](function(_0x545cdc,_0x11918b){if(_0x545cdc){_0x904874=_0x11918b;if(!_0x11918b){return _0x545cdc[_0x807e('0x5b')]({'inReplyTo':_0x160a5c[_0x807e('0x2c')][_0x807e('0x17')]['messageId'],'to':_0x160a5c[_0x807e('0x2c')][_0x807e('0x17')][_0x807e('0x36')],'cc':_0x160a5c[_0x807e('0x2c')]['message']['cc'],'subject':_0x160a5c[_0x807e('0x2c')][_0x807e('0x17')][_0x807e('0x54')],'attach':_0x545cdc[_0x807e('0x5c')]?_0x545cdc[_0x807e('0x5c')]:_0x160a5c[_0x807e('0x2c')][_0x807e('0x17')][_0x807e('0x5c')],'substatus':null,'substatusAt':moment()['format'](_0x807e('0x5d')),'lastMsgAt':moment()[_0x807e('0x55')](_0x807e('0x5d')),'lastMsgDirection':'in'});}else{return _0x545cdc;}}})[_0x807e('0xe')](function(_0x4207a3){_0x4da2b5[_0x807e('0x5e')]=_0x4207a3[_0x807e('0x5f')]({'plain':!![]});_0x4da2b5[_0x807e('0x5e')]['created']=_0x904874;return db[_0x807e('0x57')]['create']({'body':_0x160a5c[_0x807e('0x2c')]['body'],'MailAccountId':_0x160a5c['account']['id'],'MailInteractionId':_0x4207a3['id'],'direction':'in','ContactId':_0x4da2b5['contact']['id'],'messageId':_0x160a5c[_0x807e('0x2c')][_0x807e('0x17')]['messageId'],'from':_0x160a5c[_0x807e('0x2c')][_0x807e('0x17')][_0x807e('0x36')],'to':_0x160a5c[_0x807e('0x2c')][_0x807e('0x17')]['to'],'cc':_0x160a5c[_0x807e('0x2c')][_0x807e('0x17')]['cc'],'subject':_0x160a5c['body'][_0x807e('0x17')]['subject'],'attach':_0x160a5c[_0x807e('0x2c')][_0x807e('0x17')][_0x807e('0x5c')],'Attachments':_0x160a5c['body']['message'][_0x807e('0x60')],'originTo':_0x160a5c[_0x807e('0x2c')][_0x807e('0x17')][_0x807e('0x61')],'originCc':_0x160a5c[_0x807e('0x2c')][_0x807e('0x17')][_0x807e('0x62')],'bcc':_0x160a5c[_0x807e('0x2c')][_0x807e('0x17')]['bcc'],'ChatWebsiteId':_0x160a5c[_0x807e('0x2c')][_0x807e('0x17')][_0x807e('0x63')]||null,'originChannel':_0x160a5c[_0x807e('0x2c')][_0x807e('0x17')][_0x807e('0x64')]||_0x807e('0x65'),'ChatOfflineMessageId':_0x160a5c[_0x807e('0x2c')][_0x807e('0x17')]['ChatOfflineMessageId']||null},{'include':[{'model':db[_0x807e('0x66')],'as':'Attachments'}]});})[_0x807e('0xe')](function(_0xd00729){_0x4da2b5[_0x807e('0x17')]=_0xd00729;if(!_0x4da2b5[_0x807e('0x5e')][_0x807e('0x67')]){return;}return db['User'][_0x807e('0x26')]({'attributes':['id','name'],'where':{'id':_0x4da2b5[_0x807e('0x5e')][_0x807e('0x67')]}});})['then'](function(_0x1ddf23){if(_0x1ddf23){_0x4da2b5[_0x807e('0x47')][_0x807e('0x68')]({'id':0x0,'priority':0x0,'app':'agent','appdata':_0x1ddf23[_0x807e('0x69')]+','+(_0x4da2b5[_0x807e('0x3c')]['waitForTheAssignedAgent']||0xa),'interval':_0x807e('0x4d')});}if(!_0x4da2b5[_0x807e('0x5e')][_0x807e('0x6a')]){return;}return db[_0x807e('0x6b')]['find']({'attributes':['id',_0x807e('0x69')],'where':{'id':_0x4da2b5[_0x807e('0x5e')][_0x807e('0x6a')]}});})[_0x807e('0xe')](function(_0x5ee542){if(_0x5ee542){_0x4da2b5[_0x807e('0x47')][_0x807e('0x68')]({'id':0x0,'priority':0x1,'app':_0x807e('0x6c'),'appdata':_0x5ee542[_0x807e('0x69')]+','+(_0x4da2b5['account']['waitForTheAssignedQueue']||0x12c),'interval':_0x807e('0x4d')});}return respondWithRpcPromise(_0x807e('0x6d'),_0x807e('0x6e'),_0x4da2b5);})[_0x807e('0xe')](function(_0x4463b6){_0x53a3d0(_0x4463b6);})[_0x807e('0x19')](function(_0x4e6968){_0x3a8eae(_0x56d88b[_0x807e('0x15')](0x1f4,_0x4e6968['message']));});});};
\ No newline at end of file
+var _0x9fd4=['generate','subject','format','YYYY-MM-DD\x20HH:mm:ss','inReplyTo','create','spread','update','attach','interaction','created','MailMessage','contact','attachments','originChannel','Email','ChatOfflineMessageId','Attachments','UserId','User','unshift','agent','name','waitForTheAssignedAgent','*,*,*,*','queueId','MailQueue','queue','waitForTheAssignedQueue','Start','startRouting','lodash','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','http','redis','defaults','socket.io-emitter','./mailAccount.socket','register','request','then','info','request\x20sent','debug','MailAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','MailAccount,\x20%s,\x20%s','message','result','catch','MailAccount','options','where','attributes','limit','include','map','model','GetMailAccount','ShowMailAccount','find','raw','smtp','setDataValue','smtpOptions','getSmtpOptions','mail','difference','keys','CmContact','rawAttributes','createdAt','updatedAt','ListId','body','isNil','from','from\x20is\x20mandatory','mapKey','includes','mapKey\x20invalid,\x20please\x20use\x20one\x20of\x20these:\x20','account','CmList','Contacts','DESC','MailApplication','MailServerOut','Smtp','CloudProvider','List','get','omit','Applications','applications','list','priority','asc','autoclose','close','length','List\x20not\x20found','messageId'];(function(_0x74c392,_0x29cc28){var _0x306791=function(_0x677d58){while(--_0x677d58){_0x74c392['push'](_0x74c392['shift']());}};_0x306791(++_0x29cc28);}(_0x9fd4,0x16c));var _0x49fd=function(_0x257544,_0x524c55){_0x257544=_0x257544-0x0;var _0x589d7d=_0x9fd4[_0x257544];return _0x589d7d;};'use strict';var _=require(_0x49fd('0x0'));var moment=require(_0x49fd('0x1'));var BPromise=require(_0x49fd('0x2'));var rs=require(_0x49fd('0x3'));var Redis=require(_0x49fd('0x4'));var db=require(_0x49fd('0x5'))['db'];var logger=require(_0x49fd('0x6'))(_0x49fd('0x7'));var config=require(_0x49fd('0x8'));var jayson=require('jayson/promise');var client=jayson['client'][_0x49fd('0x9')]({'port':0x232c});config[_0x49fd('0xa')]=_[_0x49fd('0xb')](config[_0x49fd('0xa')],{'host':'localhost','port':0x18eb});var socket=require(_0x49fd('0xc'))(new Redis(config[_0x49fd('0xa')]));require(_0x49fd('0xd'))[_0x49fd('0xe')](socket);function respondWithRpcPromise(_0x190807,_0x4a1c47,_0x35034c){return new BPromise(function(_0x130c9b,_0x3e1c71){return client[_0x49fd('0xf')](_0x190807,_0x35034c)[_0x49fd('0x10')](function(_0x2c6d77){logger[_0x49fd('0x11')]('MailAccount,\x20%s,\x20%s',_0x4a1c47,_0x49fd('0x12'));logger[_0x49fd('0x13')](_0x49fd('0x14'),_0x4a1c47,_0x49fd('0x12'),JSON[_0x49fd('0x15')](_0x2c6d77));if(_0x2c6d77[_0x49fd('0x16')]){if(_0x2c6d77[_0x49fd('0x16')][_0x49fd('0x17')]===0x1f4){logger[_0x49fd('0x16')](_0x49fd('0x18'),_0x4a1c47,_0x2c6d77[_0x49fd('0x16')][_0x49fd('0x19')]);return _0x3e1c71(_0x2c6d77[_0x49fd('0x16')][_0x49fd('0x19')]);}logger[_0x49fd('0x16')](_0x49fd('0x18'),_0x4a1c47,_0x2c6d77[_0x49fd('0x16')][_0x49fd('0x19')]);return _0x130c9b(_0x2c6d77[_0x49fd('0x16')][_0x49fd('0x19')]);}else{logger[_0x49fd('0x11')](_0x49fd('0x18'),_0x4a1c47,_0x49fd('0x12'));_0x130c9b(_0x2c6d77[_0x49fd('0x1a')][_0x49fd('0x19')]);}})[_0x49fd('0x1b')](function(_0x598793){logger[_0x49fd('0x16')](_0x49fd('0x18'),_0x4a1c47,_0x598793);_0x3e1c71(_0x598793);});});}exports['GetMailAccount']=function(_0x5c323a){var _0x449c9a=this;return new Promise(function(_0x53cbd1,_0x316e7c){return db[_0x49fd('0x1c')]['findAll']({'raw':_0x5c323a[_0x49fd('0x1d')]?_0x5c323a[_0x49fd('0x1d')]['raw']===undefined?!![]:![]:!![],'where':_0x5c323a[_0x49fd('0x1d')]?_0x5c323a[_0x49fd('0x1d')][_0x49fd('0x1e')]||null:null,'attributes':_0x5c323a[_0x49fd('0x1d')]?_0x5c323a[_0x49fd('0x1d')][_0x49fd('0x1f')]||null:null,'limit':_0x5c323a['options']?_0x5c323a[_0x49fd('0x1d')][_0x49fd('0x20')]||null:null,'include':_0x5c323a[_0x49fd('0x1d')]?_0x5c323a['options'][_0x49fd('0x21')]?_[_0x49fd('0x22')](_0x5c323a[_0x49fd('0x1d')]['include'],function(_0x597161){return{'model':db[_0x597161['model']],'as':_0x597161['as'],'attributes':_0x597161[_0x49fd('0x1f')],'include':_0x597161[_0x49fd('0x21')]?_[_0x49fd('0x22')](_0x597161[_0x49fd('0x21')],function(_0x9587b9){return{'model':db[_0x9587b9[_0x49fd('0x23')]],'as':_0x9587b9['as'],'attributes':_0x9587b9[_0x49fd('0x1f')],'include':_0x9587b9[_0x49fd('0x21')]?_['map'](_0x9587b9[_0x49fd('0x21')],function(_0x52b35d){return{'model':db[_0x52b35d[_0x49fd('0x23')]],'as':_0x52b35d['as'],'attributes':_0x52b35d[_0x49fd('0x1f')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x203038){logger[_0x49fd('0x11')](_0x49fd('0x24'),_0x5c323a);logger[_0x49fd('0x13')](_0x49fd('0x24'),_0x5c323a,JSON[_0x49fd('0x15')](_0x203038));_0x53cbd1(_0x203038);})[_0x49fd('0x1b')](function(_0x242203){logger['error'](_0x49fd('0x24'),_0x242203['message'],_0x5c323a);_0x316e7c(_0x449c9a[_0x49fd('0x16')](0x1f4,_0x242203['message']));});});};exports[_0x49fd('0x25')]=function(_0x3c082c){var _0x390788=this;return new Promise(function(_0x492622,_0x50d304){return db['MailAccount'][_0x49fd('0x26')]({'raw':_0x3c082c[_0x49fd('0x1d')]?_0x3c082c['options'][_0x49fd('0x27')]===undefined?!![]:![]:!![],'where':_0x3c082c['options']?_0x3c082c['options'][_0x49fd('0x1e')]||null:null,'attributes':_0x3c082c[_0x49fd('0x1d')]?_0x3c082c[_0x49fd('0x1d')][_0x49fd('0x1f')]||null:null,'include':_0x3c082c[_0x49fd('0x1d')]?_0x3c082c['options']['include']?_[_0x49fd('0x22')](_0x3c082c[_0x49fd('0x1d')][_0x49fd('0x21')],function(_0x28f88f){return{'model':db[_0x28f88f['model']],'as':_0x28f88f['as'],'attributes':_0x28f88f[_0x49fd('0x1f')],'include':_0x28f88f[_0x49fd('0x21')]?_[_0x49fd('0x22')](_0x28f88f[_0x49fd('0x21')],function(_0x4363b5){return{'model':db[_0x4363b5[_0x49fd('0x23')]],'as':_0x4363b5['as'],'attributes':_0x4363b5[_0x49fd('0x1f')],'include':_0x4363b5[_0x49fd('0x21')]?_[_0x49fd('0x22')](_0x4363b5[_0x49fd('0x21')],function(_0x3762c7){return{'model':db[_0x3762c7['model']],'as':_0x3762c7['as'],'attributes':_0x3762c7[_0x49fd('0x1f')]};}):[]};}):[]};}):[]:[]})[_0x49fd('0x10')](function(_0x8dc5b3){if(_0x3c082c[_0x49fd('0x1d')][_0x49fd('0x28')]===!![])_0x8dc5b3[_0x49fd('0x29')](_0x49fd('0x2a'),_0x8dc5b3[_0x49fd('0x2b')]());logger[_0x49fd('0x11')]('ShowMailAccount',_0x3c082c);logger[_0x49fd('0x13')]('ShowMailAccount',_0x3c082c,JSON[_0x49fd('0x15')](_0x8dc5b3));_0x492622(_0x8dc5b3);})[_0x49fd('0x1b')](function(_0x523ddf){logger[_0x49fd('0x16')](_0x49fd('0x25'),_0x523ddf['message'],_0x3c082c);_0x50d304(_0x390788[_0x49fd('0x16')](0x1f4,_0x523ddf['message']));});});};exports['NotifyMailAccount']=function(_0x5f56f8){var _0x10057b=this;return new Promise(function(_0x32982e,_0x36739b){var _0x3f73d3={'body':_0x5f56f8['body'],'channel':_0x49fd('0x2c')};var _0x2c3b7d=_[_0x49fd('0x2d')](_[_0x49fd('0x2e')](db[_0x49fd('0x2f')][_0x49fd('0x30')]),[_0x49fd('0x31'),_0x49fd('0x32'),'CompanyId',_0x49fd('0x33')]);var _0x2c8ab1=![];if(_0x5f56f8['body']['id']){delete _0x5f56f8[_0x49fd('0x34')]['id'];}if(_[_0x49fd('0x35')](_0x5f56f8['body'][_0x49fd('0x36')])){return _0x36739b(_0x10057b['error'](0x1f4,_0x49fd('0x37')));}if(_[_0x49fd('0x35')](_0x5f56f8[_0x49fd('0x34')][_0x49fd('0x34')])||_0x5f56f8['body']['body']===''){return _0x36739b(_0x10057b[_0x49fd('0x16')](0x1f4,'body\x20is\x20mandatory\x20and\x20not\x20empty'));}if(_[_0x49fd('0x35')](_0x5f56f8[_0x49fd('0x34')][_0x49fd('0x38')])){return _0x36739b(_0x10057b[_0x49fd('0x16')](0x1f4,'mapKey\x20is\x20mandatory,\x20please\x20use\x20one\x20of\x20these:\x20'+_0x2c3b7d));}if(!_[_0x49fd('0x39')](_0x2c3b7d,_0x5f56f8[_0x49fd('0x34')][_0x49fd('0x38')])){return _0x36739b(_0x10057b[_0x49fd('0x16')](0x1f4,_0x49fd('0x3a')+_0x2c3b7d));}var _0x30937f={};_0x30937f[_0x5f56f8[_0x49fd('0x34')][_0x49fd('0x38')]]=_0x5f56f8[_0x49fd('0x34')][_0x49fd('0x36')];return db[_0x49fd('0x1c')][_0x49fd('0x26')]({'where':{'id':_0x5f56f8[_0x49fd('0x3b')]['id']},'include':[{'model':db[_0x49fd('0x3c')],'as':'List','include':[{'model':db['CmContact'],'as':_0x49fd('0x3d'),'where':_0x30937f,'limit':0x1,'order':[[_0x49fd('0x32'),_0x49fd('0x3e')]]}]},{'model':db[_0x49fd('0x3f')],'as':'Applications'},{'model':db[_0x49fd('0x40')],'as':_0x49fd('0x41'),'include':[{'model':db['CloudProvider'],'as':_0x49fd('0x42')}]}]})[_0x49fd('0x10')](function(_0xaac56f){if(_0xaac56f&&_0xaac56f[_0x49fd('0x43')]){var _0x1316cb=_0xaac56f[_0x49fd('0x44')]({'plain':!![]});_0x3f73d3[_0x49fd('0x3b')]=_[_0x49fd('0x45')](_0x1316cb,[_0x49fd('0x46'),_0x49fd('0x43')]);_0x3f73d3[_0x49fd('0x3b')]['smtpOptions']=_0xaac56f[_0x49fd('0x2b')]();_0x3f73d3[_0x49fd('0x47')]=_0x1316cb[_0x49fd('0x46')];_0x3f73d3[_0x49fd('0x48')]=_0x1316cb[_0x49fd('0x43')];_0x3f73d3[_0x49fd('0x47')]=_['orderBy'](_0x3f73d3['applications'],[_0x49fd('0x49')],[_0x49fd('0x4a')]);if(_0x3f73d3[_0x49fd('0x3b')]&&_0x3f73d3['account'][_0x49fd('0x4b')]){_0x3f73d3[_0x49fd('0x47')]['push']({'id':0x0,'priority':_0x3f73d3['applications']['length']+0x1,'app':_0x49fd('0x4c'),'appdata':'autoclose','interval':'*,*,*,*'});}if(_0x3f73d3['account'][_0x49fd('0x46')]){delete _0x3f73d3[_0x49fd('0x3b')][_0x49fd('0x46')];}if(_0x3f73d3[_0x49fd('0x3b')][_0x49fd('0x43')]){delete _0x3f73d3[_0x49fd('0x3b')][_0x49fd('0x43')];}if(_0x1316cb[_0x49fd('0x43')][_0x49fd('0x3d')][_0x49fd('0x4d')]){return _0x1316cb['List'][_0x49fd('0x3d')][0x0];}var _0x202a86=_[_0x49fd('0xb')](_0x5f56f8[_0x49fd('0x34')],{'firstName':_0x5f56f8[_0x49fd('0x34')][_0x49fd('0x36')],'ListId':_0x1316cb['ListId']});_0x202a86[_0x5f56f8[_0x49fd('0x34')][_0x49fd('0x38')]]=_0x5f56f8['body']['from'];return db[_0x49fd('0x2f')]['create'](_0x202a86);}else{throw new Error(_0x49fd('0x4e'));}})['then'](function(_0x24b5a3){_0x3f73d3['contact']=_0x24b5a3;if(_0x24b5a3){if(!_0x5f56f8[_0x49fd('0x34')][_0x49fd('0x19')]['messageId']){_0x5f56f8[_0x49fd('0x34')][_0x49fd('0x19')][_0x49fd('0x4f')]=rs[_0x49fd('0x50')]()+'\x20'+_0x5f56f8[_0x49fd('0x34')][_0x49fd('0x19')][_0x49fd('0x36')];}var _0x138dcc={'ContactId':_0x24b5a3['id'],'MailAccountId':_0x5f56f8['account']['id'],'inReplyTo':_0x5f56f8[_0x49fd('0x34')][_0x49fd('0x19')][_0x49fd('0x4f')],'to':_0x5f56f8['body'][_0x49fd('0x19')][_0x49fd('0x36')],'cc':_0x5f56f8[_0x49fd('0x34')][_0x49fd('0x19')]['cc'],'subject':_0x5f56f8[_0x49fd('0x34')][_0x49fd('0x19')][_0x49fd('0x51')],'attach':_0x5f56f8[_0x49fd('0x34')][_0x49fd('0x19')]['attach'],'lastMsgAt':moment()[_0x49fd('0x52')](_0x49fd('0x53')),'lastMsgDirection':'in'};return db['MailInteraction'][_0x49fd('0x26')]({'where':{'closed':![],'MailAccountId':_0x5f56f8[_0x49fd('0x3b')]['id']},'include':[{'model':db['MailMessage'],'as':'Messages','attributes':['messageId'],'where':{'messageId':_0x5f56f8[_0x49fd('0x34')][_0x49fd('0x19')][_0x49fd('0x54')]}}]})[_0x49fd('0x10')](function(_0xb1e0f3){if(_0xb1e0f3){return[_0xb1e0f3,![]];}return db['MailInteraction'][_0x49fd('0x55')](_0x138dcc)['then'](function(_0x418673){return[_0x418673,!![]];});});}else{throw new Error('Contact\x20not\x20found');}})[_0x49fd('0x56')](function(_0x1a8da2,_0x234e2a){if(_0x1a8da2){_0x2c8ab1=_0x234e2a;if(!_0x234e2a){return _0x1a8da2[_0x49fd('0x57')]({'inReplyTo':_0x5f56f8['body'][_0x49fd('0x19')][_0x49fd('0x4f')],'to':_0x5f56f8['body'][_0x49fd('0x19')][_0x49fd('0x36')],'cc':_0x5f56f8[_0x49fd('0x34')]['message']['cc'],'subject':_0x5f56f8[_0x49fd('0x34')][_0x49fd('0x19')][_0x49fd('0x51')],'attach':_0x1a8da2[_0x49fd('0x58')]?_0x1a8da2[_0x49fd('0x58')]:_0x5f56f8[_0x49fd('0x34')]['message']['attach'],'substatus':null,'substatusAt':moment()[_0x49fd('0x52')](_0x49fd('0x53')),'lastMsgAt':moment()[_0x49fd('0x52')](_0x49fd('0x53')),'lastMsgDirection':'in'});}else{return _0x1a8da2;}}})[_0x49fd('0x10')](function(_0xdc81cf){_0x3f73d3[_0x49fd('0x59')]=_0xdc81cf[_0x49fd('0x44')]({'plain':!![]});_0x3f73d3[_0x49fd('0x59')][_0x49fd('0x5a')]=_0x2c8ab1;return db[_0x49fd('0x5b')][_0x49fd('0x55')]({'body':_0x5f56f8[_0x49fd('0x34')]['body'],'MailAccountId':_0x5f56f8[_0x49fd('0x3b')]['id'],'MailInteractionId':_0xdc81cf['id'],'direction':'in','ContactId':_0x3f73d3[_0x49fd('0x5c')]['id'],'messageId':_0x5f56f8[_0x49fd('0x34')]['message']['messageId'],'from':_0x5f56f8[_0x49fd('0x34')][_0x49fd('0x19')][_0x49fd('0x36')],'to':_0x5f56f8['body'][_0x49fd('0x19')]['to'],'cc':_0x5f56f8[_0x49fd('0x34')][_0x49fd('0x19')]['cc'],'subject':_0x5f56f8[_0x49fd('0x34')][_0x49fd('0x19')][_0x49fd('0x51')],'attach':_0x5f56f8[_0x49fd('0x34')]['message']['attach'],'Attachments':_0x5f56f8[_0x49fd('0x34')]['message'][_0x49fd('0x5d')],'originTo':_0x5f56f8['body']['message']['originTo'],'originCc':_0x5f56f8[_0x49fd('0x34')][_0x49fd('0x19')]['originCc'],'bcc':_0x5f56f8[_0x49fd('0x34')][_0x49fd('0x19')]['bcc'],'ChatWebsiteId':_0x5f56f8[_0x49fd('0x34')][_0x49fd('0x19')]['ChatWebsiteId']||null,'originChannel':_0x5f56f8[_0x49fd('0x34')]['message'][_0x49fd('0x5e')]||_0x49fd('0x5f'),'ChatOfflineMessageId':_0x5f56f8['body'][_0x49fd('0x19')][_0x49fd('0x60')]||null},{'include':[{'model':db['Attachment'],'as':_0x49fd('0x61')}]});})[_0x49fd('0x10')](function(_0x2e4f40){_0x3f73d3[_0x49fd('0x19')]=_0x2e4f40;if(!_0x3f73d3[_0x49fd('0x59')][_0x49fd('0x62')]){return;}return db[_0x49fd('0x63')][_0x49fd('0x26')]({'attributes':['id','name'],'where':{'id':_0x3f73d3['interaction'][_0x49fd('0x62')]}});})[_0x49fd('0x10')](function(_0x555a87){if(_0x555a87){_0x3f73d3[_0x49fd('0x47')][_0x49fd('0x64')]({'id':0x0,'priority':0x0,'app':_0x49fd('0x65'),'appdata':_0x555a87[_0x49fd('0x66')]+','+(_0x3f73d3[_0x49fd('0x3b')][_0x49fd('0x67')]||0xa),'interval':_0x49fd('0x68')});}if(!_0x3f73d3['interaction'][_0x49fd('0x69')]){return;}return db[_0x49fd('0x6a')][_0x49fd('0x26')]({'attributes':['id',_0x49fd('0x66')],'where':{'id':_0x3f73d3[_0x49fd('0x59')][_0x49fd('0x69')]}});})[_0x49fd('0x10')](function(_0x545740){if(_0x545740){_0x3f73d3[_0x49fd('0x47')][_0x49fd('0x64')]({'id':0x0,'priority':0x1,'app':_0x49fd('0x6b'),'appdata':_0x545740[_0x49fd('0x66')]+','+(_0x3f73d3[_0x49fd('0x3b')][_0x49fd('0x6c')]||0x12c),'interval':_0x49fd('0x68')});}return respondWithRpcPromise(_0x49fd('0x6d'),_0x49fd('0x6e'),_0x3f73d3);})[_0x49fd('0x10')](function(_0x41342e){_0x32982e(_0x41342e);})[_0x49fd('0x1b')](function(_0x23a779){_0x36739b(_0x10057b[_0x49fd('0x16')](0x1f4,_0x23a779[_0x49fd('0x19')]));});});};
\ No newline at end of file