Built motion from commit e02f907f.|2.6.14
[motion2.git] / server / api / mailMessage / mailMessage.controller.js
index 54333b6..0686117 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 _0x5d35=['SIP/%s','channel','motionChannel','event','fromString','EventManager','reject','[MAILMESSAGE:REJECT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','role','RejectMessage','rejectMessage','QueryTypes','email','rejectmessage','unix','files','tmp','message-%s.eml','from','Attachment','subject','decode','createdAt','headers','bcc','Bcc','Attachments','basename','existsSync','readFileSync','build','download','moment','bluebird','util','path','ioredis','html-to-text','../../components/parsers/qs','../../config/logger','api','../../config/environment','../../mysqldb','redis','localhost','socket.io-emitter','html-entities','./mailMessage.socket','register','jayson/promise','client','http','request','then','request\x20sent','debug','MailMessage,\x20%s,\x20%s,\x20%s','stringify','error','code','MailMessage,\x20%s,\x20%s','message','info','catch','status','json','offset','undefined','limit','count','set','Content-Range','update','destroy','sendStatus','stack','name','send','map','MailMessage','fieldName','type','key','model','keys','filters','intersection','query','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','VIRTUAL','merge','include','findAll','rows','params','rawAttributes','includeAll','options','find','body','describe','create','direction','out','secret','MailAccountId','CmList','List','CmContact','Contacts','updatedAt','MailServerOut','Smtp','CloudProvider','attachments','join','root','defaults','ListId','SendMail','sendMail','messageId','accept','mail','readAt','UserId','user','agent','get','MailInteraction','isNil','YYYY-MM-DD\x20HH:mm:ss','interaction','null','SELECT\x20*\x20FROM\x20cm_contacts\x20WHERE\x20id\x20=\x20','ContactId','sequelize','Sequelize','SELECT','User','fullname','internal','interface','format'];(function(_0x543904,_0x2fcefa){var _0x4f8749=function(_0x2ca7ae){while(--_0x2ca7ae){_0x543904['push'](_0x543904['shift']());}};_0x4f8749(++_0x2fcefa);}(_0x5d35,0x1eb));var _0x55d3=function(_0x320c42,_0x196ea6){_0x320c42=_0x320c42-0x0;var _0x1abf85=_0x5d35[_0x320c42];return _0x1abf85;};'use strict';var emlformat=require('eml-format');var moment=require(_0x55d3('0x0'));var BPromise=require(_0x55d3('0x1'));var util=require(_0x55d3('0x2'));var path=require(_0x55d3('0x3'));var fs=require('fs');var _=require('lodash');var Redis=require(_0x55d3('0x4'));var htmlToText=require(_0x55d3('0x5'));var qs=require(_0x55d3('0x6'));var logger=require(_0x55d3('0x7'))(_0x55d3('0x8'));var interaction_log=require(_0x55d3('0x7'))('mail-interactions');var config=require(_0x55d3('0x9'));var db=require(_0x55d3('0xa'))['db'];config[_0x55d3('0xb')]=_['defaults'](config[_0x55d3('0xb')],{'host':_0x55d3('0xc'),'port':0x18eb});var socket=require(_0x55d3('0xd'))(new Redis(config['redis']));var htmlEntities=require(_0x55d3('0xe'));require(_0x55d3('0xf'))[_0x55d3('0x10')](socket);var jayson=require(_0x55d3('0x11'));var client=jayson[_0x55d3('0x12')]['http']({'port':0x232c});var client9003=jayson[_0x55d3('0x12')]['http']({'port':0x232b});var client9002=jayson[_0x55d3('0x12')][_0x55d3('0x13')]({'port':0x232a});function respondWithRpcPromise(_0x18a338,_0x3a4d00,_0x48602f,_0x44dea2){return new BPromise(function(_0x1629e3,_0x59f5df){var _0x175fcc=_0x44dea2||client;return _0x175fcc[_0x55d3('0x14')](_0x18a338,_0x48602f)[_0x55d3('0x15')](function(_0x262abe){logger['info']('MailMessage,\x20%s,\x20%s',_0x3a4d00,_0x55d3('0x16'));logger[_0x55d3('0x17')](_0x55d3('0x18'),_0x3a4d00,_0x55d3('0x16'),JSON[_0x55d3('0x19')](_0x262abe));if(_0x262abe['error']){if(_0x262abe[_0x55d3('0x1a')][_0x55d3('0x1b')]===0x1f4){logger[_0x55d3('0x1a')](_0x55d3('0x1c'),_0x3a4d00,_0x262abe[_0x55d3('0x1a')][_0x55d3('0x1d')]);return _0x59f5df(_0x262abe['error'][_0x55d3('0x1d')]);}logger['error']('MailMessage,\x20%s,\x20%s',_0x3a4d00,_0x262abe[_0x55d3('0x1a')]['message']);return _0x1629e3(_0x262abe['error'][_0x55d3('0x1d')]);}else{logger[_0x55d3('0x1e')](_0x55d3('0x1c'),_0x3a4d00,_0x55d3('0x16'));_0x1629e3(_0x262abe['result'][_0x55d3('0x1d')]);}})[_0x55d3('0x1f')](function(_0x35fb38){logger['error'](_0x55d3('0x1c'),_0x3a4d00,_0x35fb38);_0x59f5df(_0x35fb38);});});}function respondWithResult(_0xf6a95e,_0x21c5cf){_0x21c5cf=_0x21c5cf||0xc8;return function(_0xf2fe02){if(_0xf2fe02){return _0xf6a95e[_0x55d3('0x20')](_0x21c5cf)[_0x55d3('0x21')](_0xf2fe02);}};}function respondWithFilteredResult(_0xd1c4d4,_0x21b4aa){return function(_0x6494bc){if(_0x6494bc){var _0x3cc42d=typeof _0x21b4aa[_0x55d3('0x22')]===_0x55d3('0x23')&&typeof _0x21b4aa[_0x55d3('0x24')]==='undefined';var _0x1974a0=_0x6494bc[_0x55d3('0x25')];var _0x598642=_0x3cc42d?0x0:_0x21b4aa['offset'];var _0x2d7661=_0x3cc42d?_0x6494bc['count']:_0x21b4aa[_0x55d3('0x22')]+_0x21b4aa[_0x55d3('0x24')];var _0x16c437;if(_0x2d7661>=_0x1974a0){_0x2d7661=_0x1974a0;_0x16c437=0xc8;}else{_0x16c437=0xce;}_0xd1c4d4[_0x55d3('0x20')](_0x16c437);return _0xd1c4d4[_0x55d3('0x26')](_0x55d3('0x27'),_0x598642+'-'+_0x2d7661+'/'+_0x1974a0)[_0x55d3('0x21')](_0x6494bc);}return null;};}function saveUpdates(_0x50c630){return function(_0x527a82){if(_0x527a82){return _0x527a82[_0x55d3('0x28')](_0x50c630)[_0x55d3('0x15')](function(_0x2a60ec){return _0x2a60ec;});}return null;};}function removeEntity(_0x430bf5){return function(_0x1e8392){if(_0x1e8392){return _0x1e8392[_0x55d3('0x29')]()[_0x55d3('0x15')](function(){_0x430bf5[_0x55d3('0x20')](0xcc)['end']();});}};}function handleEntityNotFound(_0x1c8a0c){return function(_0x1e7a83){if(!_0x1e7a83){_0x1c8a0c[_0x55d3('0x2a')](0x194);}return _0x1e7a83;};}function handleError(_0x3315cb,_0x179d07){_0x179d07=_0x179d07||0x1f4;return function(_0x3eae84){logger['error'](_0x3eae84[_0x55d3('0x2b')]);if(_0x3eae84[_0x55d3('0x2c')]){delete _0x3eae84[_0x55d3('0x2c')];}_0x3315cb[_0x55d3('0x20')](_0x179d07)[_0x55d3('0x2d')](_0x3eae84);};}exports['index']=function(_0x3990ca,_0x15a75d){var _0x21a0e8={},_0x2e779a={},_0x118687={'count':0x0,'rows':[]};var _0x4d7e0a=_[_0x55d3('0x2e')](db[_0x55d3('0x2f')]['rawAttributes'],function(_0x1a6067){return{'name':_0x1a6067[_0x55d3('0x30')],'type':_0x1a6067[_0x55d3('0x31')][_0x55d3('0x32')]};});_0x2e779a[_0x55d3('0x33')]=_[_0x55d3('0x2e')](_0x4d7e0a,_0x55d3('0x2c'));_0x2e779a['query']=_[_0x55d3('0x34')](_0x3990ca['query']);_0x2e779a[_0x55d3('0x35')]=_[_0x55d3('0x36')](_0x2e779a[_0x55d3('0x33')],_0x2e779a[_0x55d3('0x37')]);_0x21a0e8[_0x55d3('0x38')]=_[_0x55d3('0x36')](_0x2e779a['model'],qs[_0x55d3('0x39')](_0x3990ca[_0x55d3('0x37')][_0x55d3('0x39')]));_0x21a0e8[_0x55d3('0x38')]=_0x21a0e8['attributes'][_0x55d3('0x3a')]?_0x21a0e8['attributes']:_0x2e779a['model'];if(!_0x3990ca[_0x55d3('0x37')][_0x55d3('0x3b')](_0x55d3('0x3c'))){_0x21a0e8[_0x55d3('0x24')]=qs[_0x55d3('0x24')](_0x3990ca[_0x55d3('0x37')][_0x55d3('0x24')]);_0x21a0e8['offset']=qs[_0x55d3('0x22')](_0x3990ca[_0x55d3('0x37')][_0x55d3('0x22')]);}_0x21a0e8[_0x55d3('0x3d')]=qs[_0x55d3('0x3e')](_0x3990ca[_0x55d3('0x37')]['sort']);_0x21a0e8[_0x55d3('0x3f')]=qs[_0x55d3('0x35')](_[_0x55d3('0x40')](_0x3990ca[_0x55d3('0x37')],_0x2e779a[_0x55d3('0x35')]),_0x4d7e0a);if(_0x3990ca[_0x55d3('0x37')][_0x55d3('0x41')]){_0x21a0e8[_0x55d3('0x3f')]=_['merge'](_0x21a0e8[_0x55d3('0x3f')],{'$or':_['map'](_0x4d7e0a,function(_0x1027ce){if(_0x1027ce[_0x55d3('0x31')]!==_0x55d3('0x42')){var _0x4c0c4e={};_0x4c0c4e[_0x1027ce[_0x55d3('0x2c')]]={'$like':'%'+_0x3990ca[_0x55d3('0x37')][_0x55d3('0x41')]+'%'};return _0x4c0c4e;}})});}_0x21a0e8=_[_0x55d3('0x43')]({},_0x21a0e8,_0x3990ca['options']);var _0x409192={'where':_0x21a0e8[_0x55d3('0x3f')]};return db[_0x55d3('0x2f')][_0x55d3('0x25')](_0x409192)['then'](function(_0x34c999){_0x118687[_0x55d3('0x25')]=_0x34c999;if(_0x3990ca[_0x55d3('0x37')]['includeAll']){_0x21a0e8[_0x55d3('0x44')]=[{'all':!![]}];}return db['MailMessage'][_0x55d3('0x45')](_0x21a0e8);})[_0x55d3('0x15')](function(_0x2b4c1c){_0x118687[_0x55d3('0x46')]=_0x2b4c1c;return _0x118687;})[_0x55d3('0x15')](respondWithFilteredResult(_0x15a75d,_0x21a0e8))[_0x55d3('0x1f')](handleError(_0x15a75d,null));};exports['show']=function(_0x3eec5c,_0x472e7a){var _0x404d5e={'raw':!![],'where':{'id':_0x3eec5c[_0x55d3('0x47')]['id']}},_0x406353={};_0x406353[_0x55d3('0x33')]=_['keys'](db[_0x55d3('0x2f')][_0x55d3('0x48')]);_0x406353['query']=_[_0x55d3('0x34')](_0x3eec5c[_0x55d3('0x37')]);_0x406353[_0x55d3('0x35')]=_[_0x55d3('0x36')](_0x406353[_0x55d3('0x33')],_0x406353[_0x55d3('0x37')]);_0x404d5e[_0x55d3('0x38')]=_[_0x55d3('0x36')](_0x406353[_0x55d3('0x33')],qs[_0x55d3('0x39')](_0x3eec5c[_0x55d3('0x37')][_0x55d3('0x39')]));_0x404d5e[_0x55d3('0x38')]=_0x404d5e[_0x55d3('0x38')]['length']?_0x404d5e[_0x55d3('0x38')]:_0x406353[_0x55d3('0x33')];if(_0x3eec5c[_0x55d3('0x37')][_0x55d3('0x49')]){_0x404d5e[_0x55d3('0x44')]=[{'all':!![]}];}_0x404d5e=_['merge']({},_0x404d5e,_0x3eec5c[_0x55d3('0x4a')]);return db[_0x55d3('0x2f')][_0x55d3('0x4b')](_0x404d5e)['then'](handleEntityNotFound(_0x472e7a,null))[_0x55d3('0x15')](respondWithResult(_0x472e7a,null))[_0x55d3('0x1f')](handleError(_0x472e7a,null));};exports['update']=function(_0x308122,_0x2a9ff1){if(_0x308122[_0x55d3('0x4c')]['id']){delete _0x308122[_0x55d3('0x4c')]['id'];}return db[_0x55d3('0x2f')][_0x55d3('0x4b')]({'where':{'id':_0x308122[_0x55d3('0x47')]['id']}})[_0x55d3('0x15')](handleEntityNotFound(_0x2a9ff1,null))['then'](saveUpdates(_0x308122[_0x55d3('0x4c')],null))[_0x55d3('0x15')](respondWithResult(_0x2a9ff1,null))[_0x55d3('0x1f')](handleError(_0x2a9ff1,null));};exports[_0x55d3('0x29')]=function(_0x2a550c,_0xedb24a){return db[_0x55d3('0x2f')][_0x55d3('0x4b')]({'where':{'id':_0x2a550c[_0x55d3('0x47')]['id']}})[_0x55d3('0x15')](handleEntityNotFound(_0xedb24a,null))['then'](removeEntity(_0xedb24a,null))[_0x55d3('0x1f')](handleError(_0xedb24a,null));};exports[_0x55d3('0x4d')]=function(_0x3f964a,_0x52d08f){return db['MailMessage'][_0x55d3('0x4d')]()[_0x55d3('0x15')](respondWithResult(_0x52d08f,null))[_0x55d3('0x1f')](handleError(_0x52d08f,null));};exports[_0x55d3('0x4e')]=function(_0x50dd06,_0x5009d1){return db[_0x55d3('0x2f')][_0x55d3('0x4e')](_0x50dd06[_0x55d3('0x4c')])['then'](function(_0x2f9d61){if(_0x2f9d61){if(_0x2f9d61[_0x55d3('0x4f')]===_0x55d3('0x50')&&!_0x2f9d61[_0x55d3('0x51')]){var _0x4635a2,_0x2697b6,_0xbbfc02;if(_0x50dd06[_0x55d3('0x4c')]['to']){_0x2697b6=_0x50dd06['body']['to']['split'](',')[0x0];}return db['MailAccount']['findOne']({'where':{'id':_0x2f9d61[_0x55d3('0x52')]},'include':[{'model':db[_0x55d3('0x53')],'as':_0x55d3('0x54'),'include':[{'model':db[_0x55d3('0x55')],'as':_0x55d3('0x56'),'where':{'email':_0x2697b6},'limit':0x1,'order':[[_0x55d3('0x57'),'DESC']]}]},{'model':db[_0x55d3('0x58')],'as':_0x55d3('0x59'),'raw':!![],'include':[{'model':db[_0x55d3('0x5a')],'as':_0x55d3('0x5a'),'raw':!![]}]}]})[_0x55d3('0x15')](function(_0x56ea20){_0x4635a2=_0x56ea20;if(!_0x4635a2||!_0x4635a2[_0x55d3('0x59')])return;var _0x1aa40a=_0x4635a2['getSmtpOptions']();if(_0x50dd06['body']['attachments']&&_0x50dd06[_0x55d3('0x4c')][_0x55d3('0x5b')]['length']){for(var _0x4aeb93=0x0;_0x4aeb93<_0x50dd06[_0x55d3('0x4c')]['attachments'][_0x55d3('0x3a')];_0x4aeb93+=0x1){_0x50dd06[_0x55d3('0x4c')][_0x55d3('0x5b')][_0x4aeb93]={'filename':_0x50dd06['body']['attachments'][_0x4aeb93][_0x55d3('0x2c')],'path':path[_0x55d3('0x5c')](config[_0x55d3('0x5d')],'server/files/attachments',_0x50dd06[_0x55d3('0x4c')][_0x55d3('0x5b')][_0x4aeb93]['basename'])};}}_0xbbfc02={'account':_0x1aa40a,'message':_0x50dd06[_0x55d3('0x4c')]};return;})['then'](function(){if(_0x4635a2[_0x55d3('0x54')]){if(_0x4635a2['List'][_0x55d3('0x56')]['length']){return _0x4635a2[_0x55d3('0x54')]['Contacts'][0x0];}else{return db[_0x55d3('0x55')][_0x55d3('0x4e')](_[_0x55d3('0x5e')](_0x50dd06[_0x55d3('0x4c')],{'firstName':_0x50dd06[_0x55d3('0x4c')]['to'],'email':_0x50dd06['body']['to'],'phone':_0x50dd06[_0x55d3('0x4c')]['to'],'ListId':_0x4635a2[_0x55d3('0x5f')]}));}}else{throw new Error('List\x20not\x20found');}})['then'](function(){if(_0xbbfc02){return respondWithRpcPromise(_0x55d3('0x60'),_0x55d3('0x61'),_0xbbfc02,client9003)[_0x55d3('0x15')](function(_0x1e95cc){return _0x2f9d61['update']({'read':!![],'messageId':_0x1e95cc[_0x55d3('0x62')],'sentAt':moment()['format']('YYYY-MM-DD\x20HH:mm:ss')});})[_0x55d3('0x1f')](function(_0x2f91aa){logger['error']('%s',JSON[_0x55d3('0x19')](_0x2f91aa));return _0x2f9d61;});}return _0x2f9d61;});}return _0x2f9d61;}})[_0x55d3('0x15')](respondWithResult(_0x5009d1,0xc9))['catch'](handleError(_0x5009d1,null));};exports[_0x55d3('0x63')]=function(_0xec964a,_0xf54520){var _0x511ad7={'agent':{},'channel':_0x55d3('0x64')};if(_0xec964a[_0x55d3('0x4c')]['id']){delete _0xec964a[_0x55d3('0x4c')]['id'];}_0xec964a[_0x55d3('0x4c')]['read']=!![];_0xec964a['body'][_0x55d3('0x65')]=moment()['format']('YYYY-MM-DD\x20HH:mm:ss');_0xec964a[_0x55d3('0x4c')][_0x55d3('0x66')]=_0xec964a[_0x55d3('0x4c')]['UserId']||_0xec964a[_0x55d3('0x67')]['id'];_0x511ad7[_0x55d3('0x68')]['id']=_0xec964a['body'][_0x55d3('0x66')];return db[_0x55d3('0x2f')][_0x55d3('0x4b')]({'where':{'id':_0xec964a[_0x55d3('0x47')]['id'],'UserId':null}})[_0x55d3('0x15')](handleEntityNotFound(_0xf54520,null))['then'](saveUpdates(_0xec964a[_0x55d3('0x4c')],null))[_0x55d3('0x15')](function(_0x568ad3){if(_0x568ad3){_0x511ad7[_0x55d3('0x1d')]=_0x568ad3[_0x55d3('0x69')]({'plain':!![]});return db[_0x55d3('0x6a')][_0x55d3('0x4b')]({'where':{'id':_0x568ad3['MailInteractionId']}});}return null;})[_0x55d3('0x15')](handleEntityNotFound(_0xf54520,null))[_0x55d3('0x15')](function(_0x38c823){if(_0x38c823){return _0x38c823[_0x55d3('0x28')]({'UserId':_0xec964a[_0x55d3('0x4c')][_0x55d3('0x66')],'read1stAt':_[_0x55d3('0x6b')](_0x38c823['read1stAt'])?moment()['format'](_0x55d3('0x6c')):undefined});}return null;})[_0x55d3('0x15')](function(_0x4e2894){if(_0x4e2894){_0x511ad7[_0x55d3('0x6d')]=_0x4e2894[_0x55d3('0x69')]({'plain':!![]});interaction_log[_0x55d3('0x1e')]('[MAILMESSAGE:ACCEPT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s',_0xec964a[_0x55d3('0x67')]['id'],_0xec964a['user'][_0x55d3('0x2c')],_0xec964a[_0x55d3('0x67')]['role'],_0x511ad7[_0x55d3('0x6d')]['id'],_0xec964a[_0x55d3('0x4c')]?JSON[_0x55d3('0x19')](_0xec964a['body']):_0x55d3('0x6e'));return respondWithRpcPromise('AcceptMessage','acceptMessage',_0x511ad7);}return null;})['then'](function(_0xcbf01a){var _0x47bf0d=_0x55d3('0x6f')+_0xcbf01a['message'][_0x55d3('0x70')];return db[_0x55d3('0x71')]['query'](_0x47bf0d,{'type':db[_0x55d3('0x72')]['QueryTypes'][_0x55d3('0x73')],'raw':!![]})[_0x55d3('0x15')](function(_0x17320b){return _0x17320b;});})['then'](function(_0x27525d){if(_0x27525d){_0x511ad7[_0x55d3('0x1d')]['contact']=_0x27525d[0x0];if(!_0xec964a[_0x55d3('0x4c')][_0x55d3('0x66')])return;return db[_0x55d3('0x74')][_0x55d3('0x4b')]({'where':{'id':_0xec964a[_0x55d3('0x4c')][_0x55d3('0x66')],'role':_0x55d3('0x68')},'attributes':['id',_0x55d3('0x2c'),_0x55d3('0x75'),'email',_0x55d3('0x76')],'raw':!![]});}return null;})[_0x55d3('0x15')](function(_0x162e46){if(!_0x162e46)return null;_0x511ad7[_0x55d3('0x1d')][_0x55d3('0x68')]=_0x162e46;return _0x511ad7;})[_0x55d3('0x15')](function(_0x3b70c2){if(_0x3b70c2){if(_0xec964a[_0x55d3('0x4c')]['manual']){_0x511ad7[_0x55d3('0x1d')][_0x55d3('0x77')]=util[_0x55d3('0x78')](_0x55d3('0x79'),_0xec964a[_0x55d3('0x67')][_0x55d3('0x2c')]);_0x511ad7[_0x55d3('0x1d')][_0x55d3('0x7a')]=_0x511ad7[_0x55d3('0x7a')];_0x511ad7[_0x55d3('0x1d')][_0x55d3('0x7b')]=_0x511ad7[_0x55d3('0x7a')];_0x511ad7[_0x55d3('0x1d')][_0x55d3('0x7c')]=_0x55d3('0x63');_0x511ad7[_0x55d3('0x1d')][_0x55d3('0x4c')]=htmlToText[_0x55d3('0x7d')](_0x511ad7[_0x55d3('0x1d')][_0x55d3('0x4c')]);return respondWithRpcPromise('EventManager',_0x55d3('0x7e'),{'event':'acceptmessage','message':_0x511ad7[_0x55d3('0x1d')]},client9002)[_0x55d3('0x15')](function(){return _0x511ad7;});}return _0x511ad7;}return null;})[_0x55d3('0x15')](respondWithResult(_0xf54520,null))[_0x55d3('0x1f')](handleError(_0xf54520,null));};exports[_0x55d3('0x7f')]=function(_0x25292e,_0x43b400){var _0x5b7cf5={'agent':{},'channel':_0x55d3('0x64')};if(_0x25292e[_0x55d3('0x4c')]['id']){delete _0x25292e[_0x55d3('0x4c')]['id'];}_0x25292e['body'][_0x55d3('0x66')]=_0x25292e[_0x55d3('0x4c')][_0x55d3('0x66')]||_0x25292e[_0x55d3('0x67')]['id'];_0x5b7cf5[_0x55d3('0x68')]['id']=_0x25292e[_0x55d3('0x4c')][_0x55d3('0x66')];return db[_0x55d3('0x2f')]['find']({'where':{'id':_0x25292e[_0x55d3('0x47')]['id'],'UserId':null}})[_0x55d3('0x15')](handleEntityNotFound(_0x43b400,null))['then'](function(_0x53b130){if(_0x53b130){_0x5b7cf5[_0x55d3('0x1d')]=_0x53b130[_0x55d3('0x69')]({'plain':!![]});return db[_0x55d3('0x6a')]['find']({'where':{'id':_0x53b130['MailInteractionId']}});}return null;})['then'](handleEntityNotFound(_0x43b400,null))[_0x55d3('0x15')](function(_0x3b40e2){if(_0x3b40e2){_0x5b7cf5[_0x55d3('0x6d')]=_0x3b40e2[_0x55d3('0x69')]({'plain':!![]});interaction_log['info'](_0x55d3('0x80'),_0x25292e[_0x55d3('0x67')]['id'],_0x25292e[_0x55d3('0x67')][_0x55d3('0x2c')],_0x25292e[_0x55d3('0x67')][_0x55d3('0x81')],_0x5b7cf5['interaction']['id'],_0x25292e['body']?JSON[_0x55d3('0x19')](_0x25292e[_0x55d3('0x4c')]):_0x55d3('0x6e'));return respondWithRpcPromise(_0x55d3('0x82'),_0x55d3('0x83'),_0x5b7cf5);}return null;})[_0x55d3('0x15')](function(_0x3be8b5){var _0x1965ad=_0x55d3('0x6f')+_0x3be8b5[_0x55d3('0x1d')][_0x55d3('0x70')];return db[_0x55d3('0x71')]['query'](_0x1965ad,{'type':db[_0x55d3('0x72')][_0x55d3('0x84')]['SELECT'],'raw':!![]})[_0x55d3('0x15')](function(_0x25e260){return _0x25e260;});})[_0x55d3('0x15')](function(_0x2df4bc){if(_0x2df4bc){_0x5b7cf5[_0x55d3('0x1d')]['contact']=_0x2df4bc[0x0];if(!_0x25292e[_0x55d3('0x4c')][_0x55d3('0x66')])return;return db[_0x55d3('0x74')][_0x55d3('0x4b')]({'where':{'id':_0x25292e[_0x55d3('0x4c')]['UserId'],'role':_0x55d3('0x68')},'attributes':['id',_0x55d3('0x2c'),_0x55d3('0x75'),_0x55d3('0x85'),'internal'],'raw':!![]});}return null;})[_0x55d3('0x15')](function(_0x136e14){if(!_0x136e14)return null;_0x5b7cf5[_0x55d3('0x1d')]['agent']=_0x136e14;return _0x5b7cf5;})[_0x55d3('0x15')](function(_0x345c0b){if(_0x345c0b){_0x345c0b[_0x55d3('0x1d')][_0x55d3('0x77')]=util['format'](_0x55d3('0x79'),_0x25292e[_0x55d3('0x67')][_0x55d3('0x2c')]);_0x345c0b['message']['channel']=_0x5b7cf5[_0x55d3('0x7a')];_0x345c0b[_0x55d3('0x1d')]['motionChannel']=_0x5b7cf5[_0x55d3('0x7a')];_0x345c0b[_0x55d3('0x1d')][_0x55d3('0x7c')]='reject';_0x345c0b[_0x55d3('0x1d')][_0x55d3('0x4c')]=htmlToText[_0x55d3('0x7d')](_0x5b7cf5[_0x55d3('0x1d')][_0x55d3('0x4c')]);respondWithRpcPromise(_0x55d3('0x7e'),'EventManager',{'event':_0x55d3('0x86'),'message':_0x345c0b[_0x55d3('0x1d')]},client9002);return _0x5b7cf5;}return null;})[_0x55d3('0x15')](respondWithResult(_0x43b400,null))['catch'](handleError(_0x43b400,null));};exports['download']=function(_0x5bd898,_0x47d1a8){var _0x9384be=moment()[_0x55d3('0x87')]()['toString']();var _0x24ba6d=path[_0x55d3('0x5c')](config[_0x55d3('0x5d')],'server',_0x55d3('0x88'),_0x55d3('0x89'));var _0xefe693=path[_0x55d3('0x5c')](config['root'],'server',_0x55d3('0x88'),_0x55d3('0x5b'));var _0xac53d=util['format'](_0x55d3('0x8a'),_0x9384be);return db[_0x55d3('0x2f')][_0x55d3('0x4b')]({'where':{'id':_0x5bd898[_0x55d3('0x47')]['id']},'attributes':['id',_0x55d3('0x4c'),_0x55d3('0x8b'),'to','cc','bcc','subject','createdAt'],'include':_0x5bd898[_0x55d3('0x37')][_0x55d3('0x5b')]?[{'model':db[_0x55d3('0x8c')],'as':'Attachments'}]:undefined})[_0x55d3('0x15')](handleEntityNotFound(_0x47d1a8,null))[_0x55d3('0x15')](function(_0x1e6337){if(_0x1e6337){var _0x4e947d=_0x1e6337;var _0x154e20={'from':_0x4e947d[_0x55d3('0x8b')],'to':_0x4e947d['to'],'subject':_0x4e947d[_0x55d3('0x8d')],'html':htmlEntities[_0x55d3('0x8e')](_0x4e947d[_0x55d3('0x4c')]),'headers':{'Date':moment(_0x4e947d[_0x55d3('0x8f')])[_0x55d3('0x78')]('ddd,\x20DD\x20MMM\x20YYYY\x20HH:mm:ss\x20ZZ')},'attachments':[]};if(_0x1e6337['cc']){_0x154e20[_0x55d3('0x90')]['Cc']=_0x1e6337['cc'];}if(_0x1e6337[_0x55d3('0x91')]){_0x154e20['headers'][_0x55d3('0x92')]=_0x1e6337['bcc'];}return new BPromise(function(_0x14d575,_0x1cf61f){if(_0x1e6337[_0x55d3('0x93')]){for(var _0x3eaa05=0x0;_0x3eaa05<_0x1e6337['Attachments']['length'];_0x3eaa05++){var _0x1ceed=_0x1e6337[_0x55d3('0x93')][_0x3eaa05];var _0x582e28=path[_0x55d3('0x5c')](_0xefe693,_0x1ceed[_0x55d3('0x94')]);if(fs[_0x55d3('0x95')](_0x582e28)){_0x154e20['attachments']['push']({'name':_0x1ceed[_0x55d3('0x2c')],'contentType':_0x1ceed['type'],'data':fs[_0x55d3('0x96')](_0x582e28)});}}}emlformat[_0x55d3('0x97')](_0x154e20,function(_0x2d25f5,_0x36afb3){if(_0x2d25f5)return _0x1cf61f(_0x2d25f5);fs['writeFileSync'](path[_0x55d3('0x5c')](_0x24ba6d,_0xac53d),_0x36afb3);return _0x14d575(_0x36afb3);});});}})[_0x55d3('0x15')](function(_0x148c48){if(_0x148c48){return _0x47d1a8[_0x55d3('0x98')](path[_0x55d3('0x5c')](_0x24ba6d,_0xac53d),_0xac53d,function(_0x1bc9bc){if(!_0x1bc9bc)fs['unlinkSync'](path[_0x55d3('0x5c')](_0x24ba6d,_0xac53d));});}})[_0x55d3('0x1f')](handleError(_0x47d1a8,null));};
\ No newline at end of file