Built motion from commit df3e9871f6bcc3432fec345b2f4facbd4dba8b5c. Version 3.0.0...
[motion-next.git] / server / api / mailMessage / mailMessage.controller.js
index d13827a..d0386c7 100644 (file)
@@ -1 +1 @@
-const a413_0x4331=['log','order','readFileSync','api','null','err','MailMessage','nolimit','Smtp','lodash','describe','subject','rejectMessage','readAt','create','channel','isNil','port','split','rejectmessage','auth','YYYY-MM-DD\x20HH:mm:ss','like','messageId','mail-interactions','keys','sort','message-%s.eml','from','MailMessage,\x20%s,\x20%s,\x20%s','toString','SendMail','offset','host','request\x20sent','MailInteraction','writeFileSync','../../rediscache','key','[MAILMESSAGE:ACCEPT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','bcc','MailServerOut','options','fieldName','MailAccountId','rawAttributes','request','destroy','ddd,\x20DD\x20MMM\x20YYYY\x20HH:mm:ss\x20ZZ','fields','server/files/attachments','defaults','sequelize','unix','info','result','../../mysqldb','model','filters','Attachments','length','CmList','interaction','[MAILMESSAGE:REJECT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','query','status','download','user','merge','UserId','intersection','set','pass','read','secure','Bcc','then','AcceptMessage','SIP/%s','register','map','update','List','root','Attachment','get','show','files','event','../../config/environment','code','updatedAt','reject','format','CmContact','json','attachments','build','role','client','message','params','eml-format','jayson/promise','end','./mailMessage.socket','service','stringify','send','MailInteractionId','MailMessage,\x20%s,\x20%s','MailAccount','sendMail','includeAll','basename','rows','type','where','interface','Contacts','filter','headers','join','catch','count','util','include','body','RejectMessage','index','name','attributes','accept','createdAt','http','undefined','limit','../../components/parsers/qs','EventManager','acceptMessage','DESC','authentication','read1stAt','findAll','ListId','path','List\x20not\x20found','error','findOne'];(function(_0x466b93,_0x43315){const _0x9f63c0=function(_0x44f57c){while(--_0x44f57c){_0x466b93['push'](_0x466b93['shift']());}};_0x9f63c0(++_0x43315);}(a413_0x4331,0x11f));const a413_0x9f63=function(_0x466b93,_0x43315){_0x466b93=_0x466b93-0x0;let _0x9f63c0=a413_0x4331[_0x466b93];return _0x9f63c0;};const _0x449ef6=a413_0x9f63;'use strict';const emlformat=require(_0x449ef6('0x71')),moment=require('moment'),util=require(_0x449ef6('0x88')),path=require(_0x449ef6('0x7')),fs=require('fs'),_=require(_0x449ef6('0x14')),{getSocket}=require(_0x449ef6('0x30')),socket=getSocket(),qs=require(_0x449ef6('0x94')),logger=require('../../config/logger')(_0x449ef6('0xe')),config=require(_0x449ef6('0x64')),interaction_log=require('../../config/logger')(_0x449ef6('0x23')),db=require(_0x449ef6('0x43'))['db'],{Op}=require(_0x449ef6('0x3f'));require(_0x449ef6('0x74'))[_0x449ef6('0x5a')](socket);const jayson=require(_0x449ef6('0x72')),client=jayson['client'][_0x449ef6('0x91')]({'port':0x232c}),client9003=jayson[_0x449ef6('0x6e')][_0x449ef6('0x91')]({'port':0x232b}),client9002=jayson[_0x449ef6('0x6e')][_0x449ef6('0x91')]({'port':0x232a});function respondWithRpcPromise(_0x44f57c,_0x440871,_0x5f3214,_0x3051f9){return new Promise(function(_0x19ed77,_0x123a7f){const _0x56acdf=a413_0x9f63,_0x42fc80=_0x3051f9||client;return _0x42fc80[_0x56acdf('0x39')](_0x44f57c,_0x5f3214)['then'](function(_0x2792a8){const _0x59081e=_0x56acdf;logger['info'](_0x59081e('0x79'),_0x440871,_0x59081e('0x2d')),logger['debug'](_0x59081e('0x28'),_0x440871,_0x59081e('0x2d'),JSON[_0x59081e('0x76')](_0x2792a8));if(_0x2792a8[_0x59081e('0x9')]){if(_0x2792a8[_0x59081e('0x9')][_0x59081e('0x65')]===0x1f4)return logger[_0x59081e('0x9')](_0x59081e('0x79'),_0x440871,_0x2792a8[_0x59081e('0x9')][_0x59081e('0x6f')]),_0x123a7f(_0x2792a8[_0x59081e('0x9')][_0x59081e('0x6f')]);return logger[_0x59081e('0x9')](_0x59081e('0x79'),_0x440871,_0x2792a8['error'][_0x59081e('0x6f')]),_0x19ed77(_0x2792a8[_0x59081e('0x9')]['message']);}else logger[_0x59081e('0x41')](_0x59081e('0x79'),_0x440871,_0x59081e('0x2d')),_0x19ed77(_0x2792a8[_0x59081e('0x42')]['message']);})[_0x56acdf('0x86')](function(_0x228c50){const _0x47ed66=_0x56acdf;logger[_0x47ed66('0x9')]('MailMessage,\x20%s,\x20%s',_0x440871,_0x228c50),_0x123a7f(_0x228c50);});});}function respondWithResult(_0x2ce742,_0x5081fd){return _0x5081fd=_0x5081fd||0xc8,function(_0x19df9f){const _0x128a61=a413_0x9f63;if(_0x19df9f)return _0x2ce742[_0x128a61('0x4c')](_0x5081fd)[_0x128a61('0x6a')](_0x19df9f);};}function respondWithFilteredResult(_0x2181a1,_0x93aa9d){return function(_0x37394a){const _0x5a38e6=a413_0x9f63;if(_0x37394a){const _0x2bf5b4=_0x37394a['count'],_0x4c5220=_0x93aa9d['offset'];let _0x195939=_0x93aa9d[_0x5a38e6('0x2b')]+_0x93aa9d['limit'],_0x111bf1;return _0x195939>=_0x2bf5b4?(_0x195939=_0x2bf5b4,_0x111bf1=0xc8):_0x111bf1=0xce,_0x2181a1['status'](_0x111bf1),_0x2181a1[_0x5a38e6('0x52')]('Content-Range',_0x4c5220+'-'+_0x195939+'/'+_0x2bf5b4)[_0x5a38e6('0x6a')](_0x37394a);}return null;};}function saveUpdates(_0x311393){return function(_0x2463db){const _0x295b07=a413_0x9f63;if(_0x2463db)return _0x2463db['update'](_0x311393)[_0x295b07('0x57')](function(_0x7d225f){return _0x7d225f;});return null;};}function removeEntity(_0x2b07cb){return function(_0x39a8fc){const _0x13d0bd=a413_0x9f63;if(_0x39a8fc)return _0x39a8fc[_0x13d0bd('0x3a')]()['then'](function(){const _0x2dc1be=_0x13d0bd;_0x2b07cb[_0x2dc1be('0x4c')](0xcc)[_0x2dc1be('0x73')]();});};}function handleEntityNotFound(_0x113e44){return function(_0x5161bd){return!_0x5161bd&&_0x113e44['sendStatus'](0x194),_0x5161bd;};}function handleError(_0x3fd688,_0x19d1c0){return _0x19d1c0=_0x19d1c0||0x1f4,function(_0x3cd5f4){const _0x5ad27c=a413_0x9f63;logger['error'](_0x3cd5f4['stack']),_0x3cd5f4[_0x5ad27c('0x8d')]&&delete _0x3cd5f4[_0x5ad27c('0x8d')],_0x3fd688['status'](_0x19d1c0)[_0x5ad27c('0x77')](_0x3cd5f4);};}exports[_0x449ef6('0x8c')]=function(_0x309c20,_0x52a1e4){const _0x56ed22=_0x449ef6;let _0x3e999d={};const _0x44e19d={},_0x399d38={'count':0x0,'rows':[]},_0x5c0c06=_[_0x56ed22('0x5b')](db[_0x56ed22('0x11')][_0x56ed22('0x38')],function(_0x2e8754){const _0x405aa2=_0x56ed22;return{'name':_0x2e8754[_0x405aa2('0x36')],'type':_0x2e8754[_0x405aa2('0x7f')][_0x405aa2('0x31')]};});_0x44e19d[_0x56ed22('0x44')]=_[_0x56ed22('0x5b')](_0x5c0c06,_0x56ed22('0x8d')),_0x44e19d['query']=_[_0x56ed22('0x24')](_0x309c20[_0x56ed22('0x4b')]),_0x44e19d[_0x56ed22('0x45')]=_['intersection'](_0x44e19d[_0x56ed22('0x44')],_0x44e19d[_0x56ed22('0x4b')]),_0x3e999d[_0x56ed22('0x8e')]=_[_0x56ed22('0x51')](_0x44e19d['model'],qs[_0x56ed22('0x3c')](_0x309c20[_0x56ed22('0x4b')]['fields'])),_0x3e999d[_0x56ed22('0x8e')]=_0x3e999d[_0x56ed22('0x8e')][_0x56ed22('0x47')]?_0x3e999d[_0x56ed22('0x8e')]:_0x44e19d['model'];typeof _0x309c20[_0x56ed22('0x4b')][_0x56ed22('0x12')]===_0x56ed22('0x92')&&(_0x3e999d['limit']=qs[_0x56ed22('0x93')](_0x309c20[_0x56ed22('0x4b')][_0x56ed22('0x93')]),_0x3e999d[_0x56ed22('0x2b')]=qs[_0x56ed22('0x2b')](_0x309c20[_0x56ed22('0x4b')][_0x56ed22('0x2b')]));_0x3e999d[_0x56ed22('0xc')]=qs[_0x56ed22('0x25')](_0x309c20[_0x56ed22('0x4b')][_0x56ed22('0x25')]),_0x3e999d[_0x56ed22('0x80')]=qs[_0x56ed22('0x45')](_['pick'](_0x309c20['query'],_0x44e19d[_0x56ed22('0x45')]),_0x5c0c06);_0x309c20['query'][_0x56ed22('0x83')]&&(_0x3e999d[_0x56ed22('0x80')]=_[_0x56ed22('0x4f')](_0x3e999d[_0x56ed22('0x80')],{[Op['or']]:_['map'](_0x5c0c06,function(_0x196ab3){const _0x16dedc=_0x56ed22;if(_0x196ab3['type']!=='VIRTUAL'){const _0x84bafe={};return _0x84bafe[_0x196ab3['name']]={[Op[_0x16dedc('0x21')]]:'%'+_0x309c20[_0x16dedc('0x4b')]['filter']+'%'},_0x84bafe;}})}));_0x3e999d=_['merge']({},_0x3e999d,_0x309c20['options']);const _0x5518f4={'where':_0x3e999d[_0x56ed22('0x80')]};return db['MailMessage'][_0x56ed22('0x87')](_0x5518f4)['then'](function(_0x84045e){const _0x403b25=_0x56ed22;return _0x399d38[_0x403b25('0x87')]=_0x84045e,_0x309c20[_0x403b25('0x4b')][_0x403b25('0x7c')]&&(_0x3e999d[_0x403b25('0x89')]=[{'all':!![]}]),db['MailMessage'][_0x403b25('0x5')](_0x3e999d);})['then'](function(_0x504d28){const _0x4aa47a=_0x56ed22;return _0x399d38[_0x4aa47a('0x7e')]=_0x504d28,_0x399d38;})[_0x56ed22('0x57')](respondWithFilteredResult(_0x52a1e4,_0x3e999d))[_0x56ed22('0x86')](handleError(_0x52a1e4,null));},exports[_0x449ef6('0x61')]=function(_0x38df4e,_0xc42b3b){const _0x30f3f1=_0x449ef6;let _0x3cf149={'raw':!![],'where':{'id':_0x38df4e['params']['id']}};const _0xe6f508={};return _0xe6f508[_0x30f3f1('0x44')]=_[_0x30f3f1('0x24')](db['MailMessage']['rawAttributes']),_0xe6f508['query']=_['keys'](_0x38df4e[_0x30f3f1('0x4b')]),_0xe6f508[_0x30f3f1('0x45')]=_[_0x30f3f1('0x51')](_0xe6f508[_0x30f3f1('0x44')],_0xe6f508[_0x30f3f1('0x4b')]),_0x3cf149[_0x30f3f1('0x8e')]=_[_0x30f3f1('0x51')](_0xe6f508[_0x30f3f1('0x44')],qs[_0x30f3f1('0x3c')](_0x38df4e['query']['fields'])),_0x3cf149[_0x30f3f1('0x8e')]=_0x3cf149[_0x30f3f1('0x8e')][_0x30f3f1('0x47')]?_0x3cf149[_0x30f3f1('0x8e')]:_0xe6f508[_0x30f3f1('0x44')],_0x38df4e[_0x30f3f1('0x4b')]['includeAll']&&(_0x3cf149[_0x30f3f1('0x89')]=[{'all':!![]}]),_0x3cf149=_['merge']({},_0x3cf149,_0x38df4e[_0x30f3f1('0x35')]),db['MailMessage'][_0x30f3f1('0xa')](_0x3cf149)[_0x30f3f1('0x57')](handleEntityNotFound(_0xc42b3b,null))[_0x30f3f1('0x57')](respondWithResult(_0xc42b3b,null))['catch'](handleError(_0xc42b3b,null));},exports['update']=function(_0x4623ed,_0x55ddce){const _0x176e6e=_0x449ef6;return _0x4623ed[_0x176e6e('0x8a')]['id']&&delete _0x4623ed['body']['id'],db[_0x176e6e('0x11')][_0x176e6e('0xa')]({'where':{'id':_0x4623ed[_0x176e6e('0x70')]['id']}})[_0x176e6e('0x57')](handleEntityNotFound(_0x55ddce,null))[_0x176e6e('0x57')](saveUpdates(_0x4623ed[_0x176e6e('0x8a')],null))[_0x176e6e('0x57')](respondWithResult(_0x55ddce,null))[_0x176e6e('0x86')](handleError(_0x55ddce,null));},exports[_0x449ef6('0x3a')]=function(_0x56bdbd,_0x422d7e){const _0x27afdb=_0x449ef6;return db[_0x27afdb('0x11')]['findOne']({'where':{'id':_0x56bdbd[_0x27afdb('0x70')]['id']}})[_0x27afdb('0x57')](handleEntityNotFound(_0x422d7e,null))[_0x27afdb('0x57')](removeEntity(_0x422d7e,null))[_0x27afdb('0x86')](handleError(_0x422d7e,null));},exports[_0x449ef6('0x15')]=function(_0x3c6296,_0x17fef5){const _0x1dcdec=_0x449ef6;return db[_0x1dcdec('0x11')][_0x1dcdec('0x15')]()[_0x1dcdec('0x57')](respondWithResult(_0x17fef5,null))['catch'](handleError(_0x17fef5,null));},exports[_0x449ef6('0x19')]=function(_0x556cc3,_0x2a133c){const _0x56e460=_0x449ef6;return db['MailMessage'][_0x56e460('0x19')](_0x556cc3[_0x56e460('0x8a')])[_0x56e460('0x57')](function(_0xa34ed2){const _0x29c0db=_0x56e460;if(_0xa34ed2){if(_0xa34ed2['direction']==='out'&&!_0xa34ed2['secret']){let _0xec4190,_0x2e1173,_0x2439d8;return _0x556cc3[_0x29c0db('0x8a')]['to']&&(_0x2e1173=_0x556cc3[_0x29c0db('0x8a')]['to'][_0x29c0db('0x1d')](',')[0x0]),db[_0x29c0db('0x7a')]['findOne']({'where':{'id':_0xa34ed2[_0x29c0db('0x37')]},'include':[{'model':db[_0x29c0db('0x48')],'as':_0x29c0db('0x5d'),'include':[{'model':db[_0x29c0db('0x69')],'as':_0x29c0db('0x82'),'where':{'email':_0x2e1173},'limit':0x1,'order':[[_0x29c0db('0x66'),_0x29c0db('0x2')]]}]},{'model':db[_0x29c0db('0x34')],'as':_0x29c0db('0x13'),'raw':!![]}]})['then'](function(_0x43c47c){const _0x181bc9=_0x29c0db;_0xec4190=_0x43c47c;if(_0xec4190&&_0xec4190[_0x181bc9('0x13')]){const _0x250eae={'tls':{'rejectUnauthorized':![]}};_[_0x181bc9('0x1b')](_0xec4190[_0x181bc9('0x13')][_0x181bc9('0x75')])?(_0x250eae[_0x181bc9('0x2c')]=_0xec4190[_0x181bc9('0x13')][_0x181bc9('0x2c')],_0x250eae[_0x181bc9('0x1c')]=_0xec4190[_0x181bc9('0x13')][_0x181bc9('0x1c')],_0x250eae[_0x181bc9('0x55')]=_0xec4190[_0x181bc9('0x13')][_0x181bc9('0x55')],_0xec4190[_0x181bc9('0x13')][_0x181bc9('0x3')]&&(_0x250eae[_0x181bc9('0x1f')]={'user':_0xec4190[_0x181bc9('0x13')][_0x181bc9('0x4e')],'pass':_0xec4190[_0x181bc9('0x13')]['pass']})):(_0x250eae[_0x181bc9('0x75')]=_0xec4190[_0x181bc9('0x13')]['service'],_0x250eae[_0x181bc9('0x1f')]={'user':_0xec4190[_0x181bc9('0x13')][_0x181bc9('0x4e')],'pass':_0xec4190[_0x181bc9('0x13')][_0x181bc9('0x53')]},_0x250eae[_0x181bc9('0x55')]=_0xec4190[_0x181bc9('0x13')][_0x181bc9('0x55')]);if(_0x556cc3[_0x181bc9('0x8a')][_0x181bc9('0x6b')]&&_0x556cc3[_0x181bc9('0x8a')][_0x181bc9('0x6b')][_0x181bc9('0x47')])for(let _0x16adae=0x0;_0x16adae<_0x556cc3['body'][_0x181bc9('0x6b')][_0x181bc9('0x47')];_0x16adae+=0x1){_0x556cc3['body'][_0x181bc9('0x6b')][_0x16adae]={'filename':_0x556cc3['body']['attachments'][_0x16adae]['name'],'path':path[_0x181bc9('0x85')](config[_0x181bc9('0x5e')],_0x181bc9('0x3d'),_0x556cc3[_0x181bc9('0x8a')]['attachments'][_0x16adae][_0x181bc9('0x7d')])};}_0x2439d8={'account':_0x250eae,'message':_0x556cc3[_0x181bc9('0x8a')]};return;}})[_0x29c0db('0x57')](function(){const _0x1e3953=_0x29c0db;if(_0xec4190[_0x1e3953('0x5d')])return _0xec4190[_0x1e3953('0x5d')][_0x1e3953('0x82')][_0x1e3953('0x47')]?_0xec4190['List'][_0x1e3953('0x82')][0x0]:db[_0x1e3953('0x69')][_0x1e3953('0x19')](_[_0x1e3953('0x3e')](_0x556cc3[_0x1e3953('0x8a')],{'firstName':_0x556cc3['body']['to'],'email':_0x556cc3[_0x1e3953('0x8a')]['to'],'phone':_0x556cc3['body']['to'],'ListId':_0xec4190[_0x1e3953('0x6')]}));else throw new Error(_0x1e3953('0x8'));})[_0x29c0db('0x57')](function(){const _0xff116a=_0x29c0db;if(_0x2439d8)return respondWithRpcPromise(_0xff116a('0x2a'),_0xff116a('0x7b'),_0x2439d8,client9003)[_0xff116a('0x57')](function(_0x4c30d0){const _0x1f6422=_0xff116a;return _0xa34ed2[_0x1f6422('0x5c')]({'read':!![],'messageId':_0x4c30d0[_0x1f6422('0x22')],'sentAt':moment()[_0x1f6422('0x68')](_0x1f6422('0x20'))});})[_0xff116a('0x86')](function(_0x50ef51){const _0x5cbfeb=_0xff116a;return logger[_0x5cbfeb('0x9')]('%s',JSON[_0x5cbfeb('0x76')](_0x50ef51)),_0xa34ed2;});return _0xa34ed2;});}return _0xa34ed2;}})[_0x56e460('0x57')](respondWithResult(_0x2a133c,0xc9))[_0x56e460('0x86')](handleError(_0x2a133c,null));},exports[_0x449ef6('0x8f')]=function(_0x454f34,_0x70f46d){const _0x2ff162=_0x449ef6,_0x52e274={'channel':'mail'};return _0x454f34[_0x2ff162('0x8a')]['id']&&delete _0x454f34[_0x2ff162('0x8a')]['id'],_0x454f34[_0x2ff162('0x8a')][_0x2ff162('0x54')]=!![],_0x454f34[_0x2ff162('0x8a')][_0x2ff162('0x18')]=moment()[_0x2ff162('0x68')](_0x2ff162('0x20')),_0x454f34[_0x2ff162('0x8a')][_0x2ff162('0x50')]=_0x454f34['body']['UserId']||_0x454f34[_0x2ff162('0x4e')]['id'],db[_0x2ff162('0x11')][_0x2ff162('0xa')]({'where':{'id':_0x454f34[_0x2ff162('0x70')]['id'],'UserId':null},'include':[{'model':db['CmContact'],'as':'Contact'}]})[_0x2ff162('0x57')](handleEntityNotFound(_0x70f46d,null))['then'](saveUpdates(_0x454f34[_0x2ff162('0x8a')],null))['then'](function(_0x5d52e1){const _0x28ea3f=_0x2ff162;if(_0x5d52e1)return _0x52e274[_0x28ea3f('0x6f')]=_0x5d52e1['get']({'plain':!![]}),db['MailInteraction'][_0x28ea3f('0xa')]({'where':{'id':_0x5d52e1['MailInteractionId']}});return null;})[_0x2ff162('0x57')](handleEntityNotFound(_0x70f46d,null))['then'](function(_0x2384ec){const _0x25a1ba=_0x2ff162;if(_0x2384ec)return _0x2384ec[_0x25a1ba('0x5c')]({'UserId':_0x454f34[_0x25a1ba('0x8a')][_0x25a1ba('0x50')],'read1stAt':_[_0x25a1ba('0x1b')](_0x2384ec[_0x25a1ba('0x4')])?moment()[_0x25a1ba('0x68')]('YYYY-MM-DD\x20HH:mm:ss'):undefined});return null;})['then'](function(_0x195cae){const _0x3fd306=_0x2ff162;if(_0x195cae)return _0x52e274[_0x3fd306('0x49')]=_0x195cae['get']({'plain':!![]}),interaction_log[_0x3fd306('0x41')](_0x3fd306('0x32'),_0x454f34[_0x3fd306('0x4e')]['id'],_0x454f34[_0x3fd306('0x4e')]['name'],_0x454f34['user'][_0x3fd306('0x6d')],_0x52e274[_0x3fd306('0x49')]['id'],_0x454f34[_0x3fd306('0x8a')]?JSON[_0x3fd306('0x76')](_0x454f34[_0x3fd306('0x8a')]):'null'),respondWithRpcPromise(_0x3fd306('0x58'),_0x3fd306('0x1'),_0x52e274);return null;})[_0x2ff162('0x57')](function(_0xc21693){const _0x2c4847=_0x2ff162;if(_0xc21693){if(_0x454f34['body']['manual'])return _0x52e274[_0x2c4847('0x6f')][_0x2c4847('0x81')]=util[_0x2c4847('0x68')](_0x2c4847('0x59'),_0x454f34[_0x2c4847('0x4e')][_0x2c4847('0x8d')]),_0x52e274[_0x2c4847('0x6f')][_0x2c4847('0x1a')]=_0x52e274[_0x2c4847('0x1a')],_0x52e274[_0x2c4847('0x6f')][_0x2c4847('0x63')]='accept',respondWithRpcPromise(_0x2c4847('0x0'),_0x2c4847('0x0'),{'event':'acceptmessage','message':_0x52e274[_0x2c4847('0x6f')]},client9002)['then'](function(){return _0x52e274;});return _0x52e274;}return null;})[_0x2ff162('0x57')](respondWithResult(_0x70f46d,null))['catch'](handleError(_0x70f46d,null));},exports[_0x449ef6('0x67')]=function(_0x555d10,_0xd20d60){const _0x1f2406=_0x449ef6,_0x540cde={'agent':{},'channel':'mail'};return _0x555d10[_0x1f2406('0x8a')]['id']&&delete _0x555d10['body']['id'],_0x555d10['body']['UserId']=_0x555d10[_0x1f2406('0x8a')]['UserId']||_0x555d10[_0x1f2406('0x4e')]['id'],_0x540cde['agent']['id']=_0x555d10[_0x1f2406('0x8a')][_0x1f2406('0x50')],db[_0x1f2406('0x11')][_0x1f2406('0xa')]({'where':{'id':_0x555d10[_0x1f2406('0x70')]['id'],'UserId':null}})[_0x1f2406('0x57')](handleEntityNotFound(_0xd20d60,null))[_0x1f2406('0x57')](function(_0x2eb4cb){const _0x10ee63=_0x1f2406;if(_0x2eb4cb)return _0x540cde[_0x10ee63('0x6f')]=_0x2eb4cb[_0x10ee63('0x60')]({'plain':!![]}),db[_0x10ee63('0x2e')]['findOne']({'where':{'id':_0x2eb4cb[_0x10ee63('0x78')]}});return null;})[_0x1f2406('0x57')](handleEntityNotFound(_0xd20d60,null))[_0x1f2406('0x57')](function(_0x2c9b16){const _0x3fbb9f=_0x1f2406;if(_0x2c9b16)return _0x540cde['interaction']=_0x2c9b16[_0x3fbb9f('0x60')]({'plain':!![]}),interaction_log['info'](_0x3fbb9f('0x4a'),_0x555d10[_0x3fbb9f('0x4e')]['id'],_0x555d10['user'][_0x3fbb9f('0x8d')],_0x555d10[_0x3fbb9f('0x4e')][_0x3fbb9f('0x6d')],_0x540cde[_0x3fbb9f('0x49')]['id'],_0x555d10[_0x3fbb9f('0x8a')]?JSON[_0x3fbb9f('0x76')](_0x555d10[_0x3fbb9f('0x8a')]):_0x3fbb9f('0xf')),respondWithRpcPromise(_0x3fbb9f('0x8b'),_0x3fbb9f('0x17'),_0x540cde);return null;})['then'](function(_0x878eac){const _0x1e2a0d=_0x1f2406;if(_0x878eac)return _0x878eac['message'][_0x1e2a0d('0x81')]=util[_0x1e2a0d('0x68')](_0x1e2a0d('0x59'),_0x555d10[_0x1e2a0d('0x4e')]['name']),_0x878eac[_0x1e2a0d('0x6f')][_0x1e2a0d('0x1a')]=_0x540cde[_0x1e2a0d('0x1a')],_0x878eac[_0x1e2a0d('0x6f')][_0x1e2a0d('0x63')]=_0x1e2a0d('0x67'),respondWithRpcPromise(_0x1e2a0d('0x0'),_0x1e2a0d('0x0'),{'event':_0x1e2a0d('0x1e'),'message':_0x878eac[_0x1e2a0d('0x6f')]},client9002),_0x540cde;return null;})['then'](respondWithResult(_0xd20d60,null))[_0x1f2406('0x86')](handleError(_0xd20d60,null));},exports['download']=function(_0x2167b9,_0x398b67){const _0x55c870=_0x449ef6,_0x46e69f=moment()[_0x55c870('0x40')]()[_0x55c870('0x29')](),_0xc3213e=path['join'](config[_0x55c870('0x5e')],_0x55c870('0x62'),'tmp'),_0x15ee13=path['join'](config[_0x55c870('0x5e')],'server',_0x55c870('0x62'),_0x55c870('0x6b')),_0xdadcb0=util[_0x55c870('0x68')](_0x55c870('0x26'),_0x46e69f);return db['MailMessage'][_0x55c870('0xa')]({'where':{'id':_0x2167b9[_0x55c870('0x70')]['id']},'attributes':['id','body',_0x55c870('0x27'),'to','cc','bcc',_0x55c870('0x16'),_0x55c870('0x90')],'include':_0x2167b9[_0x55c870('0x4b')]['attachments']?[{'model':db[_0x55c870('0x5f')],'as':_0x55c870('0x46')}]:undefined})[_0x55c870('0x57')](handleEntityNotFound(_0x398b67,null))[_0x55c870('0x57')](function(_0x50e2c1){const _0x522932=_0x55c870;if(_0x50e2c1){const _0xc28342=_0x50e2c1,_0x2e6858={'from':_0xc28342[_0x522932('0x27')],'to':_0xc28342['to'],'subject':_0xc28342[_0x522932('0x16')],'html':_0xc28342[_0x522932('0x8a')],'headers':{'Date':moment(_0xc28342[_0x522932('0x90')])[_0x522932('0x68')](_0x522932('0x3b'))},'attachments':[]};return _0x50e2c1['cc']&&(_0x2e6858[_0x522932('0x84')]['Cc']=_0x50e2c1['cc']),_0x50e2c1[_0x522932('0x33')]&&(_0x2e6858[_0x522932('0x84')][_0x522932('0x56')]=_0x50e2c1[_0x522932('0x33')]),new Promise(function(_0x51f75c,_0x22a0aa){const _0x22f7c7=_0x522932;if(_0x50e2c1[_0x22f7c7('0x46')])for(let _0x28ab0d=0x0;_0x28ab0d<_0x50e2c1[_0x22f7c7('0x46')][_0x22f7c7('0x47')];_0x28ab0d++){const _0x4eb9c6=_0x50e2c1['Attachments'][_0x28ab0d],_0x513621=path['join'](_0x15ee13,_0x4eb9c6[_0x22f7c7('0x7d')]);fs['existsSync'](_0x513621)&&_0x2e6858[_0x22f7c7('0x6b')]['push']({'name':_0x4eb9c6['name'],'contentType':_0x4eb9c6[_0x22f7c7('0x7f')],'data':fs[_0x22f7c7('0xd')](_0x513621)});}emlformat[_0x22f7c7('0x6c')](_0x2e6858,function(_0x2ad887,_0x52dcbe){const _0x2ee376=_0x22f7c7;if(_0x2ad887)return _0x22a0aa(_0x2ad887);return fs[_0x2ee376('0x2f')](path[_0x2ee376('0x85')](_0xc3213e,_0xdadcb0),_0x52dcbe),_0x51f75c(_0x52dcbe);});});}})['then'](function(_0x45272b){const _0x35844=_0x55c870;if(_0x45272b)return _0x398b67[_0x35844('0x4d')](path[_0x35844('0x85')](_0xc3213e,_0xdadcb0),_0xdadcb0,function(_0x42d4d7){const _0x4584db=_0x35844;_0x42d4d7?console[_0x4584db('0xb')](_0x4584db('0x10'),_0x42d4d7):fs['unlinkSync'](path[_0x4584db('0x85')](_0xc3213e,_0xdadcb0));});})[_0x55c870('0x86')](handleError(_0x398b67,null));};
\ No newline at end of file
+const a413_0x5e64=['where','filter','MailAccount','port','client','pick','sendMail','register','isNil','readFileSync','fields','CmList','download','ListId','Attachments','role','attributes','stack','RejectMessage','reject','updatedAt','Smtp','stringify','mail-interactions','MailServerOut','key','[MAILMESSAGE:REJECT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','List\x20not\x20found','acceptMessage','set','../../mysqldb','request','jayson/promise','info','UserId','json','name','root','readAt','result','createdAt','sequelize','out','query','unix','sendStatus','messageId','Attachment','includeAll','body','limit','event','service','rawAttributes','manual','./mailMessage.socket','offset','params','../../config/environment','keys','secret','mail','List','destroy','user','defaults','subject','headers','status','basename','YYYY-MM-DD\x20HH:mm:ss','eml-format','server/files/attachments','toString','MailInteraction','MailMessage,\x20%s,\x20%s','authentication','request\x20sent','Contacts','accept','message','auth','intersection','tmp','http','rows','channel','interface','merge','writeFileSync','Bcc','catch','describe','format','Content-Range','type','SIP/%s','SendMail','findAll','host','null','code','log','model','order','DESC','unlinkSync','include','MailInteractionId','send','server','CmContact','length','files','push','split','error','interaction','filters','secure','Contact','err','agent','path','map','findOne','end','../../config/logger','[MAILMESSAGE:ACCEPT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','bcc','count','EventManager','util','attachments','create','AcceptMessage','nolimit','from','index','lodash','join','get','read','moment','fieldName','update','MailMessage','show','options','message-%s.eml','ddd,\x20DD\x20MMM\x20YYYY\x20HH:mm:ss\x20ZZ','build','like','rejectmessage','MailMessage,\x20%s,\x20%s,\x20%s','then'];(function(_0x5a3b80,_0x5e64ca){const _0x2db935=function(_0x1bf4aa){while(--_0x1bf4aa){_0x5a3b80['push'](_0x5a3b80['shift']());}};_0x2db935(++_0x5e64ca);}(a413_0x5e64,0x9a));const a413_0x2db9=function(_0x5a3b80,_0x5e64ca){_0x5a3b80=_0x5a3b80-0x0;let _0x2db935=a413_0x5e64[_0x5a3b80];return _0x2db935;};const _0x5a8e8b=a413_0x2db9;'use strict';const emlformat=require(_0x5a8e8b('0x49')),moment=require(_0x5a8e8b('0x91')),util=require(_0x5a8e8b('0x86')),path=require(_0x5a8e8b('0x7d')),fs=require('fs'),_=require(_0x5a8e8b('0x8d')),{getSocket}=require('../../rediscache'),socket=getSocket(),qs=require('../../components/parsers/qs'),logger=require(_0x5a8e8b('0x81'))('api'),config=require(_0x5a8e8b('0x3c')),interaction_log=require(_0x5a8e8b('0x81'))(_0x5a8e8b('0x19')),db=require(_0x5a8e8b('0x20'))['db'],{Op}=require(_0x5a8e8b('0x2b'));require(_0x5a8e8b('0x39'))[_0x5a8e8b('0x9')](socket);const jayson=require(_0x5a8e8b('0x22')),client=jayson[_0x5a8e8b('0x6')][_0x5a8e8b('0x56')]({'port':0x232c}),client9003=jayson[_0x5a8e8b('0x6')][_0x5a8e8b('0x56')]({'port':0x232b}),client9002=jayson['client'][_0x5a8e8b('0x56')]({'port':0x232a});function respondWithRpcPromise(_0x1bf4aa,_0x55979c,_0x3ec280,_0x196760){return new Promise(function(_0x5813af,_0x41b5c7){const _0x410b64=a413_0x2db9,_0x59b9ba=_0x196760||client;return _0x59b9ba[_0x410b64('0x21')](_0x1bf4aa,_0x3ec280)[_0x410b64('0x1')](function(_0x56db2f){const _0x118ad9=_0x410b64;logger[_0x118ad9('0x23')](_0x118ad9('0x4d'),_0x55979c,'request\x20sent'),logger['debug'](_0x118ad9('0x0'),_0x55979c,_0x118ad9('0x4f'),JSON['stringify'](_0x56db2f));if(_0x56db2f[_0x118ad9('0x76')]){if(_0x56db2f[_0x118ad9('0x76')][_0x118ad9('0x67')]===0x1f4)return logger[_0x118ad9('0x76')](_0x118ad9('0x4d'),_0x55979c,_0x56db2f['error'][_0x118ad9('0x52')]),_0x41b5c7(_0x56db2f[_0x118ad9('0x76')]['message']);return logger[_0x118ad9('0x76')](_0x118ad9('0x4d'),_0x55979c,_0x56db2f[_0x118ad9('0x76')][_0x118ad9('0x52')]),_0x5813af(_0x56db2f[_0x118ad9('0x76')][_0x118ad9('0x52')]);}else logger['info'](_0x118ad9('0x4d'),_0x55979c,'request\x20sent'),_0x5813af(_0x56db2f[_0x118ad9('0x29')][_0x118ad9('0x52')]);})[_0x410b64('0x5d')](function(_0x1839ae){const _0x2f4f96=_0x410b64;logger[_0x2f4f96('0x76')](_0x2f4f96('0x4d'),_0x55979c,_0x1839ae),_0x41b5c7(_0x1839ae);});});}function respondWithResult(_0x15117e,_0x118beb){return _0x118beb=_0x118beb||0xc8,function(_0x31a6e3){const _0x3b273b=a413_0x2db9;if(_0x31a6e3)return _0x15117e[_0x3b273b('0x46')](_0x118beb)[_0x3b273b('0x25')](_0x31a6e3);};}function respondWithFilteredResult(_0x9191df,_0x2323b5){return function(_0x22499d){const _0xf84688=a413_0x2db9;if(_0x22499d){const _0x2c90e1=_0x22499d[_0xf84688('0x84')],_0x389c29=_0x2323b5[_0xf84688('0x3a')];let _0x299640=_0x2323b5[_0xf84688('0x3a')]+_0x2323b5[_0xf84688('0x34')],_0x12613e;return _0x299640>=_0x2c90e1?(_0x299640=_0x2c90e1,_0x12613e=0xc8):_0x12613e=0xce,_0x9191df['status'](_0x12613e),_0x9191df[_0xf84688('0x1f')](_0xf84688('0x60'),_0x389c29+'-'+_0x299640+'/'+_0x2c90e1)['json'](_0x22499d);}return null;};}function saveUpdates(_0x629a39){return function(_0x3580eb){const _0x3e6edc=a413_0x2db9;if(_0x3580eb)return _0x3580eb[_0x3e6edc('0x93')](_0x629a39)[_0x3e6edc('0x1')](function(_0x3aa2c5){return _0x3aa2c5;});return null;};}function removeEntity(_0x7d37a3){return function(_0x53078e){const _0x418747=a413_0x2db9;if(_0x53078e)return _0x53078e['destroy']()[_0x418747('0x1')](function(){const _0x47c6ab=_0x418747;_0x7d37a3['status'](0xcc)[_0x47c6ab('0x80')]();});};}function handleEntityNotFound(_0x16d481){return function(_0x3ce66b){const _0x16ad72=a413_0x2db9;return!_0x3ce66b&&_0x16d481[_0x16ad72('0x2f')](0x194),_0x3ce66b;};}function handleError(_0x3124c1,_0xe05019){return _0xe05019=_0xe05019||0x1f4,function(_0x4ebf97){const _0x5a79d4=a413_0x2db9;logger[_0x5a79d4('0x76')](_0x4ebf97[_0x5a79d4('0x13')]),_0x4ebf97[_0x5a79d4('0x26')]&&delete _0x4ebf97[_0x5a79d4('0x26')],_0x3124c1['status'](_0xe05019)[_0x5a79d4('0x6f')](_0x4ebf97);};}exports[_0x5a8e8b('0x8c')]=function(_0x91db6a,_0x4831f1){const _0x35fe7c=_0x5a8e8b;let _0x3050e7={};const _0x3b472d={},_0x5a940e={'count':0x0,'rows':[]},_0x370de8=_[_0x35fe7c('0x7e')](db['MailMessage'][_0x35fe7c('0x37')],function(_0x3f6bfe){const _0x1cb760=_0x35fe7c;return{'name':_0x3f6bfe[_0x1cb760('0x92')],'type':_0x3f6bfe['type'][_0x1cb760('0x1b')]};});_0x3b472d[_0x35fe7c('0x69')]=_[_0x35fe7c('0x7e')](_0x370de8,_0x35fe7c('0x26')),_0x3b472d[_0x35fe7c('0x2d')]=_[_0x35fe7c('0x3d')](_0x91db6a[_0x35fe7c('0x2d')]),_0x3b472d['filters']=_[_0x35fe7c('0x54')](_0x3b472d['model'],_0x3b472d['query']),_0x3050e7['attributes']=_['intersection'](_0x3b472d[_0x35fe7c('0x69')],qs['fields'](_0x91db6a[_0x35fe7c('0x2d')]['fields'])),_0x3050e7[_0x35fe7c('0x12')]=_0x3050e7[_0x35fe7c('0x12')][_0x35fe7c('0x72')]?_0x3050e7[_0x35fe7c('0x12')]:_0x3b472d['model'];typeof _0x91db6a[_0x35fe7c('0x2d')][_0x35fe7c('0x8a')]==='undefined'&&(_0x3050e7[_0x35fe7c('0x34')]=qs[_0x35fe7c('0x34')](_0x91db6a[_0x35fe7c('0x2d')][_0x35fe7c('0x34')]),_0x3050e7[_0x35fe7c('0x3a')]=qs[_0x35fe7c('0x3a')](_0x91db6a['query'][_0x35fe7c('0x3a')]));_0x3050e7[_0x35fe7c('0x6a')]=qs['sort'](_0x91db6a['query']['sort']),_0x3050e7[_0x35fe7c('0x2')]=qs['filters'](_[_0x35fe7c('0x7')](_0x91db6a[_0x35fe7c('0x2d')],_0x3b472d[_0x35fe7c('0x78')]),_0x370de8);_0x91db6a['query'][_0x35fe7c('0x3')]&&(_0x3050e7['where']=_[_0x35fe7c('0x5a')](_0x3050e7[_0x35fe7c('0x2')],{[Op['or']]:_['map'](_0x370de8,function(_0x2242b9){const _0x57537e=_0x35fe7c;if(_0x2242b9['type']!=='VIRTUAL'){const _0x70ca4f={};return _0x70ca4f[_0x2242b9[_0x57537e('0x26')]]={[Op[_0x57537e('0x9a')]]:'%'+_0x91db6a[_0x57537e('0x2d')][_0x57537e('0x3')]+'%'},_0x70ca4f;}})}));_0x3050e7=_[_0x35fe7c('0x5a')]({},_0x3050e7,_0x91db6a[_0x35fe7c('0x96')]);const _0x46c3bd={'where':_0x3050e7[_0x35fe7c('0x2')]};return db[_0x35fe7c('0x94')][_0x35fe7c('0x84')](_0x46c3bd)[_0x35fe7c('0x1')](function(_0x5bbbde){const _0x330571=_0x35fe7c;return _0x5a940e[_0x330571('0x84')]=_0x5bbbde,_0x91db6a[_0x330571('0x2d')][_0x330571('0x32')]&&(_0x3050e7[_0x330571('0x6d')]=[{'all':!![]}]),db[_0x330571('0x94')][_0x330571('0x64')](_0x3050e7);})[_0x35fe7c('0x1')](function(_0x490552){const _0x183f30=_0x35fe7c;return _0x5a940e[_0x183f30('0x57')]=_0x490552,_0x5a940e;})[_0x35fe7c('0x1')](respondWithFilteredResult(_0x4831f1,_0x3050e7))['catch'](handleError(_0x4831f1,null));},exports[_0x5a8e8b('0x95')]=function(_0x32f669,_0x4a22de){const _0x1ae191=_0x5a8e8b;let _0x472a42={'raw':!![],'where':{'id':_0x32f669[_0x1ae191('0x3b')]['id']}};const _0x3cd13a={};return _0x3cd13a[_0x1ae191('0x69')]=_[_0x1ae191('0x3d')](db[_0x1ae191('0x94')][_0x1ae191('0x37')]),_0x3cd13a[_0x1ae191('0x2d')]=_['keys'](_0x32f669[_0x1ae191('0x2d')]),_0x3cd13a['filters']=_[_0x1ae191('0x54')](_0x3cd13a[_0x1ae191('0x69')],_0x3cd13a[_0x1ae191('0x2d')]),_0x472a42[_0x1ae191('0x12')]=_['intersection'](_0x3cd13a[_0x1ae191('0x69')],qs['fields'](_0x32f669[_0x1ae191('0x2d')][_0x1ae191('0xc')])),_0x472a42['attributes']=_0x472a42[_0x1ae191('0x12')][_0x1ae191('0x72')]?_0x472a42['attributes']:_0x3cd13a['model'],_0x32f669[_0x1ae191('0x2d')][_0x1ae191('0x32')]&&(_0x472a42[_0x1ae191('0x6d')]=[{'all':!![]}]),_0x472a42=_[_0x1ae191('0x5a')]({},_0x472a42,_0x32f669['options']),db['MailMessage'][_0x1ae191('0x7f')](_0x472a42)[_0x1ae191('0x1')](handleEntityNotFound(_0x4a22de,null))[_0x1ae191('0x1')](respondWithResult(_0x4a22de,null))[_0x1ae191('0x5d')](handleError(_0x4a22de,null));},exports[_0x5a8e8b('0x93')]=function(_0x453984,_0x336d04){const _0x58e19e=_0x5a8e8b;return _0x453984['body']['id']&&delete _0x453984[_0x58e19e('0x33')]['id'],db['MailMessage']['findOne']({'where':{'id':_0x453984['params']['id']}})[_0x58e19e('0x1')](handleEntityNotFound(_0x336d04,null))[_0x58e19e('0x1')](saveUpdates(_0x453984['body'],null))[_0x58e19e('0x1')](respondWithResult(_0x336d04,null))[_0x58e19e('0x5d')](handleError(_0x336d04,null));},exports[_0x5a8e8b('0x41')]=function(_0x5765fa,_0x32fcc0){const _0x2693d2=_0x5a8e8b;return db[_0x2693d2('0x94')]['findOne']({'where':{'id':_0x5765fa[_0x2693d2('0x3b')]['id']}})[_0x2693d2('0x1')](handleEntityNotFound(_0x32fcc0,null))[_0x2693d2('0x1')](removeEntity(_0x32fcc0,null))[_0x2693d2('0x5d')](handleError(_0x32fcc0,null));},exports[_0x5a8e8b('0x5e')]=function(_0x255e62,_0x4adb61){const _0x5d5ee5=_0x5a8e8b;return db[_0x5d5ee5('0x94')][_0x5d5ee5('0x5e')]()[_0x5d5ee5('0x1')](respondWithResult(_0x4adb61,null))['catch'](handleError(_0x4adb61,null));},exports[_0x5a8e8b('0x88')]=function(_0x5e38c6,_0xa1658e){const _0x1c003b=_0x5a8e8b;return db[_0x1c003b('0x94')][_0x1c003b('0x88')](_0x5e38c6[_0x1c003b('0x33')])[_0x1c003b('0x1')](function(_0x4e8cdf){const _0x2abcc1=_0x1c003b;if(_0x4e8cdf){if(_0x4e8cdf['direction']===_0x2abcc1('0x2c')&&!_0x4e8cdf[_0x2abcc1('0x3e')]){let _0x91fdec,_0x1f2b73,_0x1ab3f3;return _0x5e38c6['body']['to']&&(_0x1f2b73=_0x5e38c6[_0x2abcc1('0x33')]['to'][_0x2abcc1('0x75')](',')[0x0]),db[_0x2abcc1('0x4')][_0x2abcc1('0x7f')]({'where':{'id':_0x4e8cdf['MailAccountId']},'include':[{'model':db[_0x2abcc1('0xd')],'as':_0x2abcc1('0x40'),'include':[{'model':db[_0x2abcc1('0x71')],'as':_0x2abcc1('0x50'),'where':{'email':_0x1f2b73},'limit':0x1,'order':[[_0x2abcc1('0x16'),_0x2abcc1('0x6b')]]}]},{'model':db[_0x2abcc1('0x1a')],'as':_0x2abcc1('0x17'),'raw':!![]}]})[_0x2abcc1('0x1')](function(_0x36dab8){const _0x4095a8=_0x2abcc1;_0x91fdec=_0x36dab8;if(_0x91fdec&&_0x91fdec[_0x4095a8('0x17')]){const _0x4ceaeb={'tls':{'rejectUnauthorized':![]}};_[_0x4095a8('0xa')](_0x91fdec[_0x4095a8('0x17')]['service'])?(_0x4ceaeb['host']=_0x91fdec[_0x4095a8('0x17')][_0x4095a8('0x65')],_0x4ceaeb[_0x4095a8('0x5')]=_0x91fdec[_0x4095a8('0x17')][_0x4095a8('0x5')],_0x4ceaeb['secure']=_0x91fdec['Smtp'][_0x4095a8('0x79')],_0x91fdec[_0x4095a8('0x17')][_0x4095a8('0x4e')]&&(_0x4ceaeb[_0x4095a8('0x53')]={'user':_0x91fdec[_0x4095a8('0x17')][_0x4095a8('0x42')],'pass':_0x91fdec[_0x4095a8('0x17')]['pass']})):(_0x4ceaeb[_0x4095a8('0x36')]=_0x91fdec['Smtp'][_0x4095a8('0x36')],_0x4ceaeb['auth']={'user':_0x91fdec['Smtp'][_0x4095a8('0x42')],'pass':_0x91fdec[_0x4095a8('0x17')]['pass']},_0x4ceaeb[_0x4095a8('0x79')]=_0x91fdec['Smtp'][_0x4095a8('0x79')]);if(_0x5e38c6[_0x4095a8('0x33')]['attachments']&&_0x5e38c6['body'][_0x4095a8('0x87')][_0x4095a8('0x72')])for(let _0x176169=0x0;_0x176169<_0x5e38c6[_0x4095a8('0x33')][_0x4095a8('0x87')][_0x4095a8('0x72')];_0x176169+=0x1){_0x5e38c6[_0x4095a8('0x33')][_0x4095a8('0x87')][_0x176169]={'filename':_0x5e38c6[_0x4095a8('0x33')][_0x4095a8('0x87')][_0x176169][_0x4095a8('0x26')],'path':path['join'](config['root'],_0x4095a8('0x4a'),_0x5e38c6[_0x4095a8('0x33')][_0x4095a8('0x87')][_0x176169][_0x4095a8('0x47')])};}_0x1ab3f3={'account':_0x4ceaeb,'message':_0x5e38c6[_0x4095a8('0x33')]};return;}})['then'](function(){const _0x40cdf0=_0x2abcc1;if(_0x91fdec[_0x40cdf0('0x40')])return _0x91fdec[_0x40cdf0('0x40')][_0x40cdf0('0x50')][_0x40cdf0('0x72')]?_0x91fdec[_0x40cdf0('0x40')][_0x40cdf0('0x50')][0x0]:db[_0x40cdf0('0x71')][_0x40cdf0('0x88')](_[_0x40cdf0('0x43')](_0x5e38c6[_0x40cdf0('0x33')],{'firstName':_0x5e38c6[_0x40cdf0('0x33')]['to'],'email':_0x5e38c6[_0x40cdf0('0x33')]['to'],'phone':_0x5e38c6[_0x40cdf0('0x33')]['to'],'ListId':_0x91fdec[_0x40cdf0('0xf')]}));else throw new Error(_0x40cdf0('0x1d'));})[_0x2abcc1('0x1')](function(){const _0x4b63b1=_0x2abcc1;if(_0x1ab3f3)return respondWithRpcPromise(_0x4b63b1('0x63'),_0x4b63b1('0x8'),_0x1ab3f3,client9003)[_0x4b63b1('0x1')](function(_0x288bfa){const _0x2555bc=_0x4b63b1;return _0x4e8cdf[_0x2555bc('0x93')]({'read':!![],'messageId':_0x288bfa[_0x2555bc('0x30')],'sentAt':moment()[_0x2555bc('0x5f')](_0x2555bc('0x48'))});})[_0x4b63b1('0x5d')](function(_0x505bcf){const _0x9831c8=_0x4b63b1;return logger[_0x9831c8('0x76')]('%s',JSON[_0x9831c8('0x18')](_0x505bcf)),_0x4e8cdf;});return _0x4e8cdf;});}return _0x4e8cdf;}})[_0x1c003b('0x1')](respondWithResult(_0xa1658e,0xc9))[_0x1c003b('0x5d')](handleError(_0xa1658e,null));},exports[_0x5a8e8b('0x51')]=function(_0x5deb01,_0x19e90a){const _0x5d7706=_0x5a8e8b,_0x5e0115={'channel':_0x5d7706('0x3f')};return _0x5deb01[_0x5d7706('0x33')]['id']&&delete _0x5deb01[_0x5d7706('0x33')]['id'],_0x5deb01[_0x5d7706('0x33')][_0x5d7706('0x90')]=!![],_0x5deb01[_0x5d7706('0x33')][_0x5d7706('0x28')]=moment()[_0x5d7706('0x5f')](_0x5d7706('0x48')),_0x5deb01[_0x5d7706('0x33')][_0x5d7706('0x24')]=_0x5deb01[_0x5d7706('0x33')]['UserId']||_0x5deb01['user']['id'],db[_0x5d7706('0x94')]['findOne']({'where':{'id':_0x5deb01[_0x5d7706('0x3b')]['id'],'UserId':null},'include':[{'model':db[_0x5d7706('0x71')],'as':_0x5d7706('0x7a')}]})[_0x5d7706('0x1')](handleEntityNotFound(_0x19e90a,null))[_0x5d7706('0x1')](saveUpdates(_0x5deb01['body'],null))[_0x5d7706('0x1')](function(_0x98b017){const _0x2d4d4d=_0x5d7706;if(_0x98b017)return _0x5e0115[_0x2d4d4d('0x52')]=_0x98b017[_0x2d4d4d('0x8f')]({'plain':!![]}),db[_0x2d4d4d('0x4c')][_0x2d4d4d('0x7f')]({'where':{'id':_0x98b017['MailInteractionId']}});return null;})[_0x5d7706('0x1')](handleEntityNotFound(_0x19e90a,null))[_0x5d7706('0x1')](function(_0xa0563d){const _0x2ad0aa=_0x5d7706;if(_0xa0563d)return _0xa0563d[_0x2ad0aa('0x93')]({'UserId':_0x5deb01[_0x2ad0aa('0x33')][_0x2ad0aa('0x24')],'read1stAt':_['isNil'](_0xa0563d['read1stAt'])?moment()[_0x2ad0aa('0x5f')](_0x2ad0aa('0x48')):undefined});return null;})[_0x5d7706('0x1')](function(_0x258b75){const _0x22c75f=_0x5d7706;if(_0x258b75)return _0x5e0115[_0x22c75f('0x77')]=_0x258b75['get']({'plain':!![]}),interaction_log['info'](_0x22c75f('0x82'),_0x5deb01['user']['id'],_0x5deb01[_0x22c75f('0x42')][_0x22c75f('0x26')],_0x5deb01[_0x22c75f('0x42')][_0x22c75f('0x11')],_0x5e0115['interaction']['id'],_0x5deb01[_0x22c75f('0x33')]?JSON[_0x22c75f('0x18')](_0x5deb01[_0x22c75f('0x33')]):_0x22c75f('0x66')),respondWithRpcPromise(_0x22c75f('0x89'),_0x22c75f('0x1e'),_0x5e0115);return null;})[_0x5d7706('0x1')](function(_0x580bb8){const _0x4e1606=_0x5d7706;if(_0x580bb8){if(_0x5deb01[_0x4e1606('0x33')][_0x4e1606('0x38')])return _0x5e0115[_0x4e1606('0x52')][_0x4e1606('0x59')]=util[_0x4e1606('0x5f')](_0x4e1606('0x62'),_0x5deb01[_0x4e1606('0x42')][_0x4e1606('0x26')]),_0x5e0115[_0x4e1606('0x52')][_0x4e1606('0x58')]=_0x5e0115[_0x4e1606('0x58')],_0x5e0115[_0x4e1606('0x52')][_0x4e1606('0x35')]=_0x4e1606('0x51'),respondWithRpcPromise('EventManager',_0x4e1606('0x85'),{'event':'acceptmessage','message':_0x5e0115[_0x4e1606('0x52')]},client9002)[_0x4e1606('0x1')](function(){return _0x5e0115;});return _0x5e0115;}return null;})['then'](respondWithResult(_0x19e90a,null))[_0x5d7706('0x5d')](handleError(_0x19e90a,null));},exports[_0x5a8e8b('0x15')]=function(_0x137acb,_0x5ea91d){const _0x2c3bbc=_0x5a8e8b,_0x457c50={'agent':{},'channel':_0x2c3bbc('0x3f')};return _0x137acb['body']['id']&&delete _0x137acb[_0x2c3bbc('0x33')]['id'],_0x137acb[_0x2c3bbc('0x33')][_0x2c3bbc('0x24')]=_0x137acb[_0x2c3bbc('0x33')]['UserId']||_0x137acb[_0x2c3bbc('0x42')]['id'],_0x457c50[_0x2c3bbc('0x7c')]['id']=_0x137acb[_0x2c3bbc('0x33')]['UserId'],db[_0x2c3bbc('0x94')][_0x2c3bbc('0x7f')]({'where':{'id':_0x137acb[_0x2c3bbc('0x3b')]['id'],'UserId':null}})[_0x2c3bbc('0x1')](handleEntityNotFound(_0x5ea91d,null))[_0x2c3bbc('0x1')](function(_0x374d26){const _0x5cd02c=_0x2c3bbc;if(_0x374d26)return _0x457c50[_0x5cd02c('0x52')]=_0x374d26[_0x5cd02c('0x8f')]({'plain':!![]}),db[_0x5cd02c('0x4c')][_0x5cd02c('0x7f')]({'where':{'id':_0x374d26[_0x5cd02c('0x6e')]}});return null;})[_0x2c3bbc('0x1')](handleEntityNotFound(_0x5ea91d,null))['then'](function(_0x3f0875){const _0x5c0591=_0x2c3bbc;if(_0x3f0875)return _0x457c50[_0x5c0591('0x77')]=_0x3f0875[_0x5c0591('0x8f')]({'plain':!![]}),interaction_log[_0x5c0591('0x23')](_0x5c0591('0x1c'),_0x137acb['user']['id'],_0x137acb[_0x5c0591('0x42')][_0x5c0591('0x26')],_0x137acb[_0x5c0591('0x42')][_0x5c0591('0x11')],_0x457c50[_0x5c0591('0x77')]['id'],_0x137acb[_0x5c0591('0x33')]?JSON[_0x5c0591('0x18')](_0x137acb[_0x5c0591('0x33')]):_0x5c0591('0x66')),respondWithRpcPromise(_0x5c0591('0x14'),'rejectMessage',_0x457c50);return null;})[_0x2c3bbc('0x1')](function(_0x5bc5d8){const _0x593d09=_0x2c3bbc;if(_0x5bc5d8)return _0x5bc5d8[_0x593d09('0x52')]['interface']=util[_0x593d09('0x5f')](_0x593d09('0x62'),_0x137acb[_0x593d09('0x42')]['name']),_0x5bc5d8[_0x593d09('0x52')][_0x593d09('0x58')]=_0x457c50[_0x593d09('0x58')],_0x5bc5d8[_0x593d09('0x52')]['event']=_0x593d09('0x15'),respondWithRpcPromise('EventManager',_0x593d09('0x85'),{'event':_0x593d09('0x9b'),'message':_0x5bc5d8['message']},client9002),_0x457c50;return null;})['then'](respondWithResult(_0x5ea91d,null))['catch'](handleError(_0x5ea91d,null));},exports[_0x5a8e8b('0xe')]=function(_0x4e256a,_0x3fc42f){const _0x3250fc=_0x5a8e8b,_0x2c816a=moment()[_0x3250fc('0x2e')]()[_0x3250fc('0x4b')](),_0x593bee=path[_0x3250fc('0x8e')](config[_0x3250fc('0x27')],_0x3250fc('0x73'),_0x3250fc('0x55')),_0x5459d4=path[_0x3250fc('0x8e')](config[_0x3250fc('0x27')],_0x3250fc('0x70'),_0x3250fc('0x73'),_0x3250fc('0x87')),_0x5bbcf5=util[_0x3250fc('0x5f')](_0x3250fc('0x97'),_0x2c816a);return db[_0x3250fc('0x94')]['findOne']({'where':{'id':_0x4e256a['params']['id']},'attributes':['id',_0x3250fc('0x33'),_0x3250fc('0x8b'),'to','cc',_0x3250fc('0x83'),_0x3250fc('0x44'),_0x3250fc('0x2a')],'include':_0x4e256a[_0x3250fc('0x2d')][_0x3250fc('0x87')]?[{'model':db[_0x3250fc('0x31')],'as':'Attachments'}]:undefined})[_0x3250fc('0x1')](handleEntityNotFound(_0x3fc42f,null))[_0x3250fc('0x1')](function(_0x4973e3){const _0x1d7400=_0x3250fc;if(_0x4973e3){const _0x150d3f=_0x4973e3,_0x5a181c={'from':_0x150d3f['from'],'to':_0x150d3f['to'],'subject':_0x150d3f[_0x1d7400('0x44')],'html':_0x150d3f['body'],'headers':{'Date':moment(_0x150d3f[_0x1d7400('0x2a')])[_0x1d7400('0x5f')](_0x1d7400('0x98'))},'attachments':[]};return _0x4973e3['cc']&&(_0x5a181c[_0x1d7400('0x45')]['Cc']=_0x4973e3['cc']),_0x4973e3[_0x1d7400('0x83')]&&(_0x5a181c['headers'][_0x1d7400('0x5c')]=_0x4973e3[_0x1d7400('0x83')]),new Promise(function(_0x4b607d,_0x503392){const _0x4d5907=_0x1d7400;if(_0x4973e3[_0x4d5907('0x10')])for(let _0x3cdb9d=0x0;_0x3cdb9d<_0x4973e3[_0x4d5907('0x10')][_0x4d5907('0x72')];_0x3cdb9d++){const _0x27b9ed=_0x4973e3[_0x4d5907('0x10')][_0x3cdb9d],_0x257741=path[_0x4d5907('0x8e')](_0x5459d4,_0x27b9ed[_0x4d5907('0x47')]);fs['existsSync'](_0x257741)&&_0x5a181c['attachments'][_0x4d5907('0x74')]({'name':_0x27b9ed['name'],'contentType':_0x27b9ed[_0x4d5907('0x61')],'data':fs[_0x4d5907('0xb')](_0x257741)});}emlformat[_0x4d5907('0x99')](_0x5a181c,function(_0x57c1c0,_0x596e62){const _0x159e94=_0x4d5907;if(_0x57c1c0)return _0x503392(_0x57c1c0);return fs[_0x159e94('0x5b')](path[_0x159e94('0x8e')](_0x593bee,_0x5bbcf5),_0x596e62),_0x4b607d(_0x596e62);});});}})[_0x3250fc('0x1')](function(_0x3cf896){const _0x3edffc=_0x3250fc;if(_0x3cf896)return _0x3fc42f[_0x3edffc('0xe')](path['join'](_0x593bee,_0x5bbcf5),_0x5bbcf5,function(_0x2a60c4){const _0x59e21e=_0x3edffc;_0x2a60c4?console[_0x59e21e('0x68')](_0x59e21e('0x7b'),_0x2a60c4):fs[_0x59e21e('0x6c')](path[_0x59e21e('0x8e')](_0x593bee,_0x5bbcf5));});})[_0x3250fc('0x5d')](handleError(_0x3fc42f,null));};
\ No newline at end of file