Built motion from commit (unavailable).|2.5.6
[motion2.git] / server / api / mailMessage / mailMessage.controller.js
index 59c8461..fc3f8f7 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x731d=['localhost','client','http','ValidationError','request','info','MailMessage,\x20%s,\x20%s','request\x20sent','MailMessage,\x20%s,\x20%s,\x20%s','stringify','error','code','message','catch','sendStatus','status','json','count','offset','limit','set','Content-Range','apply','reject','update','destroy','then','end','stack','name','send','index','map','MailMessage','rawAttributes','fieldName','key','keys','query','filters','intersection','model','fields','attributes','nolimit','order','sort','where','pick','filter','merge','type','options','includeAll','findAll','rows','show','params','length','include','find','body','direction','out','MailAccount','findOne','MailAccountId','CmList','List','CmContact','Contacts','DESC','MailServerOut','Smtp','service','host','port','secure','authentication','auth','pass','user','attachments','join','server/files/attachments','ListId','List\x20not\x20found','SendMail','messageId','format','mail-interactions','accept','YYYY-MM-DD\x20HH:mm:ss','UserId','Contact','get','MailInteraction','isNil','read1stAt','interaction','acceptMessage','manual','interface','SIP/%s','channel','EventManager','acceptmessage','mail','MailInteractionId','null','RejectMessage','rejectMessage','event','download','unix','root','server','files','message-%s.eml','from','subject','createdAt','headers','bcc','Attachments','basename','existsSync','readFileSync','build','writeFileSync','log','err','unlinkSync','html-pdf','eml-format','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','path','sox','to-csv','ejs','lodash','crypto','jsforce','querystring','papaparse','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/environment','redis','defaults'];(function(_0x8c9200,_0x1928e6){var _0xc3b218=function(_0x197542){while(--_0x197542){_0x8c9200['push'](_0x8c9200['shift']());}};_0xc3b218(++_0x1928e6);}(_0x731d,0x123));var _0xd731=function(_0x6542f8,_0x367d3a){_0x6542f8=_0x6542f8-0x0;var _0x1b5637=_0x731d[_0x6542f8];return _0x1b5637;};'use strict';var pdf=require(_0xd731('0x0'));var emlformat=require(_0xd731('0x1'));var rimraf=require('rimraf');var zipdir=require(_0xd731('0x2'));var jsonpatch=require(_0xd731('0x3'));var rp=require(_0xd731('0x4'));var moment=require(_0xd731('0x5'));var BPromise=require(_0xd731('0x6'));var Mustache=require(_0xd731('0x7'));var util=require('util');var path=require(_0xd731('0x8'));var sox=require(_0xd731('0x9'));var csv=require(_0xd731('0xa'));var ejs=require(_0xd731('0xb'));var fs=require('fs');var _=require(_0xd731('0xc'));var squel=require('squel');var crypto=require(_0xd731('0xd'));var jsforce=require(_0xd731('0xe'));var deskjs=require('desk.js');var toCsv=require(_0xd731('0xa'));var querystring=require(_0xd731('0xf'));var Papa=require(_0xd731('0x10'));var Redis=require('ioredis');var authService=require(_0xd731('0x11'));var qs=require('../../components/parsers/qs');var as=require(_0xd731('0x12'));var hardwareService=require(_0xd731('0x13'));var logger=require(_0xd731('0x14'))(_0xd731('0x15'));var utils=require('../../config/utils');var config=require(_0xd731('0x16'));var db=require('../../mysqldb')['db'];config[_0xd731('0x17')]=_[_0xd731('0x18')](config['redis'],{'host':_0xd731('0x19'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require('./mailMessage.socket')['register'](socket);var jayson=require('jayson/promise');var client=jayson[_0xd731('0x1a')][_0xd731('0x1b')]({'port':0x232c});var client9003=jayson['client']['http']({'port':0x232b});var client9002=jayson[_0xd731('0x1a')][_0xd731('0x1b')]({'port':0x232a});function checkPasswordPattern(_0x3993fd,_0x493af8,_0x3e080d){if(_0x3e080d){var _0x4141bb=new RegExp(/(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[?!@#\$%\^&\*~\-_=+[{\]\}])(?=.{8,})/);if(_0x4141bb['test'](_0x493af8)){return _0x3993fd;}else{throw new db['Sequelize'][(_0xd731('0x1c'))]('The\x20password\x20must\x20be\x20at\x20least\x208\x20characters\x20long\x20and\x20have\x201\x20lowercase\x20character,\x201\x20uppercase\x20character,\x201\x20number\x20and\x201\x20special\x20character\x20~!@#$%^&-_=+[{]}.');}}else{return _0x3993fd;}}function respondWithRpcPromise(_0x5297cd,_0x59c7bf,_0x3c315a,_0x5c3716){return new BPromise(function(_0x20854b,_0x21560b){var _0x27a3d6=_0x5c3716||client;return _0x27a3d6[_0xd731('0x1d')](_0x5297cd,_0x3c315a)['then'](function(_0x222162){logger[_0xd731('0x1e')](_0xd731('0x1f'),_0x59c7bf,_0xd731('0x20'));logger['debug'](_0xd731('0x21'),_0x59c7bf,_0xd731('0x20'),JSON[_0xd731('0x22')](_0x222162));if(_0x222162[_0xd731('0x23')]){if(_0x222162[_0xd731('0x23')][_0xd731('0x24')]===0x1f4){logger[_0xd731('0x23')](_0xd731('0x1f'),_0x59c7bf,_0x222162[_0xd731('0x23')]['message']);return _0x21560b(_0x222162[_0xd731('0x23')][_0xd731('0x25')]);}logger[_0xd731('0x23')](_0xd731('0x1f'),_0x59c7bf,_0x222162[_0xd731('0x23')][_0xd731('0x25')]);return _0x20854b(_0x222162[_0xd731('0x23')]['message']);}else{logger[_0xd731('0x1e')](_0xd731('0x1f'),_0x59c7bf,'request\x20sent');_0x20854b(_0x222162['result'][_0xd731('0x25')]);}})[_0xd731('0x26')](function(_0x13999a){logger[_0xd731('0x23')](_0xd731('0x1f'),_0x59c7bf,_0x13999a);_0x21560b(_0x13999a);});});}function respondWithStatusCode(_0x2cab64,_0x3810c6){_0x3810c6=_0x3810c6||0xcc;return function(_0x1d7c55){if(_0x1d7c55){return _0x2cab64[_0xd731('0x27')](_0x3810c6);}return _0x2cab64[_0xd731('0x28')](_0x3810c6)['end']();};}function respondWithResult(_0x14540d,_0x2702ec){_0x2702ec=_0x2702ec||0xc8;return function(_0x44089c){if(_0x44089c){return _0x14540d['status'](_0x2702ec)[_0xd731('0x29')](_0x44089c);}};}function respondWithFilteredResult(_0x3b406d,_0x1d3070){return function(_0x474b3a){if(_0x474b3a){var _0x4b0064=_0x474b3a[_0xd731('0x2a')],_0x581af1=_0x1d3070[_0xd731('0x2b')],_0x17bd57=_0x1d3070[_0xd731('0x2b')]+_0x1d3070[_0xd731('0x2c')],_0x5680f7;if(_0x17bd57>=_0x4b0064){_0x17bd57=_0x4b0064;_0x5680f7=0xc8;}else{_0x5680f7=0xce;}_0x3b406d['status'](_0x5680f7);return _0x3b406d[_0xd731('0x2d')](_0xd731('0x2e'),_0x581af1+'-'+_0x17bd57+'/'+_0x4b0064)['json'](_0x474b3a);}return null;};}function patchUpdates(_0x309fb1){return function(_0x2339de){try{jsonpatch[_0xd731('0x2f')](_0x2339de,_0x309fb1,!![]);}catch(_0x13304d){return BPromise[_0xd731('0x30')](_0x13304d);}return _0x2339de['save']();};}function saveUpdates(_0x2197d6,_0xc90409){return function(_0x302fb0){if(_0x302fb0){return _0x302fb0[_0xd731('0x31')](_0x2197d6)['then'](function(_0x4cf95a){return _0x4cf95a;});}return null;};}function removeEntity(_0x3ae762,_0x1aed7){return function(_0x276fea){if(_0x276fea){return _0x276fea[_0xd731('0x32')]()[_0xd731('0x33')](function(){_0x3ae762[_0xd731('0x28')](0xcc)[_0xd731('0x34')]();});}};}function handleEntityNotFound(_0x504752,_0x5cd626){return function(_0x79e8cf){if(!_0x79e8cf){_0x504752[_0xd731('0x27')](0x194);}return _0x79e8cf;};}function handleError(_0x8246ce,_0x20ceb6){_0x20ceb6=_0x20ceb6||0x1f4;return function(_0x54b855){logger[_0xd731('0x23')](_0x54b855[_0xd731('0x35')]);if(_0x54b855[_0xd731('0x36')]){delete _0x54b855[_0xd731('0x36')];}_0x8246ce['status'](_0x20ceb6)[_0xd731('0x37')](_0x54b855);};}exports[_0xd731('0x38')]=function(_0x3020ed,_0x191bfd){var _0x34ce60={},_0x5d3179={},_0x40717f={'count':0x0,'rows':[]};var _0xc4e0bc=_[_0xd731('0x39')](db[_0xd731('0x3a')][_0xd731('0x3b')],function(_0x2308d4){return{'name':_0x2308d4[_0xd731('0x3c')],'type':_0x2308d4['type'][_0xd731('0x3d')]};});_0x5d3179['model']=_[_0xd731('0x39')](_0xc4e0bc,_0xd731('0x36'));_0x5d3179['query']=_[_0xd731('0x3e')](_0x3020ed[_0xd731('0x3f')]);_0x5d3179[_0xd731('0x40')]=_['intersection'](_0x5d3179['model'],_0x5d3179['query']);_0x34ce60['attributes']=_[_0xd731('0x41')](_0x5d3179[_0xd731('0x42')],qs[_0xd731('0x43')](_0x3020ed[_0xd731('0x3f')][_0xd731('0x43')]));_0x34ce60[_0xd731('0x44')]=_0x34ce60[_0xd731('0x44')]['length']?_0x34ce60[_0xd731('0x44')]:_0x5d3179[_0xd731('0x42')];if(!_0x3020ed[_0xd731('0x3f')]['hasOwnProperty'](_0xd731('0x45'))){_0x34ce60[_0xd731('0x2c')]=qs[_0xd731('0x2c')](_0x3020ed[_0xd731('0x3f')]['limit']);_0x34ce60[_0xd731('0x2b')]=qs[_0xd731('0x2b')](_0x3020ed[_0xd731('0x3f')][_0xd731('0x2b')]);}_0x34ce60[_0xd731('0x46')]=qs[_0xd731('0x47')](_0x3020ed[_0xd731('0x3f')][_0xd731('0x47')]);_0x34ce60[_0xd731('0x48')]=qs[_0xd731('0x40')](_[_0xd731('0x49')](_0x3020ed[_0xd731('0x3f')],_0x5d3179[_0xd731('0x40')]),_0xc4e0bc);if(_0x3020ed[_0xd731('0x3f')][_0xd731('0x4a')]){_0x34ce60[_0xd731('0x48')]=_[_0xd731('0x4b')](_0x34ce60['where'],{'$or':_['map'](_0xc4e0bc,function(_0x23bfc4){if(_0x23bfc4[_0xd731('0x4c')]!=='VIRTUAL'){var _0x89b23b={};_0x89b23b[_0x23bfc4[_0xd731('0x36')]]={'$like':'%'+_0x3020ed['query']['filter']+'%'};return _0x89b23b;}})});}_0x34ce60=_['merge']({},_0x34ce60,_0x3020ed[_0xd731('0x4d')]);var _0x3f2cbc={'where':_0x34ce60[_0xd731('0x48')]};return db[_0xd731('0x3a')]['count'](_0x3f2cbc)[_0xd731('0x33')](function(_0x2493a7){_0x40717f[_0xd731('0x2a')]=_0x2493a7;if(_0x3020ed[_0xd731('0x3f')][_0xd731('0x4e')]){_0x34ce60['include']=[{'all':!![]}];}return db[_0xd731('0x3a')][_0xd731('0x4f')](_0x34ce60);})['then'](function(_0x177246){_0x40717f[_0xd731('0x50')]=_0x177246;return _0x40717f;})[_0xd731('0x33')](respondWithFilteredResult(_0x191bfd,_0x34ce60))['catch'](handleError(_0x191bfd,null));};exports[_0xd731('0x51')]=function(_0xbcc702,_0x1bc4e2){var _0x7027dd={'raw':!![],'where':{'id':_0xbcc702[_0xd731('0x52')]['id']}},_0xd25614={};_0xd25614['model']=_[_0xd731('0x3e')](db[_0xd731('0x3a')][_0xd731('0x3b')]);_0xd25614[_0xd731('0x3f')]=_[_0xd731('0x3e')](_0xbcc702[_0xd731('0x3f')]);_0xd25614['filters']=_['intersection'](_0xd25614[_0xd731('0x42')],_0xd25614['query']);_0x7027dd[_0xd731('0x44')]=_['intersection'](_0xd25614['model'],qs[_0xd731('0x43')](_0xbcc702[_0xd731('0x3f')][_0xd731('0x43')]));_0x7027dd[_0xd731('0x44')]=_0x7027dd[_0xd731('0x44')][_0xd731('0x53')]?_0x7027dd['attributes']:_0xd25614['model'];if(_0xbcc702['query'][_0xd731('0x4e')]){_0x7027dd[_0xd731('0x54')]=[{'all':!![]}];}_0x7027dd=_['merge']({},_0x7027dd,_0xbcc702[_0xd731('0x4d')]);return db[_0xd731('0x3a')][_0xd731('0x55')](_0x7027dd)[_0xd731('0x33')](handleEntityNotFound(_0x1bc4e2,null))[_0xd731('0x33')](respondWithResult(_0x1bc4e2,null))[_0xd731('0x26')](handleError(_0x1bc4e2,null));};exports['update']=function(_0x28c633,_0x294121){if(_0x28c633[_0xd731('0x56')]['id']){delete _0x28c633['body']['id'];}return db[_0xd731('0x3a')][_0xd731('0x55')]({'where':{'id':_0x28c633[_0xd731('0x52')]['id']}})[_0xd731('0x33')](handleEntityNotFound(_0x294121,null))['then'](saveUpdates(_0x28c633['body'],null))[_0xd731('0x33')](respondWithResult(_0x294121,null))[_0xd731('0x26')](handleError(_0x294121,null));};exports['destroy']=function(_0x204676,_0x5c2cb1){return db[_0xd731('0x3a')]['find']({'where':{'id':_0x204676[_0xd731('0x52')]['id']}})['then'](handleEntityNotFound(_0x5c2cb1,null))['then'](removeEntity(_0x5c2cb1,null))[_0xd731('0x26')](handleError(_0x5c2cb1,null));};exports['describe']=function(_0xea4ca8,_0x1655ae){return db['MailMessage']['describe']()[_0xd731('0x33')](respondWithResult(_0x1655ae,null))['catch'](handleError(_0x1655ae,null));};exports['create']=function(_0x3ae42b,_0x469b44){return db[_0xd731('0x3a')]['create'](_0x3ae42b[_0xd731('0x56')])[_0xd731('0x33')](function(_0x35ce5d){if(_0x35ce5d){if(_0x35ce5d[_0xd731('0x57')]===_0xd731('0x58')&&!_0x35ce5d['secret']){var _0x4c5a67,_0x5dd447,_0x2b588c;if(_0x3ae42b[_0xd731('0x56')]['to']){_0x5dd447=_0x3ae42b[_0xd731('0x56')]['to']['split'](',')[0x0];}return db[_0xd731('0x59')][_0xd731('0x5a')]({'where':{'id':_0x35ce5d[_0xd731('0x5b')]},'include':[{'model':db[_0xd731('0x5c')],'as':_0xd731('0x5d'),'include':[{'model':db[_0xd731('0x5e')],'as':_0xd731('0x5f'),'where':{'email':_0x5dd447},'limit':0x1,'order':[['updatedAt',_0xd731('0x60')]]}]},{'model':db[_0xd731('0x61')],'as':'Smtp','raw':!![]}]})[_0xd731('0x33')](function(_0x236322){_0x4c5a67=_0x236322;if(_0x4c5a67&&_0x4c5a67[_0xd731('0x62')]){var _0x322393={'tls':{'rejectUnauthorized':![]}};if(_['isNil'](_0x4c5a67[_0xd731('0x62')][_0xd731('0x63')])){_0x322393[_0xd731('0x64')]=_0x4c5a67[_0xd731('0x62')][_0xd731('0x64')];_0x322393[_0xd731('0x65')]=_0x4c5a67[_0xd731('0x62')][_0xd731('0x65')];_0x322393['secure']=_0x4c5a67[_0xd731('0x62')][_0xd731('0x66')];if(_0x4c5a67['Smtp'][_0xd731('0x67')]){_0x322393[_0xd731('0x68')]={'user':_0x4c5a67[_0xd731('0x62')]['user'],'pass':_0x4c5a67[_0xd731('0x62')][_0xd731('0x69')]};}}else{_0x322393['service']=_0x4c5a67[_0xd731('0x62')][_0xd731('0x63')];_0x322393[_0xd731('0x68')]={'user':_0x4c5a67[_0xd731('0x62')][_0xd731('0x6a')],'pass':_0x4c5a67[_0xd731('0x62')][_0xd731('0x69')]};_0x322393['secure']=_0x4c5a67[_0xd731('0x62')]['secure'];}if(_0x3ae42b[_0xd731('0x56')][_0xd731('0x6b')]&&_0x3ae42b['body']['attachments'][_0xd731('0x53')]){for(var _0x3b676f=0x0;_0x3b676f<_0x3ae42b[_0xd731('0x56')][_0xd731('0x6b')][_0xd731('0x53')];_0x3b676f+=0x1){_0x3ae42b[_0xd731('0x56')][_0xd731('0x6b')][_0x3b676f]={'filename':_0x3ae42b[_0xd731('0x56')]['attachments'][_0x3b676f][_0xd731('0x36')],'path':path[_0xd731('0x6c')](config['root'],_0xd731('0x6d'),_0x3ae42b[_0xd731('0x56')][_0xd731('0x6b')][_0x3b676f]['basename'])};}}_0x2b588c={'account':_0x322393,'message':_0x3ae42b[_0xd731('0x56')]};return;}})[_0xd731('0x33')](function(){if(_0x4c5a67[_0xd731('0x5d')]){if(_0x4c5a67[_0xd731('0x5d')][_0xd731('0x5f')]['length']){return _0x4c5a67[_0xd731('0x5d')][_0xd731('0x5f')][0x0];}else{return db[_0xd731('0x5e')]['create'](_['defaults'](_0x3ae42b['body'],{'firstName':_0x3ae42b['body']['to'],'email':_0x3ae42b['body']['to'],'phone':_0x3ae42b[_0xd731('0x56')]['to'],'ListId':_0x4c5a67[_0xd731('0x6e')]}));}}else{throw new Error(_0xd731('0x6f'));}})[_0xd731('0x33')](function(){if(_0x2b588c){return respondWithRpcPromise(_0xd731('0x70'),'sendMail',_0x2b588c,client9003)['then'](function(_0x4b6741){return _0x35ce5d[_0xd731('0x31')]({'read':!![],'messageId':_0x4b6741[_0xd731('0x71')],'sentAt':moment()[_0xd731('0x72')]('YYYY-MM-DD\x20HH:mm:ss')});})['catch'](function(_0x2e6541){logger[_0xd731('0x23')]('%s',JSON[_0xd731('0x22')](_0x2e6541));return _0x35ce5d;});}return _0x35ce5d;});}return _0x35ce5d;}})[_0xd731('0x33')](respondWithResult(_0x469b44,0xc9))['catch'](handleError(_0x469b44,null));};var interaction_log=require(_0xd731('0x14'))(_0xd731('0x73'));exports[_0xd731('0x74')]=function(_0x1f4092,_0x1ee4ca,_0x431843){var _0x59230a={'channel':'mail'};if(_0x1f4092[_0xd731('0x56')]['id']){delete _0x1f4092[_0xd731('0x56')]['id'];}_0x1f4092['body']['read']=!![];_0x1f4092[_0xd731('0x56')]['readAt']=moment()[_0xd731('0x72')](_0xd731('0x75'));_0x1f4092[_0xd731('0x56')][_0xd731('0x76')]=_0x1f4092[_0xd731('0x56')][_0xd731('0x76')]||_0x1f4092[_0xd731('0x6a')]['id'];return db[_0xd731('0x3a')]['find']({'where':{'id':_0x1f4092[_0xd731('0x52')]['id'],'UserId':null},'include':[{'model':db['CmContact'],'as':_0xd731('0x77')}]})['then'](handleEntityNotFound(_0x1ee4ca,null))[_0xd731('0x33')](saveUpdates(_0x1f4092[_0xd731('0x56')],null))[_0xd731('0x33')](function(_0x4937c5){if(_0x4937c5){_0x59230a[_0xd731('0x25')]=_0x4937c5[_0xd731('0x78')]({'plain':!![]});return db[_0xd731('0x79')][_0xd731('0x55')]({'where':{'id':_0x4937c5['MailInteractionId']}});}return null;})[_0xd731('0x33')](handleEntityNotFound(_0x1ee4ca,null))[_0xd731('0x33')](function(_0x4928d5){if(_0x4928d5){return _0x4928d5[_0xd731('0x31')]({'UserId':_0x1f4092[_0xd731('0x56')][_0xd731('0x76')],'read1stAt':_[_0xd731('0x7a')](_0x4928d5[_0xd731('0x7b')])?moment()[_0xd731('0x72')]('YYYY-MM-DD\x20HH:mm:ss'):undefined});}return null;})[_0xd731('0x33')](function(_0x52cdd2){if(_0x52cdd2){_0x59230a[_0xd731('0x7c')]=_0x52cdd2[_0xd731('0x78')]({'plain':!![]});interaction_log[_0xd731('0x1e')]('[MAILMESSAGE:ACCEPT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s',_0x1f4092[_0xd731('0x6a')]['id'],_0x1f4092[_0xd731('0x6a')][_0xd731('0x36')],_0x1f4092['user']['role'],_0x59230a[_0xd731('0x7c')]['id'],_0x1f4092['body']?JSON[_0xd731('0x22')](_0x1f4092['body']):'null');return respondWithRpcPromise('AcceptMessage',_0xd731('0x7d'),_0x59230a);}return null;})['then'](function(_0x1fc19f){if(_0x1fc19f){if(_0x1f4092[_0xd731('0x56')][_0xd731('0x7e')]){_0x59230a['message'][_0xd731('0x7f')]=util[_0xd731('0x72')](_0xd731('0x80'),_0x1f4092[_0xd731('0x6a')][_0xd731('0x36')]);_0x59230a[_0xd731('0x25')][_0xd731('0x81')]=_0x59230a['channel'];_0x59230a[_0xd731('0x25')]['event']=_0xd731('0x74');return respondWithRpcPromise(_0xd731('0x82'),_0xd731('0x82'),{'event':_0xd731('0x83'),'message':_0x59230a[_0xd731('0x25')]},client9002)[_0xd731('0x33')](function(){return _0x59230a;});}return _0x59230a;}return null;})['then'](respondWithResult(_0x1ee4ca,null))['catch'](handleError(_0x1ee4ca,null));};var interaction_log=require('../../config/logger')(_0xd731('0x73'));exports['reject']=function(_0x3b8b20,_0x3eb513,_0x3afb7f){var _0x5ea03a={'agent':{},'channel':_0xd731('0x84')};if(_0x3b8b20[_0xd731('0x56')]['id']){delete _0x3b8b20[_0xd731('0x56')]['id'];}_0x3b8b20['body'][_0xd731('0x76')]=_0x3b8b20[_0xd731('0x56')][_0xd731('0x76')]||_0x3b8b20[_0xd731('0x6a')]['id'];_0x5ea03a['agent']['id']=_0x3b8b20['body']['UserId'];return db[_0xd731('0x3a')][_0xd731('0x55')]({'where':{'id':_0x3b8b20[_0xd731('0x52')]['id'],'UserId':null}})['then'](handleEntityNotFound(_0x3eb513,null))[_0xd731('0x33')](function(_0x156fd5){if(_0x156fd5){_0x5ea03a[_0xd731('0x25')]=_0x156fd5[_0xd731('0x78')]({'plain':!![]});return db[_0xd731('0x79')]['find']({'where':{'id':_0x156fd5[_0xd731('0x85')]}});}return null;})[_0xd731('0x33')](handleEntityNotFound(_0x3eb513,null))[_0xd731('0x33')](function(_0x2ec7a){if(_0x2ec7a){_0x5ea03a[_0xd731('0x7c')]=_0x2ec7a[_0xd731('0x78')]({'plain':!![]});interaction_log[_0xd731('0x1e')]('[MAILMESSAGE:REJECT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s',_0x3b8b20[_0xd731('0x6a')]['id'],_0x3b8b20[_0xd731('0x6a')][_0xd731('0x36')],_0x3b8b20['user']['role'],_0x5ea03a[_0xd731('0x7c')]['id'],_0x3b8b20['body']?JSON[_0xd731('0x22')](_0x3b8b20[_0xd731('0x56')]):_0xd731('0x86'));return respondWithRpcPromise(_0xd731('0x87'),_0xd731('0x88'),_0x5ea03a);}return null;})[_0xd731('0x33')](function(_0x1d8ea8){if(_0x1d8ea8){_0x1d8ea8[_0xd731('0x25')][_0xd731('0x7f')]=util[_0xd731('0x72')](_0xd731('0x80'),_0x3b8b20[_0xd731('0x6a')][_0xd731('0x36')]);_0x1d8ea8[_0xd731('0x25')][_0xd731('0x81')]=_0x5ea03a['channel'];_0x1d8ea8[_0xd731('0x25')][_0xd731('0x89')]=_0xd731('0x30');respondWithRpcPromise('EventManager',_0xd731('0x82'),{'event':'rejectmessage','message':_0x1d8ea8[_0xd731('0x25')]},client9002);return _0x5ea03a;}return null;})[_0xd731('0x33')](respondWithResult(_0x3eb513,null))[_0xd731('0x26')](handleError(_0x3eb513,null));};exports[_0xd731('0x8a')]=function(_0xf6ebe8,_0x57a436){var _0x148836=moment()[_0xd731('0x8b')]()['toString']();var _0x34c163=path[_0xd731('0x6c')](config[_0xd731('0x8c')],_0xd731('0x8d'),_0xd731('0x8e'),'tmp');var _0x2f335a=path[_0xd731('0x6c')](config[_0xd731('0x8c')],_0xd731('0x8d'),_0xd731('0x8e'),_0xd731('0x6b'));var _0x810ae=util['format'](_0xd731('0x8f'),_0x148836);return db[_0xd731('0x3a')][_0xd731('0x55')]({'where':{'id':_0xf6ebe8[_0xd731('0x52')]['id']},'attributes':['id','body',_0xd731('0x90'),'to','cc','bcc',_0xd731('0x91'),'createdAt'],'include':_0xf6ebe8[_0xd731('0x3f')]['attachments']?[{'model':db['Attachment'],'as':'Attachments'}]:undefined})[_0xd731('0x33')](handleEntityNotFound(_0x57a436,null))[_0xd731('0x33')](function(_0x3e5d01){if(_0x3e5d01){var _0x1c2b51=_0x3e5d01;var _0x210ed6={'from':_0x1c2b51[_0xd731('0x90')],'to':_0x1c2b51['to'],'subject':_0x1c2b51[_0xd731('0x91')],'html':_0x1c2b51['body'],'headers':{'Date':moment(_0x1c2b51[_0xd731('0x92')])['format']('ddd,\x20DD\x20MMM\x20YYYY\x20HH:mm:ss\x20ZZ')},'attachments':[]};if(_0x3e5d01['cc']){_0x210ed6[_0xd731('0x93')]['Cc']=_0x3e5d01['cc'];}if(_0x3e5d01['bcc']){_0x210ed6['headers']['Bcc']=_0x3e5d01[_0xd731('0x94')];}return new BPromise(function(_0x3c68ab,_0x4696da){if(_0x3e5d01[_0xd731('0x95')]){for(var _0x1e6ba9=0x0;_0x1e6ba9<_0x3e5d01[_0xd731('0x95')][_0xd731('0x53')];_0x1e6ba9++){var _0x4f8cd2=_0x3e5d01[_0xd731('0x95')][_0x1e6ba9];var _0x543242=path[_0xd731('0x6c')](_0x2f335a,_0x4f8cd2[_0xd731('0x96')]);if(fs[_0xd731('0x97')](_0x543242)){_0x210ed6[_0xd731('0x6b')]['push']({'name':_0x4f8cd2[_0xd731('0x36')],'contentType':_0x4f8cd2['type'],'data':fs[_0xd731('0x98')](_0x543242)});}}}emlformat[_0xd731('0x99')](_0x210ed6,function(_0x378efc,_0x3f869a){if(_0x378efc)return _0x4696da(_0x378efc);fs[_0xd731('0x9a')](path[_0xd731('0x6c')](_0x34c163,_0x810ae),_0x3f869a);return _0x3c68ab(_0x3f869a);});});}})['then'](function(_0x446e05){if(_0x446e05){return _0x57a436[_0xd731('0x8a')](path[_0xd731('0x6c')](_0x34c163,_0x810ae),_0x810ae,function(_0x566ce3){if(_0x566ce3){console[_0xd731('0x9b')](_0xd731('0x9c'),_0x566ce3);}else{fs[_0xd731('0x9d')](path['join'](_0x34c163,_0x810ae));}});}})[_0xd731('0x26')](handleError(_0x57a436,null));};
\ No newline at end of file
+var _0xbdb6=['format','../../config/logger','mail-interactions','accept','mail','read','readAt','UserId','Contact','get','MailInteraction','MailInteractionId','read1stAt','YYYY-MM-DD\x20HH:mm:ss','interaction','[MAILMESSAGE:ACCEPT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','AcceptMessage','acceptMessage','manual','interface','SIP/%s','channel','event','EventManager','acceptmessage','[MAILMESSAGE:REJECT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','role','RejectMessage','download','unix','toString','files','server','message-%s.eml','from','bcc','subject','createdAt','Attachments','ddd,\x20DD\x20MMM\x20YYYY\x20HH:mm:ss\x20ZZ','headers','existsSync','push','readFileSync','build','writeFileSync','log','err','unlinkSync','html-pdf','eml-format','zip-dir','request-promise','moment','bluebird','mustache','util','path','lodash','squel','crypto','desk.js','to-csv','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/utils','../../config/license/util','../../mysqldb','defaults','redis','localhost','socket.io-emitter','./mailMessage.socket','register','jayson/promise','http','client','MailMessage,\x20%s,\x20%s','debug','MailMessage,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','info','result','catch','json','count','offset','limit','status','set','Content-Range','apply','reject','save','then','destroy','end','sendStatus','stack','name','send','index','map','MailMessage','rawAttributes','fieldName','key','query','keys','filters','intersection','attributes','model','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','type','VIRTUAL','options','includeAll','include','findAll','rows','show','params','update','body','find','describe','create','split','MailAccount','MailAccountId','CmList','List','DESC','MailServerOut','Smtp','service','host','port','secure','auth','user','pass','attachments','join','root','server/files/attachments','basename','Contacts','CmContact','ListId','List\x20not\x20found','SendMail','sendMail','messageId'];(function(_0x2e89d5,_0x59778b){var _0x7c83a9=function(_0x396955){while(--_0x396955){_0x2e89d5['push'](_0x2e89d5['shift']());}};_0x7c83a9(++_0x59778b);}(_0xbdb6,0x189));var _0x6bdb=function(_0x4f5622,_0x413c6b){_0x4f5622=_0x4f5622-0x0;var _0xdd72d8=_0xbdb6[_0x4f5622];return _0xdd72d8;};'use strict';var pdf=require(_0x6bdb('0x0'));var emlformat=require(_0x6bdb('0x1'));var rimraf=require('rimraf');var zipdir=require(_0x6bdb('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0x6bdb('0x3'));var moment=require(_0x6bdb('0x4'));var BPromise=require(_0x6bdb('0x5'));var Mustache=require(_0x6bdb('0x6'));var util=require(_0x6bdb('0x7'));var path=require(_0x6bdb('0x8'));var sox=require('sox');var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var _=require(_0x6bdb('0x9'));var squel=require(_0x6bdb('0xa'));var crypto=require(_0x6bdb('0xb'));var jsforce=require('jsforce');var deskjs=require(_0x6bdb('0xc'));var toCsv=require(_0x6bdb('0xd'));var querystring=require(_0x6bdb('0xe'));var Papa=require('papaparse');var Redis=require(_0x6bdb('0xf'));var authService=require(_0x6bdb('0x10'));var qs=require(_0x6bdb('0x11'));var as=require(_0x6bdb('0x12'));var hardwareService=require(_0x6bdb('0x13'));var logger=require('../../config/logger')('api');var utils=require(_0x6bdb('0x14'));var config=require('../../config/environment');var licenseUtil=require(_0x6bdb('0x15'));var db=require(_0x6bdb('0x16'))['db'];config['redis']=_[_0x6bdb('0x17')](config[_0x6bdb('0x18')],{'host':_0x6bdb('0x19'),'port':0x18eb});var socket=require(_0x6bdb('0x1a'))(new Redis(config[_0x6bdb('0x18')]));require(_0x6bdb('0x1b'))[_0x6bdb('0x1c')](socket);var jayson=require(_0x6bdb('0x1d'));var client=jayson['client'][_0x6bdb('0x1e')]({'port':0x232c});var client9003=jayson[_0x6bdb('0x1f')][_0x6bdb('0x1e')]({'port':0x232b});var client9002=jayson[_0x6bdb('0x1f')][_0x6bdb('0x1e')]({'port':0x232a});function respondWithRpcPromise(_0x2b3c0c,_0x2e9942,_0x456b08,_0x28d677){return new BPromise(function(_0x28f3a8,_0x442d3b){var _0x3d18a7=_0x28d677||client;return _0x3d18a7['request'](_0x2b3c0c,_0x456b08)['then'](function(_0x28d66b){logger['info'](_0x6bdb('0x20'),_0x2e9942,'request\x20sent');logger[_0x6bdb('0x21')](_0x6bdb('0x22'),_0x2e9942,_0x6bdb('0x23'),JSON[_0x6bdb('0x24')](_0x28d66b));if(_0x28d66b[_0x6bdb('0x25')]){if(_0x28d66b[_0x6bdb('0x25')][_0x6bdb('0x26')]===0x1f4){logger['error'](_0x6bdb('0x20'),_0x2e9942,_0x28d66b['error'][_0x6bdb('0x27')]);return _0x442d3b(_0x28d66b[_0x6bdb('0x25')]['message']);}logger['error'](_0x6bdb('0x20'),_0x2e9942,_0x28d66b[_0x6bdb('0x25')][_0x6bdb('0x27')]);return _0x28f3a8(_0x28d66b['error']['message']);}else{logger[_0x6bdb('0x28')]('MailMessage,\x20%s,\x20%s',_0x2e9942,'request\x20sent');_0x28f3a8(_0x28d66b[_0x6bdb('0x29')][_0x6bdb('0x27')]);}})[_0x6bdb('0x2a')](function(_0x3aadf8){logger[_0x6bdb('0x25')](_0x6bdb('0x20'),_0x2e9942,_0x3aadf8);_0x442d3b(_0x3aadf8);});});}function respondWithStatusCode(_0x1f8cbb,_0x2318e0){_0x2318e0=_0x2318e0||0xcc;return function(_0x2c0b03){if(_0x2c0b03){return _0x1f8cbb['sendStatus'](_0x2318e0);}return _0x1f8cbb['status'](_0x2318e0)['end']();};}function respondWithResult(_0x3cc82f,_0x1becc9){_0x1becc9=_0x1becc9||0xc8;return function(_0x371cef){if(_0x371cef){return _0x3cc82f['status'](_0x1becc9)[_0x6bdb('0x2b')](_0x371cef);}};}function respondWithFilteredResult(_0x2d36fd,_0x5902f0){return function(_0xb3f63d){if(_0xb3f63d){var _0x1029bb=_0xb3f63d[_0x6bdb('0x2c')],_0x1e4845=_0x5902f0[_0x6bdb('0x2d')],_0x3f77f2=_0x5902f0['offset']+_0x5902f0[_0x6bdb('0x2e')],_0x445220;if(_0x3f77f2>=_0x1029bb){_0x3f77f2=_0x1029bb;_0x445220=0xc8;}else{_0x445220=0xce;}_0x2d36fd[_0x6bdb('0x2f')](_0x445220);return _0x2d36fd[_0x6bdb('0x30')](_0x6bdb('0x31'),_0x1e4845+'-'+_0x3f77f2+'/'+_0x1029bb)[_0x6bdb('0x2b')](_0xb3f63d);}return null;};}function patchUpdates(_0x957f91){return function(_0x3b9144){try{jsonpatch[_0x6bdb('0x32')](_0x3b9144,_0x957f91,!![]);}catch(_0x5f0c02){return BPromise[_0x6bdb('0x33')](_0x5f0c02);}return _0x3b9144[_0x6bdb('0x34')]();};}function saveUpdates(_0x6f63b9,_0x568e3b){return function(_0x2ebc59){if(_0x2ebc59){return _0x2ebc59['update'](_0x6f63b9)[_0x6bdb('0x35')](function(_0x238e58){return _0x238e58;});}return null;};}function removeEntity(_0x3a7b89,_0x400e8f){return function(_0x292d4b){if(_0x292d4b){return _0x292d4b[_0x6bdb('0x36')]()[_0x6bdb('0x35')](function(){_0x3a7b89[_0x6bdb('0x2f')](0xcc)[_0x6bdb('0x37')]();});}};}function handleEntityNotFound(_0x19ab4e,_0x35af9c){return function(_0x42c9c1){if(!_0x42c9c1){_0x19ab4e[_0x6bdb('0x38')](0x194);}return _0x42c9c1;};}function handleError(_0x550c7a,_0x46a890){_0x46a890=_0x46a890||0x1f4;return function(_0x445532){logger['error'](_0x445532[_0x6bdb('0x39')]);if(_0x445532[_0x6bdb('0x3a')]){delete _0x445532['name'];}_0x550c7a[_0x6bdb('0x2f')](_0x46a890)[_0x6bdb('0x3b')](_0x445532);};}exports[_0x6bdb('0x3c')]=function(_0x1fadee,_0x2e7020){var _0x2bfad0={},_0x1e3e46={},_0x3ea9d8={'count':0x0,'rows':[]};var _0x1b1c62=_[_0x6bdb('0x3d')](db[_0x6bdb('0x3e')][_0x6bdb('0x3f')],function(_0x549780){return{'name':_0x549780[_0x6bdb('0x40')],'type':_0x549780['type'][_0x6bdb('0x41')]};});_0x1e3e46['model']=_[_0x6bdb('0x3d')](_0x1b1c62,_0x6bdb('0x3a'));_0x1e3e46[_0x6bdb('0x42')]=_[_0x6bdb('0x43')](_0x1fadee[_0x6bdb('0x42')]);_0x1e3e46[_0x6bdb('0x44')]=_[_0x6bdb('0x45')](_0x1e3e46['model'],_0x1e3e46[_0x6bdb('0x42')]);_0x2bfad0[_0x6bdb('0x46')]=_[_0x6bdb('0x45')](_0x1e3e46[_0x6bdb('0x47')],qs['fields'](_0x1fadee[_0x6bdb('0x42')][_0x6bdb('0x48')]));_0x2bfad0['attributes']=_0x2bfad0[_0x6bdb('0x46')][_0x6bdb('0x49')]?_0x2bfad0['attributes']:_0x1e3e46[_0x6bdb('0x47')];if(!_0x1fadee['query'][_0x6bdb('0x4a')](_0x6bdb('0x4b'))){_0x2bfad0[_0x6bdb('0x2e')]=qs[_0x6bdb('0x2e')](_0x1fadee[_0x6bdb('0x42')]['limit']);_0x2bfad0['offset']=qs[_0x6bdb('0x2d')](_0x1fadee['query']['offset']);}_0x2bfad0[_0x6bdb('0x4c')]=qs[_0x6bdb('0x4d')](_0x1fadee[_0x6bdb('0x42')][_0x6bdb('0x4d')]);_0x2bfad0[_0x6bdb('0x4e')]=qs[_0x6bdb('0x44')](_[_0x6bdb('0x4f')](_0x1fadee[_0x6bdb('0x42')],_0x1e3e46[_0x6bdb('0x44')]),_0x1b1c62);if(_0x1fadee[_0x6bdb('0x42')][_0x6bdb('0x50')]){_0x2bfad0[_0x6bdb('0x4e')]=_[_0x6bdb('0x51')](_0x2bfad0[_0x6bdb('0x4e')],{'$or':_['map'](_0x1b1c62,function(_0x2e0e33){if(_0x2e0e33[_0x6bdb('0x52')]!==_0x6bdb('0x53')){var _0x2eb25b={};_0x2eb25b[_0x2e0e33['name']]={'$like':'%'+_0x1fadee[_0x6bdb('0x42')][_0x6bdb('0x50')]+'%'};return _0x2eb25b;}})});}_0x2bfad0=_['merge']({},_0x2bfad0,_0x1fadee[_0x6bdb('0x54')]);var _0xeb58f9={'where':_0x2bfad0[_0x6bdb('0x4e')]};return db[_0x6bdb('0x3e')][_0x6bdb('0x2c')](_0xeb58f9)['then'](function(_0x547177){_0x3ea9d8[_0x6bdb('0x2c')]=_0x547177;if(_0x1fadee[_0x6bdb('0x42')][_0x6bdb('0x55')]){_0x2bfad0[_0x6bdb('0x56')]=[{'all':!![]}];}return db['MailMessage'][_0x6bdb('0x57')](_0x2bfad0);})['then'](function(_0x54ca63){_0x3ea9d8[_0x6bdb('0x58')]=_0x54ca63;return _0x3ea9d8;})[_0x6bdb('0x35')](respondWithFilteredResult(_0x2e7020,_0x2bfad0))['catch'](handleError(_0x2e7020,null));};exports[_0x6bdb('0x59')]=function(_0xb69fcc,_0x4c9443){var _0x445cd5={'raw':!![],'where':{'id':_0xb69fcc[_0x6bdb('0x5a')]['id']}},_0x23fb89={};_0x23fb89['model']=_[_0x6bdb('0x43')](db['MailMessage'][_0x6bdb('0x3f')]);_0x23fb89[_0x6bdb('0x42')]=_[_0x6bdb('0x43')](_0xb69fcc[_0x6bdb('0x42')]);_0x23fb89[_0x6bdb('0x44')]=_['intersection'](_0x23fb89[_0x6bdb('0x47')],_0x23fb89[_0x6bdb('0x42')]);_0x445cd5[_0x6bdb('0x46')]=_[_0x6bdb('0x45')](_0x23fb89[_0x6bdb('0x47')],qs[_0x6bdb('0x48')](_0xb69fcc['query'][_0x6bdb('0x48')]));_0x445cd5[_0x6bdb('0x46')]=_0x445cd5['attributes'][_0x6bdb('0x49')]?_0x445cd5[_0x6bdb('0x46')]:_0x23fb89[_0x6bdb('0x47')];if(_0xb69fcc[_0x6bdb('0x42')][_0x6bdb('0x55')]){_0x445cd5[_0x6bdb('0x56')]=[{'all':!![]}];}_0x445cd5=_[_0x6bdb('0x51')]({},_0x445cd5,_0xb69fcc[_0x6bdb('0x54')]);return db[_0x6bdb('0x3e')]['find'](_0x445cd5)[_0x6bdb('0x35')](handleEntityNotFound(_0x4c9443,null))['then'](respondWithResult(_0x4c9443,null))[_0x6bdb('0x2a')](handleError(_0x4c9443,null));};exports[_0x6bdb('0x5b')]=function(_0x17a327,_0x42fb18){if(_0x17a327['body']['id']){delete _0x17a327[_0x6bdb('0x5c')]['id'];}return db[_0x6bdb('0x3e')]['find']({'where':{'id':_0x17a327['params']['id']}})['then'](handleEntityNotFound(_0x42fb18,null))[_0x6bdb('0x35')](saveUpdates(_0x17a327[_0x6bdb('0x5c')],null))[_0x6bdb('0x35')](respondWithResult(_0x42fb18,null))[_0x6bdb('0x2a')](handleError(_0x42fb18,null));};exports[_0x6bdb('0x36')]=function(_0xfe429,_0x28e32d){return db[_0x6bdb('0x3e')][_0x6bdb('0x5d')]({'where':{'id':_0xfe429[_0x6bdb('0x5a')]['id']}})[_0x6bdb('0x35')](handleEntityNotFound(_0x28e32d,null))['then'](removeEntity(_0x28e32d,null))[_0x6bdb('0x2a')](handleError(_0x28e32d,null));};exports[_0x6bdb('0x5e')]=function(_0x3f3cd5,_0x23b131){return db[_0x6bdb('0x3e')][_0x6bdb('0x5e')]()[_0x6bdb('0x35')](respondWithResult(_0x23b131,null))[_0x6bdb('0x2a')](handleError(_0x23b131,null));};exports['create']=function(_0x380ce0,_0x2be101){return db['MailMessage'][_0x6bdb('0x5f')](_0x380ce0['body'])[_0x6bdb('0x35')](function(_0x2b7e43){if(_0x2b7e43){if(_0x2b7e43['direction']==='out'&&!_0x2b7e43['secret']){var _0x13b2f4,_0x1c3099,_0x4357f9;if(_0x380ce0[_0x6bdb('0x5c')]['to']){_0x1c3099=_0x380ce0['body']['to'][_0x6bdb('0x60')](',')[0x0];}return db[_0x6bdb('0x61')]['findOne']({'where':{'id':_0x2b7e43[_0x6bdb('0x62')]},'include':[{'model':db[_0x6bdb('0x63')],'as':_0x6bdb('0x64'),'include':[{'model':db['CmContact'],'as':'Contacts','where':{'email':_0x1c3099},'limit':0x1,'order':[['updatedAt',_0x6bdb('0x65')]]}]},{'model':db[_0x6bdb('0x66')],'as':'Smtp','raw':!![]}]})[_0x6bdb('0x35')](function(_0x22440b){_0x13b2f4=_0x22440b;if(_0x13b2f4&&_0x13b2f4[_0x6bdb('0x67')]){var _0x3be356={'tls':{'rejectUnauthorized':![]}};if(_['isNil'](_0x13b2f4[_0x6bdb('0x67')][_0x6bdb('0x68')])){_0x3be356[_0x6bdb('0x69')]=_0x13b2f4[_0x6bdb('0x67')][_0x6bdb('0x69')];_0x3be356[_0x6bdb('0x6a')]=_0x13b2f4[_0x6bdb('0x67')][_0x6bdb('0x6a')];_0x3be356['secure']=_0x13b2f4[_0x6bdb('0x67')][_0x6bdb('0x6b')];if(_0x13b2f4[_0x6bdb('0x67')]['authentication']){_0x3be356[_0x6bdb('0x6c')]={'user':_0x13b2f4[_0x6bdb('0x67')]['user'],'pass':_0x13b2f4[_0x6bdb('0x67')]['pass']};}}else{_0x3be356['service']=_0x13b2f4[_0x6bdb('0x67')][_0x6bdb('0x68')];_0x3be356['auth']={'user':_0x13b2f4['Smtp'][_0x6bdb('0x6d')],'pass':_0x13b2f4[_0x6bdb('0x67')][_0x6bdb('0x6e')]};_0x3be356[_0x6bdb('0x6b')]=_0x13b2f4[_0x6bdb('0x67')]['secure'];}if(_0x380ce0[_0x6bdb('0x5c')]['attachments']&&_0x380ce0[_0x6bdb('0x5c')][_0x6bdb('0x6f')][_0x6bdb('0x49')]){for(var _0x41081f=0x0;_0x41081f<_0x380ce0[_0x6bdb('0x5c')][_0x6bdb('0x6f')][_0x6bdb('0x49')];_0x41081f+=0x1){_0x380ce0['body'][_0x6bdb('0x6f')][_0x41081f]={'filename':_0x380ce0['body'][_0x6bdb('0x6f')][_0x41081f][_0x6bdb('0x3a')],'path':path[_0x6bdb('0x70')](config[_0x6bdb('0x71')],_0x6bdb('0x72'),_0x380ce0['body'][_0x6bdb('0x6f')][_0x41081f][_0x6bdb('0x73')])};}}_0x4357f9={'account':_0x3be356,'message':_0x380ce0['body']};return;}})['then'](function(){if(_0x13b2f4[_0x6bdb('0x64')]){if(_0x13b2f4[_0x6bdb('0x64')][_0x6bdb('0x74')][_0x6bdb('0x49')]){return _0x13b2f4[_0x6bdb('0x64')]['Contacts'][0x0];}else{return db[_0x6bdb('0x75')][_0x6bdb('0x5f')](_['defaults'](_0x380ce0[_0x6bdb('0x5c')],{'firstName':_0x380ce0['body']['to'],'email':_0x380ce0[_0x6bdb('0x5c')]['to'],'phone':_0x380ce0[_0x6bdb('0x5c')]['to'],'ListId':_0x13b2f4[_0x6bdb('0x76')]}));}}else{throw new Error(_0x6bdb('0x77'));}})[_0x6bdb('0x35')](function(){if(_0x4357f9){return respondWithRpcPromise(_0x6bdb('0x78'),_0x6bdb('0x79'),_0x4357f9,client9003)['then'](function(_0xf9420d){return _0x2b7e43[_0x6bdb('0x5b')]({'read':!![],'messageId':_0xf9420d[_0x6bdb('0x7a')],'sentAt':moment()[_0x6bdb('0x7b')]('YYYY-MM-DD\x20HH:mm:ss')});})[_0x6bdb('0x2a')](function(_0x493db3){logger['error']('%s',JSON[_0x6bdb('0x24')](_0x493db3));return _0x2b7e43;});}return _0x2b7e43;});}return _0x2b7e43;}})['then'](respondWithResult(_0x2be101,0xc9))[_0x6bdb('0x2a')](handleError(_0x2be101,null));};var interaction_log=require(_0x6bdb('0x7c'))(_0x6bdb('0x7d'));exports[_0x6bdb('0x7e')]=function(_0x4713e6,_0x48109f,_0x3f90a4){var _0x172c13={'channel':_0x6bdb('0x7f')};if(_0x4713e6['body']['id']){delete _0x4713e6[_0x6bdb('0x5c')]['id'];}_0x4713e6[_0x6bdb('0x5c')][_0x6bdb('0x80')]=!![];_0x4713e6[_0x6bdb('0x5c')][_0x6bdb('0x81')]=moment()['format']('YYYY-MM-DD\x20HH:mm:ss');_0x4713e6[_0x6bdb('0x5c')][_0x6bdb('0x82')]=_0x4713e6[_0x6bdb('0x5c')][_0x6bdb('0x82')]||_0x4713e6[_0x6bdb('0x6d')]['id'];return db[_0x6bdb('0x3e')][_0x6bdb('0x5d')]({'where':{'id':_0x4713e6[_0x6bdb('0x5a')]['id'],'UserId':null},'include':[{'model':db[_0x6bdb('0x75')],'as':_0x6bdb('0x83')}]})['then'](handleEntityNotFound(_0x48109f,null))['then'](saveUpdates(_0x4713e6['body'],null))['then'](function(_0x448097){if(_0x448097){_0x172c13[_0x6bdb('0x27')]=_0x448097[_0x6bdb('0x84')]({'plain':!![]});return db[_0x6bdb('0x85')][_0x6bdb('0x5d')]({'where':{'id':_0x448097[_0x6bdb('0x86')]}});}return null;})[_0x6bdb('0x35')](handleEntityNotFound(_0x48109f,null))['then'](function(_0x4a4bd3){if(_0x4a4bd3){return _0x4a4bd3[_0x6bdb('0x5b')]({'UserId':_0x4713e6['body'][_0x6bdb('0x82')],'read1stAt':_['isNil'](_0x4a4bd3[_0x6bdb('0x87')])?moment()['format'](_0x6bdb('0x88')):undefined});}return null;})[_0x6bdb('0x35')](function(_0x18ae29){if(_0x18ae29){_0x172c13[_0x6bdb('0x89')]=_0x18ae29['get']({'plain':!![]});interaction_log['info'](_0x6bdb('0x8a'),_0x4713e6['user']['id'],_0x4713e6[_0x6bdb('0x6d')][_0x6bdb('0x3a')],_0x4713e6['user']['role'],_0x172c13[_0x6bdb('0x89')]['id'],_0x4713e6['body']?JSON[_0x6bdb('0x24')](_0x4713e6[_0x6bdb('0x5c')]):'null');return respondWithRpcPromise(_0x6bdb('0x8b'),_0x6bdb('0x8c'),_0x172c13);}return null;})[_0x6bdb('0x35')](function(_0x286138){if(_0x286138){if(_0x4713e6[_0x6bdb('0x5c')][_0x6bdb('0x8d')]){_0x172c13[_0x6bdb('0x27')][_0x6bdb('0x8e')]=util[_0x6bdb('0x7b')](_0x6bdb('0x8f'),_0x4713e6['user'][_0x6bdb('0x3a')]);_0x172c13['message'][_0x6bdb('0x90')]=_0x172c13[_0x6bdb('0x90')];_0x172c13['message'][_0x6bdb('0x91')]=_0x6bdb('0x7e');return respondWithRpcPromise(_0x6bdb('0x92'),_0x6bdb('0x92'),{'event':_0x6bdb('0x93'),'message':_0x172c13[_0x6bdb('0x27')]},client9002)['then'](function(){return _0x172c13;});}return _0x172c13;}return null;})[_0x6bdb('0x35')](respondWithResult(_0x48109f,null))[_0x6bdb('0x2a')](handleError(_0x48109f,null));};var interaction_log=require(_0x6bdb('0x7c'))(_0x6bdb('0x7d'));exports['reject']=function(_0x155b72,_0x438f7c,_0x18c6a8){var _0x5d2491={'agent':{},'channel':_0x6bdb('0x7f')};if(_0x155b72[_0x6bdb('0x5c')]['id']){delete _0x155b72['body']['id'];}_0x155b72['body'][_0x6bdb('0x82')]=_0x155b72[_0x6bdb('0x5c')][_0x6bdb('0x82')]||_0x155b72[_0x6bdb('0x6d')]['id'];_0x5d2491['agent']['id']=_0x155b72['body'][_0x6bdb('0x82')];return db[_0x6bdb('0x3e')][_0x6bdb('0x5d')]({'where':{'id':_0x155b72['params']['id'],'UserId':null}})['then'](handleEntityNotFound(_0x438f7c,null))['then'](function(_0x30c6f4){if(_0x30c6f4){_0x5d2491[_0x6bdb('0x27')]=_0x30c6f4[_0x6bdb('0x84')]({'plain':!![]});return db[_0x6bdb('0x85')][_0x6bdb('0x5d')]({'where':{'id':_0x30c6f4[_0x6bdb('0x86')]}});}return null;})[_0x6bdb('0x35')](handleEntityNotFound(_0x438f7c,null))['then'](function(_0x32d632){if(_0x32d632){_0x5d2491[_0x6bdb('0x89')]=_0x32d632[_0x6bdb('0x84')]({'plain':!![]});interaction_log[_0x6bdb('0x28')](_0x6bdb('0x94'),_0x155b72['user']['id'],_0x155b72['user'][_0x6bdb('0x3a')],_0x155b72[_0x6bdb('0x6d')][_0x6bdb('0x95')],_0x5d2491[_0x6bdb('0x89')]['id'],_0x155b72['body']?JSON[_0x6bdb('0x24')](_0x155b72[_0x6bdb('0x5c')]):'null');return respondWithRpcPromise(_0x6bdb('0x96'),'rejectMessage',_0x5d2491);}return null;})[_0x6bdb('0x35')](function(_0x285607){if(_0x285607){_0x285607[_0x6bdb('0x27')][_0x6bdb('0x8e')]=util[_0x6bdb('0x7b')](_0x6bdb('0x8f'),_0x155b72[_0x6bdb('0x6d')]['name']);_0x285607['message'][_0x6bdb('0x90')]=_0x5d2491[_0x6bdb('0x90')];_0x285607[_0x6bdb('0x27')][_0x6bdb('0x91')]=_0x6bdb('0x33');respondWithRpcPromise(_0x6bdb('0x92'),_0x6bdb('0x92'),{'event':'rejectmessage','message':_0x285607[_0x6bdb('0x27')]},client9002);return _0x5d2491;}return null;})[_0x6bdb('0x35')](respondWithResult(_0x438f7c,null))['catch'](handleError(_0x438f7c,null));};exports[_0x6bdb('0x97')]=function(_0x1c72d3,_0x56ef34){var _0x4751e4=moment()[_0x6bdb('0x98')]()[_0x6bdb('0x99')]();var _0x32f42e=path['join'](config[_0x6bdb('0x71')],'server',_0x6bdb('0x9a'),'tmp');var _0x55eaa4=path[_0x6bdb('0x70')](config[_0x6bdb('0x71')],_0x6bdb('0x9b'),_0x6bdb('0x9a'),_0x6bdb('0x6f'));var _0x16f3a3=util[_0x6bdb('0x7b')](_0x6bdb('0x9c'),_0x4751e4);return db[_0x6bdb('0x3e')][_0x6bdb('0x5d')]({'where':{'id':_0x1c72d3[_0x6bdb('0x5a')]['id']},'attributes':['id',_0x6bdb('0x5c'),_0x6bdb('0x9d'),'to','cc',_0x6bdb('0x9e'),_0x6bdb('0x9f'),_0x6bdb('0xa0')],'include':_0x1c72d3[_0x6bdb('0x42')][_0x6bdb('0x6f')]?[{'model':db['Attachment'],'as':_0x6bdb('0xa1')}]:undefined})[_0x6bdb('0x35')](handleEntityNotFound(_0x56ef34,null))[_0x6bdb('0x35')](function(_0x277b84){if(_0x277b84){var _0x299860=_0x277b84;var _0x51fcb1={'from':_0x299860[_0x6bdb('0x9d')],'to':_0x299860['to'],'subject':_0x299860[_0x6bdb('0x9f')],'html':_0x299860[_0x6bdb('0x5c')],'headers':{'Date':moment(_0x299860[_0x6bdb('0xa0')])[_0x6bdb('0x7b')](_0x6bdb('0xa2'))},'attachments':[]};if(_0x277b84['cc']){_0x51fcb1['headers']['Cc']=_0x277b84['cc'];}if(_0x277b84[_0x6bdb('0x9e')]){_0x51fcb1[_0x6bdb('0xa3')]['Bcc']=_0x277b84['bcc'];}return new BPromise(function(_0x3e62ca,_0x42b4b9){if(_0x277b84[_0x6bdb('0xa1')]){for(var _0x3dbad1=0x0;_0x3dbad1<_0x277b84['Attachments']['length'];_0x3dbad1++){var _0x4d986c=_0x277b84[_0x6bdb('0xa1')][_0x3dbad1];var _0x46c68b=path[_0x6bdb('0x70')](_0x55eaa4,_0x4d986c[_0x6bdb('0x73')]);if(fs[_0x6bdb('0xa4')](_0x46c68b)){_0x51fcb1[_0x6bdb('0x6f')][_0x6bdb('0xa5')]({'name':_0x4d986c[_0x6bdb('0x3a')],'contentType':_0x4d986c[_0x6bdb('0x52')],'data':fs[_0x6bdb('0xa6')](_0x46c68b)});}}}emlformat[_0x6bdb('0xa7')](_0x51fcb1,function(_0xe5cc4f,_0x15ac36){if(_0xe5cc4f)return _0x42b4b9(_0xe5cc4f);fs[_0x6bdb('0xa8')](path[_0x6bdb('0x70')](_0x32f42e,_0x16f3a3),_0x15ac36);return _0x3e62ca(_0x15ac36);});});}})[_0x6bdb('0x35')](function(_0x55d950){if(_0x55d950){return _0x56ef34['download'](path[_0x6bdb('0x70')](_0x32f42e,_0x16f3a3),_0x16f3a3,function(_0x19f963){if(_0x19f963){console[_0x6bdb('0xa9')](_0x6bdb('0xaa'),_0x19f963);}else{fs[_0x6bdb('0xab')](path[_0x6bdb('0x70')](_0x32f42e,_0x16f3a3));}});}})[_0x6bdb('0x2a')](handleError(_0x56ef34,null));};
\ No newline at end of file