Built motion from commit (unavailable).|2.5.7
[motion2.git] / server / api / mailAccount / mailAccount.controller.js
index e8cf8aa..ae9c1e5 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x98fc=['Owner','fullname','internal','Tag','Tags','tag','addApplications','sequelize','transaction','MailApplication','findAndCountAll','priority','getApplications','getMessages','$gte','format','YYYY-MM-DD\x20HH:mm:ss','MailMessage','send','CmList','Contacts','updatedAt','from','%s\x20<%s>','attachments','join','root','server/files/attachments','basename','auth','secure','SendMail','sendMail','List\x20not\x20found','List','subject','attach','out','messageId','Interaction','VerifySmtp','verifySmtp','ValidationError','You\x20can\x27t\x20remove\x20the\x20mail\x20service\x20account','addAgents','omit','spread','emit','removeAgents','isArray','userMailAccount:remove','getAgents','eml-format','rimraf','zip-dir','request-promise','bluebird','mustache','util','path','ejs','lodash','crypto','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','redis','localhost','socket.io-emitter','./mailAccount.socket','register','jayson/promise','client','request','then','info','MailAccount,\x20%s,\x20%s','request\x20sent','debug','MailAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message','catch','sendStatus','status','end','json','count','offset','limit','set','apply','reject','destroy','MailAccounts','UserProfileResource','stack','name','index','MailServerIn','Imap','MailServerOut','MailAccount','rawAttributes','fieldName','type','key','map','keys','query','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','includeAll','include','findAll','rows','Smtp','mandatoryDispositionPause','model','options','find','update','body','params','Pause','describe','addDisposition','MailAccountId','Disposition','create','getDispositions','findOne','removeDispositions','ids','addAnswer','CannedAnswer','removeAnswers','email','isNil','active','description','cservice','cuser','password','pass','authentication','port','host','service','cpassword','user','role','get','UserProfileSection','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','getImap','addImap','removeImap','setImap','getSmtp','removeSmtp','setSmtp','addInteraction','MailInteraction','getInteractions','CmContact','Contact','User'];(function(_0x45495a,_0x353d64){var _0xf6fb7c=function(_0x499820){while(--_0x499820){_0x45495a['push'](_0x45495a['shift']());}};_0xf6fb7c(++_0x353d64);}(_0x98fc,0x1b4));var _0xc98f=function(_0x179039,_0x1fb713){_0x179039=_0x179039-0x0;var _0xeb427=_0x98fc[_0x179039];return _0xeb427;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0xc98f('0x0'));var rimraf=require(_0xc98f('0x1'));var zipdir=require(_0xc98f('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0xc98f('0x3'));var moment=require('moment');var BPromise=require(_0xc98f('0x4'));var Mustache=require(_0xc98f('0x5'));var util=require(_0xc98f('0x6'));var path=require(_0xc98f('0x7'));var sox=require('sox');var csv=require('to-csv');var ejs=require(_0xc98f('0x8'));var fs=require('fs');var _=require(_0xc98f('0x9'));var squel=require('squel');var crypto=require(_0xc98f('0xa'));var jsforce=require('jsforce');var deskjs=require(_0xc98f('0xb'));var toCsv=require('to-csv');var querystring=require(_0xc98f('0xc'));var Papa=require(_0xc98f('0xd'));var Redis=require(_0xc98f('0xe'));var authService=require(_0xc98f('0xf'));var qs=require(_0xc98f('0x10'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xc98f('0x11'));var logger=require(_0xc98f('0x12'))(_0xc98f('0x13'));var utils=require(_0xc98f('0x14'));var config=require(_0xc98f('0x15'));var licenseUtil=require(_0xc98f('0x16'));var db=require('../../mysqldb')['db'];config[_0xc98f('0x17')]=_['defaults'](config['redis'],{'host':_0xc98f('0x18'),'port':0x18eb});var socket=require(_0xc98f('0x19'))(new Redis(config[_0xc98f('0x17')]));require(_0xc98f('0x1a'))[_0xc98f('0x1b')](socket);var jayson=require(_0xc98f('0x1c'));var client=jayson[_0xc98f('0x1d')]['http']({'port':0x232b});function respondWithRpcPromise(_0x3ae0b9,_0x38085d,_0x4835d6,_0x9ce1f8){return new BPromise(function(_0x56efc1,_0x28a2a6){var _0x1bb82f=_0x9ce1f8||client;return _0x1bb82f[_0xc98f('0x1e')](_0x3ae0b9,_0x4835d6)[_0xc98f('0x1f')](function(_0x2f6db0){logger[_0xc98f('0x20')](_0xc98f('0x21'),_0x38085d,_0xc98f('0x22'));logger[_0xc98f('0x23')](_0xc98f('0x24'),_0x38085d,'request\x20sent',JSON[_0xc98f('0x25')](_0x2f6db0));if(_0x2f6db0[_0xc98f('0x26')]){if(_0x2f6db0[_0xc98f('0x26')][_0xc98f('0x27')]===0x1f4){logger[_0xc98f('0x26')](_0xc98f('0x21'),_0x38085d,_0x2f6db0[_0xc98f('0x26')]['message']);return _0x28a2a6(_0x2f6db0['error']['message']);}logger[_0xc98f('0x26')](_0xc98f('0x21'),_0x38085d,_0x2f6db0['error']['message']);return _0x56efc1(_0x2f6db0[_0xc98f('0x26')][_0xc98f('0x28')]);}else{logger['info'](_0xc98f('0x21'),_0x38085d,_0xc98f('0x22'));_0x56efc1(_0x2f6db0['result'][_0xc98f('0x28')]);}})[_0xc98f('0x29')](function(_0x11743c){logger['error']('MailAccount,\x20%s,\x20%s',_0x38085d,_0x11743c);_0x28a2a6(_0x11743c);});});}function respondWithStatusCode(_0x1d0d32,_0x27831f){_0x27831f=_0x27831f||0xcc;return function(_0x26dbc6){if(_0x26dbc6){return _0x1d0d32[_0xc98f('0x2a')](_0x27831f);}return _0x1d0d32[_0xc98f('0x2b')](_0x27831f)[_0xc98f('0x2c')]();};}function respondWithResult(_0xd7da2f,_0x1c2b72){_0x1c2b72=_0x1c2b72||0xc8;return function(_0x5045d1){if(_0x5045d1){return _0xd7da2f[_0xc98f('0x2b')](_0x1c2b72)[_0xc98f('0x2d')](_0x5045d1);}};}function respondWithFilteredResult(_0x531fc6,_0x1a8486){return function(_0xc0a9c0){if(_0xc0a9c0){var _0x352fbc=_0xc0a9c0[_0xc98f('0x2e')],_0x5686e0=_0x1a8486[_0xc98f('0x2f')],_0x97182a=_0x1a8486[_0xc98f('0x2f')]+_0x1a8486[_0xc98f('0x30')],_0x41ca7a;if(_0x97182a>=_0x352fbc){_0x97182a=_0x352fbc;_0x41ca7a=0xc8;}else{_0x41ca7a=0xce;}_0x531fc6[_0xc98f('0x2b')](_0x41ca7a);return _0x531fc6[_0xc98f('0x31')]('Content-Range',_0x5686e0+'-'+_0x97182a+'/'+_0x352fbc)[_0xc98f('0x2d')](_0xc0a9c0);}return null;};}function patchUpdates(_0x5092f4){return function(_0x16ece8){try{jsonpatch[_0xc98f('0x32')](_0x16ece8,_0x5092f4,!![]);}catch(_0x35bce4){return BPromise[_0xc98f('0x33')](_0x35bce4);}return _0x16ece8['save']();};}function saveUpdates(_0x40d320,_0x58a1ba){return function(_0x5a17a8){if(_0x5a17a8){return _0x5a17a8['update'](_0x40d320)['then'](function(_0x538726){return _0x538726;});}return null;};}function removeEntity(_0x595dce,_0x2524e6){return function(_0x231778){if(_0x231778){return _0x231778[_0xc98f('0x34')]()[_0xc98f('0x1f')](function(){var _0x50e6fc=_0x231778['get']({'plain':!![]});var _0x46af2f=_0xc98f('0x35');return db[_0xc98f('0x36')][_0xc98f('0x34')]({'where':{'type':_0x46af2f,'resourceId':_0x50e6fc['id']}})[_0xc98f('0x1f')](function(){return _0x231778;});})[_0xc98f('0x1f')](function(){_0x595dce[_0xc98f('0x2b')](0xcc)['end']();});}};}function handleEntityNotFound(_0x4f0bf1,_0x140e9a){return function(_0x572caa){if(!_0x572caa){_0x4f0bf1[_0xc98f('0x2a')](0x194);}return _0x572caa;};}function handleError(_0x4b7632,_0x1e8d13){_0x1e8d13=_0x1e8d13||0x1f4;return function(_0x42b443){logger[_0xc98f('0x26')](_0x42b443[_0xc98f('0x37')]);if(_0x42b443[_0xc98f('0x38')]){delete _0x42b443['name'];}_0x4b7632['status'](_0x1e8d13)['send'](_0x42b443);};}exports[_0xc98f('0x39')]=function(_0x28851c,_0x5e6b38){var _0x27cf0e={'include':[{'model':db[_0xc98f('0x3a')],'as':_0xc98f('0x3b')},{'model':db[_0xc98f('0x3c')],'as':'Smtp'},{'model':db['Pause'],'as':'mandatoryDispositionPause'}]},_0x518f3f={},_0x5efd98={'count':0x0,'rows':[]};var _0x3acc03=_['map'](db[_0xc98f('0x3d')][_0xc98f('0x3e')],function(_0x2a2729){return{'name':_0x2a2729[_0xc98f('0x3f')],'type':_0x2a2729[_0xc98f('0x40')][_0xc98f('0x41')]};});_0x518f3f['model']=_[_0xc98f('0x42')](_0x3acc03,_0xc98f('0x38'));_0x518f3f['query']=_[_0xc98f('0x43')](_0x28851c[_0xc98f('0x44')]);_0x518f3f[_0xc98f('0x45')]=_[_0xc98f('0x46')](_0x518f3f['model'],_0x518f3f['query']);_0x27cf0e[_0xc98f('0x47')]=_[_0xc98f('0x46')](_0x518f3f['model'],qs[_0xc98f('0x48')](_0x28851c['query'][_0xc98f('0x48')]));_0x27cf0e['attributes']=_0x27cf0e[_0xc98f('0x47')][_0xc98f('0x49')]?_0x27cf0e[_0xc98f('0x47')]:_0x518f3f['model'];if(!_0x28851c[_0xc98f('0x44')][_0xc98f('0x4a')](_0xc98f('0x4b'))){_0x27cf0e['limit']=qs[_0xc98f('0x30')](_0x28851c[_0xc98f('0x44')]['limit']);_0x27cf0e[_0xc98f('0x2f')]=qs['offset'](_0x28851c[_0xc98f('0x44')][_0xc98f('0x2f')]);}_0x27cf0e[_0xc98f('0x4c')]=qs[_0xc98f('0x4d')](_0x28851c[_0xc98f('0x44')]['sort']);_0x27cf0e[_0xc98f('0x4e')]=qs[_0xc98f('0x45')](_[_0xc98f('0x4f')](_0x28851c[_0xc98f('0x44')],_0x518f3f[_0xc98f('0x45')]),_0x3acc03);if(_0x28851c[_0xc98f('0x44')][_0xc98f('0x50')]){_0x27cf0e[_0xc98f('0x4e')]=_[_0xc98f('0x51')](_0x27cf0e[_0xc98f('0x4e')],{'$or':_[_0xc98f('0x42')](_0x3acc03,function(_0xc28e14){if(_0xc28e14['type']!==_0xc98f('0x52')){var _0x286d9e={};_0x286d9e[_0xc28e14[_0xc98f('0x38')]]={'$like':'%'+_0x28851c[_0xc98f('0x44')][_0xc98f('0x50')]+'%'};return _0x286d9e;}})});}_0x27cf0e=_[_0xc98f('0x51')]({},_0x27cf0e,_0x28851c['options']);var _0x18eb31={'where':_0x27cf0e[_0xc98f('0x4e')]};return db[_0xc98f('0x3d')][_0xc98f('0x2e')](_0x18eb31)[_0xc98f('0x1f')](function(_0x5ddf21){_0x5efd98[_0xc98f('0x2e')]=_0x5ddf21;if(_0x28851c[_0xc98f('0x44')][_0xc98f('0x53')]){_0x27cf0e[_0xc98f('0x54')]=[{'all':!![]}];}return db[_0xc98f('0x3d')][_0xc98f('0x55')](_0x27cf0e);})[_0xc98f('0x1f')](function(_0x4fde57){_0x5efd98[_0xc98f('0x56')]=_0x4fde57;return _0x5efd98;})[_0xc98f('0x1f')](respondWithFilteredResult(_0x5e6b38,_0x27cf0e))[_0xc98f('0x29')](handleError(_0x5e6b38,null));};exports['show']=function(_0x44005a,_0x20a272){var _0x2fcbfe={'raw':![],'where':{'id':_0x44005a['params']['id']},'include':[{'model':db[_0xc98f('0x3a')],'as':'Imap'},{'model':db[_0xc98f('0x3c')],'as':_0xc98f('0x57')},{'model':db['Pause'],'as':_0xc98f('0x58')}]},_0x3e821e={};_0x3e821e[_0xc98f('0x59')]=_[_0xc98f('0x43')](db['MailAccount'][_0xc98f('0x3e')]);_0x3e821e[_0xc98f('0x44')]=_[_0xc98f('0x43')](_0x44005a[_0xc98f('0x44')]);_0x3e821e[_0xc98f('0x45')]=_[_0xc98f('0x46')](_0x3e821e[_0xc98f('0x59')],_0x3e821e[_0xc98f('0x44')]);_0x2fcbfe[_0xc98f('0x47')]=_['intersection'](_0x3e821e[_0xc98f('0x59')],qs[_0xc98f('0x48')](_0x44005a[_0xc98f('0x44')]['fields']));_0x2fcbfe[_0xc98f('0x47')]=_0x2fcbfe[_0xc98f('0x47')]['length']?_0x2fcbfe[_0xc98f('0x47')]:_0x3e821e[_0xc98f('0x59')];if(_0x44005a[_0xc98f('0x44')][_0xc98f('0x53')]){_0x2fcbfe['include']=[{'all':!![]}];}_0x2fcbfe=_[_0xc98f('0x51')]({},_0x2fcbfe,_0x44005a[_0xc98f('0x5a')]);return db['MailAccount'][_0xc98f('0x5b')](_0x2fcbfe)[_0xc98f('0x1f')](handleEntityNotFound(_0x20a272,null))[_0xc98f('0x1f')](respondWithResult(_0x20a272,null))[_0xc98f('0x29')](handleError(_0x20a272,null));};exports[_0xc98f('0x5c')]=function(_0x57127a,_0x17d2b4){if(_0x57127a[_0xc98f('0x5d')]['id']){delete _0x57127a[_0xc98f('0x5d')]['id'];}return db['MailAccount'][_0xc98f('0x5b')]({'where':{'id':_0x57127a[_0xc98f('0x5e')]['id']},'include':[{'model':db['MailServerIn'],'as':_0xc98f('0x3b')},{'model':db[_0xc98f('0x3c')],'as':_0xc98f('0x57')},{'model':db[_0xc98f('0x5f')],'as':_0xc98f('0x58')}]})[_0xc98f('0x1f')](handleEntityNotFound(_0x17d2b4,null))['then'](saveUpdates(_0x57127a[_0xc98f('0x5d')],null))[_0xc98f('0x1f')](function(_0x61c8e2){if(_0x61c8e2&&_0x57127a[_0xc98f('0x5d')][_0xc98f('0x3b')]){return db[_0xc98f('0x3a')]['update'](_0x57127a['body'][_0xc98f('0x3b')],{'where':{'MailAccountId':_0x61c8e2['id']}})[_0xc98f('0x1f')](function(){return _0x61c8e2;});}return _0x61c8e2;})[_0xc98f('0x1f')](function(_0x2217b3){if(_0x2217b3&&_0x57127a['body'][_0xc98f('0x57')]){return db[_0xc98f('0x3c')][_0xc98f('0x5c')](_0x57127a[_0xc98f('0x5d')][_0xc98f('0x57')],{'where':{'MailAccountId':_0x2217b3['id']}})[_0xc98f('0x1f')](function(){return _0x2217b3;});}return _0x2217b3;})[_0xc98f('0x1f')](respondWithResult(_0x17d2b4,null))[_0xc98f('0x29')](handleError(_0x17d2b4,null));};exports['describe']=function(_0x514bfe,_0x4c1cb1){return db[_0xc98f('0x3d')][_0xc98f('0x60')]()[_0xc98f('0x1f')](respondWithResult(_0x4c1cb1,null))[_0xc98f('0x29')](handleError(_0x4c1cb1,null));};exports[_0xc98f('0x61')]=function(_0x3f884a,_0x35f30a,_0x158edc){if(_0x3f884a[_0xc98f('0x5d')]['id']){delete _0x3f884a[_0xc98f('0x5d')]['id'];}return db['MailAccount'][_0xc98f('0x5b')]({'where':{'id':_0x3f884a[_0xc98f('0x5e')]['id']}})[_0xc98f('0x1f')](handleEntityNotFound(_0x35f30a,null))['then'](function(_0x4be1bb){if(_0x4be1bb){_0x3f884a[_0xc98f('0x5d')][_0xc98f('0x62')]=_0x4be1bb['id'];return db[_0xc98f('0x63')][_0xc98f('0x64')](_0x3f884a['body']);}})[_0xc98f('0x1f')](respondWithResult(_0x35f30a,null))['catch'](handleError(_0x35f30a,null));};exports[_0xc98f('0x65')]=function(_0x1dada9,_0x55d03e,_0x277a59){var _0x207a62={'raw':![],'where':{}};var _0x13b2c3={};var _0xf8da89={'count':0x0,'rows':[]};return db[_0xc98f('0x3d')][_0xc98f('0x66')]({'where':{'id':_0x1dada9[_0xc98f('0x5e')]['id']}})[_0xc98f('0x1f')](handleEntityNotFound(_0x55d03e,null))[_0xc98f('0x1f')](function(_0x326b88){if(_0x326b88){_0x13b2c3['model']=_['keys'](db[_0xc98f('0x63')][_0xc98f('0x3e')]);_0x13b2c3['query']=_[_0xc98f('0x43')](_0x1dada9[_0xc98f('0x44')]);_0x13b2c3[_0xc98f('0x45')]=_['intersection'](_0x13b2c3[_0xc98f('0x59')],_0x13b2c3['query']);_0x207a62[_0xc98f('0x47')]=_[_0xc98f('0x46')](_0x13b2c3['model'],qs[_0xc98f('0x48')](_0x1dada9['query'][_0xc98f('0x48')]));_0x207a62[_0xc98f('0x47')]=_0x207a62['attributes'][_0xc98f('0x49')]?_0x207a62[_0xc98f('0x47')]:_0x13b2c3[_0xc98f('0x59')];if(!_0x1dada9['query']['hasOwnProperty'](_0xc98f('0x4b'))){_0x207a62[_0xc98f('0x30')]=qs[_0xc98f('0x30')](_0x1dada9[_0xc98f('0x44')]['limit']);_0x207a62[_0xc98f('0x2f')]=qs[_0xc98f('0x2f')](_0x1dada9[_0xc98f('0x44')][_0xc98f('0x2f')]);}_0x207a62[_0xc98f('0x4c')]=qs[_0xc98f('0x4d')](_0x1dada9[_0xc98f('0x44')][_0xc98f('0x4d')]);_0x207a62[_0xc98f('0x4e')]=qs[_0xc98f('0x45')](_[_0xc98f('0x4f')](_0x1dada9[_0xc98f('0x44')],_0x13b2c3[_0xc98f('0x45')]));_0x207a62[_0xc98f('0x4e')][_0xc98f('0x62')]=_0x326b88['id'];if(_0x1dada9[_0xc98f('0x44')]['filter']){_0x207a62[_0xc98f('0x4e')]=_[_0xc98f('0x51')](_0x207a62['where'],{'$or':_[_0xc98f('0x42')](_0x207a62[_0xc98f('0x47')],function(_0x581048){var _0xb62e5e={};_0xb62e5e[_0x581048]={'$like':'%'+_0x1dada9[_0xc98f('0x44')][_0xc98f('0x50')]+'%'};return _0xb62e5e;})});}_0x207a62=_['merge']({},_0x207a62,_0x1dada9['options']);return db['Disposition'][_0xc98f('0x2e')]({'where':_0x207a62[_0xc98f('0x4e')]})[_0xc98f('0x1f')](function(_0x2dc62b){_0xf8da89[_0xc98f('0x2e')]=_0x2dc62b;if(_0x1dada9['query'][_0xc98f('0x53')]){_0x207a62[_0xc98f('0x54')]=[{'all':!![]}];}return db[_0xc98f('0x63')][_0xc98f('0x55')](_0x207a62);})[_0xc98f('0x1f')](function(_0x44c7e3){_0xf8da89[_0xc98f('0x56')]=_0x44c7e3;return _0xf8da89;});}})[_0xc98f('0x1f')](respondWithFilteredResult(_0x55d03e,_0x207a62))[_0xc98f('0x29')](handleError(_0x55d03e,null));};exports['removeDispositions']=function(_0x59a493,_0xe61d24,_0x1c1349){return db[_0xc98f('0x3d')]['find']({'where':{'id':_0x59a493[_0xc98f('0x5e')]['id']}})['then'](handleEntityNotFound(_0xe61d24,null))['then'](function(_0x26790d){if(_0x26790d){return _0x26790d[_0xc98f('0x67')](_0x59a493[_0xc98f('0x44')][_0xc98f('0x68')]);}})['then'](respondWithStatusCode(_0xe61d24,null))['catch'](handleError(_0xe61d24,null));};exports[_0xc98f('0x69')]=function(_0x732b6a,_0x2fbc6a,_0x1c2bd3){if(_0x732b6a[_0xc98f('0x5d')]['id']){delete _0x732b6a[_0xc98f('0x5d')]['id'];}return db[_0xc98f('0x3d')][_0xc98f('0x5b')]({'where':{'id':_0x732b6a[_0xc98f('0x5e')]['id']}})['then'](handleEntityNotFound(_0x2fbc6a,null))[_0xc98f('0x1f')](function(_0x1accd7){if(_0x1accd7){_0x732b6a[_0xc98f('0x5d')][_0xc98f('0x62')]=_0x1accd7['id'];return db[_0xc98f('0x6a')][_0xc98f('0x64')](_0x732b6a['body']);}})[_0xc98f('0x1f')](respondWithResult(_0x2fbc6a,null))[_0xc98f('0x29')](handleError(_0x2fbc6a,null));};exports['getAnswers']=function(_0x23fda3,_0x3e3a20,_0x1317dd){var _0x3340e1={'raw':![],'where':{}};var _0x4c81ca={};var _0x2088be={'count':0x0,'rows':[]};return db[_0xc98f('0x3d')][_0xc98f('0x66')]({'where':{'id':_0x23fda3[_0xc98f('0x5e')]['id']}})[_0xc98f('0x1f')](handleEntityNotFound(_0x3e3a20,null))['then'](function(_0x2cf211){if(_0x2cf211){_0x4c81ca['model']=_[_0xc98f('0x43')](db['CannedAnswer'][_0xc98f('0x3e')]);_0x4c81ca[_0xc98f('0x44')]=_[_0xc98f('0x43')](_0x23fda3[_0xc98f('0x44')]);_0x4c81ca[_0xc98f('0x45')]=_['intersection'](_0x4c81ca['model'],_0x4c81ca[_0xc98f('0x44')]);_0x3340e1['attributes']=_[_0xc98f('0x46')](_0x4c81ca[_0xc98f('0x59')],qs[_0xc98f('0x48')](_0x23fda3[_0xc98f('0x44')][_0xc98f('0x48')]));_0x3340e1[_0xc98f('0x47')]=_0x3340e1[_0xc98f('0x47')][_0xc98f('0x49')]?_0x3340e1[_0xc98f('0x47')]:_0x4c81ca[_0xc98f('0x59')];if(!_0x23fda3[_0xc98f('0x44')][_0xc98f('0x4a')](_0xc98f('0x4b'))){_0x3340e1[_0xc98f('0x30')]=qs[_0xc98f('0x30')](_0x23fda3[_0xc98f('0x44')][_0xc98f('0x30')]);_0x3340e1['offset']=qs[_0xc98f('0x2f')](_0x23fda3[_0xc98f('0x44')][_0xc98f('0x2f')]);}_0x3340e1['order']=qs[_0xc98f('0x4d')](_0x23fda3['query'][_0xc98f('0x4d')]);_0x3340e1[_0xc98f('0x4e')]=qs[_0xc98f('0x45')](_['pick'](_0x23fda3[_0xc98f('0x44')],_0x4c81ca[_0xc98f('0x45')]));_0x3340e1[_0xc98f('0x4e')]['MailAccountId']=_0x2cf211['id'];if(_0x23fda3['query'][_0xc98f('0x50')]){_0x3340e1[_0xc98f('0x4e')]=_[_0xc98f('0x51')](_0x3340e1[_0xc98f('0x4e')],{'$or':_[_0xc98f('0x42')](_0x3340e1[_0xc98f('0x47')],function(_0x5293e9){var _0x2f7ad0={};_0x2f7ad0[_0x5293e9]={'$like':'%'+_0x23fda3[_0xc98f('0x44')]['filter']+'%'};return _0x2f7ad0;})});}_0x3340e1=_[_0xc98f('0x51')]({},_0x3340e1,_0x23fda3[_0xc98f('0x5a')]);return db[_0xc98f('0x6a')][_0xc98f('0x2e')]({'where':_0x3340e1[_0xc98f('0x4e')]})[_0xc98f('0x1f')](function(_0x48e0ce){_0x2088be[_0xc98f('0x2e')]=_0x48e0ce;if(_0x23fda3[_0xc98f('0x44')]['includeAll']){_0x3340e1['include']=[{'all':!![]}];}return db['CannedAnswer'][_0xc98f('0x55')](_0x3340e1);})[_0xc98f('0x1f')](function(_0x2c0d21){_0x2088be[_0xc98f('0x56')]=_0x2c0d21;return _0x2088be;});}})['then'](respondWithFilteredResult(_0x3e3a20,_0x3340e1))[_0xc98f('0x29')](handleError(_0x3e3a20,null));};exports[_0xc98f('0x6b')]=function(_0x293f95,_0x137273,_0x24ef12){return db[_0xc98f('0x3d')]['find']({'where':{'id':_0x293f95[_0xc98f('0x5e')]['id']}})['then'](handleEntityNotFound(_0x137273,null))['then'](function(_0x3a6322){if(_0x3a6322){return _0x3a6322[_0xc98f('0x6b')](_0x293f95[_0xc98f('0x44')][_0xc98f('0x68')]);}})['then'](respondWithStatusCode(_0x137273,null))[_0xc98f('0x29')](handleError(_0x137273,null));};exports[_0xc98f('0x64')]=function(_0x1f6943,_0x219236){var _0x530291={'name':_0x1f6943[_0xc98f('0x5d')][_0xc98f('0x38')],'key':_0x1f6943['body']['key'],'email':_0x1f6943[_0xc98f('0x5d')][_0xc98f('0x6c')],'ListId':_0x1f6943[_0xc98f('0x5d')]['ListId'],'active':!_[_0xc98f('0x6d')](_0x1f6943[_0xc98f('0x5d')]['active'])?_0x1f6943['body'][_0xc98f('0x6e')]:!![],'description':_0x1f6943[_0xc98f('0x5d')][_0xc98f('0x6f')]||null,'Imap':{},'Smtp':{}};if(_['isNil'](_0x1f6943['body'][_0xc98f('0x70')])){if(_0x1f6943['body']['cauthentication']){_0x530291['Imap']['user']=_0x530291[_0xc98f('0x57')]['user']=_0x1f6943[_0xc98f('0x5d')][_0xc98f('0x71')];_0x530291[_0xc98f('0x3b')][_0xc98f('0x72')]=_0x530291[_0xc98f('0x57')][_0xc98f('0x73')]=_0x1f6943['body']['cpassword'];}else{_0x530291[_0xc98f('0x3b')][_0xc98f('0x74')]=_0x530291['Smtp'][_0xc98f('0x74')]=![];}_0x530291[_0xc98f('0x3b')]['host']=_0x1f6943[_0xc98f('0x5d')][_0xc98f('0x3b')]['host'];_0x530291['Imap']['port']=_0x1f6943[_0xc98f('0x5d')][_0xc98f('0x3b')][_0xc98f('0x75')];_0x530291[_0xc98f('0x57')][_0xc98f('0x76')]=_0x1f6943[_0xc98f('0x5d')][_0xc98f('0x57')][_0xc98f('0x76')];_0x530291[_0xc98f('0x57')]['port']=_0x1f6943[_0xc98f('0x5d')][_0xc98f('0x57')][_0xc98f('0x75')];}else{_0x530291['Imap'][_0xc98f('0x77')]=_0x530291[_0xc98f('0x57')][_0xc98f('0x77')]=_0x1f6943[_0xc98f('0x5d')]['cservice'];_0x530291['Imap']['user']=_0x530291[_0xc98f('0x57')]['user']=_0x1f6943[_0xc98f('0x5d')][_0xc98f('0x71')];_0x530291[_0xc98f('0x3b')][_0xc98f('0x72')]=_0x530291[_0xc98f('0x57')][_0xc98f('0x73')]=_0x1f6943['body'][_0xc98f('0x78')];}return db[_0xc98f('0x3d')][_0xc98f('0x64')](_0x530291,{'include':[{'model':db[_0xc98f('0x3c')],'as':_0xc98f('0x57')},{'model':db[_0xc98f('0x3a')],'as':_0xc98f('0x3b')}]})[_0xc98f('0x1f')](function(_0xcc7492){var _0x114ad1=_0x1f6943[_0xc98f('0x79')]['get']({'plain':!![]});if(!_0x114ad1)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x114ad1[_0xc98f('0x7a')]===_0xc98f('0x79')){var _0x1812e9=_0xcc7492[_0xc98f('0x7b')]({'plain':!![]});return db[_0xc98f('0x7c')][_0xc98f('0x5b')]({'where':{'name':'MailAccounts','userProfileId':_0x114ad1['userProfileId']},'raw':!![]})[_0xc98f('0x1f')](function(_0x4bc5c0){if(_0x4bc5c0&&_0x4bc5c0[_0xc98f('0x7d')]===0x0){return db['UserProfileResource'][_0xc98f('0x64')]({'name':_0x1812e9[_0xc98f('0x38')],'resourceId':_0x1812e9['id'],'type':_0x4bc5c0[_0xc98f('0x38')],'sectionId':_0x4bc5c0['id']},{})[_0xc98f('0x1f')](function(){return _0xcc7492;});}else{return _0xcc7492;}})[_0xc98f('0x29')](function(_0x4085cf){logger[_0xc98f('0x26')](_0xc98f('0x7e'),_0x4085cf);throw _0x4085cf;});}return _0xcc7492;})[_0xc98f('0x1f')](respondWithResult(_0x219236,0xc9))['catch'](handleError(_0x219236,null));};exports['getImap']=function(_0x4f59d7,_0x3c3e4d,_0x1ca856){return db[_0xc98f('0x3d')][_0xc98f('0x66')]({'where':{'id':_0x4f59d7[_0xc98f('0x5e')]['id']}})[_0xc98f('0x1f')](handleEntityNotFound(_0x3c3e4d,null))[_0xc98f('0x1f')](function(_0x318ec7){if(_0x318ec7){return _0x318ec7[_0xc98f('0x7f')]();}return null;})[_0xc98f('0x1f')](respondWithResult(_0x3c3e4d,null))[_0xc98f('0x29')](handleError(_0x3c3e4d,null));};exports[_0xc98f('0x80')]=function(_0x5ec142,_0x4fedd8,_0x489855){if(_0x5ec142['body']['id']){delete _0x5ec142[_0xc98f('0x5d')]['id'];}return db['MailAccount']['find']({'where':{'id':_0x5ec142['params']['id']}})[_0xc98f('0x1f')](handleEntityNotFound(_0x4fedd8,null))[_0xc98f('0x1f')](function(_0x1c6fdd){if(_0x1c6fdd){_0x5ec142[_0xc98f('0x5d')]['MailAccountId']=_0x1c6fdd['id'];return db['MailServerIn'][_0xc98f('0x64')](_0x5ec142[_0xc98f('0x5d')]);}})[_0xc98f('0x1f')](respondWithResult(_0x4fedd8,null))[_0xc98f('0x29')](handleError(_0x4fedd8,null));};exports[_0xc98f('0x81')]=function(_0x6f8ea6,_0x1ced9d,_0x11ab2d){return db[_0xc98f('0x3d')][_0xc98f('0x66')]({'where':{'id':_0x6f8ea6[_0xc98f('0x5e')]['id']}})[_0xc98f('0x1f')](handleEntityNotFound(_0x1ced9d,null))[_0xc98f('0x1f')](function(_0x558ee1){if(_0x558ee1){return _0x558ee1[_0xc98f('0x82')](null);}return null;})[_0xc98f('0x1f')](respondWithStatusCode(_0x1ced9d,null))[_0xc98f('0x29')](handleError(_0x1ced9d,null));};exports[_0xc98f('0x83')]=function(_0x1ed44c,_0x12bbc0,_0x24a64e){return db[_0xc98f('0x3d')]['findOne']({'where':{'id':_0x1ed44c['params']['id']}})['then'](handleEntityNotFound(_0x12bbc0,null))[_0xc98f('0x1f')](function(_0x4bb317){if(_0x4bb317){return _0x4bb317[_0xc98f('0x83')]();}return null;})[_0xc98f('0x1f')](respondWithResult(_0x12bbc0,null))['catch'](handleError(_0x12bbc0,null));};exports['addSmtp']=function(_0x198600,_0x5adc5f,_0x54585f){if(_0x198600['body']['id']){delete _0x198600[_0xc98f('0x5d')]['id'];}return db[_0xc98f('0x3d')]['find']({'where':{'id':_0x198600[_0xc98f('0x5e')]['id']}})['then'](handleEntityNotFound(_0x5adc5f,null))['then'](function(_0x5a37af){if(_0x5a37af){_0x198600['body'][_0xc98f('0x62')]=_0x5a37af['id'];return db[_0xc98f('0x3c')]['create'](_0x198600['body']);}})[_0xc98f('0x1f')](respondWithResult(_0x5adc5f,null))[_0xc98f('0x29')](handleError(_0x5adc5f,null));};exports[_0xc98f('0x84')]=function(_0x180e02,_0x396b80,_0xdb03ad){return db[_0xc98f('0x3d')][_0xc98f('0x66')]({'where':{'id':_0x180e02['params']['id']}})['then'](handleEntityNotFound(_0x396b80,null))[_0xc98f('0x1f')](function(_0x5236b1){if(_0x5236b1){return _0x5236b1[_0xc98f('0x85')](null);}return null;})[_0xc98f('0x1f')](respondWithStatusCode(_0x396b80,null))[_0xc98f('0x29')](handleError(_0x396b80,null));};exports[_0xc98f('0x86')]=function(_0x200ecf,_0x1b0322,_0x3623d2){return db[_0xc98f('0x87')][_0xc98f('0x5b')]({'where':{'id':_0x200ecf[_0xc98f('0x5e')]['id']}})[_0xc98f('0x1f')](handleEntityNotFound(_0x1b0322,null))[_0xc98f('0x1f')](function(_0xa54e8){if(_0xa54e8){return _0xa54e8[_0xc98f('0x86')](_0x200ecf['body'][_0xc98f('0x68')],_['omit'](_0x200ecf[_0xc98f('0x5d')],[_0xc98f('0x68'),'id'])||{});}})[_0xc98f('0x1f')](respondWithResult(_0x1b0322,null))[_0xc98f('0x29')](handleError(_0x1b0322,null));};exports[_0xc98f('0x88')]=function(_0x1d645a,_0x1666fc,_0xd4a190){var _0x3c75b3={'raw':![],'where':{}};var _0x17d012={};var _0x4fb4ac={'count':0x0,'rows':[]};return db[_0xc98f('0x3d')][_0xc98f('0x66')]({'where':{'id':_0x1d645a['params']['id']}})[_0xc98f('0x1f')](handleEntityNotFound(_0x1666fc,null))[_0xc98f('0x1f')](function(_0x169534){if(_0x169534){_0x17d012[_0xc98f('0x59')]=_['keys'](db[_0xc98f('0x87')][_0xc98f('0x3e')]);_0x17d012[_0xc98f('0x44')]=_['keys'](_0x1d645a[_0xc98f('0x44')]);_0x17d012['filters']=_['intersection'](_0x17d012['model'],_0x17d012['query']);_0x3c75b3[_0xc98f('0x47')]=_[_0xc98f('0x46')](_0x17d012[_0xc98f('0x59')],qs[_0xc98f('0x48')](_0x1d645a[_0xc98f('0x44')][_0xc98f('0x48')]));_0x3c75b3[_0xc98f('0x47')]=_0x3c75b3[_0xc98f('0x47')][_0xc98f('0x49')]?_0x3c75b3[_0xc98f('0x47')]:_0x17d012[_0xc98f('0x59')];if(!_0x1d645a[_0xc98f('0x44')][_0xc98f('0x4a')](_0xc98f('0x4b'))){_0x3c75b3[_0xc98f('0x30')]=qs[_0xc98f('0x30')](_0x1d645a[_0xc98f('0x44')]['limit']);_0x3c75b3['offset']=qs[_0xc98f('0x2f')](_0x1d645a[_0xc98f('0x44')]['offset']);}_0x3c75b3['order']=qs['sort'](_0x1d645a[_0xc98f('0x44')]['sort']);_0x3c75b3[_0xc98f('0x4e')]=qs['filters'](_[_0xc98f('0x4f')](_0x1d645a[_0xc98f('0x44')],_0x17d012[_0xc98f('0x45')]));_0x3c75b3['where'][_0xc98f('0x62')]=_0x169534['id'];if(_0x1d645a['query'][_0xc98f('0x50')]){_0x3c75b3[_0xc98f('0x4e')]=_[_0xc98f('0x51')](_0x3c75b3['where'],{'$or':_[_0xc98f('0x42')](_0x3c75b3[_0xc98f('0x47')],function(_0x3dc27e){var _0x73d1d1={};_0x73d1d1[_0x3dc27e]={'$like':'%'+_0x1d645a['query'][_0xc98f('0x50')]+'%'};return _0x73d1d1;})});}_0x3c75b3=_['merge']({},_0x3c75b3,_0x1d645a['options']);return db[_0xc98f('0x87')]['count']({'where':_0x3c75b3[_0xc98f('0x4e')]})[_0xc98f('0x1f')](function(_0x332119){_0x4fb4ac[_0xc98f('0x2e')]=_0x332119;if(_0x1d645a[_0xc98f('0x44')][_0xc98f('0x53')]){_0x3c75b3[_0xc98f('0x54')]=[{'model':db[_0xc98f('0x89')],'as':_0xc98f('0x8a'),'required':![]},{'model':db[_0xc98f('0x8b')],'as':_0xc98f('0x8c'),'attributes':[_0xc98f('0x38'),_0xc98f('0x8d'),_0xc98f('0x8e')],'required':![]},{'model':db[_0xc98f('0x8f')],'as':_0xc98f('0x90'),'attributes':['id','name','color'],'where':_0x1d645a['query']['tag']?{'id':_0x1d645a[_0xc98f('0x44')][_0xc98f('0x91')]}:undefined,'required':_0x1d645a['query'][_0xc98f('0x91')]?!![]:![]}];}return db[_0xc98f('0x87')][_0xc98f('0x55')](_0x3c75b3);})[_0xc98f('0x1f')](function(_0xae14d9){_0x4fb4ac['rows']=_0xae14d9;return _0x4fb4ac;});}})['then'](respondWithFilteredResult(_0x1666fc,_0x3c75b3))[_0xc98f('0x29')](handleError(_0x1666fc,null));};exports[_0xc98f('0x92')]=function(_0x31dcde,_0x5bd883,_0x21b844){return db[_0xc98f('0x3d')][_0xc98f('0x66')]({'where':{'id':_0x31dcde[_0xc98f('0x5e')]['id']}})[_0xc98f('0x1f')](handleEntityNotFound(_0x5bd883,null))[_0xc98f('0x1f')](function(_0x5ded12){if(_0x5ded12){return db[_0xc98f('0x93')][_0xc98f('0x94')](function(_0x4629f6){return db[_0xc98f('0x95')][_0xc98f('0x34')]({'where':{'MailAccountId':_0x31dcde[_0xc98f('0x5e')]['id']},'transaction':_0x4629f6})['then'](function(_0x3c53f3){var _0x3d09c0=_[_0xc98f('0x42')](_0x31dcde[_0xc98f('0x5d')],function(_0x40a258){_0x40a258[_0xc98f('0x62')]=_0x31dcde[_0xc98f('0x5e')]['id'];return _0x40a258;});return db[_0xc98f('0x95')]['bulkCreate'](_0x3d09c0,{'transaction':_0x4629f6});});})['then'](function(){return db['MailApplication'][_0xc98f('0x96')]({'where':{'MailAccountId':_0x31dcde[_0xc98f('0x5e')]['id']},'order':_0xc98f('0x97')});});}})[_0xc98f('0x1f')](respondWithResult(_0x5bd883,null))[_0xc98f('0x29')](handleError(_0x5bd883,null));};exports[_0xc98f('0x98')]=function(_0x38e5b0,_0x5b0d,_0x20443a){var _0x7e2bfe={};var _0x26dd81={};var _0x5431c7;var _0x17d514;return db[_0xc98f('0x3d')]['findOne']({'where':{'id':_0x38e5b0['params']['id']}})[_0xc98f('0x1f')](handleEntityNotFound(_0x5b0d,null))[_0xc98f('0x1f')](function(_0x59888a){if(_0x59888a){_0x5431c7=_0x59888a;_0x26dd81[_0xc98f('0x59')]=_[_0xc98f('0x43')](db[_0xc98f('0x95')][_0xc98f('0x3e')]);_0x26dd81[_0xc98f('0x44')]=_[_0xc98f('0x43')](_0x38e5b0[_0xc98f('0x44')]);_0x26dd81[_0xc98f('0x45')]=_[_0xc98f('0x46')](_0x26dd81[_0xc98f('0x59')],_0x26dd81[_0xc98f('0x44')]);_0x7e2bfe[_0xc98f('0x47')]=_[_0xc98f('0x46')](_0x26dd81['model'],qs[_0xc98f('0x48')](_0x38e5b0[_0xc98f('0x44')][_0xc98f('0x48')]));_0x7e2bfe[_0xc98f('0x47')]=_0x7e2bfe[_0xc98f('0x47')]['length']?_0x7e2bfe[_0xc98f('0x47')]:_0x26dd81[_0xc98f('0x59')];_0x7e2bfe[_0xc98f('0x4c')]=qs[_0xc98f('0x4d')](_0x38e5b0[_0xc98f('0x44')][_0xc98f('0x4d')]);_0x7e2bfe[_0xc98f('0x4e')]=qs['filters'](_[_0xc98f('0x4f')](_0x38e5b0['query'],_0x26dd81['filters']));if(_0x38e5b0['query'][_0xc98f('0x50')]){_0x7e2bfe[_0xc98f('0x4e')]=_[_0xc98f('0x51')](_0x7e2bfe[_0xc98f('0x4e')],{'$or':_[_0xc98f('0x42')](_0x7e2bfe['attributes'],function(_0x2b0248){var _0x3d0a79={};_0x3d0a79[_0x2b0248]={'$like':'%'+_0x38e5b0['query']['filter']+'%'};return _0x3d0a79;})});}_0x7e2bfe=_[_0xc98f('0x51')]({},_0x7e2bfe,_0x38e5b0['options']);return _0x5431c7[_0xc98f('0x98')](_0x7e2bfe);}})['then'](function(_0x29da8d){if(_0x29da8d){_0x17d514=_0x29da8d['length'];if(!_0x38e5b0[_0xc98f('0x44')][_0xc98f('0x4a')](_0xc98f('0x4b'))){_0x7e2bfe[_0xc98f('0x30')]=qs['limit'](_0x38e5b0[_0xc98f('0x44')][_0xc98f('0x30')]);_0x7e2bfe[_0xc98f('0x2f')]=qs[_0xc98f('0x2f')](_0x38e5b0[_0xc98f('0x44')][_0xc98f('0x2f')]);}return _0x5431c7[_0xc98f('0x98')](_0x7e2bfe);}})[_0xc98f('0x1f')](function(_0x3f13bf){if(_0x3f13bf){return _0x3f13bf?{'count':_0x17d514,'rows':_0x3f13bf}:null;}})['then'](respondWithResult(_0x5b0d,null))['catch'](handleError(_0x5b0d,null));};exports[_0xc98f('0x99')]=function(_0x1d01bb,_0x179dd6,_0x37e544){var _0x3114bc={'raw':!![],'where':{}};var _0x3ba626={};var _0x38e14e={'count':0x0,'rows':[]};return db[_0xc98f('0x3d')][_0xc98f('0x66')]({'where':{'id':_0x1d01bb[_0xc98f('0x5e')]['id']}})[_0xc98f('0x1f')](handleEntityNotFound(_0x179dd6,null))[_0xc98f('0x1f')](function(_0x11ab59){if(_0x11ab59){_0x3ba626[_0xc98f('0x59')]=_[_0xc98f('0x43')](db['MailMessage'][_0xc98f('0x3e')]);_0x3ba626[_0xc98f('0x44')]=_[_0xc98f('0x43')](_0x1d01bb[_0xc98f('0x44')]);_0x3ba626[_0xc98f('0x45')]=_[_0xc98f('0x46')](_0x3ba626[_0xc98f('0x59')],_0x3ba626[_0xc98f('0x44')]);_0x3114bc['attributes']=_['intersection'](_0x3ba626['model'],qs[_0xc98f('0x48')](_0x1d01bb['query'][_0xc98f('0x48')]));_0x3114bc[_0xc98f('0x47')]=_0x3114bc['attributes']['length']?_0x3114bc[_0xc98f('0x47')]:_0x3ba626[_0xc98f('0x59')];if(!_0x1d01bb[_0xc98f('0x44')][_0xc98f('0x4a')](_0xc98f('0x4b'))){_0x3114bc[_0xc98f('0x30')]=qs[_0xc98f('0x30')](_0x1d01bb[_0xc98f('0x44')][_0xc98f('0x30')]);_0x3114bc['offset']=qs[_0xc98f('0x2f')](_0x1d01bb[_0xc98f('0x44')][_0xc98f('0x2f')]);}_0x3114bc[_0xc98f('0x4c')]=qs['sort'](_0x1d01bb[_0xc98f('0x44')]['sort']);_0x3114bc['where']=qs[_0xc98f('0x45')](_[_0xc98f('0x4f')](_0x1d01bb[_0xc98f('0x44')],_0x3ba626['filters']));_0x3114bc[_0xc98f('0x4e')][_0xc98f('0x62')]=_0x11ab59['id'];if(_0x1d01bb[_0xc98f('0x44')][_0xc98f('0x50')]){_0x3114bc[_0xc98f('0x4e')]=_[_0xc98f('0x51')](_0x3114bc[_0xc98f('0x4e')],{'$or':_[_0xc98f('0x42')](_0x3114bc[_0xc98f('0x47')],function(_0x1d83c6){var _0x4ff380={};_0x4ff380[_0x1d83c6]={'$like':'%'+_0x1d01bb[_0xc98f('0x44')]['filter']+'%'};return _0x4ff380;})});}if(_0x1d01bb[_0xc98f('0x44')][_0xc98f('0x9a')]){var _0x382a10=_0x1d01bb['query'][_0xc98f('0x9a')]['split'](',');var _0x4484d4={};_0x4484d4[_0x382a10[0x0]]={'$gte':moment(_0x382a10[0x1])[_0xc98f('0x9b')](_0xc98f('0x9c'))};_0x3114bc[_0xc98f('0x4e')]=_[_0xc98f('0x51')](_0x3114bc[_0xc98f('0x4e')],_0x4484d4);}_0x3114bc=_[_0xc98f('0x51')]({},_0x3114bc,_0x1d01bb['options']);return db[_0xc98f('0x9d')][_0xc98f('0x2e')]({'where':_0x3114bc[_0xc98f('0x4e')]})['then'](function(_0xa1baf8){_0x38e14e[_0xc98f('0x2e')]=_0xa1baf8;if(_0x1d01bb[_0xc98f('0x44')][_0xc98f('0x53')]){_0x3114bc['include']=[{'all':!![]}];}return db[_0xc98f('0x9d')]['findAll'](_0x3114bc);})['then'](function(_0x2ea3af){_0x38e14e[_0xc98f('0x56')]=_0x2ea3af;return _0x38e14e;});}})[_0xc98f('0x1f')](respondWithFilteredResult(_0x179dd6,_0x3114bc))['catch'](handleError(_0x179dd6,null));};exports[_0xc98f('0x9e')]=function(_0x4bdeef,_0x50f558,_0x50c791){var _0x56b4f2,_0x43594d={},_0x1faf50;if(_0x4bdeef[_0xc98f('0x5d')]['to']){_0x1faf50=_0x4bdeef[_0xc98f('0x5d')]['to']['split'](',')[0x0];}return db[_0xc98f('0x3d')][_0xc98f('0x5b')]({'where':{'id':_0x4bdeef[_0xc98f('0x5e')]['id']},'include':[{'model':db[_0xc98f('0x9f')],'as':'List','include':[{'model':db[_0xc98f('0x89')],'as':_0xc98f('0xa0'),'where':{'email':_0x1faf50},'limit':0x1,'order':[[_0xc98f('0xa1'),'DESC']]}]},{'model':db[_0xc98f('0x3c')],'as':_0xc98f('0x57'),'raw':!![]}]})[_0xc98f('0x1f')](handleEntityNotFound(_0x50f558,null))[_0xc98f('0x1f')](function(_0x41314c){if(_0x41314c){_0x56b4f2=_0x41314c;if(_0x41314c[_0xc98f('0x57')]){if(_[_0xc98f('0x6d')](_0x4bdeef['body'][_0xc98f('0xa2')])){_0x4bdeef[_0xc98f('0x5d')]['from']=util[_0xc98f('0x9b')](_0xc98f('0xa3'),_0x41314c[_0xc98f('0x38')],_0x41314c[_0xc98f('0x6c')]||_0x41314c[_0xc98f('0x57')]['user']);}if(_0x4bdeef['body'][_0xc98f('0xa4')]&&_0x4bdeef[_0xc98f('0x5d')][_0xc98f('0xa4')][_0xc98f('0x49')]){for(var _0x37504e=0x0;_0x37504e<_0x4bdeef[_0xc98f('0x5d')][_0xc98f('0xa4')][_0xc98f('0x49')];_0x37504e+=0x1){_0x4bdeef[_0xc98f('0x5d')][_0xc98f('0xa4')][_0x37504e]={'filename':_0x4bdeef[_0xc98f('0x5d')][_0xc98f('0xa4')][_0x37504e]['name'],'path':path[_0xc98f('0xa5')](config[_0xc98f('0xa6')],_0xc98f('0xa7'),_0x4bdeef['body'][_0xc98f('0xa4')][_0x37504e][_0xc98f('0xa8')])};}}var _0x33094a={'tls':{'rejectUnauthorized':![]}};if(_[_0xc98f('0x6d')](_0x41314c['Smtp'][_0xc98f('0x77')])){if(_0x41314c[_0xc98f('0x57')][_0xc98f('0x74')]){_0x33094a[_0xc98f('0xa9')]={'user':_0x41314c[_0xc98f('0x57')][_0xc98f('0x79')],'pass':_0x41314c[_0xc98f('0x57')][_0xc98f('0x73')]};}_0x33094a['host']=_0x41314c['Smtp'][_0xc98f('0x76')];_0x33094a[_0xc98f('0x75')]=_0x41314c[_0xc98f('0x57')]['port'];_0x33094a[_0xc98f('0xaa')]=_0x41314c[_0xc98f('0x57')][_0xc98f('0xaa')];}else{_0x33094a['service']=_0x41314c[_0xc98f('0x57')][_0xc98f('0x77')];_0x33094a[_0xc98f('0xa9')]={'user':_0x41314c[_0xc98f('0x57')][_0xc98f('0x79')],'pass':_0x41314c['Smtp'][_0xc98f('0x73')]};}return respondWithRpcPromise(_0xc98f('0xab'),_0xc98f('0xac'),{'account':_0x33094a,'message':_0x4bdeef[_0xc98f('0x5d')]});}else{throw new Error(_0xc98f('0xad'));}}})['then'](function(_0x4918cb){if(_0x4918cb){_0x43594d=_0x4918cb;if(_0x56b4f2[_0xc98f('0xae')]){if(_0x56b4f2[_0xc98f('0xae')][_0xc98f('0xa0')][_0xc98f('0x49')]){return _0x56b4f2[_0xc98f('0xae')][_0xc98f('0xa0')][0x0];}else{return db[_0xc98f('0x89')][_0xc98f('0x64')](_['defaults'](_0x4bdeef[_0xc98f('0x5d')],{'firstName':_0x4bdeef[_0xc98f('0x5d')]['to'],'email':_0x4bdeef[_0xc98f('0x5d')]['to'],'phone':_0x4bdeef[_0xc98f('0x5d')]['to'],'ListId':_0x56b4f2['ListId']}));}}else{throw new Error(_0xc98f('0xad'));}}})['then'](function(_0x359c09){if(_0x359c09){var _0x10056e={'UserId':_0x4bdeef[_0xc98f('0x79')]['id'],'ContactId':_0x359c09['id'],'MailAccountId':_0x56b4f2['id'],'inReplyTo':_0x43594d['messageId'],'to':_0x4bdeef[_0xc98f('0x5d')][_0xc98f('0xa2')],'cc':_0x4bdeef[_0xc98f('0x5d')]['cc'],'subject':_0x4bdeef[_0xc98f('0x5d')][_0xc98f('0xaf')],'attach':_0x4bdeef[_0xc98f('0x5d')][_0xc98f('0xb0')],'firstMsgDirection':_0xc98f('0xb1'),'lastMsgAt':moment()[_0xc98f('0x9b')]('YYYY-MM-DD\x20HH:mm:ss'),'lastMsgDirection':_0xc98f('0xb1'),'lastMsgBody':_0x4bdeef['body'][_0xc98f('0x5d')],'Messages':[_[_0xc98f('0x51')](_0x4bdeef[_0xc98f('0x5d')],{'messageId':_0x43594d[_0xc98f('0xb2')],'sentAt':moment()['format'](_0xc98f('0x9c')),'read':!![],'MailAccountId':_0x56b4f2['id'],'UserId':_0x4bdeef[_0xc98f('0x79')]['id'],'ContactId':_0x359c09['id']})]};if(_0x4bdeef[_0xc98f('0x5d')]['Interaction']){_0x10056e=_[_0xc98f('0x51')](_0x10056e,_0x4bdeef[_0xc98f('0x5d')][_0xc98f('0xb3')]);}return db[_0xc98f('0x87')]['create'](_0x10056e,{'include':[{'model':db[_0xc98f('0x9d')],'as':'Messages'}]});}})[_0xc98f('0x1f')](respondWithResult(_0x50f558,null))[_0xc98f('0x29')](handleError(_0x50f558,null));};exports['verifySmtp']=function(_0x417987,_0x9500d4,_0x844980){return db['MailAccount']['find']({'where':{'id':_0x417987[_0xc98f('0x5e')]['id']},'include':[{'model':db[_0xc98f('0x3c')],'as':_0xc98f('0x57'),'raw':!![]}]})[_0xc98f('0x1f')](handleEntityNotFound(_0x9500d4,null))['then'](function(_0x56312d){if(_0x56312d&&_0x56312d[_0xc98f('0x57')]){var _0x546a89={'id':_0x56312d['id'],'tls':{'rejectUnauthorized':![]}};if(_0x56312d[_0xc98f('0x57')][_0xc98f('0x77')]){_0x546a89[_0xc98f('0x77')]=_0x56312d[_0xc98f('0x57')][_0xc98f('0x77')];}else{_0x546a89['host']=_0x56312d[_0xc98f('0x57')][_0xc98f('0x76')];_0x546a89[_0xc98f('0x75')]=_0x56312d[_0xc98f('0x57')][_0xc98f('0x75')];_0x546a89[_0xc98f('0xaa')]=_0x56312d['Smtp'][_0xc98f('0xaa')];}if(_0x56312d['Smtp'][_0xc98f('0x74')]){_0x546a89[_0xc98f('0xa9')]={'user':_0x56312d[_0xc98f('0x57')][_0xc98f('0x79')],'pass':_0x56312d[_0xc98f('0x57')][_0xc98f('0x73')]};}return respondWithRpcPromise(_0xc98f('0xb4'),_0xc98f('0xb5'),{'account':_0x546a89});}})[_0xc98f('0x1f')](respondWithResult(_0x9500d4,null))[_0xc98f('0x29')](handleError(_0x9500d4,null));};exports[_0xc98f('0x34')]=function(_0x3b1352,_0x1bf76c){return db[_0xc98f('0x3d')][_0xc98f('0x5b')]({'where':{'id':_0x3b1352[_0xc98f('0x5e')]['id']}})[_0xc98f('0x1f')](handleEntityNotFound(_0x1bf76c,null))['then'](function(_0x24fe59){if(_0x24fe59&&_0x24fe59[_0xc98f('0x77')]){throw new db['Sequelize'][(_0xc98f('0xb6'))](_0xc98f('0xb7'));}return _0x24fe59;})[_0xc98f('0x1f')](removeEntity(_0x1bf76c,null))[_0xc98f('0x29')](handleError(_0x1bf76c,null));};exports[_0xc98f('0xb8')]=function(_0x186f04,_0x5445a8,_0x534893){return db['MailAccount'][_0xc98f('0x5b')]({'where':{'id':_0x186f04['params']['id']}})[_0xc98f('0x1f')](handleEntityNotFound(_0x5445a8,null))[_0xc98f('0x1f')](function(_0x301b08){if(_0x301b08){return _0x301b08[_0xc98f('0xb8')](_0x186f04[_0xc98f('0x5d')][_0xc98f('0x68')],_[_0xc98f('0xb9')](_0x186f04[_0xc98f('0x5d')],[_0xc98f('0x68'),'id'])||{})[_0xc98f('0xba')](function(_0x50acdf){for(var _0x384fb3=0x0;_0x384fb3<_0x186f04['body'][_0xc98f('0x68')][_0xc98f('0x49')];_0x384fb3+=0x1){socket[_0xc98f('0xbb')]('userMailAccount:save',{'UserId':_0x186f04[_0xc98f('0x5d')][_0xc98f('0x68')][_0x384fb3],'MailAccountId':_0x186f04[_0xc98f('0x5e')]['id']});}return _0x50acdf;});}})[_0xc98f('0x1f')](respondWithResult(_0x5445a8,null))[_0xc98f('0x29')](handleError(_0x5445a8,null));};exports[_0xc98f('0xbc')]=function(_0x1acedb,_0x4303f6,_0x5af223){return db[_0xc98f('0x3d')][_0xc98f('0x5b')]({'where':{'id':_0x1acedb['params']['id']}})[_0xc98f('0x1f')](handleEntityNotFound(_0x4303f6,null))[_0xc98f('0x1f')](function(_0x58ad58){if(_0x58ad58){return _0x58ad58[_0xc98f('0xbc')](_0x1acedb[_0xc98f('0x44')][_0xc98f('0x68')])[_0xc98f('0x1f')](function(){if(_[_0xc98f('0xbd')](_0x1acedb['query'][_0xc98f('0x68')])){for(var _0x22d041=0x0;_0x22d041<_0x1acedb[_0xc98f('0x44')][_0xc98f('0x68')][_0xc98f('0x49')];_0x22d041+=0x1){socket['emit']('userMailAccount:remove',{'UserId':Number(_0x1acedb[_0xc98f('0x44')]['ids'][_0x22d041]),'MailAccountId':Number(_0x1acedb['params']['id'])});}}else{socket['emit'](_0xc98f('0xbe'),{'UserId':Number(_0x1acedb[_0xc98f('0x44')][_0xc98f('0x68')]),'MailAccountId':Number(_0x1acedb[_0xc98f('0x5e')]['id'])});}});}})[_0xc98f('0x1f')](respondWithStatusCode(_0x4303f6,null))[_0xc98f('0x29')](handleError(_0x4303f6,null));};exports[_0xc98f('0xbf')]=function(_0x1af740,_0x30de65,_0x230da7){var _0xa2e4ea={};var _0x29c1fa={};var _0x2a7fad;var _0x43a11a;return db[_0xc98f('0x3d')][_0xc98f('0x66')]({'where':{'id':_0x1af740[_0xc98f('0x5e')]['id']}})[_0xc98f('0x1f')](handleEntityNotFound(_0x30de65,null))[_0xc98f('0x1f')](function(_0x5cef46){if(_0x5cef46){_0x2a7fad=_0x5cef46;_0x29c1fa[_0xc98f('0x59')]=_['keys'](db['User'][_0xc98f('0x3e')]);_0x29c1fa[_0xc98f('0x44')]=_['keys'](_0x1af740[_0xc98f('0x44')]);_0x29c1fa[_0xc98f('0x45')]=_[_0xc98f('0x46')](_0x29c1fa[_0xc98f('0x59')],_0x29c1fa[_0xc98f('0x44')]);_0xa2e4ea['attributes']=_[_0xc98f('0x46')](_0x29c1fa[_0xc98f('0x59')],qs[_0xc98f('0x48')](_0x1af740['query']['fields']));_0xa2e4ea[_0xc98f('0x47')]=_0xa2e4ea[_0xc98f('0x47')][_0xc98f('0x49')]?_0xa2e4ea[_0xc98f('0x47')]:_0x29c1fa[_0xc98f('0x59')];_0xa2e4ea[_0xc98f('0x4c')]=qs[_0xc98f('0x4d')](_0x1af740['query'][_0xc98f('0x4d')]);_0xa2e4ea['where']=qs[_0xc98f('0x45')](_['pick'](_0x1af740[_0xc98f('0x44')],_0x29c1fa[_0xc98f('0x45')]));if(_0x1af740['query'][_0xc98f('0x50')]){_0xa2e4ea[_0xc98f('0x4e')]=_['merge'](_0xa2e4ea[_0xc98f('0x4e')],{'$or':_[_0xc98f('0x42')](_0xa2e4ea[_0xc98f('0x47')],function(_0x46b092){var _0x346362={};_0x346362[_0x46b092]={'$like':'%'+_0x1af740[_0xc98f('0x44')][_0xc98f('0x50')]+'%'};return _0x346362;})});}_0xa2e4ea=_[_0xc98f('0x51')]({},_0xa2e4ea,_0x1af740[_0xc98f('0x5a')]);return _0x2a7fad[_0xc98f('0xbf')](_0xa2e4ea);}})['then'](function(_0x173035){if(_0x173035){_0x43a11a=_0x173035[_0xc98f('0x49')];if(!_0x1af740['query'][_0xc98f('0x4a')](_0xc98f('0x4b'))){_0xa2e4ea[_0xc98f('0x30')]=qs[_0xc98f('0x30')](_0x1af740[_0xc98f('0x44')][_0xc98f('0x30')]);_0xa2e4ea[_0xc98f('0x2f')]=qs[_0xc98f('0x2f')](_0x1af740[_0xc98f('0x44')][_0xc98f('0x2f')]);}return _0x2a7fad[_0xc98f('0xbf')](_0xa2e4ea);}})[_0xc98f('0x1f')](function(_0x400d12){if(_0x400d12){return _0x400d12?{'count':_0x43a11a,'rows':_0x400d12}:null;}})[_0xc98f('0x1f')](respondWithResult(_0x30de65,null))['catch'](handleError(_0x30de65,null));};
\ No newline at end of file
+var _0xf582=['rows','removeDispositions','addAnswer','CannedAnswer','create','getAnswers','findOne','removeAnswers','ids','email','isNil','active','description','cservice','user','password','pass','cpassword','authentication','host','port','service','cuser','Unable\x20to\x20retrieve\x20the\x20current\x20user','MailAccounts','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','getImap','removeImap','getSmtp','addSmtp','setSmtp','addInteraction','MailInteraction','omit','getInteractions','CmContact','User','Owner','Tag','Tags','tag','addApplications','sequelize','transaction','MailApplication','bulkCreate','findAndCountAll','priority','getApplications','getMessages','MailMessage','$gte','split','format','YYYY-MM-DD\x20HH:mm:ss','CmList','List','updatedAt','from','%s\x20<%s>','attachments','join','root','server/files/attachments','basename','auth','SendMail','List\x20not\x20found','Contacts','defaults','ListId','subject','out','messageId','Interaction','verifySmtp','secure','VerifySmtp','Sequelize','ValidationError','You\x20can\x27t\x20remove\x20the\x20mail\x20service\x20account','addAgents','emit','userMailAccount:save','removeAgents','isArray','userMailAccount:remove','getAgents','eml-format','rimraf','moment','bluebird','mustache','util','sox','ejs','lodash','squel','crypto','jsforce','desk.js','to-csv','querystring','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/environment','../../config/license/util','redis','localhost','socket.io-emitter','./mailAccount.socket','register','jayson/promise','http','then','info','MailAccount,\x20%s,\x20%s','request\x20sent','MailAccount,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','sendStatus','status','offset','limit','set','json','reject','save','destroy','get','UserProfileResource','end','name','send','index','MailServerIn','Imap','MailServerOut','Smtp','Pause','mandatoryDispositionPause','map','MailAccount','rawAttributes','fieldName','key','query','filters','model','fields','attributes','length','hasOwnProperty','nolimit','sort','where','pick','filter','merge','VIRTUAL','options','count','includeAll','show','keys','intersection','include','find','update','body','params','describe','addDisposition','MailAccountId','getDispositions','Disposition','order','findAll'];(function(_0x246bcd,_0xc63678){var _0x1fe133=function(_0x5b91f0){while(--_0x5b91f0){_0x246bcd['push'](_0x246bcd['shift']());}};_0x1fe133(++_0xc63678);}(_0xf582,0x1d2));var _0x2f58=function(_0x44c79f,_0x21f727){_0x44c79f=_0x44c79f-0x0;var _0x4089ef=_0xf582[_0x44c79f];return _0x4089ef;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0x2f58('0x0'));var rimraf=require(_0x2f58('0x1'));var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require(_0x2f58('0x2'));var BPromise=require(_0x2f58('0x3'));var Mustache=require(_0x2f58('0x4'));var util=require(_0x2f58('0x5'));var path=require('path');var sox=require(_0x2f58('0x6'));var csv=require('to-csv');var ejs=require(_0x2f58('0x7'));var fs=require('fs');var _=require(_0x2f58('0x8'));var squel=require(_0x2f58('0x9'));var crypto=require(_0x2f58('0xa'));var jsforce=require(_0x2f58('0xb'));var deskjs=require(_0x2f58('0xc'));var toCsv=require(_0x2f58('0xd'));var querystring=require(_0x2f58('0xe'));var Papa=require('papaparse');var Redis=require(_0x2f58('0xf'));var authService=require('../../components/auth/service');var qs=require(_0x2f58('0x10'));var as=require(_0x2f58('0x11'));var hardwareService=require(_0x2f58('0x12'));var logger=require('../../config/logger')(_0x2f58('0x13'));var utils=require('../../config/utils');var config=require(_0x2f58('0x14'));var licenseUtil=require(_0x2f58('0x15'));var db=require('../../mysqldb')['db'];config[_0x2f58('0x16')]=_['defaults'](config['redis'],{'host':_0x2f58('0x17'),'port':0x18eb});var socket=require(_0x2f58('0x18'))(new Redis(config['redis']));require(_0x2f58('0x19'))[_0x2f58('0x1a')](socket);var jayson=require(_0x2f58('0x1b'));var client=jayson['client'][_0x2f58('0x1c')]({'port':0x232b});function respondWithRpcPromise(_0x11feae,_0x21e435,_0xcb470e,_0x2037c7){return new BPromise(function(_0x1afad8,_0x1f0556){var _0x3f8c6e=_0x2037c7||client;return _0x3f8c6e['request'](_0x11feae,_0xcb470e)[_0x2f58('0x1d')](function(_0x325354){logger[_0x2f58('0x1e')](_0x2f58('0x1f'),_0x21e435,_0x2f58('0x20'));logger['debug'](_0x2f58('0x21'),_0x21e435,'request\x20sent',JSON[_0x2f58('0x22')](_0x325354));if(_0x325354[_0x2f58('0x23')]){if(_0x325354[_0x2f58('0x23')][_0x2f58('0x24')]===0x1f4){logger[_0x2f58('0x23')](_0x2f58('0x1f'),_0x21e435,_0x325354[_0x2f58('0x23')]['message']);return _0x1f0556(_0x325354['error'][_0x2f58('0x25')]);}logger[_0x2f58('0x23')](_0x2f58('0x1f'),_0x21e435,_0x325354[_0x2f58('0x23')][_0x2f58('0x25')]);return _0x1afad8(_0x325354['error']['message']);}else{logger[_0x2f58('0x1e')](_0x2f58('0x1f'),_0x21e435,_0x2f58('0x20'));_0x1afad8(_0x325354[_0x2f58('0x26')]['message']);}})[_0x2f58('0x27')](function(_0x58242f){logger[_0x2f58('0x23')](_0x2f58('0x1f'),_0x21e435,_0x58242f);_0x1f0556(_0x58242f);});});}function respondWithStatusCode(_0x14ae48,_0x201749){_0x201749=_0x201749||0xcc;return function(_0x17c104){if(_0x17c104){return _0x14ae48[_0x2f58('0x28')](_0x201749);}return _0x14ae48[_0x2f58('0x29')](_0x201749)['end']();};}function respondWithResult(_0x5ea23d,_0x1b5f83){_0x1b5f83=_0x1b5f83||0xc8;return function(_0x279d11){if(_0x279d11){return _0x5ea23d[_0x2f58('0x29')](_0x1b5f83)['json'](_0x279d11);}};}function respondWithFilteredResult(_0x20c9b8,_0x231cf5){return function(_0x48a432){if(_0x48a432){var _0x55d4ec=_0x48a432['count'],_0x55b513=_0x231cf5[_0x2f58('0x2a')],_0x2e5b1f=_0x231cf5[_0x2f58('0x2a')]+_0x231cf5[_0x2f58('0x2b')],_0x6bbbfa;if(_0x2e5b1f>=_0x55d4ec){_0x2e5b1f=_0x55d4ec;_0x6bbbfa=0xc8;}else{_0x6bbbfa=0xce;}_0x20c9b8['status'](_0x6bbbfa);return _0x20c9b8[_0x2f58('0x2c')]('Content-Range',_0x55b513+'-'+_0x2e5b1f+'/'+_0x55d4ec)[_0x2f58('0x2d')](_0x48a432);}return null;};}function patchUpdates(_0xe84066){return function(_0x252539){try{jsonpatch['apply'](_0x252539,_0xe84066,!![]);}catch(_0x39d192){return BPromise[_0x2f58('0x2e')](_0x39d192);}return _0x252539[_0x2f58('0x2f')]();};}function saveUpdates(_0x14d042,_0x1c3178){return function(_0x1d2c5d){if(_0x1d2c5d){return _0x1d2c5d['update'](_0x14d042)[_0x2f58('0x1d')](function(_0x2f3133){return _0x2f3133;});}return null;};}function removeEntity(_0x363d26,_0x5d8af6){return function(_0x276058){if(_0x276058){return _0x276058[_0x2f58('0x30')]()[_0x2f58('0x1d')](function(){var _0x1149cd=_0x276058[_0x2f58('0x31')]({'plain':!![]});var _0x15d599='MailAccounts';return db[_0x2f58('0x32')][_0x2f58('0x30')]({'where':{'type':_0x15d599,'resourceId':_0x1149cd['id']}})['then'](function(){return _0x276058;});})['then'](function(){_0x363d26[_0x2f58('0x29')](0xcc)[_0x2f58('0x33')]();});}};}function handleEntityNotFound(_0x4c0859,_0x428a56){return function(_0x32a6d6){if(!_0x32a6d6){_0x4c0859[_0x2f58('0x28')](0x194);}return _0x32a6d6;};}function handleError(_0x21ee49,_0x24251b){_0x24251b=_0x24251b||0x1f4;return function(_0x572632){logger[_0x2f58('0x23')](_0x572632['stack']);if(_0x572632['name']){delete _0x572632[_0x2f58('0x34')];}_0x21ee49[_0x2f58('0x29')](_0x24251b)[_0x2f58('0x35')](_0x572632);};}exports[_0x2f58('0x36')]=function(_0xfc433d,_0x9c6c4a){var _0x1023b6={'include':[{'model':db[_0x2f58('0x37')],'as':_0x2f58('0x38')},{'model':db[_0x2f58('0x39')],'as':_0x2f58('0x3a')},{'model':db[_0x2f58('0x3b')],'as':_0x2f58('0x3c')}]},_0x49c98c={},_0x3719f5={'count':0x0,'rows':[]};var _0x4a54d8=_[_0x2f58('0x3d')](db[_0x2f58('0x3e')][_0x2f58('0x3f')],function(_0x3a989b){return{'name':_0x3a989b[_0x2f58('0x40')],'type':_0x3a989b['type'][_0x2f58('0x41')]};});_0x49c98c['model']=_[_0x2f58('0x3d')](_0x4a54d8,'name');_0x49c98c[_0x2f58('0x42')]=_['keys'](_0xfc433d[_0x2f58('0x42')]);_0x49c98c[_0x2f58('0x43')]=_['intersection'](_0x49c98c[_0x2f58('0x44')],_0x49c98c[_0x2f58('0x42')]);_0x1023b6['attributes']=_['intersection'](_0x49c98c['model'],qs['fields'](_0xfc433d[_0x2f58('0x42')][_0x2f58('0x45')]));_0x1023b6['attributes']=_0x1023b6[_0x2f58('0x46')][_0x2f58('0x47')]?_0x1023b6[_0x2f58('0x46')]:_0x49c98c[_0x2f58('0x44')];if(!_0xfc433d[_0x2f58('0x42')][_0x2f58('0x48')](_0x2f58('0x49'))){_0x1023b6[_0x2f58('0x2b')]=qs[_0x2f58('0x2b')](_0xfc433d['query']['limit']);_0x1023b6['offset']=qs[_0x2f58('0x2a')](_0xfc433d['query']['offset']);}_0x1023b6['order']=qs[_0x2f58('0x4a')](_0xfc433d['query'][_0x2f58('0x4a')]);_0x1023b6[_0x2f58('0x4b')]=qs['filters'](_[_0x2f58('0x4c')](_0xfc433d[_0x2f58('0x42')],_0x49c98c[_0x2f58('0x43')]),_0x4a54d8);if(_0xfc433d[_0x2f58('0x42')][_0x2f58('0x4d')]){_0x1023b6[_0x2f58('0x4b')]=_[_0x2f58('0x4e')](_0x1023b6[_0x2f58('0x4b')],{'$or':_['map'](_0x4a54d8,function(_0x5ce1c7){if(_0x5ce1c7['type']!==_0x2f58('0x4f')){var _0x483149={};_0x483149[_0x5ce1c7[_0x2f58('0x34')]]={'$like':'%'+_0xfc433d[_0x2f58('0x42')][_0x2f58('0x4d')]+'%'};return _0x483149;}})});}_0x1023b6=_[_0x2f58('0x4e')]({},_0x1023b6,_0xfc433d[_0x2f58('0x50')]);var _0x3afd0d={'where':_0x1023b6['where']};return db['MailAccount'][_0x2f58('0x51')](_0x3afd0d)[_0x2f58('0x1d')](function(_0x2814bd){_0x3719f5[_0x2f58('0x51')]=_0x2814bd;if(_0xfc433d['query'][_0x2f58('0x52')]){_0x1023b6['include']=[{'all':!![]}];}return db[_0x2f58('0x3e')]['findAll'](_0x1023b6);})[_0x2f58('0x1d')](function(_0x59e3d7){_0x3719f5['rows']=_0x59e3d7;return _0x3719f5;})['then'](respondWithFilteredResult(_0x9c6c4a,_0x1023b6))[_0x2f58('0x27')](handleError(_0x9c6c4a,null));};exports[_0x2f58('0x53')]=function(_0x41dd0b,_0x1702c6){var _0x26ce63={'raw':![],'where':{'id':_0x41dd0b['params']['id']},'include':[{'model':db[_0x2f58('0x37')],'as':_0x2f58('0x38')},{'model':db['MailServerOut'],'as':_0x2f58('0x3a')},{'model':db[_0x2f58('0x3b')],'as':_0x2f58('0x3c')}]},_0x5bcab1={};_0x5bcab1['model']=_[_0x2f58('0x54')](db[_0x2f58('0x3e')][_0x2f58('0x3f')]);_0x5bcab1[_0x2f58('0x42')]=_[_0x2f58('0x54')](_0x41dd0b[_0x2f58('0x42')]);_0x5bcab1[_0x2f58('0x43')]=_[_0x2f58('0x55')](_0x5bcab1[_0x2f58('0x44')],_0x5bcab1[_0x2f58('0x42')]);_0x26ce63[_0x2f58('0x46')]=_[_0x2f58('0x55')](_0x5bcab1['model'],qs['fields'](_0x41dd0b[_0x2f58('0x42')][_0x2f58('0x45')]));_0x26ce63['attributes']=_0x26ce63['attributes'][_0x2f58('0x47')]?_0x26ce63[_0x2f58('0x46')]:_0x5bcab1['model'];if(_0x41dd0b[_0x2f58('0x42')][_0x2f58('0x52')]){_0x26ce63[_0x2f58('0x56')]=[{'all':!![]}];}_0x26ce63=_[_0x2f58('0x4e')]({},_0x26ce63,_0x41dd0b[_0x2f58('0x50')]);return db[_0x2f58('0x3e')][_0x2f58('0x57')](_0x26ce63)['then'](handleEntityNotFound(_0x1702c6,null))['then'](respondWithResult(_0x1702c6,null))['catch'](handleError(_0x1702c6,null));};exports[_0x2f58('0x58')]=function(_0x55d801,_0x19a24f){if(_0x55d801[_0x2f58('0x59')]['id']){delete _0x55d801[_0x2f58('0x59')]['id'];}return db[_0x2f58('0x3e')][_0x2f58('0x57')]({'where':{'id':_0x55d801[_0x2f58('0x5a')]['id']},'include':[{'model':db['MailServerIn'],'as':_0x2f58('0x38')},{'model':db[_0x2f58('0x39')],'as':_0x2f58('0x3a')},{'model':db[_0x2f58('0x3b')],'as':'mandatoryDispositionPause'}]})['then'](handleEntityNotFound(_0x19a24f,null))[_0x2f58('0x1d')](saveUpdates(_0x55d801[_0x2f58('0x59')],null))[_0x2f58('0x1d')](function(_0x1c0c20){if(_0x1c0c20&&_0x55d801[_0x2f58('0x59')][_0x2f58('0x38')]){return db['MailServerIn'][_0x2f58('0x58')](_0x55d801[_0x2f58('0x59')][_0x2f58('0x38')],{'where':{'MailAccountId':_0x1c0c20['id']}})['then'](function(){return _0x1c0c20;});}return _0x1c0c20;})[_0x2f58('0x1d')](function(_0x3d054e){if(_0x3d054e&&_0x55d801['body'][_0x2f58('0x3a')]){return db['MailServerOut']['update'](_0x55d801[_0x2f58('0x59')][_0x2f58('0x3a')],{'where':{'MailAccountId':_0x3d054e['id']}})[_0x2f58('0x1d')](function(){return _0x3d054e;});}return _0x3d054e;})[_0x2f58('0x1d')](respondWithResult(_0x19a24f,null))[_0x2f58('0x27')](handleError(_0x19a24f,null));};exports[_0x2f58('0x5b')]=function(_0x3adaf9,_0x3c4e39){return db[_0x2f58('0x3e')]['describe']()[_0x2f58('0x1d')](respondWithResult(_0x3c4e39,null))['catch'](handleError(_0x3c4e39,null));};exports[_0x2f58('0x5c')]=function(_0x36497d,_0x53a18c,_0x2bd499){if(_0x36497d['body']['id']){delete _0x36497d['body']['id'];}return db[_0x2f58('0x3e')][_0x2f58('0x57')]({'where':{'id':_0x36497d[_0x2f58('0x5a')]['id']}})[_0x2f58('0x1d')](handleEntityNotFound(_0x53a18c,null))[_0x2f58('0x1d')](function(_0x7da3d7){if(_0x7da3d7){_0x36497d[_0x2f58('0x59')][_0x2f58('0x5d')]=_0x7da3d7['id'];return db['Disposition']['create'](_0x36497d[_0x2f58('0x59')]);}})['then'](respondWithResult(_0x53a18c,null))['catch'](handleError(_0x53a18c,null));};exports[_0x2f58('0x5e')]=function(_0x59044c,_0x248885,_0x270c0e){var _0x519fdc={'raw':![],'where':{}};var _0x5443ef={};var _0x3ceea4={'count':0x0,'rows':[]};return db[_0x2f58('0x3e')]['findOne']({'where':{'id':_0x59044c[_0x2f58('0x5a')]['id']}})[_0x2f58('0x1d')](handleEntityNotFound(_0x248885,null))[_0x2f58('0x1d')](function(_0x3f044f){if(_0x3f044f){_0x5443ef[_0x2f58('0x44')]=_['keys'](db[_0x2f58('0x5f')][_0x2f58('0x3f')]);_0x5443ef[_0x2f58('0x42')]=_[_0x2f58('0x54')](_0x59044c['query']);_0x5443ef['filters']=_[_0x2f58('0x55')](_0x5443ef['model'],_0x5443ef[_0x2f58('0x42')]);_0x519fdc['attributes']=_[_0x2f58('0x55')](_0x5443ef[_0x2f58('0x44')],qs[_0x2f58('0x45')](_0x59044c[_0x2f58('0x42')][_0x2f58('0x45')]));_0x519fdc[_0x2f58('0x46')]=_0x519fdc['attributes'][_0x2f58('0x47')]?_0x519fdc[_0x2f58('0x46')]:_0x5443ef['model'];if(!_0x59044c[_0x2f58('0x42')]['hasOwnProperty']('nolimit')){_0x519fdc[_0x2f58('0x2b')]=qs['limit'](_0x59044c[_0x2f58('0x42')][_0x2f58('0x2b')]);_0x519fdc[_0x2f58('0x2a')]=qs['offset'](_0x59044c[_0x2f58('0x42')][_0x2f58('0x2a')]);}_0x519fdc[_0x2f58('0x60')]=qs[_0x2f58('0x4a')](_0x59044c[_0x2f58('0x42')][_0x2f58('0x4a')]);_0x519fdc['where']=qs[_0x2f58('0x43')](_[_0x2f58('0x4c')](_0x59044c[_0x2f58('0x42')],_0x5443ef['filters']));_0x519fdc['where']['MailAccountId']=_0x3f044f['id'];if(_0x59044c['query'][_0x2f58('0x4d')]){_0x519fdc[_0x2f58('0x4b')]=_[_0x2f58('0x4e')](_0x519fdc[_0x2f58('0x4b')],{'$or':_[_0x2f58('0x3d')](_0x519fdc[_0x2f58('0x46')],function(_0x2c9c19){var _0x5013af={};_0x5013af[_0x2c9c19]={'$like':'%'+_0x59044c[_0x2f58('0x42')][_0x2f58('0x4d')]+'%'};return _0x5013af;})});}_0x519fdc=_[_0x2f58('0x4e')]({},_0x519fdc,_0x59044c[_0x2f58('0x50')]);return db['Disposition'][_0x2f58('0x51')]({'where':_0x519fdc[_0x2f58('0x4b')]})[_0x2f58('0x1d')](function(_0x31c707){_0x3ceea4[_0x2f58('0x51')]=_0x31c707;if(_0x59044c[_0x2f58('0x42')][_0x2f58('0x52')]){_0x519fdc[_0x2f58('0x56')]=[{'all':!![]}];}return db[_0x2f58('0x5f')][_0x2f58('0x61')](_0x519fdc);})['then'](function(_0x2a353b){_0x3ceea4[_0x2f58('0x62')]=_0x2a353b;return _0x3ceea4;});}})['then'](respondWithFilteredResult(_0x248885,_0x519fdc))[_0x2f58('0x27')](handleError(_0x248885,null));};exports[_0x2f58('0x63')]=function(_0x134c0d,_0x429eb0,_0xbd4585){return db[_0x2f58('0x3e')][_0x2f58('0x57')]({'where':{'id':_0x134c0d[_0x2f58('0x5a')]['id']}})['then'](handleEntityNotFound(_0x429eb0,null))[_0x2f58('0x1d')](function(_0x11e331){if(_0x11e331){return _0x11e331['removeDispositions'](_0x134c0d[_0x2f58('0x42')]['ids']);}})[_0x2f58('0x1d')](respondWithStatusCode(_0x429eb0,null))[_0x2f58('0x27')](handleError(_0x429eb0,null));};exports[_0x2f58('0x64')]=function(_0x1ebc2d,_0x24dae2,_0x48a8fb){if(_0x1ebc2d[_0x2f58('0x59')]['id']){delete _0x1ebc2d[_0x2f58('0x59')]['id'];}return db['MailAccount'][_0x2f58('0x57')]({'where':{'id':_0x1ebc2d[_0x2f58('0x5a')]['id']}})['then'](handleEntityNotFound(_0x24dae2,null))[_0x2f58('0x1d')](function(_0x4cb25e){if(_0x4cb25e){_0x1ebc2d[_0x2f58('0x59')]['MailAccountId']=_0x4cb25e['id'];return db[_0x2f58('0x65')][_0x2f58('0x66')](_0x1ebc2d[_0x2f58('0x59')]);}})[_0x2f58('0x1d')](respondWithResult(_0x24dae2,null))[_0x2f58('0x27')](handleError(_0x24dae2,null));};exports[_0x2f58('0x67')]=function(_0x3433f5,_0x557b5e,_0x472f62){var _0x267d45={'raw':![],'where':{}};var _0x484f95={};var _0x571f72={'count':0x0,'rows':[]};return db[_0x2f58('0x3e')][_0x2f58('0x68')]({'where':{'id':_0x3433f5[_0x2f58('0x5a')]['id']}})['then'](handleEntityNotFound(_0x557b5e,null))[_0x2f58('0x1d')](function(_0x2b7bd4){if(_0x2b7bd4){_0x484f95[_0x2f58('0x44')]=_['keys'](db[_0x2f58('0x65')][_0x2f58('0x3f')]);_0x484f95[_0x2f58('0x42')]=_[_0x2f58('0x54')](_0x3433f5[_0x2f58('0x42')]);_0x484f95[_0x2f58('0x43')]=_[_0x2f58('0x55')](_0x484f95[_0x2f58('0x44')],_0x484f95['query']);_0x267d45[_0x2f58('0x46')]=_[_0x2f58('0x55')](_0x484f95['model'],qs['fields'](_0x3433f5[_0x2f58('0x42')][_0x2f58('0x45')]));_0x267d45[_0x2f58('0x46')]=_0x267d45[_0x2f58('0x46')]['length']?_0x267d45[_0x2f58('0x46')]:_0x484f95[_0x2f58('0x44')];if(!_0x3433f5[_0x2f58('0x42')][_0x2f58('0x48')](_0x2f58('0x49'))){_0x267d45[_0x2f58('0x2b')]=qs['limit'](_0x3433f5[_0x2f58('0x42')][_0x2f58('0x2b')]);_0x267d45['offset']=qs[_0x2f58('0x2a')](_0x3433f5[_0x2f58('0x42')][_0x2f58('0x2a')]);}_0x267d45[_0x2f58('0x60')]=qs[_0x2f58('0x4a')](_0x3433f5[_0x2f58('0x42')][_0x2f58('0x4a')]);_0x267d45['where']=qs[_0x2f58('0x43')](_['pick'](_0x3433f5[_0x2f58('0x42')],_0x484f95[_0x2f58('0x43')]));_0x267d45[_0x2f58('0x4b')][_0x2f58('0x5d')]=_0x2b7bd4['id'];if(_0x3433f5['query'][_0x2f58('0x4d')]){_0x267d45['where']=_[_0x2f58('0x4e')](_0x267d45[_0x2f58('0x4b')],{'$or':_[_0x2f58('0x3d')](_0x267d45[_0x2f58('0x46')],function(_0x1080fa){var _0x19fd15={};_0x19fd15[_0x1080fa]={'$like':'%'+_0x3433f5[_0x2f58('0x42')][_0x2f58('0x4d')]+'%'};return _0x19fd15;})});}_0x267d45=_[_0x2f58('0x4e')]({},_0x267d45,_0x3433f5[_0x2f58('0x50')]);return db[_0x2f58('0x65')]['count']({'where':_0x267d45[_0x2f58('0x4b')]})[_0x2f58('0x1d')](function(_0x42d16b){_0x571f72[_0x2f58('0x51')]=_0x42d16b;if(_0x3433f5[_0x2f58('0x42')]['includeAll']){_0x267d45[_0x2f58('0x56')]=[{'all':!![]}];}return db[_0x2f58('0x65')][_0x2f58('0x61')](_0x267d45);})[_0x2f58('0x1d')](function(_0x499963){_0x571f72[_0x2f58('0x62')]=_0x499963;return _0x571f72;});}})[_0x2f58('0x1d')](respondWithFilteredResult(_0x557b5e,_0x267d45))['catch'](handleError(_0x557b5e,null));};exports[_0x2f58('0x69')]=function(_0x1bc2ff,_0x484488,_0x183bdf){return db[_0x2f58('0x3e')][_0x2f58('0x57')]({'where':{'id':_0x1bc2ff[_0x2f58('0x5a')]['id']}})[_0x2f58('0x1d')](handleEntityNotFound(_0x484488,null))['then'](function(_0x498772){if(_0x498772){return _0x498772['removeAnswers'](_0x1bc2ff[_0x2f58('0x42')][_0x2f58('0x6a')]);}})[_0x2f58('0x1d')](respondWithStatusCode(_0x484488,null))[_0x2f58('0x27')](handleError(_0x484488,null));};exports[_0x2f58('0x66')]=function(_0x462724,_0x44f7e5){var _0x2f3d8b={'name':_0x462724[_0x2f58('0x59')][_0x2f58('0x34')],'key':_0x462724[_0x2f58('0x59')][_0x2f58('0x41')],'email':_0x462724[_0x2f58('0x59')][_0x2f58('0x6b')],'ListId':_0x462724[_0x2f58('0x59')]['ListId'],'active':!_[_0x2f58('0x6c')](_0x462724[_0x2f58('0x59')][_0x2f58('0x6d')])?_0x462724[_0x2f58('0x59')][_0x2f58('0x6d')]:!![],'description':_0x462724[_0x2f58('0x59')][_0x2f58('0x6e')]||null,'Imap':{},'Smtp':{}};if(_[_0x2f58('0x6c')](_0x462724[_0x2f58('0x59')][_0x2f58('0x6f')])){if(_0x462724[_0x2f58('0x59')]['cauthentication']){_0x2f3d8b[_0x2f58('0x38')][_0x2f58('0x70')]=_0x2f3d8b[_0x2f58('0x3a')][_0x2f58('0x70')]=_0x462724[_0x2f58('0x59')]['cuser'];_0x2f3d8b[_0x2f58('0x38')][_0x2f58('0x71')]=_0x2f3d8b[_0x2f58('0x3a')][_0x2f58('0x72')]=_0x462724[_0x2f58('0x59')][_0x2f58('0x73')];}else{_0x2f3d8b[_0x2f58('0x38')]['authentication']=_0x2f3d8b['Smtp'][_0x2f58('0x74')]=![];}_0x2f3d8b[_0x2f58('0x38')][_0x2f58('0x75')]=_0x462724[_0x2f58('0x59')][_0x2f58('0x38')][_0x2f58('0x75')];_0x2f3d8b[_0x2f58('0x38')][_0x2f58('0x76')]=_0x462724[_0x2f58('0x59')]['Imap']['port'];_0x2f3d8b[_0x2f58('0x3a')][_0x2f58('0x75')]=_0x462724[_0x2f58('0x59')][_0x2f58('0x3a')]['host'];_0x2f3d8b['Smtp'][_0x2f58('0x76')]=_0x462724[_0x2f58('0x59')][_0x2f58('0x3a')][_0x2f58('0x76')];}else{_0x2f3d8b['Imap'][_0x2f58('0x77')]=_0x2f3d8b['Smtp'][_0x2f58('0x77')]=_0x462724['body'][_0x2f58('0x6f')];_0x2f3d8b[_0x2f58('0x38')][_0x2f58('0x70')]=_0x2f3d8b[_0x2f58('0x3a')][_0x2f58('0x70')]=_0x462724[_0x2f58('0x59')][_0x2f58('0x78')];_0x2f3d8b[_0x2f58('0x38')][_0x2f58('0x71')]=_0x2f3d8b['Smtp'][_0x2f58('0x72')]=_0x462724['body']['cpassword'];}return db['MailAccount'][_0x2f58('0x66')](_0x2f3d8b,{'include':[{'model':db[_0x2f58('0x39')],'as':_0x2f58('0x3a')},{'model':db[_0x2f58('0x37')],'as':'Imap'}]})['then'](function(_0x5dee23){var _0x184d29=_0x462724[_0x2f58('0x70')][_0x2f58('0x31')]({'plain':!![]});if(!_0x184d29)throw new Error(_0x2f58('0x79'));if(_0x184d29['role']==='user'){var _0x414353=_0x5dee23['get']({'plain':!![]});return db['UserProfileSection'][_0x2f58('0x57')]({'where':{'name':_0x2f58('0x7a'),'userProfileId':_0x184d29[_0x2f58('0x7b')]},'raw':!![]})['then'](function(_0x29d503){if(_0x29d503&&_0x29d503[_0x2f58('0x7c')]===0x0){return db[_0x2f58('0x32')]['create']({'name':_0x414353[_0x2f58('0x34')],'resourceId':_0x414353['id'],'type':_0x29d503[_0x2f58('0x34')],'sectionId':_0x29d503['id']},{})[_0x2f58('0x1d')](function(){return _0x5dee23;});}else{return _0x5dee23;}})[_0x2f58('0x27')](function(_0x30f784){logger[_0x2f58('0x23')](_0x2f58('0x7d'),_0x30f784);throw _0x30f784;});}return _0x5dee23;})['then'](respondWithResult(_0x44f7e5,0xc9))[_0x2f58('0x27')](handleError(_0x44f7e5,null));};exports[_0x2f58('0x7e')]=function(_0x5ee2a8,_0x547da2,_0x25fa10){return db[_0x2f58('0x3e')][_0x2f58('0x68')]({'where':{'id':_0x5ee2a8[_0x2f58('0x5a')]['id']}})['then'](handleEntityNotFound(_0x547da2,null))[_0x2f58('0x1d')](function(_0x28da6f){if(_0x28da6f){return _0x28da6f[_0x2f58('0x7e')]();}return null;})[_0x2f58('0x1d')](respondWithResult(_0x547da2,null))[_0x2f58('0x27')](handleError(_0x547da2,null));};exports['addImap']=function(_0x492129,_0x3d9fc0,_0x6b5a84){if(_0x492129[_0x2f58('0x59')]['id']){delete _0x492129[_0x2f58('0x59')]['id'];}return db[_0x2f58('0x3e')]['find']({'where':{'id':_0x492129[_0x2f58('0x5a')]['id']}})[_0x2f58('0x1d')](handleEntityNotFound(_0x3d9fc0,null))['then'](function(_0x3612fa){if(_0x3612fa){_0x492129['body'][_0x2f58('0x5d')]=_0x3612fa['id'];return db[_0x2f58('0x37')][_0x2f58('0x66')](_0x492129[_0x2f58('0x59')]);}})['then'](respondWithResult(_0x3d9fc0,null))[_0x2f58('0x27')](handleError(_0x3d9fc0,null));};exports[_0x2f58('0x7f')]=function(_0xd091a3,_0x36423d,_0x5127dc){return db[_0x2f58('0x3e')][_0x2f58('0x68')]({'where':{'id':_0xd091a3['params']['id']}})[_0x2f58('0x1d')](handleEntityNotFound(_0x36423d,null))[_0x2f58('0x1d')](function(_0x2c6ab7){if(_0x2c6ab7){return _0x2c6ab7['setImap'](null);}return null;})['then'](respondWithStatusCode(_0x36423d,null))[_0x2f58('0x27')](handleError(_0x36423d,null));};exports[_0x2f58('0x80')]=function(_0x1cb5e3,_0x35aa18,_0x16ede0){return db[_0x2f58('0x3e')][_0x2f58('0x68')]({'where':{'id':_0x1cb5e3['params']['id']}})[_0x2f58('0x1d')](handleEntityNotFound(_0x35aa18,null))[_0x2f58('0x1d')](function(_0x20f6c1){if(_0x20f6c1){return _0x20f6c1[_0x2f58('0x80')]();}return null;})['then'](respondWithResult(_0x35aa18,null))['catch'](handleError(_0x35aa18,null));};exports[_0x2f58('0x81')]=function(_0x56ea7f,_0x308162,_0x5cc4e8){if(_0x56ea7f[_0x2f58('0x59')]['id']){delete _0x56ea7f['body']['id'];}return db[_0x2f58('0x3e')]['find']({'where':{'id':_0x56ea7f[_0x2f58('0x5a')]['id']}})[_0x2f58('0x1d')](handleEntityNotFound(_0x308162,null))[_0x2f58('0x1d')](function(_0x244ef2){if(_0x244ef2){_0x56ea7f[_0x2f58('0x59')][_0x2f58('0x5d')]=_0x244ef2['id'];return db['MailServerOut'][_0x2f58('0x66')](_0x56ea7f[_0x2f58('0x59')]);}})[_0x2f58('0x1d')](respondWithResult(_0x308162,null))[_0x2f58('0x27')](handleError(_0x308162,null));};exports['removeSmtp']=function(_0x1ce645,_0x3115aa,_0x4215be){return db[_0x2f58('0x3e')][_0x2f58('0x68')]({'where':{'id':_0x1ce645[_0x2f58('0x5a')]['id']}})[_0x2f58('0x1d')](handleEntityNotFound(_0x3115aa,null))[_0x2f58('0x1d')](function(_0x4a1643){if(_0x4a1643){return _0x4a1643[_0x2f58('0x82')](null);}return null;})[_0x2f58('0x1d')](respondWithStatusCode(_0x3115aa,null))[_0x2f58('0x27')](handleError(_0x3115aa,null));};exports[_0x2f58('0x83')]=function(_0x327b96,_0x11be13,_0x4c4a47){return db[_0x2f58('0x84')][_0x2f58('0x57')]({'where':{'id':_0x327b96[_0x2f58('0x5a')]['id']}})[_0x2f58('0x1d')](handleEntityNotFound(_0x11be13,null))[_0x2f58('0x1d')](function(_0x25c9ff){if(_0x25c9ff){return _0x25c9ff[_0x2f58('0x83')](_0x327b96[_0x2f58('0x59')]['ids'],_[_0x2f58('0x85')](_0x327b96[_0x2f58('0x59')],[_0x2f58('0x6a'),'id'])||{});}})[_0x2f58('0x1d')](respondWithResult(_0x11be13,null))[_0x2f58('0x27')](handleError(_0x11be13,null));};exports[_0x2f58('0x86')]=function(_0x4cce38,_0x29016a,_0xf973fa){var _0x170037={'raw':![],'where':{}};var _0x5936a3={};var _0x2c292b={'count':0x0,'rows':[]};return db[_0x2f58('0x3e')][_0x2f58('0x68')]({'where':{'id':_0x4cce38[_0x2f58('0x5a')]['id']}})[_0x2f58('0x1d')](handleEntityNotFound(_0x29016a,null))['then'](function(_0x713f35){if(_0x713f35){_0x5936a3[_0x2f58('0x44')]=_[_0x2f58('0x54')](db[_0x2f58('0x84')][_0x2f58('0x3f')]);_0x5936a3['query']=_[_0x2f58('0x54')](_0x4cce38[_0x2f58('0x42')]);_0x5936a3[_0x2f58('0x43')]=_[_0x2f58('0x55')](_0x5936a3[_0x2f58('0x44')],_0x5936a3[_0x2f58('0x42')]);_0x170037[_0x2f58('0x46')]=_[_0x2f58('0x55')](_0x5936a3[_0x2f58('0x44')],qs[_0x2f58('0x45')](_0x4cce38[_0x2f58('0x42')]['fields']));_0x170037['attributes']=_0x170037['attributes']['length']?_0x170037['attributes']:_0x5936a3[_0x2f58('0x44')];if(!_0x4cce38[_0x2f58('0x42')][_0x2f58('0x48')]('nolimit')){_0x170037[_0x2f58('0x2b')]=qs[_0x2f58('0x2b')](_0x4cce38[_0x2f58('0x42')]['limit']);_0x170037[_0x2f58('0x2a')]=qs['offset'](_0x4cce38[_0x2f58('0x42')][_0x2f58('0x2a')]);}_0x170037[_0x2f58('0x60')]=qs[_0x2f58('0x4a')](_0x4cce38[_0x2f58('0x42')][_0x2f58('0x4a')]);_0x170037[_0x2f58('0x4b')]=qs['filters'](_['pick'](_0x4cce38[_0x2f58('0x42')],_0x5936a3[_0x2f58('0x43')]));_0x170037['where'][_0x2f58('0x5d')]=_0x713f35['id'];if(_0x4cce38['query'][_0x2f58('0x4d')]){_0x170037[_0x2f58('0x4b')]=_[_0x2f58('0x4e')](_0x170037[_0x2f58('0x4b')],{'$or':_[_0x2f58('0x3d')](_0x170037['attributes'],function(_0x428fee){var _0x531ca1={};_0x531ca1[_0x428fee]={'$like':'%'+_0x4cce38['query'][_0x2f58('0x4d')]+'%'};return _0x531ca1;})});}_0x170037=_[_0x2f58('0x4e')]({},_0x170037,_0x4cce38['options']);return db[_0x2f58('0x84')][_0x2f58('0x51')]({'where':_0x170037['where']})[_0x2f58('0x1d')](function(_0x48641e){_0x2c292b[_0x2f58('0x51')]=_0x48641e;if(_0x4cce38['query'][_0x2f58('0x52')]){_0x170037['include']=[{'model':db[_0x2f58('0x87')],'as':'Contact','required':![]},{'model':db[_0x2f58('0x88')],'as':_0x2f58('0x89'),'attributes':[_0x2f58('0x34'),'fullname','internal'],'required':![]},{'model':db[_0x2f58('0x8a')],'as':_0x2f58('0x8b'),'attributes':['id',_0x2f58('0x34'),'color'],'where':_0x4cce38[_0x2f58('0x42')][_0x2f58('0x8c')]?{'id':_0x4cce38[_0x2f58('0x42')][_0x2f58('0x8c')]}:undefined,'required':_0x4cce38['query'][_0x2f58('0x8c')]?!![]:![]}];}return db['MailInteraction'][_0x2f58('0x61')](_0x170037);})[_0x2f58('0x1d')](function(_0x31bb4b){_0x2c292b[_0x2f58('0x62')]=_0x31bb4b;return _0x2c292b;});}})['then'](respondWithFilteredResult(_0x29016a,_0x170037))['catch'](handleError(_0x29016a,null));};exports[_0x2f58('0x8d')]=function(_0x33cfc0,_0x41928e,_0x3bbf6d){return db[_0x2f58('0x3e')][_0x2f58('0x68')]({'where':{'id':_0x33cfc0[_0x2f58('0x5a')]['id']}})[_0x2f58('0x1d')](handleEntityNotFound(_0x41928e,null))[_0x2f58('0x1d')](function(_0x2681ce){if(_0x2681ce){return db[_0x2f58('0x8e')][_0x2f58('0x8f')](function(_0x22f21b){return db[_0x2f58('0x90')][_0x2f58('0x30')]({'where':{'MailAccountId':_0x33cfc0[_0x2f58('0x5a')]['id']},'transaction':_0x22f21b})['then'](function(_0x107ad9){var _0x281ba9=_[_0x2f58('0x3d')](_0x33cfc0[_0x2f58('0x59')],function(_0x11f568){_0x11f568[_0x2f58('0x5d')]=_0x33cfc0[_0x2f58('0x5a')]['id'];return _0x11f568;});return db['MailApplication'][_0x2f58('0x91')](_0x281ba9,{'transaction':_0x22f21b});});})['then'](function(){return db[_0x2f58('0x90')][_0x2f58('0x92')]({'where':{'MailAccountId':_0x33cfc0[_0x2f58('0x5a')]['id']},'order':_0x2f58('0x93')});});}})['then'](respondWithResult(_0x41928e,null))[_0x2f58('0x27')](handleError(_0x41928e,null));};exports[_0x2f58('0x94')]=function(_0x4d504c,_0x549083,_0x296ba0){var _0xe9c14f={};var _0x459bdf={};var _0x1cbfd8;var _0x20fb03;return db[_0x2f58('0x3e')][_0x2f58('0x68')]({'where':{'id':_0x4d504c[_0x2f58('0x5a')]['id']}})['then'](handleEntityNotFound(_0x549083,null))['then'](function(_0x194484){if(_0x194484){_0x1cbfd8=_0x194484;_0x459bdf[_0x2f58('0x44')]=_[_0x2f58('0x54')](db[_0x2f58('0x90')][_0x2f58('0x3f')]);_0x459bdf[_0x2f58('0x42')]=_[_0x2f58('0x54')](_0x4d504c['query']);_0x459bdf['filters']=_[_0x2f58('0x55')](_0x459bdf[_0x2f58('0x44')],_0x459bdf[_0x2f58('0x42')]);_0xe9c14f[_0x2f58('0x46')]=_[_0x2f58('0x55')](_0x459bdf[_0x2f58('0x44')],qs[_0x2f58('0x45')](_0x4d504c[_0x2f58('0x42')][_0x2f58('0x45')]));_0xe9c14f[_0x2f58('0x46')]=_0xe9c14f['attributes'][_0x2f58('0x47')]?_0xe9c14f[_0x2f58('0x46')]:_0x459bdf[_0x2f58('0x44')];_0xe9c14f[_0x2f58('0x60')]=qs['sort'](_0x4d504c[_0x2f58('0x42')][_0x2f58('0x4a')]);_0xe9c14f[_0x2f58('0x4b')]=qs[_0x2f58('0x43')](_[_0x2f58('0x4c')](_0x4d504c[_0x2f58('0x42')],_0x459bdf['filters']));if(_0x4d504c[_0x2f58('0x42')][_0x2f58('0x4d')]){_0xe9c14f['where']=_[_0x2f58('0x4e')](_0xe9c14f['where'],{'$or':_[_0x2f58('0x3d')](_0xe9c14f[_0x2f58('0x46')],function(_0x1bc49d){var _0x292c00={};_0x292c00[_0x1bc49d]={'$like':'%'+_0x4d504c['query'][_0x2f58('0x4d')]+'%'};return _0x292c00;})});}_0xe9c14f=_[_0x2f58('0x4e')]({},_0xe9c14f,_0x4d504c[_0x2f58('0x50')]);return _0x1cbfd8['getApplications'](_0xe9c14f);}})[_0x2f58('0x1d')](function(_0x5d86ba){if(_0x5d86ba){_0x20fb03=_0x5d86ba[_0x2f58('0x47')];if(!_0x4d504c[_0x2f58('0x42')][_0x2f58('0x48')]('nolimit')){_0xe9c14f[_0x2f58('0x2b')]=qs[_0x2f58('0x2b')](_0x4d504c['query'][_0x2f58('0x2b')]);_0xe9c14f[_0x2f58('0x2a')]=qs[_0x2f58('0x2a')](_0x4d504c['query'][_0x2f58('0x2a')]);}return _0x1cbfd8[_0x2f58('0x94')](_0xe9c14f);}})[_0x2f58('0x1d')](function(_0x546621){if(_0x546621){return _0x546621?{'count':_0x20fb03,'rows':_0x546621}:null;}})[_0x2f58('0x1d')](respondWithResult(_0x549083,null))[_0x2f58('0x27')](handleError(_0x549083,null));};exports[_0x2f58('0x95')]=function(_0x1e0b18,_0x21ea25,_0x53c116){var _0x22c659={'raw':!![],'where':{}};var _0x406c8f={};var _0x3e38c2={'count':0x0,'rows':[]};return db[_0x2f58('0x3e')][_0x2f58('0x68')]({'where':{'id':_0x1e0b18[_0x2f58('0x5a')]['id']}})[_0x2f58('0x1d')](handleEntityNotFound(_0x21ea25,null))[_0x2f58('0x1d')](function(_0x441b3b){if(_0x441b3b){_0x406c8f['model']=_[_0x2f58('0x54')](db[_0x2f58('0x96')][_0x2f58('0x3f')]);_0x406c8f[_0x2f58('0x42')]=_[_0x2f58('0x54')](_0x1e0b18[_0x2f58('0x42')]);_0x406c8f[_0x2f58('0x43')]=_['intersection'](_0x406c8f[_0x2f58('0x44')],_0x406c8f[_0x2f58('0x42')]);_0x22c659[_0x2f58('0x46')]=_[_0x2f58('0x55')](_0x406c8f[_0x2f58('0x44')],qs[_0x2f58('0x45')](_0x1e0b18[_0x2f58('0x42')]['fields']));_0x22c659[_0x2f58('0x46')]=_0x22c659[_0x2f58('0x46')]['length']?_0x22c659[_0x2f58('0x46')]:_0x406c8f['model'];if(!_0x1e0b18[_0x2f58('0x42')][_0x2f58('0x48')](_0x2f58('0x49'))){_0x22c659[_0x2f58('0x2b')]=qs[_0x2f58('0x2b')](_0x1e0b18[_0x2f58('0x42')][_0x2f58('0x2b')]);_0x22c659[_0x2f58('0x2a')]=qs['offset'](_0x1e0b18[_0x2f58('0x42')]['offset']);}_0x22c659[_0x2f58('0x60')]=qs[_0x2f58('0x4a')](_0x1e0b18[_0x2f58('0x42')]['sort']);_0x22c659['where']=qs[_0x2f58('0x43')](_[_0x2f58('0x4c')](_0x1e0b18['query'],_0x406c8f[_0x2f58('0x43')]));_0x22c659[_0x2f58('0x4b')]['MailAccountId']=_0x441b3b['id'];if(_0x1e0b18['query'][_0x2f58('0x4d')]){_0x22c659[_0x2f58('0x4b')]=_[_0x2f58('0x4e')](_0x22c659[_0x2f58('0x4b')],{'$or':_[_0x2f58('0x3d')](_0x22c659[_0x2f58('0x46')],function(_0xb8e9fb){var _0x4ecf5b={};_0x4ecf5b[_0xb8e9fb]={'$like':'%'+_0x1e0b18['query']['filter']+'%'};return _0x4ecf5b;})});}if(_0x1e0b18[_0x2f58('0x42')][_0x2f58('0x97')]){var _0x1b1b6b=_0x1e0b18[_0x2f58('0x42')][_0x2f58('0x97')][_0x2f58('0x98')](',');var _0x2a81b7={};_0x2a81b7[_0x1b1b6b[0x0]]={'$gte':moment(_0x1b1b6b[0x1])[_0x2f58('0x99')](_0x2f58('0x9a'))};_0x22c659['where']=_[_0x2f58('0x4e')](_0x22c659[_0x2f58('0x4b')],_0x2a81b7);}_0x22c659=_[_0x2f58('0x4e')]({},_0x22c659,_0x1e0b18['options']);return db[_0x2f58('0x96')][_0x2f58('0x51')]({'where':_0x22c659[_0x2f58('0x4b')]})[_0x2f58('0x1d')](function(_0xaf03ed){_0x3e38c2['count']=_0xaf03ed;if(_0x1e0b18[_0x2f58('0x42')][_0x2f58('0x52')]){_0x22c659[_0x2f58('0x56')]=[{'all':!![]}];}return db['MailMessage'][_0x2f58('0x61')](_0x22c659);})[_0x2f58('0x1d')](function(_0x2bb029){_0x3e38c2[_0x2f58('0x62')]=_0x2bb029;return _0x3e38c2;});}})[_0x2f58('0x1d')](respondWithFilteredResult(_0x21ea25,_0x22c659))['catch'](handleError(_0x21ea25,null));};exports['send']=function(_0x3aa460,_0x523eae,_0x206b51){var _0x58696d,_0x792acf={},_0x21e3f3;if(_0x3aa460['body']['to']){_0x21e3f3=_0x3aa460[_0x2f58('0x59')]['to'][_0x2f58('0x98')](',')[0x0];}return db['MailAccount']['find']({'where':{'id':_0x3aa460[_0x2f58('0x5a')]['id']},'include':[{'model':db[_0x2f58('0x9b')],'as':_0x2f58('0x9c'),'include':[{'model':db['CmContact'],'as':'Contacts','where':{'email':_0x21e3f3},'limit':0x1,'order':[[_0x2f58('0x9d'),'DESC']]}]},{'model':db['MailServerOut'],'as':_0x2f58('0x3a'),'raw':!![]}]})[_0x2f58('0x1d')](handleEntityNotFound(_0x523eae,null))[_0x2f58('0x1d')](function(_0x5787c4){if(_0x5787c4){_0x58696d=_0x5787c4;if(_0x5787c4[_0x2f58('0x3a')]){if(_[_0x2f58('0x6c')](_0x3aa460[_0x2f58('0x59')][_0x2f58('0x9e')])){_0x3aa460[_0x2f58('0x59')][_0x2f58('0x9e')]=util['format'](_0x2f58('0x9f'),_0x5787c4[_0x2f58('0x34')],_0x5787c4[_0x2f58('0x6b')]||_0x5787c4[_0x2f58('0x3a')][_0x2f58('0x70')]);}if(_0x3aa460['body']['attachments']&&_0x3aa460[_0x2f58('0x59')][_0x2f58('0xa0')]['length']){for(var _0x980d7=0x0;_0x980d7<_0x3aa460['body'][_0x2f58('0xa0')][_0x2f58('0x47')];_0x980d7+=0x1){_0x3aa460[_0x2f58('0x59')]['attachments'][_0x980d7]={'filename':_0x3aa460[_0x2f58('0x59')][_0x2f58('0xa0')][_0x980d7][_0x2f58('0x34')],'path':path[_0x2f58('0xa1')](config[_0x2f58('0xa2')],_0x2f58('0xa3'),_0x3aa460[_0x2f58('0x59')][_0x2f58('0xa0')][_0x980d7][_0x2f58('0xa4')])};}}var _0x1da45b={'tls':{'rejectUnauthorized':![]}};if(_[_0x2f58('0x6c')](_0x5787c4['Smtp']['service'])){if(_0x5787c4['Smtp'][_0x2f58('0x74')]){_0x1da45b[_0x2f58('0xa5')]={'user':_0x5787c4[_0x2f58('0x3a')][_0x2f58('0x70')],'pass':_0x5787c4[_0x2f58('0x3a')]['pass']};}_0x1da45b[_0x2f58('0x75')]=_0x5787c4['Smtp'][_0x2f58('0x75')];_0x1da45b[_0x2f58('0x76')]=_0x5787c4[_0x2f58('0x3a')][_0x2f58('0x76')];_0x1da45b['secure']=_0x5787c4['Smtp']['secure'];}else{_0x1da45b[_0x2f58('0x77')]=_0x5787c4[_0x2f58('0x3a')][_0x2f58('0x77')];_0x1da45b[_0x2f58('0xa5')]={'user':_0x5787c4[_0x2f58('0x3a')]['user'],'pass':_0x5787c4['Smtp'][_0x2f58('0x72')]};}return respondWithRpcPromise(_0x2f58('0xa6'),'sendMail',{'account':_0x1da45b,'message':_0x3aa460['body']});}else{throw new Error(_0x2f58('0xa7'));}}})[_0x2f58('0x1d')](function(_0x18099e){if(_0x18099e){_0x792acf=_0x18099e;if(_0x58696d[_0x2f58('0x9c')]){if(_0x58696d[_0x2f58('0x9c')][_0x2f58('0xa8')][_0x2f58('0x47')]){return _0x58696d[_0x2f58('0x9c')][_0x2f58('0xa8')][0x0];}else{return db['CmContact'][_0x2f58('0x66')](_[_0x2f58('0xa9')](_0x3aa460[_0x2f58('0x59')],{'firstName':_0x3aa460[_0x2f58('0x59')]['to'],'email':_0x3aa460[_0x2f58('0x59')]['to'],'phone':_0x3aa460[_0x2f58('0x59')]['to'],'ListId':_0x58696d[_0x2f58('0xaa')]}));}}else{throw new Error(_0x2f58('0xa7'));}}})[_0x2f58('0x1d')](function(_0x5be7c3){if(_0x5be7c3){var _0x32bf59={'UserId':_0x3aa460[_0x2f58('0x70')]['id'],'ContactId':_0x5be7c3['id'],'MailAccountId':_0x58696d['id'],'inReplyTo':_0x792acf['messageId'],'to':_0x3aa460[_0x2f58('0x59')]['from'],'cc':_0x3aa460[_0x2f58('0x59')]['cc'],'subject':_0x3aa460[_0x2f58('0x59')][_0x2f58('0xab')],'attach':_0x3aa460['body']['attach'],'firstMsgDirection':_0x2f58('0xac'),'lastMsgAt':moment()[_0x2f58('0x99')](_0x2f58('0x9a')),'lastMsgDirection':_0x2f58('0xac'),'lastMsgBody':_0x3aa460[_0x2f58('0x59')][_0x2f58('0x59')],'Messages':[_[_0x2f58('0x4e')](_0x3aa460[_0x2f58('0x59')],{'messageId':_0x792acf[_0x2f58('0xad')],'sentAt':moment()['format'](_0x2f58('0x9a')),'read':!![],'MailAccountId':_0x58696d['id'],'UserId':_0x3aa460[_0x2f58('0x70')]['id'],'ContactId':_0x5be7c3['id']})]};if(_0x3aa460['body'][_0x2f58('0xae')]){_0x32bf59=_[_0x2f58('0x4e')](_0x32bf59,_0x3aa460[_0x2f58('0x59')][_0x2f58('0xae')]);}return db[_0x2f58('0x84')][_0x2f58('0x66')](_0x32bf59,{'include':[{'model':db['MailMessage'],'as':'Messages'}]});}})[_0x2f58('0x1d')](respondWithResult(_0x523eae,null))[_0x2f58('0x27')](handleError(_0x523eae,null));};exports[_0x2f58('0xaf')]=function(_0x4c1409,_0x30225e,_0x4740c6){return db[_0x2f58('0x3e')][_0x2f58('0x57')]({'where':{'id':_0x4c1409[_0x2f58('0x5a')]['id']},'include':[{'model':db[_0x2f58('0x39')],'as':_0x2f58('0x3a'),'raw':!![]}]})[_0x2f58('0x1d')](handleEntityNotFound(_0x30225e,null))['then'](function(_0x1bf6eb){if(_0x1bf6eb&&_0x1bf6eb[_0x2f58('0x3a')]){var _0x4a3aaa={'id':_0x1bf6eb['id'],'tls':{'rejectUnauthorized':![]}};if(_0x1bf6eb[_0x2f58('0x3a')][_0x2f58('0x77')]){_0x4a3aaa[_0x2f58('0x77')]=_0x1bf6eb['Smtp'][_0x2f58('0x77')];}else{_0x4a3aaa[_0x2f58('0x75')]=_0x1bf6eb[_0x2f58('0x3a')][_0x2f58('0x75')];_0x4a3aaa['port']=_0x1bf6eb['Smtp']['port'];_0x4a3aaa[_0x2f58('0xb0')]=_0x1bf6eb[_0x2f58('0x3a')]['secure'];}if(_0x1bf6eb[_0x2f58('0x3a')][_0x2f58('0x74')]){_0x4a3aaa['auth']={'user':_0x1bf6eb[_0x2f58('0x3a')][_0x2f58('0x70')],'pass':_0x1bf6eb[_0x2f58('0x3a')]['pass']};}return respondWithRpcPromise(_0x2f58('0xb1'),'verifySmtp',{'account':_0x4a3aaa});}})[_0x2f58('0x1d')](respondWithResult(_0x30225e,null))[_0x2f58('0x27')](handleError(_0x30225e,null));};exports[_0x2f58('0x30')]=function(_0x239d23,_0x191219){return db[_0x2f58('0x3e')][_0x2f58('0x57')]({'where':{'id':_0x239d23[_0x2f58('0x5a')]['id']}})[_0x2f58('0x1d')](handleEntityNotFound(_0x191219,null))[_0x2f58('0x1d')](function(_0x2faef7){if(_0x2faef7&&_0x2faef7[_0x2f58('0x77')]){throw new db[(_0x2f58('0xb2'))][(_0x2f58('0xb3'))](_0x2f58('0xb4'));}return _0x2faef7;})[_0x2f58('0x1d')](removeEntity(_0x191219,null))[_0x2f58('0x27')](handleError(_0x191219,null));};exports[_0x2f58('0xb5')]=function(_0x3ded8b,_0x51cb7b,_0x5f4968){return db[_0x2f58('0x3e')][_0x2f58('0x57')]({'where':{'id':_0x3ded8b[_0x2f58('0x5a')]['id']}})[_0x2f58('0x1d')](handleEntityNotFound(_0x51cb7b,null))[_0x2f58('0x1d')](function(_0x3c339a){if(_0x3c339a){return _0x3c339a[_0x2f58('0xb5')](_0x3ded8b[_0x2f58('0x59')][_0x2f58('0x6a')],_[_0x2f58('0x85')](_0x3ded8b['body'],['ids','id'])||{})['spread'](function(_0x1b079b){for(var _0x884b21=0x0;_0x884b21<_0x3ded8b[_0x2f58('0x59')][_0x2f58('0x6a')][_0x2f58('0x47')];_0x884b21+=0x1){socket[_0x2f58('0xb6')](_0x2f58('0xb7'),{'UserId':_0x3ded8b['body'][_0x2f58('0x6a')][_0x884b21],'MailAccountId':_0x3ded8b['params']['id']});}return _0x1b079b;});}})[_0x2f58('0x1d')](respondWithResult(_0x51cb7b,null))['catch'](handleError(_0x51cb7b,null));};exports['removeAgents']=function(_0x5273ec,_0x1230ed,_0x1024ec){return db['MailAccount'][_0x2f58('0x57')]({'where':{'id':_0x5273ec[_0x2f58('0x5a')]['id']}})[_0x2f58('0x1d')](handleEntityNotFound(_0x1230ed,null))[_0x2f58('0x1d')](function(_0x282703){if(_0x282703){return _0x282703[_0x2f58('0xb8')](_0x5273ec[_0x2f58('0x42')][_0x2f58('0x6a')])[_0x2f58('0x1d')](function(){if(_[_0x2f58('0xb9')](_0x5273ec[_0x2f58('0x42')][_0x2f58('0x6a')])){for(var _0x554304=0x0;_0x554304<_0x5273ec['query'][_0x2f58('0x6a')][_0x2f58('0x47')];_0x554304+=0x1){socket[_0x2f58('0xb6')](_0x2f58('0xba'),{'UserId':Number(_0x5273ec[_0x2f58('0x42')][_0x2f58('0x6a')][_0x554304]),'MailAccountId':Number(_0x5273ec[_0x2f58('0x5a')]['id'])});}}else{socket['emit'](_0x2f58('0xba'),{'UserId':Number(_0x5273ec[_0x2f58('0x42')]['ids']),'MailAccountId':Number(_0x5273ec[_0x2f58('0x5a')]['id'])});}});}})[_0x2f58('0x1d')](respondWithStatusCode(_0x1230ed,null))['catch'](handleError(_0x1230ed,null));};exports[_0x2f58('0xbb')]=function(_0x2d250d,_0x23191d,_0x845cbc){var _0x5b31b1={};var _0x339fe0={};var _0x54f433;var _0x2e4902;return db[_0x2f58('0x3e')][_0x2f58('0x68')]({'where':{'id':_0x2d250d['params']['id']}})[_0x2f58('0x1d')](handleEntityNotFound(_0x23191d,null))['then'](function(_0x19213b){if(_0x19213b){_0x54f433=_0x19213b;_0x339fe0['model']=_[_0x2f58('0x54')](db[_0x2f58('0x88')][_0x2f58('0x3f')]);_0x339fe0['query']=_['keys'](_0x2d250d[_0x2f58('0x42')]);_0x339fe0[_0x2f58('0x43')]=_[_0x2f58('0x55')](_0x339fe0[_0x2f58('0x44')],_0x339fe0[_0x2f58('0x42')]);_0x5b31b1[_0x2f58('0x46')]=_[_0x2f58('0x55')](_0x339fe0[_0x2f58('0x44')],qs[_0x2f58('0x45')](_0x2d250d[_0x2f58('0x42')][_0x2f58('0x45')]));_0x5b31b1[_0x2f58('0x46')]=_0x5b31b1[_0x2f58('0x46')][_0x2f58('0x47')]?_0x5b31b1[_0x2f58('0x46')]:_0x339fe0[_0x2f58('0x44')];_0x5b31b1[_0x2f58('0x60')]=qs[_0x2f58('0x4a')](_0x2d250d[_0x2f58('0x42')][_0x2f58('0x4a')]);_0x5b31b1[_0x2f58('0x4b')]=qs[_0x2f58('0x43')](_[_0x2f58('0x4c')](_0x2d250d[_0x2f58('0x42')],_0x339fe0[_0x2f58('0x43')]));if(_0x2d250d['query'][_0x2f58('0x4d')]){_0x5b31b1[_0x2f58('0x4b')]=_[_0x2f58('0x4e')](_0x5b31b1[_0x2f58('0x4b')],{'$or':_[_0x2f58('0x3d')](_0x5b31b1[_0x2f58('0x46')],function(_0x4ba851){var _0x131c6e={};_0x131c6e[_0x4ba851]={'$like':'%'+_0x2d250d[_0x2f58('0x42')][_0x2f58('0x4d')]+'%'};return _0x131c6e;})});}_0x5b31b1=_[_0x2f58('0x4e')]({},_0x5b31b1,_0x2d250d[_0x2f58('0x50')]);return _0x54f433['getAgents'](_0x5b31b1);}})[_0x2f58('0x1d')](function(_0x4a4e46){if(_0x4a4e46){_0x2e4902=_0x4a4e46['length'];if(!_0x2d250d['query'][_0x2f58('0x48')]('nolimit')){_0x5b31b1['limit']=qs['limit'](_0x2d250d[_0x2f58('0x42')][_0x2f58('0x2b')]);_0x5b31b1[_0x2f58('0x2a')]=qs['offset'](_0x2d250d[_0x2f58('0x42')][_0x2f58('0x2a')]);}return _0x54f433[_0x2f58('0xbb')](_0x5b31b1);}})[_0x2f58('0x1d')](function(_0x41ab5b){if(_0x41ab5b){return _0x41ab5b?{'count':_0x2e4902,'rows':_0x41ab5b}:null;}})[_0x2f58('0x1d')](respondWithResult(_0x23191d,null))[_0x2f58('0x27')](handleError(_0x23191d,null));};
\ No newline at end of file