Built motion from commit (unavailable).|2.5.6
[motion2.git] / server / api / mailMessage / mailMessage.controller.js
index 54333b6..fc3f8f7 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x69de=['updatedAt','DESC','Smtp','isNil','service','host','secure','authentication','auth','pass','user','attachments','root','server/files/attachments','defaults','ListId','List\x20not\x20found','SendMail','sendMail','format','YYYY-MM-DD\x20HH:mm:ss','mail-interactions','accept','read','readAt','UserId','MailInteraction','MailInteractionId','role','interaction','null','acceptMessage','manual','interface','SIP/%s','channel','event','EventManager','acceptmessage','agent','get','[MAILMESSAGE:REJECT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','RejectMessage','rejectMessage','download','files','tmp','join','server','message-%s.eml','bcc','subject','createdAt','Attachment','Attachments','ddd,\x20DD\x20MMM\x20YYYY\x20HH:mm:ss\x20ZZ','headers','Bcc','existsSync','readFileSync','build','log','err','unlinkSync','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','bluebird','util','path','sox','to-csv','crypto','jsforce','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../mysqldb','redis','localhost','socket.io-emitter','./mailMessage.socket','register','http','client','test','Sequelize','ValidationError','The\x20password\x20must\x20be\x20at\x20least\x208\x20characters\x20long\x20and\x20have\x201\x20lowercase\x20character,\x201\x20uppercase\x20character,\x201\x20number\x20and\x201\x20special\x20character\x20~!@#$%^&-_=+[{]}.','request','info','MailMessage,\x20%s,\x20%s','debug','MailMessage,\x20%s,\x20%s,\x20%s','stringify','error','code','message','request\x20sent','sendStatus','status','count','offset','set','Content-Range','apply','reject','save','update','destroy','then','end','stack','name','index','MailMessage','fieldName','type','key','map','keys','filters','model','attributes','intersection','fields','query','length','nolimit','limit','order','sort','pick','filter','where','options','includeAll','include','findAll','rows','catch','params','rawAttributes','merge','find','body','create','out','secret','split','MailAccount','findOne','CmList','List','CmContact','Contacts'];(function(_0x35c5a8,_0x8ecb48){var _0x34782c=function(_0x1b23ec){while(--_0x1b23ec){_0x35c5a8['push'](_0x35c5a8['shift']());}};_0x34782c(++_0x8ecb48);}(_0x69de,0xe5));var _0xe69d=function(_0x2067e9,_0x5e6a97){_0x2067e9=_0x2067e9-0x0;var _0x280ce4=_0x69de[_0x2067e9];return _0x280ce4;};'use strict';var pdf=require(_0xe69d('0x0'));var emlformat=require(_0xe69d('0x1'));var rimraf=require(_0xe69d('0x2'));var zipdir=require(_0xe69d('0x3'));var jsonpatch=require(_0xe69d('0x4'));var rp=require(_0xe69d('0x5'));var moment=require('moment');var BPromise=require(_0xe69d('0x6'));var Mustache=require('mustache');var util=require(_0xe69d('0x7'));var path=require(_0xe69d('0x8'));var sox=require(_0xe69d('0x9'));var csv=require(_0xe69d('0xa'));var ejs=require('ejs');var fs=require('fs');var _=require('lodash');var squel=require('squel');var crypto=require(_0xe69d('0xb'));var jsforce=require(_0xe69d('0xc'));var deskjs=require('desk.js');var toCsv=require(_0xe69d('0xa'));var querystring=require(_0xe69d('0xd'));var Papa=require(_0xe69d('0xe'));var Redis=require('ioredis');var authService=require(_0xe69d('0xf'));var qs=require(_0xe69d('0x10'));var as=require(_0xe69d('0x11'));var hardwareService=require(_0xe69d('0x12'));var logger=require(_0xe69d('0x13'))(_0xe69d('0x14'));var utils=require(_0xe69d('0x15'));var config=require('../../config/environment');var db=require(_0xe69d('0x16'))['db'];config[_0xe69d('0x17')]=_['defaults'](config[_0xe69d('0x17')],{'host':_0xe69d('0x18'),'port':0x18eb});var socket=require(_0xe69d('0x19'))(new Redis(config['redis']));require(_0xe69d('0x1a'))[_0xe69d('0x1b')](socket);var jayson=require('jayson/promise');var client=jayson['client'][_0xe69d('0x1c')]({'port':0x232c});var client9003=jayson[_0xe69d('0x1d')]['http']({'port':0x232b});var client9002=jayson[_0xe69d('0x1d')]['http']({'port':0x232a});function checkPasswordPattern(_0x3e47be,_0x55e26c,_0x4c9b43){if(_0x4c9b43){var _0x5e1ed0=new RegExp(/(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[?!@#\$%\^&\*~\-_=+[{\]\}])(?=.{8,})/);if(_0x5e1ed0[_0xe69d('0x1e')](_0x55e26c)){return _0x3e47be;}else{throw new db[(_0xe69d('0x1f'))][(_0xe69d('0x20'))](_0xe69d('0x21'));}}else{return _0x3e47be;}}function respondWithRpcPromise(_0xa7aca7,_0x1ea1cf,_0x181e29,_0x518d34){return new BPromise(function(_0x22e275,_0x51bd39){var _0x245276=_0x518d34||client;return _0x245276[_0xe69d('0x22')](_0xa7aca7,_0x181e29)['then'](function(_0x3c04d5){logger[_0xe69d('0x23')](_0xe69d('0x24'),_0x1ea1cf,'request\x20sent');logger[_0xe69d('0x25')](_0xe69d('0x26'),_0x1ea1cf,'request\x20sent',JSON[_0xe69d('0x27')](_0x3c04d5));if(_0x3c04d5[_0xe69d('0x28')]){if(_0x3c04d5[_0xe69d('0x28')][_0xe69d('0x29')]===0x1f4){logger['error']('MailMessage,\x20%s,\x20%s',_0x1ea1cf,_0x3c04d5[_0xe69d('0x28')][_0xe69d('0x2a')]);return _0x51bd39(_0x3c04d5['error'][_0xe69d('0x2a')]);}logger[_0xe69d('0x28')](_0xe69d('0x24'),_0x1ea1cf,_0x3c04d5[_0xe69d('0x28')][_0xe69d('0x2a')]);return _0x22e275(_0x3c04d5['error']['message']);}else{logger[_0xe69d('0x23')](_0xe69d('0x24'),_0x1ea1cf,_0xe69d('0x2b'));_0x22e275(_0x3c04d5['result'][_0xe69d('0x2a')]);}})['catch'](function(_0x38f076){logger[_0xe69d('0x28')](_0xe69d('0x24'),_0x1ea1cf,_0x38f076);_0x51bd39(_0x38f076);});});}function respondWithStatusCode(_0x4e6c4b,_0x4d7bfa){_0x4d7bfa=_0x4d7bfa||0xcc;return function(_0x360b8f){if(_0x360b8f){return _0x4e6c4b[_0xe69d('0x2c')](_0x4d7bfa);}return _0x4e6c4b[_0xe69d('0x2d')](_0x4d7bfa)['end']();};}function respondWithResult(_0x4c6885,_0xda55ec){_0xda55ec=_0xda55ec||0xc8;return function(_0x1ce893){if(_0x1ce893){return _0x4c6885['status'](_0xda55ec)['json'](_0x1ce893);}};}function respondWithFilteredResult(_0x23c4d4,_0x54223a){return function(_0x677e61){if(_0x677e61){var _0x2bc505=_0x677e61[_0xe69d('0x2e')],_0x20dc79=_0x54223a[_0xe69d('0x2f')],_0x40b2d4=_0x54223a[_0xe69d('0x2f')]+_0x54223a['limit'],_0x5491bb;if(_0x40b2d4>=_0x2bc505){_0x40b2d4=_0x2bc505;_0x5491bb=0xc8;}else{_0x5491bb=0xce;}_0x23c4d4['status'](_0x5491bb);return _0x23c4d4[_0xe69d('0x30')](_0xe69d('0x31'),_0x20dc79+'-'+_0x40b2d4+'/'+_0x2bc505)['json'](_0x677e61);}return null;};}function patchUpdates(_0x5eb1d8){return function(_0x4186a9){try{jsonpatch[_0xe69d('0x32')](_0x4186a9,_0x5eb1d8,!![]);}catch(_0x3e9eb1){return BPromise[_0xe69d('0x33')](_0x3e9eb1);}return _0x4186a9[_0xe69d('0x34')]();};}function saveUpdates(_0x3d134d,_0x16b178){return function(_0x244cad){if(_0x244cad){return _0x244cad[_0xe69d('0x35')](_0x3d134d)['then'](function(_0x394af1){return _0x394af1;});}return null;};}function removeEntity(_0x2b36f7,_0x216c05){return function(_0x62fd8){if(_0x62fd8){return _0x62fd8[_0xe69d('0x36')]()[_0xe69d('0x37')](function(){_0x2b36f7[_0xe69d('0x2d')](0xcc)[_0xe69d('0x38')]();});}};}function handleEntityNotFound(_0xbae508,_0x4ade55){return function(_0x599093){if(!_0x599093){_0xbae508[_0xe69d('0x2c')](0x194);}return _0x599093;};}function handleError(_0x5e38ee,_0x38ac37){_0x38ac37=_0x38ac37||0x1f4;return function(_0xd20f2e){logger[_0xe69d('0x28')](_0xd20f2e[_0xe69d('0x39')]);if(_0xd20f2e[_0xe69d('0x3a')]){delete _0xd20f2e['name'];}_0x5e38ee['status'](_0x38ac37)['send'](_0xd20f2e);};}exports[_0xe69d('0x3b')]=function(_0x5df7cd,_0x577cb5){var _0x2d606a={},_0x39a19d={},_0x1fd04d={'count':0x0,'rows':[]};var _0x371451=_['map'](db[_0xe69d('0x3c')]['rawAttributes'],function(_0x30a49b){return{'name':_0x30a49b[_0xe69d('0x3d')],'type':_0x30a49b[_0xe69d('0x3e')][_0xe69d('0x3f')]};});_0x39a19d['model']=_[_0xe69d('0x40')](_0x371451,_0xe69d('0x3a'));_0x39a19d['query']=_[_0xe69d('0x41')](_0x5df7cd['query']);_0x39a19d[_0xe69d('0x42')]=_['intersection'](_0x39a19d[_0xe69d('0x43')],_0x39a19d['query']);_0x2d606a[_0xe69d('0x44')]=_[_0xe69d('0x45')](_0x39a19d[_0xe69d('0x43')],qs[_0xe69d('0x46')](_0x5df7cd[_0xe69d('0x47')][_0xe69d('0x46')]));_0x2d606a[_0xe69d('0x44')]=_0x2d606a[_0xe69d('0x44')][_0xe69d('0x48')]?_0x2d606a[_0xe69d('0x44')]:_0x39a19d['model'];if(!_0x5df7cd['query']['hasOwnProperty'](_0xe69d('0x49'))){_0x2d606a[_0xe69d('0x4a')]=qs['limit'](_0x5df7cd[_0xe69d('0x47')][_0xe69d('0x4a')]);_0x2d606a[_0xe69d('0x2f')]=qs['offset'](_0x5df7cd[_0xe69d('0x47')][_0xe69d('0x2f')]);}_0x2d606a[_0xe69d('0x4b')]=qs[_0xe69d('0x4c')](_0x5df7cd['query'][_0xe69d('0x4c')]);_0x2d606a['where']=qs['filters'](_[_0xe69d('0x4d')](_0x5df7cd[_0xe69d('0x47')],_0x39a19d['filters']));if(_0x5df7cd[_0xe69d('0x47')][_0xe69d('0x4e')]){_0x2d606a[_0xe69d('0x4f')]=_['merge'](_0x2d606a['where'],{'$or':_[_0xe69d('0x40')](_0x371451,function(_0x1f218d){if(_0x1f218d[_0xe69d('0x3e')]!=='VIRTUAL'){var _0x28869f={};_0x28869f[_0x1f218d[_0xe69d('0x3a')]]={'$like':'%'+_0x5df7cd['query'][_0xe69d('0x4e')]+'%'};return _0x28869f;}})});}_0x2d606a=_['merge']({},_0x2d606a,_0x5df7cd[_0xe69d('0x50')]);var _0x3290aa={'where':_0x2d606a[_0xe69d('0x4f')]};return db[_0xe69d('0x3c')][_0xe69d('0x2e')](_0x3290aa)[_0xe69d('0x37')](function(_0x180953){_0x1fd04d[_0xe69d('0x2e')]=_0x180953;if(_0x5df7cd[_0xe69d('0x47')][_0xe69d('0x51')]){_0x2d606a[_0xe69d('0x52')]=[{'all':!![]}];}return db['MailMessage'][_0xe69d('0x53')](_0x2d606a);})[_0xe69d('0x37')](function(_0x2df85c){_0x1fd04d[_0xe69d('0x54')]=_0x2df85c;return _0x1fd04d;})['then'](respondWithFilteredResult(_0x577cb5,_0x2d606a))[_0xe69d('0x55')](handleError(_0x577cb5,null));};exports['show']=function(_0x4c9a60,_0x383e71){var _0x396f22={'raw':!![],'where':{'id':_0x4c9a60[_0xe69d('0x56')]['id']}},_0x1eb2be={};_0x1eb2be[_0xe69d('0x43')]=_[_0xe69d('0x41')](db[_0xe69d('0x3c')][_0xe69d('0x57')]);_0x1eb2be[_0xe69d('0x47')]=_[_0xe69d('0x41')](_0x4c9a60[_0xe69d('0x47')]);_0x1eb2be[_0xe69d('0x42')]=_['intersection'](_0x1eb2be[_0xe69d('0x43')],_0x1eb2be[_0xe69d('0x47')]);_0x396f22[_0xe69d('0x44')]=_['intersection'](_0x1eb2be[_0xe69d('0x43')],qs[_0xe69d('0x46')](_0x4c9a60[_0xe69d('0x47')][_0xe69d('0x46')]));_0x396f22[_0xe69d('0x44')]=_0x396f22[_0xe69d('0x44')][_0xe69d('0x48')]?_0x396f22[_0xe69d('0x44')]:_0x1eb2be[_0xe69d('0x43')];if(_0x4c9a60['query'][_0xe69d('0x51')]){_0x396f22['include']=[{'all':!![]}];}_0x396f22=_[_0xe69d('0x58')]({},_0x396f22,_0x4c9a60[_0xe69d('0x50')]);return db[_0xe69d('0x3c')][_0xe69d('0x59')](_0x396f22)[_0xe69d('0x37')](handleEntityNotFound(_0x383e71,null))[_0xe69d('0x37')](respondWithResult(_0x383e71,null))[_0xe69d('0x55')](handleError(_0x383e71,null));};exports[_0xe69d('0x35')]=function(_0x56df68,_0x5a7dfa){if(_0x56df68[_0xe69d('0x5a')]['id']){delete _0x56df68['body']['id'];}return db[_0xe69d('0x3c')][_0xe69d('0x59')]({'where':{'id':_0x56df68[_0xe69d('0x56')]['id']}})[_0xe69d('0x37')](handleEntityNotFound(_0x5a7dfa,null))[_0xe69d('0x37')](saveUpdates(_0x56df68[_0xe69d('0x5a')],null))[_0xe69d('0x37')](respondWithResult(_0x5a7dfa,null))[_0xe69d('0x55')](handleError(_0x5a7dfa,null));};exports[_0xe69d('0x36')]=function(_0x633ea7,_0x1505a8){return db[_0xe69d('0x3c')][_0xe69d('0x59')]({'where':{'id':_0x633ea7['params']['id']}})['then'](handleEntityNotFound(_0x1505a8,null))[_0xe69d('0x37')](removeEntity(_0x1505a8,null))[_0xe69d('0x55')](handleError(_0x1505a8,null));};exports['describe']=function(_0xaa44d8,_0x20c33a){return db[_0xe69d('0x3c')]['describe']()['then'](respondWithResult(_0x20c33a,null))[_0xe69d('0x55')](handleError(_0x20c33a,null));};exports[_0xe69d('0x5b')]=function(_0x538dfa,_0x4d1116){return db[_0xe69d('0x3c')][_0xe69d('0x5b')](_0x538dfa['body'])['then'](function(_0x49d7ac){if(_0x49d7ac){if(_0x49d7ac['direction']===_0xe69d('0x5c')&&!_0x49d7ac[_0xe69d('0x5d')]){var _0x166252,_0x4b28b0,_0x5071f1;if(_0x538dfa[_0xe69d('0x5a')]['to']){_0x4b28b0=_0x538dfa['body']['to'][_0xe69d('0x5e')](',')[0x0];}return db[_0xe69d('0x5f')][_0xe69d('0x60')]({'where':{'id':_0x49d7ac['MailAccountId']},'include':[{'model':db[_0xe69d('0x61')],'as':_0xe69d('0x62'),'include':[{'model':db[_0xe69d('0x63')],'as':_0xe69d('0x64'),'where':{'email':_0x4b28b0},'limit':0x1,'order':[[_0xe69d('0x65'),_0xe69d('0x66')]]}]},{'model':db['MailServerOut'],'as':_0xe69d('0x67'),'raw':!![]}]})[_0xe69d('0x37')](function(_0x207ca2){_0x166252=_0x207ca2;if(_0x166252&&_0x166252[_0xe69d('0x67')]){var _0x4e5861={'tls':{'rejectUnauthorized':![]}};if(_[_0xe69d('0x68')](_0x166252[_0xe69d('0x67')][_0xe69d('0x69')])){_0x4e5861[_0xe69d('0x6a')]=_0x166252['Smtp'][_0xe69d('0x6a')];_0x4e5861['port']=_0x166252[_0xe69d('0x67')]['port'];_0x4e5861[_0xe69d('0x6b')]=_0x166252[_0xe69d('0x67')][_0xe69d('0x6b')];if(_0x166252[_0xe69d('0x67')][_0xe69d('0x6c')]){_0x4e5861[_0xe69d('0x6d')]={'user':_0x166252['Smtp']['user'],'pass':_0x166252[_0xe69d('0x67')][_0xe69d('0x6e')]};}}else{_0x4e5861[_0xe69d('0x69')]=_0x166252[_0xe69d('0x67')][_0xe69d('0x69')];_0x4e5861[_0xe69d('0x6d')]={'user':_0x166252['Smtp'][_0xe69d('0x6f')],'pass':_0x166252['Smtp'][_0xe69d('0x6e')]};_0x4e5861[_0xe69d('0x6b')]=_0x166252[_0xe69d('0x67')][_0xe69d('0x6b')];}if(_0x538dfa['body']['attachments']&&_0x538dfa[_0xe69d('0x5a')][_0xe69d('0x70')]['length']){for(var _0x1a2fa6=0x0;_0x1a2fa6<_0x538dfa[_0xe69d('0x5a')][_0xe69d('0x70')]['length'];_0x1a2fa6+=0x1){_0x538dfa['body'][_0xe69d('0x70')][_0x1a2fa6]={'filename':_0x538dfa[_0xe69d('0x5a')]['attachments'][_0x1a2fa6][_0xe69d('0x3a')],'path':path['join'](config[_0xe69d('0x71')],_0xe69d('0x72'),_0x538dfa[_0xe69d('0x5a')][_0xe69d('0x70')][_0x1a2fa6]['basename'])};}}_0x5071f1={'account':_0x4e5861,'message':_0x538dfa[_0xe69d('0x5a')]};return;}})[_0xe69d('0x37')](function(){if(_0x166252[_0xe69d('0x62')]){if(_0x166252[_0xe69d('0x62')][_0xe69d('0x64')]['length']){return _0x166252[_0xe69d('0x62')][_0xe69d('0x64')][0x0];}else{return db[_0xe69d('0x63')]['create'](_[_0xe69d('0x73')](_0x538dfa[_0xe69d('0x5a')],{'firstName':_0x538dfa[_0xe69d('0x5a')]['to'],'email':_0x538dfa[_0xe69d('0x5a')]['to'],'phone':_0x538dfa[_0xe69d('0x5a')]['to'],'ListId':_0x166252[_0xe69d('0x74')]}));}}else{throw new Error(_0xe69d('0x75'));}})[_0xe69d('0x37')](function(){if(_0x5071f1){return respondWithRpcPromise(_0xe69d('0x76'),_0xe69d('0x77'),_0x5071f1,client9003)[_0xe69d('0x37')](function(_0x39a5e6){return _0x49d7ac['update']({'read':!![],'messageId':_0x39a5e6['messageId'],'sentAt':moment()[_0xe69d('0x78')](_0xe69d('0x79'))});})[_0xe69d('0x55')](function(_0x116ece){logger['error']('%s',JSON[_0xe69d('0x27')](_0x116ece));return _0x49d7ac;});}return _0x49d7ac;});}return _0x49d7ac;}})[_0xe69d('0x37')](respondWithResult(_0x4d1116,0xc9))[_0xe69d('0x55')](handleError(_0x4d1116,null));};var interaction_log=require(_0xe69d('0x13'))(_0xe69d('0x7a'));exports[_0xe69d('0x7b')]=function(_0x396d4b,_0x499dbf,_0x2b00f8){var _0x2720f1={'channel':'mail'};if(_0x396d4b[_0xe69d('0x5a')]['id']){delete _0x396d4b['body']['id'];}_0x396d4b[_0xe69d('0x5a')][_0xe69d('0x7c')]=!![];_0x396d4b[_0xe69d('0x5a')][_0xe69d('0x7d')]=moment()[_0xe69d('0x78')](_0xe69d('0x79'));_0x396d4b[_0xe69d('0x5a')]['UserId']=_0x396d4b['body'][_0xe69d('0x7e')]||_0x396d4b[_0xe69d('0x6f')]['id'];return db[_0xe69d('0x3c')][_0xe69d('0x59')]({'where':{'id':_0x396d4b[_0xe69d('0x56')]['id'],'UserId':null},'include':[{'model':db[_0xe69d('0x63')],'as':'Contact'}]})['then'](handleEntityNotFound(_0x499dbf,null))['then'](saveUpdates(_0x396d4b[_0xe69d('0x5a')],null))['then'](function(_0x23c0f2){if(_0x23c0f2){_0x2720f1[_0xe69d('0x2a')]=_0x23c0f2['get']({'plain':!![]});return db[_0xe69d('0x7f')]['find']({'where':{'id':_0x23c0f2[_0xe69d('0x80')]}});}return null;})['then'](handleEntityNotFound(_0x499dbf,null))['then'](function(_0x50bc93){if(_0x50bc93){return _0x50bc93[_0xe69d('0x35')]({'UserId':_0x396d4b[_0xe69d('0x5a')][_0xe69d('0x7e')],'read1stAt':_[_0xe69d('0x68')](_0x50bc93['read1stAt'])?moment()[_0xe69d('0x78')](_0xe69d('0x79')):undefined});}return null;})[_0xe69d('0x37')](function(_0x52ff86){if(_0x52ff86){_0x2720f1['interaction']=_0x52ff86['get']({'plain':!![]});interaction_log[_0xe69d('0x23')]('[MAILMESSAGE:ACCEPT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s',_0x396d4b[_0xe69d('0x6f')]['id'],_0x396d4b[_0xe69d('0x6f')][_0xe69d('0x3a')],_0x396d4b[_0xe69d('0x6f')][_0xe69d('0x81')],_0x2720f1[_0xe69d('0x82')]['id'],_0x396d4b[_0xe69d('0x5a')]?JSON[_0xe69d('0x27')](_0x396d4b[_0xe69d('0x5a')]):_0xe69d('0x83'));return respondWithRpcPromise('AcceptMessage',_0xe69d('0x84'),_0x2720f1);}return null;})[_0xe69d('0x37')](function(_0x3fe697){if(_0x3fe697){if(_0x396d4b[_0xe69d('0x5a')][_0xe69d('0x85')]){_0x2720f1[_0xe69d('0x2a')][_0xe69d('0x86')]=util[_0xe69d('0x78')](_0xe69d('0x87'),_0x396d4b[_0xe69d('0x6f')][_0xe69d('0x3a')]);_0x2720f1[_0xe69d('0x2a')]['channel']=_0x2720f1[_0xe69d('0x88')];_0x2720f1[_0xe69d('0x2a')][_0xe69d('0x89')]='accept';return respondWithRpcPromise(_0xe69d('0x8a'),'EventManager',{'event':_0xe69d('0x8b'),'message':_0x2720f1[_0xe69d('0x2a')]},client9002)[_0xe69d('0x37')](function(){return _0x2720f1;});}return _0x2720f1;}return null;})['then'](respondWithResult(_0x499dbf,null))[_0xe69d('0x55')](handleError(_0x499dbf,null));};var interaction_log=require(_0xe69d('0x13'))(_0xe69d('0x7a'));exports['reject']=function(_0x1a2ec4,_0x15dbab,_0x17015a){var _0xe57b9e={'agent':{},'channel':'mail'};if(_0x1a2ec4[_0xe69d('0x5a')]['id']){delete _0x1a2ec4[_0xe69d('0x5a')]['id'];}_0x1a2ec4[_0xe69d('0x5a')]['UserId']=_0x1a2ec4[_0xe69d('0x5a')][_0xe69d('0x7e')]||_0x1a2ec4['user']['id'];_0xe57b9e[_0xe69d('0x8c')]['id']=_0x1a2ec4[_0xe69d('0x5a')][_0xe69d('0x7e')];return db['MailMessage']['find']({'where':{'id':_0x1a2ec4[_0xe69d('0x56')]['id'],'UserId':null}})['then'](handleEntityNotFound(_0x15dbab,null))[_0xe69d('0x37')](function(_0x2827f7){if(_0x2827f7){_0xe57b9e[_0xe69d('0x2a')]=_0x2827f7[_0xe69d('0x8d')]({'plain':!![]});return db[_0xe69d('0x7f')][_0xe69d('0x59')]({'where':{'id':_0x2827f7[_0xe69d('0x80')]}});}return null;})[_0xe69d('0x37')](handleEntityNotFound(_0x15dbab,null))[_0xe69d('0x37')](function(_0x2e7d16){if(_0x2e7d16){_0xe57b9e[_0xe69d('0x82')]=_0x2e7d16[_0xe69d('0x8d')]({'plain':!![]});interaction_log['info'](_0xe69d('0x8e'),_0x1a2ec4[_0xe69d('0x6f')]['id'],_0x1a2ec4[_0xe69d('0x6f')][_0xe69d('0x3a')],_0x1a2ec4[_0xe69d('0x6f')]['role'],_0xe57b9e[_0xe69d('0x82')]['id'],_0x1a2ec4[_0xe69d('0x5a')]?JSON[_0xe69d('0x27')](_0x1a2ec4[_0xe69d('0x5a')]):_0xe69d('0x83'));return respondWithRpcPromise(_0xe69d('0x8f'),_0xe69d('0x90'),_0xe57b9e);}return null;})['then'](function(_0x295b6b){if(_0x295b6b){_0x295b6b[_0xe69d('0x2a')][_0xe69d('0x86')]=util[_0xe69d('0x78')](_0xe69d('0x87'),_0x1a2ec4[_0xe69d('0x6f')][_0xe69d('0x3a')]);_0x295b6b['message']['channel']=_0xe57b9e['channel'];_0x295b6b['message']['event']=_0xe69d('0x33');respondWithRpcPromise(_0xe69d('0x8a'),'EventManager',{'event':'rejectmessage','message':_0x295b6b['message']},client9002);return _0xe57b9e;}return null;})[_0xe69d('0x37')](respondWithResult(_0x15dbab,null))['catch'](handleError(_0x15dbab,null));};exports[_0xe69d('0x91')]=function(_0x502f8b,_0xaf5dbd){var _0x3b2b7d=moment()['unix']()['toString']();var _0x1e7df8=path['join'](config[_0xe69d('0x71')],'server',_0xe69d('0x92'),_0xe69d('0x93'));var _0x1e6a51=path[_0xe69d('0x94')](config[_0xe69d('0x71')],_0xe69d('0x95'),_0xe69d('0x92'),_0xe69d('0x70'));var _0x23c3af=util['format'](_0xe69d('0x96'),_0x3b2b7d);return db[_0xe69d('0x3c')][_0xe69d('0x59')]({'where':{'id':_0x502f8b[_0xe69d('0x56')]['id']},'attributes':['id','body','from','to','cc',_0xe69d('0x97'),_0xe69d('0x98'),_0xe69d('0x99')],'include':_0x502f8b['query']['attachments']?[{'model':db[_0xe69d('0x9a')],'as':_0xe69d('0x9b')}]:undefined})['then'](handleEntityNotFound(_0xaf5dbd,null))[_0xe69d('0x37')](function(_0x48c61a){if(_0x48c61a){var _0x3cbb54=_0x48c61a;var _0x22de35={'from':_0x3cbb54['from'],'to':_0x3cbb54['to'],'subject':_0x3cbb54[_0xe69d('0x98')],'html':_0x3cbb54[_0xe69d('0x5a')],'headers':{'Date':moment(_0x3cbb54['createdAt'])[_0xe69d('0x78')](_0xe69d('0x9c'))},'attachments':[]};if(_0x48c61a['cc']){_0x22de35[_0xe69d('0x9d')]['Cc']=_0x48c61a['cc'];}if(_0x48c61a[_0xe69d('0x97')]){_0x22de35[_0xe69d('0x9d')][_0xe69d('0x9e')]=_0x48c61a[_0xe69d('0x97')];}return new BPromise(function(_0x261fa3,_0x1427d9){if(_0x48c61a[_0xe69d('0x9b')]){for(var _0x26adeb=0x0;_0x26adeb<_0x48c61a['Attachments'][_0xe69d('0x48')];_0x26adeb++){var _0xb044c5=_0x48c61a[_0xe69d('0x9b')][_0x26adeb];var _0x1c7167=path[_0xe69d('0x94')](_0x1e6a51,_0xb044c5['basename']);if(fs[_0xe69d('0x9f')](_0x1c7167)){_0x22de35['attachments']['push']({'name':_0xb044c5[_0xe69d('0x3a')],'contentType':_0xb044c5[_0xe69d('0x3e')],'data':fs[_0xe69d('0xa0')](_0x1c7167)});}}}emlformat[_0xe69d('0xa1')](_0x22de35,function(_0x14a412,_0x1bc483){if(_0x14a412)return _0x1427d9(_0x14a412);fs['writeFileSync'](path[_0xe69d('0x94')](_0x1e7df8,_0x23c3af),_0x1bc483);return _0x261fa3(_0x1bc483);});});}})[_0xe69d('0x37')](function(_0xc748bb){if(_0xc748bb){return _0xaf5dbd['download'](path[_0xe69d('0x94')](_0x1e7df8,_0x23c3af),_0x23c3af,function(_0x2fdfc0){if(_0x2fdfc0){console[_0xe69d('0xa2')](_0xe69d('0xa3'),_0x2fdfc0);}else{fs[_0xe69d('0xa4')](path[_0xe69d('0x94')](_0x1e7df8,_0x23c3af));}});}})['catch'](handleError(_0xaf5dbd,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