Built motion from commit 932cf0d0.|2.5.42
[motion2.git] / server / api / mailAccount / mailAccount.controller.js
index 3ad481c..877fd7c 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x1c59=['Imap','includeAll','find','update','body','modernAuthentication','CloudProviderId','params','describe','Disposition','create','include','findAll','removeDispositions','addAnswer','MailAccountId','CannedAnswer','getAnswers','findOne','hasOwnProperty','removeAnswers','ids','custom','provider','email','isNil','description','user','password','pass','service','host','port','authentication','username','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','getImap','addImap','removeImap','setImap','getSmtp','addSmtp','removeSmtp','setSmtp','addInteraction','MailInteraction','omit','getInteractions','CmContact','Contact','Owner','fullname','internal','Tag','color','tag','addApplications','sequelize','transaction','ISOLATION_LEVELS','MailApplication','bulkCreate','findAndCountAll','priority','finally','getApplications','getMessages','MailMessage','$gte','format','YYYY-MM-DD\x20HH:mm:ss','inlineCss','true','split','Contacts','updatedAt','DESC','from','%s\x20<%s>','attachments','join','server/files/attachments','basename','secure','auth','sendMail','List\x20not\x20found','List','ListId','messageId','attach','out','Interaction','Messages','CloudProvider','OAuth2','VerifySmtp','Sequelize','ValidationError','You\x20can\x27t\x20remove\x20the\x20mail\x20service\x20account','addAgents','spread','emit','userMailAccount:save','removeAgents','isArray','userMailAccount:remove','User','getAgents','moment','bluebird','path','lodash','juice','../../config/logger','api','../../config/environment','../../mysqldb','redis','defaults','localhost','socket.io-emitter','register','client','http','info','MailAccount,\x20%s,\x20%s','debug','MailAccount,\x20%s,\x20%s,\x20%s','stringify','error','message','result','catch','end','status','json','offset','undefined','count','set','then','destroy','get','MailAccounts','UserProfileResource','sendStatus','stack','name','send','index','MailServerIn','MailServerOut','Smtp','Pause','mandatoryDispositionPause','MailAccount','rawAttributes','type','key','map','query','keys','intersection','model','fields','attributes','length','nolimit','limit','order','sort','where','filters','pick','filter','merge','VIRTUAL','options','rows','show'];(function(_0x2446ce,_0x21d439){var _0x30b895=function(_0x526739){while(--_0x526739){_0x2446ce['push'](_0x2446ce['shift']());}};_0x30b895(++_0x21d439);}(_0x1c59,0x71));var _0x91c5=function(_0x44545d,_0x34c540){_0x44545d=_0x44545d-0x0;var _0x5cc9c2=_0x1c59[_0x44545d];return _0x5cc9c2;};'use strict';var moment=require(_0x91c5('0x0'));var BPromise=require(_0x91c5('0x1'));var util=require('util');var path=require(_0x91c5('0x2'));var _=require(_0x91c5('0x3'));var juice=require(_0x91c5('0x4'));var Redis=require('ioredis');var qs=require('../../components/parsers/qs');var logger=require(_0x91c5('0x5'))(_0x91c5('0x6'));var config=require(_0x91c5('0x7'));var db=require(_0x91c5('0x8'))['db'];config[_0x91c5('0x9')]=_[_0x91c5('0xa')](config[_0x91c5('0x9')],{'host':_0x91c5('0xb'),'port':0x18eb});var socket=require(_0x91c5('0xc'))(new Redis(config[_0x91c5('0x9')]));require('./mailAccount.socket')[_0x91c5('0xd')](socket);var jayson=require('jayson/promise');var client=jayson[_0x91c5('0xe')][_0x91c5('0xf')]({'port':0x232b});function respondWithRpcPromise(_0x1f2a1f,_0x4b5efd,_0x5c29a4,_0x19097f){return new BPromise(function(_0x2fbebc,_0x48bdea){var _0x2ecfd2=_0x19097f||client;return _0x2ecfd2['request'](_0x1f2a1f,_0x5c29a4)['then'](function(_0x4eb168){logger[_0x91c5('0x10')](_0x91c5('0x11'),_0x4b5efd,'request\x20sent');logger[_0x91c5('0x12')](_0x91c5('0x13'),_0x4b5efd,'request\x20sent',JSON[_0x91c5('0x14')](_0x4eb168));if(_0x4eb168[_0x91c5('0x15')]){if(_0x4eb168['error']['code']===0x1f4){logger['error'](_0x91c5('0x11'),_0x4b5efd,_0x4eb168[_0x91c5('0x15')][_0x91c5('0x16')]);return _0x48bdea(_0x4eb168[_0x91c5('0x15')][_0x91c5('0x16')]);}logger['error']('MailAccount,\x20%s,\x20%s',_0x4b5efd,_0x4eb168[_0x91c5('0x15')][_0x91c5('0x16')]);return _0x2fbebc(_0x4eb168['error'][_0x91c5('0x16')]);}else{logger['info']('MailAccount,\x20%s,\x20%s',_0x4b5efd,'request\x20sent');_0x2fbebc(_0x4eb168[_0x91c5('0x17')][_0x91c5('0x16')]);}})[_0x91c5('0x18')](function(_0x5a3343){logger['error']('MailAccount,\x20%s,\x20%s',_0x4b5efd,_0x5a3343);_0x48bdea(_0x5a3343);});});}function respondWithStatusCode(_0x503ce4,_0x1ff4f0){_0x1ff4f0=_0x1ff4f0||0xcc;return function(_0x476568){if(_0x476568){return _0x503ce4['sendStatus'](_0x1ff4f0);}return _0x503ce4['status'](_0x1ff4f0)[_0x91c5('0x19')]();};}function respondWithResult(_0x36a37f,_0x31e9fb){_0x31e9fb=_0x31e9fb||0xc8;return function(_0x367017){if(_0x367017){return _0x36a37f[_0x91c5('0x1a')](_0x31e9fb)[_0x91c5('0x1b')](_0x367017);}};}function respondWithFilteredResult(_0x61e15,_0x5a005f){return function(_0x295943){if(_0x295943){var _0x23eb81=typeof _0x5a005f[_0x91c5('0x1c')]===_0x91c5('0x1d')&&typeof _0x5a005f['limit']===_0x91c5('0x1d');var _0x7062ed=_0x295943[_0x91c5('0x1e')];var _0x5b235f=_0x23eb81?0x0:_0x5a005f['offset'];var _0xab440e=_0x23eb81?_0x295943[_0x91c5('0x1e')]:_0x5a005f[_0x91c5('0x1c')]+_0x5a005f['limit'];var _0xc55159;if(_0xab440e>=_0x7062ed){_0xab440e=_0x7062ed;_0xc55159=0xc8;}else{_0xc55159=0xce;}_0x61e15[_0x91c5('0x1a')](_0xc55159);return _0x61e15[_0x91c5('0x1f')]('Content-Range',_0x5b235f+'-'+_0xab440e+'/'+_0x7062ed)[_0x91c5('0x1b')](_0x295943);}return null;};}function saveUpdates(_0x3bb525){return function(_0x403abd){if(_0x403abd){return _0x403abd['update'](_0x3bb525)[_0x91c5('0x20')](function(_0x33b260){return _0x33b260;});}return null;};}function removeEntity(_0x2278e3){return function(_0x4b2c2b){if(_0x4b2c2b){return _0x4b2c2b[_0x91c5('0x21')]()[_0x91c5('0x20')](function(){var _0x259a44=_0x4b2c2b[_0x91c5('0x22')]({'plain':!![]});var _0x3999a8=_0x91c5('0x23');return db[_0x91c5('0x24')][_0x91c5('0x21')]({'where':{'type':_0x3999a8,'resourceId':_0x259a44['id']}})['then'](function(){return _0x4b2c2b;});})[_0x91c5('0x20')](function(){_0x2278e3[_0x91c5('0x1a')](0xcc)[_0x91c5('0x19')]();});}};}function handleEntityNotFound(_0x1dfece){return function(_0x404b22){if(!_0x404b22){_0x1dfece[_0x91c5('0x25')](0x194);}return _0x404b22;};}function handleError(_0x274c30,_0x385dee){_0x385dee=_0x385dee||0x1f4;return function(_0x52778c){logger[_0x91c5('0x15')](_0x52778c[_0x91c5('0x26')]);if(_0x52778c[_0x91c5('0x27')]){delete _0x52778c[_0x91c5('0x27')];}_0x274c30[_0x91c5('0x1a')](_0x385dee)[_0x91c5('0x28')](_0x52778c);};}exports[_0x91c5('0x29')]=function(_0x406ed9,_0x54abe6){var _0x4d4c20={'include':[{'model':db[_0x91c5('0x2a')],'as':'Imap'},{'model':db[_0x91c5('0x2b')],'as':_0x91c5('0x2c')},{'model':db[_0x91c5('0x2d')],'as':_0x91c5('0x2e')}]},_0x549b0c={},_0x22345e={'count':0x0,'rows':[]};var _0x3b5766=_['map'](db[_0x91c5('0x2f')][_0x91c5('0x30')],function(_0xcff556){return{'name':_0xcff556['fieldName'],'type':_0xcff556[_0x91c5('0x31')][_0x91c5('0x32')]};});_0x549b0c['model']=_[_0x91c5('0x33')](_0x3b5766,_0x91c5('0x27'));_0x549b0c[_0x91c5('0x34')]=_[_0x91c5('0x35')](_0x406ed9['query']);_0x549b0c['filters']=_[_0x91c5('0x36')](_0x549b0c[_0x91c5('0x37')],_0x549b0c[_0x91c5('0x34')]);_0x4d4c20['attributes']=_[_0x91c5('0x36')](_0x549b0c[_0x91c5('0x37')],qs[_0x91c5('0x38')](_0x406ed9[_0x91c5('0x34')][_0x91c5('0x38')]));_0x4d4c20['attributes']=_0x4d4c20[_0x91c5('0x39')][_0x91c5('0x3a')]?_0x4d4c20['attributes']:_0x549b0c[_0x91c5('0x37')];if(!_0x406ed9['query']['hasOwnProperty'](_0x91c5('0x3b'))){_0x4d4c20[_0x91c5('0x3c')]=qs[_0x91c5('0x3c')](_0x406ed9[_0x91c5('0x34')][_0x91c5('0x3c')]);_0x4d4c20[_0x91c5('0x1c')]=qs[_0x91c5('0x1c')](_0x406ed9[_0x91c5('0x34')][_0x91c5('0x1c')]);}_0x4d4c20[_0x91c5('0x3d')]=qs[_0x91c5('0x3e')](_0x406ed9[_0x91c5('0x34')][_0x91c5('0x3e')]);_0x4d4c20[_0x91c5('0x3f')]=qs[_0x91c5('0x40')](_[_0x91c5('0x41')](_0x406ed9[_0x91c5('0x34')],_0x549b0c[_0x91c5('0x40')]),_0x3b5766);if(_0x406ed9[_0x91c5('0x34')][_0x91c5('0x42')]){_0x4d4c20[_0x91c5('0x3f')]=_[_0x91c5('0x43')](_0x4d4c20[_0x91c5('0x3f')],{'$or':_[_0x91c5('0x33')](_0x3b5766,function(_0x1170d7){if(_0x1170d7[_0x91c5('0x31')]!==_0x91c5('0x44')){var _0x175124={};_0x175124[_0x1170d7[_0x91c5('0x27')]]={'$like':'%'+_0x406ed9[_0x91c5('0x34')][_0x91c5('0x42')]+'%'};return _0x175124;}})});}_0x4d4c20=_['merge']({},_0x4d4c20,_0x406ed9[_0x91c5('0x45')]);var _0x3bea08={'where':_0x4d4c20['where']};return db[_0x91c5('0x2f')][_0x91c5('0x1e')](_0x3bea08)['then'](function(_0x237816){_0x22345e[_0x91c5('0x1e')]=_0x237816;if(_0x406ed9[_0x91c5('0x34')]['includeAll']){_0x4d4c20['include']=[{'all':!![]}];}return db[_0x91c5('0x2f')]['findAll'](_0x4d4c20);})[_0x91c5('0x20')](function(_0x3990a4){_0x22345e[_0x91c5('0x46')]=_0x3990a4;return _0x22345e;})[_0x91c5('0x20')](respondWithFilteredResult(_0x54abe6,_0x4d4c20))[_0x91c5('0x18')](handleError(_0x54abe6,null));};exports[_0x91c5('0x47')]=function(_0x2d7c7c,_0x3b29c3){var _0x3e766e={'raw':![],'where':{'id':_0x2d7c7c['params']['id']},'include':[{'model':db[_0x91c5('0x2a')],'as':_0x91c5('0x48')},{'model':db[_0x91c5('0x2b')],'as':_0x91c5('0x2c')},{'model':db[_0x91c5('0x2d')],'as':_0x91c5('0x2e')}]},_0x542052={};_0x542052['model']=_['keys'](db[_0x91c5('0x2f')]['rawAttributes']);_0x542052['query']=_['keys'](_0x2d7c7c[_0x91c5('0x34')]);_0x542052['filters']=_[_0x91c5('0x36')](_0x542052[_0x91c5('0x37')],_0x542052[_0x91c5('0x34')]);_0x3e766e[_0x91c5('0x39')]=_[_0x91c5('0x36')](_0x542052[_0x91c5('0x37')],qs[_0x91c5('0x38')](_0x2d7c7c[_0x91c5('0x34')]['fields']));_0x3e766e[_0x91c5('0x39')]=_0x3e766e[_0x91c5('0x39')]['length']?_0x3e766e[_0x91c5('0x39')]:_0x542052[_0x91c5('0x37')];if(_0x2d7c7c[_0x91c5('0x34')][_0x91c5('0x49')]){_0x3e766e['include']=[{'all':!![]}];}_0x3e766e=_['merge']({},_0x3e766e,_0x2d7c7c[_0x91c5('0x45')]);return db[_0x91c5('0x2f')][_0x91c5('0x4a')](_0x3e766e)[_0x91c5('0x20')](handleEntityNotFound(_0x3b29c3,null))['then'](respondWithResult(_0x3b29c3,null))['catch'](handleError(_0x3b29c3,null));};exports[_0x91c5('0x4b')]=function(_0x488631,_0x5ce100){if(_0x488631['body']['id']){delete _0x488631['body']['id'];}if(_0x488631[_0x91c5('0x4c')][_0x91c5('0x48')]){if(!_0x488631['body'][_0x91c5('0x48')][_0x91c5('0x4d')]){_0x488631['body'][_0x91c5('0x48')][_0x91c5('0x4e')]=null;}}if(_0x488631[_0x91c5('0x4c')][_0x91c5('0x2c')]){if(!_0x488631[_0x91c5('0x4c')][_0x91c5('0x2c')][_0x91c5('0x4d')]){_0x488631[_0x91c5('0x4c')][_0x91c5('0x2c')][_0x91c5('0x4e')]=null;}}return db[_0x91c5('0x2f')][_0x91c5('0x4a')]({'where':{'id':_0x488631[_0x91c5('0x4f')]['id']},'include':[{'model':db['MailServerIn'],'as':_0x91c5('0x48')},{'model':db['MailServerOut'],'as':'Smtp'},{'model':db[_0x91c5('0x2d')],'as':_0x91c5('0x2e')}]})[_0x91c5('0x20')](handleEntityNotFound(_0x5ce100,null))['then'](saveUpdates(_0x488631[_0x91c5('0x4c')],null))['then'](function(_0x1f216e){if(_0x1f216e&&_0x488631[_0x91c5('0x4c')]['Imap']){return db[_0x91c5('0x2a')]['update'](_0x488631['body']['Imap'],{'where':{'MailAccountId':_0x1f216e['id']}})[_0x91c5('0x20')](function(){return _0x1f216e;});}return _0x1f216e;})[_0x91c5('0x20')](function(_0x50a7ab){if(_0x50a7ab&&_0x488631[_0x91c5('0x4c')][_0x91c5('0x2c')]){return db[_0x91c5('0x2b')][_0x91c5('0x4b')](_0x488631[_0x91c5('0x4c')]['Smtp'],{'where':{'MailAccountId':_0x50a7ab['id']}})['then'](function(){return _0x50a7ab;});}return _0x50a7ab;})[_0x91c5('0x20')](respondWithResult(_0x5ce100,null))[_0x91c5('0x18')](handleError(_0x5ce100,null));};exports['describe']=function(_0x43d0e5,_0x37d3c1){return db[_0x91c5('0x2f')][_0x91c5('0x50')]()[_0x91c5('0x20')](respondWithResult(_0x37d3c1,null))[_0x91c5('0x18')](handleError(_0x37d3c1,null));};exports['addDisposition']=function(_0x32df83,_0x26e872){if(_0x32df83[_0x91c5('0x4c')]['id']){delete _0x32df83['body']['id'];}return db[_0x91c5('0x2f')][_0x91c5('0x4a')]({'where':{'id':_0x32df83[_0x91c5('0x4f')]['id']}})[_0x91c5('0x20')](handleEntityNotFound(_0x26e872,null))['then'](function(_0x596fa6){if(_0x596fa6){_0x32df83[_0x91c5('0x4c')]['MailAccountId']=_0x596fa6['id'];return db[_0x91c5('0x51')][_0x91c5('0x52')](_0x32df83['body']);}})[_0x91c5('0x20')](respondWithResult(_0x26e872,null))[_0x91c5('0x18')](handleError(_0x26e872,null));};exports['getDispositions']=function(_0x42e0e4,_0x170a41){var _0x167bbe={'raw':![],'where':{}};var _0x5cd7d7={};var _0x76ba0b={'count':0x0,'rows':[]};return db[_0x91c5('0x2f')]['findOne']({'where':{'id':_0x42e0e4['params']['id']}})[_0x91c5('0x20')](handleEntityNotFound(_0x170a41,null))[_0x91c5('0x20')](function(_0x255302){if(_0x255302){_0x5cd7d7[_0x91c5('0x37')]=_[_0x91c5('0x35')](db['Disposition'][_0x91c5('0x30')]);_0x5cd7d7[_0x91c5('0x34')]=_[_0x91c5('0x35')](_0x42e0e4[_0x91c5('0x34')]);_0x5cd7d7[_0x91c5('0x40')]=_['intersection'](_0x5cd7d7[_0x91c5('0x37')],_0x5cd7d7[_0x91c5('0x34')]);_0x167bbe[_0x91c5('0x39')]=_[_0x91c5('0x36')](_0x5cd7d7[_0x91c5('0x37')],qs[_0x91c5('0x38')](_0x42e0e4['query'][_0x91c5('0x38')]));_0x167bbe[_0x91c5('0x39')]=_0x167bbe[_0x91c5('0x39')][_0x91c5('0x3a')]?_0x167bbe[_0x91c5('0x39')]:_0x5cd7d7['model'];if(!_0x42e0e4[_0x91c5('0x34')]['hasOwnProperty'](_0x91c5('0x3b'))){_0x167bbe[_0x91c5('0x3c')]=qs['limit'](_0x42e0e4[_0x91c5('0x34')]['limit']);_0x167bbe[_0x91c5('0x1c')]=qs[_0x91c5('0x1c')](_0x42e0e4[_0x91c5('0x34')][_0x91c5('0x1c')]);}_0x167bbe[_0x91c5('0x3d')]=qs[_0x91c5('0x3e')](_0x42e0e4[_0x91c5('0x34')][_0x91c5('0x3e')]);_0x167bbe[_0x91c5('0x3f')]=qs[_0x91c5('0x40')](_[_0x91c5('0x41')](_0x42e0e4[_0x91c5('0x34')],_0x5cd7d7[_0x91c5('0x40')]));_0x167bbe[_0x91c5('0x3f')]['MailAccountId']=_0x255302['id'];if(_0x42e0e4[_0x91c5('0x34')]['filter']){_0x167bbe[_0x91c5('0x3f')]=_[_0x91c5('0x43')](_0x167bbe[_0x91c5('0x3f')],{'$or':_[_0x91c5('0x33')](_0x167bbe[_0x91c5('0x39')],function(_0x37a09b){var _0x4dda45={};_0x4dda45[_0x37a09b]={'$like':'%'+_0x42e0e4[_0x91c5('0x34')][_0x91c5('0x42')]+'%'};return _0x4dda45;})});}_0x167bbe=_[_0x91c5('0x43')]({},_0x167bbe,_0x42e0e4[_0x91c5('0x45')]);return db[_0x91c5('0x51')][_0x91c5('0x1e')]({'where':_0x167bbe['where']})[_0x91c5('0x20')](function(_0x2e1a15){_0x76ba0b[_0x91c5('0x1e')]=_0x2e1a15;if(_0x42e0e4[_0x91c5('0x34')]['includeAll']){_0x167bbe[_0x91c5('0x53')]=[{'all':!![]}];}return db['Disposition'][_0x91c5('0x54')](_0x167bbe);})[_0x91c5('0x20')](function(_0x1261f2){_0x76ba0b[_0x91c5('0x46')]=_0x1261f2;return _0x76ba0b;});}})[_0x91c5('0x20')](respondWithFilteredResult(_0x170a41,_0x167bbe))[_0x91c5('0x18')](handleError(_0x170a41,null));};exports['removeDispositions']=function(_0x3656d2,_0x3c6782){return db[_0x91c5('0x2f')][_0x91c5('0x4a')]({'where':{'id':_0x3656d2[_0x91c5('0x4f')]['id']}})[_0x91c5('0x20')](handleEntityNotFound(_0x3c6782,null))[_0x91c5('0x20')](function(_0x5d25f0){if(_0x5d25f0){return _0x5d25f0[_0x91c5('0x55')](_0x3656d2[_0x91c5('0x34')]['ids']);}})[_0x91c5('0x20')](respondWithStatusCode(_0x3c6782,null))['catch'](handleError(_0x3c6782,null));};exports[_0x91c5('0x56')]=function(_0x291ef2,_0xd36373){if(_0x291ef2['body']['id']){delete _0x291ef2[_0x91c5('0x4c')]['id'];}return db[_0x91c5('0x2f')]['find']({'where':{'id':_0x291ef2['params']['id']}})[_0x91c5('0x20')](handleEntityNotFound(_0xd36373,null))['then'](function(_0x55a316){if(_0x55a316){_0x291ef2[_0x91c5('0x4c')][_0x91c5('0x57')]=_0x55a316['id'];return db[_0x91c5('0x58')][_0x91c5('0x52')](_0x291ef2[_0x91c5('0x4c')]);}})[_0x91c5('0x20')](respondWithResult(_0xd36373,null))[_0x91c5('0x18')](handleError(_0xd36373,null));};exports[_0x91c5('0x59')]=function(_0x59683d,_0x519553){var _0x20fe9a={'raw':![],'where':{}};var _0x43e467={};var _0x1a7019={'count':0x0,'rows':[]};return db[_0x91c5('0x2f')][_0x91c5('0x5a')]({'where':{'id':_0x59683d[_0x91c5('0x4f')]['id']}})['then'](handleEntityNotFound(_0x519553,null))[_0x91c5('0x20')](function(_0x314eb1){if(_0x314eb1){_0x43e467[_0x91c5('0x37')]=_['keys'](db[_0x91c5('0x58')]['rawAttributes']);_0x43e467[_0x91c5('0x34')]=_[_0x91c5('0x35')](_0x59683d[_0x91c5('0x34')]);_0x43e467[_0x91c5('0x40')]=_[_0x91c5('0x36')](_0x43e467['model'],_0x43e467[_0x91c5('0x34')]);_0x20fe9a[_0x91c5('0x39')]=_[_0x91c5('0x36')](_0x43e467['model'],qs[_0x91c5('0x38')](_0x59683d[_0x91c5('0x34')]['fields']));_0x20fe9a[_0x91c5('0x39')]=_0x20fe9a[_0x91c5('0x39')][_0x91c5('0x3a')]?_0x20fe9a[_0x91c5('0x39')]:_0x43e467[_0x91c5('0x37')];if(!_0x59683d[_0x91c5('0x34')][_0x91c5('0x5b')](_0x91c5('0x3b'))){_0x20fe9a[_0x91c5('0x3c')]=qs['limit'](_0x59683d[_0x91c5('0x34')][_0x91c5('0x3c')]);_0x20fe9a[_0x91c5('0x1c')]=qs[_0x91c5('0x1c')](_0x59683d[_0x91c5('0x34')][_0x91c5('0x1c')]);}_0x20fe9a[_0x91c5('0x3d')]=qs[_0x91c5('0x3e')](_0x59683d[_0x91c5('0x34')]['sort']);_0x20fe9a[_0x91c5('0x3f')]=qs['filters'](_['pick'](_0x59683d[_0x91c5('0x34')],_0x43e467[_0x91c5('0x40')]));_0x20fe9a[_0x91c5('0x3f')][_0x91c5('0x57')]=_0x314eb1['id'];if(_0x59683d[_0x91c5('0x34')][_0x91c5('0x42')]){_0x20fe9a[_0x91c5('0x3f')]=_[_0x91c5('0x43')](_0x20fe9a[_0x91c5('0x3f')],{'$or':_[_0x91c5('0x33')](_0x20fe9a[_0x91c5('0x39')],function(_0x593e85){var _0x317cd6={};_0x317cd6[_0x593e85]={'$like':'%'+_0x59683d['query']['filter']+'%'};return _0x317cd6;})});}_0x20fe9a=_[_0x91c5('0x43')]({},_0x20fe9a,_0x59683d['options']);return db[_0x91c5('0x58')][_0x91c5('0x1e')]({'where':_0x20fe9a[_0x91c5('0x3f')]})[_0x91c5('0x20')](function(_0x1a21ef){_0x1a7019[_0x91c5('0x1e')]=_0x1a21ef;if(_0x59683d[_0x91c5('0x34')][_0x91c5('0x49')]){_0x20fe9a[_0x91c5('0x53')]=[{'all':!![]}];}return db[_0x91c5('0x58')][_0x91c5('0x54')](_0x20fe9a);})[_0x91c5('0x20')](function(_0x5dd55f){_0x1a7019[_0x91c5('0x46')]=_0x5dd55f;return _0x1a7019;});}})['then'](respondWithFilteredResult(_0x519553,_0x20fe9a))[_0x91c5('0x18')](handleError(_0x519553,null));};exports[_0x91c5('0x5c')]=function(_0x45e42b,_0x2f4cef){return db[_0x91c5('0x2f')][_0x91c5('0x4a')]({'where':{'id':_0x45e42b[_0x91c5('0x4f')]['id']}})['then'](handleEntityNotFound(_0x2f4cef,null))[_0x91c5('0x20')](function(_0x37de2e){if(_0x37de2e){return _0x37de2e[_0x91c5('0x5c')](_0x45e42b['query'][_0x91c5('0x5d')]);}})['then'](respondWithStatusCode(_0x2f4cef,null))[_0x91c5('0x18')](handleError(_0x2f4cef,null));};exports[_0x91c5('0x52')]=function(_0x2765f2,_0x20edeb){var _0x5aade0={'name':_0x2765f2[_0x91c5('0x4c')][_0x91c5('0x27')],'key':_0x2765f2[_0x91c5('0x4c')]['key'],'provider':_0x2765f2[_0x91c5('0x4c')]['provider']===_0x91c5('0x5e')?null:_0x2765f2['body'][_0x91c5('0x5f')],'email':_0x2765f2[_0x91c5('0x4c')][_0x91c5('0x60')],'ListId':_0x2765f2[_0x91c5('0x4c')]['ListId'],'active':!_[_0x91c5('0x61')](_0x2765f2[_0x91c5('0x4c')]['active'])?_0x2765f2[_0x91c5('0x4c')]['active']:!![],'description':_0x2765f2[_0x91c5('0x4c')][_0x91c5('0x62')]||null,'Imap':{},'Smtp':{}};if(_0x5aade0['provider']){_0x5aade0[_0x91c5('0x48')][_0x91c5('0x63')]=_0x5aade0[_0x91c5('0x2c')]['user']=_0x2765f2[_0x91c5('0x4c')]['username'];_0x5aade0['Imap'][_0x91c5('0x64')]=_0x5aade0[_0x91c5('0x2c')]['pass']=_0x2765f2[_0x91c5('0x4c')]['password'];if(_0x2765f2[_0x91c5('0x4c')][_0x91c5('0x4d')]){_0x5aade0[_0x91c5('0x48')][_0x91c5('0x4d')]=_0x5aade0[_0x91c5('0x2c')][_0x91c5('0x4d')]=!![];_0x5aade0[_0x91c5('0x48')][_0x91c5('0x4e')]=_0x5aade0[_0x91c5('0x2c')][_0x91c5('0x4e')]=_0x2765f2['body'][_0x91c5('0x4e')];_0x5aade0[_0x91c5('0x48')][_0x91c5('0x64')]=_0x5aade0['Smtp'][_0x91c5('0x65')]=null;}else{_0x5aade0['Imap'][_0x91c5('0x4e')]=_0x5aade0[_0x91c5('0x2c')][_0x91c5('0x4e')]=null;}_0x5aade0['Imap'][_0x91c5('0x66')]=_0x5aade0[_0x91c5('0x2c')][_0x91c5('0x66')]=null;_0x5aade0['Imap']['host']=_0x5aade0[_0x91c5('0x2c')][_0x91c5('0x67')]=null;_0x5aade0[_0x91c5('0x48')][_0x91c5('0x68')]=_0x5aade0[_0x91c5('0x2c')][_0x91c5('0x68')]=null;}else{if(_0x2765f2[_0x91c5('0x4c')][_0x91c5('0x69')]){_0x5aade0[_0x91c5('0x48')][_0x91c5('0x63')]=_0x5aade0[_0x91c5('0x2c')][_0x91c5('0x63')]=_0x2765f2[_0x91c5('0x4c')][_0x91c5('0x6a')];_0x5aade0[_0x91c5('0x48')][_0x91c5('0x64')]=_0x5aade0[_0x91c5('0x2c')][_0x91c5('0x65')]=_0x2765f2[_0x91c5('0x4c')]['password'];}else{_0x5aade0[_0x91c5('0x48')]['authentication']=_0x5aade0[_0x91c5('0x2c')][_0x91c5('0x69')]=![];_0x5aade0['Imap'][_0x91c5('0x63')]=_0x5aade0[_0x91c5('0x2c')][_0x91c5('0x63')]=null;_0x5aade0[_0x91c5('0x48')][_0x91c5('0x64')]=_0x5aade0[_0x91c5('0x2c')][_0x91c5('0x65')]=null;}_0x5aade0[_0x91c5('0x48')][_0x91c5('0x67')]=_0x2765f2[_0x91c5('0x4c')][_0x91c5('0x48')][_0x91c5('0x67')];_0x5aade0[_0x91c5('0x48')][_0x91c5('0x68')]=_0x2765f2[_0x91c5('0x4c')][_0x91c5('0x48')]['port'];_0x5aade0[_0x91c5('0x2c')][_0x91c5('0x67')]=_0x2765f2[_0x91c5('0x4c')][_0x91c5('0x2c')][_0x91c5('0x67')];_0x5aade0['Smtp'][_0x91c5('0x68')]=_0x2765f2['body']['Smtp'][_0x91c5('0x68')];}return db['MailAccount'][_0x91c5('0x52')](_0x5aade0,{'include':[{'model':db[_0x91c5('0x2b')],'as':_0x91c5('0x2c')},{'model':db['MailServerIn'],'as':_0x91c5('0x48')}]})[_0x91c5('0x20')](function(_0x3fb2aa){var _0x1e9686=_0x2765f2[_0x91c5('0x63')]['get']({'plain':!![]});if(!_0x1e9686)throw new Error(_0x91c5('0x6b'));if(_0x1e9686[_0x91c5('0x6c')]==='user'){var _0x3db09d=_0x3fb2aa['get']({'plain':!![]});return db[_0x91c5('0x6d')][_0x91c5('0x4a')]({'where':{'name':'MailAccounts','userProfileId':_0x1e9686['userProfileId']},'raw':!![]})['then'](function(_0x33ecb1){if(_0x33ecb1&&_0x33ecb1[_0x91c5('0x6e')]===0x0){return db['UserProfileResource'][_0x91c5('0x52')]({'name':_0x3db09d['name'],'resourceId':_0x3db09d['id'],'type':_0x33ecb1[_0x91c5('0x27')],'sectionId':_0x33ecb1['id']},{})[_0x91c5('0x20')](function(){return _0x3fb2aa;});}else{return _0x3fb2aa;}})[_0x91c5('0x18')](function(_0x3f3623){logger[_0x91c5('0x15')](_0x91c5('0x6f'),_0x3f3623);throw _0x3f3623;});}return _0x3fb2aa;})[_0x91c5('0x20')](respondWithResult(_0x20edeb,0xc9))[_0x91c5('0x18')](handleError(_0x20edeb,null));};exports[_0x91c5('0x70')]=function(_0x59cd58,_0x3c1d6e){return db[_0x91c5('0x2f')]['findOne']({'where':{'id':_0x59cd58[_0x91c5('0x4f')]['id']}})[_0x91c5('0x20')](handleEntityNotFound(_0x3c1d6e,null))['then'](function(_0x35a2e5){if(_0x35a2e5){return _0x35a2e5[_0x91c5('0x70')]();}return null;})[_0x91c5('0x20')](respondWithResult(_0x3c1d6e,null))['catch'](handleError(_0x3c1d6e,null));};exports[_0x91c5('0x71')]=function(_0x323ccf,_0x3c9fc9){if(_0x323ccf[_0x91c5('0x4c')]['id']){delete _0x323ccf[_0x91c5('0x4c')]['id'];}return db[_0x91c5('0x2f')][_0x91c5('0x4a')]({'where':{'id':_0x323ccf[_0x91c5('0x4f')]['id']}})[_0x91c5('0x20')](handleEntityNotFound(_0x3c9fc9,null))[_0x91c5('0x20')](function(_0x362427){if(_0x362427){_0x323ccf[_0x91c5('0x4c')][_0x91c5('0x57')]=_0x362427['id'];return db['MailServerIn'][_0x91c5('0x52')](_0x323ccf['body']);}})[_0x91c5('0x20')](respondWithResult(_0x3c9fc9,null))[_0x91c5('0x18')](handleError(_0x3c9fc9,null));};exports[_0x91c5('0x72')]=function(_0x48bfd1,_0x218395){return db[_0x91c5('0x2f')][_0x91c5('0x5a')]({'where':{'id':_0x48bfd1[_0x91c5('0x4f')]['id']}})[_0x91c5('0x20')](handleEntityNotFound(_0x218395,null))[_0x91c5('0x20')](function(_0x9fea9d){if(_0x9fea9d){return _0x9fea9d[_0x91c5('0x73')](null);}return null;})[_0x91c5('0x20')](respondWithStatusCode(_0x218395,null))[_0x91c5('0x18')](handleError(_0x218395,null));};exports[_0x91c5('0x74')]=function(_0x2012e5,_0x34df29){return db[_0x91c5('0x2f')][_0x91c5('0x5a')]({'where':{'id':_0x2012e5[_0x91c5('0x4f')]['id']}})[_0x91c5('0x20')](handleEntityNotFound(_0x34df29,null))[_0x91c5('0x20')](function(_0x3f06ae){if(_0x3f06ae){return _0x3f06ae[_0x91c5('0x74')]();}return null;})[_0x91c5('0x20')](respondWithResult(_0x34df29,null))[_0x91c5('0x18')](handleError(_0x34df29,null));};exports[_0x91c5('0x75')]=function(_0x516055,_0x25f5f6){if(_0x516055['body']['id']){delete _0x516055[_0x91c5('0x4c')]['id'];}return db[_0x91c5('0x2f')][_0x91c5('0x4a')]({'where':{'id':_0x516055[_0x91c5('0x4f')]['id']}})[_0x91c5('0x20')](handleEntityNotFound(_0x25f5f6,null))['then'](function(_0x1545f0){if(_0x1545f0){_0x516055[_0x91c5('0x4c')][_0x91c5('0x57')]=_0x1545f0['id'];return db[_0x91c5('0x2b')][_0x91c5('0x52')](_0x516055['body']);}})['then'](respondWithResult(_0x25f5f6,null))['catch'](handleError(_0x25f5f6,null));};exports[_0x91c5('0x76')]=function(_0x231fc7,_0x2ed429){return db['MailAccount'][_0x91c5('0x5a')]({'where':{'id':_0x231fc7[_0x91c5('0x4f')]['id']}})['then'](handleEntityNotFound(_0x2ed429,null))[_0x91c5('0x20')](function(_0x116223){if(_0x116223){return _0x116223[_0x91c5('0x77')](null);}return null;})[_0x91c5('0x20')](respondWithStatusCode(_0x2ed429,null))['catch'](handleError(_0x2ed429,null));};exports[_0x91c5('0x78')]=function(_0x5401f1,_0x3bf835){return db[_0x91c5('0x79')]['find']({'where':{'id':_0x5401f1['params']['id']}})[_0x91c5('0x20')](handleEntityNotFound(_0x3bf835,null))[_0x91c5('0x20')](function(_0x3e60be){if(_0x3e60be){return _0x3e60be[_0x91c5('0x78')](_0x5401f1[_0x91c5('0x4c')][_0x91c5('0x5d')],_[_0x91c5('0x7a')](_0x5401f1['body'],[_0x91c5('0x5d'),'id'])||{});}})[_0x91c5('0x20')](respondWithResult(_0x3bf835,null))['catch'](handleError(_0x3bf835,null));};exports[_0x91c5('0x7b')]=function(_0xaa957d,_0x32346b){var _0x50f6d4={'raw':![],'where':{}};var _0x3f956a={};var _0x44c247={'count':0x0,'rows':[]};return db[_0x91c5('0x2f')][_0x91c5('0x5a')]({'where':{'id':_0xaa957d['params']['id']}})[_0x91c5('0x20')](handleEntityNotFound(_0x32346b,null))[_0x91c5('0x20')](function(_0x41bebd){if(_0x41bebd){_0x3f956a['model']=_['keys'](db[_0x91c5('0x79')]['rawAttributes']);_0x3f956a[_0x91c5('0x34')]=_['keys'](_0xaa957d[_0x91c5('0x34')]);_0x3f956a['filters']=_[_0x91c5('0x36')](_0x3f956a[_0x91c5('0x37')],_0x3f956a[_0x91c5('0x34')]);_0x50f6d4[_0x91c5('0x39')]=_['intersection'](_0x3f956a['model'],qs[_0x91c5('0x38')](_0xaa957d[_0x91c5('0x34')][_0x91c5('0x38')]));_0x50f6d4[_0x91c5('0x39')]=_0x50f6d4[_0x91c5('0x39')][_0x91c5('0x3a')]?_0x50f6d4[_0x91c5('0x39')]:_0x3f956a[_0x91c5('0x37')];if(!_0xaa957d['query'][_0x91c5('0x5b')]('nolimit')){_0x50f6d4[_0x91c5('0x3c')]=qs[_0x91c5('0x3c')](_0xaa957d['query'][_0x91c5('0x3c')]);_0x50f6d4[_0x91c5('0x1c')]=qs[_0x91c5('0x1c')](_0xaa957d[_0x91c5('0x34')][_0x91c5('0x1c')]);}_0x50f6d4['order']=qs['sort'](_0xaa957d['query'][_0x91c5('0x3e')]);_0x50f6d4['where']=qs['filters'](_[_0x91c5('0x41')](_0xaa957d[_0x91c5('0x34')],_0x3f956a[_0x91c5('0x40')]));_0x50f6d4[_0x91c5('0x3f')][_0x91c5('0x57')]=_0x41bebd['id'];if(_0xaa957d['query'][_0x91c5('0x42')]){_0x50f6d4[_0x91c5('0x3f')]=_[_0x91c5('0x43')](_0x50f6d4[_0x91c5('0x3f')],{'$or':_[_0x91c5('0x33')](_0x50f6d4[_0x91c5('0x39')],function(_0x3f281b){var _0x2711b3={};_0x2711b3[_0x3f281b]={'$like':'%'+_0xaa957d[_0x91c5('0x34')][_0x91c5('0x42')]+'%'};return _0x2711b3;})});}_0x50f6d4=_[_0x91c5('0x43')]({},_0x50f6d4,_0xaa957d[_0x91c5('0x45')]);return db[_0x91c5('0x79')][_0x91c5('0x1e')]({'where':_0x50f6d4[_0x91c5('0x3f')]})[_0x91c5('0x20')](function(_0x5be815){_0x44c247['count']=_0x5be815;if(_0xaa957d[_0x91c5('0x34')][_0x91c5('0x49')]){_0x50f6d4[_0x91c5('0x53')]=[{'model':db[_0x91c5('0x7c')],'as':_0x91c5('0x7d'),'required':![]},{'model':db['User'],'as':_0x91c5('0x7e'),'attributes':['name',_0x91c5('0x7f'),_0x91c5('0x80')],'required':![]},{'model':db[_0x91c5('0x81')],'as':'Tags','attributes':['id',_0x91c5('0x27'),_0x91c5('0x82')],'where':_0xaa957d[_0x91c5('0x34')][_0x91c5('0x83')]?{'id':_0xaa957d[_0x91c5('0x34')][_0x91c5('0x83')]}:undefined,'required':_0xaa957d[_0x91c5('0x34')][_0x91c5('0x83')]?!![]:![]}];}return db['MailInteraction'][_0x91c5('0x54')](_0x50f6d4);})[_0x91c5('0x20')](function(_0x3b67eb){_0x44c247['rows']=_0x3b67eb;return _0x44c247;});}})[_0x91c5('0x20')](respondWithFilteredResult(_0x32346b,_0x50f6d4))[_0x91c5('0x18')](handleError(_0x32346b,null));};exports[_0x91c5('0x84')]=function addApplications(_0x581d00,_0xcdbf99){var _0x2ffcdb=_0x581d00['params']['id'];var _0x1dfe27=_0x581d00['body'];var _0x4cdc46=0xc8;var _0x2f51ca=null;return db[_0x91c5('0x85')][_0x91c5('0x86')]({'isolationLevel':db[_0x91c5('0x85')]['Transaction'][_0x91c5('0x87')]['READ_COMMITTED']},function(_0x40cc16){return db[_0x91c5('0x2f')][_0x91c5('0x5a')]({'where':{'id':_0x2ffcdb},'transaction':_0x40cc16})['then'](function(_0x39b769){if(_0x39b769){return db[_0x91c5('0x88')][_0x91c5('0x21')]({'where':{'MailAccountId':_0x2ffcdb},'transaction':_0x40cc16})[_0x91c5('0x20')](function(){var _0x44a686=_[_0x91c5('0x33')](_0x1dfe27,function(_0x5a464f){_0x5a464f[_0x91c5('0x57')]=_0x2ffcdb;return _0x5a464f;});return db['MailApplication'][_0x91c5('0x89')](_0x44a686,{'transaction':_0x40cc16});});}else{_0x4cdc46=0x194;_0x2f51ca=[];}});})[_0x91c5('0x20')](function(){if(_0x4cdc46!==0x194){return db['MailApplication'][_0x91c5('0x8a')]({'where':{'MailAccountId':_0x2ffcdb},'order':_0x91c5('0x8b')})['then'](function(_0x161383){_0x2f51ca=_0x161383;});}})[_0x91c5('0x18')](function(_0x4ba545){_0x4cdc46=0x1f4;logger[_0x91c5('0x15')](_0x4ba545[_0x91c5('0x26')]);if(_0x4ba545[_0x91c5('0x27')]){delete _0x4ba545[_0x91c5('0x27')];}_0x2f51ca=_0x4ba545;})[_0x91c5('0x8c')](function(){if(_0x2f51ca===null){_0xcdbf99['sendStatus'](_0x4cdc46);}else{if(_0x4cdc46===0x1f4){_0xcdbf99[_0x91c5('0x1a')](_0x4cdc46)[_0x91c5('0x28')](_0x2f51ca);}else{_0xcdbf99[_0x91c5('0x1a')](_0x4cdc46)[_0x91c5('0x1b')](_0x2f51ca);}}});};exports['getApplications']=function(_0x52b67e,_0x3c7c26){var _0x5a27c4={};var _0x4455d6={};var _0x2e6397;var _0x3552a0;return db['MailAccount']['findOne']({'where':{'id':_0x52b67e[_0x91c5('0x4f')]['id']}})[_0x91c5('0x20')](handleEntityNotFound(_0x3c7c26,null))['then'](function(_0x364015){if(_0x364015){_0x2e6397=_0x364015;_0x4455d6[_0x91c5('0x37')]=_[_0x91c5('0x35')](db['MailApplication']['rawAttributes']);_0x4455d6[_0x91c5('0x34')]=_[_0x91c5('0x35')](_0x52b67e[_0x91c5('0x34')]);_0x4455d6[_0x91c5('0x40')]=_[_0x91c5('0x36')](_0x4455d6['model'],_0x4455d6['query']);_0x5a27c4[_0x91c5('0x39')]=_['intersection'](_0x4455d6[_0x91c5('0x37')],qs[_0x91c5('0x38')](_0x52b67e['query'][_0x91c5('0x38')]));_0x5a27c4['attributes']=_0x5a27c4[_0x91c5('0x39')][_0x91c5('0x3a')]?_0x5a27c4[_0x91c5('0x39')]:_0x4455d6['model'];_0x5a27c4['order']=qs[_0x91c5('0x3e')](_0x52b67e[_0x91c5('0x34')][_0x91c5('0x3e')]);_0x5a27c4[_0x91c5('0x3f')]=qs[_0x91c5('0x40')](_[_0x91c5('0x41')](_0x52b67e[_0x91c5('0x34')],_0x4455d6[_0x91c5('0x40')]));if(_0x52b67e[_0x91c5('0x34')]['filter']){_0x5a27c4['where']=_[_0x91c5('0x43')](_0x5a27c4[_0x91c5('0x3f')],{'$or':_['map'](_0x5a27c4['attributes'],function(_0x355cd2){var _0x47aebf={};_0x47aebf[_0x355cd2]={'$like':'%'+_0x52b67e[_0x91c5('0x34')][_0x91c5('0x42')]+'%'};return _0x47aebf;})});}_0x5a27c4=_['merge']({},_0x5a27c4,_0x52b67e['options']);return _0x2e6397['getApplications'](_0x5a27c4);}})['then'](function(_0x3dfb36){if(_0x3dfb36){_0x3552a0=_0x3dfb36[_0x91c5('0x3a')];if(!_0x52b67e[_0x91c5('0x34')][_0x91c5('0x5b')](_0x91c5('0x3b'))){_0x5a27c4[_0x91c5('0x3c')]=qs[_0x91c5('0x3c')](_0x52b67e[_0x91c5('0x34')]['limit']);_0x5a27c4[_0x91c5('0x1c')]=qs[_0x91c5('0x1c')](_0x52b67e[_0x91c5('0x34')]['offset']);}return _0x2e6397[_0x91c5('0x8d')](_0x5a27c4);}})[_0x91c5('0x20')](function(_0x18429b){if(_0x18429b){return _0x18429b?{'count':_0x3552a0,'rows':_0x18429b}:null;}})[_0x91c5('0x20')](respondWithResult(_0x3c7c26,null))['catch'](handleError(_0x3c7c26,null));};exports[_0x91c5('0x8e')]=function(_0x148080,_0xf0f5d0){var _0x251568={'raw':!![],'where':{}};var _0x4d02ee={};var _0x20b007={'count':0x0,'rows':[]};return db['MailAccount'][_0x91c5('0x5a')]({'where':{'id':_0x148080[_0x91c5('0x4f')]['id']}})[_0x91c5('0x20')](handleEntityNotFound(_0xf0f5d0,null))[_0x91c5('0x20')](function(_0x4840f8){if(_0x4840f8){_0x4d02ee[_0x91c5('0x37')]=_[_0x91c5('0x35')](db[_0x91c5('0x8f')][_0x91c5('0x30')]);_0x4d02ee[_0x91c5('0x34')]=_[_0x91c5('0x35')](_0x148080[_0x91c5('0x34')]);_0x4d02ee[_0x91c5('0x40')]=_[_0x91c5('0x36')](_0x4d02ee[_0x91c5('0x37')],_0x4d02ee[_0x91c5('0x34')]);_0x251568['attributes']=_[_0x91c5('0x36')](_0x4d02ee[_0x91c5('0x37')],qs[_0x91c5('0x38')](_0x148080[_0x91c5('0x34')][_0x91c5('0x38')]));_0x251568['attributes']=_0x251568[_0x91c5('0x39')][_0x91c5('0x3a')]?_0x251568[_0x91c5('0x39')]:_0x4d02ee[_0x91c5('0x37')];if(!_0x148080[_0x91c5('0x34')][_0x91c5('0x5b')](_0x91c5('0x3b'))){_0x251568[_0x91c5('0x3c')]=qs[_0x91c5('0x3c')](_0x148080[_0x91c5('0x34')]['limit']);_0x251568[_0x91c5('0x1c')]=qs[_0x91c5('0x1c')](_0x148080['query'][_0x91c5('0x1c')]);}_0x251568[_0x91c5('0x3d')]=qs[_0x91c5('0x3e')](_0x148080['query'][_0x91c5('0x3e')]);_0x251568[_0x91c5('0x3f')]=qs['filters'](_[_0x91c5('0x41')](_0x148080[_0x91c5('0x34')],_0x4d02ee[_0x91c5('0x40')]));_0x251568['where'][_0x91c5('0x57')]=_0x4840f8['id'];if(_0x148080[_0x91c5('0x34')][_0x91c5('0x42')]){_0x251568['where']=_[_0x91c5('0x43')](_0x251568['where'],{'$or':_['map'](_0x251568[_0x91c5('0x39')],function(_0x8d87f7){var _0x46062f={};_0x46062f[_0x8d87f7]={'$like':'%'+_0x148080[_0x91c5('0x34')][_0x91c5('0x42')]+'%'};return _0x46062f;})});}if(_0x148080[_0x91c5('0x34')][_0x91c5('0x90')]){var _0x43574d=_0x148080['query'][_0x91c5('0x90')]['split'](',');var _0x309c78={};_0x309c78[_0x43574d[0x0]]={'$gte':moment(_0x43574d[0x1])[_0x91c5('0x91')](_0x91c5('0x92'))};_0x251568['where']=_[_0x91c5('0x43')](_0x251568['where'],_0x309c78);}_0x251568=_['merge']({},_0x251568,_0x148080[_0x91c5('0x45')]);return db['MailMessage'][_0x91c5('0x1e')]({'where':_0x251568[_0x91c5('0x3f')]})[_0x91c5('0x20')](function(_0x1cf8a3){_0x20b007[_0x91c5('0x1e')]=_0x1cf8a3;if(_0x148080['query'][_0x91c5('0x49')]){_0x251568[_0x91c5('0x53')]=[{'all':!![]}];}return db[_0x91c5('0x8f')][_0x91c5('0x54')](_0x251568);})['then'](function(_0x50896a){if(_0x148080['query'][_0x91c5('0x93')]===_0x91c5('0x94')){for(var _0x1a66ec=0x0;_0x1a66ec<_0x50896a[_0x91c5('0x3a')];_0x1a66ec++){_0x50896a[_0x1a66ec][_0x91c5('0x4c')]=juice(_0x50896a[_0x1a66ec][_0x91c5('0x4c')]);}}_0x20b007[_0x91c5('0x46')]=_0x50896a;return _0x20b007;});}})[_0x91c5('0x20')](respondWithFilteredResult(_0xf0f5d0,_0x251568))[_0x91c5('0x18')](handleError(_0xf0f5d0,null));};exports[_0x91c5('0x28')]=function(_0x2086dd,_0x58f1e3){var _0x28628d,_0x1588db={},_0x4d172b;if(_0x2086dd[_0x91c5('0x4c')]['to']){_0x4d172b=_0x2086dd[_0x91c5('0x4c')]['to'][_0x91c5('0x95')](',')[0x0];}return db[_0x91c5('0x2f')][_0x91c5('0x4a')]({'where':{'id':_0x2086dd[_0x91c5('0x4f')]['id']},'include':[{'model':db['CmList'],'as':'List','include':[{'model':db['CmContact'],'as':_0x91c5('0x96'),'where':{'email':_0x4d172b},'limit':0x1,'order':[[_0x91c5('0x97'),_0x91c5('0x98')]]}]},{'model':db[_0x91c5('0x2b')],'as':'Smtp','raw':!![]}]})[_0x91c5('0x20')](handleEntityNotFound(_0x58f1e3,null))['then'](function(_0x47777f){if(_0x47777f){_0x28628d=_0x47777f;if(_0x47777f[_0x91c5('0x2c')]){if(_[_0x91c5('0x61')](_0x2086dd[_0x91c5('0x4c')][_0x91c5('0x99')])){_0x2086dd[_0x91c5('0x4c')][_0x91c5('0x99')]=util[_0x91c5('0x91')](_0x91c5('0x9a'),_0x47777f['name'],_0x47777f['email']||_0x47777f[_0x91c5('0x2c')][_0x91c5('0x63')]);}if(_0x2086dd[_0x91c5('0x4c')][_0x91c5('0x9b')]&&_0x2086dd[_0x91c5('0x4c')][_0x91c5('0x9b')][_0x91c5('0x3a')]){for(var _0x23be6f=0x0;_0x23be6f<_0x2086dd[_0x91c5('0x4c')][_0x91c5('0x9b')][_0x91c5('0x3a')];_0x23be6f+=0x1){_0x2086dd['body'][_0x91c5('0x9b')][_0x23be6f]={'filename':_0x2086dd['body'][_0x91c5('0x9b')][_0x23be6f]['name'],'path':path[_0x91c5('0x9c')](config['root'],_0x91c5('0x9d'),_0x2086dd[_0x91c5('0x4c')][_0x91c5('0x9b')][_0x23be6f][_0x91c5('0x9e')])};}}var _0x48ddfd={'tls':{'rejectUnauthorized':![]}};if(_[_0x91c5('0x61')](_0x47777f[_0x91c5('0x2c')][_0x91c5('0x66')])){if(_0x47777f['Smtp'][_0x91c5('0x69')]){_0x48ddfd['auth']={'user':_0x47777f[_0x91c5('0x2c')][_0x91c5('0x63')],'pass':_0x47777f[_0x91c5('0x2c')]['pass']};}_0x48ddfd[_0x91c5('0x67')]=_0x47777f[_0x91c5('0x2c')][_0x91c5('0x67')];_0x48ddfd[_0x91c5('0x68')]=_0x47777f[_0x91c5('0x2c')][_0x91c5('0x68')];_0x48ddfd[_0x91c5('0x9f')]=_0x47777f['Smtp'][_0x91c5('0x9f')];}else{_0x48ddfd[_0x91c5('0x66')]=_0x47777f[_0x91c5('0x2c')]['service'];_0x48ddfd[_0x91c5('0xa0')]={'user':_0x47777f[_0x91c5('0x2c')][_0x91c5('0x63')],'pass':_0x47777f[_0x91c5('0x2c')]['pass']};}return respondWithRpcPromise('SendMail',_0x91c5('0xa1'),{'account':_0x48ddfd,'message':_0x2086dd[_0x91c5('0x4c')]});}else{throw new Error(_0x91c5('0xa2'));}}})[_0x91c5('0x20')](function(_0x2d0ff6){if(_0x2d0ff6){_0x1588db=_0x2d0ff6;if(_0x28628d[_0x91c5('0xa3')]){if(_0x28628d[_0x91c5('0xa3')][_0x91c5('0x96')][_0x91c5('0x3a')]){return _0x28628d[_0x91c5('0xa3')][_0x91c5('0x96')][0x0];}else{return db['CmContact'][_0x91c5('0x52')](_[_0x91c5('0xa')](_0x2086dd[_0x91c5('0x4c')],{'firstName':_0x2086dd[_0x91c5('0x4c')]['to'],'email':_0x2086dd[_0x91c5('0x4c')]['to'],'phone':_0x2086dd['body']['to'],'ListId':_0x28628d[_0x91c5('0xa4')]}));}}else{throw new Error('List\x20not\x20found');}}})[_0x91c5('0x20')](function(_0x5c637e){if(_0x5c637e){var _0x48c3a8={'UserId':_0x2086dd[_0x91c5('0x63')]['id'],'ContactId':_0x5c637e['id'],'MailAccountId':_0x28628d['id'],'inReplyTo':_0x1588db[_0x91c5('0xa5')],'to':_0x2086dd[_0x91c5('0x4c')][_0x91c5('0x99')],'cc':_0x2086dd[_0x91c5('0x4c')]['cc'],'subject':_0x2086dd[_0x91c5('0x4c')]['subject'],'attach':_0x2086dd[_0x91c5('0x4c')][_0x91c5('0xa6')],'firstMsgDirection':'out','lastMsgAt':moment()['format'](_0x91c5('0x92')),'lastMsgDirection':_0x91c5('0xa7'),'Messages':[_[_0x91c5('0x43')](_0x2086dd[_0x91c5('0x4c')],{'messageId':_0x1588db[_0x91c5('0xa5')],'sentAt':moment()[_0x91c5('0x91')](_0x91c5('0x92')),'read':!![],'MailAccountId':_0x28628d['id'],'UserId':_0x2086dd[_0x91c5('0x63')]['id'],'ContactId':_0x5c637e['id']})]};if(_0x2086dd[_0x91c5('0x4c')][_0x91c5('0xa8')]){_0x48c3a8=_['merge'](_0x48c3a8,_0x2086dd[_0x91c5('0x4c')][_0x91c5('0xa8')]);}return db[_0x91c5('0x79')][_0x91c5('0x52')](_0x48c3a8,{'include':[{'model':db[_0x91c5('0x8f')],'as':_0x91c5('0xa9')}]});}})[_0x91c5('0x20')](respondWithResult(_0x58f1e3,null))[_0x91c5('0x18')](handleError(_0x58f1e3,null));};exports['verifySmtp']=function(_0xc730bb,_0x4421ed){return db[_0x91c5('0x2f')]['find']({'where':{'id':_0xc730bb[_0x91c5('0x4f')]['id']},'include':[{'model':db[_0x91c5('0x2b')],'as':_0x91c5('0x2c'),'raw':!![],'include':[{'model':db[_0x91c5('0xaa')],'as':_0x91c5('0xaa'),'raw':!![]}]}]})['then'](handleEntityNotFound(_0x4421ed,null))[_0x91c5('0x20')](function(_0x1baf3d){if(!_0x1baf3d['Smtp'])return;var _0x2a7440={'id':_0x1baf3d['id'],'tls':{'rejectUnauthorized':![]}};if(_0x1baf3d[_0x91c5('0x5f')]!==_0x91c5('0x5e')){_0x2a7440[_0x91c5('0x66')]=_0x1baf3d['provider'];}else{_0x2a7440[_0x91c5('0x67')]=_0x1baf3d[_0x91c5('0x2c')][_0x91c5('0x67')];_0x2a7440[_0x91c5('0x68')]=_0x1baf3d[_0x91c5('0x2c')][_0x91c5('0x68')];_0x2a7440[_0x91c5('0x9f')]=_0x1baf3d['Smtp']['secure'];}if(_0x1baf3d[_0x91c5('0x2c')][_0x91c5('0x69')]){if(_0x1baf3d[_0x91c5('0x2c')][_0x91c5('0x4d')]){_0x2a7440[_0x91c5('0xa0')]={'type':_0x91c5('0xab'),'user':_0x1baf3d[_0x91c5('0x2c')][_0x91c5('0x63')],'accessToken':_0x1baf3d[_0x91c5('0x2c')][_0x91c5('0xaa')]['data5']};}else{_0x2a7440[_0x91c5('0xa0')]={'user':_0x1baf3d['Smtp'][_0x91c5('0x63')],'pass':_0x1baf3d[_0x91c5('0x2c')][_0x91c5('0x65')]};}}return respondWithRpcPromise(_0x91c5('0xac'),'verifySmtp',{'account':_0x2a7440});})[_0x91c5('0x20')](respondWithResult(_0x4421ed,null))[_0x91c5('0x18')](handleError(_0x4421ed,null));};exports[_0x91c5('0x21')]=function(_0x25a180,_0x31e28a){return db[_0x91c5('0x2f')]['find']({'where':{'id':_0x25a180[_0x91c5('0x4f')]['id']}})[_0x91c5('0x20')](handleEntityNotFound(_0x31e28a,null))[_0x91c5('0x20')](function(_0x2720ab){if(_0x2720ab&&_0x2720ab[_0x91c5('0x66')]){throw new db[(_0x91c5('0xad'))][(_0x91c5('0xae'))](_0x91c5('0xaf'));}return _0x2720ab;})[_0x91c5('0x20')](removeEntity(_0x31e28a,null))[_0x91c5('0x18')](handleError(_0x31e28a,null));};exports[_0x91c5('0xb0')]=function(_0x144e86,_0x2d4198){return db[_0x91c5('0x2f')][_0x91c5('0x4a')]({'where':{'id':_0x144e86['params']['id']}})[_0x91c5('0x20')](handleEntityNotFound(_0x2d4198,null))[_0x91c5('0x20')](function(_0x2a1615){if(_0x2a1615){return _0x2a1615[_0x91c5('0xb0')](_0x144e86[_0x91c5('0x4c')]['ids'],_['omit'](_0x144e86[_0x91c5('0x4c')],[_0x91c5('0x5d'),'id'])||{})[_0x91c5('0xb1')](function(_0x12a501){for(var _0x100f3b=0x0;_0x100f3b<_0x144e86[_0x91c5('0x4c')][_0x91c5('0x5d')][_0x91c5('0x3a')];_0x100f3b+=0x1){socket[_0x91c5('0xb2')](_0x91c5('0xb3'),{'UserId':Number(_0x144e86[_0x91c5('0x4c')][_0x91c5('0x5d')][_0x100f3b]),'MailAccountId':Number(_0x144e86[_0x91c5('0x4f')]['id'])});}return _0x12a501;});}})[_0x91c5('0x20')](respondWithResult(_0x2d4198,null))['catch'](handleError(_0x2d4198,null));};exports[_0x91c5('0xb4')]=function(_0x5bcdc1,_0x45a49e){return db['MailAccount'][_0x91c5('0x4a')]({'where':{'id':_0x5bcdc1[_0x91c5('0x4f')]['id']}})[_0x91c5('0x20')](handleEntityNotFound(_0x45a49e,null))[_0x91c5('0x20')](function(_0x3aaded){if(_0x3aaded){return _0x3aaded[_0x91c5('0xb4')](_0x5bcdc1['query'][_0x91c5('0x5d')])['then'](function(){if(_[_0x91c5('0xb5')](_0x5bcdc1[_0x91c5('0x34')][_0x91c5('0x5d')])){for(var _0x56d1fd=0x0;_0x56d1fd<_0x5bcdc1[_0x91c5('0x34')]['ids']['length'];_0x56d1fd+=0x1){socket[_0x91c5('0xb2')](_0x91c5('0xb6'),{'UserId':Number(_0x5bcdc1[_0x91c5('0x34')][_0x91c5('0x5d')][_0x56d1fd]),'MailAccountId':Number(_0x5bcdc1[_0x91c5('0x4f')]['id'])});}}else{socket['emit']('userMailAccount:remove',{'UserId':Number(_0x5bcdc1[_0x91c5('0x34')][_0x91c5('0x5d')]),'MailAccountId':Number(_0x5bcdc1[_0x91c5('0x4f')]['id'])});}});}})[_0x91c5('0x20')](respondWithStatusCode(_0x45a49e,null))[_0x91c5('0x18')](handleError(_0x45a49e,null));};exports['getAgents']=function(_0x419f0d,_0x1c672f){var _0x10744e={};var _0x5a8ccb={};var _0x51e808;var _0x59959e;return db[_0x91c5('0x2f')][_0x91c5('0x5a')]({'where':{'id':_0x419f0d['params']['id']}})[_0x91c5('0x20')](handleEntityNotFound(_0x1c672f,null))[_0x91c5('0x20')](function(_0x210ca5){if(_0x210ca5){_0x51e808=_0x210ca5;_0x5a8ccb[_0x91c5('0x37')]=_['keys'](db[_0x91c5('0xb7')][_0x91c5('0x30')]);_0x5a8ccb[_0x91c5('0x34')]=_[_0x91c5('0x35')](_0x419f0d[_0x91c5('0x34')]);_0x5a8ccb[_0x91c5('0x40')]=_[_0x91c5('0x36')](_0x5a8ccb[_0x91c5('0x37')],_0x5a8ccb[_0x91c5('0x34')]);_0x10744e[_0x91c5('0x39')]=_[_0x91c5('0x36')](_0x5a8ccb[_0x91c5('0x37')],qs[_0x91c5('0x38')](_0x419f0d[_0x91c5('0x34')][_0x91c5('0x38')]));_0x10744e[_0x91c5('0x39')]=_0x10744e['attributes'][_0x91c5('0x3a')]?_0x10744e['attributes']:_0x5a8ccb[_0x91c5('0x37')];_0x10744e['order']=qs[_0x91c5('0x3e')](_0x419f0d['query']['sort']);_0x10744e[_0x91c5('0x3f')]=qs['filters'](_[_0x91c5('0x41')](_0x419f0d[_0x91c5('0x34')],_0x5a8ccb[_0x91c5('0x40')]));if(_0x419f0d[_0x91c5('0x34')]['filter']){_0x10744e['where']=_[_0x91c5('0x43')](_0x10744e[_0x91c5('0x3f')],{'$or':_['map'](_0x10744e[_0x91c5('0x39')],function(_0xb8ddc3){var _0x480c27={};_0x480c27[_0xb8ddc3]={'$like':'%'+_0x419f0d[_0x91c5('0x34')][_0x91c5('0x42')]+'%'};return _0x480c27;})});}_0x10744e=_[_0x91c5('0x43')]({},_0x10744e,_0x419f0d[_0x91c5('0x45')]);return _0x51e808[_0x91c5('0xb8')](_0x10744e);}})[_0x91c5('0x20')](function(_0x5abf5b){if(_0x5abf5b){_0x59959e=_0x5abf5b[_0x91c5('0x3a')];if(!_0x419f0d[_0x91c5('0x34')][_0x91c5('0x5b')](_0x91c5('0x3b'))){_0x10744e['limit']=qs[_0x91c5('0x3c')](_0x419f0d[_0x91c5('0x34')][_0x91c5('0x3c')]);_0x10744e[_0x91c5('0x1c')]=qs[_0x91c5('0x1c')](_0x419f0d[_0x91c5('0x34')][_0x91c5('0x1c')]);}return _0x51e808[_0x91c5('0xb8')](_0x10744e);}})[_0x91c5('0x20')](function(_0x205176){if(_0x205176){return _0x205176?{'count':_0x59959e,'rows':_0x205176}:null;}})['then'](respondWithResult(_0x1c672f,null))['catch'](handleError(_0x1c672f,null));};
\ No newline at end of file
+var _0x03f3=['MailServerIn','Pause','length','find','update','body','CloudProviderId','modernAuthentication','describe','addDisposition','MailAccountId','Disposition','getDispositions','findOne','nolimit','pick','include','ids','addAnswer','CannedAnswer','create','getAnswers','order','removeAnswers','custom','email','description','provider','user','pass','password','host','port','authentication','username','role','UserProfileSection','MailAccounts','userProfileId','autoAssociation','getImap','addImap','getSmtp','addSmtp','setSmtp','addInteraction','omit','getInteractions','User','Owner','fullname','internal','Tag','Tags','color','tag','MailInteraction','sequelize','transaction','Transaction','ISOLATION_LEVELS','READ_COMMITTED','MailApplication','bulkCreate','findAndCountAll','priority','getApplications','getMessages','MailMessage','$gte','YYYY-MM-DD\x20HH:mm:ss','inlineCss','true','List','CmContact','Contacts','isNil','from','format','attachments','join','root','basename','service','secure','auth','SendMail','sendMail','List\x20not\x20found','ListId','messageId','out','Interaction','verifySmtp','CloudProvider','OAuth2','data5','Sequelize','ValidationError','You\x20can\x27t\x20remove\x20the\x20mail\x20service\x20account','addAgents','spread','emit','userMailAccount:save','removeAgents','isArray','userMailAccount:remove','getAgents','moment','bluebird','util','path','lodash','juice','ioredis','../../mysqldb','defaults','redis','socket.io-emitter','./mailAccount.socket','register','client','http','request','then','MailAccount,\x20%s,\x20%s','request\x20sent','MailAccount,\x20%s,\x20%s,\x20%s','error','code','message','info','result','catch','sendStatus','status','end','json','offset','undefined','limit','count','Content-Range','destroy','get','UserProfileResource','stack','name','send','index','Imap','MailServerOut','Smtp','mandatoryDispositionPause','map','rawAttributes','fieldName','type','key','keys','query','intersection','attributes','fields','model','hasOwnProperty','sort','filters','where','merge','filter','options','MailAccount','includeAll','findAll','rows','show','params'];(function(_0x563069,_0xea9144){var _0x6456f8=function(_0x3b27e9){while(--_0x3b27e9){_0x563069['push'](_0x563069['shift']());}};_0x6456f8(++_0xea9144);}(_0x03f3,0x11e));var _0x303f=function(_0x40de6f,_0x3d5f9c){_0x40de6f=_0x40de6f-0x0;var _0x44a887=_0x03f3[_0x40de6f];return _0x44a887;};'use strict';var moment=require(_0x303f('0x0'));var BPromise=require(_0x303f('0x1'));var util=require(_0x303f('0x2'));var path=require(_0x303f('0x3'));var _=require(_0x303f('0x4'));var juice=require(_0x303f('0x5'));var Redis=require(_0x303f('0x6'));var qs=require('../../components/parsers/qs');var logger=require('../../config/logger')('api');var config=require('../../config/environment');var db=require(_0x303f('0x7'))['db'];config['redis']=_[_0x303f('0x8')](config[_0x303f('0x9')],{'host':'localhost','port':0x18eb});var socket=require(_0x303f('0xa'))(new Redis(config[_0x303f('0x9')]));require(_0x303f('0xb'))[_0x303f('0xc')](socket);var jayson=require('jayson/promise');var client=jayson[_0x303f('0xd')][_0x303f('0xe')]({'port':0x232b});function respondWithRpcPromise(_0x1642cf,_0x56ae6c,_0x5c38fd,_0x3680cb){return new BPromise(function(_0x3eb3a9,_0x3c93a0){var _0x2d00b2=_0x3680cb||client;return _0x2d00b2[_0x303f('0xf')](_0x1642cf,_0x5c38fd)[_0x303f('0x10')](function(_0x56fb9){logger['info'](_0x303f('0x11'),_0x56ae6c,_0x303f('0x12'));logger['debug'](_0x303f('0x13'),_0x56ae6c,'request\x20sent',JSON['stringify'](_0x56fb9));if(_0x56fb9['error']){if(_0x56fb9[_0x303f('0x14')][_0x303f('0x15')]===0x1f4){logger[_0x303f('0x14')]('MailAccount,\x20%s,\x20%s',_0x56ae6c,_0x56fb9[_0x303f('0x14')][_0x303f('0x16')]);return _0x3c93a0(_0x56fb9[_0x303f('0x14')][_0x303f('0x16')]);}logger[_0x303f('0x14')]('MailAccount,\x20%s,\x20%s',_0x56ae6c,_0x56fb9[_0x303f('0x14')][_0x303f('0x16')]);return _0x3eb3a9(_0x56fb9[_0x303f('0x14')][_0x303f('0x16')]);}else{logger[_0x303f('0x17')](_0x303f('0x11'),_0x56ae6c,_0x303f('0x12'));_0x3eb3a9(_0x56fb9[_0x303f('0x18')]['message']);}})[_0x303f('0x19')](function(_0x52c738){logger[_0x303f('0x14')](_0x303f('0x11'),_0x56ae6c,_0x52c738);_0x3c93a0(_0x52c738);});});}function respondWithStatusCode(_0x5403bd,_0xc94782){_0xc94782=_0xc94782||0xcc;return function(_0x361012){if(_0x361012){return _0x5403bd[_0x303f('0x1a')](_0xc94782);}return _0x5403bd[_0x303f('0x1b')](_0xc94782)[_0x303f('0x1c')]();};}function respondWithResult(_0x66673b,_0x193979){_0x193979=_0x193979||0xc8;return function(_0x481346){if(_0x481346){return _0x66673b[_0x303f('0x1b')](_0x193979)[_0x303f('0x1d')](_0x481346);}};}function respondWithFilteredResult(_0x2b541b,_0x4cf817){return function(_0x3dd7eb){if(_0x3dd7eb){var _0x309cfa=typeof _0x4cf817[_0x303f('0x1e')]===_0x303f('0x1f')&&typeof _0x4cf817[_0x303f('0x20')]==='undefined';var _0x256f2b=_0x3dd7eb[_0x303f('0x21')];var _0x2b9ef1=_0x309cfa?0x0:_0x4cf817[_0x303f('0x1e')];var _0x6a6eaf=_0x309cfa?_0x3dd7eb['count']:_0x4cf817[_0x303f('0x1e')]+_0x4cf817['limit'];var _0x1abc54;if(_0x6a6eaf>=_0x256f2b){_0x6a6eaf=_0x256f2b;_0x1abc54=0xc8;}else{_0x1abc54=0xce;}_0x2b541b[_0x303f('0x1b')](_0x1abc54);return _0x2b541b['set'](_0x303f('0x22'),_0x2b9ef1+'-'+_0x6a6eaf+'/'+_0x256f2b)[_0x303f('0x1d')](_0x3dd7eb);}return null;};}function saveUpdates(_0x314cbc){return function(_0x9839cd){if(_0x9839cd){return _0x9839cd['update'](_0x314cbc)['then'](function(_0x494fed){return _0x494fed;});}return null;};}function removeEntity(_0x470252){return function(_0x52d4f1){if(_0x52d4f1){return _0x52d4f1[_0x303f('0x23')]()[_0x303f('0x10')](function(){var _0x11f9e2=_0x52d4f1[_0x303f('0x24')]({'plain':!![]});var _0xf29876='MailAccounts';return db[_0x303f('0x25')][_0x303f('0x23')]({'where':{'type':_0xf29876,'resourceId':_0x11f9e2['id']}})[_0x303f('0x10')](function(){return _0x52d4f1;});})[_0x303f('0x10')](function(){_0x470252['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x3cb58e){return function(_0x2c4650){if(!_0x2c4650){_0x3cb58e[_0x303f('0x1a')](0x194);}return _0x2c4650;};}function handleError(_0x4f1fc6,_0x2fc917){_0x2fc917=_0x2fc917||0x1f4;return function(_0x483cd6){logger[_0x303f('0x14')](_0x483cd6[_0x303f('0x26')]);if(_0x483cd6[_0x303f('0x27')]){delete _0x483cd6[_0x303f('0x27')];}_0x4f1fc6[_0x303f('0x1b')](_0x2fc917)[_0x303f('0x28')](_0x483cd6);};}exports[_0x303f('0x29')]=function(_0x36050f,_0x42510){var _0xfb9413={'include':[{'model':db['MailServerIn'],'as':_0x303f('0x2a')},{'model':db[_0x303f('0x2b')],'as':_0x303f('0x2c')},{'model':db['Pause'],'as':_0x303f('0x2d')}]},_0x1737cd={},_0x508536={'count':0x0,'rows':[]};var _0x3ad659=_[_0x303f('0x2e')](db['MailAccount'][_0x303f('0x2f')],function(_0x4d76a7){return{'name':_0x4d76a7[_0x303f('0x30')],'type':_0x4d76a7[_0x303f('0x31')][_0x303f('0x32')]};});_0x1737cd['model']=_[_0x303f('0x2e')](_0x3ad659,'name');_0x1737cd['query']=_[_0x303f('0x33')](_0x36050f[_0x303f('0x34')]);_0x1737cd['filters']=_[_0x303f('0x35')](_0x1737cd['model'],_0x1737cd[_0x303f('0x34')]);_0xfb9413[_0x303f('0x36')]=_[_0x303f('0x35')](_0x1737cd['model'],qs[_0x303f('0x37')](_0x36050f['query'][_0x303f('0x37')]));_0xfb9413[_0x303f('0x36')]=_0xfb9413[_0x303f('0x36')]['length']?_0xfb9413[_0x303f('0x36')]:_0x1737cd[_0x303f('0x38')];if(!_0x36050f['query'][_0x303f('0x39')]('nolimit')){_0xfb9413['limit']=qs['limit'](_0x36050f[_0x303f('0x34')][_0x303f('0x20')]);_0xfb9413[_0x303f('0x1e')]=qs[_0x303f('0x1e')](_0x36050f['query']['offset']);}_0xfb9413['order']=qs['sort'](_0x36050f[_0x303f('0x34')][_0x303f('0x3a')]);_0xfb9413['where']=qs[_0x303f('0x3b')](_['pick'](_0x36050f[_0x303f('0x34')],_0x1737cd[_0x303f('0x3b')]),_0x3ad659);if(_0x36050f[_0x303f('0x34')]['filter']){_0xfb9413[_0x303f('0x3c')]=_[_0x303f('0x3d')](_0xfb9413[_0x303f('0x3c')],{'$or':_[_0x303f('0x2e')](_0x3ad659,function(_0x4e9f2c){if(_0x4e9f2c[_0x303f('0x31')]!=='VIRTUAL'){var _0x42adcb={};_0x42adcb[_0x4e9f2c[_0x303f('0x27')]]={'$like':'%'+_0x36050f[_0x303f('0x34')][_0x303f('0x3e')]+'%'};return _0x42adcb;}})});}_0xfb9413=_[_0x303f('0x3d')]({},_0xfb9413,_0x36050f[_0x303f('0x3f')]);var _0x1009b5={'where':_0xfb9413[_0x303f('0x3c')]};return db[_0x303f('0x40')][_0x303f('0x21')](_0x1009b5)[_0x303f('0x10')](function(_0x5dc983){_0x508536[_0x303f('0x21')]=_0x5dc983;if(_0x36050f[_0x303f('0x34')][_0x303f('0x41')]){_0xfb9413['include']=[{'all':!![]}];}return db['MailAccount'][_0x303f('0x42')](_0xfb9413);})['then'](function(_0x209ecc){_0x508536[_0x303f('0x43')]=_0x209ecc;return _0x508536;})[_0x303f('0x10')](respondWithFilteredResult(_0x42510,_0xfb9413))[_0x303f('0x19')](handleError(_0x42510,null));};exports[_0x303f('0x44')]=function(_0x212c40,_0x547291){var _0x2f301c={'raw':![],'where':{'id':_0x212c40[_0x303f('0x45')]['id']},'include':[{'model':db[_0x303f('0x46')],'as':_0x303f('0x2a')},{'model':db[_0x303f('0x2b')],'as':_0x303f('0x2c')},{'model':db[_0x303f('0x47')],'as':'mandatoryDispositionPause'}]},_0x16f60f={};_0x16f60f[_0x303f('0x38')]=_[_0x303f('0x33')](db['MailAccount'][_0x303f('0x2f')]);_0x16f60f[_0x303f('0x34')]=_[_0x303f('0x33')](_0x212c40[_0x303f('0x34')]);_0x16f60f['filters']=_[_0x303f('0x35')](_0x16f60f[_0x303f('0x38')],_0x16f60f['query']);_0x2f301c[_0x303f('0x36')]=_[_0x303f('0x35')](_0x16f60f[_0x303f('0x38')],qs[_0x303f('0x37')](_0x212c40['query']['fields']));_0x2f301c[_0x303f('0x36')]=_0x2f301c[_0x303f('0x36')][_0x303f('0x48')]?_0x2f301c[_0x303f('0x36')]:_0x16f60f[_0x303f('0x38')];if(_0x212c40[_0x303f('0x34')]['includeAll']){_0x2f301c['include']=[{'all':!![]}];}_0x2f301c=_[_0x303f('0x3d')]({},_0x2f301c,_0x212c40[_0x303f('0x3f')]);return db[_0x303f('0x40')][_0x303f('0x49')](_0x2f301c)[_0x303f('0x10')](handleEntityNotFound(_0x547291,null))[_0x303f('0x10')](respondWithResult(_0x547291,null))[_0x303f('0x19')](handleError(_0x547291,null));};exports[_0x303f('0x4a')]=function(_0x2c5fda,_0x53e83d){if(_0x2c5fda[_0x303f('0x4b')]['id']){delete _0x2c5fda[_0x303f('0x4b')]['id'];}if(_0x2c5fda[_0x303f('0x4b')][_0x303f('0x2a')]){if(!_0x2c5fda[_0x303f('0x4b')][_0x303f('0x2a')]['modernAuthentication']){_0x2c5fda['body'][_0x303f('0x2a')][_0x303f('0x4c')]=null;}}if(_0x2c5fda[_0x303f('0x4b')]['Smtp']){if(!_0x2c5fda[_0x303f('0x4b')][_0x303f('0x2c')][_0x303f('0x4d')]){_0x2c5fda['body'][_0x303f('0x2c')]['CloudProviderId']=null;}}return db['MailAccount'][_0x303f('0x49')]({'where':{'id':_0x2c5fda[_0x303f('0x45')]['id']},'include':[{'model':db[_0x303f('0x46')],'as':_0x303f('0x2a')},{'model':db[_0x303f('0x2b')],'as':_0x303f('0x2c')},{'model':db[_0x303f('0x47')],'as':_0x303f('0x2d')}]})[_0x303f('0x10')](handleEntityNotFound(_0x53e83d,null))[_0x303f('0x10')](saveUpdates(_0x2c5fda['body'],null))[_0x303f('0x10')](function(_0x3e8a00){if(_0x3e8a00&&_0x2c5fda['body']['Imap']){return db['MailServerIn'][_0x303f('0x4a')](_0x2c5fda[_0x303f('0x4b')][_0x303f('0x2a')],{'where':{'MailAccountId':_0x3e8a00['id']}})['then'](function(){return _0x3e8a00;});}return _0x3e8a00;})[_0x303f('0x10')](function(_0x465e8c){if(_0x465e8c&&_0x2c5fda['body'][_0x303f('0x2c')]){return db[_0x303f('0x2b')][_0x303f('0x4a')](_0x2c5fda[_0x303f('0x4b')][_0x303f('0x2c')],{'where':{'MailAccountId':_0x465e8c['id']}})['then'](function(){return _0x465e8c;});}return _0x465e8c;})[_0x303f('0x10')](respondWithResult(_0x53e83d,null))[_0x303f('0x19')](handleError(_0x53e83d,null));};exports[_0x303f('0x4e')]=function(_0x40faa1,_0x1ca205){return db[_0x303f('0x40')][_0x303f('0x4e')]()['then'](respondWithResult(_0x1ca205,null))[_0x303f('0x19')](handleError(_0x1ca205,null));};exports[_0x303f('0x4f')]=function(_0x1dc780,_0x4d28f8){if(_0x1dc780[_0x303f('0x4b')]['id']){delete _0x1dc780[_0x303f('0x4b')]['id'];}return db['MailAccount'][_0x303f('0x49')]({'where':{'id':_0x1dc780[_0x303f('0x45')]['id']}})[_0x303f('0x10')](handleEntityNotFound(_0x4d28f8,null))[_0x303f('0x10')](function(_0xde8929){if(_0xde8929){_0x1dc780[_0x303f('0x4b')][_0x303f('0x50')]=_0xde8929['id'];return db[_0x303f('0x51')]['create'](_0x1dc780['body']);}})['then'](respondWithResult(_0x4d28f8,null))[_0x303f('0x19')](handleError(_0x4d28f8,null));};exports[_0x303f('0x52')]=function(_0x11c1d3,_0x3f5a9b){var _0x48aa4e={'raw':![],'where':{}};var _0x23a7e7={};var _0x3eda47={'count':0x0,'rows':[]};return db['MailAccount'][_0x303f('0x53')]({'where':{'id':_0x11c1d3['params']['id']}})[_0x303f('0x10')](handleEntityNotFound(_0x3f5a9b,null))['then'](function(_0x3f6433){if(_0x3f6433){_0x23a7e7[_0x303f('0x38')]=_[_0x303f('0x33')](db[_0x303f('0x51')][_0x303f('0x2f')]);_0x23a7e7['query']=_[_0x303f('0x33')](_0x11c1d3[_0x303f('0x34')]);_0x23a7e7['filters']=_[_0x303f('0x35')](_0x23a7e7[_0x303f('0x38')],_0x23a7e7['query']);_0x48aa4e[_0x303f('0x36')]=_[_0x303f('0x35')](_0x23a7e7['model'],qs[_0x303f('0x37')](_0x11c1d3[_0x303f('0x34')][_0x303f('0x37')]));_0x48aa4e['attributes']=_0x48aa4e[_0x303f('0x36')][_0x303f('0x48')]?_0x48aa4e['attributes']:_0x23a7e7['model'];if(!_0x11c1d3[_0x303f('0x34')][_0x303f('0x39')](_0x303f('0x54'))){_0x48aa4e['limit']=qs['limit'](_0x11c1d3['query'][_0x303f('0x20')]);_0x48aa4e['offset']=qs[_0x303f('0x1e')](_0x11c1d3[_0x303f('0x34')][_0x303f('0x1e')]);}_0x48aa4e['order']=qs['sort'](_0x11c1d3[_0x303f('0x34')][_0x303f('0x3a')]);_0x48aa4e[_0x303f('0x3c')]=qs['filters'](_[_0x303f('0x55')](_0x11c1d3['query'],_0x23a7e7[_0x303f('0x3b')]));_0x48aa4e['where']['MailAccountId']=_0x3f6433['id'];if(_0x11c1d3[_0x303f('0x34')][_0x303f('0x3e')]){_0x48aa4e[_0x303f('0x3c')]=_[_0x303f('0x3d')](_0x48aa4e[_0x303f('0x3c')],{'$or':_[_0x303f('0x2e')](_0x48aa4e[_0x303f('0x36')],function(_0x3c9fb9){var _0x350ee7={};_0x350ee7[_0x3c9fb9]={'$like':'%'+_0x11c1d3[_0x303f('0x34')][_0x303f('0x3e')]+'%'};return _0x350ee7;})});}_0x48aa4e=_[_0x303f('0x3d')]({},_0x48aa4e,_0x11c1d3['options']);return db[_0x303f('0x51')][_0x303f('0x21')]({'where':_0x48aa4e[_0x303f('0x3c')]})[_0x303f('0x10')](function(_0x8345e7){_0x3eda47[_0x303f('0x21')]=_0x8345e7;if(_0x11c1d3['query']['includeAll']){_0x48aa4e[_0x303f('0x56')]=[{'all':!![]}];}return db[_0x303f('0x51')][_0x303f('0x42')](_0x48aa4e);})[_0x303f('0x10')](function(_0x1f59f7){_0x3eda47[_0x303f('0x43')]=_0x1f59f7;return _0x3eda47;});}})[_0x303f('0x10')](respondWithFilteredResult(_0x3f5a9b,_0x48aa4e))[_0x303f('0x19')](handleError(_0x3f5a9b,null));};exports['removeDispositions']=function(_0x3a5f7c,_0x97650a){return db[_0x303f('0x40')]['find']({'where':{'id':_0x3a5f7c['params']['id']}})[_0x303f('0x10')](handleEntityNotFound(_0x97650a,null))[_0x303f('0x10')](function(_0x44e7e0){if(_0x44e7e0){return _0x44e7e0['removeDispositions'](_0x3a5f7c[_0x303f('0x34')][_0x303f('0x57')]);}})[_0x303f('0x10')](respondWithStatusCode(_0x97650a,null))[_0x303f('0x19')](handleError(_0x97650a,null));};exports[_0x303f('0x58')]=function(_0x4bac40,_0x8d28ac){if(_0x4bac40['body']['id']){delete _0x4bac40[_0x303f('0x4b')]['id'];}return db[_0x303f('0x40')][_0x303f('0x49')]({'where':{'id':_0x4bac40[_0x303f('0x45')]['id']}})['then'](handleEntityNotFound(_0x8d28ac,null))['then'](function(_0x28c015){if(_0x28c015){_0x4bac40['body'][_0x303f('0x50')]=_0x28c015['id'];return db[_0x303f('0x59')][_0x303f('0x5a')](_0x4bac40[_0x303f('0x4b')]);}})['then'](respondWithResult(_0x8d28ac,null))['catch'](handleError(_0x8d28ac,null));};exports[_0x303f('0x5b')]=function(_0x1aff24,_0x140c75){var _0x1cd144={'raw':![],'where':{}};var _0x3eb773={};var _0x594ddc={'count':0x0,'rows':[]};return db['MailAccount'][_0x303f('0x53')]({'where':{'id':_0x1aff24[_0x303f('0x45')]['id']}})[_0x303f('0x10')](handleEntityNotFound(_0x140c75,null))[_0x303f('0x10')](function(_0x2dea7a){if(_0x2dea7a){_0x3eb773['model']=_[_0x303f('0x33')](db[_0x303f('0x59')][_0x303f('0x2f')]);_0x3eb773[_0x303f('0x34')]=_[_0x303f('0x33')](_0x1aff24[_0x303f('0x34')]);_0x3eb773['filters']=_['intersection'](_0x3eb773['model'],_0x3eb773[_0x303f('0x34')]);_0x1cd144[_0x303f('0x36')]=_[_0x303f('0x35')](_0x3eb773[_0x303f('0x38')],qs[_0x303f('0x37')](_0x1aff24[_0x303f('0x34')]['fields']));_0x1cd144[_0x303f('0x36')]=_0x1cd144[_0x303f('0x36')][_0x303f('0x48')]?_0x1cd144[_0x303f('0x36')]:_0x3eb773[_0x303f('0x38')];if(!_0x1aff24[_0x303f('0x34')]['hasOwnProperty'](_0x303f('0x54'))){_0x1cd144[_0x303f('0x20')]=qs[_0x303f('0x20')](_0x1aff24[_0x303f('0x34')]['limit']);_0x1cd144[_0x303f('0x1e')]=qs[_0x303f('0x1e')](_0x1aff24[_0x303f('0x34')][_0x303f('0x1e')]);}_0x1cd144[_0x303f('0x5c')]=qs[_0x303f('0x3a')](_0x1aff24[_0x303f('0x34')][_0x303f('0x3a')]);_0x1cd144[_0x303f('0x3c')]=qs['filters'](_[_0x303f('0x55')](_0x1aff24[_0x303f('0x34')],_0x3eb773[_0x303f('0x3b')]));_0x1cd144[_0x303f('0x3c')]['MailAccountId']=_0x2dea7a['id'];if(_0x1aff24[_0x303f('0x34')]['filter']){_0x1cd144['where']=_[_0x303f('0x3d')](_0x1cd144[_0x303f('0x3c')],{'$or':_[_0x303f('0x2e')](_0x1cd144[_0x303f('0x36')],function(_0x56bbd9){var _0x2aaa90={};_0x2aaa90[_0x56bbd9]={'$like':'%'+_0x1aff24[_0x303f('0x34')][_0x303f('0x3e')]+'%'};return _0x2aaa90;})});}_0x1cd144=_['merge']({},_0x1cd144,_0x1aff24[_0x303f('0x3f')]);return db[_0x303f('0x59')][_0x303f('0x21')]({'where':_0x1cd144['where']})[_0x303f('0x10')](function(_0xd5cd79){_0x594ddc[_0x303f('0x21')]=_0xd5cd79;if(_0x1aff24[_0x303f('0x34')][_0x303f('0x41')]){_0x1cd144[_0x303f('0x56')]=[{'all':!![]}];}return db[_0x303f('0x59')][_0x303f('0x42')](_0x1cd144);})[_0x303f('0x10')](function(_0x2bfcb3){_0x594ddc['rows']=_0x2bfcb3;return _0x594ddc;});}})[_0x303f('0x10')](respondWithFilteredResult(_0x140c75,_0x1cd144))[_0x303f('0x19')](handleError(_0x140c75,null));};exports[_0x303f('0x5d')]=function(_0x388df8,_0x1f389a){return db['MailAccount'][_0x303f('0x49')]({'where':{'id':_0x388df8[_0x303f('0x45')]['id']}})[_0x303f('0x10')](handleEntityNotFound(_0x1f389a,null))[_0x303f('0x10')](function(_0x39f8db){if(_0x39f8db){return _0x39f8db[_0x303f('0x5d')](_0x388df8[_0x303f('0x34')]['ids']);}})[_0x303f('0x10')](respondWithStatusCode(_0x1f389a,null))[_0x303f('0x19')](handleError(_0x1f389a,null));};exports[_0x303f('0x5a')]=function(_0x1101ef,_0x26d26b){var _0x51dab0={'name':_0x1101ef['body'][_0x303f('0x27')],'key':_0x1101ef[_0x303f('0x4b')][_0x303f('0x32')],'provider':_0x1101ef[_0x303f('0x4b')]['provider']===_0x303f('0x5e')?null:_0x1101ef[_0x303f('0x4b')]['provider'],'email':_0x1101ef[_0x303f('0x4b')][_0x303f('0x5f')],'ListId':_0x1101ef[_0x303f('0x4b')]['ListId'],'active':!_['isNil'](_0x1101ef[_0x303f('0x4b')]['active'])?_0x1101ef[_0x303f('0x4b')]['active']:!![],'description':_0x1101ef[_0x303f('0x4b')][_0x303f('0x60')]||null,'Imap':{},'Smtp':{}};if(_0x51dab0[_0x303f('0x61')]){_0x51dab0[_0x303f('0x2a')][_0x303f('0x62')]=_0x51dab0[_0x303f('0x2c')][_0x303f('0x62')]=_0x1101ef['body']['username'];_0x51dab0[_0x303f('0x2a')]['password']=_0x51dab0[_0x303f('0x2c')][_0x303f('0x63')]=_0x1101ef[_0x303f('0x4b')][_0x303f('0x64')];if(_0x1101ef[_0x303f('0x4b')][_0x303f('0x4d')]){_0x51dab0['Imap'][_0x303f('0x4d')]=_0x51dab0[_0x303f('0x2c')]['modernAuthentication']=!![];_0x51dab0[_0x303f('0x2a')][_0x303f('0x4c')]=_0x51dab0[_0x303f('0x2c')][_0x303f('0x4c')]=_0x1101ef[_0x303f('0x4b')]['CloudProviderId'];_0x51dab0[_0x303f('0x2a')][_0x303f('0x64')]=_0x51dab0['Smtp'][_0x303f('0x63')]=null;}else{_0x51dab0[_0x303f('0x2a')][_0x303f('0x4c')]=_0x51dab0[_0x303f('0x2c')][_0x303f('0x4c')]=null;}_0x51dab0[_0x303f('0x2a')]['service']=_0x51dab0[_0x303f('0x2c')]['service']=null;_0x51dab0[_0x303f('0x2a')][_0x303f('0x65')]=_0x51dab0[_0x303f('0x2c')][_0x303f('0x65')]=null;_0x51dab0['Imap'][_0x303f('0x66')]=_0x51dab0[_0x303f('0x2c')][_0x303f('0x66')]=null;}else{if(_0x1101ef[_0x303f('0x4b')][_0x303f('0x67')]){_0x51dab0[_0x303f('0x2a')][_0x303f('0x62')]=_0x51dab0[_0x303f('0x2c')][_0x303f('0x62')]=_0x1101ef[_0x303f('0x4b')][_0x303f('0x68')];_0x51dab0['Imap']['password']=_0x51dab0[_0x303f('0x2c')][_0x303f('0x63')]=_0x1101ef['body'][_0x303f('0x64')];}else{_0x51dab0['Imap'][_0x303f('0x67')]=_0x51dab0['Smtp'][_0x303f('0x67')]=![];_0x51dab0[_0x303f('0x2a')][_0x303f('0x62')]=_0x51dab0['Smtp'][_0x303f('0x62')]=null;_0x51dab0[_0x303f('0x2a')][_0x303f('0x64')]=_0x51dab0[_0x303f('0x2c')]['pass']=null;}_0x51dab0['Imap']['host']=_0x1101ef[_0x303f('0x4b')]['Imap']['host'];_0x51dab0[_0x303f('0x2a')][_0x303f('0x66')]=_0x1101ef[_0x303f('0x4b')][_0x303f('0x2a')][_0x303f('0x66')];_0x51dab0[_0x303f('0x2c')][_0x303f('0x65')]=_0x1101ef[_0x303f('0x4b')][_0x303f('0x2c')][_0x303f('0x65')];_0x51dab0[_0x303f('0x2c')][_0x303f('0x66')]=_0x1101ef[_0x303f('0x4b')][_0x303f('0x2c')]['port'];}return db[_0x303f('0x40')]['create'](_0x51dab0,{'include':[{'model':db[_0x303f('0x2b')],'as':_0x303f('0x2c')},{'model':db[_0x303f('0x46')],'as':'Imap'}]})[_0x303f('0x10')](function(_0x18281e){var _0x208dbc=_0x1101ef[_0x303f('0x62')][_0x303f('0x24')]({'plain':!![]});if(!_0x208dbc)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x208dbc[_0x303f('0x69')]===_0x303f('0x62')){var _0x24eca0=_0x18281e[_0x303f('0x24')]({'plain':!![]});return db[_0x303f('0x6a')][_0x303f('0x49')]({'where':{'name':_0x303f('0x6b'),'userProfileId':_0x208dbc[_0x303f('0x6c')]},'raw':!![]})[_0x303f('0x10')](function(_0x3f49cb){if(_0x3f49cb&&_0x3f49cb[_0x303f('0x6d')]===0x0){return db[_0x303f('0x25')][_0x303f('0x5a')]({'name':_0x24eca0['name'],'resourceId':_0x24eca0['id'],'type':_0x3f49cb[_0x303f('0x27')],'sectionId':_0x3f49cb['id']},{})[_0x303f('0x10')](function(){return _0x18281e;});}else{return _0x18281e;}})['catch'](function(_0x59145b){logger[_0x303f('0x14')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x59145b);throw _0x59145b;});}return _0x18281e;})[_0x303f('0x10')](respondWithResult(_0x26d26b,0xc9))[_0x303f('0x19')](handleError(_0x26d26b,null));};exports[_0x303f('0x6e')]=function(_0x47b2b1,_0x34291c){return db['MailAccount']['findOne']({'where':{'id':_0x47b2b1['params']['id']}})[_0x303f('0x10')](handleEntityNotFound(_0x34291c,null))[_0x303f('0x10')](function(_0x6b6702){if(_0x6b6702){return _0x6b6702[_0x303f('0x6e')]();}return null;})['then'](respondWithResult(_0x34291c,null))['catch'](handleError(_0x34291c,null));};exports[_0x303f('0x6f')]=function(_0x448b9f,_0x149426){if(_0x448b9f['body']['id']){delete _0x448b9f['body']['id'];}return db[_0x303f('0x40')]['find']({'where':{'id':_0x448b9f[_0x303f('0x45')]['id']}})[_0x303f('0x10')](handleEntityNotFound(_0x149426,null))[_0x303f('0x10')](function(_0x1fe393){if(_0x1fe393){_0x448b9f[_0x303f('0x4b')][_0x303f('0x50')]=_0x1fe393['id'];return db['MailServerIn']['create'](_0x448b9f[_0x303f('0x4b')]);}})[_0x303f('0x10')](respondWithResult(_0x149426,null))[_0x303f('0x19')](handleError(_0x149426,null));};exports['removeImap']=function(_0x286ed0,_0x1fab45){return db[_0x303f('0x40')][_0x303f('0x53')]({'where':{'id':_0x286ed0[_0x303f('0x45')]['id']}})['then'](handleEntityNotFound(_0x1fab45,null))[_0x303f('0x10')](function(_0x3beac5){if(_0x3beac5){return _0x3beac5['setImap'](null);}return null;})[_0x303f('0x10')](respondWithStatusCode(_0x1fab45,null))[_0x303f('0x19')](handleError(_0x1fab45,null));};exports[_0x303f('0x70')]=function(_0x4bbb31,_0x37723b){return db[_0x303f('0x40')]['findOne']({'where':{'id':_0x4bbb31[_0x303f('0x45')]['id']}})[_0x303f('0x10')](handleEntityNotFound(_0x37723b,null))[_0x303f('0x10')](function(_0x3788e6){if(_0x3788e6){return _0x3788e6[_0x303f('0x70')]();}return null;})[_0x303f('0x10')](respondWithResult(_0x37723b,null))[_0x303f('0x19')](handleError(_0x37723b,null));};exports[_0x303f('0x71')]=function(_0x155820,_0xdf95a2){if(_0x155820['body']['id']){delete _0x155820[_0x303f('0x4b')]['id'];}return db[_0x303f('0x40')]['find']({'where':{'id':_0x155820[_0x303f('0x45')]['id']}})[_0x303f('0x10')](handleEntityNotFound(_0xdf95a2,null))['then'](function(_0x25ec89){if(_0x25ec89){_0x155820[_0x303f('0x4b')][_0x303f('0x50')]=_0x25ec89['id'];return db[_0x303f('0x2b')]['create'](_0x155820[_0x303f('0x4b')]);}})[_0x303f('0x10')](respondWithResult(_0xdf95a2,null))['catch'](handleError(_0xdf95a2,null));};exports['removeSmtp']=function(_0x116f8a,_0x54e02a){return db['MailAccount'][_0x303f('0x53')]({'where':{'id':_0x116f8a['params']['id']}})['then'](handleEntityNotFound(_0x54e02a,null))[_0x303f('0x10')](function(_0x1ca9c5){if(_0x1ca9c5){return _0x1ca9c5[_0x303f('0x72')](null);}return null;})['then'](respondWithStatusCode(_0x54e02a,null))[_0x303f('0x19')](handleError(_0x54e02a,null));};exports[_0x303f('0x73')]=function(_0x153baf,_0x57b11c){return db['MailInteraction'][_0x303f('0x49')]({'where':{'id':_0x153baf['params']['id']}})['then'](handleEntityNotFound(_0x57b11c,null))[_0x303f('0x10')](function(_0x18c606){if(_0x18c606){return _0x18c606[_0x303f('0x73')](_0x153baf[_0x303f('0x4b')][_0x303f('0x57')],_[_0x303f('0x74')](_0x153baf[_0x303f('0x4b')],['ids','id'])||{});}})[_0x303f('0x10')](respondWithResult(_0x57b11c,null))['catch'](handleError(_0x57b11c,null));};exports[_0x303f('0x75')]=function(_0x56685e,_0x3b7df4){var _0x45eea6={'raw':![],'where':{}};var _0x2de8f7={};var _0x4f761e={'count':0x0,'rows':[]};return db[_0x303f('0x40')]['findOne']({'where':{'id':_0x56685e['params']['id']}})[_0x303f('0x10')](handleEntityNotFound(_0x3b7df4,null))['then'](function(_0x8ccd86){if(_0x8ccd86){_0x2de8f7[_0x303f('0x38')]=_['keys'](db['MailInteraction'][_0x303f('0x2f')]);_0x2de8f7[_0x303f('0x34')]=_[_0x303f('0x33')](_0x56685e['query']);_0x2de8f7['filters']=_[_0x303f('0x35')](_0x2de8f7[_0x303f('0x38')],_0x2de8f7[_0x303f('0x34')]);_0x45eea6['attributes']=_[_0x303f('0x35')](_0x2de8f7[_0x303f('0x38')],qs[_0x303f('0x37')](_0x56685e[_0x303f('0x34')][_0x303f('0x37')]));_0x45eea6['attributes']=_0x45eea6['attributes'][_0x303f('0x48')]?_0x45eea6[_0x303f('0x36')]:_0x2de8f7['model'];if(!_0x56685e[_0x303f('0x34')]['hasOwnProperty'](_0x303f('0x54'))){_0x45eea6[_0x303f('0x20')]=qs['limit'](_0x56685e['query'][_0x303f('0x20')]);_0x45eea6['offset']=qs[_0x303f('0x1e')](_0x56685e[_0x303f('0x34')][_0x303f('0x1e')]);}_0x45eea6[_0x303f('0x5c')]=qs[_0x303f('0x3a')](_0x56685e[_0x303f('0x34')]['sort']);_0x45eea6[_0x303f('0x3c')]=qs[_0x303f('0x3b')](_[_0x303f('0x55')](_0x56685e[_0x303f('0x34')],_0x2de8f7[_0x303f('0x3b')]));_0x45eea6['where'][_0x303f('0x50')]=_0x8ccd86['id'];if(_0x56685e[_0x303f('0x34')][_0x303f('0x3e')]){_0x45eea6[_0x303f('0x3c')]=_['merge'](_0x45eea6[_0x303f('0x3c')],{'$or':_['map'](_0x45eea6[_0x303f('0x36')],function(_0xfa94c){var _0x369cb0={};_0x369cb0[_0xfa94c]={'$like':'%'+_0x56685e[_0x303f('0x34')][_0x303f('0x3e')]+'%'};return _0x369cb0;})});}_0x45eea6=_[_0x303f('0x3d')]({},_0x45eea6,_0x56685e['options']);return db['MailInteraction'][_0x303f('0x21')]({'where':_0x45eea6[_0x303f('0x3c')]})[_0x303f('0x10')](function(_0x3ea7ca){_0x4f761e[_0x303f('0x21')]=_0x3ea7ca;if(_0x56685e[_0x303f('0x34')][_0x303f('0x41')]){_0x45eea6[_0x303f('0x56')]=[{'model':db['CmContact'],'as':'Contact','required':![]},{'model':db[_0x303f('0x76')],'as':_0x303f('0x77'),'attributes':[_0x303f('0x27'),_0x303f('0x78'),_0x303f('0x79')],'required':![]},{'model':db[_0x303f('0x7a')],'as':_0x303f('0x7b'),'attributes':['id','name',_0x303f('0x7c')],'where':_0x56685e[_0x303f('0x34')][_0x303f('0x7d')]?{'id':_0x56685e[_0x303f('0x34')][_0x303f('0x7d')]}:undefined,'required':_0x56685e[_0x303f('0x34')]['tag']?!![]:![]}];}return db[_0x303f('0x7e')][_0x303f('0x42')](_0x45eea6);})[_0x303f('0x10')](function(_0x47f195){_0x4f761e[_0x303f('0x43')]=_0x47f195;return _0x4f761e;});}})[_0x303f('0x10')](respondWithFilteredResult(_0x3b7df4,_0x45eea6))[_0x303f('0x19')](handleError(_0x3b7df4,null));};exports['addApplications']=function addApplications(_0x30cdd4,_0x4adfdb){var _0x3ebf00=_0x30cdd4[_0x303f('0x45')]['id'];var _0x4c556f=_0x30cdd4['body'];var _0x5a274e=0xc8;var _0x485854=null;return db[_0x303f('0x7f')][_0x303f('0x80')]({'isolationLevel':db[_0x303f('0x7f')][_0x303f('0x81')][_0x303f('0x82')][_0x303f('0x83')]},function(_0x1761f4){return db['MailAccount'][_0x303f('0x53')]({'where':{'id':_0x3ebf00},'transaction':_0x1761f4})[_0x303f('0x10')](function(_0x146aa7){if(_0x146aa7){return db['MailApplication'][_0x303f('0x23')]({'where':{'MailAccountId':_0x3ebf00},'transaction':_0x1761f4})[_0x303f('0x10')](function(){var _0x62cba5=_['map'](_0x4c556f,function(_0x3ae08f){_0x3ae08f[_0x303f('0x50')]=_0x3ebf00;return _0x3ae08f;});return db[_0x303f('0x84')][_0x303f('0x85')](_0x62cba5,{'transaction':_0x1761f4});});}else{_0x5a274e=0x194;_0x485854=[];}});})[_0x303f('0x10')](function(){if(_0x5a274e!==0x194){return db['MailApplication'][_0x303f('0x86')]({'where':{'MailAccountId':_0x3ebf00},'order':_0x303f('0x87')})[_0x303f('0x10')](function(_0x5913a2){_0x485854=_0x5913a2;});}})[_0x303f('0x19')](function(_0x1a3526){_0x5a274e=0x1f4;logger[_0x303f('0x14')](_0x1a3526[_0x303f('0x26')]);if(_0x1a3526[_0x303f('0x27')]){delete _0x1a3526['name'];}_0x485854=_0x1a3526;})['finally'](function(){if(_0x485854===null){_0x4adfdb[_0x303f('0x1a')](_0x5a274e);}else{if(_0x5a274e===0x1f4){_0x4adfdb['status'](_0x5a274e)[_0x303f('0x28')](_0x485854);}else{_0x4adfdb[_0x303f('0x1b')](_0x5a274e)[_0x303f('0x1d')](_0x485854);}}});};exports[_0x303f('0x88')]=function(_0x191879,_0x3892a1){var _0x13cb9e={};var _0x34f3eb={};var _0x5bc015;var _0x24cb8d;return db['MailAccount'][_0x303f('0x53')]({'where':{'id':_0x191879[_0x303f('0x45')]['id']}})[_0x303f('0x10')](handleEntityNotFound(_0x3892a1,null))[_0x303f('0x10')](function(_0x4dae52){if(_0x4dae52){_0x5bc015=_0x4dae52;_0x34f3eb[_0x303f('0x38')]=_[_0x303f('0x33')](db[_0x303f('0x84')][_0x303f('0x2f')]);_0x34f3eb[_0x303f('0x34')]=_[_0x303f('0x33')](_0x191879[_0x303f('0x34')]);_0x34f3eb['filters']=_[_0x303f('0x35')](_0x34f3eb[_0x303f('0x38')],_0x34f3eb[_0x303f('0x34')]);_0x13cb9e[_0x303f('0x36')]=_['intersection'](_0x34f3eb['model'],qs[_0x303f('0x37')](_0x191879['query'][_0x303f('0x37')]));_0x13cb9e[_0x303f('0x36')]=_0x13cb9e[_0x303f('0x36')][_0x303f('0x48')]?_0x13cb9e[_0x303f('0x36')]:_0x34f3eb['model'];_0x13cb9e[_0x303f('0x5c')]=qs[_0x303f('0x3a')](_0x191879[_0x303f('0x34')][_0x303f('0x3a')]);_0x13cb9e['where']=qs['filters'](_[_0x303f('0x55')](_0x191879['query'],_0x34f3eb['filters']));if(_0x191879['query']['filter']){_0x13cb9e['where']=_[_0x303f('0x3d')](_0x13cb9e[_0x303f('0x3c')],{'$or':_[_0x303f('0x2e')](_0x13cb9e['attributes'],function(_0x59f68e){var _0x5ee7c6={};_0x5ee7c6[_0x59f68e]={'$like':'%'+_0x191879[_0x303f('0x34')][_0x303f('0x3e')]+'%'};return _0x5ee7c6;})});}_0x13cb9e=_[_0x303f('0x3d')]({},_0x13cb9e,_0x191879['options']);return _0x5bc015[_0x303f('0x88')](_0x13cb9e);}})[_0x303f('0x10')](function(_0x5c28f4){if(_0x5c28f4){_0x24cb8d=_0x5c28f4[_0x303f('0x48')];if(!_0x191879[_0x303f('0x34')][_0x303f('0x39')](_0x303f('0x54'))){_0x13cb9e[_0x303f('0x20')]=qs[_0x303f('0x20')](_0x191879['query'][_0x303f('0x20')]);_0x13cb9e[_0x303f('0x1e')]=qs['offset'](_0x191879[_0x303f('0x34')]['offset']);}return _0x5bc015[_0x303f('0x88')](_0x13cb9e);}})['then'](function(_0x24271b){if(_0x24271b){return _0x24271b?{'count':_0x24cb8d,'rows':_0x24271b}:null;}})[_0x303f('0x10')](respondWithResult(_0x3892a1,null))['catch'](handleError(_0x3892a1,null));};exports[_0x303f('0x89')]=function(_0x4ea063,_0x2e7520){var _0x2e0e67={'raw':!![],'where':{}};var _0x855b29={};var _0x31f2b9={'count':0x0,'rows':[]};return db[_0x303f('0x40')][_0x303f('0x53')]({'where':{'id':_0x4ea063[_0x303f('0x45')]['id']}})[_0x303f('0x10')](handleEntityNotFound(_0x2e7520,null))[_0x303f('0x10')](function(_0x97ec7){if(_0x97ec7){_0x855b29[_0x303f('0x38')]=_[_0x303f('0x33')](db[_0x303f('0x8a')][_0x303f('0x2f')]);_0x855b29[_0x303f('0x34')]=_[_0x303f('0x33')](_0x4ea063[_0x303f('0x34')]);_0x855b29[_0x303f('0x3b')]=_[_0x303f('0x35')](_0x855b29[_0x303f('0x38')],_0x855b29[_0x303f('0x34')]);_0x2e0e67[_0x303f('0x36')]=_[_0x303f('0x35')](_0x855b29[_0x303f('0x38')],qs[_0x303f('0x37')](_0x4ea063[_0x303f('0x34')][_0x303f('0x37')]));_0x2e0e67[_0x303f('0x36')]=_0x2e0e67[_0x303f('0x36')]['length']?_0x2e0e67['attributes']:_0x855b29[_0x303f('0x38')];if(!_0x4ea063['query']['hasOwnProperty'](_0x303f('0x54'))){_0x2e0e67[_0x303f('0x20')]=qs[_0x303f('0x20')](_0x4ea063['query'][_0x303f('0x20')]);_0x2e0e67[_0x303f('0x1e')]=qs['offset'](_0x4ea063['query'][_0x303f('0x1e')]);}_0x2e0e67[_0x303f('0x5c')]=qs[_0x303f('0x3a')](_0x4ea063['query'][_0x303f('0x3a')]);_0x2e0e67[_0x303f('0x3c')]=qs['filters'](_[_0x303f('0x55')](_0x4ea063['query'],_0x855b29[_0x303f('0x3b')]));_0x2e0e67[_0x303f('0x3c')][_0x303f('0x50')]=_0x97ec7['id'];if(_0x4ea063['query'][_0x303f('0x3e')]){_0x2e0e67[_0x303f('0x3c')]=_[_0x303f('0x3d')](_0x2e0e67[_0x303f('0x3c')],{'$or':_[_0x303f('0x2e')](_0x2e0e67['attributes'],function(_0x4434cc){var _0x1a80bd={};_0x1a80bd[_0x4434cc]={'$like':'%'+_0x4ea063[_0x303f('0x34')]['filter']+'%'};return _0x1a80bd;})});}if(_0x4ea063[_0x303f('0x34')][_0x303f('0x8b')]){var _0x2d50fb=_0x4ea063[_0x303f('0x34')]['$gte']['split'](',');var _0x3ad412={};_0x3ad412[_0x2d50fb[0x0]]={'$gte':moment(_0x2d50fb[0x1])['format'](_0x303f('0x8c'))};_0x2e0e67[_0x303f('0x3c')]=_[_0x303f('0x3d')](_0x2e0e67['where'],_0x3ad412);}_0x2e0e67=_[_0x303f('0x3d')]({},_0x2e0e67,_0x4ea063[_0x303f('0x3f')]);return db['MailMessage'][_0x303f('0x21')]({'where':_0x2e0e67['where']})[_0x303f('0x10')](function(_0x3fce4f){_0x31f2b9['count']=_0x3fce4f;if(_0x4ea063['query'][_0x303f('0x41')]){_0x2e0e67[_0x303f('0x56')]=[{'all':!![]}];}return db[_0x303f('0x8a')][_0x303f('0x42')](_0x2e0e67);})[_0x303f('0x10')](function(_0x1e3c7c){if(_0x4ea063[_0x303f('0x34')][_0x303f('0x8d')]===_0x303f('0x8e')){for(var _0x4c5b1d=0x0;_0x4c5b1d<_0x1e3c7c[_0x303f('0x48')];_0x4c5b1d++){_0x1e3c7c[_0x4c5b1d][_0x303f('0x4b')]=juice(_0x1e3c7c[_0x4c5b1d]['body']);}}_0x31f2b9['rows']=_0x1e3c7c;return _0x31f2b9;});}})[_0x303f('0x10')](respondWithFilteredResult(_0x2e7520,_0x2e0e67))[_0x303f('0x19')](handleError(_0x2e7520,null));};exports[_0x303f('0x28')]=function(_0x38c7c4,_0x31bd0d){var _0x4564a3,_0x1b7434={},_0x168df5;if(_0x38c7c4['body']['to']){_0x168df5=_0x38c7c4[_0x303f('0x4b')]['to']['split'](',')[0x0];}return db[_0x303f('0x40')][_0x303f('0x49')]({'where':{'id':_0x38c7c4['params']['id']},'include':[{'model':db['CmList'],'as':_0x303f('0x8f'),'include':[{'model':db[_0x303f('0x90')],'as':_0x303f('0x91'),'where':{'email':_0x168df5},'limit':0x1,'order':[['updatedAt','DESC']]}]},{'model':db['MailServerOut'],'as':'Smtp','raw':!![]}]})[_0x303f('0x10')](handleEntityNotFound(_0x31bd0d,null))[_0x303f('0x10')](function(_0x28cf11){if(_0x28cf11){_0x4564a3=_0x28cf11;if(_0x28cf11[_0x303f('0x2c')]){if(_[_0x303f('0x92')](_0x38c7c4['body'][_0x303f('0x93')])){_0x38c7c4[_0x303f('0x4b')][_0x303f('0x93')]=util[_0x303f('0x94')]('%s\x20<%s>',_0x28cf11[_0x303f('0x27')],_0x28cf11[_0x303f('0x5f')]||_0x28cf11['Smtp']['user']);}if(_0x38c7c4[_0x303f('0x4b')]['attachments']&&_0x38c7c4[_0x303f('0x4b')][_0x303f('0x95')][_0x303f('0x48')]){for(var _0x381d02=0x0;_0x381d02<_0x38c7c4[_0x303f('0x4b')]['attachments']['length'];_0x381d02+=0x1){_0x38c7c4[_0x303f('0x4b')][_0x303f('0x95')][_0x381d02]={'filename':_0x38c7c4[_0x303f('0x4b')][_0x303f('0x95')][_0x381d02][_0x303f('0x27')],'path':path[_0x303f('0x96')](config[_0x303f('0x97')],'server/files/attachments',_0x38c7c4[_0x303f('0x4b')][_0x303f('0x95')][_0x381d02][_0x303f('0x98')])};}}var _0x4ff27d={'tls':{'rejectUnauthorized':![]}};if(_[_0x303f('0x92')](_0x28cf11[_0x303f('0x2c')][_0x303f('0x99')])){if(_0x28cf11[_0x303f('0x2c')][_0x303f('0x67')]){_0x4ff27d['auth']={'user':_0x28cf11[_0x303f('0x2c')][_0x303f('0x62')],'pass':_0x28cf11[_0x303f('0x2c')][_0x303f('0x63')]};}_0x4ff27d['host']=_0x28cf11['Smtp'][_0x303f('0x65')];_0x4ff27d['port']=_0x28cf11[_0x303f('0x2c')][_0x303f('0x66')];_0x4ff27d[_0x303f('0x9a')]=_0x28cf11[_0x303f('0x2c')][_0x303f('0x9a')];}else{_0x4ff27d[_0x303f('0x99')]=_0x28cf11['Smtp'][_0x303f('0x99')];_0x4ff27d[_0x303f('0x9b')]={'user':_0x28cf11[_0x303f('0x2c')][_0x303f('0x62')],'pass':_0x28cf11[_0x303f('0x2c')]['pass']};}return respondWithRpcPromise(_0x303f('0x9c'),_0x303f('0x9d'),{'account':_0x4ff27d,'message':_0x38c7c4[_0x303f('0x4b')]});}else{throw new Error(_0x303f('0x9e'));}}})[_0x303f('0x10')](function(_0x4f4a6c){if(_0x4f4a6c){_0x1b7434=_0x4f4a6c;if(_0x4564a3[_0x303f('0x8f')]){if(_0x4564a3[_0x303f('0x8f')][_0x303f('0x91')][_0x303f('0x48')]){return _0x4564a3[_0x303f('0x8f')][_0x303f('0x91')][0x0];}else{return db['CmContact']['create'](_['defaults'](_0x38c7c4[_0x303f('0x4b')],{'firstName':_0x38c7c4[_0x303f('0x4b')]['to'],'email':_0x38c7c4[_0x303f('0x4b')]['to'],'phone':_0x38c7c4['body']['to'],'ListId':_0x4564a3[_0x303f('0x9f')]}));}}else{throw new Error(_0x303f('0x9e'));}}})['then'](function(_0x28467a){if(_0x28467a){var _0x3a4546={'UserId':_0x38c7c4['user']['id'],'ContactId':_0x28467a['id'],'MailAccountId':_0x4564a3['id'],'inReplyTo':_0x1b7434[_0x303f('0xa0')],'to':_0x38c7c4['body'][_0x303f('0x93')],'cc':_0x38c7c4[_0x303f('0x4b')]['cc'],'subject':_0x38c7c4[_0x303f('0x4b')]['subject'],'attach':_0x38c7c4['body']['attach'],'firstMsgDirection':_0x303f('0xa1'),'lastMsgAt':moment()['format']('YYYY-MM-DD\x20HH:mm:ss'),'lastMsgDirection':_0x303f('0xa1'),'Messages':[_['merge'](_0x38c7c4[_0x303f('0x4b')],{'messageId':_0x1b7434[_0x303f('0xa0')],'sentAt':moment()[_0x303f('0x94')](_0x303f('0x8c')),'read':!![],'MailAccountId':_0x4564a3['id'],'UserId':_0x38c7c4[_0x303f('0x62')]['id'],'ContactId':_0x28467a['id']})]};if(_0x38c7c4['body'][_0x303f('0xa2')]){_0x3a4546=_[_0x303f('0x3d')](_0x3a4546,_0x38c7c4[_0x303f('0x4b')]['Interaction']);}return db[_0x303f('0x7e')]['create'](_0x3a4546,{'include':[{'model':db[_0x303f('0x8a')],'as':'Messages'}]});}})[_0x303f('0x10')](respondWithResult(_0x31bd0d,null))['catch'](handleError(_0x31bd0d,null));};exports[_0x303f('0xa3')]=function(_0xf581e6,_0x342197){return db[_0x303f('0x40')][_0x303f('0x49')]({'where':{'id':_0xf581e6[_0x303f('0x45')]['id']},'include':[{'model':db[_0x303f('0x2b')],'as':_0x303f('0x2c'),'raw':!![],'include':[{'model':db[_0x303f('0xa4')],'as':'CloudProvider','raw':!![]}]}]})[_0x303f('0x10')](handleEntityNotFound(_0x342197,null))['then'](function(_0x36eda4){if(!_0x36eda4[_0x303f('0x2c')])return;var _0x3f458f={'id':_0x36eda4['id'],'tls':{'rejectUnauthorized':![]}};if(_0x36eda4[_0x303f('0x61')]!==_0x303f('0x5e')){_0x3f458f[_0x303f('0x99')]=_0x36eda4[_0x303f('0x61')];}else{_0x3f458f[_0x303f('0x65')]=_0x36eda4[_0x303f('0x2c')][_0x303f('0x65')];_0x3f458f['port']=_0x36eda4[_0x303f('0x2c')][_0x303f('0x66')];_0x3f458f[_0x303f('0x9a')]=_0x36eda4['Smtp'][_0x303f('0x9a')];}if(_0x36eda4[_0x303f('0x2c')]['authentication']){if(_0x36eda4[_0x303f('0x2c')][_0x303f('0x4d')]){_0x3f458f['auth']={'type':_0x303f('0xa5'),'user':_0x36eda4[_0x303f('0x2c')][_0x303f('0x62')],'accessToken':_0x36eda4['Smtp'][_0x303f('0xa4')][_0x303f('0xa6')]};}else{_0x3f458f[_0x303f('0x9b')]={'user':_0x36eda4[_0x303f('0x2c')][_0x303f('0x62')],'pass':_0x36eda4[_0x303f('0x2c')][_0x303f('0x63')]};}}return respondWithRpcPromise('VerifySmtp','verifySmtp',{'account':_0x3f458f});})['then'](respondWithResult(_0x342197,null))[_0x303f('0x19')](handleError(_0x342197,null));};exports[_0x303f('0x23')]=function(_0xe7cf7f,_0x18dc54){return db['MailAccount'][_0x303f('0x49')]({'where':{'id':_0xe7cf7f[_0x303f('0x45')]['id']}})[_0x303f('0x10')](handleEntityNotFound(_0x18dc54,null))['then'](function(_0x11698e){if(_0x11698e&&_0x11698e[_0x303f('0x99')]){throw new db[(_0x303f('0xa7'))][(_0x303f('0xa8'))](_0x303f('0xa9'));}return _0x11698e;})[_0x303f('0x10')](removeEntity(_0x18dc54,null))['catch'](handleError(_0x18dc54,null));};exports[_0x303f('0xaa')]=function(_0x50148a,_0x256a97){return db[_0x303f('0x40')][_0x303f('0x49')]({'where':{'id':_0x50148a[_0x303f('0x45')]['id']}})[_0x303f('0x10')](handleEntityNotFound(_0x256a97,null))[_0x303f('0x10')](function(_0x5794f4){if(_0x5794f4){return _0x5794f4[_0x303f('0xaa')](_0x50148a[_0x303f('0x4b')][_0x303f('0x57')],_[_0x303f('0x74')](_0x50148a['body'],['ids','id'])||{})[_0x303f('0xab')](function(_0xb30439){for(var _0x4278b6=0x0;_0x4278b6<_0x50148a['body'][_0x303f('0x57')][_0x303f('0x48')];_0x4278b6+=0x1){socket[_0x303f('0xac')](_0x303f('0xad'),{'UserId':Number(_0x50148a[_0x303f('0x4b')][_0x303f('0x57')][_0x4278b6]),'MailAccountId':Number(_0x50148a[_0x303f('0x45')]['id'])});}return _0xb30439;});}})[_0x303f('0x10')](respondWithResult(_0x256a97,null))[_0x303f('0x19')](handleError(_0x256a97,null));};exports['removeAgents']=function(_0x2d16eb,_0x25b53e){return db[_0x303f('0x40')][_0x303f('0x49')]({'where':{'id':_0x2d16eb[_0x303f('0x45')]['id']}})[_0x303f('0x10')](handleEntityNotFound(_0x25b53e,null))[_0x303f('0x10')](function(_0x4df851){if(_0x4df851){return _0x4df851[_0x303f('0xae')](_0x2d16eb[_0x303f('0x34')][_0x303f('0x57')])[_0x303f('0x10')](function(){if(_[_0x303f('0xaf')](_0x2d16eb['query']['ids'])){for(var _0x16be69=0x0;_0x16be69<_0x2d16eb[_0x303f('0x34')][_0x303f('0x57')][_0x303f('0x48')];_0x16be69+=0x1){socket['emit'](_0x303f('0xb0'),{'UserId':Number(_0x2d16eb['query'][_0x303f('0x57')][_0x16be69]),'MailAccountId':Number(_0x2d16eb['params']['id'])});}}else{socket['emit'](_0x303f('0xb0'),{'UserId':Number(_0x2d16eb['query'][_0x303f('0x57')]),'MailAccountId':Number(_0x2d16eb[_0x303f('0x45')]['id'])});}});}})[_0x303f('0x10')](respondWithStatusCode(_0x25b53e,null))['catch'](handleError(_0x25b53e,null));};exports[_0x303f('0xb1')]=function(_0xca0b63,_0x4259d0){var _0x2c551a={};var _0x3fd949={};var _0x3ffb0e;var _0x5a9945;return db['MailAccount']['findOne']({'where':{'id':_0xca0b63[_0x303f('0x45')]['id']}})['then'](handleEntityNotFound(_0x4259d0,null))[_0x303f('0x10')](function(_0x57a310){if(_0x57a310){_0x3ffb0e=_0x57a310;_0x3fd949[_0x303f('0x38')]=_[_0x303f('0x33')](db[_0x303f('0x76')][_0x303f('0x2f')]);_0x3fd949[_0x303f('0x34')]=_[_0x303f('0x33')](_0xca0b63[_0x303f('0x34')]);_0x3fd949['filters']=_[_0x303f('0x35')](_0x3fd949['model'],_0x3fd949[_0x303f('0x34')]);_0x2c551a[_0x303f('0x36')]=_['intersection'](_0x3fd949['model'],qs['fields'](_0xca0b63[_0x303f('0x34')][_0x303f('0x37')]));_0x2c551a[_0x303f('0x36')]=_0x2c551a['attributes'][_0x303f('0x48')]?_0x2c551a[_0x303f('0x36')]:_0x3fd949[_0x303f('0x38')];_0x2c551a[_0x303f('0x5c')]=qs[_0x303f('0x3a')](_0xca0b63[_0x303f('0x34')][_0x303f('0x3a')]);_0x2c551a[_0x303f('0x3c')]=qs[_0x303f('0x3b')](_['pick'](_0xca0b63['query'],_0x3fd949['filters']));if(_0xca0b63[_0x303f('0x34')]['filter']){_0x2c551a['where']=_[_0x303f('0x3d')](_0x2c551a[_0x303f('0x3c')],{'$or':_[_0x303f('0x2e')](_0x2c551a[_0x303f('0x36')],function(_0x1d5a09){var _0x418080={};_0x418080[_0x1d5a09]={'$like':'%'+_0xca0b63['query']['filter']+'%'};return _0x418080;})});}_0x2c551a=_[_0x303f('0x3d')]({},_0x2c551a,_0xca0b63['options']);return _0x3ffb0e[_0x303f('0xb1')](_0x2c551a);}})[_0x303f('0x10')](function(_0x459016){if(_0x459016){_0x5a9945=_0x459016[_0x303f('0x48')];if(!_0xca0b63[_0x303f('0x34')][_0x303f('0x39')](_0x303f('0x54'))){_0x2c551a[_0x303f('0x20')]=qs[_0x303f('0x20')](_0xca0b63[_0x303f('0x34')][_0x303f('0x20')]);_0x2c551a['offset']=qs[_0x303f('0x1e')](_0xca0b63[_0x303f('0x34')]['offset']);}return _0x3ffb0e[_0x303f('0xb1')](_0x2c551a);}})[_0x303f('0x10')](function(_0x37bfef){if(_0x37bfef){return _0x37bfef?{'count':_0x5a9945,'rows':_0x37bfef}:null;}})[_0x303f('0x10')](respondWithResult(_0x4259d0,null))['catch'](handleError(_0x4259d0,null));};
\ No newline at end of file