Built motion from commit e02f907f.|2.6.14
[motion2.git] / server / api / mailMessage / mailMessage.controller.js
index be34cbd..0686117 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xbd50=['user','pass','attachments','length','join','root','server/files/attachments','basename','List\x20not\x20found','SendMail','sendMail','mail-interactions','mail','read','readAt','YYYY-MM-DD\x20HH:mm:ss','UserId','CmContact','Contact','get','MailInteraction','MailInteractionId','read1stAt','format','interaction','info','[MAILMESSAGE:ACCEPT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','role','null','AcceptMessage','acceptMessage','manual','interface','SIP/%s','channel','event','accept','EventManager','acceptmessage','agent','RejectMessage','rejectMessage','rejectmessage','download','unix','toString','tmp','files','bcc','subject','createdAt','Attachment','Attachments','ddd,\x20DD\x20MMM\x20YYYY\x20HH:mm:ss\x20ZZ','headers','Bcc','existsSync','push','readFileSync','build','writeFileSync','unlinkSync','html-pdf','eml-format','rimraf','fast-json-patch','request-promise','moment','bluebird','mustache','to-csv','ejs','lodash','squel','crypto','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../mysqldb','defaults','redis','localhost','socket.io-emitter','./mailMessage.socket','register','jayson/promise','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','then','MailMessage,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','MailMessage,\x20%s,\x20%s','message','result','catch','sendStatus','status','end','json','count','offset','limit','set','apply','reject','save','update','destroy','stack','name','send','map','MailMessage','fieldName','type','key','model','query','keys','filters','intersection','fields','attributes','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','options','includeAll','include','findAll','rows','show','params','find','body','describe','create','direction','secret','split','MailAccount','findOne','MailAccountId','CmList','List','Contacts','updatedAt','DESC','Smtp','isNil','service','host','port','secure','authentication'];(function(_0x1c963d,_0x1d6da8){var _0x33cd38=function(_0x2c69a){while(--_0x2c69a){_0x1c963d['push'](_0x1c963d['shift']());}};_0x33cd38(++_0x1d6da8);}(_0xbd50,0x196));var _0x0bd5=function(_0x5894ee,_0x1bb6eb){_0x5894ee=_0x5894ee-0x0;var _0x40466a=_0xbd50[_0x5894ee];return _0x40466a;};'use strict';var pdf=require(_0x0bd5('0x0'));var emlformat=require(_0x0bd5('0x1'));var rimraf=require(_0x0bd5('0x2'));var zipdir=require('zip-dir');var jsonpatch=require(_0x0bd5('0x3'));var rp=require(_0x0bd5('0x4'));var moment=require(_0x0bd5('0x5'));var BPromise=require(_0x0bd5('0x6'));var Mustache=require(_0x0bd5('0x7'));var util=require('util');var path=require('path');var sox=require('sox');var csv=require(_0x0bd5('0x8'));var ejs=require(_0x0bd5('0x9'));var fs=require('fs');var _=require(_0x0bd5('0xa'));var squel=require(_0x0bd5('0xb'));var crypto=require(_0x0bd5('0xc'));var jsforce=require('jsforce');var deskjs=require('desk.js');var toCsv=require(_0x0bd5('0x8'));var querystring=require(_0x0bd5('0xd'));var Papa=require(_0x0bd5('0xe'));var Redis=require('ioredis');var authService=require(_0x0bd5('0xf'));var qs=require(_0x0bd5('0x10'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x0bd5('0x11'));var logger=require(_0x0bd5('0x12'))('api');var utils=require(_0x0bd5('0x13'));var config=require(_0x0bd5('0x14'));var db=require(_0x0bd5('0x15'))['db'];config['redis']=_[_0x0bd5('0x16')](config[_0x0bd5('0x17')],{'host':_0x0bd5('0x18'),'port':0x18eb});var socket=require(_0x0bd5('0x19'))(new Redis(config[_0x0bd5('0x17')]));require(_0x0bd5('0x1a'))[_0x0bd5('0x1b')](socket);var jayson=require(_0x0bd5('0x1c'));var client=jayson['client'][_0x0bd5('0x1d')]({'port':0x232c});var client9003=jayson[_0x0bd5('0x1e')]['http']({'port':0x232b});var client9002=jayson[_0x0bd5('0x1e')][_0x0bd5('0x1d')]({'port':0x232a});function checkPasswordPattern(_0x3a34e4,_0xc22553,_0x55d565){if(_0x55d565){var _0x14f32c=new RegExp(/(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[?!@#\$%\^&\*~\-_=+[{\]\}])(?=.{8,})/);if(_0x14f32c[_0x0bd5('0x1f')](_0xc22553)){return _0x3a34e4;}else{throw new db[(_0x0bd5('0x20'))][(_0x0bd5('0x21'))](_0x0bd5('0x22'));}}else{return _0x3a34e4;}}function respondWithRpcPromise(_0x23be38,_0xc58e12,_0x19fe20,_0x29fa4c){return new BPromise(function(_0x20c667,_0x27bc1e){var _0x415d8f=_0x29fa4c||client;return _0x415d8f[_0x0bd5('0x23')](_0x23be38,_0x19fe20)[_0x0bd5('0x24')](function(_0x527c37){logger['info']('MailMessage,\x20%s,\x20%s',_0xc58e12,'request\x20sent');logger['debug'](_0x0bd5('0x25'),_0xc58e12,_0x0bd5('0x26'),JSON[_0x0bd5('0x27')](_0x527c37));if(_0x527c37[_0x0bd5('0x28')]){if(_0x527c37[_0x0bd5('0x28')]['code']===0x1f4){logger[_0x0bd5('0x28')](_0x0bd5('0x29'),_0xc58e12,_0x527c37[_0x0bd5('0x28')]['message']);return _0x27bc1e(_0x527c37[_0x0bd5('0x28')]['message']);}logger['error'](_0x0bd5('0x29'),_0xc58e12,_0x527c37[_0x0bd5('0x28')][_0x0bd5('0x2a')]);return _0x20c667(_0x527c37['error'][_0x0bd5('0x2a')]);}else{logger['info'](_0x0bd5('0x29'),_0xc58e12,_0x0bd5('0x26'));_0x20c667(_0x527c37[_0x0bd5('0x2b')][_0x0bd5('0x2a')]);}})[_0x0bd5('0x2c')](function(_0x2023d5){logger[_0x0bd5('0x28')](_0x0bd5('0x29'),_0xc58e12,_0x2023d5);_0x27bc1e(_0x2023d5);});});}function respondWithStatusCode(_0x41c244,_0x4020ee){_0x4020ee=_0x4020ee||0xcc;return function(_0x15561b){if(_0x15561b){return _0x41c244[_0x0bd5('0x2d')](_0x4020ee);}return _0x41c244[_0x0bd5('0x2e')](_0x4020ee)[_0x0bd5('0x2f')]();};}function respondWithResult(_0x5e5a33,_0x461ae3){_0x461ae3=_0x461ae3||0xc8;return function(_0x19eb75){if(_0x19eb75){return _0x5e5a33['status'](_0x461ae3)[_0x0bd5('0x30')](_0x19eb75);}};}function respondWithFilteredResult(_0x8eccc9,_0x5d9d20){return function(_0x11f482){if(_0x11f482){var _0x1b7cf4=_0x11f482[_0x0bd5('0x31')],_0x28ab82=_0x5d9d20[_0x0bd5('0x32')],_0x25a35b=_0x5d9d20[_0x0bd5('0x32')]+_0x5d9d20[_0x0bd5('0x33')],_0x59683d;if(_0x25a35b>=_0x1b7cf4){_0x25a35b=_0x1b7cf4;_0x59683d=0xc8;}else{_0x59683d=0xce;}_0x8eccc9[_0x0bd5('0x2e')](_0x59683d);return _0x8eccc9[_0x0bd5('0x34')]('Content-Range',_0x28ab82+'-'+_0x25a35b+'/'+_0x1b7cf4)[_0x0bd5('0x30')](_0x11f482);}return null;};}function patchUpdates(_0x589ea2){return function(_0x398362){try{jsonpatch[_0x0bd5('0x35')](_0x398362,_0x589ea2,!![]);}catch(_0x444ddb){return BPromise[_0x0bd5('0x36')](_0x444ddb);}return _0x398362[_0x0bd5('0x37')]();};}function saveUpdates(_0x1c7010,_0x15e380){return function(_0x24f7d5){if(_0x24f7d5){return _0x24f7d5[_0x0bd5('0x38')](_0x1c7010)[_0x0bd5('0x24')](function(_0x1a735c){return _0x1a735c;});}return null;};}function removeEntity(_0x64d66d,_0x3cfb74){return function(_0x4c9a61){if(_0x4c9a61){return _0x4c9a61[_0x0bd5('0x39')]()[_0x0bd5('0x24')](function(){_0x64d66d['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x6b93ed,_0xdf1ef5){return function(_0x8a6edc){if(!_0x8a6edc){_0x6b93ed[_0x0bd5('0x2d')](0x194);}return _0x8a6edc;};}function handleError(_0x1dd2e1,_0x387e24){_0x387e24=_0x387e24||0x1f4;return function(_0x22c10c){logger[_0x0bd5('0x28')](_0x22c10c[_0x0bd5('0x3a')]);if(_0x22c10c[_0x0bd5('0x3b')]){delete _0x22c10c[_0x0bd5('0x3b')];}_0x1dd2e1[_0x0bd5('0x2e')](_0x387e24)[_0x0bd5('0x3c')](_0x22c10c);};}exports['index']=function(_0x109f54,_0x5b915c){var _0x369d23={},_0x2f17a1={},_0x30f9da={'count':0x0,'rows':[]};var _0x1fcc49=_[_0x0bd5('0x3d')](db[_0x0bd5('0x3e')]['rawAttributes'],function(_0x35b4b9){return{'name':_0x35b4b9[_0x0bd5('0x3f')],'type':_0x35b4b9[_0x0bd5('0x40')][_0x0bd5('0x41')]};});_0x2f17a1[_0x0bd5('0x42')]=_[_0x0bd5('0x3d')](_0x1fcc49,_0x0bd5('0x3b'));_0x2f17a1[_0x0bd5('0x43')]=_[_0x0bd5('0x44')](_0x109f54['query']);_0x2f17a1[_0x0bd5('0x45')]=_['intersection'](_0x2f17a1[_0x0bd5('0x42')],_0x2f17a1[_0x0bd5('0x43')]);_0x369d23['attributes']=_[_0x0bd5('0x46')](_0x2f17a1[_0x0bd5('0x42')],qs[_0x0bd5('0x47')](_0x109f54[_0x0bd5('0x43')][_0x0bd5('0x47')]));_0x369d23[_0x0bd5('0x48')]=_0x369d23[_0x0bd5('0x48')]['length']?_0x369d23['attributes']:_0x2f17a1[_0x0bd5('0x42')];if(!_0x109f54['query']['hasOwnProperty'](_0x0bd5('0x49'))){_0x369d23[_0x0bd5('0x33')]=qs['limit'](_0x109f54['query']['limit']);_0x369d23[_0x0bd5('0x32')]=qs['offset'](_0x109f54['query'][_0x0bd5('0x32')]);}_0x369d23[_0x0bd5('0x4a')]=qs['sort'](_0x109f54['query'][_0x0bd5('0x4b')]);_0x369d23[_0x0bd5('0x4c')]=qs[_0x0bd5('0x45')](_[_0x0bd5('0x4d')](_0x109f54['query'],_0x2f17a1[_0x0bd5('0x45')]),_0x1fcc49);if(_0x109f54[_0x0bd5('0x43')][_0x0bd5('0x4e')]){_0x369d23[_0x0bd5('0x4c')]=_[_0x0bd5('0x4f')](_0x369d23[_0x0bd5('0x4c')],{'$or':_['map'](_0x1fcc49,function(_0x36348a){if(_0x36348a[_0x0bd5('0x40')]!==_0x0bd5('0x50')){var _0x5cdfe6={};_0x5cdfe6[_0x36348a[_0x0bd5('0x3b')]]={'$like':'%'+_0x109f54[_0x0bd5('0x43')][_0x0bd5('0x4e')]+'%'};return _0x5cdfe6;}})});}_0x369d23=_['merge']({},_0x369d23,_0x109f54[_0x0bd5('0x51')]);var _0x45240c={'where':_0x369d23[_0x0bd5('0x4c')]};return db[_0x0bd5('0x3e')][_0x0bd5('0x31')](_0x45240c)['then'](function(_0x205569){_0x30f9da[_0x0bd5('0x31')]=_0x205569;if(_0x109f54['query'][_0x0bd5('0x52')]){_0x369d23[_0x0bd5('0x53')]=[{'all':!![]}];}return db[_0x0bd5('0x3e')][_0x0bd5('0x54')](_0x369d23);})[_0x0bd5('0x24')](function(_0x508aa8){_0x30f9da[_0x0bd5('0x55')]=_0x508aa8;return _0x30f9da;})[_0x0bd5('0x24')](respondWithFilteredResult(_0x5b915c,_0x369d23))['catch'](handleError(_0x5b915c,null));};exports[_0x0bd5('0x56')]=function(_0x5bee57,_0x3c3e9b){var _0x14b74b={'raw':!![],'where':{'id':_0x5bee57[_0x0bd5('0x57')]['id']}},_0x37dc86={};_0x37dc86['model']=_[_0x0bd5('0x44')](db['MailMessage']['rawAttributes']);_0x37dc86[_0x0bd5('0x43')]=_[_0x0bd5('0x44')](_0x5bee57[_0x0bd5('0x43')]);_0x37dc86['filters']=_[_0x0bd5('0x46')](_0x37dc86['model'],_0x37dc86[_0x0bd5('0x43')]);_0x14b74b[_0x0bd5('0x48')]=_[_0x0bd5('0x46')](_0x37dc86['model'],qs['fields'](_0x5bee57['query'][_0x0bd5('0x47')]));_0x14b74b[_0x0bd5('0x48')]=_0x14b74b[_0x0bd5('0x48')]['length']?_0x14b74b[_0x0bd5('0x48')]:_0x37dc86[_0x0bd5('0x42')];if(_0x5bee57['query'][_0x0bd5('0x52')]){_0x14b74b['include']=[{'all':!![]}];}_0x14b74b=_['merge']({},_0x14b74b,_0x5bee57[_0x0bd5('0x51')]);return db[_0x0bd5('0x3e')][_0x0bd5('0x58')](_0x14b74b)[_0x0bd5('0x24')](handleEntityNotFound(_0x3c3e9b,null))['then'](respondWithResult(_0x3c3e9b,null))[_0x0bd5('0x2c')](handleError(_0x3c3e9b,null));};exports[_0x0bd5('0x38')]=function(_0x3df0a0,_0x5cf2f2){if(_0x3df0a0[_0x0bd5('0x59')]['id']){delete _0x3df0a0[_0x0bd5('0x59')]['id'];}return db[_0x0bd5('0x3e')]['find']({'where':{'id':_0x3df0a0['params']['id']}})[_0x0bd5('0x24')](handleEntityNotFound(_0x5cf2f2,null))['then'](saveUpdates(_0x3df0a0[_0x0bd5('0x59')],null))[_0x0bd5('0x24')](respondWithResult(_0x5cf2f2,null))[_0x0bd5('0x2c')](handleError(_0x5cf2f2,null));};exports['destroy']=function(_0x9b0dc5,_0x43e3d1){return db[_0x0bd5('0x3e')][_0x0bd5('0x58')]({'where':{'id':_0x9b0dc5['params']['id']}})[_0x0bd5('0x24')](handleEntityNotFound(_0x43e3d1,null))[_0x0bd5('0x24')](removeEntity(_0x43e3d1,null))[_0x0bd5('0x2c')](handleError(_0x43e3d1,null));};exports[_0x0bd5('0x5a')]=function(_0xf545c2,_0x478faa){return db[_0x0bd5('0x3e')]['describe']()[_0x0bd5('0x24')](respondWithResult(_0x478faa,null))['catch'](handleError(_0x478faa,null));};exports['create']=function(_0x24c496,_0x55883d){return db[_0x0bd5('0x3e')][_0x0bd5('0x5b')](_0x24c496[_0x0bd5('0x59')])['then'](function(_0x4f7e86){if(_0x4f7e86){if(_0x4f7e86[_0x0bd5('0x5c')]==='out'&&!_0x4f7e86[_0x0bd5('0x5d')]){var _0x134504,_0x5eeb83,_0x460ebb;if(_0x24c496['body']['to']){_0x5eeb83=_0x24c496[_0x0bd5('0x59')]['to'][_0x0bd5('0x5e')](',')[0x0];}return db[_0x0bd5('0x5f')][_0x0bd5('0x60')]({'where':{'id':_0x4f7e86[_0x0bd5('0x61')]},'include':[{'model':db[_0x0bd5('0x62')],'as':_0x0bd5('0x63'),'include':[{'model':db['CmContact'],'as':_0x0bd5('0x64'),'where':{'email':_0x5eeb83},'limit':0x1,'order':[[_0x0bd5('0x65'),_0x0bd5('0x66')]]}]},{'model':db['MailServerOut'],'as':'Smtp','raw':!![]}]})[_0x0bd5('0x24')](function(_0x378586){_0x134504=_0x378586;if(_0x134504&&_0x134504[_0x0bd5('0x67')]){var _0x42dc72={'tls':{'rejectUnauthorized':![]}};if(_[_0x0bd5('0x68')](_0x134504[_0x0bd5('0x67')][_0x0bd5('0x69')])){_0x42dc72[_0x0bd5('0x6a')]=_0x134504[_0x0bd5('0x67')][_0x0bd5('0x6a')];_0x42dc72[_0x0bd5('0x6b')]=_0x134504[_0x0bd5('0x67')][_0x0bd5('0x6b')];_0x42dc72[_0x0bd5('0x6c')]=_0x134504[_0x0bd5('0x67')][_0x0bd5('0x6c')];if(_0x134504[_0x0bd5('0x67')][_0x0bd5('0x6d')]){_0x42dc72['auth']={'user':_0x134504[_0x0bd5('0x67')][_0x0bd5('0x6e')],'pass':_0x134504['Smtp'][_0x0bd5('0x6f')]};}}else{_0x42dc72['service']=_0x134504[_0x0bd5('0x67')][_0x0bd5('0x69')];_0x42dc72['auth']={'user':_0x134504[_0x0bd5('0x67')][_0x0bd5('0x6e')],'pass':_0x134504[_0x0bd5('0x67')][_0x0bd5('0x6f')]};_0x42dc72[_0x0bd5('0x6c')]=_0x134504[_0x0bd5('0x67')][_0x0bd5('0x6c')];}if(_0x24c496[_0x0bd5('0x59')][_0x0bd5('0x70')]&&_0x24c496['body'][_0x0bd5('0x70')][_0x0bd5('0x71')]){for(var _0x583835=0x0;_0x583835<_0x24c496[_0x0bd5('0x59')][_0x0bd5('0x70')]['length'];_0x583835+=0x1){_0x24c496[_0x0bd5('0x59')][_0x0bd5('0x70')][_0x583835]={'filename':_0x24c496['body'][_0x0bd5('0x70')][_0x583835]['name'],'path':path[_0x0bd5('0x72')](config[_0x0bd5('0x73')],_0x0bd5('0x74'),_0x24c496[_0x0bd5('0x59')][_0x0bd5('0x70')][_0x583835][_0x0bd5('0x75')])};}}_0x460ebb={'account':_0x42dc72,'message':_0x24c496[_0x0bd5('0x59')]};return;}})[_0x0bd5('0x24')](function(){if(_0x134504[_0x0bd5('0x63')]){if(_0x134504[_0x0bd5('0x63')][_0x0bd5('0x64')][_0x0bd5('0x71')]){return _0x134504[_0x0bd5('0x63')][_0x0bd5('0x64')][0x0];}else{return db['CmContact'][_0x0bd5('0x5b')](_[_0x0bd5('0x16')](_0x24c496[_0x0bd5('0x59')],{'firstName':_0x24c496[_0x0bd5('0x59')]['to'],'email':_0x24c496[_0x0bd5('0x59')]['to'],'phone':_0x24c496[_0x0bd5('0x59')]['to'],'ListId':_0x134504['ListId']}));}}else{throw new Error(_0x0bd5('0x76'));}})[_0x0bd5('0x24')](function(){if(_0x460ebb){return respondWithRpcPromise(_0x0bd5('0x77'),_0x0bd5('0x78'),_0x460ebb,client9003)[_0x0bd5('0x24')](function(_0x116e67){return _0x4f7e86[_0x0bd5('0x38')]({'read':!![],'messageId':_0x116e67['messageId'],'sentAt':moment()['format']('YYYY-MM-DD\x20HH:mm:ss')});})[_0x0bd5('0x2c')](function(_0x343658){logger[_0x0bd5('0x28')]('%s',JSON[_0x0bd5('0x27')](_0x343658));return _0x4f7e86;});}return _0x4f7e86;});}return _0x4f7e86;}})[_0x0bd5('0x24')](respondWithResult(_0x55883d,0xc9))['catch'](handleError(_0x55883d,null));};var interaction_log=require(_0x0bd5('0x12'))(_0x0bd5('0x79'));exports['accept']=function(_0x46edf6,_0x935f1c,_0x1a812e){var _0x3cdfa9={'channel':_0x0bd5('0x7a')};if(_0x46edf6[_0x0bd5('0x59')]['id']){delete _0x46edf6[_0x0bd5('0x59')]['id'];}_0x46edf6[_0x0bd5('0x59')][_0x0bd5('0x7b')]=!![];_0x46edf6[_0x0bd5('0x59')][_0x0bd5('0x7c')]=moment()['format'](_0x0bd5('0x7d'));_0x46edf6[_0x0bd5('0x59')][_0x0bd5('0x7e')]=_0x46edf6[_0x0bd5('0x59')][_0x0bd5('0x7e')]||_0x46edf6['user']['id'];return db[_0x0bd5('0x3e')][_0x0bd5('0x58')]({'where':{'id':_0x46edf6[_0x0bd5('0x57')]['id'],'UserId':null},'include':[{'model':db[_0x0bd5('0x7f')],'as':_0x0bd5('0x80')}]})[_0x0bd5('0x24')](handleEntityNotFound(_0x935f1c,null))[_0x0bd5('0x24')](saveUpdates(_0x46edf6[_0x0bd5('0x59')],null))[_0x0bd5('0x24')](function(_0x9acef6){if(_0x9acef6){_0x3cdfa9[_0x0bd5('0x2a')]=_0x9acef6[_0x0bd5('0x81')]({'plain':!![]});return db[_0x0bd5('0x82')][_0x0bd5('0x58')]({'where':{'id':_0x9acef6[_0x0bd5('0x83')]}});}return null;})[_0x0bd5('0x24')](handleEntityNotFound(_0x935f1c,null))[_0x0bd5('0x24')](function(_0x14653e){if(_0x14653e){return _0x14653e[_0x0bd5('0x38')]({'UserId':_0x46edf6['body']['UserId'],'read1stAt':_[_0x0bd5('0x68')](_0x14653e[_0x0bd5('0x84')])?moment()[_0x0bd5('0x85')](_0x0bd5('0x7d')):undefined});}return null;})[_0x0bd5('0x24')](function(_0x4f57fe){if(_0x4f57fe){_0x3cdfa9[_0x0bd5('0x86')]=_0x4f57fe[_0x0bd5('0x81')]({'plain':!![]});interaction_log[_0x0bd5('0x87')](_0x0bd5('0x88'),_0x46edf6[_0x0bd5('0x6e')]['id'],_0x46edf6['user'][_0x0bd5('0x3b')],_0x46edf6[_0x0bd5('0x6e')][_0x0bd5('0x89')],_0x3cdfa9[_0x0bd5('0x86')]['id'],_0x46edf6[_0x0bd5('0x59')]?JSON[_0x0bd5('0x27')](_0x46edf6[_0x0bd5('0x59')]):_0x0bd5('0x8a'));return respondWithRpcPromise(_0x0bd5('0x8b'),_0x0bd5('0x8c'),_0x3cdfa9);}return null;})[_0x0bd5('0x24')](function(_0x48a77d){if(_0x48a77d){if(_0x46edf6[_0x0bd5('0x59')][_0x0bd5('0x8d')]){_0x3cdfa9[_0x0bd5('0x2a')][_0x0bd5('0x8e')]=util[_0x0bd5('0x85')](_0x0bd5('0x8f'),_0x46edf6[_0x0bd5('0x6e')][_0x0bd5('0x3b')]);_0x3cdfa9['message'][_0x0bd5('0x90')]=_0x3cdfa9[_0x0bd5('0x90')];_0x3cdfa9[_0x0bd5('0x2a')][_0x0bd5('0x91')]=_0x0bd5('0x92');return respondWithRpcPromise(_0x0bd5('0x93'),_0x0bd5('0x93'),{'event':_0x0bd5('0x94'),'message':_0x3cdfa9[_0x0bd5('0x2a')]},client9002)[_0x0bd5('0x24')](function(){return _0x3cdfa9;});}return _0x3cdfa9;}return null;})[_0x0bd5('0x24')](respondWithResult(_0x935f1c,null))[_0x0bd5('0x2c')](handleError(_0x935f1c,null));};var interaction_log=require(_0x0bd5('0x12'))(_0x0bd5('0x79'));exports[_0x0bd5('0x36')]=function(_0x40b00c,_0x54ba20,_0x289ba4){var _0x331841={'agent':{},'channel':_0x0bd5('0x7a')};if(_0x40b00c[_0x0bd5('0x59')]['id']){delete _0x40b00c[_0x0bd5('0x59')]['id'];}_0x40b00c[_0x0bd5('0x59')][_0x0bd5('0x7e')]=_0x40b00c[_0x0bd5('0x59')][_0x0bd5('0x7e')]||_0x40b00c['user']['id'];_0x331841[_0x0bd5('0x95')]['id']=_0x40b00c[_0x0bd5('0x59')][_0x0bd5('0x7e')];return db['MailMessage'][_0x0bd5('0x58')]({'where':{'id':_0x40b00c[_0x0bd5('0x57')]['id'],'UserId':null}})[_0x0bd5('0x24')](handleEntityNotFound(_0x54ba20,null))[_0x0bd5('0x24')](function(_0x1e7d05){if(_0x1e7d05){_0x331841[_0x0bd5('0x2a')]=_0x1e7d05['get']({'plain':!![]});return db[_0x0bd5('0x82')]['find']({'where':{'id':_0x1e7d05[_0x0bd5('0x83')]}});}return null;})['then'](handleEntityNotFound(_0x54ba20,null))['then'](function(_0x236981){if(_0x236981){_0x331841[_0x0bd5('0x86')]=_0x236981[_0x0bd5('0x81')]({'plain':!![]});interaction_log[_0x0bd5('0x87')]('[MAILMESSAGE:REJECT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s',_0x40b00c[_0x0bd5('0x6e')]['id'],_0x40b00c[_0x0bd5('0x6e')]['name'],_0x40b00c[_0x0bd5('0x6e')][_0x0bd5('0x89')],_0x331841[_0x0bd5('0x86')]['id'],_0x40b00c[_0x0bd5('0x59')]?JSON[_0x0bd5('0x27')](_0x40b00c[_0x0bd5('0x59')]):_0x0bd5('0x8a'));return respondWithRpcPromise(_0x0bd5('0x96'),_0x0bd5('0x97'),_0x331841);}return null;})[_0x0bd5('0x24')](function(_0xdb91c0){if(_0xdb91c0){_0xdb91c0[_0x0bd5('0x2a')][_0x0bd5('0x8e')]=util[_0x0bd5('0x85')](_0x0bd5('0x8f'),_0x40b00c[_0x0bd5('0x6e')][_0x0bd5('0x3b')]);_0xdb91c0[_0x0bd5('0x2a')][_0x0bd5('0x90')]=_0x331841[_0x0bd5('0x90')];_0xdb91c0[_0x0bd5('0x2a')][_0x0bd5('0x91')]=_0x0bd5('0x36');respondWithRpcPromise(_0x0bd5('0x93'),_0x0bd5('0x93'),{'event':_0x0bd5('0x98'),'message':_0xdb91c0['message']},client9002);return _0x331841;}return null;})[_0x0bd5('0x24')](respondWithResult(_0x54ba20,null))['catch'](handleError(_0x54ba20,null));};exports[_0x0bd5('0x99')]=function(_0x467a37,_0x2d843a){var _0x3704be=moment()[_0x0bd5('0x9a')]()[_0x0bd5('0x9b')]();var _0x1fa5c7=path[_0x0bd5('0x72')](config[_0x0bd5('0x73')],'server','files',_0x0bd5('0x9c'));var _0x392bdc=path['join'](config[_0x0bd5('0x73')],'server',_0x0bd5('0x9d'),_0x0bd5('0x70'));var _0x240ed8=util[_0x0bd5('0x85')]('message-%s.eml',_0x3704be);return db[_0x0bd5('0x3e')][_0x0bd5('0x58')]({'where':{'id':_0x467a37[_0x0bd5('0x57')]['id']},'attributes':['id',_0x0bd5('0x59'),'from','to','cc',_0x0bd5('0x9e'),_0x0bd5('0x9f'),_0x0bd5('0xa0')],'include':_0x467a37[_0x0bd5('0x43')][_0x0bd5('0x70')]?[{'model':db[_0x0bd5('0xa1')],'as':_0x0bd5('0xa2')}]:undefined})[_0x0bd5('0x24')](handleEntityNotFound(_0x2d843a,null))[_0x0bd5('0x24')](function(_0x42a7b0){if(_0x42a7b0){var _0x2404c9=_0x42a7b0;var _0x1a79af={'from':_0x2404c9['from'],'to':_0x2404c9['to'],'subject':_0x2404c9[_0x0bd5('0x9f')],'html':_0x2404c9[_0x0bd5('0x59')],'headers':{'Date':moment(_0x2404c9[_0x0bd5('0xa0')])[_0x0bd5('0x85')](_0x0bd5('0xa3'))},'attachments':[]};if(_0x42a7b0['cc']){_0x1a79af[_0x0bd5('0xa4')]['Cc']=_0x42a7b0['cc'];}if(_0x42a7b0[_0x0bd5('0x9e')]){_0x1a79af[_0x0bd5('0xa4')][_0x0bd5('0xa5')]=_0x42a7b0[_0x0bd5('0x9e')];}return new BPromise(function(_0x2a05bc,_0x5f529b){if(_0x42a7b0[_0x0bd5('0xa2')]){for(var _0x571f2b=0x0;_0x571f2b<_0x42a7b0[_0x0bd5('0xa2')][_0x0bd5('0x71')];_0x571f2b++){var _0x427e68=_0x42a7b0['Attachments'][_0x571f2b];var _0x509e4d=path['join'](_0x392bdc,_0x427e68[_0x0bd5('0x75')]);if(fs[_0x0bd5('0xa6')](_0x509e4d)){_0x1a79af[_0x0bd5('0x70')][_0x0bd5('0xa7')]({'name':_0x427e68[_0x0bd5('0x3b')],'contentType':_0x427e68[_0x0bd5('0x40')],'data':fs[_0x0bd5('0xa8')](_0x509e4d)});}}}emlformat[_0x0bd5('0xa9')](_0x1a79af,function(_0x1c1b4d,_0x1117f2){if(_0x1c1b4d)return _0x5f529b(_0x1c1b4d);fs[_0x0bd5('0xaa')](path['join'](_0x1fa5c7,_0x240ed8),_0x1117f2);return _0x2a05bc(_0x1117f2);});});}})[_0x0bd5('0x24')](function(_0x27561e){if(_0x27561e){return _0x2d843a['download'](path['join'](_0x1fa5c7,_0x240ed8),_0x240ed8,function(_0x141787){if(_0x141787){console['log']('err',_0x141787);}else{fs[_0x0bd5('0xab')](path[_0x0bd5('0x72')](_0x1fa5c7,_0x240ed8));}});}})[_0x0bd5('0x2c')](handleError(_0x2d843a,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