Built motion from commit (unavailable).|2.4.4
[motion2.git] / server / api / mailAccount / mailAccount.controller.js
index 2f13d0d..ce933b1 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xae31=['updatedAt','DESC','from','%s\x20<%s>','attachments','join','root','server/files/attachments','basename','service','auth','secure','SendMail','sendMail','List\x20not\x20found','defaults','subject','attach','out','Messages','verifySmtp','VerifySmtp','Sequelize','ValidationError','You\x20can\x27t\x20remove\x20the\x20mail\x20service\x20account','addAgents','omit','spread','emit','userMailAccount:save','removeAgents','userMailAccount:remove','getAgents','eml-format','rimraf','zip-dir','fast-json-patch','moment','bluebird','mustache','sox','ejs','lodash','squel','crypto','desk.js','to-csv','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','redis','localhost','socket.io-emitter','./mailAccount.socket','register','jayson/promise','client','http','test','request','then','request\x20sent','debug','MailAccount,\x20%s,\x20%s,\x20%s','error','code','MailAccount,\x20%s,\x20%s','message','info','result','sendStatus','status','end','count','offset','limit','set','json','apply','save','update','destroy','MailAccounts','name','index','Smtp','mandatoryDispositionPause','MailAccount','rawAttributes','model','keys','query','filters','intersection','fields','attributes','nolimit','order','sort','where','pick','filter','merge','map','type','key','field','options','include','findAll','rows','catch','show','params','MailServerIn','Imap','MailServerOut','Pause','length','includeAll','find','body','describe','addDisposition','MailAccountId','create','getDispositions','findOne','hasOwnProperty','Disposition','removeDispositions','ids','addAnswer','CannedAnswer','getAnswers','removeAnswers','email','ListId','isNil','active','description','cservice','cauthentication','user','cuser','pass','cpassword','authentication','host','port','password','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','UserProfileSection','UserProfileResource','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','getImap','removeImap','getSmtp','addSmtp','removeSmtp','setSmtp','addInteraction','MailInteraction','Contact','User','Owner','internal','Tag','Tags','color','tag','addApplications','sequelize','transaction','MailApplication','findAndCountAll','getApplications','getMessages','MailMessage','$gte','format','YYYY-MM-DD\x20HH:mm:ss','split','CmList','List','CmContact','Contacts'];(function(_0x5b1072,_0x422d9f){var _0x352a6e=function(_0x4d1248){while(--_0x4d1248){_0x5b1072['push'](_0x5b1072['shift']());}};_0x352a6e(++_0x422d9f);}(_0xae31,0xe4));var _0x1ae3=function(_0x1e79b9,_0x223ef3){_0x1e79b9=_0x1e79b9-0x0;var _0x2c2d29=_0xae31[_0x1e79b9];return _0x2c2d29;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0x1ae3('0x0'));var rimraf=require(_0x1ae3('0x1'));var zipdir=require(_0x1ae3('0x2'));var jsonpatch=require(_0x1ae3('0x3'));var rp=require('request-promise');var moment=require(_0x1ae3('0x4'));var BPromise=require(_0x1ae3('0x5'));var Mustache=require(_0x1ae3('0x6'));var util=require('util');var path=require('path');var sox=require(_0x1ae3('0x7'));var csv=require('to-csv');var ejs=require(_0x1ae3('0x8'));var fs=require('fs');var _=require(_0x1ae3('0x9'));var squel=require(_0x1ae3('0xa'));var crypto=require(_0x1ae3('0xb'));var jsforce=require('jsforce');var deskjs=require(_0x1ae3('0xc'));var toCsv=require(_0x1ae3('0xd'));var querystring=require(_0x1ae3('0xe'));var Papa=require(_0x1ae3('0xf'));var Redis=require(_0x1ae3('0x10'));var authService=require(_0x1ae3('0x11'));var qs=require(_0x1ae3('0x12'));var hardwareService=require(_0x1ae3('0x13'));var logger=require(_0x1ae3('0x14'))(_0x1ae3('0x15'));var utils=require(_0x1ae3('0x16'));var config=require(_0x1ae3('0x17'));var db=require('../../mysqldb')['db'];config[_0x1ae3('0x18')]=_['defaults'](config[_0x1ae3('0x18')],{'host':_0x1ae3('0x19'),'port':0x18eb});var socket=require(_0x1ae3('0x1a'))(new Redis(config[_0x1ae3('0x18')]));require(_0x1ae3('0x1b'))[_0x1ae3('0x1c')](socket);var jayson=require(_0x1ae3('0x1d'));var client=jayson[_0x1ae3('0x1e')][_0x1ae3('0x1f')]({'port':0x232b});function checkPasswordPattern(_0xe68c3f,_0x48c728,_0x32890d){if(_0x32890d){var _0x126db5=new RegExp(/(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[?!@#\$%\^&\*~\-_=+[{\]\}])(?=.{8,})/);if(_0x126db5[_0x1ae3('0x20')](_0x48c728)){return _0xe68c3f;}else{throw new Error('The\x20password\x20must\x20be\x20at\x20least\x208\x20characters\x20long\x20and\x20have\x201\x20lowercase\x20character,\x201\x20uppercase\x20character,\x201\x20number\x20and\x201\x20special\x20character\x20~!@#$%^&-_=+[{]}.');}}else{return _0xe68c3f;}}function respondWithRpcPromise(_0x3b55b0,_0x5361c6,_0x434aee,_0x27b09a){return new BPromise(function(_0x469ba8,_0x59e6c4){var _0x403718=_0x27b09a||client;return _0x403718[_0x1ae3('0x21')](_0x3b55b0,_0x434aee)[_0x1ae3('0x22')](function(_0x440ab9){logger['info']('MailAccount,\x20%s,\x20%s',_0x5361c6,_0x1ae3('0x23'));logger[_0x1ae3('0x24')](_0x1ae3('0x25'),_0x5361c6,_0x1ae3('0x23'),JSON['stringify'](_0x440ab9));if(_0x440ab9[_0x1ae3('0x26')]){if(_0x440ab9[_0x1ae3('0x26')][_0x1ae3('0x27')]===0x1f4){logger[_0x1ae3('0x26')](_0x1ae3('0x28'),_0x5361c6,_0x440ab9['error']['message']);return _0x59e6c4(_0x440ab9[_0x1ae3('0x26')][_0x1ae3('0x29')]);}logger['error'](_0x1ae3('0x28'),_0x5361c6,_0x440ab9[_0x1ae3('0x26')][_0x1ae3('0x29')]);return _0x469ba8(_0x440ab9[_0x1ae3('0x26')][_0x1ae3('0x29')]);}else{logger[_0x1ae3('0x2a')](_0x1ae3('0x28'),_0x5361c6,_0x1ae3('0x23'));_0x469ba8(_0x440ab9[_0x1ae3('0x2b')][_0x1ae3('0x29')]);}})['catch'](function(_0x20140a){logger[_0x1ae3('0x26')](_0x1ae3('0x28'),_0x5361c6,_0x20140a);_0x59e6c4(_0x20140a);});});}function respondWithStatusCode(_0x4fa822,_0x2b575f){_0x2b575f=_0x2b575f||0xcc;return function(_0x19d77d){if(_0x19d77d){return _0x4fa822[_0x1ae3('0x2c')](_0x2b575f);}return _0x4fa822[_0x1ae3('0x2d')](_0x2b575f)[_0x1ae3('0x2e')]();};}function respondWithResult(_0x596ee2,_0x94ca54){_0x94ca54=_0x94ca54||0xc8;return function(_0x234801){if(_0x234801){return _0x596ee2[_0x1ae3('0x2d')](_0x94ca54)['json'](_0x234801);}};}function respondWithFilteredResult(_0x53eedd,_0x3cb444){return function(_0x3fd6db){if(_0x3fd6db){var _0x1d0073=_0x3fd6db[_0x1ae3('0x2f')],_0xaf72d=_0x3cb444[_0x1ae3('0x30')],_0x1cb1a3=_0x3cb444[_0x1ae3('0x30')]+_0x3cb444[_0x1ae3('0x31')],_0x5e3d14;if(_0x1cb1a3>=_0x1d0073){_0x1cb1a3=_0x1d0073;_0x5e3d14=0xc8;}else{_0x5e3d14=0xce;}_0x53eedd[_0x1ae3('0x2d')](_0x5e3d14);return _0x53eedd[_0x1ae3('0x32')]('Content-Range',_0xaf72d+'-'+_0x1cb1a3+'/'+_0x1d0073)[_0x1ae3('0x33')](_0x3fd6db);}return null;};}function patchUpdates(_0x89a13d){return function(_0x5e0037){try{jsonpatch[_0x1ae3('0x34')](_0x5e0037,_0x89a13d,!![]);}catch(_0x57bdec){return BPromise['reject'](_0x57bdec);}return _0x5e0037[_0x1ae3('0x35')]();};}function saveUpdates(_0x3e8ccb,_0x1ed2d8){return function(_0xf148a3){if(_0xf148a3){return _0xf148a3[_0x1ae3('0x36')](_0x3e8ccb)[_0x1ae3('0x22')](function(_0x38b544){return _0x38b544;});}return null;};}function removeEntity(_0x915242,_0x21c343){return function(_0x4e9451){if(_0x4e9451){return _0x4e9451[_0x1ae3('0x37')]()[_0x1ae3('0x22')](function(){var _0x7afc8f=_0x4e9451['get']({'plain':!![]});var _0x11b905=_0x1ae3('0x38');return db['UserProfileResource']['destroy']({'where':{'type':_0x11b905,'resourceId':_0x7afc8f['id']}})[_0x1ae3('0x22')](function(){return _0x4e9451;});})[_0x1ae3('0x22')](function(){_0x915242[_0x1ae3('0x2d')](0xcc)['end']();});}};}function handleEntityNotFound(_0x2f20a9,_0x2a2609){return function(_0x10f76c){if(!_0x10f76c){_0x2f20a9['sendStatus'](0x194);}return _0x10f76c;};}function handleError(_0x18c969,_0xd9b9ad){_0xd9b9ad=_0xd9b9ad||0x1f4;return function(_0x4d74d1){logger[_0x1ae3('0x26')](_0x4d74d1['stack']);if(_0x4d74d1['name']){delete _0x4d74d1[_0x1ae3('0x39')];}_0x18c969[_0x1ae3('0x2d')](_0xd9b9ad)['send'](_0x4d74d1);};}exports[_0x1ae3('0x3a')]=function(_0x52be1e,_0x403192){var _0x361eef={'include':[{'model':db['MailServerIn'],'as':'Imap'},{'model':db['MailServerOut'],'as':_0x1ae3('0x3b')},{'model':db['Pause'],'as':_0x1ae3('0x3c')}]},_0x5d26ca={},_0x50692f={'count':0x0,'rows':[]};var _0x3b76ab=db[_0x1ae3('0x3d')][_0x1ae3('0x3e')];_0x5d26ca[_0x1ae3('0x3f')]=_[_0x1ae3('0x40')](_0x3b76ab);_0x5d26ca[_0x1ae3('0x41')]=_[_0x1ae3('0x40')](_0x52be1e['query']);_0x5d26ca[_0x1ae3('0x42')]=_[_0x1ae3('0x43')](_0x5d26ca['model'],_0x5d26ca['query']);_0x361eef['attributes']=_['intersection'](_0x5d26ca['model'],qs['fields'](_0x52be1e[_0x1ae3('0x41')][_0x1ae3('0x44')]));_0x361eef[_0x1ae3('0x45')]=_0x361eef[_0x1ae3('0x45')]['length']?_0x361eef[_0x1ae3('0x45')]:_0x5d26ca[_0x1ae3('0x3f')];if(!_0x52be1e[_0x1ae3('0x41')]['hasOwnProperty'](_0x1ae3('0x46'))){_0x361eef[_0x1ae3('0x31')]=qs[_0x1ae3('0x31')](_0x52be1e[_0x1ae3('0x41')]['limit']);_0x361eef[_0x1ae3('0x30')]=qs[_0x1ae3('0x30')](_0x52be1e[_0x1ae3('0x41')]['offset']);}_0x361eef[_0x1ae3('0x47')]=qs[_0x1ae3('0x48')](_0x52be1e[_0x1ae3('0x41')][_0x1ae3('0x48')]);_0x361eef[_0x1ae3('0x49')]=qs[_0x1ae3('0x42')](_[_0x1ae3('0x4a')](_0x52be1e['query'],_0x5d26ca['filters']));if(_0x52be1e[_0x1ae3('0x41')][_0x1ae3('0x4b')]){_0x361eef[_0x1ae3('0x49')]=_[_0x1ae3('0x4c')](_0x361eef[_0x1ae3('0x49')],{'$or':_[_0x1ae3('0x4d')](_0x3b76ab,function(_0x490f97){if(_0x490f97[_0x1ae3('0x4e')][_0x1ae3('0x4f')]!=='VIRTUAL'){var _0x7e02f={};_0x7e02f[_0x490f97[_0x1ae3('0x50')]]={'$like':'%'+_0x52be1e[_0x1ae3('0x41')]['filter']+'%'};return _0x7e02f;}})});}_0x361eef=_[_0x1ae3('0x4c')]({},_0x361eef,_0x52be1e[_0x1ae3('0x51')]);var _0x33fd11={'where':_0x361eef['where']};return db[_0x1ae3('0x3d')][_0x1ae3('0x2f')](_0x33fd11)[_0x1ae3('0x22')](function(_0x206605){_0x50692f['count']=_0x206605;if(_0x52be1e['query']['includeAll']){_0x361eef[_0x1ae3('0x52')]=[{'all':!![]}];}return db['MailAccount'][_0x1ae3('0x53')](_0x361eef);})[_0x1ae3('0x22')](function(_0x2b1a68){_0x50692f[_0x1ae3('0x54')]=_0x2b1a68;return _0x50692f;})[_0x1ae3('0x22')](respondWithFilteredResult(_0x403192,_0x361eef))[_0x1ae3('0x55')](handleError(_0x403192,null));};exports[_0x1ae3('0x56')]=function(_0x1985d5,_0x5eb07a){var _0x4b4880={'raw':![],'where':{'id':_0x1985d5[_0x1ae3('0x57')]['id']},'include':[{'model':db[_0x1ae3('0x58')],'as':_0x1ae3('0x59')},{'model':db[_0x1ae3('0x5a')],'as':_0x1ae3('0x3b')},{'model':db[_0x1ae3('0x5b')],'as':'mandatoryDispositionPause'}]},_0x1a0e62={};_0x1a0e62[_0x1ae3('0x3f')]=_[_0x1ae3('0x40')](db[_0x1ae3('0x3d')][_0x1ae3('0x3e')]);_0x1a0e62[_0x1ae3('0x41')]=_[_0x1ae3('0x40')](_0x1985d5[_0x1ae3('0x41')]);_0x1a0e62['filters']=_[_0x1ae3('0x43')](_0x1a0e62[_0x1ae3('0x3f')],_0x1a0e62[_0x1ae3('0x41')]);_0x4b4880[_0x1ae3('0x45')]=_[_0x1ae3('0x43')](_0x1a0e62[_0x1ae3('0x3f')],qs[_0x1ae3('0x44')](_0x1985d5[_0x1ae3('0x41')]['fields']));_0x4b4880[_0x1ae3('0x45')]=_0x4b4880['attributes'][_0x1ae3('0x5c')]?_0x4b4880[_0x1ae3('0x45')]:_0x1a0e62[_0x1ae3('0x3f')];if(_0x1985d5[_0x1ae3('0x41')][_0x1ae3('0x5d')]){_0x4b4880[_0x1ae3('0x52')]=[{'all':!![]}];}_0x4b4880=_[_0x1ae3('0x4c')]({},_0x4b4880,_0x1985d5[_0x1ae3('0x51')]);return db['MailAccount'][_0x1ae3('0x5e')](_0x4b4880)['then'](handleEntityNotFound(_0x5eb07a,null))[_0x1ae3('0x22')](respondWithResult(_0x5eb07a,null))[_0x1ae3('0x55')](handleError(_0x5eb07a,null));};exports['update']=function(_0x3e5cd7,_0x34b9c4){if(_0x3e5cd7[_0x1ae3('0x5f')]['id']){delete _0x3e5cd7[_0x1ae3('0x5f')]['id'];}return db[_0x1ae3('0x3d')][_0x1ae3('0x5e')]({'where':{'id':_0x3e5cd7[_0x1ae3('0x57')]['id']},'include':[{'model':db[_0x1ae3('0x58')],'as':_0x1ae3('0x59')},{'model':db[_0x1ae3('0x5a')],'as':_0x1ae3('0x3b')},{'model':db[_0x1ae3('0x5b')],'as':_0x1ae3('0x3c')}]})[_0x1ae3('0x22')](handleEntityNotFound(_0x34b9c4,null))[_0x1ae3('0x22')](saveUpdates(_0x3e5cd7['body'],null))[_0x1ae3('0x22')](function(_0x27cfd5){if(_0x27cfd5&&_0x3e5cd7[_0x1ae3('0x5f')][_0x1ae3('0x59')]){return db['MailServerIn'][_0x1ae3('0x36')](_0x3e5cd7[_0x1ae3('0x5f')][_0x1ae3('0x59')],{'where':{'MailAccountId':_0x27cfd5['id']}})[_0x1ae3('0x22')](function(){return _0x27cfd5;});}return _0x27cfd5;})[_0x1ae3('0x22')](function(_0x2f1a39){if(_0x2f1a39&&_0x3e5cd7['body']['Smtp']){return db[_0x1ae3('0x5a')][_0x1ae3('0x36')](_0x3e5cd7[_0x1ae3('0x5f')][_0x1ae3('0x3b')],{'where':{'MailAccountId':_0x2f1a39['id']}})[_0x1ae3('0x22')](function(){return _0x2f1a39;});}return _0x2f1a39;})[_0x1ae3('0x22')](respondWithResult(_0x34b9c4,null))[_0x1ae3('0x55')](handleError(_0x34b9c4,null));};exports[_0x1ae3('0x60')]=function(_0x32f31b,_0x37a225){return db[_0x1ae3('0x3d')]['describe']()[_0x1ae3('0x22')](respondWithResult(_0x37a225,null))['catch'](handleError(_0x37a225,null));};exports[_0x1ae3('0x61')]=function(_0x22d281,_0x36c91b,_0x12cb6e){if(_0x22d281['body']['id']){delete _0x22d281[_0x1ae3('0x5f')]['id'];}return db[_0x1ae3('0x3d')][_0x1ae3('0x5e')]({'where':{'id':_0x22d281[_0x1ae3('0x57')]['id']}})['then'](handleEntityNotFound(_0x36c91b,null))[_0x1ae3('0x22')](function(_0x210b5d){if(_0x210b5d){_0x22d281[_0x1ae3('0x5f')][_0x1ae3('0x62')]=_0x210b5d['id'];return db['Disposition'][_0x1ae3('0x63')](_0x22d281[_0x1ae3('0x5f')]);}})[_0x1ae3('0x22')](respondWithResult(_0x36c91b,null))[_0x1ae3('0x55')](handleError(_0x36c91b,null));};exports[_0x1ae3('0x64')]=function(_0x13130a,_0x43edb2,_0x50bf8b){var _0xa5fac7={'raw':![],'where':{}};var _0x112c1b={};var _0x4e5bf8={'count':0x0,'rows':[]};return db[_0x1ae3('0x3d')][_0x1ae3('0x65')]({'where':{'id':_0x13130a['params']['id']}})['then'](handleEntityNotFound(_0x43edb2,null))[_0x1ae3('0x22')](function(_0x3a6e71){if(_0x3a6e71){_0x112c1b[_0x1ae3('0x3f')]=_[_0x1ae3('0x40')](db['Disposition'][_0x1ae3('0x3e')]);_0x112c1b[_0x1ae3('0x41')]=_['keys'](_0x13130a[_0x1ae3('0x41')]);_0x112c1b[_0x1ae3('0x42')]=_['intersection'](_0x112c1b[_0x1ae3('0x3f')],_0x112c1b[_0x1ae3('0x41')]);_0xa5fac7[_0x1ae3('0x45')]=_[_0x1ae3('0x43')](_0x112c1b[_0x1ae3('0x3f')],qs[_0x1ae3('0x44')](_0x13130a[_0x1ae3('0x41')][_0x1ae3('0x44')]));_0xa5fac7[_0x1ae3('0x45')]=_0xa5fac7[_0x1ae3('0x45')][_0x1ae3('0x5c')]?_0xa5fac7['attributes']:_0x112c1b[_0x1ae3('0x3f')];if(!_0x13130a[_0x1ae3('0x41')][_0x1ae3('0x66')](_0x1ae3('0x46'))){_0xa5fac7[_0x1ae3('0x31')]=qs[_0x1ae3('0x31')](_0x13130a[_0x1ae3('0x41')][_0x1ae3('0x31')]);_0xa5fac7['offset']=qs[_0x1ae3('0x30')](_0x13130a[_0x1ae3('0x41')][_0x1ae3('0x30')]);}_0xa5fac7[_0x1ae3('0x47')]=qs[_0x1ae3('0x48')](_0x13130a[_0x1ae3('0x41')]['sort']);_0xa5fac7[_0x1ae3('0x49')]=qs['filters'](_[_0x1ae3('0x4a')](_0x13130a[_0x1ae3('0x41')],_0x112c1b['filters']));_0xa5fac7[_0x1ae3('0x49')][_0x1ae3('0x62')]=_0x3a6e71['id'];if(_0x13130a[_0x1ae3('0x41')][_0x1ae3('0x4b')]){_0xa5fac7['where']=_[_0x1ae3('0x4c')](_0xa5fac7[_0x1ae3('0x49')],{'$or':_[_0x1ae3('0x4d')](_0xa5fac7[_0x1ae3('0x45')],function(_0x2da8e1){var _0x4a0afd={};_0x4a0afd[_0x2da8e1]={'$like':'%'+_0x13130a['query'][_0x1ae3('0x4b')]+'%'};return _0x4a0afd;})});}_0xa5fac7=_[_0x1ae3('0x4c')]({},_0xa5fac7,_0x13130a['options']);return db[_0x1ae3('0x67')][_0x1ae3('0x2f')]({'where':_0xa5fac7['where']})[_0x1ae3('0x22')](function(_0x4e6e10){_0x4e5bf8[_0x1ae3('0x2f')]=_0x4e6e10;if(_0x13130a[_0x1ae3('0x41')][_0x1ae3('0x5d')]){_0xa5fac7[_0x1ae3('0x52')]=[{'all':!![]}];}return db[_0x1ae3('0x67')]['findAll'](_0xa5fac7);})[_0x1ae3('0x22')](function(_0x215ffe){_0x4e5bf8[_0x1ae3('0x54')]=_0x215ffe;return _0x4e5bf8;});}})[_0x1ae3('0x22')](respondWithFilteredResult(_0x43edb2,_0xa5fac7))['catch'](handleError(_0x43edb2,null));};exports['removeDispositions']=function(_0x3240c9,_0x9acdb2,_0x1fe987){return db[_0x1ae3('0x3d')][_0x1ae3('0x5e')]({'where':{'id':_0x3240c9['params']['id']}})[_0x1ae3('0x22')](handleEntityNotFound(_0x9acdb2,null))[_0x1ae3('0x22')](function(_0x271596){if(_0x271596){return _0x271596[_0x1ae3('0x68')](_0x3240c9[_0x1ae3('0x41')][_0x1ae3('0x69')]);}})['then'](respondWithStatusCode(_0x9acdb2,null))[_0x1ae3('0x55')](handleError(_0x9acdb2,null));};exports[_0x1ae3('0x6a')]=function(_0x3e5dc9,_0x5c5a09,_0x3262bd){if(_0x3e5dc9[_0x1ae3('0x5f')]['id']){delete _0x3e5dc9[_0x1ae3('0x5f')]['id'];}return db[_0x1ae3('0x3d')][_0x1ae3('0x5e')]({'where':{'id':_0x3e5dc9['params']['id']}})[_0x1ae3('0x22')](handleEntityNotFound(_0x5c5a09,null))['then'](function(_0x8607b5){if(_0x8607b5){_0x3e5dc9[_0x1ae3('0x5f')][_0x1ae3('0x62')]=_0x8607b5['id'];return db[_0x1ae3('0x6b')][_0x1ae3('0x63')](_0x3e5dc9['body']);}})[_0x1ae3('0x22')](respondWithResult(_0x5c5a09,null))[_0x1ae3('0x55')](handleError(_0x5c5a09,null));};exports[_0x1ae3('0x6c')]=function(_0x58a9e3,_0x5636ef,_0x3f83ae){var _0x50d48f={'raw':![],'where':{}};var _0x42d3cb={};var _0x48b511={'count':0x0,'rows':[]};return db[_0x1ae3('0x3d')][_0x1ae3('0x65')]({'where':{'id':_0x58a9e3[_0x1ae3('0x57')]['id']}})[_0x1ae3('0x22')](handleEntityNotFound(_0x5636ef,null))[_0x1ae3('0x22')](function(_0x551cc9){if(_0x551cc9){_0x42d3cb[_0x1ae3('0x3f')]=_['keys'](db['CannedAnswer']['rawAttributes']);_0x42d3cb[_0x1ae3('0x41')]=_[_0x1ae3('0x40')](_0x58a9e3[_0x1ae3('0x41')]);_0x42d3cb['filters']=_[_0x1ae3('0x43')](_0x42d3cb[_0x1ae3('0x3f')],_0x42d3cb[_0x1ae3('0x41')]);_0x50d48f[_0x1ae3('0x45')]=_[_0x1ae3('0x43')](_0x42d3cb[_0x1ae3('0x3f')],qs[_0x1ae3('0x44')](_0x58a9e3[_0x1ae3('0x41')]['fields']));_0x50d48f[_0x1ae3('0x45')]=_0x50d48f[_0x1ae3('0x45')][_0x1ae3('0x5c')]?_0x50d48f['attributes']:_0x42d3cb[_0x1ae3('0x3f')];if(!_0x58a9e3[_0x1ae3('0x41')][_0x1ae3('0x66')]('nolimit')){_0x50d48f[_0x1ae3('0x31')]=qs[_0x1ae3('0x31')](_0x58a9e3[_0x1ae3('0x41')]['limit']);_0x50d48f[_0x1ae3('0x30')]=qs['offset'](_0x58a9e3[_0x1ae3('0x41')][_0x1ae3('0x30')]);}_0x50d48f[_0x1ae3('0x47')]=qs['sort'](_0x58a9e3[_0x1ae3('0x41')][_0x1ae3('0x48')]);_0x50d48f['where']=qs['filters'](_[_0x1ae3('0x4a')](_0x58a9e3[_0x1ae3('0x41')],_0x42d3cb[_0x1ae3('0x42')]));_0x50d48f[_0x1ae3('0x49')]['MailAccountId']=_0x551cc9['id'];if(_0x58a9e3[_0x1ae3('0x41')][_0x1ae3('0x4b')]){_0x50d48f[_0x1ae3('0x49')]=_['merge'](_0x50d48f[_0x1ae3('0x49')],{'$or':_[_0x1ae3('0x4d')](_0x50d48f[_0x1ae3('0x45')],function(_0x7dd258){var _0x78bcda={};_0x78bcda[_0x7dd258]={'$like':'%'+_0x58a9e3[_0x1ae3('0x41')][_0x1ae3('0x4b')]+'%'};return _0x78bcda;})});}_0x50d48f=_['merge']({},_0x50d48f,_0x58a9e3['options']);return db[_0x1ae3('0x6b')][_0x1ae3('0x2f')]({'where':_0x50d48f[_0x1ae3('0x49')]})[_0x1ae3('0x22')](function(_0x17ef3c){_0x48b511[_0x1ae3('0x2f')]=_0x17ef3c;if(_0x58a9e3[_0x1ae3('0x41')][_0x1ae3('0x5d')]){_0x50d48f['include']=[{'all':!![]}];}return db[_0x1ae3('0x6b')][_0x1ae3('0x53')](_0x50d48f);})['then'](function(_0x124d73){_0x48b511[_0x1ae3('0x54')]=_0x124d73;return _0x48b511;});}})[_0x1ae3('0x22')](respondWithFilteredResult(_0x5636ef,_0x50d48f))['catch'](handleError(_0x5636ef,null));};exports[_0x1ae3('0x6d')]=function(_0x1d4f75,_0x100e42,_0x23ec1b){return db[_0x1ae3('0x3d')][_0x1ae3('0x5e')]({'where':{'id':_0x1d4f75['params']['id']}})[_0x1ae3('0x22')](handleEntityNotFound(_0x100e42,null))[_0x1ae3('0x22')](function(_0x16040c){if(_0x16040c){return _0x16040c[_0x1ae3('0x6d')](_0x1d4f75['query'][_0x1ae3('0x69')]);}})[_0x1ae3('0x22')](respondWithStatusCode(_0x100e42,null))['catch'](handleError(_0x100e42,null));};exports[_0x1ae3('0x63')]=function(_0x269124,_0xc401cb){var _0x348cf6={'name':_0x269124['body']['name'],'key':_0x269124['body'][_0x1ae3('0x4f')],'email':_0x269124[_0x1ae3('0x5f')][_0x1ae3('0x6e')],'ListId':_0x269124[_0x1ae3('0x5f')][_0x1ae3('0x6f')],'active':!_[_0x1ae3('0x70')](_0x269124[_0x1ae3('0x5f')][_0x1ae3('0x71')])?_0x269124['body'][_0x1ae3('0x71')]:!![],'description':_0x269124['body'][_0x1ae3('0x72')]||null,'Imap':{},'Smtp':{}};if(_[_0x1ae3('0x70')](_0x269124['body'][_0x1ae3('0x73')])){if(_0x269124[_0x1ae3('0x5f')][_0x1ae3('0x74')]){_0x348cf6['Imap'][_0x1ae3('0x75')]=_0x348cf6[_0x1ae3('0x3b')][_0x1ae3('0x75')]=_0x269124[_0x1ae3('0x5f')][_0x1ae3('0x76')];_0x348cf6[_0x1ae3('0x59')]['password']=_0x348cf6['Smtp'][_0x1ae3('0x77')]=_0x269124[_0x1ae3('0x5f')][_0x1ae3('0x78')];}else{_0x348cf6['Imap'][_0x1ae3('0x79')]=_0x348cf6[_0x1ae3('0x3b')][_0x1ae3('0x79')]=![];}_0x348cf6['Imap'][_0x1ae3('0x7a')]=_0x269124['body'][_0x1ae3('0x59')][_0x1ae3('0x7a')];_0x348cf6[_0x1ae3('0x59')]['port']=_0x269124[_0x1ae3('0x5f')][_0x1ae3('0x59')][_0x1ae3('0x7b')];_0x348cf6[_0x1ae3('0x3b')]['host']=_0x269124['body'][_0x1ae3('0x3b')][_0x1ae3('0x7a')];_0x348cf6[_0x1ae3('0x3b')][_0x1ae3('0x7b')]=_0x269124['body'][_0x1ae3('0x3b')][_0x1ae3('0x7b')];}else{_0x348cf6[_0x1ae3('0x59')]['service']=_0x348cf6['Smtp']['service']=_0x269124[_0x1ae3('0x5f')][_0x1ae3('0x73')];_0x348cf6[_0x1ae3('0x59')][_0x1ae3('0x75')]=_0x348cf6[_0x1ae3('0x3b')][_0x1ae3('0x75')]=_0x269124[_0x1ae3('0x5f')][_0x1ae3('0x76')];_0x348cf6[_0x1ae3('0x59')][_0x1ae3('0x7c')]=_0x348cf6['Smtp'][_0x1ae3('0x77')]=_0x269124[_0x1ae3('0x5f')][_0x1ae3('0x78')];}return db[_0x1ae3('0x3d')][_0x1ae3('0x63')](_0x348cf6,{'include':[{'model':db['MailServerOut'],'as':_0x1ae3('0x3b')},{'model':db['MailServerIn'],'as':_0x1ae3('0x59')}]})[_0x1ae3('0x22')](function(_0x85f05b){var _0x547f33=_0x269124['user'][_0x1ae3('0x7d')]({'plain':!![]});if(!_0x547f33)throw new Error(_0x1ae3('0x7e'));if(_0x547f33['role']===_0x1ae3('0x75')){var _0x42ba53=_0x85f05b['get']({'plain':!![]});return db[_0x1ae3('0x7f')][_0x1ae3('0x5e')]({'where':{'name':_0x1ae3('0x38'),'userProfileId':_0x547f33['userProfileId']},'raw':!![]})[_0x1ae3('0x22')](function(_0x22db0b){if(_0x22db0b&&_0x22db0b['autoAssociation']===0x0){return db[_0x1ae3('0x80')][_0x1ae3('0x63')]({'name':_0x42ba53[_0x1ae3('0x39')],'resourceId':_0x42ba53['id'],'type':_0x22db0b['name'],'sectionId':_0x22db0b['id']},{})[_0x1ae3('0x22')](function(){return _0x85f05b;});}else{return _0x85f05b;}})['catch'](function(_0x3fcdae){logger[_0x1ae3('0x26')](_0x1ae3('0x81'),_0x3fcdae);throw _0x3fcdae;});}return _0x85f05b;})['then'](respondWithResult(_0xc401cb,0xc9))[_0x1ae3('0x55')](handleError(_0xc401cb,null));};exports['getImap']=function(_0x5252b2,_0x326211,_0x166855){return db[_0x1ae3('0x3d')][_0x1ae3('0x65')]({'where':{'id':_0x5252b2[_0x1ae3('0x57')]['id']}})[_0x1ae3('0x22')](handleEntityNotFound(_0x326211,null))[_0x1ae3('0x22')](function(_0x1284d0){if(_0x1284d0){return _0x1284d0[_0x1ae3('0x82')]();}return null;})[_0x1ae3('0x22')](respondWithResult(_0x326211,null))['catch'](handleError(_0x326211,null));};exports['addImap']=function(_0x21ec2b,_0x13b112,_0x762421){if(_0x21ec2b['body']['id']){delete _0x21ec2b['body']['id'];}return db[_0x1ae3('0x3d')][_0x1ae3('0x5e')]({'where':{'id':_0x21ec2b[_0x1ae3('0x57')]['id']}})[_0x1ae3('0x22')](handleEntityNotFound(_0x13b112,null))[_0x1ae3('0x22')](function(_0xefce27){if(_0xefce27){_0x21ec2b[_0x1ae3('0x5f')][_0x1ae3('0x62')]=_0xefce27['id'];return db[_0x1ae3('0x58')][_0x1ae3('0x63')](_0x21ec2b[_0x1ae3('0x5f')]);}})[_0x1ae3('0x22')](respondWithResult(_0x13b112,null))['catch'](handleError(_0x13b112,null));};exports[_0x1ae3('0x83')]=function(_0x5ef511,_0x238e83,_0x329f2e){return db[_0x1ae3('0x3d')][_0x1ae3('0x65')]({'where':{'id':_0x5ef511['params']['id']}})['then'](handleEntityNotFound(_0x238e83,null))[_0x1ae3('0x22')](function(_0x2598b8){if(_0x2598b8){return _0x2598b8['setImap'](null);}return null;})['then'](respondWithStatusCode(_0x238e83,null))[_0x1ae3('0x55')](handleError(_0x238e83,null));};exports['getSmtp']=function(_0x1624ed,_0x5c61eb,_0x43d35d){return db[_0x1ae3('0x3d')][_0x1ae3('0x65')]({'where':{'id':_0x1624ed[_0x1ae3('0x57')]['id']}})[_0x1ae3('0x22')](handleEntityNotFound(_0x5c61eb,null))[_0x1ae3('0x22')](function(_0x12acac){if(_0x12acac){return _0x12acac[_0x1ae3('0x84')]();}return null;})[_0x1ae3('0x22')](respondWithResult(_0x5c61eb,null))['catch'](handleError(_0x5c61eb,null));};exports[_0x1ae3('0x85')]=function(_0x440591,_0x43f78c,_0x19c088){if(_0x440591[_0x1ae3('0x5f')]['id']){delete _0x440591[_0x1ae3('0x5f')]['id'];}return db[_0x1ae3('0x3d')][_0x1ae3('0x5e')]({'where':{'id':_0x440591[_0x1ae3('0x57')]['id']}})['then'](handleEntityNotFound(_0x43f78c,null))['then'](function(_0x5d093a){if(_0x5d093a){_0x440591[_0x1ae3('0x5f')][_0x1ae3('0x62')]=_0x5d093a['id'];return db[_0x1ae3('0x5a')][_0x1ae3('0x63')](_0x440591[_0x1ae3('0x5f')]);}})[_0x1ae3('0x22')](respondWithResult(_0x43f78c,null))[_0x1ae3('0x55')](handleError(_0x43f78c,null));};exports[_0x1ae3('0x86')]=function(_0x94e0e3,_0x52f0f7,_0x22586a){return db[_0x1ae3('0x3d')][_0x1ae3('0x65')]({'where':{'id':_0x94e0e3[_0x1ae3('0x57')]['id']}})[_0x1ae3('0x22')](handleEntityNotFound(_0x52f0f7,null))[_0x1ae3('0x22')](function(_0x558b91){if(_0x558b91){return _0x558b91[_0x1ae3('0x87')](null);}return null;})[_0x1ae3('0x22')](respondWithStatusCode(_0x52f0f7,null))[_0x1ae3('0x55')](handleError(_0x52f0f7,null));};exports[_0x1ae3('0x88')]=function(_0x4dc27c,_0x387125,_0x1d40e8){return db[_0x1ae3('0x89')]['find']({'where':{'id':_0x4dc27c[_0x1ae3('0x57')]['id']}})[_0x1ae3('0x22')](handleEntityNotFound(_0x387125,null))[_0x1ae3('0x22')](function(_0x38f408){if(_0x38f408){return _0x38f408[_0x1ae3('0x88')](_0x4dc27c[_0x1ae3('0x5f')][_0x1ae3('0x69')],_['omit'](_0x4dc27c['body'],[_0x1ae3('0x69'),'id'])||{});}})[_0x1ae3('0x22')](respondWithResult(_0x387125,null))[_0x1ae3('0x55')](handleError(_0x387125,null));};exports['getInteractions']=function(_0x29f1b4,_0x5aac82,_0x643ed4){var _0x5f33af={'raw':![],'where':{}};var _0x4b1263={};var _0x17dd7f={'count':0x0,'rows':[]};return db['MailAccount'][_0x1ae3('0x65')]({'where':{'id':_0x29f1b4['params']['id']}})['then'](handleEntityNotFound(_0x5aac82,null))['then'](function(_0x27f3bd){if(_0x27f3bd){_0x4b1263[_0x1ae3('0x3f')]=_[_0x1ae3('0x40')](db[_0x1ae3('0x89')][_0x1ae3('0x3e')]);_0x4b1263[_0x1ae3('0x41')]=_[_0x1ae3('0x40')](_0x29f1b4['query']);_0x4b1263[_0x1ae3('0x42')]=_[_0x1ae3('0x43')](_0x4b1263[_0x1ae3('0x3f')],_0x4b1263[_0x1ae3('0x41')]);_0x5f33af['attributes']=_[_0x1ae3('0x43')](_0x4b1263[_0x1ae3('0x3f')],qs[_0x1ae3('0x44')](_0x29f1b4[_0x1ae3('0x41')][_0x1ae3('0x44')]));_0x5f33af[_0x1ae3('0x45')]=_0x5f33af[_0x1ae3('0x45')]['length']?_0x5f33af[_0x1ae3('0x45')]:_0x4b1263[_0x1ae3('0x3f')];if(!_0x29f1b4[_0x1ae3('0x41')][_0x1ae3('0x66')](_0x1ae3('0x46'))){_0x5f33af['limit']=qs[_0x1ae3('0x31')](_0x29f1b4['query'][_0x1ae3('0x31')]);_0x5f33af[_0x1ae3('0x30')]=qs[_0x1ae3('0x30')](_0x29f1b4['query']['offset']);}_0x5f33af[_0x1ae3('0x47')]=qs[_0x1ae3('0x48')](_0x29f1b4[_0x1ae3('0x41')][_0x1ae3('0x48')]);_0x5f33af[_0x1ae3('0x49')]=qs[_0x1ae3('0x42')](_[_0x1ae3('0x4a')](_0x29f1b4[_0x1ae3('0x41')],_0x4b1263['filters']));_0x5f33af[_0x1ae3('0x49')][_0x1ae3('0x62')]=_0x27f3bd['id'];if(_0x29f1b4['query'][_0x1ae3('0x4b')]){_0x5f33af[_0x1ae3('0x49')]=_[_0x1ae3('0x4c')](_0x5f33af[_0x1ae3('0x49')],{'$or':_[_0x1ae3('0x4d')](_0x5f33af[_0x1ae3('0x45')],function(_0x712164){var _0xd74537={};_0xd74537[_0x712164]={'$like':'%'+_0x29f1b4[_0x1ae3('0x41')]['filter']+'%'};return _0xd74537;})});}_0x5f33af=_[_0x1ae3('0x4c')]({},_0x5f33af,_0x29f1b4[_0x1ae3('0x51')]);return db[_0x1ae3('0x89')][_0x1ae3('0x2f')]({'where':_0x5f33af['where']})[_0x1ae3('0x22')](function(_0x340d9f){_0x17dd7f[_0x1ae3('0x2f')]=_0x340d9f;if(_0x29f1b4[_0x1ae3('0x41')][_0x1ae3('0x5d')]){_0x5f33af['include']=[{'model':db['CmContact'],'as':_0x1ae3('0x8a'),'required':![]},{'model':db[_0x1ae3('0x8b')],'as':_0x1ae3('0x8c'),'attributes':[_0x1ae3('0x39'),'fullname',_0x1ae3('0x8d')],'required':![]},{'model':db[_0x1ae3('0x8e')],'as':_0x1ae3('0x8f'),'attributes':['id',_0x1ae3('0x39'),_0x1ae3('0x90')],'where':_0x29f1b4['query'][_0x1ae3('0x91')]?{'id':_0x29f1b4['query'][_0x1ae3('0x91')]}:undefined,'required':_0x29f1b4[_0x1ae3('0x41')]['tag']?!![]:![]}];}return db[_0x1ae3('0x89')][_0x1ae3('0x53')](_0x5f33af);})[_0x1ae3('0x22')](function(_0x41bfa8){_0x17dd7f[_0x1ae3('0x54')]=_0x41bfa8;return _0x17dd7f;});}})[_0x1ae3('0x22')](respondWithFilteredResult(_0x5aac82,_0x5f33af))['catch'](handleError(_0x5aac82,null));};exports[_0x1ae3('0x92')]=function(_0x2c15e0,_0xb5fb1b,_0x3342c2){return db[_0x1ae3('0x3d')][_0x1ae3('0x65')]({'where':{'id':_0x2c15e0[_0x1ae3('0x57')]['id']}})[_0x1ae3('0x22')](handleEntityNotFound(_0xb5fb1b,null))[_0x1ae3('0x22')](function(_0x36a4e4){if(_0x36a4e4){return db[_0x1ae3('0x93')][_0x1ae3('0x94')](function(_0x5a8837){return db[_0x1ae3('0x95')][_0x1ae3('0x37')]({'where':{'MailAccountId':_0x2c15e0[_0x1ae3('0x57')]['id']},'transaction':_0x5a8837})[_0x1ae3('0x22')](function(_0x593c2f){var _0x5b1329=_[_0x1ae3('0x4d')](_0x2c15e0[_0x1ae3('0x5f')],function(_0x27f0c1){_0x27f0c1[_0x1ae3('0x62')]=_0x2c15e0['params']['id'];return _0x27f0c1;});return db['MailApplication']['bulkCreate'](_0x5b1329,{'transaction':_0x5a8837});});})[_0x1ae3('0x22')](function(){return db[_0x1ae3('0x95')][_0x1ae3('0x96')]({'where':{'MailAccountId':_0x2c15e0[_0x1ae3('0x57')]['id']},'order':'priority'});});}})[_0x1ae3('0x22')](respondWithResult(_0xb5fb1b,null))[_0x1ae3('0x55')](handleError(_0xb5fb1b,null));};exports[_0x1ae3('0x97')]=function(_0x18b413,_0x202e7a,_0x57013e){var _0x45c574={};var _0x143459={};var _0x2b0cae;var _0x17b3ec;return db[_0x1ae3('0x3d')]['findOne']({'where':{'id':_0x18b413[_0x1ae3('0x57')]['id']}})[_0x1ae3('0x22')](handleEntityNotFound(_0x202e7a,null))['then'](function(_0x54c7ac){if(_0x54c7ac){_0x2b0cae=_0x54c7ac;_0x143459[_0x1ae3('0x3f')]=_[_0x1ae3('0x40')](db[_0x1ae3('0x95')][_0x1ae3('0x3e')]);_0x143459[_0x1ae3('0x41')]=_[_0x1ae3('0x40')](_0x18b413['query']);_0x143459[_0x1ae3('0x42')]=_[_0x1ae3('0x43')](_0x143459[_0x1ae3('0x3f')],_0x143459['query']);_0x45c574[_0x1ae3('0x45')]=_[_0x1ae3('0x43')](_0x143459[_0x1ae3('0x3f')],qs['fields'](_0x18b413[_0x1ae3('0x41')][_0x1ae3('0x44')]));_0x45c574[_0x1ae3('0x45')]=_0x45c574[_0x1ae3('0x45')]['length']?_0x45c574[_0x1ae3('0x45')]:_0x143459[_0x1ae3('0x3f')];_0x45c574[_0x1ae3('0x47')]=qs[_0x1ae3('0x48')](_0x18b413[_0x1ae3('0x41')]['sort']);_0x45c574[_0x1ae3('0x49')]=qs['filters'](_['pick'](_0x18b413[_0x1ae3('0x41')],_0x143459[_0x1ae3('0x42')]));if(_0x18b413[_0x1ae3('0x41')][_0x1ae3('0x4b')]){_0x45c574['where']=_[_0x1ae3('0x4c')](_0x45c574[_0x1ae3('0x49')],{'$or':_['map'](_0x45c574['attributes'],function(_0x2aa224){var _0x13f9a8={};_0x13f9a8[_0x2aa224]={'$like':'%'+_0x18b413['query'][_0x1ae3('0x4b')]+'%'};return _0x13f9a8;})});}_0x45c574=_[_0x1ae3('0x4c')]({},_0x45c574,_0x18b413[_0x1ae3('0x51')]);return _0x2b0cae[_0x1ae3('0x97')](_0x45c574);}})[_0x1ae3('0x22')](function(_0x3885f0){if(_0x3885f0){_0x17b3ec=_0x3885f0['length'];if(!_0x18b413[_0x1ae3('0x41')]['hasOwnProperty']('nolimit')){_0x45c574[_0x1ae3('0x31')]=qs[_0x1ae3('0x31')](_0x18b413[_0x1ae3('0x41')]['limit']);_0x45c574[_0x1ae3('0x30')]=qs[_0x1ae3('0x30')](_0x18b413[_0x1ae3('0x41')][_0x1ae3('0x30')]);}return _0x2b0cae[_0x1ae3('0x97')](_0x45c574);}})[_0x1ae3('0x22')](function(_0x11b270){if(_0x11b270){return _0x11b270?{'count':_0x17b3ec,'rows':_0x11b270}:null;}})[_0x1ae3('0x22')](respondWithResult(_0x202e7a,null))[_0x1ae3('0x55')](handleError(_0x202e7a,null));};exports[_0x1ae3('0x98')]=function(_0x51dbd8,_0x523c9a,_0x3995c1){var _0x226846={'raw':!![],'where':{}};var _0x19ceab={};var _0x3a9a0c={'count':0x0,'rows':[]};return db[_0x1ae3('0x3d')][_0x1ae3('0x65')]({'where':{'id':_0x51dbd8['params']['id']}})['then'](handleEntityNotFound(_0x523c9a,null))['then'](function(_0x56de8f){if(_0x56de8f){_0x19ceab['model']=_[_0x1ae3('0x40')](db[_0x1ae3('0x99')][_0x1ae3('0x3e')]);_0x19ceab[_0x1ae3('0x41')]=_[_0x1ae3('0x40')](_0x51dbd8[_0x1ae3('0x41')]);_0x19ceab['filters']=_[_0x1ae3('0x43')](_0x19ceab[_0x1ae3('0x3f')],_0x19ceab[_0x1ae3('0x41')]);_0x226846[_0x1ae3('0x45')]=_[_0x1ae3('0x43')](_0x19ceab[_0x1ae3('0x3f')],qs[_0x1ae3('0x44')](_0x51dbd8[_0x1ae3('0x41')][_0x1ae3('0x44')]));_0x226846[_0x1ae3('0x45')]=_0x226846[_0x1ae3('0x45')][_0x1ae3('0x5c')]?_0x226846[_0x1ae3('0x45')]:_0x19ceab[_0x1ae3('0x3f')];if(!_0x51dbd8[_0x1ae3('0x41')][_0x1ae3('0x66')]('nolimit')){_0x226846[_0x1ae3('0x31')]=qs[_0x1ae3('0x31')](_0x51dbd8[_0x1ae3('0x41')]['limit']);_0x226846[_0x1ae3('0x30')]=qs[_0x1ae3('0x30')](_0x51dbd8['query'][_0x1ae3('0x30')]);}_0x226846[_0x1ae3('0x47')]=qs[_0x1ae3('0x48')](_0x51dbd8[_0x1ae3('0x41')][_0x1ae3('0x48')]);_0x226846[_0x1ae3('0x49')]=qs[_0x1ae3('0x42')](_[_0x1ae3('0x4a')](_0x51dbd8['query'],_0x19ceab[_0x1ae3('0x42')]));_0x226846['where']['MailAccountId']=_0x56de8f['id'];if(_0x51dbd8[_0x1ae3('0x41')][_0x1ae3('0x4b')]){_0x226846[_0x1ae3('0x49')]=_['merge'](_0x226846['where'],{'$or':_[_0x1ae3('0x4d')](_0x226846[_0x1ae3('0x45')],function(_0x66a6d1){var _0x8a173={};_0x8a173[_0x66a6d1]={'$like':'%'+_0x51dbd8[_0x1ae3('0x41')][_0x1ae3('0x4b')]+'%'};return _0x8a173;})});}if(_0x51dbd8[_0x1ae3('0x41')][_0x1ae3('0x9a')]){var _0x263d4c=_0x51dbd8[_0x1ae3('0x41')]['$gte']['split'](',');var _0x4e91b5={};_0x4e91b5[_0x263d4c[0x0]]={'$gte':moment(_0x263d4c[0x1])[_0x1ae3('0x9b')](_0x1ae3('0x9c'))};_0x226846[_0x1ae3('0x49')]=_[_0x1ae3('0x4c')](_0x226846[_0x1ae3('0x49')],_0x4e91b5);}_0x226846=_['merge']({},_0x226846,_0x51dbd8[_0x1ae3('0x51')]);return db[_0x1ae3('0x99')]['count']({'where':_0x226846['where']})[_0x1ae3('0x22')](function(_0x1542c0){_0x3a9a0c[_0x1ae3('0x2f')]=_0x1542c0;if(_0x51dbd8[_0x1ae3('0x41')][_0x1ae3('0x5d')]){_0x226846[_0x1ae3('0x52')]=[{'all':!![]}];}return db['MailMessage'][_0x1ae3('0x53')](_0x226846);})['then'](function(_0x390067){_0x3a9a0c['rows']=_0x390067;return _0x3a9a0c;});}})[_0x1ae3('0x22')](respondWithFilteredResult(_0x523c9a,_0x226846))[_0x1ae3('0x55')](handleError(_0x523c9a,null));};exports['send']=function(_0x135a48,_0x14894b,_0x5efd2d){var _0x30e8d7,_0x4049a7={},_0x26aff9;if(_0x135a48[_0x1ae3('0x5f')]['to']){_0x26aff9=_0x135a48[_0x1ae3('0x5f')]['to'][_0x1ae3('0x9d')](',')[0x0];}return db[_0x1ae3('0x3d')][_0x1ae3('0x5e')]({'where':{'id':_0x135a48[_0x1ae3('0x57')]['id']},'include':[{'model':db[_0x1ae3('0x9e')],'as':_0x1ae3('0x9f'),'include':[{'model':db[_0x1ae3('0xa0')],'as':_0x1ae3('0xa1'),'where':{'email':_0x26aff9},'limit':0x1,'order':[[_0x1ae3('0xa2'),_0x1ae3('0xa3')]]}]},{'model':db[_0x1ae3('0x5a')],'as':'Smtp','raw':!![]}]})[_0x1ae3('0x22')](handleEntityNotFound(_0x14894b,null))[_0x1ae3('0x22')](function(_0x3e7fdb){if(_0x3e7fdb){_0x30e8d7=_0x3e7fdb;if(_0x3e7fdb[_0x1ae3('0x3b')]){if(_[_0x1ae3('0x70')](_0x135a48[_0x1ae3('0x5f')][_0x1ae3('0xa4')])){_0x135a48[_0x1ae3('0x5f')]['from']=util[_0x1ae3('0x9b')](_0x1ae3('0xa5'),_0x3e7fdb['name'],_0x3e7fdb[_0x1ae3('0x6e')]||_0x3e7fdb['Smtp'][_0x1ae3('0x75')]);}if(_0x135a48[_0x1ae3('0x5f')]['attachments']&&_0x135a48[_0x1ae3('0x5f')][_0x1ae3('0xa6')]['length']){for(var _0x314fce=0x0;_0x314fce<_0x135a48['body']['attachments'][_0x1ae3('0x5c')];_0x314fce+=0x1){_0x135a48[_0x1ae3('0x5f')][_0x1ae3('0xa6')][_0x314fce]={'filename':_0x135a48['body']['attachments'][_0x314fce][_0x1ae3('0x39')],'path':path[_0x1ae3('0xa7')](config[_0x1ae3('0xa8')],_0x1ae3('0xa9'),_0x135a48[_0x1ae3('0x5f')][_0x1ae3('0xa6')][_0x314fce][_0x1ae3('0xaa')])};}}var _0x2a945a={'tls':{'rejectUnauthorized':![]}};if(_[_0x1ae3('0x70')](_0x3e7fdb['Smtp'][_0x1ae3('0xab')])){if(_0x3e7fdb[_0x1ae3('0x3b')]['authentication']){_0x2a945a[_0x1ae3('0xac')]={'user':_0x3e7fdb[_0x1ae3('0x3b')][_0x1ae3('0x75')],'pass':_0x3e7fdb[_0x1ae3('0x3b')]['pass']};}_0x2a945a[_0x1ae3('0x7a')]=_0x3e7fdb['Smtp'][_0x1ae3('0x7a')];_0x2a945a['port']=_0x3e7fdb[_0x1ae3('0x3b')][_0x1ae3('0x7b')];_0x2a945a[_0x1ae3('0xad')]=_0x3e7fdb[_0x1ae3('0x3b')]['secure'];}else{_0x2a945a[_0x1ae3('0xab')]=_0x3e7fdb['Smtp'][_0x1ae3('0xab')];_0x2a945a['auth']={'user':_0x3e7fdb[_0x1ae3('0x3b')]['user'],'pass':_0x3e7fdb[_0x1ae3('0x3b')]['pass']};}return respondWithRpcPromise(_0x1ae3('0xae'),_0x1ae3('0xaf'),{'account':_0x2a945a,'message':_0x135a48[_0x1ae3('0x5f')]});}else{throw new Error(_0x1ae3('0xb0'));}}})['then'](function(_0x4ba503){if(_0x4ba503){_0x4049a7=_0x4ba503;if(_0x30e8d7[_0x1ae3('0x9f')]){if(_0x30e8d7[_0x1ae3('0x9f')][_0x1ae3('0xa1')]['length']){return _0x30e8d7[_0x1ae3('0x9f')]['Contacts'][0x0];}else{return db[_0x1ae3('0xa0')][_0x1ae3('0x63')](_[_0x1ae3('0xb1')](_0x135a48[_0x1ae3('0x5f')],{'firstName':_0x135a48[_0x1ae3('0x5f')]['to'],'email':_0x135a48[_0x1ae3('0x5f')]['to'],'phone':_0x135a48['body']['to'],'ListId':_0x30e8d7['ListId']}));}}else{throw new Error(_0x1ae3('0xb0'));}}})[_0x1ae3('0x22')](function(_0x34e3be){if(_0x34e3be){var _0x40dc6b={'UserId':_0x135a48[_0x1ae3('0x75')]['id'],'ContactId':_0x34e3be['id'],'MailAccountId':_0x30e8d7['id'],'inReplyTo':_0x4049a7['messageId'],'to':_0x135a48['body'][_0x1ae3('0xa4')],'cc':_0x135a48['body']['cc'],'subject':_0x135a48['body'][_0x1ae3('0xb2')],'attach':_0x135a48[_0x1ae3('0x5f')][_0x1ae3('0xb3')],'firstMsgDirection':_0x1ae3('0xb4'),'lastMsgAt':moment()[_0x1ae3('0x9b')](_0x1ae3('0x9c')),'lastMsgDirection':_0x1ae3('0xb4'),'lastMsgBody':_0x135a48[_0x1ae3('0x5f')][_0x1ae3('0x5f')],'Messages':[_[_0x1ae3('0x4c')](_0x135a48[_0x1ae3('0x5f')],{'messageId':_0x4049a7['messageId'],'sentAt':moment()['format'](_0x1ae3('0x9c')),'read':!![],'MailAccountId':_0x30e8d7['id'],'UserId':_0x135a48[_0x1ae3('0x75')]['id'],'ContactId':_0x34e3be['id']})]};if(_0x135a48[_0x1ae3('0x5f')]['Interaction']){_0x40dc6b=_[_0x1ae3('0x4c')](_0x40dc6b,_0x135a48[_0x1ae3('0x5f')]['Interaction']);}return db[_0x1ae3('0x89')][_0x1ae3('0x63')](_0x40dc6b,{'include':[{'model':db[_0x1ae3('0x99')],'as':_0x1ae3('0xb5')}]});}})[_0x1ae3('0x22')](respondWithResult(_0x14894b,null))[_0x1ae3('0x55')](handleError(_0x14894b,null));};exports[_0x1ae3('0xb6')]=function(_0x4e27a2,_0x56ac5b,_0x9c4e59){return db[_0x1ae3('0x3d')][_0x1ae3('0x5e')]({'where':{'id':_0x4e27a2[_0x1ae3('0x57')]['id']},'include':[{'model':db[_0x1ae3('0x5a')],'as':'Smtp','raw':!![]}]})[_0x1ae3('0x22')](handleEntityNotFound(_0x56ac5b,null))[_0x1ae3('0x22')](function(_0x7ae993){if(_0x7ae993&&_0x7ae993[_0x1ae3('0x3b')]){var _0x27eddb={'id':_0x7ae993['id'],'tls':{'rejectUnauthorized':![]}};if(_0x7ae993['Smtp']['service']){_0x27eddb[_0x1ae3('0xab')]=_0x7ae993[_0x1ae3('0x3b')][_0x1ae3('0xab')];}else{_0x27eddb[_0x1ae3('0x7a')]=_0x7ae993[_0x1ae3('0x3b')][_0x1ae3('0x7a')];_0x27eddb[_0x1ae3('0x7b')]=_0x7ae993[_0x1ae3('0x3b')]['port'];_0x27eddb[_0x1ae3('0xad')]=_0x7ae993['Smtp'][_0x1ae3('0xad')];}if(_0x7ae993['Smtp'][_0x1ae3('0x79')]){_0x27eddb[_0x1ae3('0xac')]={'user':_0x7ae993[_0x1ae3('0x3b')][_0x1ae3('0x75')],'pass':_0x7ae993[_0x1ae3('0x3b')]['pass']};}return respondWithRpcPromise(_0x1ae3('0xb7'),_0x1ae3('0xb6'),{'account':_0x27eddb});}})[_0x1ae3('0x22')](respondWithResult(_0x56ac5b,null))[_0x1ae3('0x55')](handleError(_0x56ac5b,null));};exports['destroy']=function(_0x341aa4,_0x5e29a3){return db[_0x1ae3('0x3d')][_0x1ae3('0x5e')]({'where':{'id':_0x341aa4[_0x1ae3('0x57')]['id']}})[_0x1ae3('0x22')](handleEntityNotFound(_0x5e29a3,null))['then'](function(_0x24081d){if(_0x24081d&&_0x24081d[_0x1ae3('0xab')]){throw new db[(_0x1ae3('0xb8'))][(_0x1ae3('0xb9'))](_0x1ae3('0xba'));}return _0x24081d;})[_0x1ae3('0x22')](removeEntity(_0x5e29a3,null))[_0x1ae3('0x55')](handleError(_0x5e29a3,null));};exports['addAgents']=function(_0x2361bf,_0x44972f,_0x503124){return db[_0x1ae3('0x3d')]['find']({'where':{'id':_0x2361bf[_0x1ae3('0x57')]['id']}})[_0x1ae3('0x22')](handleEntityNotFound(_0x44972f,null))[_0x1ae3('0x22')](function(_0x22eb2d){if(_0x22eb2d){return _0x22eb2d[_0x1ae3('0xbb')](_0x2361bf['body'][_0x1ae3('0x69')],_[_0x1ae3('0xbc')](_0x2361bf[_0x1ae3('0x5f')],[_0x1ae3('0x69'),'id'])||{})[_0x1ae3('0xbd')](function(_0xb953ae){for(var _0x447b34=0x0;_0x447b34<_0x2361bf[_0x1ae3('0x5f')][_0x1ae3('0x69')][_0x1ae3('0x5c')];_0x447b34+=0x1){socket[_0x1ae3('0xbe')](_0x1ae3('0xbf'),{'UserId':_0x2361bf[_0x1ae3('0x5f')][_0x1ae3('0x69')][_0x447b34],'MailAccountId':_0x2361bf[_0x1ae3('0x57')]['id']});}return _0xb953ae;});}})['then'](respondWithResult(_0x44972f,null))['catch'](handleError(_0x44972f,null));};exports[_0x1ae3('0xc0')]=function(_0xf827b4,_0x30a2e2,_0x20a5b9){return db['MailAccount'][_0x1ae3('0x5e')]({'where':{'id':_0xf827b4[_0x1ae3('0x57')]['id']}})['then'](handleEntityNotFound(_0x30a2e2,null))['then'](function(_0x4e35ea){if(_0x4e35ea){return _0x4e35ea[_0x1ae3('0xc0')](_0xf827b4['query'][_0x1ae3('0x69')])[_0x1ae3('0x22')](function(){if(_['isArray'](_0xf827b4[_0x1ae3('0x41')][_0x1ae3('0x69')])){for(var _0x43a300=0x0;_0x43a300<_0xf827b4[_0x1ae3('0x41')][_0x1ae3('0x69')][_0x1ae3('0x5c')];_0x43a300+=0x1){socket[_0x1ae3('0xbe')](_0x1ae3('0xc1'),{'UserId':Number(_0xf827b4['query']['ids'][_0x43a300]),'MailAccountId':Number(_0xf827b4[_0x1ae3('0x57')]['id'])});}}else{socket[_0x1ae3('0xbe')](_0x1ae3('0xc1'),{'UserId':Number(_0xf827b4[_0x1ae3('0x41')][_0x1ae3('0x69')]),'MailAccountId':Number(_0xf827b4[_0x1ae3('0x57')]['id'])});}});}})['then'](respondWithStatusCode(_0x30a2e2,null))[_0x1ae3('0x55')](handleError(_0x30a2e2,null));};exports[_0x1ae3('0xc2')]=function(_0x2045d1,_0x54d840,_0x412aca){var _0x1b299d={};var _0x864db4={};var _0x524a88;var _0x1a7971;return db['MailAccount'][_0x1ae3('0x65')]({'where':{'id':_0x2045d1['params']['id']}})[_0x1ae3('0x22')](handleEntityNotFound(_0x54d840,null))[_0x1ae3('0x22')](function(_0x5a5cd8){if(_0x5a5cd8){_0x524a88=_0x5a5cd8;_0x864db4[_0x1ae3('0x3f')]=_[_0x1ae3('0x40')](db[_0x1ae3('0x8b')][_0x1ae3('0x3e')]);_0x864db4[_0x1ae3('0x41')]=_['keys'](_0x2045d1['query']);_0x864db4[_0x1ae3('0x42')]=_['intersection'](_0x864db4[_0x1ae3('0x3f')],_0x864db4['query']);_0x1b299d[_0x1ae3('0x45')]=_[_0x1ae3('0x43')](_0x864db4[_0x1ae3('0x3f')],qs[_0x1ae3('0x44')](_0x2045d1[_0x1ae3('0x41')][_0x1ae3('0x44')]));_0x1b299d['attributes']=_0x1b299d['attributes'][_0x1ae3('0x5c')]?_0x1b299d[_0x1ae3('0x45')]:_0x864db4[_0x1ae3('0x3f')];_0x1b299d['order']=qs[_0x1ae3('0x48')](_0x2045d1[_0x1ae3('0x41')]['sort']);_0x1b299d[_0x1ae3('0x49')]=qs[_0x1ae3('0x42')](_[_0x1ae3('0x4a')](_0x2045d1[_0x1ae3('0x41')],_0x864db4[_0x1ae3('0x42')]));if(_0x2045d1['query']['filter']){_0x1b299d[_0x1ae3('0x49')]=_[_0x1ae3('0x4c')](_0x1b299d['where'],{'$or':_[_0x1ae3('0x4d')](_0x1b299d[_0x1ae3('0x45')],function(_0x232e1e){var _0x2c7cd5={};_0x2c7cd5[_0x232e1e]={'$like':'%'+_0x2045d1[_0x1ae3('0x41')][_0x1ae3('0x4b')]+'%'};return _0x2c7cd5;})});}_0x1b299d=_[_0x1ae3('0x4c')]({},_0x1b299d,_0x2045d1[_0x1ae3('0x51')]);return _0x524a88[_0x1ae3('0xc2')](_0x1b299d);}})[_0x1ae3('0x22')](function(_0x130201){if(_0x130201){_0x1a7971=_0x130201[_0x1ae3('0x5c')];if(!_0x2045d1['query'][_0x1ae3('0x66')](_0x1ae3('0x46'))){_0x1b299d[_0x1ae3('0x31')]=qs[_0x1ae3('0x31')](_0x2045d1[_0x1ae3('0x41')][_0x1ae3('0x31')]);_0x1b299d[_0x1ae3('0x30')]=qs[_0x1ae3('0x30')](_0x2045d1[_0x1ae3('0x41')][_0x1ae3('0x30')]);}return _0x524a88['getAgents'](_0x1b299d);}})[_0x1ae3('0x22')](function(_0x1f6644){if(_0x1f6644){return _0x1f6644?{'count':_0x1a7971,'rows':_0x1f6644}:null;}})[_0x1ae3('0x22')](respondWithResult(_0x54d840,null))[_0x1ae3('0x55')](handleError(_0x54d840,null));};
\ No newline at end of file
+var _0xb1fe=['MailMessage','$gte','split','format','YYYY-MM-DD\x20HH:mm:ss','CmList','List','updatedAt','DESC','from','%s\x20<%s>','attachments','join','root','server/files/attachments','basename','secure','auth','SendMail','sendMail','List\x20not\x20found','Contacts','subject','attach','out','messageId','Interaction','Messages','VerifySmtp','verifySmtp','Sequelize','ValidationError','You\x20can\x27t\x20remove\x20the\x20mail\x20service\x20account','addAgents','omit','spread','emit','userMailAccount:save','isArray','userMailAccount:remove','getAgents','eml-format','rimraf','request-promise','bluebird','mustache','util','path','to-csv','ejs','lodash','squel','crypto','jsforce','desk.js','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','defaults','redis','localhost','socket.io-emitter','./mailAccount.socket','register','jayson/promise','client','http','test','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','info','request\x20sent','debug','MailAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','MailAccount,\x20%s,\x20%s','message','result','sendStatus','end','json','count','offset','limit','status','set','Content-Range','apply','reject','save','update','destroy','get','UserProfileResource','stack','name','MailServerIn','Imap','MailServerOut','Smtp','MailAccount','rawAttributes','model','query','keys','filters','intersection','fields','attributes','hasOwnProperty','nolimit','order','sort','where','pick','merge','map','type','field','filter','includeAll','include','findAll','rows','catch','show','params','length','body','mandatoryDispositionPause','describe','addDisposition','find','Disposition','create','getDispositions','MailAccountId','options','removeDispositions','findOne','CannedAnswer','removeAnswers','key','email','ListId','isNil','active','description','cservice','cauthentication','user','cuser','password','authentication','host','port','service','pass','UserProfileSection','MailAccounts','userProfileId','autoAssociation','getImap','addImap','removeImap','setImap','getSmtp','addSmtp','removeSmtp','setSmtp','MailInteraction','addInteraction','ids','getInteractions','CmContact','User','Owner','fullname','internal','Tag','Tags','tag','addApplications','transaction','MailApplication','getApplications'];(function(_0x5ba52b,_0x3a60f4){var _0x1217f4=function(_0x5947b3){while(--_0x5947b3){_0x5ba52b['push'](_0x5ba52b['shift']());}};_0x1217f4(++_0x3a60f4);}(_0xb1fe,0xec));var _0xeb1f=function(_0x37ae76,_0x38f18a){_0x37ae76=_0x37ae76-0x0;var _0x4799be=_0xb1fe[_0x37ae76];return _0x4799be;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0xeb1f('0x0'));var rimraf=require(_0xeb1f('0x1'));var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require(_0xeb1f('0x2'));var moment=require('moment');var BPromise=require(_0xeb1f('0x3'));var Mustache=require(_0xeb1f('0x4'));var util=require(_0xeb1f('0x5'));var path=require(_0xeb1f('0x6'));var sox=require('sox');var csv=require(_0xeb1f('0x7'));var ejs=require(_0xeb1f('0x8'));var fs=require('fs');var _=require(_0xeb1f('0x9'));var squel=require(_0xeb1f('0xa'));var crypto=require(_0xeb1f('0xb'));var jsforce=require(_0xeb1f('0xc'));var deskjs=require(_0xeb1f('0xd'));var toCsv=require(_0xeb1f('0x7'));var querystring=require(_0xeb1f('0xe'));var Papa=require('papaparse');var Redis=require(_0xeb1f('0xf'));var authService=require(_0xeb1f('0x10'));var qs=require(_0xeb1f('0x11'));var hardwareService=require('../../config/license/hardware');var logger=require(_0xeb1f('0x12'))(_0xeb1f('0x13'));var utils=require(_0xeb1f('0x14'));var config=require(_0xeb1f('0x15'));var db=require(_0xeb1f('0x16'))['db'];config['redis']=_[_0xeb1f('0x17')](config[_0xeb1f('0x18')],{'host':_0xeb1f('0x19'),'port':0x18eb});var socket=require(_0xeb1f('0x1a'))(new Redis(config[_0xeb1f('0x18')]));require(_0xeb1f('0x1b'))[_0xeb1f('0x1c')](socket);var jayson=require(_0xeb1f('0x1d'));var client=jayson[_0xeb1f('0x1e')][_0xeb1f('0x1f')]({'port':0x232b});function checkPasswordPattern(_0x4e7fda,_0x199ca4,_0x26b613){if(_0x26b613){var _0x24e853=new RegExp(/(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[?!@#\$%\^&\*~\-_=+[{\]\}])(?=.{8,})/);if(_0x24e853[_0xeb1f('0x20')](_0x199ca4)){return _0x4e7fda;}else{throw new Error(_0xeb1f('0x21'));}}else{return _0x4e7fda;}}function respondWithRpcPromise(_0x5df446,_0x480a18,_0x2e829f,_0x42b9b1){return new BPromise(function(_0x2adbba,_0x28a328){var _0x1c8ebc=_0x42b9b1||client;return _0x1c8ebc[_0xeb1f('0x22')](_0x5df446,_0x2e829f)[_0xeb1f('0x23')](function(_0x430b2e){logger[_0xeb1f('0x24')]('MailAccount,\x20%s,\x20%s',_0x480a18,_0xeb1f('0x25'));logger[_0xeb1f('0x26')](_0xeb1f('0x27'),_0x480a18,'request\x20sent',JSON[_0xeb1f('0x28')](_0x430b2e));if(_0x430b2e[_0xeb1f('0x29')]){if(_0x430b2e[_0xeb1f('0x29')][_0xeb1f('0x2a')]===0x1f4){logger[_0xeb1f('0x29')](_0xeb1f('0x2b'),_0x480a18,_0x430b2e[_0xeb1f('0x29')][_0xeb1f('0x2c')]);return _0x28a328(_0x430b2e[_0xeb1f('0x29')][_0xeb1f('0x2c')]);}logger[_0xeb1f('0x29')]('MailAccount,\x20%s,\x20%s',_0x480a18,_0x430b2e[_0xeb1f('0x29')][_0xeb1f('0x2c')]);return _0x2adbba(_0x430b2e[_0xeb1f('0x29')]['message']);}else{logger[_0xeb1f('0x24')]('MailAccount,\x20%s,\x20%s',_0x480a18,'request\x20sent');_0x2adbba(_0x430b2e[_0xeb1f('0x2d')][_0xeb1f('0x2c')]);}})['catch'](function(_0xb458ea){logger[_0xeb1f('0x29')](_0xeb1f('0x2b'),_0x480a18,_0xb458ea);_0x28a328(_0xb458ea);});});}function respondWithStatusCode(_0x44e2a4,_0x581e5d){_0x581e5d=_0x581e5d||0xcc;return function(_0x4a7e8e){if(_0x4a7e8e){return _0x44e2a4[_0xeb1f('0x2e')](_0x581e5d);}return _0x44e2a4['status'](_0x581e5d)[_0xeb1f('0x2f')]();};}function respondWithResult(_0x57facd,_0x57bbbb){_0x57bbbb=_0x57bbbb||0xc8;return function(_0x23dde7){if(_0x23dde7){return _0x57facd['status'](_0x57bbbb)[_0xeb1f('0x30')](_0x23dde7);}};}function respondWithFilteredResult(_0x5864e8,_0x41e9e5){return function(_0x1b016b){if(_0x1b016b){var _0x8eeaa9=_0x1b016b[_0xeb1f('0x31')],_0x294ba1=_0x41e9e5[_0xeb1f('0x32')],_0x24e0d4=_0x41e9e5[_0xeb1f('0x32')]+_0x41e9e5[_0xeb1f('0x33')],_0x10b25d;if(_0x24e0d4>=_0x8eeaa9){_0x24e0d4=_0x8eeaa9;_0x10b25d=0xc8;}else{_0x10b25d=0xce;}_0x5864e8[_0xeb1f('0x34')](_0x10b25d);return _0x5864e8[_0xeb1f('0x35')](_0xeb1f('0x36'),_0x294ba1+'-'+_0x24e0d4+'/'+_0x8eeaa9)['json'](_0x1b016b);}return null;};}function patchUpdates(_0x1f99f1){return function(_0x1a9ac3){try{jsonpatch[_0xeb1f('0x37')](_0x1a9ac3,_0x1f99f1,!![]);}catch(_0x6dfa51){return BPromise[_0xeb1f('0x38')](_0x6dfa51);}return _0x1a9ac3[_0xeb1f('0x39')]();};}function saveUpdates(_0x4eeb3c,_0x20f8b3){return function(_0x5ece2e){if(_0x5ece2e){return _0x5ece2e[_0xeb1f('0x3a')](_0x4eeb3c)['then'](function(_0xc9326c){return _0xc9326c;});}return null;};}function removeEntity(_0x1765cb,_0x5651fb){return function(_0x3ff525){if(_0x3ff525){return _0x3ff525[_0xeb1f('0x3b')]()[_0xeb1f('0x23')](function(){var _0x18982b=_0x3ff525[_0xeb1f('0x3c')]({'plain':!![]});var _0x258f07='MailAccounts';return db[_0xeb1f('0x3d')][_0xeb1f('0x3b')]({'where':{'type':_0x258f07,'resourceId':_0x18982b['id']}})[_0xeb1f('0x23')](function(){return _0x3ff525;});})[_0xeb1f('0x23')](function(){_0x1765cb[_0xeb1f('0x34')](0xcc)['end']();});}};}function handleEntityNotFound(_0x5e9f16,_0x3cf212){return function(_0x339765){if(!_0x339765){_0x5e9f16['sendStatus'](0x194);}return _0x339765;};}function handleError(_0x808a61,_0x13f90e){_0x13f90e=_0x13f90e||0x1f4;return function(_0x291320){logger[_0xeb1f('0x29')](_0x291320[_0xeb1f('0x3e')]);if(_0x291320[_0xeb1f('0x3f')]){delete _0x291320['name'];}_0x808a61[_0xeb1f('0x34')](_0x13f90e)['send'](_0x291320);};}exports['index']=function(_0x70fba7,_0x695cd0){var _0x5ba170={'include':[{'model':db[_0xeb1f('0x40')],'as':_0xeb1f('0x41')},{'model':db[_0xeb1f('0x42')],'as':_0xeb1f('0x43')},{'model':db['Pause'],'as':'mandatoryDispositionPause'}]},_0x285ee0={},_0x1cd78b={'count':0x0,'rows':[]};var _0x153b21=db[_0xeb1f('0x44')][_0xeb1f('0x45')];_0x285ee0[_0xeb1f('0x46')]=_['keys'](_0x153b21);_0x285ee0[_0xeb1f('0x47')]=_[_0xeb1f('0x48')](_0x70fba7[_0xeb1f('0x47')]);_0x285ee0[_0xeb1f('0x49')]=_[_0xeb1f('0x4a')](_0x285ee0[_0xeb1f('0x46')],_0x285ee0[_0xeb1f('0x47')]);_0x5ba170['attributes']=_[_0xeb1f('0x4a')](_0x285ee0[_0xeb1f('0x46')],qs['fields'](_0x70fba7[_0xeb1f('0x47')][_0xeb1f('0x4b')]));_0x5ba170[_0xeb1f('0x4c')]=_0x5ba170[_0xeb1f('0x4c')]['length']?_0x5ba170['attributes']:_0x285ee0[_0xeb1f('0x46')];if(!_0x70fba7[_0xeb1f('0x47')][_0xeb1f('0x4d')](_0xeb1f('0x4e'))){_0x5ba170[_0xeb1f('0x33')]=qs[_0xeb1f('0x33')](_0x70fba7[_0xeb1f('0x47')]['limit']);_0x5ba170[_0xeb1f('0x32')]=qs[_0xeb1f('0x32')](_0x70fba7['query'][_0xeb1f('0x32')]);}_0x5ba170[_0xeb1f('0x4f')]=qs[_0xeb1f('0x50')](_0x70fba7['query']['sort']);_0x5ba170[_0xeb1f('0x51')]=qs[_0xeb1f('0x49')](_[_0xeb1f('0x52')](_0x70fba7['query'],_0x285ee0[_0xeb1f('0x49')]));if(_0x70fba7[_0xeb1f('0x47')]['filter']){_0x5ba170[_0xeb1f('0x51')]=_[_0xeb1f('0x53')](_0x5ba170[_0xeb1f('0x51')],{'$or':_[_0xeb1f('0x54')](_0x153b21,function(_0x95cdd0){if(_0x95cdd0[_0xeb1f('0x55')]['key']!=='VIRTUAL'){var _0xc8583b={};_0xc8583b[_0x95cdd0[_0xeb1f('0x56')]]={'$like':'%'+_0x70fba7[_0xeb1f('0x47')][_0xeb1f('0x57')]+'%'};return _0xc8583b;}})});}_0x5ba170=_[_0xeb1f('0x53')]({},_0x5ba170,_0x70fba7['options']);var _0x355a5c={'where':_0x5ba170['where']};return db[_0xeb1f('0x44')][_0xeb1f('0x31')](_0x355a5c)[_0xeb1f('0x23')](function(_0x212040){_0x1cd78b[_0xeb1f('0x31')]=_0x212040;if(_0x70fba7['query'][_0xeb1f('0x58')]){_0x5ba170[_0xeb1f('0x59')]=[{'all':!![]}];}return db[_0xeb1f('0x44')][_0xeb1f('0x5a')](_0x5ba170);})['then'](function(_0xded495){_0x1cd78b[_0xeb1f('0x5b')]=_0xded495;return _0x1cd78b;})[_0xeb1f('0x23')](respondWithFilteredResult(_0x695cd0,_0x5ba170))[_0xeb1f('0x5c')](handleError(_0x695cd0,null));};exports[_0xeb1f('0x5d')]=function(_0x28de6b,_0x237058){var _0x31ec07={'raw':![],'where':{'id':_0x28de6b[_0xeb1f('0x5e')]['id']},'include':[{'model':db[_0xeb1f('0x40')],'as':_0xeb1f('0x41')},{'model':db['MailServerOut'],'as':_0xeb1f('0x43')},{'model':db['Pause'],'as':'mandatoryDispositionPause'}]},_0x3db57b={};_0x3db57b[_0xeb1f('0x46')]=_[_0xeb1f('0x48')](db[_0xeb1f('0x44')][_0xeb1f('0x45')]);_0x3db57b[_0xeb1f('0x47')]=_[_0xeb1f('0x48')](_0x28de6b[_0xeb1f('0x47')]);_0x3db57b['filters']=_[_0xeb1f('0x4a')](_0x3db57b[_0xeb1f('0x46')],_0x3db57b[_0xeb1f('0x47')]);_0x31ec07['attributes']=_[_0xeb1f('0x4a')](_0x3db57b[_0xeb1f('0x46')],qs[_0xeb1f('0x4b')](_0x28de6b[_0xeb1f('0x47')][_0xeb1f('0x4b')]));_0x31ec07[_0xeb1f('0x4c')]=_0x31ec07[_0xeb1f('0x4c')][_0xeb1f('0x5f')]?_0x31ec07[_0xeb1f('0x4c')]:_0x3db57b[_0xeb1f('0x46')];if(_0x28de6b['query'][_0xeb1f('0x58')]){_0x31ec07[_0xeb1f('0x59')]=[{'all':!![]}];}_0x31ec07=_['merge']({},_0x31ec07,_0x28de6b['options']);return db['MailAccount']['find'](_0x31ec07)[_0xeb1f('0x23')](handleEntityNotFound(_0x237058,null))[_0xeb1f('0x23')](respondWithResult(_0x237058,null))['catch'](handleError(_0x237058,null));};exports[_0xeb1f('0x3a')]=function(_0x25227c,_0x347ae8){if(_0x25227c[_0xeb1f('0x60')]['id']){delete _0x25227c['body']['id'];}return db['MailAccount']['find']({'where':{'id':_0x25227c[_0xeb1f('0x5e')]['id']},'include':[{'model':db[_0xeb1f('0x40')],'as':'Imap'},{'model':db['MailServerOut'],'as':_0xeb1f('0x43')},{'model':db['Pause'],'as':_0xeb1f('0x61')}]})['then'](handleEntityNotFound(_0x347ae8,null))['then'](saveUpdates(_0x25227c['body'],null))[_0xeb1f('0x23')](function(_0x16a7c6){if(_0x16a7c6&&_0x25227c[_0xeb1f('0x60')]['Imap']){return db[_0xeb1f('0x40')][_0xeb1f('0x3a')](_0x25227c[_0xeb1f('0x60')]['Imap'],{'where':{'MailAccountId':_0x16a7c6['id']}})['then'](function(){return _0x16a7c6;});}return _0x16a7c6;})[_0xeb1f('0x23')](function(_0x57d894){if(_0x57d894&&_0x25227c['body'][_0xeb1f('0x43')]){return db[_0xeb1f('0x42')][_0xeb1f('0x3a')](_0x25227c[_0xeb1f('0x60')]['Smtp'],{'where':{'MailAccountId':_0x57d894['id']}})[_0xeb1f('0x23')](function(){return _0x57d894;});}return _0x57d894;})[_0xeb1f('0x23')](respondWithResult(_0x347ae8,null))[_0xeb1f('0x5c')](handleError(_0x347ae8,null));};exports['describe']=function(_0x284a0e,_0x1f278b){return db[_0xeb1f('0x44')][_0xeb1f('0x62')]()[_0xeb1f('0x23')](respondWithResult(_0x1f278b,null))[_0xeb1f('0x5c')](handleError(_0x1f278b,null));};exports[_0xeb1f('0x63')]=function(_0x3e1070,_0x17a70b,_0x152aa5){if(_0x3e1070[_0xeb1f('0x60')]['id']){delete _0x3e1070[_0xeb1f('0x60')]['id'];}return db[_0xeb1f('0x44')][_0xeb1f('0x64')]({'where':{'id':_0x3e1070['params']['id']}})['then'](handleEntityNotFound(_0x17a70b,null))['then'](function(_0x3b5695){if(_0x3b5695){_0x3e1070[_0xeb1f('0x60')]['MailAccountId']=_0x3b5695['id'];return db[_0xeb1f('0x65')][_0xeb1f('0x66')](_0x3e1070[_0xeb1f('0x60')]);}})[_0xeb1f('0x23')](respondWithResult(_0x17a70b,null))[_0xeb1f('0x5c')](handleError(_0x17a70b,null));};exports[_0xeb1f('0x67')]=function(_0x318c81,_0x74df50,_0x40ef3f){var _0x42e0c3={'raw':![],'where':{}};var _0xe9d0f7={};var _0x49c19e={'count':0x0,'rows':[]};return db[_0xeb1f('0x44')]['findOne']({'where':{'id':_0x318c81[_0xeb1f('0x5e')]['id']}})[_0xeb1f('0x23')](handleEntityNotFound(_0x74df50,null))[_0xeb1f('0x23')](function(_0x537927){if(_0x537927){_0xe9d0f7[_0xeb1f('0x46')]=_[_0xeb1f('0x48')](db[_0xeb1f('0x65')][_0xeb1f('0x45')]);_0xe9d0f7[_0xeb1f('0x47')]=_['keys'](_0x318c81['query']);_0xe9d0f7[_0xeb1f('0x49')]=_[_0xeb1f('0x4a')](_0xe9d0f7[_0xeb1f('0x46')],_0xe9d0f7[_0xeb1f('0x47')]);_0x42e0c3[_0xeb1f('0x4c')]=_[_0xeb1f('0x4a')](_0xe9d0f7[_0xeb1f('0x46')],qs[_0xeb1f('0x4b')](_0x318c81[_0xeb1f('0x47')]['fields']));_0x42e0c3['attributes']=_0x42e0c3[_0xeb1f('0x4c')]['length']?_0x42e0c3[_0xeb1f('0x4c')]:_0xe9d0f7[_0xeb1f('0x46')];if(!_0x318c81[_0xeb1f('0x47')][_0xeb1f('0x4d')]('nolimit')){_0x42e0c3[_0xeb1f('0x33')]=qs[_0xeb1f('0x33')](_0x318c81['query'][_0xeb1f('0x33')]);_0x42e0c3[_0xeb1f('0x32')]=qs[_0xeb1f('0x32')](_0x318c81['query'][_0xeb1f('0x32')]);}_0x42e0c3[_0xeb1f('0x4f')]=qs[_0xeb1f('0x50')](_0x318c81[_0xeb1f('0x47')][_0xeb1f('0x50')]);_0x42e0c3['where']=qs[_0xeb1f('0x49')](_[_0xeb1f('0x52')](_0x318c81[_0xeb1f('0x47')],_0xe9d0f7[_0xeb1f('0x49')]));_0x42e0c3[_0xeb1f('0x51')][_0xeb1f('0x68')]=_0x537927['id'];if(_0x318c81['query'][_0xeb1f('0x57')]){_0x42e0c3[_0xeb1f('0x51')]=_[_0xeb1f('0x53')](_0x42e0c3[_0xeb1f('0x51')],{'$or':_[_0xeb1f('0x54')](_0x42e0c3[_0xeb1f('0x4c')],function(_0x15b36d){var _0xf38ae9={};_0xf38ae9[_0x15b36d]={'$like':'%'+_0x318c81[_0xeb1f('0x47')][_0xeb1f('0x57')]+'%'};return _0xf38ae9;})});}_0x42e0c3=_[_0xeb1f('0x53')]({},_0x42e0c3,_0x318c81[_0xeb1f('0x69')]);return db[_0xeb1f('0x65')][_0xeb1f('0x31')]({'where':_0x42e0c3[_0xeb1f('0x51')]})[_0xeb1f('0x23')](function(_0x567d4d){_0x49c19e['count']=_0x567d4d;if(_0x318c81['query'][_0xeb1f('0x58')]){_0x42e0c3['include']=[{'all':!![]}];}return db['Disposition'][_0xeb1f('0x5a')](_0x42e0c3);})['then'](function(_0x58c2bb){_0x49c19e[_0xeb1f('0x5b')]=_0x58c2bb;return _0x49c19e;});}})[_0xeb1f('0x23')](respondWithFilteredResult(_0x74df50,_0x42e0c3))[_0xeb1f('0x5c')](handleError(_0x74df50,null));};exports[_0xeb1f('0x6a')]=function(_0x274a77,_0x591e62,_0x3335f1){return db[_0xeb1f('0x44')][_0xeb1f('0x64')]({'where':{'id':_0x274a77[_0xeb1f('0x5e')]['id']}})['then'](handleEntityNotFound(_0x591e62,null))[_0xeb1f('0x23')](function(_0x495b43){if(_0x495b43){return _0x495b43['removeDispositions'](_0x274a77[_0xeb1f('0x47')]['ids']);}})['then'](respondWithStatusCode(_0x591e62,null))[_0xeb1f('0x5c')](handleError(_0x591e62,null));};exports['addAnswer']=function(_0x49f58e,_0x4d9eb8,_0x24956a){if(_0x49f58e[_0xeb1f('0x60')]['id']){delete _0x49f58e['body']['id'];}return db[_0xeb1f('0x44')][_0xeb1f('0x64')]({'where':{'id':_0x49f58e['params']['id']}})[_0xeb1f('0x23')](handleEntityNotFound(_0x4d9eb8,null))[_0xeb1f('0x23')](function(_0x3e0a57){if(_0x3e0a57){_0x49f58e[_0xeb1f('0x60')][_0xeb1f('0x68')]=_0x3e0a57['id'];return db['CannedAnswer'][_0xeb1f('0x66')](_0x49f58e[_0xeb1f('0x60')]);}})[_0xeb1f('0x23')](respondWithResult(_0x4d9eb8,null))[_0xeb1f('0x5c')](handleError(_0x4d9eb8,null));};exports['getAnswers']=function(_0x49c284,_0x22bff9,_0x1f594a){var _0x2fdfc2={'raw':![],'where':{}};var _0x3ba576={};var _0x5151f1={'count':0x0,'rows':[]};return db['MailAccount'][_0xeb1f('0x6b')]({'where':{'id':_0x49c284[_0xeb1f('0x5e')]['id']}})[_0xeb1f('0x23')](handleEntityNotFound(_0x22bff9,null))[_0xeb1f('0x23')](function(_0x34914d){if(_0x34914d){_0x3ba576[_0xeb1f('0x46')]=_[_0xeb1f('0x48')](db['CannedAnswer']['rawAttributes']);_0x3ba576[_0xeb1f('0x47')]=_['keys'](_0x49c284[_0xeb1f('0x47')]);_0x3ba576[_0xeb1f('0x49')]=_[_0xeb1f('0x4a')](_0x3ba576[_0xeb1f('0x46')],_0x3ba576['query']);_0x2fdfc2[_0xeb1f('0x4c')]=_[_0xeb1f('0x4a')](_0x3ba576[_0xeb1f('0x46')],qs[_0xeb1f('0x4b')](_0x49c284[_0xeb1f('0x47')][_0xeb1f('0x4b')]));_0x2fdfc2['attributes']=_0x2fdfc2[_0xeb1f('0x4c')][_0xeb1f('0x5f')]?_0x2fdfc2[_0xeb1f('0x4c')]:_0x3ba576[_0xeb1f('0x46')];if(!_0x49c284[_0xeb1f('0x47')][_0xeb1f('0x4d')](_0xeb1f('0x4e'))){_0x2fdfc2[_0xeb1f('0x33')]=qs['limit'](_0x49c284[_0xeb1f('0x47')][_0xeb1f('0x33')]);_0x2fdfc2['offset']=qs[_0xeb1f('0x32')](_0x49c284[_0xeb1f('0x47')][_0xeb1f('0x32')]);}_0x2fdfc2[_0xeb1f('0x4f')]=qs['sort'](_0x49c284[_0xeb1f('0x47')]['sort']);_0x2fdfc2['where']=qs[_0xeb1f('0x49')](_[_0xeb1f('0x52')](_0x49c284[_0xeb1f('0x47')],_0x3ba576[_0xeb1f('0x49')]));_0x2fdfc2[_0xeb1f('0x51')]['MailAccountId']=_0x34914d['id'];if(_0x49c284[_0xeb1f('0x47')][_0xeb1f('0x57')]){_0x2fdfc2[_0xeb1f('0x51')]=_[_0xeb1f('0x53')](_0x2fdfc2[_0xeb1f('0x51')],{'$or':_['map'](_0x2fdfc2[_0xeb1f('0x4c')],function(_0x1f8f8d){var _0x567d5e={};_0x567d5e[_0x1f8f8d]={'$like':'%'+_0x49c284[_0xeb1f('0x47')][_0xeb1f('0x57')]+'%'};return _0x567d5e;})});}_0x2fdfc2=_[_0xeb1f('0x53')]({},_0x2fdfc2,_0x49c284[_0xeb1f('0x69')]);return db[_0xeb1f('0x6c')][_0xeb1f('0x31')]({'where':_0x2fdfc2['where']})[_0xeb1f('0x23')](function(_0x4e2127){_0x5151f1[_0xeb1f('0x31')]=_0x4e2127;if(_0x49c284[_0xeb1f('0x47')][_0xeb1f('0x58')]){_0x2fdfc2[_0xeb1f('0x59')]=[{'all':!![]}];}return db[_0xeb1f('0x6c')][_0xeb1f('0x5a')](_0x2fdfc2);})[_0xeb1f('0x23')](function(_0x2497be){_0x5151f1[_0xeb1f('0x5b')]=_0x2497be;return _0x5151f1;});}})['then'](respondWithFilteredResult(_0x22bff9,_0x2fdfc2))['catch'](handleError(_0x22bff9,null));};exports[_0xeb1f('0x6d')]=function(_0xbc1dc0,_0x417e5b,_0x49fd1c){return db['MailAccount']['find']({'where':{'id':_0xbc1dc0[_0xeb1f('0x5e')]['id']}})['then'](handleEntityNotFound(_0x417e5b,null))['then'](function(_0x514844){if(_0x514844){return _0x514844[_0xeb1f('0x6d')](_0xbc1dc0[_0xeb1f('0x47')]['ids']);}})[_0xeb1f('0x23')](respondWithStatusCode(_0x417e5b,null))[_0xeb1f('0x5c')](handleError(_0x417e5b,null));};exports[_0xeb1f('0x66')]=function(_0x4042df,_0x5668d0){var _0x53f093={'name':_0x4042df['body'][_0xeb1f('0x3f')],'key':_0x4042df[_0xeb1f('0x60')][_0xeb1f('0x6e')],'email':_0x4042df[_0xeb1f('0x60')][_0xeb1f('0x6f')],'ListId':_0x4042df[_0xeb1f('0x60')][_0xeb1f('0x70')],'active':!_[_0xeb1f('0x71')](_0x4042df['body'][_0xeb1f('0x72')])?_0x4042df[_0xeb1f('0x60')]['active']:!![],'description':_0x4042df[_0xeb1f('0x60')][_0xeb1f('0x73')]||null,'Imap':{},'Smtp':{}};if(_[_0xeb1f('0x71')](_0x4042df[_0xeb1f('0x60')][_0xeb1f('0x74')])){if(_0x4042df[_0xeb1f('0x60')][_0xeb1f('0x75')]){_0x53f093[_0xeb1f('0x41')][_0xeb1f('0x76')]=_0x53f093[_0xeb1f('0x43')][_0xeb1f('0x76')]=_0x4042df['body'][_0xeb1f('0x77')];_0x53f093[_0xeb1f('0x41')][_0xeb1f('0x78')]=_0x53f093[_0xeb1f('0x43')]['pass']=_0x4042df['body']['cpassword'];}else{_0x53f093[_0xeb1f('0x41')][_0xeb1f('0x79')]=_0x53f093[_0xeb1f('0x43')][_0xeb1f('0x79')]=![];}_0x53f093[_0xeb1f('0x41')][_0xeb1f('0x7a')]=_0x4042df[_0xeb1f('0x60')]['Imap']['host'];_0x53f093[_0xeb1f('0x41')]['port']=_0x4042df['body'][_0xeb1f('0x41')][_0xeb1f('0x7b')];_0x53f093[_0xeb1f('0x43')][_0xeb1f('0x7a')]=_0x4042df[_0xeb1f('0x60')]['Smtp']['host'];_0x53f093[_0xeb1f('0x43')][_0xeb1f('0x7b')]=_0x4042df[_0xeb1f('0x60')][_0xeb1f('0x43')][_0xeb1f('0x7b')];}else{_0x53f093[_0xeb1f('0x41')][_0xeb1f('0x7c')]=_0x53f093[_0xeb1f('0x43')][_0xeb1f('0x7c')]=_0x4042df[_0xeb1f('0x60')][_0xeb1f('0x74')];_0x53f093[_0xeb1f('0x41')][_0xeb1f('0x76')]=_0x53f093[_0xeb1f('0x43')][_0xeb1f('0x76')]=_0x4042df[_0xeb1f('0x60')]['cuser'];_0x53f093['Imap'][_0xeb1f('0x78')]=_0x53f093[_0xeb1f('0x43')][_0xeb1f('0x7d')]=_0x4042df[_0xeb1f('0x60')]['cpassword'];}return db[_0xeb1f('0x44')][_0xeb1f('0x66')](_0x53f093,{'include':[{'model':db[_0xeb1f('0x42')],'as':_0xeb1f('0x43')},{'model':db[_0xeb1f('0x40')],'as':_0xeb1f('0x41')}]})[_0xeb1f('0x23')](function(_0x568cbe){var _0x23f337=_0x4042df[_0xeb1f('0x76')][_0xeb1f('0x3c')]({'plain':!![]});if(!_0x23f337)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x23f337['role']===_0xeb1f('0x76')){var _0x1c2ab5=_0x568cbe['get']({'plain':!![]});return db[_0xeb1f('0x7e')][_0xeb1f('0x64')]({'where':{'name':_0xeb1f('0x7f'),'userProfileId':_0x23f337[_0xeb1f('0x80')]},'raw':!![]})[_0xeb1f('0x23')](function(_0x49c06a){if(_0x49c06a&&_0x49c06a[_0xeb1f('0x81')]===0x0){return db[_0xeb1f('0x3d')][_0xeb1f('0x66')]({'name':_0x1c2ab5['name'],'resourceId':_0x1c2ab5['id'],'type':_0x49c06a[_0xeb1f('0x3f')],'sectionId':_0x49c06a['id']},{})[_0xeb1f('0x23')](function(){return _0x568cbe;});}else{return _0x568cbe;}})[_0xeb1f('0x5c')](function(_0x365a65){logger['error']('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x365a65);throw _0x365a65;});}return _0x568cbe;})[_0xeb1f('0x23')](respondWithResult(_0x5668d0,0xc9))['catch'](handleError(_0x5668d0,null));};exports[_0xeb1f('0x82')]=function(_0xbc2b6f,_0x42f516,_0x1d18e9){return db[_0xeb1f('0x44')][_0xeb1f('0x6b')]({'where':{'id':_0xbc2b6f[_0xeb1f('0x5e')]['id']}})[_0xeb1f('0x23')](handleEntityNotFound(_0x42f516,null))[_0xeb1f('0x23')](function(_0x2a0866){if(_0x2a0866){return _0x2a0866[_0xeb1f('0x82')]();}return null;})[_0xeb1f('0x23')](respondWithResult(_0x42f516,null))[_0xeb1f('0x5c')](handleError(_0x42f516,null));};exports[_0xeb1f('0x83')]=function(_0x377c78,_0x46bd4d,_0x3055dc){if(_0x377c78['body']['id']){delete _0x377c78['body']['id'];}return db[_0xeb1f('0x44')][_0xeb1f('0x64')]({'where':{'id':_0x377c78[_0xeb1f('0x5e')]['id']}})[_0xeb1f('0x23')](handleEntityNotFound(_0x46bd4d,null))['then'](function(_0x466056){if(_0x466056){_0x377c78['body']['MailAccountId']=_0x466056['id'];return db[_0xeb1f('0x40')][_0xeb1f('0x66')](_0x377c78[_0xeb1f('0x60')]);}})[_0xeb1f('0x23')](respondWithResult(_0x46bd4d,null))[_0xeb1f('0x5c')](handleError(_0x46bd4d,null));};exports[_0xeb1f('0x84')]=function(_0x35b36b,_0x1cb4a5,_0x3637fd){return db['MailAccount']['findOne']({'where':{'id':_0x35b36b[_0xeb1f('0x5e')]['id']}})[_0xeb1f('0x23')](handleEntityNotFound(_0x1cb4a5,null))[_0xeb1f('0x23')](function(_0x413158){if(_0x413158){return _0x413158[_0xeb1f('0x85')](null);}return null;})[_0xeb1f('0x23')](respondWithStatusCode(_0x1cb4a5,null))[_0xeb1f('0x5c')](handleError(_0x1cb4a5,null));};exports['getSmtp']=function(_0x3c30f8,_0x2c3ac5,_0x39055e){return db[_0xeb1f('0x44')][_0xeb1f('0x6b')]({'where':{'id':_0x3c30f8['params']['id']}})[_0xeb1f('0x23')](handleEntityNotFound(_0x2c3ac5,null))[_0xeb1f('0x23')](function(_0x361bf3){if(_0x361bf3){return _0x361bf3[_0xeb1f('0x86')]();}return null;})[_0xeb1f('0x23')](respondWithResult(_0x2c3ac5,null))['catch'](handleError(_0x2c3ac5,null));};exports[_0xeb1f('0x87')]=function(_0x43dc43,_0x361032,_0x356768){if(_0x43dc43[_0xeb1f('0x60')]['id']){delete _0x43dc43[_0xeb1f('0x60')]['id'];}return db['MailAccount']['find']({'where':{'id':_0x43dc43['params']['id']}})['then'](handleEntityNotFound(_0x361032,null))[_0xeb1f('0x23')](function(_0x31d039){if(_0x31d039){_0x43dc43[_0xeb1f('0x60')][_0xeb1f('0x68')]=_0x31d039['id'];return db[_0xeb1f('0x42')][_0xeb1f('0x66')](_0x43dc43[_0xeb1f('0x60')]);}})[_0xeb1f('0x23')](respondWithResult(_0x361032,null))[_0xeb1f('0x5c')](handleError(_0x361032,null));};exports[_0xeb1f('0x88')]=function(_0x2375a2,_0x560c10,_0x425cf3){return db['MailAccount'][_0xeb1f('0x6b')]({'where':{'id':_0x2375a2['params']['id']}})['then'](handleEntityNotFound(_0x560c10,null))['then'](function(_0x47f24c){if(_0x47f24c){return _0x47f24c[_0xeb1f('0x89')](null);}return null;})[_0xeb1f('0x23')](respondWithStatusCode(_0x560c10,null))[_0xeb1f('0x5c')](handleError(_0x560c10,null));};exports['addInteraction']=function(_0x1fb47c,_0x2bea47,_0x55eb2c){return db[_0xeb1f('0x8a')][_0xeb1f('0x64')]({'where':{'id':_0x1fb47c[_0xeb1f('0x5e')]['id']}})[_0xeb1f('0x23')](handleEntityNotFound(_0x2bea47,null))[_0xeb1f('0x23')](function(_0x4b8227){if(_0x4b8227){return _0x4b8227[_0xeb1f('0x8b')](_0x1fb47c[_0xeb1f('0x60')][_0xeb1f('0x8c')],_['omit'](_0x1fb47c[_0xeb1f('0x60')],[_0xeb1f('0x8c'),'id'])||{});}})[_0xeb1f('0x23')](respondWithResult(_0x2bea47,null))['catch'](handleError(_0x2bea47,null));};exports[_0xeb1f('0x8d')]=function(_0x2cd3b2,_0x57d23a,_0x345ad8){var _0x43bc4b={'raw':![],'where':{}};var _0x38d802={};var _0xf663a9={'count':0x0,'rows':[]};return db['MailAccount']['findOne']({'where':{'id':_0x2cd3b2[_0xeb1f('0x5e')]['id']}})['then'](handleEntityNotFound(_0x57d23a,null))[_0xeb1f('0x23')](function(_0x4528e7){if(_0x4528e7){_0x38d802[_0xeb1f('0x46')]=_[_0xeb1f('0x48')](db['MailInteraction']['rawAttributes']);_0x38d802[_0xeb1f('0x47')]=_[_0xeb1f('0x48')](_0x2cd3b2['query']);_0x38d802[_0xeb1f('0x49')]=_[_0xeb1f('0x4a')](_0x38d802[_0xeb1f('0x46')],_0x38d802[_0xeb1f('0x47')]);_0x43bc4b['attributes']=_[_0xeb1f('0x4a')](_0x38d802[_0xeb1f('0x46')],qs['fields'](_0x2cd3b2[_0xeb1f('0x47')][_0xeb1f('0x4b')]));_0x43bc4b[_0xeb1f('0x4c')]=_0x43bc4b[_0xeb1f('0x4c')][_0xeb1f('0x5f')]?_0x43bc4b[_0xeb1f('0x4c')]:_0x38d802['model'];if(!_0x2cd3b2[_0xeb1f('0x47')][_0xeb1f('0x4d')](_0xeb1f('0x4e'))){_0x43bc4b['limit']=qs['limit'](_0x2cd3b2['query'][_0xeb1f('0x33')]);_0x43bc4b['offset']=qs['offset'](_0x2cd3b2[_0xeb1f('0x47')][_0xeb1f('0x32')]);}_0x43bc4b[_0xeb1f('0x4f')]=qs[_0xeb1f('0x50')](_0x2cd3b2[_0xeb1f('0x47')][_0xeb1f('0x50')]);_0x43bc4b[_0xeb1f('0x51')]=qs[_0xeb1f('0x49')](_['pick'](_0x2cd3b2[_0xeb1f('0x47')],_0x38d802[_0xeb1f('0x49')]));_0x43bc4b['where'][_0xeb1f('0x68')]=_0x4528e7['id'];if(_0x2cd3b2[_0xeb1f('0x47')]['filter']){_0x43bc4b['where']=_[_0xeb1f('0x53')](_0x43bc4b[_0xeb1f('0x51')],{'$or':_[_0xeb1f('0x54')](_0x43bc4b['attributes'],function(_0x1227d3){var _0x572f33={};_0x572f33[_0x1227d3]={'$like':'%'+_0x2cd3b2[_0xeb1f('0x47')][_0xeb1f('0x57')]+'%'};return _0x572f33;})});}_0x43bc4b=_[_0xeb1f('0x53')]({},_0x43bc4b,_0x2cd3b2['options']);return db[_0xeb1f('0x8a')][_0xeb1f('0x31')]({'where':_0x43bc4b[_0xeb1f('0x51')]})['then'](function(_0x1a37ad){_0xf663a9['count']=_0x1a37ad;if(_0x2cd3b2[_0xeb1f('0x47')][_0xeb1f('0x58')]){_0x43bc4b[_0xeb1f('0x59')]=[{'model':db[_0xeb1f('0x8e')],'as':'Contact','required':![]},{'model':db[_0xeb1f('0x8f')],'as':_0xeb1f('0x90'),'attributes':['name',_0xeb1f('0x91'),_0xeb1f('0x92')],'required':![]},{'model':db[_0xeb1f('0x93')],'as':_0xeb1f('0x94'),'attributes':['id',_0xeb1f('0x3f'),'color'],'where':_0x2cd3b2[_0xeb1f('0x47')]['tag']?{'id':_0x2cd3b2[_0xeb1f('0x47')][_0xeb1f('0x95')]}:undefined,'required':_0x2cd3b2[_0xeb1f('0x47')][_0xeb1f('0x95')]?!![]:![]}];}return db['MailInteraction'][_0xeb1f('0x5a')](_0x43bc4b);})['then'](function(_0x528333){_0xf663a9[_0xeb1f('0x5b')]=_0x528333;return _0xf663a9;});}})[_0xeb1f('0x23')](respondWithFilteredResult(_0x57d23a,_0x43bc4b))[_0xeb1f('0x5c')](handleError(_0x57d23a,null));};exports[_0xeb1f('0x96')]=function(_0x24f40b,_0x28cd60,_0x150ab3){return db['MailAccount'][_0xeb1f('0x6b')]({'where':{'id':_0x24f40b['params']['id']}})[_0xeb1f('0x23')](handleEntityNotFound(_0x28cd60,null))[_0xeb1f('0x23')](function(_0x4c7645){if(_0x4c7645){return db['sequelize'][_0xeb1f('0x97')](function(_0x4590b4){return db['MailApplication'][_0xeb1f('0x3b')]({'where':{'MailAccountId':_0x24f40b[_0xeb1f('0x5e')]['id']},'transaction':_0x4590b4})[_0xeb1f('0x23')](function(_0x49fd21){var _0x3e280d=_[_0xeb1f('0x54')](_0x24f40b[_0xeb1f('0x60')],function(_0x597bf7){_0x597bf7['MailAccountId']=_0x24f40b[_0xeb1f('0x5e')]['id'];return _0x597bf7;});return db[_0xeb1f('0x98')]['bulkCreate'](_0x3e280d,{'transaction':_0x4590b4});});})[_0xeb1f('0x23')](function(){return db[_0xeb1f('0x98')]['findAndCountAll']({'where':{'MailAccountId':_0x24f40b[_0xeb1f('0x5e')]['id']},'order':'priority'});});}})[_0xeb1f('0x23')](respondWithResult(_0x28cd60,null))[_0xeb1f('0x5c')](handleError(_0x28cd60,null));};exports[_0xeb1f('0x99')]=function(_0x97da02,_0x3af4f5,_0x14da9c){var _0x1adfc6={};var _0xb86495={};var _0x3bf5c3;var _0x4ca706;return db[_0xeb1f('0x44')][_0xeb1f('0x6b')]({'where':{'id':_0x97da02[_0xeb1f('0x5e')]['id']}})['then'](handleEntityNotFound(_0x3af4f5,null))[_0xeb1f('0x23')](function(_0x3bae5b){if(_0x3bae5b){_0x3bf5c3=_0x3bae5b;_0xb86495['model']=_[_0xeb1f('0x48')](db['MailApplication']['rawAttributes']);_0xb86495[_0xeb1f('0x47')]=_['keys'](_0x97da02[_0xeb1f('0x47')]);_0xb86495[_0xeb1f('0x49')]=_[_0xeb1f('0x4a')](_0xb86495[_0xeb1f('0x46')],_0xb86495[_0xeb1f('0x47')]);_0x1adfc6['attributes']=_[_0xeb1f('0x4a')](_0xb86495['model'],qs['fields'](_0x97da02['query']['fields']));_0x1adfc6[_0xeb1f('0x4c')]=_0x1adfc6[_0xeb1f('0x4c')]['length']?_0x1adfc6[_0xeb1f('0x4c')]:_0xb86495[_0xeb1f('0x46')];_0x1adfc6[_0xeb1f('0x4f')]=qs[_0xeb1f('0x50')](_0x97da02[_0xeb1f('0x47')]['sort']);_0x1adfc6[_0xeb1f('0x51')]=qs[_0xeb1f('0x49')](_[_0xeb1f('0x52')](_0x97da02[_0xeb1f('0x47')],_0xb86495[_0xeb1f('0x49')]));if(_0x97da02[_0xeb1f('0x47')]['filter']){_0x1adfc6[_0xeb1f('0x51')]=_[_0xeb1f('0x53')](_0x1adfc6[_0xeb1f('0x51')],{'$or':_[_0xeb1f('0x54')](_0x1adfc6[_0xeb1f('0x4c')],function(_0x5935d0){var _0x4bd2ab={};_0x4bd2ab[_0x5935d0]={'$like':'%'+_0x97da02[_0xeb1f('0x47')][_0xeb1f('0x57')]+'%'};return _0x4bd2ab;})});}_0x1adfc6=_['merge']({},_0x1adfc6,_0x97da02[_0xeb1f('0x69')]);return _0x3bf5c3[_0xeb1f('0x99')](_0x1adfc6);}})[_0xeb1f('0x23')](function(_0x1aff88){if(_0x1aff88){_0x4ca706=_0x1aff88[_0xeb1f('0x5f')];if(!_0x97da02[_0xeb1f('0x47')][_0xeb1f('0x4d')]('nolimit')){_0x1adfc6[_0xeb1f('0x33')]=qs[_0xeb1f('0x33')](_0x97da02[_0xeb1f('0x47')]['limit']);_0x1adfc6[_0xeb1f('0x32')]=qs[_0xeb1f('0x32')](_0x97da02['query']['offset']);}return _0x3bf5c3[_0xeb1f('0x99')](_0x1adfc6);}})['then'](function(_0x21ba3f){if(_0x21ba3f){return _0x21ba3f?{'count':_0x4ca706,'rows':_0x21ba3f}:null;}})['then'](respondWithResult(_0x3af4f5,null))['catch'](handleError(_0x3af4f5,null));};exports['getMessages']=function(_0x13eaa6,_0x1ee07f,_0x2c698c){var _0x40f59a={'raw':!![],'where':{}};var _0xddbe5={};var _0x4f1ea9={'count':0x0,'rows':[]};return db['MailAccount'][_0xeb1f('0x6b')]({'where':{'id':_0x13eaa6['params']['id']}})[_0xeb1f('0x23')](handleEntityNotFound(_0x1ee07f,null))[_0xeb1f('0x23')](function(_0x5550fd){if(_0x5550fd){_0xddbe5[_0xeb1f('0x46')]=_['keys'](db[_0xeb1f('0x9a')]['rawAttributes']);_0xddbe5[_0xeb1f('0x47')]=_['keys'](_0x13eaa6[_0xeb1f('0x47')]);_0xddbe5[_0xeb1f('0x49')]=_[_0xeb1f('0x4a')](_0xddbe5[_0xeb1f('0x46')],_0xddbe5['query']);_0x40f59a['attributes']=_['intersection'](_0xddbe5[_0xeb1f('0x46')],qs['fields'](_0x13eaa6[_0xeb1f('0x47')][_0xeb1f('0x4b')]));_0x40f59a['attributes']=_0x40f59a[_0xeb1f('0x4c')][_0xeb1f('0x5f')]?_0x40f59a[_0xeb1f('0x4c')]:_0xddbe5['model'];if(!_0x13eaa6[_0xeb1f('0x47')][_0xeb1f('0x4d')](_0xeb1f('0x4e'))){_0x40f59a['limit']=qs[_0xeb1f('0x33')](_0x13eaa6[_0xeb1f('0x47')][_0xeb1f('0x33')]);_0x40f59a[_0xeb1f('0x32')]=qs['offset'](_0x13eaa6[_0xeb1f('0x47')][_0xeb1f('0x32')]);}_0x40f59a['order']=qs['sort'](_0x13eaa6[_0xeb1f('0x47')]['sort']);_0x40f59a['where']=qs[_0xeb1f('0x49')](_[_0xeb1f('0x52')](_0x13eaa6['query'],_0xddbe5[_0xeb1f('0x49')]));_0x40f59a[_0xeb1f('0x51')][_0xeb1f('0x68')]=_0x5550fd['id'];if(_0x13eaa6['query'][_0xeb1f('0x57')]){_0x40f59a['where']=_[_0xeb1f('0x53')](_0x40f59a['where'],{'$or':_[_0xeb1f('0x54')](_0x40f59a[_0xeb1f('0x4c')],function(_0x3504d1){var _0x376f31={};_0x376f31[_0x3504d1]={'$like':'%'+_0x13eaa6['query']['filter']+'%'};return _0x376f31;})});}if(_0x13eaa6[_0xeb1f('0x47')][_0xeb1f('0x9b')]){var _0x1a8738=_0x13eaa6[_0xeb1f('0x47')]['$gte'][_0xeb1f('0x9c')](',');var _0x45bf62={};_0x45bf62[_0x1a8738[0x0]]={'$gte':moment(_0x1a8738[0x1])[_0xeb1f('0x9d')](_0xeb1f('0x9e'))};_0x40f59a['where']=_[_0xeb1f('0x53')](_0x40f59a['where'],_0x45bf62);}_0x40f59a=_[_0xeb1f('0x53')]({},_0x40f59a,_0x13eaa6[_0xeb1f('0x69')]);return db[_0xeb1f('0x9a')][_0xeb1f('0x31')]({'where':_0x40f59a[_0xeb1f('0x51')]})[_0xeb1f('0x23')](function(_0x5e8ca8){_0x4f1ea9[_0xeb1f('0x31')]=_0x5e8ca8;if(_0x13eaa6[_0xeb1f('0x47')][_0xeb1f('0x58')]){_0x40f59a[_0xeb1f('0x59')]=[{'all':!![]}];}return db[_0xeb1f('0x9a')][_0xeb1f('0x5a')](_0x40f59a);})[_0xeb1f('0x23')](function(_0x1c5d4a){_0x4f1ea9[_0xeb1f('0x5b')]=_0x1c5d4a;return _0x4f1ea9;});}})[_0xeb1f('0x23')](respondWithFilteredResult(_0x1ee07f,_0x40f59a))[_0xeb1f('0x5c')](handleError(_0x1ee07f,null));};exports['send']=function(_0xff2968,_0x4bb828,_0x12dbf9){var _0x59f895,_0x5453b1={},_0x2732a1;if(_0xff2968[_0xeb1f('0x60')]['to']){_0x2732a1=_0xff2968['body']['to'][_0xeb1f('0x9c')](',')[0x0];}return db[_0xeb1f('0x44')][_0xeb1f('0x64')]({'where':{'id':_0xff2968['params']['id']},'include':[{'model':db[_0xeb1f('0x9f')],'as':_0xeb1f('0xa0'),'include':[{'model':db[_0xeb1f('0x8e')],'as':'Contacts','where':{'email':_0x2732a1},'limit':0x1,'order':[[_0xeb1f('0xa1'),_0xeb1f('0xa2')]]}]},{'model':db['MailServerOut'],'as':_0xeb1f('0x43'),'raw':!![]}]})[_0xeb1f('0x23')](handleEntityNotFound(_0x4bb828,null))[_0xeb1f('0x23')](function(_0x10d55d){if(_0x10d55d){_0x59f895=_0x10d55d;if(_0x10d55d['Smtp']){if(_[_0xeb1f('0x71')](_0xff2968['body'][_0xeb1f('0xa3')])){_0xff2968[_0xeb1f('0x60')][_0xeb1f('0xa3')]=util[_0xeb1f('0x9d')](_0xeb1f('0xa4'),_0x10d55d[_0xeb1f('0x3f')],_0x10d55d[_0xeb1f('0x6f')]||_0x10d55d[_0xeb1f('0x43')]['user']);}if(_0xff2968[_0xeb1f('0x60')]['attachments']&&_0xff2968[_0xeb1f('0x60')]['attachments'][_0xeb1f('0x5f')]){for(var _0x298f3c=0x0;_0x298f3c<_0xff2968[_0xeb1f('0x60')][_0xeb1f('0xa5')][_0xeb1f('0x5f')];_0x298f3c+=0x1){_0xff2968[_0xeb1f('0x60')][_0xeb1f('0xa5')][_0x298f3c]={'filename':_0xff2968[_0xeb1f('0x60')][_0xeb1f('0xa5')][_0x298f3c]['name'],'path':path[_0xeb1f('0xa6')](config[_0xeb1f('0xa7')],_0xeb1f('0xa8'),_0xff2968[_0xeb1f('0x60')]['attachments'][_0x298f3c][_0xeb1f('0xa9')])};}}var _0x4c629c={'tls':{'rejectUnauthorized':![]}};if(_[_0xeb1f('0x71')](_0x10d55d[_0xeb1f('0x43')][_0xeb1f('0x7c')])){if(_0x10d55d[_0xeb1f('0x43')][_0xeb1f('0x79')]){_0x4c629c['auth']={'user':_0x10d55d[_0xeb1f('0x43')]['user'],'pass':_0x10d55d['Smtp'][_0xeb1f('0x7d')]};}_0x4c629c[_0xeb1f('0x7a')]=_0x10d55d[_0xeb1f('0x43')][_0xeb1f('0x7a')];_0x4c629c[_0xeb1f('0x7b')]=_0x10d55d[_0xeb1f('0x43')]['port'];_0x4c629c[_0xeb1f('0xaa')]=_0x10d55d[_0xeb1f('0x43')][_0xeb1f('0xaa')];}else{_0x4c629c[_0xeb1f('0x7c')]=_0x10d55d[_0xeb1f('0x43')]['service'];_0x4c629c[_0xeb1f('0xab')]={'user':_0x10d55d['Smtp']['user'],'pass':_0x10d55d[_0xeb1f('0x43')]['pass']};}return respondWithRpcPromise(_0xeb1f('0xac'),_0xeb1f('0xad'),{'account':_0x4c629c,'message':_0xff2968[_0xeb1f('0x60')]});}else{throw new Error(_0xeb1f('0xae'));}}})['then'](function(_0x4d2955){if(_0x4d2955){_0x5453b1=_0x4d2955;if(_0x59f895[_0xeb1f('0xa0')]){if(_0x59f895['List'][_0xeb1f('0xaf')][_0xeb1f('0x5f')]){return _0x59f895[_0xeb1f('0xa0')][_0xeb1f('0xaf')][0x0];}else{return db['CmContact'][_0xeb1f('0x66')](_[_0xeb1f('0x17')](_0xff2968[_0xeb1f('0x60')],{'firstName':_0xff2968['body']['to'],'email':_0xff2968[_0xeb1f('0x60')]['to'],'phone':_0xff2968[_0xeb1f('0x60')]['to'],'ListId':_0x59f895[_0xeb1f('0x70')]}));}}else{throw new Error(_0xeb1f('0xae'));}}})['then'](function(_0x341f92){if(_0x341f92){var _0x435891={'UserId':_0xff2968[_0xeb1f('0x76')]['id'],'ContactId':_0x341f92['id'],'MailAccountId':_0x59f895['id'],'inReplyTo':_0x5453b1['messageId'],'to':_0xff2968[_0xeb1f('0x60')][_0xeb1f('0xa3')],'cc':_0xff2968[_0xeb1f('0x60')]['cc'],'subject':_0xff2968[_0xeb1f('0x60')][_0xeb1f('0xb0')],'attach':_0xff2968[_0xeb1f('0x60')][_0xeb1f('0xb1')],'firstMsgDirection':_0xeb1f('0xb2'),'lastMsgAt':moment()[_0xeb1f('0x9d')](_0xeb1f('0x9e')),'lastMsgDirection':_0xeb1f('0xb2'),'lastMsgBody':_0xff2968[_0xeb1f('0x60')][_0xeb1f('0x60')],'Messages':[_['merge'](_0xff2968['body'],{'messageId':_0x5453b1[_0xeb1f('0xb3')],'sentAt':moment()[_0xeb1f('0x9d')](_0xeb1f('0x9e')),'read':!![],'MailAccountId':_0x59f895['id'],'UserId':_0xff2968[_0xeb1f('0x76')]['id'],'ContactId':_0x341f92['id']})]};if(_0xff2968[_0xeb1f('0x60')][_0xeb1f('0xb4')]){_0x435891=_['merge'](_0x435891,_0xff2968[_0xeb1f('0x60')]['Interaction']);}return db[_0xeb1f('0x8a')][_0xeb1f('0x66')](_0x435891,{'include':[{'model':db[_0xeb1f('0x9a')],'as':_0xeb1f('0xb5')}]});}})['then'](respondWithResult(_0x4bb828,null))[_0xeb1f('0x5c')](handleError(_0x4bb828,null));};exports['verifySmtp']=function(_0x36d880,_0x5d5c61,_0x1b5a9a){return db['MailAccount'][_0xeb1f('0x64')]({'where':{'id':_0x36d880[_0xeb1f('0x5e')]['id']},'include':[{'model':db[_0xeb1f('0x42')],'as':_0xeb1f('0x43'),'raw':!![]}]})[_0xeb1f('0x23')](handleEntityNotFound(_0x5d5c61,null))[_0xeb1f('0x23')](function(_0xafe45d){if(_0xafe45d&&_0xafe45d[_0xeb1f('0x43')]){var _0x3b1f99={'id':_0xafe45d['id'],'tls':{'rejectUnauthorized':![]}};if(_0xafe45d[_0xeb1f('0x43')][_0xeb1f('0x7c')]){_0x3b1f99['service']=_0xafe45d[_0xeb1f('0x43')][_0xeb1f('0x7c')];}else{_0x3b1f99[_0xeb1f('0x7a')]=_0xafe45d['Smtp'][_0xeb1f('0x7a')];_0x3b1f99[_0xeb1f('0x7b')]=_0xafe45d[_0xeb1f('0x43')][_0xeb1f('0x7b')];_0x3b1f99[_0xeb1f('0xaa')]=_0xafe45d[_0xeb1f('0x43')][_0xeb1f('0xaa')];}if(_0xafe45d[_0xeb1f('0x43')][_0xeb1f('0x79')]){_0x3b1f99['auth']={'user':_0xafe45d[_0xeb1f('0x43')][_0xeb1f('0x76')],'pass':_0xafe45d['Smtp'][_0xeb1f('0x7d')]};}return respondWithRpcPromise(_0xeb1f('0xb6'),_0xeb1f('0xb7'),{'account':_0x3b1f99});}})[_0xeb1f('0x23')](respondWithResult(_0x5d5c61,null))[_0xeb1f('0x5c')](handleError(_0x5d5c61,null));};exports['destroy']=function(_0x298fe5,_0x55f691){return db[_0xeb1f('0x44')]['find']({'where':{'id':_0x298fe5[_0xeb1f('0x5e')]['id']}})[_0xeb1f('0x23')](handleEntityNotFound(_0x55f691,null))['then'](function(_0x20f64e){if(_0x20f64e&&_0x20f64e['service']){throw new db[(_0xeb1f('0xb8'))][(_0xeb1f('0xb9'))](_0xeb1f('0xba'));}return _0x20f64e;})[_0xeb1f('0x23')](removeEntity(_0x55f691,null))['catch'](handleError(_0x55f691,null));};exports['addAgents']=function(_0x11a63,_0x36100b,_0x2eb060){return db[_0xeb1f('0x44')][_0xeb1f('0x64')]({'where':{'id':_0x11a63['params']['id']}})['then'](handleEntityNotFound(_0x36100b,null))[_0xeb1f('0x23')](function(_0x44ed38){if(_0x44ed38){return _0x44ed38[_0xeb1f('0xbb')](_0x11a63[_0xeb1f('0x60')]['ids'],_[_0xeb1f('0xbc')](_0x11a63[_0xeb1f('0x60')],[_0xeb1f('0x8c'),'id'])||{})[_0xeb1f('0xbd')](function(_0x2db04e){for(var _0x53d699=0x0;_0x53d699<_0x11a63['body'][_0xeb1f('0x8c')]['length'];_0x53d699+=0x1){socket[_0xeb1f('0xbe')](_0xeb1f('0xbf'),{'UserId':_0x11a63['body'][_0xeb1f('0x8c')][_0x53d699],'MailAccountId':_0x11a63[_0xeb1f('0x5e')]['id']});}return _0x2db04e;});}})[_0xeb1f('0x23')](respondWithResult(_0x36100b,null))[_0xeb1f('0x5c')](handleError(_0x36100b,null));};exports['removeAgents']=function(_0x433848,_0xb74b05,_0x25a124){return db[_0xeb1f('0x44')]['find']({'where':{'id':_0x433848['params']['id']}})['then'](handleEntityNotFound(_0xb74b05,null))[_0xeb1f('0x23')](function(_0x643032){if(_0x643032){return _0x643032['removeAgents'](_0x433848[_0xeb1f('0x47')][_0xeb1f('0x8c')])[_0xeb1f('0x23')](function(){if(_[_0xeb1f('0xc0')](_0x433848['query'][_0xeb1f('0x8c')])){for(var _0x4b2e14=0x0;_0x4b2e14<_0x433848[_0xeb1f('0x47')]['ids'][_0xeb1f('0x5f')];_0x4b2e14+=0x1){socket[_0xeb1f('0xbe')]('userMailAccount:remove',{'UserId':Number(_0x433848[_0xeb1f('0x47')][_0xeb1f('0x8c')][_0x4b2e14]),'MailAccountId':Number(_0x433848[_0xeb1f('0x5e')]['id'])});}}else{socket[_0xeb1f('0xbe')](_0xeb1f('0xc1'),{'UserId':Number(_0x433848['query']['ids']),'MailAccountId':Number(_0x433848['params']['id'])});}});}})['then'](respondWithStatusCode(_0xb74b05,null))[_0xeb1f('0x5c')](handleError(_0xb74b05,null));};exports[_0xeb1f('0xc2')]=function(_0x4e3bc0,_0x56e73a,_0x2c013e){var _0x3a8b53={};var _0x33cffb={};var _0x3f1298;var _0x1ef29b;return db['MailAccount'][_0xeb1f('0x6b')]({'where':{'id':_0x4e3bc0[_0xeb1f('0x5e')]['id']}})[_0xeb1f('0x23')](handleEntityNotFound(_0x56e73a,null))[_0xeb1f('0x23')](function(_0x3a7e26){if(_0x3a7e26){_0x3f1298=_0x3a7e26;_0x33cffb['model']=_[_0xeb1f('0x48')](db[_0xeb1f('0x8f')]['rawAttributes']);_0x33cffb[_0xeb1f('0x47')]=_[_0xeb1f('0x48')](_0x4e3bc0['query']);_0x33cffb['filters']=_[_0xeb1f('0x4a')](_0x33cffb['model'],_0x33cffb['query']);_0x3a8b53['attributes']=_[_0xeb1f('0x4a')](_0x33cffb[_0xeb1f('0x46')],qs['fields'](_0x4e3bc0[_0xeb1f('0x47')]['fields']));_0x3a8b53[_0xeb1f('0x4c')]=_0x3a8b53[_0xeb1f('0x4c')][_0xeb1f('0x5f')]?_0x3a8b53[_0xeb1f('0x4c')]:_0x33cffb[_0xeb1f('0x46')];_0x3a8b53[_0xeb1f('0x4f')]=qs[_0xeb1f('0x50')](_0x4e3bc0[_0xeb1f('0x47')][_0xeb1f('0x50')]);_0x3a8b53['where']=qs[_0xeb1f('0x49')](_[_0xeb1f('0x52')](_0x4e3bc0[_0xeb1f('0x47')],_0x33cffb['filters']));if(_0x4e3bc0[_0xeb1f('0x47')][_0xeb1f('0x57')]){_0x3a8b53['where']=_[_0xeb1f('0x53')](_0x3a8b53[_0xeb1f('0x51')],{'$or':_['map'](_0x3a8b53[_0xeb1f('0x4c')],function(_0x30b3d6){var _0x558dd5={};_0x558dd5[_0x30b3d6]={'$like':'%'+_0x4e3bc0['query'][_0xeb1f('0x57')]+'%'};return _0x558dd5;})});}_0x3a8b53=_['merge']({},_0x3a8b53,_0x4e3bc0['options']);return _0x3f1298[_0xeb1f('0xc2')](_0x3a8b53);}})['then'](function(_0x34a293){if(_0x34a293){_0x1ef29b=_0x34a293[_0xeb1f('0x5f')];if(!_0x4e3bc0[_0xeb1f('0x47')][_0xeb1f('0x4d')](_0xeb1f('0x4e'))){_0x3a8b53['limit']=qs[_0xeb1f('0x33')](_0x4e3bc0[_0xeb1f('0x47')]['limit']);_0x3a8b53[_0xeb1f('0x32')]=qs[_0xeb1f('0x32')](_0x4e3bc0[_0xeb1f('0x47')][_0xeb1f('0x32')]);}return _0x3f1298[_0xeb1f('0xc2')](_0x3a8b53);}})['then'](function(_0x47b26d){if(_0x47b26d){return _0x47b26d?{'count':_0x1ef29b,'rows':_0x47b26d}:null;}})[_0xeb1f('0x23')](respondWithResult(_0x56e73a,null))['catch'](handleError(_0x56e73a,null));};
\ No newline at end of file