Built motion from commit 953226e6.|2.6.32
[motion2.git] / server / api / mailAccount / mailAccount.controller.js
index 3df24d5..1f3c13f 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xd6c8=['userMailAccount:remove','getAgents','moment','util','lodash','juice','../../components/parsers/qs','../../config/logger','api','../../config/environment','../../mysqldb','redis','defaults','localhost','socket.io-emitter','./mailAccount.socket','register','client','http','request','then','MailAccount,\x20%s,\x20%s','request\x20sent','debug','error','message','info','result','catch','sendStatus','status','offset','limit','undefined','count','set','Content-Range','update','get','MailAccounts','UserProfileResource','end','stack','name','send','gmail','imap.gmail.com','yahoo','imap.mail.yahoo.com','hotmail','imap-mail.outlook.com','Unknown\x20email\x20service\x20provider','smtp.gmail.com','smtp.mail.yahoo.com','smtp-mail.outlook.com','user','username','password','modernAuthentication','CloudProviderId','pass','host','port','secure','service','authentication','Imap','Smtp','index','MailServerOut','Pause','mandatoryDispositionPause','map','MailAccount','type','key','model','query','filters','intersection','attributes','fields','nolimit','sort','where','filter','VIRTUAL','merge','options','includeAll','findAll','rows','show','rawAttributes','keys','include','find','body','provider','params','Mail\x20Account\x20not\x20found','MailServerIn','describe','addDisposition','MailAccountId','create','getDispositions','findOne','Disposition','length','hasOwnProperty','order','removeDispositions','addAnswer','CannedAnswer','getAnswers','pick','removeAnswers','custom','email','ListId','isNil','active','description','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','getImap','removeImap','setImap','getSmtp','addSmtp','removeSmtp','setSmtp','addInteraction','MailInteraction','ids','omit','getInteractions','CmContact','User','Owner','fullname','internal','Tag','Tags','color','tag','addApplications','sequelize','transaction','Transaction','ISOLATION_LEVELS','READ_COMMITTED','MailApplication','bulkCreate','findAndCountAll','finally','json','getApplications','getMessages','MailMessage','$gte','split','format','YYYY-MM-DD\x20HH:mm:ss','inlineCss','CmList','DESC','CloudProvider','Smtp\x20configuration\x20not\x20found','from','%s\x20<%s>','attachments','root','basename','getSmtpOptions','SendMail','List','List\x20not\x20found','Contacts','messageId','attach','out','Interaction','Messages','verifySmtp','VerifySmtp','destroy','ValidationError','You\x20can\x27t\x20remove\x20the\x20mail\x20service\x20account','addAgents','spread','emit','userMailAccount:save','removeAgents','isArray'];(function(_0x14b24f,_0x23814c){var _0x5530fc=function(_0x1baa50){while(--_0x1baa50){_0x14b24f['push'](_0x14b24f['shift']());}};_0x5530fc(++_0x23814c);}(_0xd6c8,0x192));var _0x8d6c=function(_0x4d934b,_0x52f8e9){_0x4d934b=_0x4d934b-0x0;var _0xc0338b=_0xd6c8[_0x4d934b];return _0xc0338b;};'use strict';var moment=require(_0x8d6c('0x0'));var BPromise=require('bluebird');var util=require(_0x8d6c('0x1'));var path=require('path');var _=require(_0x8d6c('0x2'));var juice=require(_0x8d6c('0x3'));var Redis=require('ioredis');var qs=require(_0x8d6c('0x4'));var logger=require(_0x8d6c('0x5'))(_0x8d6c('0x6'));var config=require(_0x8d6c('0x7'));var db=require(_0x8d6c('0x8'))['db'];config[_0x8d6c('0x9')]=_[_0x8d6c('0xa')](config[_0x8d6c('0x9')],{'host':_0x8d6c('0xb'),'port':0x18eb});var socket=require(_0x8d6c('0xc'))(new Redis(config[_0x8d6c('0x9')]));require(_0x8d6c('0xd'))[_0x8d6c('0xe')](socket);var jayson=require('jayson/promise');var client=jayson[_0x8d6c('0xf')][_0x8d6c('0x10')]({'port':0x232b});function respondWithRpcPromise(_0x47a0a0,_0x2d3aae,_0x44c04a,_0x11ae81){return new BPromise(function(_0x4fdc9e,_0x340eba){var _0x588a90=_0x11ae81||client;return _0x588a90[_0x8d6c('0x11')](_0x47a0a0,_0x44c04a)[_0x8d6c('0x12')](function(_0x841fe2){logger['info'](_0x8d6c('0x13'),_0x2d3aae,_0x8d6c('0x14'));logger[_0x8d6c('0x15')]('MailAccount,\x20%s,\x20%s,\x20%s',_0x2d3aae,_0x8d6c('0x14'),JSON['stringify'](_0x841fe2));if(_0x841fe2[_0x8d6c('0x16')]){if(_0x841fe2[_0x8d6c('0x16')]['code']===0x1f4){logger['error'](_0x8d6c('0x13'),_0x2d3aae,_0x841fe2['error']['message']);return _0x340eba(_0x841fe2[_0x8d6c('0x16')][_0x8d6c('0x17')]);}logger[_0x8d6c('0x16')](_0x8d6c('0x13'),_0x2d3aae,_0x841fe2[_0x8d6c('0x16')]['message']);return _0x4fdc9e(_0x841fe2[_0x8d6c('0x16')][_0x8d6c('0x17')]);}else{logger[_0x8d6c('0x18')](_0x8d6c('0x13'),_0x2d3aae,_0x8d6c('0x14'));_0x4fdc9e(_0x841fe2[_0x8d6c('0x19')][_0x8d6c('0x17')]);}})[_0x8d6c('0x1a')](function(_0x430c94){logger[_0x8d6c('0x16')](_0x8d6c('0x13'),_0x2d3aae,_0x430c94);_0x340eba(_0x430c94);});});}function respondWithStatusCode(_0x49003b,_0x11c810){_0x11c810=_0x11c810||0xcc;return function(_0x511239){if(_0x511239){return _0x49003b[_0x8d6c('0x1b')](_0x11c810);}return _0x49003b[_0x8d6c('0x1c')](_0x11c810)['end']();};}function respondWithResult(_0x29c238,_0x46b5fe){_0x46b5fe=_0x46b5fe||0xc8;return function(_0x2f437d){if(_0x2f437d){return _0x29c238['status'](_0x46b5fe)['json'](_0x2f437d);}};}function respondWithFilteredResult(_0xc3038f,_0x5199eb){return function(_0x10e948){if(_0x10e948){var _0xf33860=typeof _0x5199eb[_0x8d6c('0x1d')]==='undefined'&&typeof _0x5199eb[_0x8d6c('0x1e')]===_0x8d6c('0x1f');var _0x3055de=_0x10e948[_0x8d6c('0x20')];var _0x287231=_0xf33860?0x0:_0x5199eb[_0x8d6c('0x1d')];var _0x5bfa4e=_0xf33860?_0x10e948[_0x8d6c('0x20')]:_0x5199eb[_0x8d6c('0x1d')]+_0x5199eb[_0x8d6c('0x1e')];var _0xd99c09;if(_0x5bfa4e>=_0x3055de){_0x5bfa4e=_0x3055de;_0xd99c09=0xc8;}else{_0xd99c09=0xce;}_0xc3038f[_0x8d6c('0x1c')](_0xd99c09);return _0xc3038f[_0x8d6c('0x21')](_0x8d6c('0x22'),_0x287231+'-'+_0x5bfa4e+'/'+_0x3055de)['json'](_0x10e948);}return null;};}function saveUpdates(_0x28c1c6){return function(_0x175098){if(_0x175098){return _0x175098[_0x8d6c('0x23')](_0x28c1c6)[_0x8d6c('0x12')](function(_0x5b5b90){return _0x5b5b90;});}return null;};}function removeEntity(_0x2a815b){return function(_0x2a243d){if(_0x2a243d){return _0x2a243d['destroy']()['then'](function(){var _0x33331f=_0x2a243d[_0x8d6c('0x24')]({'plain':!![]});var _0x58556a=_0x8d6c('0x25');return db[_0x8d6c('0x26')]['destroy']({'where':{'type':_0x58556a,'resourceId':_0x33331f['id']}})[_0x8d6c('0x12')](function(){return _0x2a243d;});})[_0x8d6c('0x12')](function(){_0x2a815b[_0x8d6c('0x1c')](0xcc)[_0x8d6c('0x27')]();});}};}function handleEntityNotFound(_0x3b2912){return function(_0x3f762b){if(!_0x3f762b){_0x3b2912[_0x8d6c('0x1b')](0x194);}return _0x3f762b;};}function handleError(_0x462635,_0x34177f){_0x34177f=_0x34177f||0x1f4;return function(_0x18eeb7){logger[_0x8d6c('0x16')](_0x18eeb7[_0x8d6c('0x28')]);if(_0x18eeb7[_0x8d6c('0x29')]){delete _0x18eeb7[_0x8d6c('0x29')];}_0x462635['status'](_0x34177f)[_0x8d6c('0x2a')](_0x18eeb7);};}function getImapHost(_0xf36378){switch(_0xf36378){case _0x8d6c('0x2b'):return _0x8d6c('0x2c');case _0x8d6c('0x2d'):return _0x8d6c('0x2e');case _0x8d6c('0x2f'):return _0x8d6c('0x30');case'outlook365':return'outlook.office365.com';}throw new Error(_0x8d6c('0x31'),_0xf36378);}function getSmtpHost(_0x5c3688){switch(_0x5c3688){case'gmail':return _0x8d6c('0x32');case'yahoo':return _0x8d6c('0x33');case _0x8d6c('0x2f'):return _0x8d6c('0x34');case'outlook365':return'smtp.office365.com';}throw new Error(_0x8d6c('0x31'),_0x5c3688);}function getAuthenticationOptions(_0x20739a,_0x20f112){var _0x2b9997={};var _0x265ca5={};if(_0x20739a){_0x2b9997[_0x8d6c('0x35')]=_0x265ca5[_0x8d6c('0x35')]=_0x20f112[_0x8d6c('0x36')];_0x2b9997[_0x8d6c('0x37')]=_0x265ca5['pass']=_0x20f112['password'];if(_0x20f112[_0x8d6c('0x38')]){_0x2b9997['modernAuthentication']=_0x265ca5['modernAuthentication']=!![];_0x2b9997[_0x8d6c('0x39')]=_0x265ca5[_0x8d6c('0x39')]=_0x20f112['CloudProviderId'];_0x2b9997[_0x8d6c('0x37')]=_0x265ca5[_0x8d6c('0x3a')]=null;}else{_0x2b9997[_0x8d6c('0x39')]=_0x265ca5[_0x8d6c('0x39')]=null;}_0x2b9997[_0x8d6c('0x3b')]=getImapHost(_0x20739a);_0x2b9997[_0x8d6c('0x3c')]=0x3e1;_0x265ca5[_0x8d6c('0x3b')]=getSmtpHost(_0x20739a);_0x265ca5['port']=0x24b;_0x265ca5[_0x8d6c('0x3d')]=![];_0x2b9997[_0x8d6c('0x3e')]=_0x265ca5[_0x8d6c('0x3e')]=null;}else{if(_0x20f112[_0x8d6c('0x3f')]){_0x2b9997['user']=_0x265ca5[_0x8d6c('0x35')]=_0x20f112[_0x8d6c('0x36')];_0x2b9997[_0x8d6c('0x37')]=_0x265ca5[_0x8d6c('0x3a')]=_0x20f112[_0x8d6c('0x37')];}else{_0x2b9997[_0x8d6c('0x3f')]=_0x265ca5[_0x8d6c('0x3f')]=![];_0x2b9997[_0x8d6c('0x35')]=_0x265ca5[_0x8d6c('0x35')]=null;_0x2b9997['password']=_0x265ca5['pass']=null;}_0x2b9997['host']=_0x20f112[_0x8d6c('0x40')][_0x8d6c('0x3b')];_0x2b9997[_0x8d6c('0x3c')]=_0x20f112[_0x8d6c('0x40')][_0x8d6c('0x3c')];_0x265ca5[_0x8d6c('0x3b')]=_0x20f112[_0x8d6c('0x41')]['host'];_0x265ca5['port']=_0x20f112[_0x8d6c('0x41')][_0x8d6c('0x3c')];}return{'Imap':_0x2b9997,'Smtp':_0x265ca5};}exports[_0x8d6c('0x42')]=function(_0x1abe81,_0x52a568){var _0x51e7a8={'include':[{'model':db['MailServerIn'],'as':'Imap'},{'model':db[_0x8d6c('0x43')],'as':_0x8d6c('0x41')},{'model':db[_0x8d6c('0x44')],'as':_0x8d6c('0x45')}]},_0x59223d={},_0x153115={'count':0x0,'rows':[]};var _0x249386=_[_0x8d6c('0x46')](db[_0x8d6c('0x47')]['rawAttributes'],function(_0x4503e9){return{'name':_0x4503e9['fieldName'],'type':_0x4503e9[_0x8d6c('0x48')][_0x8d6c('0x49')]};});_0x59223d[_0x8d6c('0x4a')]=_[_0x8d6c('0x46')](_0x249386,_0x8d6c('0x29'));_0x59223d[_0x8d6c('0x4b')]=_['keys'](_0x1abe81[_0x8d6c('0x4b')]);_0x59223d[_0x8d6c('0x4c')]=_[_0x8d6c('0x4d')](_0x59223d[_0x8d6c('0x4a')],_0x59223d[_0x8d6c('0x4b')]);_0x51e7a8[_0x8d6c('0x4e')]=_[_0x8d6c('0x4d')](_0x59223d['model'],qs[_0x8d6c('0x4f')](_0x1abe81[_0x8d6c('0x4b')][_0x8d6c('0x4f')]));_0x51e7a8['attributes']=_0x51e7a8['attributes']['length']?_0x51e7a8['attributes']:_0x59223d['model'];if(!_0x1abe81[_0x8d6c('0x4b')]['hasOwnProperty'](_0x8d6c('0x50'))){_0x51e7a8[_0x8d6c('0x1e')]=qs['limit'](_0x1abe81[_0x8d6c('0x4b')][_0x8d6c('0x1e')]);_0x51e7a8[_0x8d6c('0x1d')]=qs[_0x8d6c('0x1d')](_0x1abe81[_0x8d6c('0x4b')][_0x8d6c('0x1d')]);}_0x51e7a8['order']=qs[_0x8d6c('0x51')](_0x1abe81[_0x8d6c('0x4b')][_0x8d6c('0x51')]);_0x51e7a8[_0x8d6c('0x52')]=qs['filters'](_['pick'](_0x1abe81[_0x8d6c('0x4b')],_0x59223d[_0x8d6c('0x4c')]),_0x249386);if(_0x1abe81[_0x8d6c('0x4b')][_0x8d6c('0x53')]){_0x51e7a8[_0x8d6c('0x52')]=_['merge'](_0x51e7a8[_0x8d6c('0x52')],{'$or':_['map'](_0x249386,function(_0x419bce){if(_0x419bce[_0x8d6c('0x48')]!==_0x8d6c('0x54')){var _0x2ba688={};_0x2ba688[_0x419bce[_0x8d6c('0x29')]]={'$like':'%'+_0x1abe81[_0x8d6c('0x4b')][_0x8d6c('0x53')]+'%'};return _0x2ba688;}})});}_0x51e7a8=_[_0x8d6c('0x55')]({},_0x51e7a8,_0x1abe81[_0x8d6c('0x56')]);var _0x1df4fb={'where':_0x51e7a8[_0x8d6c('0x52')]};return db['MailAccount'][_0x8d6c('0x20')](_0x1df4fb)[_0x8d6c('0x12')](function(_0x2f8aab){_0x153115['count']=_0x2f8aab;if(_0x1abe81['query'][_0x8d6c('0x57')]){_0x51e7a8['include']=[{'all':!![]}];}return db['MailAccount'][_0x8d6c('0x58')](_0x51e7a8);})[_0x8d6c('0x12')](function(_0x2ce507){_0x153115[_0x8d6c('0x59')]=_0x2ce507;return _0x153115;})[_0x8d6c('0x12')](respondWithFilteredResult(_0x52a568,_0x51e7a8))[_0x8d6c('0x1a')](handleError(_0x52a568,null));};exports[_0x8d6c('0x5a')]=function(_0x34e59e,_0x43b237){var _0x5862ca={'raw':![],'where':{'id':_0x34e59e['params']['id']},'include':[{'model':db['MailServerIn'],'as':_0x8d6c('0x40')},{'model':db[_0x8d6c('0x43')],'as':_0x8d6c('0x41')},{'model':db[_0x8d6c('0x44')],'as':_0x8d6c('0x45')}]},_0xf02ec5={};_0xf02ec5['model']=_['keys'](db[_0x8d6c('0x47')][_0x8d6c('0x5b')]);_0xf02ec5['query']=_[_0x8d6c('0x5c')](_0x34e59e['query']);_0xf02ec5[_0x8d6c('0x4c')]=_[_0x8d6c('0x4d')](_0xf02ec5[_0x8d6c('0x4a')],_0xf02ec5[_0x8d6c('0x4b')]);_0x5862ca[_0x8d6c('0x4e')]=_['intersection'](_0xf02ec5[_0x8d6c('0x4a')],qs[_0x8d6c('0x4f')](_0x34e59e[_0x8d6c('0x4b')][_0x8d6c('0x4f')]));_0x5862ca[_0x8d6c('0x4e')]=_0x5862ca[_0x8d6c('0x4e')]['length']?_0x5862ca[_0x8d6c('0x4e')]:_0xf02ec5[_0x8d6c('0x4a')];if(_0x34e59e[_0x8d6c('0x4b')][_0x8d6c('0x57')]){_0x5862ca[_0x8d6c('0x5d')]=[{'all':!![]}];}_0x5862ca=_['merge']({},_0x5862ca,_0x34e59e[_0x8d6c('0x56')]);return db['MailAccount'][_0x8d6c('0x5e')](_0x5862ca)[_0x8d6c('0x12')](handleEntityNotFound(_0x43b237,null))[_0x8d6c('0x12')](respondWithResult(_0x43b237,null))[_0x8d6c('0x1a')](handleError(_0x43b237,null));};exports[_0x8d6c('0x23')]=function(_0x351bb1,_0x2122b6){if(_0x351bb1['body']['id']){delete _0x351bb1[_0x8d6c('0x5f')]['id'];}var _0x3a80d3=_0x351bb1[_0x8d6c('0x5f')][_0x8d6c('0x60')]==='custom'?null:_0x351bb1[_0x8d6c('0x5f')][_0x8d6c('0x60')];var _0xfaf6ea=_0x351bb1[_0x8d6c('0x5f')][_0x8d6c('0x40')]||{};var _0x3be46a=_0x351bb1[_0x8d6c('0x5f')]['Smtp']||{};if(_0x3a80d3){_0xfaf6ea[_0x8d6c('0x3b')]=getImapHost(_0x3a80d3);_0xfaf6ea[_0x8d6c('0x3c')]=0x3e1;_0x3be46a[_0x8d6c('0x3b')]=getSmtpHost(_0x3a80d3);_0x3be46a[_0x8d6c('0x3c')]=0x24b;_0x3be46a[_0x8d6c('0x3d')]=![];}if(_0x3be46a[_0x8d6c('0x38')]){_0x3be46a[_0x8d6c('0x3d')]=![];}else{_0x3be46a[_0x8d6c('0x39')]=null;}if(!_0xfaf6ea['modernAuthentication'])_0xfaf6ea[_0x8d6c('0x39')]=null;_0x351bb1[_0x8d6c('0x5f')]['Imap']=_0xfaf6ea;_0x351bb1[_0x8d6c('0x5f')][_0x8d6c('0x41')]=_0x3be46a;return db[_0x8d6c('0x47')][_0x8d6c('0x5e')]({'where':{'id':_0x351bb1[_0x8d6c('0x61')]['id']},'include':[{'model':db['MailServerIn'],'as':_0x8d6c('0x40')},{'model':db[_0x8d6c('0x43')],'as':_0x8d6c('0x41')},{'model':db[_0x8d6c('0x44')],'as':_0x8d6c('0x45')}]})[_0x8d6c('0x12')](handleEntityNotFound(_0x2122b6,null))[_0x8d6c('0x12')](function(_0x244c4e){if(!_0x244c4e)throw new Error(_0x8d6c('0x62'));if(_0x244c4e[_0x8d6c('0x3e')])delete _0x351bb1[_0x8d6c('0x5f')][_0x8d6c('0x40')];return _0x244c4e;})['then'](saveUpdates(_0x351bb1['body'],null))['then'](function(_0x4d8f95){if(!_0x351bb1[_0x8d6c('0x5f')][_0x8d6c('0x40')])return _0x4d8f95;return db[_0x8d6c('0x63')][_0x8d6c('0x23')](_0x351bb1[_0x8d6c('0x5f')][_0x8d6c('0x40')],{'where':{'MailAccountId':_0x4d8f95['id']}})[_0x8d6c('0x12')](function(){return _0x4d8f95;});})['then'](function(_0x2ffb93){if(!_0x351bb1[_0x8d6c('0x5f')][_0x8d6c('0x41')])return _0x2ffb93;return db[_0x8d6c('0x43')][_0x8d6c('0x23')](_0x351bb1[_0x8d6c('0x5f')][_0x8d6c('0x41')],{'where':{'MailAccountId':_0x2ffb93['id']}})[_0x8d6c('0x12')](function(){return _0x2ffb93;});})['then'](respondWithResult(_0x2122b6,null))[_0x8d6c('0x1a')](handleError(_0x2122b6,null));};exports[_0x8d6c('0x64')]=function(_0x307625,_0x187e5d){return db[_0x8d6c('0x47')][_0x8d6c('0x64')]()[_0x8d6c('0x12')](respondWithResult(_0x187e5d,null))[_0x8d6c('0x1a')](handleError(_0x187e5d,null));};exports[_0x8d6c('0x65')]=function(_0x2e024f,_0x192332){if(_0x2e024f[_0x8d6c('0x5f')]['id']){delete _0x2e024f['body']['id'];}return db['MailAccount'][_0x8d6c('0x5e')]({'where':{'id':_0x2e024f[_0x8d6c('0x61')]['id']}})[_0x8d6c('0x12')](handleEntityNotFound(_0x192332,null))['then'](function(_0xd0df05){if(_0xd0df05){_0x2e024f[_0x8d6c('0x5f')][_0x8d6c('0x66')]=_0xd0df05['id'];return db['Disposition'][_0x8d6c('0x67')](_0x2e024f[_0x8d6c('0x5f')]);}})[_0x8d6c('0x12')](respondWithResult(_0x192332,null))['catch'](handleError(_0x192332,null));};exports[_0x8d6c('0x68')]=function(_0x1e0049,_0x517ce8){var _0x82b17e={'raw':![],'where':{}};var _0x1a3a1f={};var _0x447cbc={'count':0x0,'rows':[]};return db[_0x8d6c('0x47')][_0x8d6c('0x69')]({'where':{'id':_0x1e0049[_0x8d6c('0x61')]['id']}})['then'](handleEntityNotFound(_0x517ce8,null))[_0x8d6c('0x12')](function(_0x6ca3db){if(_0x6ca3db){_0x1a3a1f['model']=_[_0x8d6c('0x5c')](db[_0x8d6c('0x6a')][_0x8d6c('0x5b')]);_0x1a3a1f['query']=_[_0x8d6c('0x5c')](_0x1e0049[_0x8d6c('0x4b')]);_0x1a3a1f[_0x8d6c('0x4c')]=_['intersection'](_0x1a3a1f[_0x8d6c('0x4a')],_0x1a3a1f[_0x8d6c('0x4b')]);_0x82b17e[_0x8d6c('0x4e')]=_[_0x8d6c('0x4d')](_0x1a3a1f[_0x8d6c('0x4a')],qs[_0x8d6c('0x4f')](_0x1e0049[_0x8d6c('0x4b')]['fields']));_0x82b17e[_0x8d6c('0x4e')]=_0x82b17e['attributes'][_0x8d6c('0x6b')]?_0x82b17e[_0x8d6c('0x4e')]:_0x1a3a1f[_0x8d6c('0x4a')];if(!_0x1e0049[_0x8d6c('0x4b')][_0x8d6c('0x6c')](_0x8d6c('0x50'))){_0x82b17e[_0x8d6c('0x1e')]=qs[_0x8d6c('0x1e')](_0x1e0049[_0x8d6c('0x4b')][_0x8d6c('0x1e')]);_0x82b17e[_0x8d6c('0x1d')]=qs[_0x8d6c('0x1d')](_0x1e0049[_0x8d6c('0x4b')]['offset']);}_0x82b17e[_0x8d6c('0x6d')]=qs[_0x8d6c('0x51')](_0x1e0049[_0x8d6c('0x4b')]['sort']);_0x82b17e['where']=qs[_0x8d6c('0x4c')](_['pick'](_0x1e0049['query'],_0x1a3a1f[_0x8d6c('0x4c')]));_0x82b17e[_0x8d6c('0x52')][_0x8d6c('0x66')]=_0x6ca3db['id'];if(_0x1e0049['query'][_0x8d6c('0x53')]){_0x82b17e[_0x8d6c('0x52')]=_['merge'](_0x82b17e[_0x8d6c('0x52')],{'$or':_[_0x8d6c('0x46')](_0x82b17e[_0x8d6c('0x4e')],function(_0x500311){var _0x150c0b={};_0x150c0b[_0x500311]={'$like':'%'+_0x1e0049[_0x8d6c('0x4b')][_0x8d6c('0x53')]+'%'};return _0x150c0b;})});}_0x82b17e=_['merge']({},_0x82b17e,_0x1e0049[_0x8d6c('0x56')]);return db[_0x8d6c('0x6a')][_0x8d6c('0x20')]({'where':_0x82b17e[_0x8d6c('0x52')]})[_0x8d6c('0x12')](function(_0x16ea17){_0x447cbc[_0x8d6c('0x20')]=_0x16ea17;if(_0x1e0049[_0x8d6c('0x4b')][_0x8d6c('0x57')]){_0x82b17e['include']=[{'all':!![]}];}return db[_0x8d6c('0x6a')][_0x8d6c('0x58')](_0x82b17e);})[_0x8d6c('0x12')](function(_0x15e4b8){_0x447cbc[_0x8d6c('0x59')]=_0x15e4b8;return _0x447cbc;});}})[_0x8d6c('0x12')](respondWithFilteredResult(_0x517ce8,_0x82b17e))[_0x8d6c('0x1a')](handleError(_0x517ce8,null));};exports[_0x8d6c('0x6e')]=function(_0x3311a6,_0x4f6bcf){return db[_0x8d6c('0x47')]['find']({'where':{'id':_0x3311a6[_0x8d6c('0x61')]['id']}})[_0x8d6c('0x12')](handleEntityNotFound(_0x4f6bcf,null))[_0x8d6c('0x12')](function(_0x55cb5e){if(_0x55cb5e){return _0x55cb5e[_0x8d6c('0x6e')](_0x3311a6[_0x8d6c('0x4b')]['ids']);}})[_0x8d6c('0x12')](respondWithStatusCode(_0x4f6bcf,null))[_0x8d6c('0x1a')](handleError(_0x4f6bcf,null));};exports[_0x8d6c('0x6f')]=function(_0x122ff2,_0x21b972){if(_0x122ff2[_0x8d6c('0x5f')]['id']){delete _0x122ff2[_0x8d6c('0x5f')]['id'];}return db[_0x8d6c('0x47')]['find']({'where':{'id':_0x122ff2[_0x8d6c('0x61')]['id']}})[_0x8d6c('0x12')](handleEntityNotFound(_0x21b972,null))[_0x8d6c('0x12')](function(_0x159419){if(_0x159419){_0x122ff2[_0x8d6c('0x5f')][_0x8d6c('0x66')]=_0x159419['id'];return db[_0x8d6c('0x70')]['create'](_0x122ff2[_0x8d6c('0x5f')]);}})[_0x8d6c('0x12')](respondWithResult(_0x21b972,null))[_0x8d6c('0x1a')](handleError(_0x21b972,null));};exports[_0x8d6c('0x71')]=function(_0x63cf42,_0x5c6a4e){var _0x5b9573={'raw':![],'where':{}};var _0x137a34={};var _0x272c36={'count':0x0,'rows':[]};return db[_0x8d6c('0x47')][_0x8d6c('0x69')]({'where':{'id':_0x63cf42[_0x8d6c('0x61')]['id']}})[_0x8d6c('0x12')](handleEntityNotFound(_0x5c6a4e,null))[_0x8d6c('0x12')](function(_0x107d7a){if(_0x107d7a){_0x137a34[_0x8d6c('0x4a')]=_['keys'](db['CannedAnswer'][_0x8d6c('0x5b')]);_0x137a34[_0x8d6c('0x4b')]=_['keys'](_0x63cf42['query']);_0x137a34[_0x8d6c('0x4c')]=_[_0x8d6c('0x4d')](_0x137a34[_0x8d6c('0x4a')],_0x137a34[_0x8d6c('0x4b')]);_0x5b9573['attributes']=_[_0x8d6c('0x4d')](_0x137a34[_0x8d6c('0x4a')],qs['fields'](_0x63cf42[_0x8d6c('0x4b')]['fields']));_0x5b9573[_0x8d6c('0x4e')]=_0x5b9573[_0x8d6c('0x4e')]['length']?_0x5b9573[_0x8d6c('0x4e')]:_0x137a34[_0x8d6c('0x4a')];if(!_0x63cf42[_0x8d6c('0x4b')]['hasOwnProperty'](_0x8d6c('0x50'))){_0x5b9573['limit']=qs[_0x8d6c('0x1e')](_0x63cf42[_0x8d6c('0x4b')]['limit']);_0x5b9573[_0x8d6c('0x1d')]=qs[_0x8d6c('0x1d')](_0x63cf42['query'][_0x8d6c('0x1d')]);}_0x5b9573[_0x8d6c('0x6d')]=qs['sort'](_0x63cf42['query'][_0x8d6c('0x51')]);_0x5b9573[_0x8d6c('0x52')]=qs[_0x8d6c('0x4c')](_[_0x8d6c('0x72')](_0x63cf42[_0x8d6c('0x4b')],_0x137a34['filters']));_0x5b9573[_0x8d6c('0x52')][_0x8d6c('0x66')]=_0x107d7a['id'];if(_0x63cf42[_0x8d6c('0x4b')]['filter']){_0x5b9573['where']=_[_0x8d6c('0x55')](_0x5b9573['where'],{'$or':_['map'](_0x5b9573[_0x8d6c('0x4e')],function(_0x40e39c){var _0x1c85fb={};_0x1c85fb[_0x40e39c]={'$like':'%'+_0x63cf42[_0x8d6c('0x4b')][_0x8d6c('0x53')]+'%'};return _0x1c85fb;})});}_0x5b9573=_[_0x8d6c('0x55')]({},_0x5b9573,_0x63cf42[_0x8d6c('0x56')]);return db[_0x8d6c('0x70')][_0x8d6c('0x20')]({'where':_0x5b9573[_0x8d6c('0x52')]})[_0x8d6c('0x12')](function(_0x2ab35d){_0x272c36[_0x8d6c('0x20')]=_0x2ab35d;if(_0x63cf42[_0x8d6c('0x4b')][_0x8d6c('0x57')]){_0x5b9573[_0x8d6c('0x5d')]=[{'all':!![]}];}return db[_0x8d6c('0x70')][_0x8d6c('0x58')](_0x5b9573);})[_0x8d6c('0x12')](function(_0x4697ca){_0x272c36[_0x8d6c('0x59')]=_0x4697ca;return _0x272c36;});}})[_0x8d6c('0x12')](respondWithFilteredResult(_0x5c6a4e,_0x5b9573))[_0x8d6c('0x1a')](handleError(_0x5c6a4e,null));};exports[_0x8d6c('0x73')]=function(_0xa3f1a8,_0x57bdef){return db['MailAccount'][_0x8d6c('0x5e')]({'where':{'id':_0xa3f1a8[_0x8d6c('0x61')]['id']}})[_0x8d6c('0x12')](handleEntityNotFound(_0x57bdef,null))[_0x8d6c('0x12')](function(_0x56ccd1){if(_0x56ccd1){return _0x56ccd1[_0x8d6c('0x73')](_0xa3f1a8[_0x8d6c('0x4b')]['ids']);}})['then'](respondWithStatusCode(_0x57bdef,null))[_0x8d6c('0x1a')](handleError(_0x57bdef,null));};exports['create']=function(_0x4a083b,_0x171a79){var _0x581e97={'name':_0x4a083b['body'][_0x8d6c('0x29')],'key':_0x4a083b['body'][_0x8d6c('0x49')],'provider':_0x4a083b[_0x8d6c('0x5f')][_0x8d6c('0x60')]===_0x8d6c('0x74')?null:_0x4a083b[_0x8d6c('0x5f')][_0x8d6c('0x60')],'email':_0x4a083b['body'][_0x8d6c('0x75')],'ListId':_0x4a083b[_0x8d6c('0x5f')][_0x8d6c('0x76')],'active':!_[_0x8d6c('0x77')](_0x4a083b['body'][_0x8d6c('0x78')])?_0x4a083b[_0x8d6c('0x5f')]['active']:!![],'description':_0x4a083b['body'][_0x8d6c('0x79')]||null};var _0x25a13c=getAuthenticationOptions(_0x581e97[_0x8d6c('0x60')],_0x4a083b[_0x8d6c('0x5f')]);_0x581e97[_0x8d6c('0x40')]=_0x25a13c[_0x8d6c('0x40')];_0x581e97[_0x8d6c('0x41')]=_0x25a13c[_0x8d6c('0x41')];return db[_0x8d6c('0x47')][_0x8d6c('0x67')](_0x581e97,{'include':[{'model':db[_0x8d6c('0x43')],'as':_0x8d6c('0x41')},{'model':db['MailServerIn'],'as':_0x8d6c('0x40')}]})['then'](function(_0x5bd755){var _0x1ffb83=_0x4a083b[_0x8d6c('0x35')]['get']({'plain':!![]});if(!_0x1ffb83)throw new Error(_0x8d6c('0x7a'));if(_0x1ffb83[_0x8d6c('0x7b')]===_0x8d6c('0x35')){var _0x2fbfcf=_0x5bd755[_0x8d6c('0x24')]({'plain':!![]});return db[_0x8d6c('0x7c')][_0x8d6c('0x5e')]({'where':{'name':'MailAccounts','userProfileId':_0x1ffb83[_0x8d6c('0x7d')]},'raw':!![]})['then'](function(_0x3b0c95){if(_0x3b0c95&&_0x3b0c95[_0x8d6c('0x7e')]===0x0){return db[_0x8d6c('0x26')][_0x8d6c('0x67')]({'name':_0x2fbfcf['name'],'resourceId':_0x2fbfcf['id'],'type':_0x3b0c95[_0x8d6c('0x29')],'sectionId':_0x3b0c95['id']},{})[_0x8d6c('0x12')](function(){return _0x5bd755;});}else{return _0x5bd755;}})['catch'](function(_0x6e377){logger[_0x8d6c('0x16')](_0x8d6c('0x7f'),_0x6e377);throw _0x6e377;});}return _0x5bd755;})['then'](respondWithResult(_0x171a79,0xc9))[_0x8d6c('0x1a')](handleError(_0x171a79,null));};exports[_0x8d6c('0x80')]=function(_0x2cd7d8,_0x499c3e){return db[_0x8d6c('0x47')][_0x8d6c('0x69')]({'where':{'id':_0x2cd7d8[_0x8d6c('0x61')]['id']}})[_0x8d6c('0x12')](handleEntityNotFound(_0x499c3e,null))[_0x8d6c('0x12')](function(_0x5174e7){if(_0x5174e7){return _0x5174e7['getImap']();}return null;})['then'](respondWithResult(_0x499c3e,null))['catch'](handleError(_0x499c3e,null));};exports['addImap']=function(_0x17c886,_0x2fbe31){if(_0x17c886[_0x8d6c('0x5f')]['id']){delete _0x17c886[_0x8d6c('0x5f')]['id'];}return db['MailAccount'][_0x8d6c('0x5e')]({'where':{'id':_0x17c886['params']['id']}})[_0x8d6c('0x12')](handleEntityNotFound(_0x2fbe31,null))[_0x8d6c('0x12')](function(_0x1fa9b4){if(_0x1fa9b4){_0x17c886['body'][_0x8d6c('0x66')]=_0x1fa9b4['id'];return db[_0x8d6c('0x63')][_0x8d6c('0x67')](_0x17c886[_0x8d6c('0x5f')]);}})[_0x8d6c('0x12')](respondWithResult(_0x2fbe31,null))[_0x8d6c('0x1a')](handleError(_0x2fbe31,null));};exports[_0x8d6c('0x81')]=function(_0x42337e,_0x19919b){return db[_0x8d6c('0x47')][_0x8d6c('0x69')]({'where':{'id':_0x42337e[_0x8d6c('0x61')]['id']}})[_0x8d6c('0x12')](handleEntityNotFound(_0x19919b,null))[_0x8d6c('0x12')](function(_0x3b8443){if(_0x3b8443){return _0x3b8443[_0x8d6c('0x82')](null);}return null;})[_0x8d6c('0x12')](respondWithStatusCode(_0x19919b,null))['catch'](handleError(_0x19919b,null));};exports[_0x8d6c('0x83')]=function(_0x12c545,_0x27c2d0){return db[_0x8d6c('0x47')][_0x8d6c('0x69')]({'where':{'id':_0x12c545[_0x8d6c('0x61')]['id']}})[_0x8d6c('0x12')](handleEntityNotFound(_0x27c2d0,null))[_0x8d6c('0x12')](function(_0x571e2f){if(_0x571e2f){return _0x571e2f[_0x8d6c('0x83')]();}return null;})[_0x8d6c('0x12')](respondWithResult(_0x27c2d0,null))[_0x8d6c('0x1a')](handleError(_0x27c2d0,null));};exports[_0x8d6c('0x84')]=function(_0x399de3,_0x1b9e20){if(_0x399de3['body']['id']){delete _0x399de3['body']['id'];}return db[_0x8d6c('0x47')][_0x8d6c('0x5e')]({'where':{'id':_0x399de3[_0x8d6c('0x61')]['id']}})[_0x8d6c('0x12')](handleEntityNotFound(_0x1b9e20,null))[_0x8d6c('0x12')](function(_0x164c7c){if(_0x164c7c){_0x399de3[_0x8d6c('0x5f')]['MailAccountId']=_0x164c7c['id'];return db[_0x8d6c('0x43')][_0x8d6c('0x67')](_0x399de3[_0x8d6c('0x5f')]);}})[_0x8d6c('0x12')](respondWithResult(_0x1b9e20,null))[_0x8d6c('0x1a')](handleError(_0x1b9e20,null));};exports[_0x8d6c('0x85')]=function(_0x4fbd09,_0x2114ae){return db[_0x8d6c('0x47')][_0x8d6c('0x69')]({'where':{'id':_0x4fbd09['params']['id']}})['then'](handleEntityNotFound(_0x2114ae,null))[_0x8d6c('0x12')](function(_0x3ba4df){if(_0x3ba4df){return _0x3ba4df[_0x8d6c('0x86')](null);}return null;})[_0x8d6c('0x12')](respondWithStatusCode(_0x2114ae,null))['catch'](handleError(_0x2114ae,null));};exports[_0x8d6c('0x87')]=function(_0xa9b212,_0x3cf156){return db[_0x8d6c('0x88')]['find']({'where':{'id':_0xa9b212[_0x8d6c('0x61')]['id']}})[_0x8d6c('0x12')](handleEntityNotFound(_0x3cf156,null))[_0x8d6c('0x12')](function(_0x45c5b1){if(_0x45c5b1){return _0x45c5b1['addInteraction'](_0xa9b212['body'][_0x8d6c('0x89')],_[_0x8d6c('0x8a')](_0xa9b212[_0x8d6c('0x5f')],[_0x8d6c('0x89'),'id'])||{});}})[_0x8d6c('0x12')](respondWithResult(_0x3cf156,null))[_0x8d6c('0x1a')](handleError(_0x3cf156,null));};exports[_0x8d6c('0x8b')]=function(_0x38681a,_0x2fe06b){var _0x11f2d9={'raw':![],'where':{}};var _0xb04ee2={};var _0x3c2667={'count':0x0,'rows':[]};return db[_0x8d6c('0x47')][_0x8d6c('0x69')]({'where':{'id':_0x38681a['params']['id']}})[_0x8d6c('0x12')](handleEntityNotFound(_0x2fe06b,null))[_0x8d6c('0x12')](function(_0x4ec544){if(_0x4ec544){_0xb04ee2[_0x8d6c('0x4a')]=_[_0x8d6c('0x5c')](db[_0x8d6c('0x88')]['rawAttributes']);_0xb04ee2[_0x8d6c('0x4b')]=_[_0x8d6c('0x5c')](_0x38681a[_0x8d6c('0x4b')]);_0xb04ee2[_0x8d6c('0x4c')]=_[_0x8d6c('0x4d')](_0xb04ee2[_0x8d6c('0x4a')],_0xb04ee2[_0x8d6c('0x4b')]);_0x11f2d9[_0x8d6c('0x4e')]=_[_0x8d6c('0x4d')](_0xb04ee2[_0x8d6c('0x4a')],qs[_0x8d6c('0x4f')](_0x38681a['query'][_0x8d6c('0x4f')]));_0x11f2d9[_0x8d6c('0x4e')]=_0x11f2d9['attributes'][_0x8d6c('0x6b')]?_0x11f2d9[_0x8d6c('0x4e')]:_0xb04ee2[_0x8d6c('0x4a')];if(!_0x38681a[_0x8d6c('0x4b')][_0x8d6c('0x6c')](_0x8d6c('0x50'))){_0x11f2d9[_0x8d6c('0x1e')]=qs[_0x8d6c('0x1e')](_0x38681a['query'][_0x8d6c('0x1e')]);_0x11f2d9[_0x8d6c('0x1d')]=qs['offset'](_0x38681a[_0x8d6c('0x4b')][_0x8d6c('0x1d')]);}_0x11f2d9['order']=qs[_0x8d6c('0x51')](_0x38681a['query'][_0x8d6c('0x51')]);_0x11f2d9['where']=qs[_0x8d6c('0x4c')](_[_0x8d6c('0x72')](_0x38681a[_0x8d6c('0x4b')],_0xb04ee2[_0x8d6c('0x4c')]));_0x11f2d9['where'][_0x8d6c('0x66')]=_0x4ec544['id'];if(_0x38681a[_0x8d6c('0x4b')][_0x8d6c('0x53')]){_0x11f2d9[_0x8d6c('0x52')]=_['merge'](_0x11f2d9[_0x8d6c('0x52')],{'$or':_[_0x8d6c('0x46')](_0x11f2d9['attributes'],function(_0x27a978){var _0x2b1877={};_0x2b1877[_0x27a978]={'$like':'%'+_0x38681a[_0x8d6c('0x4b')]['filter']+'%'};return _0x2b1877;})});}_0x11f2d9=_[_0x8d6c('0x55')]({},_0x11f2d9,_0x38681a[_0x8d6c('0x56')]);return db[_0x8d6c('0x88')][_0x8d6c('0x20')]({'where':_0x11f2d9[_0x8d6c('0x52')]})[_0x8d6c('0x12')](function(_0x492559){_0x3c2667['count']=_0x492559;if(_0x38681a['query'][_0x8d6c('0x57')]){_0x11f2d9[_0x8d6c('0x5d')]=[{'model':db[_0x8d6c('0x8c')],'as':'Contact','required':![]},{'model':db[_0x8d6c('0x8d')],'as':_0x8d6c('0x8e'),'attributes':[_0x8d6c('0x29'),_0x8d6c('0x8f'),_0x8d6c('0x90')],'required':![]},{'model':db[_0x8d6c('0x91')],'as':_0x8d6c('0x92'),'attributes':['id','name',_0x8d6c('0x93')],'where':_0x38681a[_0x8d6c('0x4b')][_0x8d6c('0x94')]?{'id':_0x38681a[_0x8d6c('0x4b')][_0x8d6c('0x94')]}:undefined,'required':_0x38681a[_0x8d6c('0x4b')][_0x8d6c('0x94')]?!![]:![]}];}return db[_0x8d6c('0x88')][_0x8d6c('0x58')](_0x11f2d9);})['then'](function(_0x1bf122){_0x3c2667[_0x8d6c('0x59')]=_0x1bf122;return _0x3c2667;});}})[_0x8d6c('0x12')](respondWithFilteredResult(_0x2fe06b,_0x11f2d9))[_0x8d6c('0x1a')](handleError(_0x2fe06b,null));};exports[_0x8d6c('0x95')]=function addApplications(_0x4cfe75,_0x24c406){var _0x79bb78=_0x4cfe75[_0x8d6c('0x61')]['id'];var _0x42d75a=_0x4cfe75[_0x8d6c('0x5f')];var _0xbbb41f=0xc8;var _0x265475=null;return db[_0x8d6c('0x96')][_0x8d6c('0x97')]({'isolationLevel':db[_0x8d6c('0x96')][_0x8d6c('0x98')][_0x8d6c('0x99')][_0x8d6c('0x9a')]},function(_0x1e0c17){return db['MailAccount'][_0x8d6c('0x69')]({'where':{'id':_0x79bb78},'transaction':_0x1e0c17})[_0x8d6c('0x12')](function(_0x46f52d){if(_0x46f52d){return db['MailApplication']['destroy']({'where':{'MailAccountId':_0x79bb78},'transaction':_0x1e0c17})[_0x8d6c('0x12')](function(){var _0x150379=_['map'](_0x42d75a,function(_0x203721){_0x203721['MailAccountId']=_0x79bb78;return _0x203721;});return db[_0x8d6c('0x9b')][_0x8d6c('0x9c')](_0x150379,{'transaction':_0x1e0c17});});}else{_0xbbb41f=0x194;_0x265475=[];}});})['then'](function(){if(_0xbbb41f!==0x194){return db['MailApplication'][_0x8d6c('0x9d')]({'where':{'MailAccountId':_0x79bb78},'order':'priority'})[_0x8d6c('0x12')](function(_0x3c584e){_0x265475=_0x3c584e;});}})['catch'](function(_0x56d950){_0xbbb41f=0x1f4;logger['error'](_0x56d950['stack']);if(_0x56d950[_0x8d6c('0x29')]){delete _0x56d950[_0x8d6c('0x29')];}_0x265475=_0x56d950;})[_0x8d6c('0x9e')](function(){if(_0x265475===null){_0x24c406[_0x8d6c('0x1b')](_0xbbb41f);}else{if(_0xbbb41f===0x1f4){_0x24c406['status'](_0xbbb41f)['send'](_0x265475);}else{_0x24c406[_0x8d6c('0x1c')](_0xbbb41f)[_0x8d6c('0x9f')](_0x265475);}}});};exports['getApplications']=function(_0x3d7afd,_0x1d330a){var _0x1dfb2a={};var _0x5bad42={};var _0x5d41f9;var _0x9f30ad;return db[_0x8d6c('0x47')][_0x8d6c('0x69')]({'where':{'id':_0x3d7afd['params']['id']}})[_0x8d6c('0x12')](handleEntityNotFound(_0x1d330a,null))[_0x8d6c('0x12')](function(_0xadc7e7){if(_0xadc7e7){_0x5d41f9=_0xadc7e7;_0x5bad42[_0x8d6c('0x4a')]=_[_0x8d6c('0x5c')](db[_0x8d6c('0x9b')][_0x8d6c('0x5b')]);_0x5bad42[_0x8d6c('0x4b')]=_[_0x8d6c('0x5c')](_0x3d7afd[_0x8d6c('0x4b')]);_0x5bad42[_0x8d6c('0x4c')]=_[_0x8d6c('0x4d')](_0x5bad42['model'],_0x5bad42[_0x8d6c('0x4b')]);_0x1dfb2a[_0x8d6c('0x4e')]=_['intersection'](_0x5bad42[_0x8d6c('0x4a')],qs[_0x8d6c('0x4f')](_0x3d7afd[_0x8d6c('0x4b')][_0x8d6c('0x4f')]));_0x1dfb2a['attributes']=_0x1dfb2a[_0x8d6c('0x4e')]['length']?_0x1dfb2a[_0x8d6c('0x4e')]:_0x5bad42[_0x8d6c('0x4a')];_0x1dfb2a[_0x8d6c('0x6d')]=qs[_0x8d6c('0x51')](_0x3d7afd[_0x8d6c('0x4b')][_0x8d6c('0x51')]);_0x1dfb2a[_0x8d6c('0x52')]=qs[_0x8d6c('0x4c')](_['pick'](_0x3d7afd['query'],_0x5bad42['filters']));if(_0x3d7afd[_0x8d6c('0x4b')][_0x8d6c('0x53')]){_0x1dfb2a[_0x8d6c('0x52')]=_[_0x8d6c('0x55')](_0x1dfb2a[_0x8d6c('0x52')],{'$or':_[_0x8d6c('0x46')](_0x1dfb2a[_0x8d6c('0x4e')],function(_0x492b72){var _0x2ea00b={};_0x2ea00b[_0x492b72]={'$like':'%'+_0x3d7afd[_0x8d6c('0x4b')][_0x8d6c('0x53')]+'%'};return _0x2ea00b;})});}_0x1dfb2a=_['merge']({},_0x1dfb2a,_0x3d7afd[_0x8d6c('0x56')]);return _0x5d41f9[_0x8d6c('0xa0')](_0x1dfb2a);}})[_0x8d6c('0x12')](function(_0x268d28){if(_0x268d28){_0x9f30ad=_0x268d28[_0x8d6c('0x6b')];if(!_0x3d7afd[_0x8d6c('0x4b')][_0x8d6c('0x6c')]('nolimit')){_0x1dfb2a[_0x8d6c('0x1e')]=qs[_0x8d6c('0x1e')](_0x3d7afd[_0x8d6c('0x4b')][_0x8d6c('0x1e')]);_0x1dfb2a[_0x8d6c('0x1d')]=qs['offset'](_0x3d7afd[_0x8d6c('0x4b')][_0x8d6c('0x1d')]);}return _0x5d41f9['getApplications'](_0x1dfb2a);}})[_0x8d6c('0x12')](function(_0x48c504){if(_0x48c504){return _0x48c504?{'count':_0x9f30ad,'rows':_0x48c504}:null;}})['then'](respondWithResult(_0x1d330a,null))['catch'](handleError(_0x1d330a,null));};exports[_0x8d6c('0xa1')]=function(_0x5de618,_0x346b93){var _0x3f59a8={'raw':!![],'where':{}};var _0x4397c0={};var _0x2d59fa={'count':0x0,'rows':[]};return db['MailAccount']['findOne']({'where':{'id':_0x5de618['params']['id']}})[_0x8d6c('0x12')](handleEntityNotFound(_0x346b93,null))['then'](function(_0x295b9c){if(_0x295b9c){_0x4397c0[_0x8d6c('0x4a')]=_[_0x8d6c('0x5c')](db[_0x8d6c('0xa2')][_0x8d6c('0x5b')]);_0x4397c0[_0x8d6c('0x4b')]=_[_0x8d6c('0x5c')](_0x5de618[_0x8d6c('0x4b')]);_0x4397c0[_0x8d6c('0x4c')]=_[_0x8d6c('0x4d')](_0x4397c0[_0x8d6c('0x4a')],_0x4397c0[_0x8d6c('0x4b')]);_0x3f59a8['attributes']=_[_0x8d6c('0x4d')](_0x4397c0[_0x8d6c('0x4a')],qs['fields'](_0x5de618[_0x8d6c('0x4b')][_0x8d6c('0x4f')]));_0x3f59a8[_0x8d6c('0x4e')]=_0x3f59a8['attributes'][_0x8d6c('0x6b')]?_0x3f59a8[_0x8d6c('0x4e')]:_0x4397c0[_0x8d6c('0x4a')];if(!_0x5de618[_0x8d6c('0x4b')]['hasOwnProperty'](_0x8d6c('0x50'))){_0x3f59a8[_0x8d6c('0x1e')]=qs[_0x8d6c('0x1e')](_0x5de618[_0x8d6c('0x4b')]['limit']);_0x3f59a8['offset']=qs[_0x8d6c('0x1d')](_0x5de618[_0x8d6c('0x4b')][_0x8d6c('0x1d')]);}_0x3f59a8[_0x8d6c('0x6d')]=qs[_0x8d6c('0x51')](_0x5de618[_0x8d6c('0x4b')][_0x8d6c('0x51')]);_0x3f59a8[_0x8d6c('0x52')]=qs[_0x8d6c('0x4c')](_[_0x8d6c('0x72')](_0x5de618[_0x8d6c('0x4b')],_0x4397c0[_0x8d6c('0x4c')]));_0x3f59a8['where'][_0x8d6c('0x66')]=_0x295b9c['id'];if(_0x5de618[_0x8d6c('0x4b')][_0x8d6c('0x53')]){_0x3f59a8[_0x8d6c('0x52')]=_[_0x8d6c('0x55')](_0x3f59a8[_0x8d6c('0x52')],{'$or':_[_0x8d6c('0x46')](_0x3f59a8[_0x8d6c('0x4e')],function(_0x511279){var _0x446081={};_0x446081[_0x511279]={'$like':'%'+_0x5de618[_0x8d6c('0x4b')][_0x8d6c('0x53')]+'%'};return _0x446081;})});}if(_0x5de618[_0x8d6c('0x4b')]['$gte']){var _0x18bc0a=_0x5de618[_0x8d6c('0x4b')][_0x8d6c('0xa3')][_0x8d6c('0xa4')](',');var _0x42aa99={};_0x42aa99[_0x18bc0a[0x0]]={'$gte':moment(_0x18bc0a[0x1])[_0x8d6c('0xa5')](_0x8d6c('0xa6'))};_0x3f59a8[_0x8d6c('0x52')]=_[_0x8d6c('0x55')](_0x3f59a8[_0x8d6c('0x52')],_0x42aa99);}_0x3f59a8=_[_0x8d6c('0x55')]({},_0x3f59a8,_0x5de618[_0x8d6c('0x56')]);return db[_0x8d6c('0xa2')][_0x8d6c('0x20')]({'where':_0x3f59a8[_0x8d6c('0x52')]})[_0x8d6c('0x12')](function(_0x4e33f8){_0x2d59fa[_0x8d6c('0x20')]=_0x4e33f8;if(_0x5de618[_0x8d6c('0x4b')]['includeAll']){_0x3f59a8['include']=[{'all':!![]}];}return db[_0x8d6c('0xa2')][_0x8d6c('0x58')](_0x3f59a8);})[_0x8d6c('0x12')](function(_0x25e35b){if(_0x5de618[_0x8d6c('0x4b')][_0x8d6c('0xa7')]==='true'){for(var _0x3b1d5c=0x0;_0x3b1d5c<_0x25e35b[_0x8d6c('0x6b')];_0x3b1d5c++){_0x25e35b[_0x3b1d5c]['body']=juice(_0x25e35b[_0x3b1d5c][_0x8d6c('0x5f')]);}}_0x2d59fa[_0x8d6c('0x59')]=_0x25e35b;return _0x2d59fa;});}})[_0x8d6c('0x12')](respondWithFilteredResult(_0x346b93,_0x3f59a8))[_0x8d6c('0x1a')](handleError(_0x346b93,null));};exports['send']=function(_0x1ad39d,_0x167fba){var _0x29f328,_0x38ba6b={},_0xe8ce7d;if(_0x1ad39d['body']['to']){_0xe8ce7d=_0x1ad39d[_0x8d6c('0x5f')]['to'][_0x8d6c('0xa4')](',')[0x0];}return db['MailAccount']['find']({'where':{'id':_0x1ad39d[_0x8d6c('0x61')]['id']},'include':[{'model':db[_0x8d6c('0xa8')],'as':'List','include':[{'model':db[_0x8d6c('0x8c')],'as':'Contacts','where':{'email':_0xe8ce7d},'limit':0x1,'order':[['updatedAt',_0x8d6c('0xa9')]]}]},{'model':db['MailServerOut'],'as':'Smtp','raw':!![],'include':[{'model':db[_0x8d6c('0xaa')],'as':_0x8d6c('0xaa'),'raw':!![]}]}]})['then'](handleEntityNotFound(_0x167fba,null))['then'](function(_0x1f61e3){if(!_0x1f61e3)return;_0x29f328=_0x1f61e3;if(!_0x1f61e3['Smtp'])throw new Error(_0x8d6c('0xab'));if(_[_0x8d6c('0x77')](_0x1ad39d[_0x8d6c('0x5f')][_0x8d6c('0xac')])){_0x1ad39d[_0x8d6c('0x5f')]['from']=util[_0x8d6c('0xa5')](_0x8d6c('0xad'),_0x1f61e3[_0x8d6c('0x29')],_0x1f61e3[_0x8d6c('0x75')]||_0x1f61e3[_0x8d6c('0x41')]['user']);}if(_0x1ad39d['body'][_0x8d6c('0xae')]&&_0x1ad39d['body'][_0x8d6c('0xae')][_0x8d6c('0x6b')]){for(var _0x1a3683=0x0;_0x1a3683<_0x1ad39d[_0x8d6c('0x5f')][_0x8d6c('0xae')]['length'];_0x1a3683+=0x1){_0x1ad39d[_0x8d6c('0x5f')][_0x8d6c('0xae')][_0x1a3683]={'filename':_0x1ad39d[_0x8d6c('0x5f')][_0x8d6c('0xae')][_0x1a3683][_0x8d6c('0x29')],'path':path['join'](config[_0x8d6c('0xaf')],'server/files/attachments',_0x1ad39d[_0x8d6c('0x5f')][_0x8d6c('0xae')][_0x1a3683][_0x8d6c('0xb0')])};}}var _0x16b84b=_0x1f61e3[_0x8d6c('0xb1')]();return respondWithRpcPromise(_0x8d6c('0xb2'),'sendMail',{'account':_0x16b84b,'message':_0x1ad39d[_0x8d6c('0x5f')]});})[_0x8d6c('0x12')](function(_0x2c3447){if(!_0x2c3447)return;_0x38ba6b=_0x2c3447;if(!_0x29f328[_0x8d6c('0xb3')])throw new Error(_0x8d6c('0xb4'));if(_0x29f328[_0x8d6c('0xb3')]['Contacts']['length'])return _0x29f328[_0x8d6c('0xb3')][_0x8d6c('0xb5')][0x0];return db[_0x8d6c('0x8c')][_0x8d6c('0x67')](_['defaults'](_0x1ad39d['body'],{'firstName':_0x1ad39d[_0x8d6c('0x5f')]['to'],'email':_0x1ad39d[_0x8d6c('0x5f')]['to'],'phone':_0x1ad39d[_0x8d6c('0x5f')]['to'],'ListId':_0x29f328[_0x8d6c('0x76')]}));})['then'](function(_0x840acc){if(!_0x840acc)return;var _0x1cff08={'UserId':_0x1ad39d['user']['id'],'ContactId':_0x840acc['id'],'MailAccountId':_0x29f328['id'],'inReplyTo':_0x38ba6b[_0x8d6c('0xb6')],'to':_0x1ad39d[_0x8d6c('0x5f')][_0x8d6c('0xac')],'cc':_0x1ad39d[_0x8d6c('0x5f')]['cc'],'subject':_0x1ad39d[_0x8d6c('0x5f')]['subject'],'attach':_0x1ad39d['body'][_0x8d6c('0xb7')],'firstMsgDirection':_0x8d6c('0xb8'),'lastMsgAt':moment()['format'](_0x8d6c('0xa6')),'lastMsgDirection':_0x8d6c('0xb8'),'Messages':[_[_0x8d6c('0x55')](_0x1ad39d['body'],{'messageId':_0x38ba6b['messageId'],'sentAt':moment()[_0x8d6c('0xa5')]('YYYY-MM-DD\x20HH:mm:ss'),'read':!![],'MailAccountId':_0x29f328['id'],'UserId':_0x1ad39d[_0x8d6c('0x35')]['id'],'ContactId':_0x840acc['id']})]};if(_0x1ad39d[_0x8d6c('0x5f')][_0x8d6c('0xb9')]){_0x1cff08=_['merge'](_0x1cff08,_0x1ad39d[_0x8d6c('0x5f')][_0x8d6c('0xb9')]);}return db[_0x8d6c('0x88')]['create'](_0x1cff08,{'include':[{'model':db[_0x8d6c('0xa2')],'as':_0x8d6c('0xba')}]});})[_0x8d6c('0x12')](respondWithResult(_0x167fba,null))[_0x8d6c('0x1a')](handleError(_0x167fba,null));};exports[_0x8d6c('0xbb')]=function(_0x333b28,_0x5ae2c4){return db[_0x8d6c('0x47')][_0x8d6c('0x5e')]({'where':{'id':_0x333b28[_0x8d6c('0x61')]['id']},'include':[{'model':db[_0x8d6c('0x43')],'as':'Smtp','raw':!![],'include':[{'model':db['CloudProvider'],'as':_0x8d6c('0xaa'),'raw':!![]}]}]})[_0x8d6c('0x12')](handleEntityNotFound(_0x5ae2c4,null))[_0x8d6c('0x12')](function(_0x40810b){if(!_0x40810b[_0x8d6c('0x41')])return;var _0x5c1323=_0x40810b[_0x8d6c('0xb1')]();return respondWithRpcPromise(_0x8d6c('0xbc'),_0x8d6c('0xbb'),{'account':_0x5c1323});})['then'](respondWithResult(_0x5ae2c4,null))['catch'](handleError(_0x5ae2c4,null));};exports[_0x8d6c('0xbd')]=function(_0x29ed36,_0x3ad506){return db[_0x8d6c('0x47')]['find']({'where':{'id':_0x29ed36[_0x8d6c('0x61')]['id']}})[_0x8d6c('0x12')](handleEntityNotFound(_0x3ad506,null))[_0x8d6c('0x12')](function(_0x142ccc){if(_0x142ccc&&_0x142ccc[_0x8d6c('0x3e')]){throw new db['Sequelize'][(_0x8d6c('0xbe'))](_0x8d6c('0xbf'));}return _0x142ccc;})[_0x8d6c('0x12')](removeEntity(_0x3ad506,null))[_0x8d6c('0x1a')](handleError(_0x3ad506,null));};exports[_0x8d6c('0xc0')]=function(_0x280ce2,_0x2216e1){return db[_0x8d6c('0x47')][_0x8d6c('0x5e')]({'where':{'id':_0x280ce2['params']['id']}})['then'](handleEntityNotFound(_0x2216e1,null))['then'](function(_0x545da2){if(_0x545da2){return _0x545da2['addAgents'](_0x280ce2[_0x8d6c('0x5f')]['ids'],_[_0x8d6c('0x8a')](_0x280ce2[_0x8d6c('0x5f')],[_0x8d6c('0x89'),'id'])||{})[_0x8d6c('0xc1')](function(_0x3e1336){for(var _0x3a61e0=0x0;_0x3a61e0<_0x280ce2['body'][_0x8d6c('0x89')][_0x8d6c('0x6b')];_0x3a61e0+=0x1){socket[_0x8d6c('0xc2')](_0x8d6c('0xc3'),{'UserId':Number(_0x280ce2['body'][_0x8d6c('0x89')][_0x3a61e0]),'MailAccountId':Number(_0x280ce2[_0x8d6c('0x61')]['id'])});}return _0x3e1336;});}})[_0x8d6c('0x12')](respondWithResult(_0x2216e1,null))['catch'](handleError(_0x2216e1,null));};exports[_0x8d6c('0xc4')]=function(_0x25e4f7,_0x31d514){return db[_0x8d6c('0x47')][_0x8d6c('0x5e')]({'where':{'id':_0x25e4f7[_0x8d6c('0x61')]['id']}})[_0x8d6c('0x12')](handleEntityNotFound(_0x31d514,null))[_0x8d6c('0x12')](function(_0xd3cc53){if(_0xd3cc53){return _0xd3cc53[_0x8d6c('0xc4')](_0x25e4f7[_0x8d6c('0x4b')][_0x8d6c('0x89')])[_0x8d6c('0x12')](function(){if(_[_0x8d6c('0xc5')](_0x25e4f7[_0x8d6c('0x4b')][_0x8d6c('0x89')])){for(var _0x2290b0=0x0;_0x2290b0<_0x25e4f7[_0x8d6c('0x4b')]['ids'][_0x8d6c('0x6b')];_0x2290b0+=0x1){socket[_0x8d6c('0xc2')](_0x8d6c('0xc6'),{'UserId':Number(_0x25e4f7[_0x8d6c('0x4b')][_0x8d6c('0x89')][_0x2290b0]),'MailAccountId':Number(_0x25e4f7[_0x8d6c('0x61')]['id'])});}}else{socket[_0x8d6c('0xc2')](_0x8d6c('0xc6'),{'UserId':Number(_0x25e4f7[_0x8d6c('0x4b')]['ids']),'MailAccountId':Number(_0x25e4f7['params']['id'])});}});}})[_0x8d6c('0x12')](respondWithStatusCode(_0x31d514,null))[_0x8d6c('0x1a')](handleError(_0x31d514,null));};exports[_0x8d6c('0xc7')]=function(_0x341fb5,_0x1160e4){var _0x5688f2={};var _0x428847={};var _0x3c3148;var _0x4b6564;return db[_0x8d6c('0x47')][_0x8d6c('0x69')]({'where':{'id':_0x341fb5[_0x8d6c('0x61')]['id']}})[_0x8d6c('0x12')](handleEntityNotFound(_0x1160e4,null))[_0x8d6c('0x12')](function(_0x5f246){if(_0x5f246){_0x3c3148=_0x5f246;_0x428847[_0x8d6c('0x4a')]=_[_0x8d6c('0x5c')](db[_0x8d6c('0x8d')][_0x8d6c('0x5b')]);_0x428847[_0x8d6c('0x4b')]=_[_0x8d6c('0x5c')](_0x341fb5[_0x8d6c('0x4b')]);_0x428847[_0x8d6c('0x4c')]=_[_0x8d6c('0x4d')](_0x428847['model'],_0x428847[_0x8d6c('0x4b')]);_0x5688f2[_0x8d6c('0x4e')]=_[_0x8d6c('0x4d')](_0x428847[_0x8d6c('0x4a')],qs[_0x8d6c('0x4f')](_0x341fb5[_0x8d6c('0x4b')][_0x8d6c('0x4f')]));_0x5688f2['attributes']=_0x5688f2['attributes'][_0x8d6c('0x6b')]?_0x5688f2['attributes']:_0x428847[_0x8d6c('0x4a')];_0x5688f2[_0x8d6c('0x6d')]=qs['sort'](_0x341fb5[_0x8d6c('0x4b')][_0x8d6c('0x51')]);_0x5688f2[_0x8d6c('0x52')]=qs[_0x8d6c('0x4c')](_['pick'](_0x341fb5[_0x8d6c('0x4b')],_0x428847[_0x8d6c('0x4c')]));if(_0x341fb5[_0x8d6c('0x4b')][_0x8d6c('0x53')]){_0x5688f2[_0x8d6c('0x52')]=_[_0x8d6c('0x55')](_0x5688f2[_0x8d6c('0x52')],{'$or':_['map'](_0x5688f2[_0x8d6c('0x4e')],function(_0x175f89){var _0x3c188e={};_0x3c188e[_0x175f89]={'$like':'%'+_0x341fb5[_0x8d6c('0x4b')]['filter']+'%'};return _0x3c188e;})});}_0x5688f2=_['merge']({},_0x5688f2,_0x341fb5[_0x8d6c('0x56')]);return _0x3c3148[_0x8d6c('0xc7')](_0x5688f2);}})[_0x8d6c('0x12')](function(_0x3ca620){if(_0x3ca620){_0x4b6564=_0x3ca620[_0x8d6c('0x6b')];if(!_0x341fb5[_0x8d6c('0x4b')][_0x8d6c('0x6c')]('nolimit')){_0x5688f2['limit']=qs['limit'](_0x341fb5[_0x8d6c('0x4b')][_0x8d6c('0x1e')]);_0x5688f2[_0x8d6c('0x1d')]=qs[_0x8d6c('0x1d')](_0x341fb5[_0x8d6c('0x4b')][_0x8d6c('0x1d')]);}return _0x3c3148[_0x8d6c('0xc7')](_0x5688f2);}})['then'](function(_0x2b1ee0){if(_0x2b1ee0){return _0x2b1ee0?{'count':_0x4b6564,'rows':_0x2b1ee0}:null;}})[_0x8d6c('0x12')](respondWithResult(_0x1160e4,null))[_0x8d6c('0x1a')](handleError(_0x1160e4,null));};
\ No newline at end of file
+var _0x2d6d=['CmContact','User','Owner','fullname','internal','Tag','tag','transaction','sequelize','Transaction','ISOLATION_LEVELS','MailApplication','destroy','findAndCountAll','priority','send','getApplications','MailMessage','$gte','format','YYYY-MM-DD\x20HH:mm:ss','inlineCss','true','split','CmList','List','Contacts','updatedAt','DESC','CloudProvider','Smtp\x20configuration\x20not\x20found','from','%s\x20<%s>','attachments','join','getSmtpOptions','List\x20not\x20found','defaults','messageId','subject','out','Messages','verifySmtp','VerifySmtp','Sequelize','You\x20can\x27t\x20remove\x20the\x20mail\x20service\x20account','addAgents','spread','emit','userMailAccount:save','userMailAccount:remove','getAgents','moment','bluebird','lodash','ioredis','../../components/parsers/qs','../../config/logger','../../config/environment','../../mysqldb','redis','localhost','socket.io-emitter','./mailAccount.socket','register','jayson/promise','client','http','MailAccount,\x20%s,\x20%s','request\x20sent','debug','MailAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message','info','catch','sendStatus','end','status','json','offset','undefined','count','limit','update','then','get','MailAccounts','UserProfileResource','stack','imap.gmail.com','yahoo','hotmail','imap-mail.outlook.com','outlook365','outlook.office365.com','Unknown\x20email\x20service\x20provider','gmail','smtp.gmail.com','smtp.mail.yahoo.com','smtp-mail.outlook.com','smtp.office365.com','user','username','password','pass','modernAuthentication','CloudProviderId','host','port','secure','service','authentication','Imap','Smtp','index','MailServerIn','MailServerOut','mandatoryDispositionPause','map','fieldName','key','model','query','filters','intersection','attributes','length','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','name','options','includeAll','include','MailAccount','findAll','show','params','Pause','keys','rawAttributes','fields','find','body','provider','custom','describe','addDisposition','MailAccountId','Disposition','create','getDispositions','findOne','hasOwnProperty','rows','removeDispositions','ids','addAnswer','CannedAnswer','removeAnswers','isNil','Unable\x20to\x20retrieve\x20the\x20current\x20user','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','getImap','addImap','setImap','getSmtp','addSmtp','removeSmtp','setSmtp','addInteraction','MailInteraction','omit'];(function(_0x43bb57,_0x1bd572){var _0x260a1e=function(_0x41f80b){while(--_0x41f80b){_0x43bb57['push'](_0x43bb57['shift']());}};_0x260a1e(++_0x1bd572);}(_0x2d6d,0xec));var _0xd2d6=function(_0x13b7fd,_0x4eaf7f){_0x13b7fd=_0x13b7fd-0x0;var _0x32a74a=_0x2d6d[_0x13b7fd];return _0x32a74a;};'use strict';var moment=require(_0xd2d6('0x0'));var BPromise=require(_0xd2d6('0x1'));var util=require('util');var path=require('path');var _=require(_0xd2d6('0x2'));var juice=require('juice');var Redis=require(_0xd2d6('0x3'));var qs=require(_0xd2d6('0x4'));var logger=require(_0xd2d6('0x5'))('api');var config=require(_0xd2d6('0x6'));var db=require(_0xd2d6('0x7'))['db'];config[_0xd2d6('0x8')]=_['defaults'](config[_0xd2d6('0x8')],{'host':_0xd2d6('0x9'),'port':0x18eb});var socket=require(_0xd2d6('0xa'))(new Redis(config['redis']));require(_0xd2d6('0xb'))[_0xd2d6('0xc')](socket);var jayson=require(_0xd2d6('0xd'));var client=jayson[_0xd2d6('0xe')][_0xd2d6('0xf')]({'port':0x232b});function respondWithRpcPromise(_0x26db10,_0x19eb2c,_0x41b41e,_0x5cf8b6){return new BPromise(function(_0xe3e2b9,_0x3914b4){var _0x51d1a7=_0x5cf8b6||client;return _0x51d1a7['request'](_0x26db10,_0x41b41e)['then'](function(_0x18e746){logger['info'](_0xd2d6('0x10'),_0x19eb2c,_0xd2d6('0x11'));logger[_0xd2d6('0x12')](_0xd2d6('0x13'),_0x19eb2c,_0xd2d6('0x11'),JSON[_0xd2d6('0x14')](_0x18e746));if(_0x18e746['error']){if(_0x18e746[_0xd2d6('0x15')][_0xd2d6('0x16')]===0x1f4){logger['error'](_0xd2d6('0x10'),_0x19eb2c,_0x18e746[_0xd2d6('0x15')][_0xd2d6('0x17')]);return _0x3914b4(_0x18e746[_0xd2d6('0x15')][_0xd2d6('0x17')]);}logger[_0xd2d6('0x15')]('MailAccount,\x20%s,\x20%s',_0x19eb2c,_0x18e746[_0xd2d6('0x15')][_0xd2d6('0x17')]);return _0xe3e2b9(_0x18e746[_0xd2d6('0x15')]['message']);}else{logger[_0xd2d6('0x18')](_0xd2d6('0x10'),_0x19eb2c,_0xd2d6('0x11'));_0xe3e2b9(_0x18e746['result']['message']);}})[_0xd2d6('0x19')](function(_0x55c328){logger[_0xd2d6('0x15')](_0xd2d6('0x10'),_0x19eb2c,_0x55c328);_0x3914b4(_0x55c328);});});}function respondWithStatusCode(_0x18f0e8,_0x5df1ab){_0x5df1ab=_0x5df1ab||0xcc;return function(_0x1a9e17){if(_0x1a9e17){return _0x18f0e8[_0xd2d6('0x1a')](_0x5df1ab);}return _0x18f0e8['status'](_0x5df1ab)[_0xd2d6('0x1b')]();};}function respondWithResult(_0x95ca,_0x652790){_0x652790=_0x652790||0xc8;return function(_0x56821f){if(_0x56821f){return _0x95ca[_0xd2d6('0x1c')](_0x652790)[_0xd2d6('0x1d')](_0x56821f);}};}function respondWithFilteredResult(_0x545445,_0x3f56af){return function(_0x5ffcd5){if(_0x5ffcd5){var _0x2f0a67=typeof _0x3f56af[_0xd2d6('0x1e')]===_0xd2d6('0x1f')&&typeof _0x3f56af['limit']==='undefined';var _0x21ba09=_0x5ffcd5[_0xd2d6('0x20')];var _0x4d1cee=_0x2f0a67?0x0:_0x3f56af['offset'];var _0x185531=_0x2f0a67?_0x5ffcd5[_0xd2d6('0x20')]:_0x3f56af[_0xd2d6('0x1e')]+_0x3f56af[_0xd2d6('0x21')];var _0x2ff225;if(_0x185531>=_0x21ba09){_0x185531=_0x21ba09;_0x2ff225=0xc8;}else{_0x2ff225=0xce;}_0x545445[_0xd2d6('0x1c')](_0x2ff225);return _0x545445['set']('Content-Range',_0x4d1cee+'-'+_0x185531+'/'+_0x21ba09)['json'](_0x5ffcd5);}return null;};}function saveUpdates(_0x3531ec){return function(_0x1b21a0){if(_0x1b21a0){return _0x1b21a0[_0xd2d6('0x22')](_0x3531ec)[_0xd2d6('0x23')](function(_0x22d85a){return _0x22d85a;});}return null;};}function removeEntity(_0x3f5cd2){return function(_0x3174d3){if(_0x3174d3){return _0x3174d3['destroy']()[_0xd2d6('0x23')](function(){var _0x5c98da=_0x3174d3[_0xd2d6('0x24')]({'plain':!![]});var _0x1cba5d=_0xd2d6('0x25');return db[_0xd2d6('0x26')]['destroy']({'where':{'type':_0x1cba5d,'resourceId':_0x5c98da['id']}})[_0xd2d6('0x23')](function(){return _0x3174d3;});})[_0xd2d6('0x23')](function(){_0x3f5cd2[_0xd2d6('0x1c')](0xcc)['end']();});}};}function handleEntityNotFound(_0xef95c0){return function(_0x1e3eb5){if(!_0x1e3eb5){_0xef95c0[_0xd2d6('0x1a')](0x194);}return _0x1e3eb5;};}function handleError(_0xbed937,_0x2bade1){_0x2bade1=_0x2bade1||0x1f4;return function(_0x4bde24){logger[_0xd2d6('0x15')](_0x4bde24[_0xd2d6('0x27')]);if(_0x4bde24['name']){delete _0x4bde24['name'];}_0xbed937[_0xd2d6('0x1c')](_0x2bade1)['send'](_0x4bde24);};}function getImapHost(_0xaec960){switch(_0xaec960){case'gmail':return _0xd2d6('0x28');case _0xd2d6('0x29'):return'imap.mail.yahoo.com';case _0xd2d6('0x2a'):return _0xd2d6('0x2b');case _0xd2d6('0x2c'):return _0xd2d6('0x2d');}throw new Error(_0xd2d6('0x2e'),_0xaec960);}function getSmtpHost(_0x22a9a2){switch(_0x22a9a2){case _0xd2d6('0x2f'):return _0xd2d6('0x30');case _0xd2d6('0x29'):return _0xd2d6('0x31');case'hotmail':return _0xd2d6('0x32');case'outlook365':return _0xd2d6('0x33');}throw new Error(_0xd2d6('0x2e'),_0x22a9a2);}function getAuthenticationOptions(_0xc4ce7e,_0x1ea9e7){var _0x2eb7f6={};var _0x32033d={};if(_0xc4ce7e){_0x2eb7f6[_0xd2d6('0x34')]=_0x32033d[_0xd2d6('0x34')]=_0x1ea9e7[_0xd2d6('0x35')];_0x2eb7f6[_0xd2d6('0x36')]=_0x32033d[_0xd2d6('0x37')]=_0x1ea9e7[_0xd2d6('0x36')];if(_0x1ea9e7['modernAuthentication']){_0x2eb7f6[_0xd2d6('0x38')]=_0x32033d[_0xd2d6('0x38')]=!![];_0x2eb7f6[_0xd2d6('0x39')]=_0x32033d[_0xd2d6('0x39')]=_0x1ea9e7['CloudProviderId'];_0x2eb7f6[_0xd2d6('0x36')]=_0x32033d[_0xd2d6('0x37')]=null;}else{_0x2eb7f6[_0xd2d6('0x39')]=_0x32033d[_0xd2d6('0x39')]=null;}_0x2eb7f6[_0xd2d6('0x3a')]=getImapHost(_0xc4ce7e);_0x2eb7f6['port']=0x3e1;_0x32033d[_0xd2d6('0x3a')]=getSmtpHost(_0xc4ce7e);_0x32033d[_0xd2d6('0x3b')]=0x24b;_0x32033d[_0xd2d6('0x3c')]=![];_0x2eb7f6[_0xd2d6('0x3d')]=_0x32033d[_0xd2d6('0x3d')]=null;}else{if(_0x1ea9e7[_0xd2d6('0x3e')]){_0x2eb7f6[_0xd2d6('0x34')]=_0x32033d['user']=_0x1ea9e7[_0xd2d6('0x35')];_0x2eb7f6['password']=_0x32033d[_0xd2d6('0x37')]=_0x1ea9e7[_0xd2d6('0x36')];}else{_0x2eb7f6[_0xd2d6('0x3e')]=_0x32033d[_0xd2d6('0x3e')]=![];_0x2eb7f6[_0xd2d6('0x34')]=_0x32033d['user']=null;_0x2eb7f6['password']=_0x32033d['pass']=null;}_0x2eb7f6[_0xd2d6('0x3a')]=_0x1ea9e7[_0xd2d6('0x3f')][_0xd2d6('0x3a')];_0x2eb7f6[_0xd2d6('0x3b')]=_0x1ea9e7['Imap']['port'];_0x32033d[_0xd2d6('0x3a')]=_0x1ea9e7[_0xd2d6('0x40')]['host'];_0x32033d['port']=_0x1ea9e7['Smtp']['port'];}return{'Imap':_0x2eb7f6,'Smtp':_0x32033d};}exports[_0xd2d6('0x41')]=function(_0x4fea03,_0x1c1ecc){var _0x3138f3={'include':[{'model':db[_0xd2d6('0x42')],'as':_0xd2d6('0x3f')},{'model':db[_0xd2d6('0x43')],'as':_0xd2d6('0x40')},{'model':db['Pause'],'as':_0xd2d6('0x44')}]},_0x16d58e={},_0x98e7e5={'count':0x0,'rows':[]};var _0x49e65e=_[_0xd2d6('0x45')](db['MailAccount']['rawAttributes'],function(_0x40e1f9){return{'name':_0x40e1f9[_0xd2d6('0x46')],'type':_0x40e1f9['type'][_0xd2d6('0x47')]};});_0x16d58e[_0xd2d6('0x48')]=_[_0xd2d6('0x45')](_0x49e65e,'name');_0x16d58e[_0xd2d6('0x49')]=_['keys'](_0x4fea03[_0xd2d6('0x49')]);_0x16d58e[_0xd2d6('0x4a')]=_[_0xd2d6('0x4b')](_0x16d58e[_0xd2d6('0x48')],_0x16d58e[_0xd2d6('0x49')]);_0x3138f3['attributes']=_['intersection'](_0x16d58e[_0xd2d6('0x48')],qs['fields'](_0x4fea03[_0xd2d6('0x49')]['fields']));_0x3138f3[_0xd2d6('0x4c')]=_0x3138f3['attributes'][_0xd2d6('0x4d')]?_0x3138f3[_0xd2d6('0x4c')]:_0x16d58e['model'];if(!_0x4fea03[_0xd2d6('0x49')]['hasOwnProperty'](_0xd2d6('0x4e'))){_0x3138f3[_0xd2d6('0x21')]=qs['limit'](_0x4fea03['query'][_0xd2d6('0x21')]);_0x3138f3['offset']=qs[_0xd2d6('0x1e')](_0x4fea03['query']['offset']);}_0x3138f3[_0xd2d6('0x4f')]=qs[_0xd2d6('0x50')](_0x4fea03[_0xd2d6('0x49')][_0xd2d6('0x50')]);_0x3138f3[_0xd2d6('0x51')]=qs['filters'](_[_0xd2d6('0x52')](_0x4fea03[_0xd2d6('0x49')],_0x16d58e[_0xd2d6('0x4a')]),_0x49e65e);if(_0x4fea03[_0xd2d6('0x49')][_0xd2d6('0x53')]){_0x3138f3[_0xd2d6('0x51')]=_[_0xd2d6('0x54')](_0x3138f3[_0xd2d6('0x51')],{'$or':_[_0xd2d6('0x45')](_0x49e65e,function(_0x334230){if(_0x334230['type']!==_0xd2d6('0x55')){var _0x598675={};_0x598675[_0x334230[_0xd2d6('0x56')]]={'$like':'%'+_0x4fea03[_0xd2d6('0x49')]['filter']+'%'};return _0x598675;}})});}_0x3138f3=_['merge']({},_0x3138f3,_0x4fea03[_0xd2d6('0x57')]);var _0x2cba4e={'where':_0x3138f3[_0xd2d6('0x51')]};return db['MailAccount'][_0xd2d6('0x20')](_0x2cba4e)[_0xd2d6('0x23')](function(_0x507608){_0x98e7e5['count']=_0x507608;if(_0x4fea03[_0xd2d6('0x49')][_0xd2d6('0x58')]){_0x3138f3[_0xd2d6('0x59')]=[{'all':!![]}];}return db[_0xd2d6('0x5a')][_0xd2d6('0x5b')](_0x3138f3);})[_0xd2d6('0x23')](function(_0x1790c0){_0x98e7e5['rows']=_0x1790c0;return _0x98e7e5;})['then'](respondWithFilteredResult(_0x1c1ecc,_0x3138f3))[_0xd2d6('0x19')](handleError(_0x1c1ecc,null));};exports[_0xd2d6('0x5c')]=function(_0x8a4fc8,_0x1de4e7){var _0x12b75e={'raw':![],'where':{'id':_0x8a4fc8[_0xd2d6('0x5d')]['id']},'include':[{'model':db[_0xd2d6('0x42')],'as':_0xd2d6('0x3f')},{'model':db['MailServerOut'],'as':_0xd2d6('0x40')},{'model':db[_0xd2d6('0x5e')],'as':_0xd2d6('0x44')}]},_0x231b7b={};_0x231b7b[_0xd2d6('0x48')]=_[_0xd2d6('0x5f')](db[_0xd2d6('0x5a')][_0xd2d6('0x60')]);_0x231b7b[_0xd2d6('0x49')]=_['keys'](_0x8a4fc8['query']);_0x231b7b['filters']=_[_0xd2d6('0x4b')](_0x231b7b['model'],_0x231b7b[_0xd2d6('0x49')]);_0x12b75e[_0xd2d6('0x4c')]=_[_0xd2d6('0x4b')](_0x231b7b['model'],qs['fields'](_0x8a4fc8[_0xd2d6('0x49')][_0xd2d6('0x61')]));_0x12b75e[_0xd2d6('0x4c')]=_0x12b75e['attributes'][_0xd2d6('0x4d')]?_0x12b75e[_0xd2d6('0x4c')]:_0x231b7b[_0xd2d6('0x48')];if(_0x8a4fc8[_0xd2d6('0x49')][_0xd2d6('0x58')]){_0x12b75e['include']=[{'all':!![]}];}_0x12b75e=_[_0xd2d6('0x54')]({},_0x12b75e,_0x8a4fc8[_0xd2d6('0x57')]);return db[_0xd2d6('0x5a')][_0xd2d6('0x62')](_0x12b75e)['then'](handleEntityNotFound(_0x1de4e7,null))[_0xd2d6('0x23')](respondWithResult(_0x1de4e7,null))['catch'](handleError(_0x1de4e7,null));};exports[_0xd2d6('0x22')]=function(_0x38929b,_0x2ebf90){if(_0x38929b[_0xd2d6('0x63')]['id']){delete _0x38929b[_0xd2d6('0x63')]['id'];}var _0xd23946=_0x38929b[_0xd2d6('0x63')][_0xd2d6('0x64')]===_0xd2d6('0x65')?null:_0x38929b[_0xd2d6('0x63')]['provider'];var _0x31c149=_0x38929b[_0xd2d6('0x63')][_0xd2d6('0x3f')]||{};var _0x10bdcc=_0x38929b[_0xd2d6('0x63')]['Smtp']||{};if(_0xd23946){_0x31c149['host']=getImapHost(_0xd23946);_0x31c149[_0xd2d6('0x3b')]=0x3e1;_0x10bdcc[_0xd2d6('0x3a')]=getSmtpHost(_0xd23946);_0x10bdcc['port']=0x24b;_0x10bdcc[_0xd2d6('0x3c')]=![];}if(_0x10bdcc[_0xd2d6('0x38')]){_0x10bdcc['secure']=![];}else{_0x10bdcc[_0xd2d6('0x39')]=null;}if(!_0x31c149['modernAuthentication'])_0x31c149[_0xd2d6('0x39')]=null;_0x38929b[_0xd2d6('0x63')][_0xd2d6('0x3f')]=_0x31c149;_0x38929b['body'][_0xd2d6('0x40')]=_0x10bdcc;return db[_0xd2d6('0x5a')][_0xd2d6('0x62')]({'where':{'id':_0x38929b[_0xd2d6('0x5d')]['id']},'include':[{'model':db[_0xd2d6('0x42')],'as':_0xd2d6('0x3f')},{'model':db[_0xd2d6('0x43')],'as':'Smtp'},{'model':db[_0xd2d6('0x5e')],'as':_0xd2d6('0x44')}]})['then'](handleEntityNotFound(_0x2ebf90,null))['then'](function(_0x449918){if(!_0x449918)throw new Error('Mail\x20Account\x20not\x20found');if(_0x449918[_0xd2d6('0x3d')])delete _0x38929b[_0xd2d6('0x63')]['Imap'];return _0x449918;})[_0xd2d6('0x23')](saveUpdates(_0x38929b['body'],null))[_0xd2d6('0x23')](function(_0x1fb96f){if(!_0x38929b[_0xd2d6('0x63')][_0xd2d6('0x3f')])return _0x1fb96f;return db[_0xd2d6('0x42')][_0xd2d6('0x22')](_0x38929b[_0xd2d6('0x63')][_0xd2d6('0x3f')],{'where':{'MailAccountId':_0x1fb96f['id']}})[_0xd2d6('0x23')](function(){return _0x1fb96f;});})[_0xd2d6('0x23')](function(_0x61299d){if(!_0x38929b[_0xd2d6('0x63')][_0xd2d6('0x40')])return _0x61299d;return db[_0xd2d6('0x43')][_0xd2d6('0x22')](_0x38929b['body'][_0xd2d6('0x40')],{'where':{'MailAccountId':_0x61299d['id']}})[_0xd2d6('0x23')](function(){return _0x61299d;});})[_0xd2d6('0x23')](respondWithResult(_0x2ebf90,null))[_0xd2d6('0x19')](handleError(_0x2ebf90,null));};exports[_0xd2d6('0x66')]=function(_0x286c46,_0x2739eb){return db['MailAccount'][_0xd2d6('0x66')]()[_0xd2d6('0x23')](respondWithResult(_0x2739eb,null))[_0xd2d6('0x19')](handleError(_0x2739eb,null));};exports[_0xd2d6('0x67')]=function(_0x2ed5e4,_0xfbd19e){if(_0x2ed5e4[_0xd2d6('0x63')]['id']){delete _0x2ed5e4['body']['id'];}return db[_0xd2d6('0x5a')][_0xd2d6('0x62')]({'where':{'id':_0x2ed5e4[_0xd2d6('0x5d')]['id']}})[_0xd2d6('0x23')](handleEntityNotFound(_0xfbd19e,null))[_0xd2d6('0x23')](function(_0x240465){if(_0x240465){_0x2ed5e4[_0xd2d6('0x63')][_0xd2d6('0x68')]=_0x240465['id'];return db[_0xd2d6('0x69')][_0xd2d6('0x6a')](_0x2ed5e4[_0xd2d6('0x63')]);}})[_0xd2d6('0x23')](respondWithResult(_0xfbd19e,null))[_0xd2d6('0x19')](handleError(_0xfbd19e,null));};exports[_0xd2d6('0x6b')]=function(_0x1daf99,_0x588a2a){var _0x319b9d={'raw':![],'where':{}};var _0x110cb9={};var _0x49f9be={'count':0x0,'rows':[]};return db[_0xd2d6('0x5a')][_0xd2d6('0x6c')]({'where':{'id':_0x1daf99[_0xd2d6('0x5d')]['id']}})[_0xd2d6('0x23')](handleEntityNotFound(_0x588a2a,null))[_0xd2d6('0x23')](function(_0x35c800){if(_0x35c800){_0x110cb9[_0xd2d6('0x48')]=_[_0xd2d6('0x5f')](db[_0xd2d6('0x69')][_0xd2d6('0x60')]);_0x110cb9[_0xd2d6('0x49')]=_[_0xd2d6('0x5f')](_0x1daf99[_0xd2d6('0x49')]);_0x110cb9[_0xd2d6('0x4a')]=_[_0xd2d6('0x4b')](_0x110cb9[_0xd2d6('0x48')],_0x110cb9[_0xd2d6('0x49')]);_0x319b9d[_0xd2d6('0x4c')]=_[_0xd2d6('0x4b')](_0x110cb9[_0xd2d6('0x48')],qs[_0xd2d6('0x61')](_0x1daf99[_0xd2d6('0x49')][_0xd2d6('0x61')]));_0x319b9d[_0xd2d6('0x4c')]=_0x319b9d[_0xd2d6('0x4c')][_0xd2d6('0x4d')]?_0x319b9d[_0xd2d6('0x4c')]:_0x110cb9[_0xd2d6('0x48')];if(!_0x1daf99[_0xd2d6('0x49')][_0xd2d6('0x6d')]('nolimit')){_0x319b9d[_0xd2d6('0x21')]=qs[_0xd2d6('0x21')](_0x1daf99[_0xd2d6('0x49')]['limit']);_0x319b9d[_0xd2d6('0x1e')]=qs[_0xd2d6('0x1e')](_0x1daf99[_0xd2d6('0x49')][_0xd2d6('0x1e')]);}_0x319b9d[_0xd2d6('0x4f')]=qs['sort'](_0x1daf99[_0xd2d6('0x49')][_0xd2d6('0x50')]);_0x319b9d[_0xd2d6('0x51')]=qs[_0xd2d6('0x4a')](_['pick'](_0x1daf99[_0xd2d6('0x49')],_0x110cb9[_0xd2d6('0x4a')]));_0x319b9d[_0xd2d6('0x51')][_0xd2d6('0x68')]=_0x35c800['id'];if(_0x1daf99['query']['filter']){_0x319b9d[_0xd2d6('0x51')]=_[_0xd2d6('0x54')](_0x319b9d[_0xd2d6('0x51')],{'$or':_[_0xd2d6('0x45')](_0x319b9d['attributes'],function(_0x560fc8){var _0x2ceeee={};_0x2ceeee[_0x560fc8]={'$like':'%'+_0x1daf99[_0xd2d6('0x49')][_0xd2d6('0x53')]+'%'};return _0x2ceeee;})});}_0x319b9d=_['merge']({},_0x319b9d,_0x1daf99[_0xd2d6('0x57')]);return db[_0xd2d6('0x69')][_0xd2d6('0x20')]({'where':_0x319b9d['where']})[_0xd2d6('0x23')](function(_0x2eccb5){_0x49f9be['count']=_0x2eccb5;if(_0x1daf99[_0xd2d6('0x49')][_0xd2d6('0x58')]){_0x319b9d[_0xd2d6('0x59')]=[{'all':!![]}];}return db['Disposition'][_0xd2d6('0x5b')](_0x319b9d);})[_0xd2d6('0x23')](function(_0x2efc0d){_0x49f9be[_0xd2d6('0x6e')]=_0x2efc0d;return _0x49f9be;});}})[_0xd2d6('0x23')](respondWithFilteredResult(_0x588a2a,_0x319b9d))[_0xd2d6('0x19')](handleError(_0x588a2a,null));};exports[_0xd2d6('0x6f')]=function(_0x497e27,_0x54bbac){return db[_0xd2d6('0x5a')][_0xd2d6('0x62')]({'where':{'id':_0x497e27[_0xd2d6('0x5d')]['id']}})[_0xd2d6('0x23')](handleEntityNotFound(_0x54bbac,null))[_0xd2d6('0x23')](function(_0x3f47e8){if(_0x3f47e8){return _0x3f47e8[_0xd2d6('0x6f')](_0x497e27[_0xd2d6('0x49')][_0xd2d6('0x70')]);}})[_0xd2d6('0x23')](respondWithStatusCode(_0x54bbac,null))['catch'](handleError(_0x54bbac,null));};exports[_0xd2d6('0x71')]=function(_0x3cfe22,_0x3de25d){if(_0x3cfe22['body']['id']){delete _0x3cfe22['body']['id'];}return db[_0xd2d6('0x5a')]['find']({'where':{'id':_0x3cfe22[_0xd2d6('0x5d')]['id']}})[_0xd2d6('0x23')](handleEntityNotFound(_0x3de25d,null))[_0xd2d6('0x23')](function(_0x3ad821){if(_0x3ad821){_0x3cfe22[_0xd2d6('0x63')][_0xd2d6('0x68')]=_0x3ad821['id'];return db['CannedAnswer'][_0xd2d6('0x6a')](_0x3cfe22['body']);}})[_0xd2d6('0x23')](respondWithResult(_0x3de25d,null))[_0xd2d6('0x19')](handleError(_0x3de25d,null));};exports['getAnswers']=function(_0x211c8f,_0x348bde){var _0x5a2795={'raw':![],'where':{}};var _0x81f538={};var _0x2802bb={'count':0x0,'rows':[]};return db['MailAccount']['findOne']({'where':{'id':_0x211c8f[_0xd2d6('0x5d')]['id']}})['then'](handleEntityNotFound(_0x348bde,null))['then'](function(_0x3cfd2d){if(_0x3cfd2d){_0x81f538['model']=_[_0xd2d6('0x5f')](db['CannedAnswer'][_0xd2d6('0x60')]);_0x81f538[_0xd2d6('0x49')]=_[_0xd2d6('0x5f')](_0x211c8f[_0xd2d6('0x49')]);_0x81f538[_0xd2d6('0x4a')]=_['intersection'](_0x81f538[_0xd2d6('0x48')],_0x81f538[_0xd2d6('0x49')]);_0x5a2795[_0xd2d6('0x4c')]=_[_0xd2d6('0x4b')](_0x81f538['model'],qs['fields'](_0x211c8f[_0xd2d6('0x49')]['fields']));_0x5a2795[_0xd2d6('0x4c')]=_0x5a2795['attributes'][_0xd2d6('0x4d')]?_0x5a2795[_0xd2d6('0x4c')]:_0x81f538[_0xd2d6('0x48')];if(!_0x211c8f[_0xd2d6('0x49')]['hasOwnProperty'](_0xd2d6('0x4e'))){_0x5a2795[_0xd2d6('0x21')]=qs[_0xd2d6('0x21')](_0x211c8f[_0xd2d6('0x49')][_0xd2d6('0x21')]);_0x5a2795[_0xd2d6('0x1e')]=qs[_0xd2d6('0x1e')](_0x211c8f[_0xd2d6('0x49')][_0xd2d6('0x1e')]);}_0x5a2795[_0xd2d6('0x4f')]=qs[_0xd2d6('0x50')](_0x211c8f[_0xd2d6('0x49')][_0xd2d6('0x50')]);_0x5a2795['where']=qs['filters'](_[_0xd2d6('0x52')](_0x211c8f[_0xd2d6('0x49')],_0x81f538[_0xd2d6('0x4a')]));_0x5a2795[_0xd2d6('0x51')]['MailAccountId']=_0x3cfd2d['id'];if(_0x211c8f[_0xd2d6('0x49')][_0xd2d6('0x53')]){_0x5a2795[_0xd2d6('0x51')]=_[_0xd2d6('0x54')](_0x5a2795[_0xd2d6('0x51')],{'$or':_[_0xd2d6('0x45')](_0x5a2795[_0xd2d6('0x4c')],function(_0x5f0e1e){var _0x561ae0={};_0x561ae0[_0x5f0e1e]={'$like':'%'+_0x211c8f[_0xd2d6('0x49')][_0xd2d6('0x53')]+'%'};return _0x561ae0;})});}_0x5a2795=_['merge']({},_0x5a2795,_0x211c8f[_0xd2d6('0x57')]);return db['CannedAnswer'][_0xd2d6('0x20')]({'where':_0x5a2795[_0xd2d6('0x51')]})[_0xd2d6('0x23')](function(_0x520233){_0x2802bb[_0xd2d6('0x20')]=_0x520233;if(_0x211c8f[_0xd2d6('0x49')]['includeAll']){_0x5a2795[_0xd2d6('0x59')]=[{'all':!![]}];}return db[_0xd2d6('0x72')]['findAll'](_0x5a2795);})['then'](function(_0x25c059){_0x2802bb[_0xd2d6('0x6e')]=_0x25c059;return _0x2802bb;});}})[_0xd2d6('0x23')](respondWithFilteredResult(_0x348bde,_0x5a2795))[_0xd2d6('0x19')](handleError(_0x348bde,null));};exports[_0xd2d6('0x73')]=function(_0x17d605,_0xcbfb7d){return db['MailAccount'][_0xd2d6('0x62')]({'where':{'id':_0x17d605[_0xd2d6('0x5d')]['id']}})['then'](handleEntityNotFound(_0xcbfb7d,null))['then'](function(_0x179f50){if(_0x179f50){return _0x179f50[_0xd2d6('0x73')](_0x17d605[_0xd2d6('0x49')][_0xd2d6('0x70')]);}})[_0xd2d6('0x23')](respondWithStatusCode(_0xcbfb7d,null))[_0xd2d6('0x19')](handleError(_0xcbfb7d,null));};exports[_0xd2d6('0x6a')]=function(_0x4c1a36,_0x32d98b){var _0x45a460={'name':_0x4c1a36['body']['name'],'key':_0x4c1a36['body'][_0xd2d6('0x47')],'provider':_0x4c1a36[_0xd2d6('0x63')]['provider']===_0xd2d6('0x65')?null:_0x4c1a36[_0xd2d6('0x63')][_0xd2d6('0x64')],'email':_0x4c1a36[_0xd2d6('0x63')]['email'],'ListId':_0x4c1a36[_0xd2d6('0x63')]['ListId'],'active':!_[_0xd2d6('0x74')](_0x4c1a36[_0xd2d6('0x63')]['active'])?_0x4c1a36[_0xd2d6('0x63')]['active']:!![],'description':_0x4c1a36['body']['description']||null};var _0x258942=getAuthenticationOptions(_0x45a460['provider'],_0x4c1a36[_0xd2d6('0x63')]);_0x45a460[_0xd2d6('0x3f')]=_0x258942[_0xd2d6('0x3f')];_0x45a460['Smtp']=_0x258942[_0xd2d6('0x40')];return db[_0xd2d6('0x5a')][_0xd2d6('0x6a')](_0x45a460,{'include':[{'model':db[_0xd2d6('0x43')],'as':_0xd2d6('0x40')},{'model':db[_0xd2d6('0x42')],'as':_0xd2d6('0x3f')}]})[_0xd2d6('0x23')](function(_0x8b0119){var _0x51fdfb=_0x4c1a36['user'][_0xd2d6('0x24')]({'plain':!![]});if(!_0x51fdfb)throw new Error(_0xd2d6('0x75'));if(_0x51fdfb['role']===_0xd2d6('0x34')){var _0x58c178=_0x8b0119[_0xd2d6('0x24')]({'plain':!![]});return db[_0xd2d6('0x76')][_0xd2d6('0x62')]({'where':{'name':_0xd2d6('0x25'),'userProfileId':_0x51fdfb[_0xd2d6('0x77')]},'raw':!![]})[_0xd2d6('0x23')](function(_0x293693){if(_0x293693&&_0x293693[_0xd2d6('0x78')]===0x0){return db['UserProfileResource'][_0xd2d6('0x6a')]({'name':_0x58c178[_0xd2d6('0x56')],'resourceId':_0x58c178['id'],'type':_0x293693[_0xd2d6('0x56')],'sectionId':_0x293693['id']},{})[_0xd2d6('0x23')](function(){return _0x8b0119;});}else{return _0x8b0119;}})[_0xd2d6('0x19')](function(_0x3bd403){logger[_0xd2d6('0x15')](_0xd2d6('0x79'),_0x3bd403);throw _0x3bd403;});}return _0x8b0119;})[_0xd2d6('0x23')](respondWithResult(_0x32d98b,0xc9))[_0xd2d6('0x19')](handleError(_0x32d98b,null));};exports[_0xd2d6('0x7a')]=function(_0x43dd36,_0x2551c1){return db['MailAccount']['findOne']({'where':{'id':_0x43dd36[_0xd2d6('0x5d')]['id']}})[_0xd2d6('0x23')](handleEntityNotFound(_0x2551c1,null))['then'](function(_0x2b322d){if(_0x2b322d){return _0x2b322d[_0xd2d6('0x7a')]();}return null;})[_0xd2d6('0x23')](respondWithResult(_0x2551c1,null))[_0xd2d6('0x19')](handleError(_0x2551c1,null));};exports[_0xd2d6('0x7b')]=function(_0x382a65,_0x47cdfa){if(_0x382a65[_0xd2d6('0x63')]['id']){delete _0x382a65[_0xd2d6('0x63')]['id'];}return db[_0xd2d6('0x5a')][_0xd2d6('0x62')]({'where':{'id':_0x382a65[_0xd2d6('0x5d')]['id']}})[_0xd2d6('0x23')](handleEntityNotFound(_0x47cdfa,null))[_0xd2d6('0x23')](function(_0x1f2910){if(_0x1f2910){_0x382a65[_0xd2d6('0x63')][_0xd2d6('0x68')]=_0x1f2910['id'];return db[_0xd2d6('0x42')][_0xd2d6('0x6a')](_0x382a65[_0xd2d6('0x63')]);}})['then'](respondWithResult(_0x47cdfa,null))[_0xd2d6('0x19')](handleError(_0x47cdfa,null));};exports['removeImap']=function(_0x53cffb,_0x31e013){return db['MailAccount'][_0xd2d6('0x6c')]({'where':{'id':_0x53cffb[_0xd2d6('0x5d')]['id']}})[_0xd2d6('0x23')](handleEntityNotFound(_0x31e013,null))[_0xd2d6('0x23')](function(_0xe99a88){if(_0xe99a88){return _0xe99a88[_0xd2d6('0x7c')](null);}return null;})[_0xd2d6('0x23')](respondWithStatusCode(_0x31e013,null))[_0xd2d6('0x19')](handleError(_0x31e013,null));};exports[_0xd2d6('0x7d')]=function(_0x39c835,_0x49a3d7){return db[_0xd2d6('0x5a')]['findOne']({'where':{'id':_0x39c835['params']['id']}})[_0xd2d6('0x23')](handleEntityNotFound(_0x49a3d7,null))[_0xd2d6('0x23')](function(_0x21a06f){if(_0x21a06f){return _0x21a06f[_0xd2d6('0x7d')]();}return null;})[_0xd2d6('0x23')](respondWithResult(_0x49a3d7,null))[_0xd2d6('0x19')](handleError(_0x49a3d7,null));};exports[_0xd2d6('0x7e')]=function(_0x1a0ca3,_0x57ff1d){if(_0x1a0ca3[_0xd2d6('0x63')]['id']){delete _0x1a0ca3[_0xd2d6('0x63')]['id'];}return db[_0xd2d6('0x5a')][_0xd2d6('0x62')]({'where':{'id':_0x1a0ca3[_0xd2d6('0x5d')]['id']}})[_0xd2d6('0x23')](handleEntityNotFound(_0x57ff1d,null))[_0xd2d6('0x23')](function(_0x464312){if(_0x464312){_0x1a0ca3[_0xd2d6('0x63')]['MailAccountId']=_0x464312['id'];return db['MailServerOut']['create'](_0x1a0ca3[_0xd2d6('0x63')]);}})[_0xd2d6('0x23')](respondWithResult(_0x57ff1d,null))[_0xd2d6('0x19')](handleError(_0x57ff1d,null));};exports[_0xd2d6('0x7f')]=function(_0x28fd99,_0x3caf87){return db[_0xd2d6('0x5a')][_0xd2d6('0x6c')]({'where':{'id':_0x28fd99[_0xd2d6('0x5d')]['id']}})[_0xd2d6('0x23')](handleEntityNotFound(_0x3caf87,null))[_0xd2d6('0x23')](function(_0x1ccf32){if(_0x1ccf32){return _0x1ccf32[_0xd2d6('0x80')](null);}return null;})[_0xd2d6('0x23')](respondWithStatusCode(_0x3caf87,null))[_0xd2d6('0x19')](handleError(_0x3caf87,null));};exports[_0xd2d6('0x81')]=function(_0x33d67a,_0x3dd25e){return db[_0xd2d6('0x82')]['find']({'where':{'id':_0x33d67a[_0xd2d6('0x5d')]['id']}})[_0xd2d6('0x23')](handleEntityNotFound(_0x3dd25e,null))['then'](function(_0x51ba60){if(_0x51ba60){return _0x51ba60[_0xd2d6('0x81')](_0x33d67a[_0xd2d6('0x63')]['ids'],_[_0xd2d6('0x83')](_0x33d67a[_0xd2d6('0x63')],['ids','id'])||{});}})[_0xd2d6('0x23')](respondWithResult(_0x3dd25e,null))[_0xd2d6('0x19')](handleError(_0x3dd25e,null));};exports['getInteractions']=function(_0x92d387,_0x5f1ce3){var _0x25d191={'raw':![],'where':{}};var _0x56e966={};var _0x35521a={'count':0x0,'rows':[]};return db['MailAccount'][_0xd2d6('0x6c')]({'where':{'id':_0x92d387[_0xd2d6('0x5d')]['id']}})[_0xd2d6('0x23')](handleEntityNotFound(_0x5f1ce3,null))['then'](function(_0x354940){if(_0x354940){_0x56e966[_0xd2d6('0x48')]=_[_0xd2d6('0x5f')](db['MailInteraction'][_0xd2d6('0x60')]);_0x56e966['query']=_['keys'](_0x92d387[_0xd2d6('0x49')]);_0x56e966[_0xd2d6('0x4a')]=_[_0xd2d6('0x4b')](_0x56e966[_0xd2d6('0x48')],_0x56e966[_0xd2d6('0x49')]);_0x25d191[_0xd2d6('0x4c')]=_[_0xd2d6('0x4b')](_0x56e966[_0xd2d6('0x48')],qs['fields'](_0x92d387['query'][_0xd2d6('0x61')]));_0x25d191[_0xd2d6('0x4c')]=_0x25d191[_0xd2d6('0x4c')][_0xd2d6('0x4d')]?_0x25d191[_0xd2d6('0x4c')]:_0x56e966['model'];if(!_0x92d387['query'][_0xd2d6('0x6d')]('nolimit')){_0x25d191['limit']=qs[_0xd2d6('0x21')](_0x92d387[_0xd2d6('0x49')]['limit']);_0x25d191[_0xd2d6('0x1e')]=qs[_0xd2d6('0x1e')](_0x92d387['query'][_0xd2d6('0x1e')]);}_0x25d191[_0xd2d6('0x4f')]=qs[_0xd2d6('0x50')](_0x92d387[_0xd2d6('0x49')][_0xd2d6('0x50')]);_0x25d191[_0xd2d6('0x51')]=qs[_0xd2d6('0x4a')](_[_0xd2d6('0x52')](_0x92d387[_0xd2d6('0x49')],_0x56e966['filters']));_0x25d191[_0xd2d6('0x51')][_0xd2d6('0x68')]=_0x354940['id'];if(_0x92d387[_0xd2d6('0x49')]['filter']){_0x25d191['where']=_[_0xd2d6('0x54')](_0x25d191[_0xd2d6('0x51')],{'$or':_[_0xd2d6('0x45')](_0x25d191[_0xd2d6('0x4c')],function(_0x5eb27f){var _0x5d2ad8={};_0x5d2ad8[_0x5eb27f]={'$like':'%'+_0x92d387[_0xd2d6('0x49')][_0xd2d6('0x53')]+'%'};return _0x5d2ad8;})});}_0x25d191=_[_0xd2d6('0x54')]({},_0x25d191,_0x92d387[_0xd2d6('0x57')]);return db[_0xd2d6('0x82')]['count']({'where':_0x25d191[_0xd2d6('0x51')]})[_0xd2d6('0x23')](function(_0x17a5fa){_0x35521a[_0xd2d6('0x20')]=_0x17a5fa;if(_0x92d387[_0xd2d6('0x49')]['includeAll']){_0x25d191['include']=[{'model':db[_0xd2d6('0x84')],'as':'Contact','required':![]},{'model':db[_0xd2d6('0x85')],'as':_0xd2d6('0x86'),'attributes':[_0xd2d6('0x56'),_0xd2d6('0x87'),_0xd2d6('0x88')],'required':![]},{'model':db[_0xd2d6('0x89')],'as':'Tags','attributes':['id',_0xd2d6('0x56'),'color'],'where':_0x92d387[_0xd2d6('0x49')][_0xd2d6('0x8a')]?{'id':_0x92d387[_0xd2d6('0x49')][_0xd2d6('0x8a')]}:undefined,'required':_0x92d387[_0xd2d6('0x49')]['tag']?!![]:![]}];}return db[_0xd2d6('0x82')][_0xd2d6('0x5b')](_0x25d191);})[_0xd2d6('0x23')](function(_0x11339b){_0x35521a[_0xd2d6('0x6e')]=_0x11339b;return _0x35521a;});}})[_0xd2d6('0x23')](respondWithFilteredResult(_0x5f1ce3,_0x25d191))[_0xd2d6('0x19')](handleError(_0x5f1ce3,null));};exports['addApplications']=function addApplications(_0x17e9fd,_0x38d42e){var _0x2d4d22=_0x17e9fd[_0xd2d6('0x5d')]['id'];var _0x2078f5=_0x17e9fd[_0xd2d6('0x63')];var _0x3027cb=0xc8;var _0x114981=null;return db['sequelize'][_0xd2d6('0x8b')]({'isolationLevel':db[_0xd2d6('0x8c')][_0xd2d6('0x8d')][_0xd2d6('0x8e')]['READ_COMMITTED']},function(_0x32a2da){return db[_0xd2d6('0x5a')][_0xd2d6('0x6c')]({'where':{'id':_0x2d4d22},'transaction':_0x32a2da})[_0xd2d6('0x23')](function(_0x43db57){if(_0x43db57){return db[_0xd2d6('0x8f')][_0xd2d6('0x90')]({'where':{'MailAccountId':_0x2d4d22},'transaction':_0x32a2da})['then'](function(){var _0x2e1159=_[_0xd2d6('0x45')](_0x2078f5,function(_0x325803){_0x325803[_0xd2d6('0x68')]=_0x2d4d22;return _0x325803;});return db[_0xd2d6('0x8f')]['bulkCreate'](_0x2e1159,{'transaction':_0x32a2da});});}else{_0x3027cb=0x194;_0x114981=[];}});})[_0xd2d6('0x23')](function(){if(_0x3027cb!==0x194){return db[_0xd2d6('0x8f')][_0xd2d6('0x91')]({'where':{'MailAccountId':_0x2d4d22},'order':_0xd2d6('0x92')})[_0xd2d6('0x23')](function(_0x2ac13f){_0x114981=_0x2ac13f;});}})['catch'](function(_0x557fbb){_0x3027cb=0x1f4;logger['error'](_0x557fbb[_0xd2d6('0x27')]);if(_0x557fbb['name']){delete _0x557fbb[_0xd2d6('0x56')];}_0x114981=_0x557fbb;})['finally'](function(){if(_0x114981===null){_0x38d42e['sendStatus'](_0x3027cb);}else{if(_0x3027cb===0x1f4){_0x38d42e['status'](_0x3027cb)[_0xd2d6('0x93')](_0x114981);}else{_0x38d42e['status'](_0x3027cb)[_0xd2d6('0x1d')](_0x114981);}}});};exports[_0xd2d6('0x94')]=function(_0x17b865,_0x36c14c){var _0x342297={};var _0x4c237e={};var _0x413035;var _0x4aecdd;return db[_0xd2d6('0x5a')][_0xd2d6('0x6c')]({'where':{'id':_0x17b865[_0xd2d6('0x5d')]['id']}})[_0xd2d6('0x23')](handleEntityNotFound(_0x36c14c,null))[_0xd2d6('0x23')](function(_0x12f416){if(_0x12f416){_0x413035=_0x12f416;_0x4c237e[_0xd2d6('0x48')]=_[_0xd2d6('0x5f')](db[_0xd2d6('0x8f')][_0xd2d6('0x60')]);_0x4c237e['query']=_[_0xd2d6('0x5f')](_0x17b865[_0xd2d6('0x49')]);_0x4c237e[_0xd2d6('0x4a')]=_[_0xd2d6('0x4b')](_0x4c237e['model'],_0x4c237e[_0xd2d6('0x49')]);_0x342297['attributes']=_[_0xd2d6('0x4b')](_0x4c237e[_0xd2d6('0x48')],qs[_0xd2d6('0x61')](_0x17b865['query'][_0xd2d6('0x61')]));_0x342297[_0xd2d6('0x4c')]=_0x342297[_0xd2d6('0x4c')][_0xd2d6('0x4d')]?_0x342297['attributes']:_0x4c237e[_0xd2d6('0x48')];_0x342297[_0xd2d6('0x4f')]=qs['sort'](_0x17b865[_0xd2d6('0x49')][_0xd2d6('0x50')]);_0x342297['where']=qs[_0xd2d6('0x4a')](_[_0xd2d6('0x52')](_0x17b865[_0xd2d6('0x49')],_0x4c237e[_0xd2d6('0x4a')]));if(_0x17b865['query']['filter']){_0x342297['where']=_[_0xd2d6('0x54')](_0x342297[_0xd2d6('0x51')],{'$or':_['map'](_0x342297['attributes'],function(_0x4c6d13){var _0x24a8ac={};_0x24a8ac[_0x4c6d13]={'$like':'%'+_0x17b865[_0xd2d6('0x49')][_0xd2d6('0x53')]+'%'};return _0x24a8ac;})});}_0x342297=_[_0xd2d6('0x54')]({},_0x342297,_0x17b865[_0xd2d6('0x57')]);return _0x413035[_0xd2d6('0x94')](_0x342297);}})[_0xd2d6('0x23')](function(_0x208041){if(_0x208041){_0x4aecdd=_0x208041[_0xd2d6('0x4d')];if(!_0x17b865['query'][_0xd2d6('0x6d')]('nolimit')){_0x342297[_0xd2d6('0x21')]=qs[_0xd2d6('0x21')](_0x17b865[_0xd2d6('0x49')][_0xd2d6('0x21')]);_0x342297[_0xd2d6('0x1e')]=qs[_0xd2d6('0x1e')](_0x17b865[_0xd2d6('0x49')][_0xd2d6('0x1e')]);}return _0x413035['getApplications'](_0x342297);}})[_0xd2d6('0x23')](function(_0x2f7a2f){if(_0x2f7a2f){return _0x2f7a2f?{'count':_0x4aecdd,'rows':_0x2f7a2f}:null;}})[_0xd2d6('0x23')](respondWithResult(_0x36c14c,null))[_0xd2d6('0x19')](handleError(_0x36c14c,null));};exports['getMessages']=function(_0x373612,_0x3bf729){var _0x3b8693={'raw':!![],'where':{}};var _0x2f0481={};var _0x2bef9f={'count':0x0,'rows':[]};return db[_0xd2d6('0x5a')][_0xd2d6('0x6c')]({'where':{'id':_0x373612[_0xd2d6('0x5d')]['id']}})[_0xd2d6('0x23')](handleEntityNotFound(_0x3bf729,null))['then'](function(_0x558967){if(_0x558967){_0x2f0481[_0xd2d6('0x48')]=_[_0xd2d6('0x5f')](db[_0xd2d6('0x95')]['rawAttributes']);_0x2f0481['query']=_['keys'](_0x373612[_0xd2d6('0x49')]);_0x2f0481[_0xd2d6('0x4a')]=_['intersection'](_0x2f0481[_0xd2d6('0x48')],_0x2f0481[_0xd2d6('0x49')]);_0x3b8693['attributes']=_['intersection'](_0x2f0481[_0xd2d6('0x48')],qs[_0xd2d6('0x61')](_0x373612[_0xd2d6('0x49')][_0xd2d6('0x61')]));_0x3b8693[_0xd2d6('0x4c')]=_0x3b8693[_0xd2d6('0x4c')][_0xd2d6('0x4d')]?_0x3b8693[_0xd2d6('0x4c')]:_0x2f0481['model'];if(!_0x373612[_0xd2d6('0x49')][_0xd2d6('0x6d')](_0xd2d6('0x4e'))){_0x3b8693['limit']=qs[_0xd2d6('0x21')](_0x373612['query']['limit']);_0x3b8693['offset']=qs[_0xd2d6('0x1e')](_0x373612[_0xd2d6('0x49')][_0xd2d6('0x1e')]);}_0x3b8693[_0xd2d6('0x4f')]=qs['sort'](_0x373612[_0xd2d6('0x49')][_0xd2d6('0x50')]);_0x3b8693[_0xd2d6('0x51')]=qs[_0xd2d6('0x4a')](_['pick'](_0x373612[_0xd2d6('0x49')],_0x2f0481['filters']));_0x3b8693[_0xd2d6('0x51')][_0xd2d6('0x68')]=_0x558967['id'];if(_0x373612[_0xd2d6('0x49')][_0xd2d6('0x53')]){_0x3b8693[_0xd2d6('0x51')]=_[_0xd2d6('0x54')](_0x3b8693[_0xd2d6('0x51')],{'$or':_['map'](_0x3b8693[_0xd2d6('0x4c')],function(_0x355b12){var _0x24508d={};_0x24508d[_0x355b12]={'$like':'%'+_0x373612[_0xd2d6('0x49')]['filter']+'%'};return _0x24508d;})});}if(_0x373612[_0xd2d6('0x49')][_0xd2d6('0x96')]){var _0x2f8add=_0x373612['query']['$gte']['split'](',');var _0xf3a7de={};_0xf3a7de[_0x2f8add[0x0]]={'$gte':moment(_0x2f8add[0x1])[_0xd2d6('0x97')](_0xd2d6('0x98'))};_0x3b8693[_0xd2d6('0x51')]=_[_0xd2d6('0x54')](_0x3b8693[_0xd2d6('0x51')],_0xf3a7de);}_0x3b8693=_[_0xd2d6('0x54')]({},_0x3b8693,_0x373612[_0xd2d6('0x57')]);return db[_0xd2d6('0x95')][_0xd2d6('0x20')]({'where':_0x3b8693[_0xd2d6('0x51')]})[_0xd2d6('0x23')](function(_0x204a28){_0x2bef9f[_0xd2d6('0x20')]=_0x204a28;if(_0x373612['query'][_0xd2d6('0x58')]){_0x3b8693[_0xd2d6('0x59')]=[{'all':!![]}];}return db[_0xd2d6('0x95')][_0xd2d6('0x5b')](_0x3b8693);})[_0xd2d6('0x23')](function(_0x20677a){if(_0x373612[_0xd2d6('0x49')][_0xd2d6('0x99')]===_0xd2d6('0x9a')){for(var _0x29d46b=0x0;_0x29d46b<_0x20677a[_0xd2d6('0x4d')];_0x29d46b++){_0x20677a[_0x29d46b][_0xd2d6('0x63')]=juice(_0x20677a[_0x29d46b][_0xd2d6('0x63')]);}}_0x2bef9f[_0xd2d6('0x6e')]=_0x20677a;return _0x2bef9f;});}})['then'](respondWithFilteredResult(_0x3bf729,_0x3b8693))[_0xd2d6('0x19')](handleError(_0x3bf729,null));};exports[_0xd2d6('0x93')]=function(_0x2e925b,_0x3b3443){var _0x5a4cdd,_0x1d74a0={},_0x116a0d;if(_0x2e925b['body']['to']){_0x116a0d=_0x2e925b[_0xd2d6('0x63')]['to'][_0xd2d6('0x9b')](',')[0x0];}return db['MailAccount'][_0xd2d6('0x62')]({'where':{'id':_0x2e925b[_0xd2d6('0x5d')]['id']},'include':[{'model':db[_0xd2d6('0x9c')],'as':_0xd2d6('0x9d'),'include':[{'model':db[_0xd2d6('0x84')],'as':_0xd2d6('0x9e'),'where':{'email':_0x116a0d},'limit':0x1,'order':[[_0xd2d6('0x9f'),_0xd2d6('0xa0')]]}]},{'model':db[_0xd2d6('0x43')],'as':_0xd2d6('0x40'),'raw':!![],'include':[{'model':db[_0xd2d6('0xa1')],'as':'CloudProvider','raw':!![]}]}]})[_0xd2d6('0x23')](handleEntityNotFound(_0x3b3443,null))['then'](function(_0x15f1a7){if(!_0x15f1a7)return;_0x5a4cdd=_0x15f1a7;if(!_0x15f1a7[_0xd2d6('0x40')])throw new Error(_0xd2d6('0xa2'));if(_[_0xd2d6('0x74')](_0x2e925b[_0xd2d6('0x63')][_0xd2d6('0xa3')])){_0x2e925b[_0xd2d6('0x63')][_0xd2d6('0xa3')]=util[_0xd2d6('0x97')](_0xd2d6('0xa4'),_0x15f1a7[_0xd2d6('0x56')],_0x15f1a7['email']||_0x15f1a7[_0xd2d6('0x40')][_0xd2d6('0x34')]);}if(_0x2e925b['body'][_0xd2d6('0xa5')]&&_0x2e925b[_0xd2d6('0x63')][_0xd2d6('0xa5')]['length']){for(var _0x46dd44=0x0;_0x46dd44<_0x2e925b['body']['attachments']['length'];_0x46dd44+=0x1){_0x2e925b[_0xd2d6('0x63')][_0xd2d6('0xa5')][_0x46dd44]={'filename':_0x2e925b[_0xd2d6('0x63')]['attachments'][_0x46dd44][_0xd2d6('0x56')],'path':path[_0xd2d6('0xa6')](config['root'],'server/files/attachments',_0x2e925b['body'][_0xd2d6('0xa5')][_0x46dd44]['basename'])};}}var _0x33b7bb=_0x15f1a7[_0xd2d6('0xa7')]();return respondWithRpcPromise('SendMail','sendMail',{'account':_0x33b7bb,'message':_0x2e925b['body']});})[_0xd2d6('0x23')](function(_0xe5730a){if(!_0xe5730a)return;_0x1d74a0=_0xe5730a;if(!_0x5a4cdd[_0xd2d6('0x9d')])throw new Error(_0xd2d6('0xa8'));if(_0x5a4cdd[_0xd2d6('0x9d')][_0xd2d6('0x9e')][_0xd2d6('0x4d')])return _0x5a4cdd[_0xd2d6('0x9d')][_0xd2d6('0x9e')][0x0];return db[_0xd2d6('0x84')][_0xd2d6('0x6a')](_[_0xd2d6('0xa9')](_0x2e925b[_0xd2d6('0x63')],{'firstName':_0x2e925b[_0xd2d6('0x63')]['to'],'email':_0x2e925b[_0xd2d6('0x63')]['to'],'phone':_0x2e925b[_0xd2d6('0x63')]['to'],'ListId':_0x5a4cdd['ListId']}));})['then'](function(_0x70e6b2){if(!_0x70e6b2)return;var _0x39bbc4={'UserId':_0x2e925b[_0xd2d6('0x34')]['id'],'ContactId':_0x70e6b2['id'],'MailAccountId':_0x5a4cdd['id'],'inReplyTo':_0x1d74a0[_0xd2d6('0xaa')],'to':_0x2e925b[_0xd2d6('0x63')]['from'],'cc':_0x2e925b['body']['cc'],'subject':_0x2e925b[_0xd2d6('0x63')][_0xd2d6('0xab')],'attach':_0x2e925b['body']['attach'],'firstMsgDirection':'out','lastMsgAt':moment()[_0xd2d6('0x97')](_0xd2d6('0x98')),'lastMsgDirection':_0xd2d6('0xac'),'Messages':[_[_0xd2d6('0x54')](_0x2e925b[_0xd2d6('0x63')],{'messageId':_0x1d74a0[_0xd2d6('0xaa')],'sentAt':moment()['format'](_0xd2d6('0x98')),'read':!![],'MailAccountId':_0x5a4cdd['id'],'UserId':_0x2e925b[_0xd2d6('0x34')]['id'],'ContactId':_0x70e6b2['id']})]};if(_0x2e925b[_0xd2d6('0x63')]['Interaction']){_0x39bbc4=_[_0xd2d6('0x54')](_0x39bbc4,_0x2e925b[_0xd2d6('0x63')]['Interaction']);}return db['MailInteraction']['create'](_0x39bbc4,{'include':[{'model':db[_0xd2d6('0x95')],'as':_0xd2d6('0xad')}]});})[_0xd2d6('0x23')](respondWithResult(_0x3b3443,null))[_0xd2d6('0x19')](handleError(_0x3b3443,null));};exports[_0xd2d6('0xae')]=function(_0xeed1bc,_0x1362ca){return db[_0xd2d6('0x5a')][_0xd2d6('0x62')]({'where':{'id':_0xeed1bc[_0xd2d6('0x5d')]['id']},'include':[{'model':db[_0xd2d6('0x43')],'as':_0xd2d6('0x40'),'raw':!![],'include':[{'model':db[_0xd2d6('0xa1')],'as':_0xd2d6('0xa1'),'raw':!![]}]}]})[_0xd2d6('0x23')](handleEntityNotFound(_0x1362ca,null))[_0xd2d6('0x23')](function(_0x5a82b8){if(!_0x5a82b8[_0xd2d6('0x40')])return;var _0x5e0dc7=_0x5a82b8[_0xd2d6('0xa7')]();return respondWithRpcPromise(_0xd2d6('0xaf'),'verifySmtp',{'account':_0x5e0dc7});})['then'](respondWithResult(_0x1362ca,null))[_0xd2d6('0x19')](handleError(_0x1362ca,null));};exports['destroy']=function(_0x56e1b0,_0x5e9da0){return db[_0xd2d6('0x5a')]['find']({'where':{'id':_0x56e1b0['params']['id']}})[_0xd2d6('0x23')](handleEntityNotFound(_0x5e9da0,null))[_0xd2d6('0x23')](function(_0xa39333){if(_0xa39333&&_0xa39333[_0xd2d6('0x3d')]){throw new db[(_0xd2d6('0xb0'))]['ValidationError'](_0xd2d6('0xb1'));}return _0xa39333;})['then'](removeEntity(_0x5e9da0,null))[_0xd2d6('0x19')](handleError(_0x5e9da0,null));};exports[_0xd2d6('0xb2')]=function(_0x1feb06,_0x27c982){return db[_0xd2d6('0x5a')][_0xd2d6('0x62')]({'where':{'id':_0x1feb06['params']['id']}})[_0xd2d6('0x23')](handleEntityNotFound(_0x27c982,null))['then'](function(_0x5e56c6){if(_0x5e56c6){return _0x5e56c6[_0xd2d6('0xb2')](_0x1feb06[_0xd2d6('0x63')][_0xd2d6('0x70')],_[_0xd2d6('0x83')](_0x1feb06[_0xd2d6('0x63')],['ids','id'])||{})[_0xd2d6('0xb3')](function(_0x23ed72){for(var _0x165ca2=0x0;_0x165ca2<_0x1feb06['body'][_0xd2d6('0x70')][_0xd2d6('0x4d')];_0x165ca2+=0x1){socket[_0xd2d6('0xb4')](_0xd2d6('0xb5'),{'UserId':Number(_0x1feb06['body'][_0xd2d6('0x70')][_0x165ca2]),'MailAccountId':Number(_0x1feb06[_0xd2d6('0x5d')]['id'])});}return _0x23ed72;});}})[_0xd2d6('0x23')](respondWithResult(_0x27c982,null))[_0xd2d6('0x19')](handleError(_0x27c982,null));};exports['removeAgents']=function(_0x561dcb,_0x40c436){return db[_0xd2d6('0x5a')][_0xd2d6('0x62')]({'where':{'id':_0x561dcb[_0xd2d6('0x5d')]['id']}})['then'](handleEntityNotFound(_0x40c436,null))[_0xd2d6('0x23')](function(_0x2d79c4){if(_0x2d79c4){return _0x2d79c4['removeAgents'](_0x561dcb[_0xd2d6('0x49')][_0xd2d6('0x70')])['then'](function(){if(_['isArray'](_0x561dcb['query']['ids'])){for(var _0x1dd7e6=0x0;_0x1dd7e6<_0x561dcb[_0xd2d6('0x49')][_0xd2d6('0x70')]['length'];_0x1dd7e6+=0x1){socket[_0xd2d6('0xb4')]('userMailAccount:remove',{'UserId':Number(_0x561dcb['query'][_0xd2d6('0x70')][_0x1dd7e6]),'MailAccountId':Number(_0x561dcb[_0xd2d6('0x5d')]['id'])});}}else{socket['emit'](_0xd2d6('0xb6'),{'UserId':Number(_0x561dcb[_0xd2d6('0x49')][_0xd2d6('0x70')]),'MailAccountId':Number(_0x561dcb[_0xd2d6('0x5d')]['id'])});}});}})[_0xd2d6('0x23')](respondWithStatusCode(_0x40c436,null))[_0xd2d6('0x19')](handleError(_0x40c436,null));};exports[_0xd2d6('0xb7')]=function(_0x11a389,_0x1a1b32){var _0x52babe={};var _0x47b6d1={};var _0x3a32a4;var _0x240dd0;return db['MailAccount'][_0xd2d6('0x6c')]({'where':{'id':_0x11a389[_0xd2d6('0x5d')]['id']}})[_0xd2d6('0x23')](handleEntityNotFound(_0x1a1b32,null))[_0xd2d6('0x23')](function(_0x2863c9){if(_0x2863c9){_0x3a32a4=_0x2863c9;_0x47b6d1[_0xd2d6('0x48')]=_[_0xd2d6('0x5f')](db[_0xd2d6('0x85')][_0xd2d6('0x60')]);_0x47b6d1[_0xd2d6('0x49')]=_[_0xd2d6('0x5f')](_0x11a389['query']);_0x47b6d1['filters']=_[_0xd2d6('0x4b')](_0x47b6d1[_0xd2d6('0x48')],_0x47b6d1[_0xd2d6('0x49')]);_0x52babe[_0xd2d6('0x4c')]=_[_0xd2d6('0x4b')](_0x47b6d1[_0xd2d6('0x48')],qs[_0xd2d6('0x61')](_0x11a389['query'][_0xd2d6('0x61')]));_0x52babe[_0xd2d6('0x4c')]=_0x52babe[_0xd2d6('0x4c')][_0xd2d6('0x4d')]?_0x52babe[_0xd2d6('0x4c')]:_0x47b6d1[_0xd2d6('0x48')];_0x52babe['order']=qs[_0xd2d6('0x50')](_0x11a389[_0xd2d6('0x49')]['sort']);_0x52babe[_0xd2d6('0x51')]=qs[_0xd2d6('0x4a')](_[_0xd2d6('0x52')](_0x11a389[_0xd2d6('0x49')],_0x47b6d1[_0xd2d6('0x4a')]));if(_0x11a389[_0xd2d6('0x49')][_0xd2d6('0x53')]){_0x52babe[_0xd2d6('0x51')]=_[_0xd2d6('0x54')](_0x52babe['where'],{'$or':_[_0xd2d6('0x45')](_0x52babe[_0xd2d6('0x4c')],function(_0x2b0d08){var _0x224e7a={};_0x224e7a[_0x2b0d08]={'$like':'%'+_0x11a389[_0xd2d6('0x49')][_0xd2d6('0x53')]+'%'};return _0x224e7a;})});}_0x52babe=_[_0xd2d6('0x54')]({},_0x52babe,_0x11a389['options']);return _0x3a32a4[_0xd2d6('0xb7')](_0x52babe);}})[_0xd2d6('0x23')](function(_0x5546d7){if(_0x5546d7){_0x240dd0=_0x5546d7[_0xd2d6('0x4d')];if(!_0x11a389[_0xd2d6('0x49')][_0xd2d6('0x6d')](_0xd2d6('0x4e'))){_0x52babe[_0xd2d6('0x21')]=qs['limit'](_0x11a389[_0xd2d6('0x49')][_0xd2d6('0x21')]);_0x52babe['offset']=qs[_0xd2d6('0x1e')](_0x11a389[_0xd2d6('0x49')][_0xd2d6('0x1e')]);}return _0x3a32a4['getAgents'](_0x52babe);}})[_0xd2d6('0x23')](function(_0x4f486f){if(_0x4f486f){return _0x4f486f?{'count':_0x240dd0,'rows':_0x4f486f}:null;}})[_0xd2d6('0x23')](respondWithResult(_0x1a1b32,null))[_0xd2d6('0x19')](handleError(_0x1a1b32,null));};
\ No newline at end of file