Built motion from commit (unavailable).|2.5.31
[motion2.git] / server / api / mailAccount / mailAccount.controller.js
index 7cb84f2..3ada8ed 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x97fb=['List\x20not\x20found','messageId','subject','attach','out','YYYY-MM-DD\x20HH:mm:ss','Interaction','Messages','verifySmtp','ValidationError','You\x20can\x27t\x20remove\x20the\x20mail\x20service\x20account','addAgents','omit','spread','emit','userMailAccount:save','removeAgents','isArray','getAgents','eml-format','zip-dir','fast-json-patch','request-promise','moment','bluebird','util','path','sox','to-csv','ejs','fs-extra','lodash','squel','jsforce','desk.js','papaparse','juice','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','localhost','socket.io-emitter','./mailAccount.socket','register','jayson/promise','client','http','request','info','MailAccount,\x20%s,\x20%s','request\x20sent','debug','stringify','error','code','message','result','catch','sendStatus','status','json','offset','undefined','count','set','apply','update','then','destroy','UserProfileResource','end','stack','name','send','merge','contact','agent','interaction','index','MailServerIn','Imap','Smtp','mandatoryDispositionPause','MailAccount','type','key','model','keys','query','intersection','attributes','fields','length','hasOwnProperty','nolimit','limit','order','sort','where','filters','pick','filter','map','VIRTUAL','options','includeAll','include','findAll','rows','show','params','Pause','rawAttributes','find','body','MailServerOut','describe','addDisposition','MailAccountId','Disposition','create','getDispositions','findOne','removeDispositions','addAnswer','CannedAnswer','getAnswers','removeAnswers','email','ListId','isNil','active','description','cservice','cauthentication','user','password','pass','cpassword','authentication','host','port','service','cuser','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','getImap','addImap','removeImap','setImap','getSmtp','addSmtp','setSmtp','MailInteraction','ids','getInteractions','CmContact','Contact','User','Owner','fullname','internal','Tag','Tags','color','tag','addApplications','sequelize','transaction','MailApplication','findAndCountAll','priority','getApplications','MailMessage','$gte','split','inlineCss','CmList','Contacts','updatedAt','DESC','from','format','%s\x20<%s>','attachments','join','root','server/files/attachments','basename','auth','secure','SendMail','sendMail','List'];(function(_0xbc267d,_0x122f36){var _0x5cdac8=function(_0x232660){while(--_0x232660){_0xbc267d['push'](_0xbc267d['shift']());}};_0x5cdac8(++_0x122f36);}(_0x97fb,0x1a9));var _0xb97f=function(_0x529abc,_0x17b97e){_0x529abc=_0x529abc-0x0;var _0x453afa=_0x97fb[_0x529abc];return _0x453afa;};'use strict';var emlformat=require(_0xb97f('0x0'));var rimraf=require('rimraf');var zipdir=require(_0xb97f('0x1'));var jsonpatch=require(_0xb97f('0x2'));var rp=require(_0xb97f('0x3'));var moment=require(_0xb97f('0x4'));var BPromise=require(_0xb97f('0x5'));var Mustache=require('mustache');var util=require(_0xb97f('0x6'));var path=require(_0xb97f('0x7'));var sox=require(_0xb97f('0x8'));var csv=require(_0xb97f('0x9'));var ejs=require(_0xb97f('0xa'));var fs=require('fs');var fs_extra=require(_0xb97f('0xb'));var _=require(_0xb97f('0xc'));var squel=require(_0xb97f('0xd'));var crypto=require('crypto');var jsforce=require(_0xb97f('0xe'));var deskjs=require(_0xb97f('0xf'));var toCsv=require(_0xb97f('0x9'));var querystring=require('querystring');var Papa=require(_0xb97f('0x10'));var htmlToText=require('html-to-text');var juice=require(_0xb97f('0x11'));var Redis=require(_0xb97f('0x12'));var authService=require(_0xb97f('0x13'));var qs=require('../../components/parsers/qs');var as=require(_0xb97f('0x14'));var hardwareService=require(_0xb97f('0x15'));var logger=require(_0xb97f('0x16'))('api');var utils=require('../../config/utils');var config=require(_0xb97f('0x17'));var licenseUtil=require(_0xb97f('0x18'));var db=require(_0xb97f('0x19'))['db'];config[_0xb97f('0x1a')]=_[_0xb97f('0x1b')](config[_0xb97f('0x1a')],{'host':_0xb97f('0x1c'),'port':0x18eb});var socket=require(_0xb97f('0x1d'))(new Redis(config[_0xb97f('0x1a')]));require(_0xb97f('0x1e'))[_0xb97f('0x1f')](socket);var jayson=require(_0xb97f('0x20'));var client=jayson[_0xb97f('0x21')][_0xb97f('0x22')]({'port':0x232b});function respondWithRpcPromise(_0x21003f,_0xe6df13,_0x44d3bf,_0x1d7cac){return new BPromise(function(_0x45dfa9,_0x2b14c7){var _0x5f5747=_0x1d7cac||client;return _0x5f5747[_0xb97f('0x23')](_0x21003f,_0x44d3bf)['then'](function(_0x66ad46){logger[_0xb97f('0x24')](_0xb97f('0x25'),_0xe6df13,_0xb97f('0x26'));logger[_0xb97f('0x27')]('MailAccount,\x20%s,\x20%s,\x20%s',_0xe6df13,_0xb97f('0x26'),JSON[_0xb97f('0x28')](_0x66ad46));if(_0x66ad46[_0xb97f('0x29')]){if(_0x66ad46[_0xb97f('0x29')][_0xb97f('0x2a')]===0x1f4){logger[_0xb97f('0x29')](_0xb97f('0x25'),_0xe6df13,_0x66ad46[_0xb97f('0x29')][_0xb97f('0x2b')]);return _0x2b14c7(_0x66ad46[_0xb97f('0x29')]['message']);}logger[_0xb97f('0x29')](_0xb97f('0x25'),_0xe6df13,_0x66ad46['error']['message']);return _0x45dfa9(_0x66ad46[_0xb97f('0x29')][_0xb97f('0x2b')]);}else{logger[_0xb97f('0x24')](_0xb97f('0x25'),_0xe6df13,_0xb97f('0x26'));_0x45dfa9(_0x66ad46[_0xb97f('0x2c')][_0xb97f('0x2b')]);}})[_0xb97f('0x2d')](function(_0x424198){logger[_0xb97f('0x29')]('MailAccount,\x20%s,\x20%s',_0xe6df13,_0x424198);_0x2b14c7(_0x424198);});});}function respondWithStatusCode(_0x374ffd,_0x30b230){_0x30b230=_0x30b230||0xcc;return function(_0x4c8d4c){if(_0x4c8d4c){return _0x374ffd[_0xb97f('0x2e')](_0x30b230);}return _0x374ffd[_0xb97f('0x2f')](_0x30b230)['end']();};}function respondWithResult(_0x9a11ee,_0x5e236a){_0x5e236a=_0x5e236a||0xc8;return function(_0x4b5a93){if(_0x4b5a93){return _0x9a11ee[_0xb97f('0x2f')](_0x5e236a)[_0xb97f('0x30')](_0x4b5a93);}};}function respondWithFilteredResult(_0x2c0fd5,_0x3282b5){return function(_0x3cd7c4){if(_0x3cd7c4){var _0x47f1fd=typeof _0x3282b5[_0xb97f('0x31')]===_0xb97f('0x32')&&typeof _0x3282b5['limit']===_0xb97f('0x32');var _0xba2a71=_0x3cd7c4[_0xb97f('0x33')];var _0x258677=_0x47f1fd?0x0:_0x3282b5[_0xb97f('0x31')];var _0x47c79a=_0x47f1fd?_0x3cd7c4[_0xb97f('0x33')]:_0x3282b5[_0xb97f('0x31')]+_0x3282b5['limit'];var _0x1de703;if(_0x47c79a>=_0xba2a71){_0x47c79a=_0xba2a71;_0x1de703=0xc8;}else{_0x1de703=0xce;}_0x2c0fd5[_0xb97f('0x2f')](_0x1de703);return _0x2c0fd5[_0xb97f('0x34')]('Content-Range',_0x258677+'-'+_0x47c79a+'/'+_0xba2a71)[_0xb97f('0x30')](_0x3cd7c4);}return null;};}function patchUpdates(_0xf24c94){return function(_0x50ec1a){try{jsonpatch[_0xb97f('0x35')](_0x50ec1a,_0xf24c94,!![]);}catch(_0x56ca3a){return BPromise['reject'](_0x56ca3a);}return _0x50ec1a['save']();};}function saveUpdates(_0x3fc08b,_0x1968af){return function(_0x63757){if(_0x63757){return _0x63757[_0xb97f('0x36')](_0x3fc08b)[_0xb97f('0x37')](function(_0x165d6e){return _0x165d6e;});}return null;};}function removeEntity(_0x2f8c04,_0x2361db){return function(_0x5c670a){if(_0x5c670a){return _0x5c670a[_0xb97f('0x38')]()[_0xb97f('0x37')](function(){var _0x18432c=_0x5c670a['get']({'plain':!![]});var _0x204ce8='MailAccounts';return db[_0xb97f('0x39')]['destroy']({'where':{'type':_0x204ce8,'resourceId':_0x18432c['id']}})[_0xb97f('0x37')](function(){return _0x5c670a;});})[_0xb97f('0x37')](function(){_0x2f8c04[_0xb97f('0x2f')](0xcc)[_0xb97f('0x3a')]();});}};}function handleEntityNotFound(_0x1de32d,_0x1e354e){return function(_0x51a330){if(!_0x51a330){_0x1de32d[_0xb97f('0x2e')](0x194);}return _0x51a330;};}function handleError(_0x359469,_0x36c7aa){_0x36c7aa=_0x36c7aa||0x1f4;return function(_0x33435c){logger[_0xb97f('0x29')](_0x33435c[_0xb97f('0x3b')]);if(_0x33435c[_0xb97f('0x3c')]){delete _0x33435c[_0xb97f('0x3c')];}_0x359469[_0xb97f('0x2f')](_0x36c7aa)[_0xb97f('0x3d')](_0x33435c);};}function getMustacheRender(_0x57321d,_0x8fe409){return Mustache['render'](_0x57321d,_[_0xb97f('0x3e')](_0x8fe409['body'],{'contact':_0x8fe409[_0xb97f('0x3f')],'message':_0x8fe409[_0xb97f('0x2b')],'agent':_0x8fe409[_0xb97f('0x40')],'interaction':_0x8fe409[_0xb97f('0x41')],'account':_0x8fe409['account']}))||'';}exports[_0xb97f('0x42')]=function(_0x48b3f0,_0x55cafc){var _0x36f1fa={'include':[{'model':db[_0xb97f('0x43')],'as':_0xb97f('0x44')},{'model':db['MailServerOut'],'as':_0xb97f('0x45')},{'model':db['Pause'],'as':_0xb97f('0x46')}]},_0x5845a6={},_0x1911e9={'count':0x0,'rows':[]};var _0x553a2f=_['map'](db[_0xb97f('0x47')]['rawAttributes'],function(_0x1908e1){return{'name':_0x1908e1['fieldName'],'type':_0x1908e1[_0xb97f('0x48')][_0xb97f('0x49')]};});_0x5845a6[_0xb97f('0x4a')]=_['map'](_0x553a2f,_0xb97f('0x3c'));_0x5845a6['query']=_[_0xb97f('0x4b')](_0x48b3f0[_0xb97f('0x4c')]);_0x5845a6['filters']=_[_0xb97f('0x4d')](_0x5845a6[_0xb97f('0x4a')],_0x5845a6[_0xb97f('0x4c')]);_0x36f1fa[_0xb97f('0x4e')]=_['intersection'](_0x5845a6['model'],qs[_0xb97f('0x4f')](_0x48b3f0['query'][_0xb97f('0x4f')]));_0x36f1fa['attributes']=_0x36f1fa['attributes'][_0xb97f('0x50')]?_0x36f1fa[_0xb97f('0x4e')]:_0x5845a6['model'];if(!_0x48b3f0[_0xb97f('0x4c')][_0xb97f('0x51')](_0xb97f('0x52'))){_0x36f1fa[_0xb97f('0x53')]=qs[_0xb97f('0x53')](_0x48b3f0[_0xb97f('0x4c')][_0xb97f('0x53')]);_0x36f1fa['offset']=qs['offset'](_0x48b3f0[_0xb97f('0x4c')][_0xb97f('0x31')]);}_0x36f1fa[_0xb97f('0x54')]=qs[_0xb97f('0x55')](_0x48b3f0['query'][_0xb97f('0x55')]);_0x36f1fa[_0xb97f('0x56')]=qs[_0xb97f('0x57')](_[_0xb97f('0x58')](_0x48b3f0[_0xb97f('0x4c')],_0x5845a6[_0xb97f('0x57')]),_0x553a2f);if(_0x48b3f0[_0xb97f('0x4c')][_0xb97f('0x59')]){_0x36f1fa[_0xb97f('0x56')]=_[_0xb97f('0x3e')](_0x36f1fa[_0xb97f('0x56')],{'$or':_[_0xb97f('0x5a')](_0x553a2f,function(_0x1334c4){if(_0x1334c4[_0xb97f('0x48')]!==_0xb97f('0x5b')){var _0x19e8b2={};_0x19e8b2[_0x1334c4[_0xb97f('0x3c')]]={'$like':'%'+_0x48b3f0[_0xb97f('0x4c')][_0xb97f('0x59')]+'%'};return _0x19e8b2;}})});}_0x36f1fa=_[_0xb97f('0x3e')]({},_0x36f1fa,_0x48b3f0[_0xb97f('0x5c')]);var _0x51f2cf={'where':_0x36f1fa[_0xb97f('0x56')]};return db[_0xb97f('0x47')][_0xb97f('0x33')](_0x51f2cf)[_0xb97f('0x37')](function(_0x32e9c8){_0x1911e9[_0xb97f('0x33')]=_0x32e9c8;if(_0x48b3f0['query'][_0xb97f('0x5d')]){_0x36f1fa[_0xb97f('0x5e')]=[{'all':!![]}];}return db[_0xb97f('0x47')][_0xb97f('0x5f')](_0x36f1fa);})[_0xb97f('0x37')](function(_0x155506){_0x1911e9[_0xb97f('0x60')]=_0x155506;return _0x1911e9;})[_0xb97f('0x37')](respondWithFilteredResult(_0x55cafc,_0x36f1fa))[_0xb97f('0x2d')](handleError(_0x55cafc,null));};exports[_0xb97f('0x61')]=function(_0x369d4f,_0x55bd03){var _0x3a5766={'raw':![],'where':{'id':_0x369d4f[_0xb97f('0x62')]['id']},'include':[{'model':db[_0xb97f('0x43')],'as':_0xb97f('0x44')},{'model':db['MailServerOut'],'as':'Smtp'},{'model':db[_0xb97f('0x63')],'as':_0xb97f('0x46')}]},_0x50ca4f={};_0x50ca4f[_0xb97f('0x4a')]=_['keys'](db[_0xb97f('0x47')][_0xb97f('0x64')]);_0x50ca4f['query']=_['keys'](_0x369d4f[_0xb97f('0x4c')]);_0x50ca4f[_0xb97f('0x57')]=_[_0xb97f('0x4d')](_0x50ca4f[_0xb97f('0x4a')],_0x50ca4f[_0xb97f('0x4c')]);_0x3a5766[_0xb97f('0x4e')]=_[_0xb97f('0x4d')](_0x50ca4f['model'],qs[_0xb97f('0x4f')](_0x369d4f['query'][_0xb97f('0x4f')]));_0x3a5766[_0xb97f('0x4e')]=_0x3a5766[_0xb97f('0x4e')][_0xb97f('0x50')]?_0x3a5766[_0xb97f('0x4e')]:_0x50ca4f[_0xb97f('0x4a')];if(_0x369d4f[_0xb97f('0x4c')][_0xb97f('0x5d')]){_0x3a5766[_0xb97f('0x5e')]=[{'all':!![]}];}_0x3a5766=_['merge']({},_0x3a5766,_0x369d4f[_0xb97f('0x5c')]);return db[_0xb97f('0x47')][_0xb97f('0x65')](_0x3a5766)['then'](handleEntityNotFound(_0x55bd03,null))[_0xb97f('0x37')](respondWithResult(_0x55bd03,null))[_0xb97f('0x2d')](handleError(_0x55bd03,null));};exports[_0xb97f('0x36')]=function(_0x3f2b76,_0x1945a0){if(_0x3f2b76[_0xb97f('0x66')]['id']){delete _0x3f2b76['body']['id'];}return db[_0xb97f('0x47')][_0xb97f('0x65')]({'where':{'id':_0x3f2b76[_0xb97f('0x62')]['id']},'include':[{'model':db[_0xb97f('0x43')],'as':_0xb97f('0x44')},{'model':db[_0xb97f('0x67')],'as':_0xb97f('0x45')},{'model':db[_0xb97f('0x63')],'as':_0xb97f('0x46')}]})[_0xb97f('0x37')](handleEntityNotFound(_0x1945a0,null))[_0xb97f('0x37')](saveUpdates(_0x3f2b76[_0xb97f('0x66')],null))['then'](function(_0x42ea10){if(_0x42ea10&&_0x3f2b76[_0xb97f('0x66')][_0xb97f('0x44')]){return db[_0xb97f('0x43')][_0xb97f('0x36')](_0x3f2b76[_0xb97f('0x66')][_0xb97f('0x44')],{'where':{'MailAccountId':_0x42ea10['id']}})['then'](function(){return _0x42ea10;});}return _0x42ea10;})[_0xb97f('0x37')](function(_0x599739){if(_0x599739&&_0x3f2b76['body']['Smtp']){return db[_0xb97f('0x67')]['update'](_0x3f2b76[_0xb97f('0x66')][_0xb97f('0x45')],{'where':{'MailAccountId':_0x599739['id']}})[_0xb97f('0x37')](function(){return _0x599739;});}return _0x599739;})[_0xb97f('0x37')](respondWithResult(_0x1945a0,null))['catch'](handleError(_0x1945a0,null));};exports[_0xb97f('0x68')]=function(_0x30826f,_0x2096f1){return db[_0xb97f('0x47')][_0xb97f('0x68')]()[_0xb97f('0x37')](respondWithResult(_0x2096f1,null))[_0xb97f('0x2d')](handleError(_0x2096f1,null));};exports[_0xb97f('0x69')]=function(_0x2b5311,_0x3b23ff,_0x22aae5){if(_0x2b5311['body']['id']){delete _0x2b5311['body']['id'];}return db[_0xb97f('0x47')][_0xb97f('0x65')]({'where':{'id':_0x2b5311[_0xb97f('0x62')]['id']}})['then'](handleEntityNotFound(_0x3b23ff,null))[_0xb97f('0x37')](function(_0x102a7c){if(_0x102a7c){_0x2b5311['body'][_0xb97f('0x6a')]=_0x102a7c['id'];return db[_0xb97f('0x6b')][_0xb97f('0x6c')](_0x2b5311[_0xb97f('0x66')]);}})[_0xb97f('0x37')](respondWithResult(_0x3b23ff,null))[_0xb97f('0x2d')](handleError(_0x3b23ff,null));};exports[_0xb97f('0x6d')]=function(_0x415168,_0x26f84b,_0xbb2649){var _0x4c282c={'raw':![],'where':{}};var _0x204f9f={};var _0xfd4ff5={'count':0x0,'rows':[]};return db[_0xb97f('0x47')][_0xb97f('0x6e')]({'where':{'id':_0x415168['params']['id']}})[_0xb97f('0x37')](handleEntityNotFound(_0x26f84b,null))[_0xb97f('0x37')](function(_0x4e2c7d){if(_0x4e2c7d){_0x204f9f[_0xb97f('0x4a')]=_['keys'](db[_0xb97f('0x6b')][_0xb97f('0x64')]);_0x204f9f[_0xb97f('0x4c')]=_['keys'](_0x415168[_0xb97f('0x4c')]);_0x204f9f['filters']=_[_0xb97f('0x4d')](_0x204f9f[_0xb97f('0x4a')],_0x204f9f[_0xb97f('0x4c')]);_0x4c282c[_0xb97f('0x4e')]=_[_0xb97f('0x4d')](_0x204f9f[_0xb97f('0x4a')],qs[_0xb97f('0x4f')](_0x415168[_0xb97f('0x4c')][_0xb97f('0x4f')]));_0x4c282c[_0xb97f('0x4e')]=_0x4c282c['attributes'][_0xb97f('0x50')]?_0x4c282c['attributes']:_0x204f9f[_0xb97f('0x4a')];if(!_0x415168[_0xb97f('0x4c')][_0xb97f('0x51')](_0xb97f('0x52'))){_0x4c282c[_0xb97f('0x53')]=qs[_0xb97f('0x53')](_0x415168['query']['limit']);_0x4c282c[_0xb97f('0x31')]=qs[_0xb97f('0x31')](_0x415168[_0xb97f('0x4c')][_0xb97f('0x31')]);}_0x4c282c[_0xb97f('0x54')]=qs[_0xb97f('0x55')](_0x415168[_0xb97f('0x4c')][_0xb97f('0x55')]);_0x4c282c[_0xb97f('0x56')]=qs[_0xb97f('0x57')](_[_0xb97f('0x58')](_0x415168[_0xb97f('0x4c')],_0x204f9f[_0xb97f('0x57')]));_0x4c282c['where'][_0xb97f('0x6a')]=_0x4e2c7d['id'];if(_0x415168[_0xb97f('0x4c')][_0xb97f('0x59')]){_0x4c282c[_0xb97f('0x56')]=_['merge'](_0x4c282c[_0xb97f('0x56')],{'$or':_[_0xb97f('0x5a')](_0x4c282c[_0xb97f('0x4e')],function(_0x20bc7c){var _0x4bb24e={};_0x4bb24e[_0x20bc7c]={'$like':'%'+_0x415168[_0xb97f('0x4c')][_0xb97f('0x59')]+'%'};return _0x4bb24e;})});}_0x4c282c=_[_0xb97f('0x3e')]({},_0x4c282c,_0x415168[_0xb97f('0x5c')]);return db[_0xb97f('0x6b')][_0xb97f('0x33')]({'where':_0x4c282c[_0xb97f('0x56')]})[_0xb97f('0x37')](function(_0x3a112e){_0xfd4ff5['count']=_0x3a112e;if(_0x415168[_0xb97f('0x4c')]['includeAll']){_0x4c282c[_0xb97f('0x5e')]=[{'all':!![]}];}return db['Disposition']['findAll'](_0x4c282c);})[_0xb97f('0x37')](function(_0x3b09fa){_0xfd4ff5[_0xb97f('0x60')]=_0x3b09fa;return _0xfd4ff5;});}})[_0xb97f('0x37')](respondWithFilteredResult(_0x26f84b,_0x4c282c))[_0xb97f('0x2d')](handleError(_0x26f84b,null));};exports['removeDispositions']=function(_0x1a5d25,_0x425e0a,_0x11ed2f){return db[_0xb97f('0x47')]['find']({'where':{'id':_0x1a5d25[_0xb97f('0x62')]['id']}})[_0xb97f('0x37')](handleEntityNotFound(_0x425e0a,null))['then'](function(_0x173b76){if(_0x173b76){return _0x173b76[_0xb97f('0x6f')](_0x1a5d25[_0xb97f('0x4c')]['ids']);}})[_0xb97f('0x37')](respondWithStatusCode(_0x425e0a,null))[_0xb97f('0x2d')](handleError(_0x425e0a,null));};exports[_0xb97f('0x70')]=function(_0x2df4d0,_0x4e1777,_0x5e6777){if(_0x2df4d0['body']['id']){delete _0x2df4d0[_0xb97f('0x66')]['id'];}return db[_0xb97f('0x47')][_0xb97f('0x65')]({'where':{'id':_0x2df4d0['params']['id']}})[_0xb97f('0x37')](handleEntityNotFound(_0x4e1777,null))[_0xb97f('0x37')](function(_0x5d3163){if(_0x5d3163){_0x2df4d0[_0xb97f('0x66')][_0xb97f('0x6a')]=_0x5d3163['id'];return db[_0xb97f('0x71')][_0xb97f('0x6c')](_0x2df4d0[_0xb97f('0x66')]);}})[_0xb97f('0x37')](respondWithResult(_0x4e1777,null))[_0xb97f('0x2d')](handleError(_0x4e1777,null));};exports[_0xb97f('0x72')]=function(_0x5d791e,_0x1b651f,_0x5e7ff6){var _0x3a65f2={'raw':![],'where':{}};var _0x35cece={};var _0x139ee8={'count':0x0,'rows':[]};return db[_0xb97f('0x47')][_0xb97f('0x6e')]({'where':{'id':_0x5d791e[_0xb97f('0x62')]['id']}})[_0xb97f('0x37')](handleEntityNotFound(_0x1b651f,null))[_0xb97f('0x37')](function(_0xbffed){if(_0xbffed){_0x35cece[_0xb97f('0x4a')]=_[_0xb97f('0x4b')](db[_0xb97f('0x71')][_0xb97f('0x64')]);_0x35cece[_0xb97f('0x4c')]=_[_0xb97f('0x4b')](_0x5d791e[_0xb97f('0x4c')]);_0x35cece[_0xb97f('0x57')]=_[_0xb97f('0x4d')](_0x35cece[_0xb97f('0x4a')],_0x35cece[_0xb97f('0x4c')]);_0x3a65f2[_0xb97f('0x4e')]=_['intersection'](_0x35cece[_0xb97f('0x4a')],qs['fields'](_0x5d791e[_0xb97f('0x4c')][_0xb97f('0x4f')]));_0x3a65f2[_0xb97f('0x4e')]=_0x3a65f2[_0xb97f('0x4e')][_0xb97f('0x50')]?_0x3a65f2['attributes']:_0x35cece['model'];if(!_0x5d791e[_0xb97f('0x4c')][_0xb97f('0x51')]('nolimit')){_0x3a65f2[_0xb97f('0x53')]=qs[_0xb97f('0x53')](_0x5d791e['query'][_0xb97f('0x53')]);_0x3a65f2[_0xb97f('0x31')]=qs[_0xb97f('0x31')](_0x5d791e[_0xb97f('0x4c')][_0xb97f('0x31')]);}_0x3a65f2['order']=qs['sort'](_0x5d791e[_0xb97f('0x4c')][_0xb97f('0x55')]);_0x3a65f2[_0xb97f('0x56')]=qs[_0xb97f('0x57')](_[_0xb97f('0x58')](_0x5d791e[_0xb97f('0x4c')],_0x35cece[_0xb97f('0x57')]));_0x3a65f2[_0xb97f('0x56')][_0xb97f('0x6a')]=_0xbffed['id'];if(_0x5d791e[_0xb97f('0x4c')][_0xb97f('0x59')]){_0x3a65f2[_0xb97f('0x56')]=_['merge'](_0x3a65f2[_0xb97f('0x56')],{'$or':_[_0xb97f('0x5a')](_0x3a65f2['attributes'],function(_0x36980f){var _0x47422d={};_0x47422d[_0x36980f]={'$like':'%'+_0x5d791e[_0xb97f('0x4c')][_0xb97f('0x59')]+'%'};return _0x47422d;})});}_0x3a65f2=_[_0xb97f('0x3e')]({},_0x3a65f2,_0x5d791e['options']);return db[_0xb97f('0x71')][_0xb97f('0x33')]({'where':_0x3a65f2[_0xb97f('0x56')]})[_0xb97f('0x37')](function(_0x53ae1c){_0x139ee8['count']=_0x53ae1c;if(_0x5d791e[_0xb97f('0x4c')]['includeAll']){_0x3a65f2[_0xb97f('0x5e')]=[{'all':!![]}];}return db[_0xb97f('0x71')]['findAll'](_0x3a65f2);})[_0xb97f('0x37')](function(_0x1c25af){_0x139ee8[_0xb97f('0x60')]=_0x1c25af;return _0x139ee8;});}})[_0xb97f('0x37')](respondWithFilteredResult(_0x1b651f,_0x3a65f2))[_0xb97f('0x2d')](handleError(_0x1b651f,null));};exports[_0xb97f('0x73')]=function(_0x42516b,_0x1e9a2c,_0x11ce09){return db[_0xb97f('0x47')][_0xb97f('0x65')]({'where':{'id':_0x42516b[_0xb97f('0x62')]['id']}})[_0xb97f('0x37')](handleEntityNotFound(_0x1e9a2c,null))['then'](function(_0x118188){if(_0x118188){return _0x118188[_0xb97f('0x73')](_0x42516b[_0xb97f('0x4c')]['ids']);}})[_0xb97f('0x37')](respondWithStatusCode(_0x1e9a2c,null))[_0xb97f('0x2d')](handleError(_0x1e9a2c,null));};exports[_0xb97f('0x6c')]=function(_0x48fa34,_0x378f7b){var _0x238e15={'name':_0x48fa34[_0xb97f('0x66')][_0xb97f('0x3c')],'key':_0x48fa34[_0xb97f('0x66')]['key'],'email':_0x48fa34[_0xb97f('0x66')][_0xb97f('0x74')],'ListId':_0x48fa34[_0xb97f('0x66')][_0xb97f('0x75')],'active':!_[_0xb97f('0x76')](_0x48fa34[_0xb97f('0x66')][_0xb97f('0x77')])?_0x48fa34['body'][_0xb97f('0x77')]:!![],'description':_0x48fa34[_0xb97f('0x66')][_0xb97f('0x78')]||null,'Imap':{},'Smtp':{}};if(_[_0xb97f('0x76')](_0x48fa34['body'][_0xb97f('0x79')])){if(_0x48fa34[_0xb97f('0x66')][_0xb97f('0x7a')]){_0x238e15['Imap'][_0xb97f('0x7b')]=_0x238e15[_0xb97f('0x45')][_0xb97f('0x7b')]=_0x48fa34['body']['cuser'];_0x238e15[_0xb97f('0x44')][_0xb97f('0x7c')]=_0x238e15[_0xb97f('0x45')][_0xb97f('0x7d')]=_0x48fa34[_0xb97f('0x66')][_0xb97f('0x7e')];}else{_0x238e15['Imap'][_0xb97f('0x7f')]=_0x238e15['Smtp']['authentication']=![];}_0x238e15[_0xb97f('0x44')][_0xb97f('0x80')]=_0x48fa34[_0xb97f('0x66')][_0xb97f('0x44')][_0xb97f('0x80')];_0x238e15['Imap'][_0xb97f('0x81')]=_0x48fa34[_0xb97f('0x66')][_0xb97f('0x44')]['port'];_0x238e15[_0xb97f('0x45')][_0xb97f('0x80')]=_0x48fa34['body'][_0xb97f('0x45')][_0xb97f('0x80')];_0x238e15[_0xb97f('0x45')]['port']=_0x48fa34['body'][_0xb97f('0x45')]['port'];}else{_0x238e15[_0xb97f('0x44')][_0xb97f('0x82')]=_0x238e15[_0xb97f('0x45')]['service']=_0x48fa34[_0xb97f('0x66')][_0xb97f('0x79')];_0x238e15[_0xb97f('0x44')][_0xb97f('0x7b')]=_0x238e15['Smtp'][_0xb97f('0x7b')]=_0x48fa34[_0xb97f('0x66')][_0xb97f('0x83')];_0x238e15['Imap'][_0xb97f('0x7c')]=_0x238e15[_0xb97f('0x45')][_0xb97f('0x7d')]=_0x48fa34[_0xb97f('0x66')][_0xb97f('0x7e')];}return db[_0xb97f('0x47')]['create'](_0x238e15,{'include':[{'model':db[_0xb97f('0x67')],'as':_0xb97f('0x45')},{'model':db['MailServerIn'],'as':_0xb97f('0x44')}]})[_0xb97f('0x37')](function(_0x20cda7){var _0x530f31=_0x48fa34[_0xb97f('0x7b')][_0xb97f('0x84')]({'plain':!![]});if(!_0x530f31)throw new Error(_0xb97f('0x85'));if(_0x530f31[_0xb97f('0x86')]==='user'){var _0x2b2d0a=_0x20cda7[_0xb97f('0x84')]({'plain':!![]});return db['UserProfileSection'][_0xb97f('0x65')]({'where':{'name':'MailAccounts','userProfileId':_0x530f31['userProfileId']},'raw':!![]})[_0xb97f('0x37')](function(_0x44a2e6){if(_0x44a2e6&&_0x44a2e6['autoAssociation']===0x0){return db[_0xb97f('0x39')][_0xb97f('0x6c')]({'name':_0x2b2d0a['name'],'resourceId':_0x2b2d0a['id'],'type':_0x44a2e6[_0xb97f('0x3c')],'sectionId':_0x44a2e6['id']},{})['then'](function(){return _0x20cda7;});}else{return _0x20cda7;}})[_0xb97f('0x2d')](function(_0x58ddfc){logger[_0xb97f('0x29')](_0xb97f('0x87'),_0x58ddfc);throw _0x58ddfc;});}return _0x20cda7;})[_0xb97f('0x37')](respondWithResult(_0x378f7b,0xc9))['catch'](handleError(_0x378f7b,null));};exports[_0xb97f('0x88')]=function(_0x33af81,_0x6b07a4,_0x101328){return db[_0xb97f('0x47')][_0xb97f('0x6e')]({'where':{'id':_0x33af81[_0xb97f('0x62')]['id']}})[_0xb97f('0x37')](handleEntityNotFound(_0x6b07a4,null))['then'](function(_0x2914d6){if(_0x2914d6){return _0x2914d6['getImap']();}return null;})[_0xb97f('0x37')](respondWithResult(_0x6b07a4,null))[_0xb97f('0x2d')](handleError(_0x6b07a4,null));};exports[_0xb97f('0x89')]=function(_0x13973d,_0x215c72,_0x5992e3){if(_0x13973d['body']['id']){delete _0x13973d[_0xb97f('0x66')]['id'];}return db[_0xb97f('0x47')][_0xb97f('0x65')]({'where':{'id':_0x13973d['params']['id']}})['then'](handleEntityNotFound(_0x215c72,null))[_0xb97f('0x37')](function(_0x5687ec){if(_0x5687ec){_0x13973d[_0xb97f('0x66')]['MailAccountId']=_0x5687ec['id'];return db[_0xb97f('0x43')][_0xb97f('0x6c')](_0x13973d[_0xb97f('0x66')]);}})[_0xb97f('0x37')](respondWithResult(_0x215c72,null))[_0xb97f('0x2d')](handleError(_0x215c72,null));};exports[_0xb97f('0x8a')]=function(_0x213079,_0x28a6a7,_0x2936b6){return db[_0xb97f('0x47')][_0xb97f('0x6e')]({'where':{'id':_0x213079[_0xb97f('0x62')]['id']}})[_0xb97f('0x37')](handleEntityNotFound(_0x28a6a7,null))[_0xb97f('0x37')](function(_0x274f96){if(_0x274f96){return _0x274f96[_0xb97f('0x8b')](null);}return null;})[_0xb97f('0x37')](respondWithStatusCode(_0x28a6a7,null))[_0xb97f('0x2d')](handleError(_0x28a6a7,null));};exports[_0xb97f('0x8c')]=function(_0x2018bc,_0x4f827e,_0x13e424){return db[_0xb97f('0x47')]['findOne']({'where':{'id':_0x2018bc[_0xb97f('0x62')]['id']}})[_0xb97f('0x37')](handleEntityNotFound(_0x4f827e,null))[_0xb97f('0x37')](function(_0x5cc9d6){if(_0x5cc9d6){return _0x5cc9d6[_0xb97f('0x8c')]();}return null;})[_0xb97f('0x37')](respondWithResult(_0x4f827e,null))[_0xb97f('0x2d')](handleError(_0x4f827e,null));};exports[_0xb97f('0x8d')]=function(_0x282cd7,_0x7e8b4e,_0x1771ce){if(_0x282cd7[_0xb97f('0x66')]['id']){delete _0x282cd7[_0xb97f('0x66')]['id'];}return db['MailAccount'][_0xb97f('0x65')]({'where':{'id':_0x282cd7[_0xb97f('0x62')]['id']}})[_0xb97f('0x37')](handleEntityNotFound(_0x7e8b4e,null))['then'](function(_0x4e31d0){if(_0x4e31d0){_0x282cd7['body'][_0xb97f('0x6a')]=_0x4e31d0['id'];return db['MailServerOut'][_0xb97f('0x6c')](_0x282cd7[_0xb97f('0x66')]);}})['then'](respondWithResult(_0x7e8b4e,null))[_0xb97f('0x2d')](handleError(_0x7e8b4e,null));};exports['removeSmtp']=function(_0x1eb0c1,_0x3f18cc,_0x23ea08){return db[_0xb97f('0x47')]['findOne']({'where':{'id':_0x1eb0c1['params']['id']}})[_0xb97f('0x37')](handleEntityNotFound(_0x3f18cc,null))[_0xb97f('0x37')](function(_0x1e0ea4){if(_0x1e0ea4){return _0x1e0ea4[_0xb97f('0x8e')](null);}return null;})['then'](respondWithStatusCode(_0x3f18cc,null))['catch'](handleError(_0x3f18cc,null));};exports['addInteraction']=function(_0x119aff,_0x47b366,_0x46d383){return db[_0xb97f('0x8f')][_0xb97f('0x65')]({'where':{'id':_0x119aff['params']['id']}})[_0xb97f('0x37')](handleEntityNotFound(_0x47b366,null))[_0xb97f('0x37')](function(_0x3a3188){if(_0x3a3188){return _0x3a3188['addInteraction'](_0x119aff[_0xb97f('0x66')][_0xb97f('0x90')],_['omit'](_0x119aff[_0xb97f('0x66')],[_0xb97f('0x90'),'id'])||{});}})[_0xb97f('0x37')](respondWithResult(_0x47b366,null))['catch'](handleError(_0x47b366,null));};exports[_0xb97f('0x91')]=function(_0x421b46,_0x1c98d8,_0x1cab0){var _0x20c643={'raw':![],'where':{}};var _0x506568={};var _0x28435b={'count':0x0,'rows':[]};return db['MailAccount'][_0xb97f('0x6e')]({'where':{'id':_0x421b46[_0xb97f('0x62')]['id']}})['then'](handleEntityNotFound(_0x1c98d8,null))[_0xb97f('0x37')](function(_0x30c926){if(_0x30c926){_0x506568[_0xb97f('0x4a')]=_[_0xb97f('0x4b')](db[_0xb97f('0x8f')][_0xb97f('0x64')]);_0x506568[_0xb97f('0x4c')]=_[_0xb97f('0x4b')](_0x421b46[_0xb97f('0x4c')]);_0x506568['filters']=_[_0xb97f('0x4d')](_0x506568[_0xb97f('0x4a')],_0x506568['query']);_0x20c643[_0xb97f('0x4e')]=_[_0xb97f('0x4d')](_0x506568['model'],qs[_0xb97f('0x4f')](_0x421b46['query']['fields']));_0x20c643['attributes']=_0x20c643[_0xb97f('0x4e')]['length']?_0x20c643[_0xb97f('0x4e')]:_0x506568[_0xb97f('0x4a')];if(!_0x421b46['query'][_0xb97f('0x51')]('nolimit')){_0x20c643[_0xb97f('0x53')]=qs[_0xb97f('0x53')](_0x421b46[_0xb97f('0x4c')][_0xb97f('0x53')]);_0x20c643[_0xb97f('0x31')]=qs[_0xb97f('0x31')](_0x421b46[_0xb97f('0x4c')][_0xb97f('0x31')]);}_0x20c643['order']=qs[_0xb97f('0x55')](_0x421b46['query'][_0xb97f('0x55')]);_0x20c643[_0xb97f('0x56')]=qs[_0xb97f('0x57')](_[_0xb97f('0x58')](_0x421b46['query'],_0x506568['filters']));_0x20c643['where'][_0xb97f('0x6a')]=_0x30c926['id'];if(_0x421b46[_0xb97f('0x4c')]['filter']){_0x20c643[_0xb97f('0x56')]=_[_0xb97f('0x3e')](_0x20c643['where'],{'$or':_[_0xb97f('0x5a')](_0x20c643[_0xb97f('0x4e')],function(_0x3b7a2e){var _0x114621={};_0x114621[_0x3b7a2e]={'$like':'%'+_0x421b46['query'][_0xb97f('0x59')]+'%'};return _0x114621;})});}_0x20c643=_[_0xb97f('0x3e')]({},_0x20c643,_0x421b46[_0xb97f('0x5c')]);return db[_0xb97f('0x8f')][_0xb97f('0x33')]({'where':_0x20c643[_0xb97f('0x56')]})[_0xb97f('0x37')](function(_0x2b2bcd){_0x28435b[_0xb97f('0x33')]=_0x2b2bcd;if(_0x421b46[_0xb97f('0x4c')][_0xb97f('0x5d')]){_0x20c643[_0xb97f('0x5e')]=[{'model':db[_0xb97f('0x92')],'as':_0xb97f('0x93'),'required':![]},{'model':db[_0xb97f('0x94')],'as':_0xb97f('0x95'),'attributes':[_0xb97f('0x3c'),_0xb97f('0x96'),_0xb97f('0x97')],'required':![]},{'model':db[_0xb97f('0x98')],'as':_0xb97f('0x99'),'attributes':['id','name',_0xb97f('0x9a')],'where':_0x421b46[_0xb97f('0x4c')][_0xb97f('0x9b')]?{'id':_0x421b46['query'][_0xb97f('0x9b')]}:undefined,'required':_0x421b46[_0xb97f('0x4c')][_0xb97f('0x9b')]?!![]:![]}];}return db[_0xb97f('0x8f')][_0xb97f('0x5f')](_0x20c643);})[_0xb97f('0x37')](function(_0x38ea71){_0x28435b['rows']=_0x38ea71;return _0x28435b;});}})['then'](respondWithFilteredResult(_0x1c98d8,_0x20c643))['catch'](handleError(_0x1c98d8,null));};exports[_0xb97f('0x9c')]=function(_0x1b50d8,_0x535b54,_0x2a55be){return db[_0xb97f('0x47')]['findOne']({'where':{'id':_0x1b50d8[_0xb97f('0x62')]['id']}})[_0xb97f('0x37')](handleEntityNotFound(_0x535b54,null))[_0xb97f('0x37')](function(_0x3707eb){if(_0x3707eb){return db[_0xb97f('0x9d')][_0xb97f('0x9e')](function(_0x2e7426){return db[_0xb97f('0x9f')][_0xb97f('0x38')]({'where':{'MailAccountId':_0x1b50d8[_0xb97f('0x62')]['id']},'transaction':_0x2e7426})[_0xb97f('0x37')](function(_0x391acc){var _0x352986=_[_0xb97f('0x5a')](_0x1b50d8[_0xb97f('0x66')],function(_0x13e470){_0x13e470[_0xb97f('0x6a')]=_0x1b50d8[_0xb97f('0x62')]['id'];return _0x13e470;});return db[_0xb97f('0x9f')]['bulkCreate'](_0x352986,{'transaction':_0x2e7426});});})[_0xb97f('0x37')](function(){return db[_0xb97f('0x9f')][_0xb97f('0xa0')]({'where':{'MailAccountId':_0x1b50d8[_0xb97f('0x62')]['id']},'order':_0xb97f('0xa1')});});}})[_0xb97f('0x37')](respondWithResult(_0x535b54,null))[_0xb97f('0x2d')](handleError(_0x535b54,null));};exports[_0xb97f('0xa2')]=function(_0xbc3bff,_0x3f600f,_0xc69302){var _0x5ea79b={};var _0xab1ef={};var _0x4173d1;var _0x114ea0;return db[_0xb97f('0x47')][_0xb97f('0x6e')]({'where':{'id':_0xbc3bff['params']['id']}})[_0xb97f('0x37')](handleEntityNotFound(_0x3f600f,null))[_0xb97f('0x37')](function(_0x2008f6){if(_0x2008f6){_0x4173d1=_0x2008f6;_0xab1ef[_0xb97f('0x4a')]=_[_0xb97f('0x4b')](db['MailApplication'][_0xb97f('0x64')]);_0xab1ef['query']=_['keys'](_0xbc3bff[_0xb97f('0x4c')]);_0xab1ef['filters']=_['intersection'](_0xab1ef[_0xb97f('0x4a')],_0xab1ef['query']);_0x5ea79b[_0xb97f('0x4e')]=_[_0xb97f('0x4d')](_0xab1ef[_0xb97f('0x4a')],qs[_0xb97f('0x4f')](_0xbc3bff[_0xb97f('0x4c')][_0xb97f('0x4f')]));_0x5ea79b[_0xb97f('0x4e')]=_0x5ea79b[_0xb97f('0x4e')][_0xb97f('0x50')]?_0x5ea79b[_0xb97f('0x4e')]:_0xab1ef['model'];_0x5ea79b[_0xb97f('0x54')]=qs[_0xb97f('0x55')](_0xbc3bff[_0xb97f('0x4c')][_0xb97f('0x55')]);_0x5ea79b[_0xb97f('0x56')]=qs[_0xb97f('0x57')](_['pick'](_0xbc3bff['query'],_0xab1ef[_0xb97f('0x57')]));if(_0xbc3bff[_0xb97f('0x4c')][_0xb97f('0x59')]){_0x5ea79b[_0xb97f('0x56')]=_['merge'](_0x5ea79b[_0xb97f('0x56')],{'$or':_[_0xb97f('0x5a')](_0x5ea79b[_0xb97f('0x4e')],function(_0x243a13){var _0x3c684d={};_0x3c684d[_0x243a13]={'$like':'%'+_0xbc3bff['query'][_0xb97f('0x59')]+'%'};return _0x3c684d;})});}_0x5ea79b=_[_0xb97f('0x3e')]({},_0x5ea79b,_0xbc3bff[_0xb97f('0x5c')]);return _0x4173d1[_0xb97f('0xa2')](_0x5ea79b);}})['then'](function(_0x968cb4){if(_0x968cb4){_0x114ea0=_0x968cb4[_0xb97f('0x50')];if(!_0xbc3bff[_0xb97f('0x4c')][_0xb97f('0x51')](_0xb97f('0x52'))){_0x5ea79b['limit']=qs['limit'](_0xbc3bff[_0xb97f('0x4c')][_0xb97f('0x53')]);_0x5ea79b['offset']=qs[_0xb97f('0x31')](_0xbc3bff[_0xb97f('0x4c')]['offset']);}return _0x4173d1[_0xb97f('0xa2')](_0x5ea79b);}})[_0xb97f('0x37')](function(_0x41c85f){if(_0x41c85f){return _0x41c85f?{'count':_0x114ea0,'rows':_0x41c85f}:null;}})[_0xb97f('0x37')](respondWithResult(_0x3f600f,null))[_0xb97f('0x2d')](handleError(_0x3f600f,null));};exports['getMessages']=function(_0x4cf7a3,_0xb635db,_0x127453){var _0x15c107={'raw':!![],'where':{}};var _0x56c152={};var _0x12218a={'count':0x0,'rows':[]};return db[_0xb97f('0x47')][_0xb97f('0x6e')]({'where':{'id':_0x4cf7a3[_0xb97f('0x62')]['id']}})[_0xb97f('0x37')](handleEntityNotFound(_0xb635db,null))[_0xb97f('0x37')](function(_0x59dfd2){if(_0x59dfd2){_0x56c152[_0xb97f('0x4a')]=_[_0xb97f('0x4b')](db[_0xb97f('0xa3')][_0xb97f('0x64')]);_0x56c152[_0xb97f('0x4c')]=_[_0xb97f('0x4b')](_0x4cf7a3[_0xb97f('0x4c')]);_0x56c152[_0xb97f('0x57')]=_[_0xb97f('0x4d')](_0x56c152[_0xb97f('0x4a')],_0x56c152[_0xb97f('0x4c')]);_0x15c107['attributes']=_[_0xb97f('0x4d')](_0x56c152['model'],qs[_0xb97f('0x4f')](_0x4cf7a3[_0xb97f('0x4c')][_0xb97f('0x4f')]));_0x15c107[_0xb97f('0x4e')]=_0x15c107[_0xb97f('0x4e')][_0xb97f('0x50')]?_0x15c107[_0xb97f('0x4e')]:_0x56c152[_0xb97f('0x4a')];if(!_0x4cf7a3[_0xb97f('0x4c')][_0xb97f('0x51')](_0xb97f('0x52'))){_0x15c107['limit']=qs['limit'](_0x4cf7a3[_0xb97f('0x4c')]['limit']);_0x15c107['offset']=qs[_0xb97f('0x31')](_0x4cf7a3['query'][_0xb97f('0x31')]);}_0x15c107[_0xb97f('0x54')]=qs[_0xb97f('0x55')](_0x4cf7a3['query'][_0xb97f('0x55')]);_0x15c107[_0xb97f('0x56')]=qs['filters'](_['pick'](_0x4cf7a3['query'],_0x56c152[_0xb97f('0x57')]));_0x15c107[_0xb97f('0x56')][_0xb97f('0x6a')]=_0x59dfd2['id'];if(_0x4cf7a3[_0xb97f('0x4c')][_0xb97f('0x59')]){_0x15c107[_0xb97f('0x56')]=_[_0xb97f('0x3e')](_0x15c107[_0xb97f('0x56')],{'$or':_['map'](_0x15c107[_0xb97f('0x4e')],function(_0x5028bb){var _0x50abea={};_0x50abea[_0x5028bb]={'$like':'%'+_0x4cf7a3[_0xb97f('0x4c')][_0xb97f('0x59')]+'%'};return _0x50abea;})});}if(_0x4cf7a3[_0xb97f('0x4c')]['$gte']){var _0x93161d=_0x4cf7a3['query'][_0xb97f('0xa4')][_0xb97f('0xa5')](',');var _0x3b4907={};_0x3b4907[_0x93161d[0x0]]={'$gte':moment(_0x93161d[0x1])['format']('YYYY-MM-DD\x20HH:mm:ss')};_0x15c107[_0xb97f('0x56')]=_[_0xb97f('0x3e')](_0x15c107[_0xb97f('0x56')],_0x3b4907);}_0x15c107=_['merge']({},_0x15c107,_0x4cf7a3['options']);return db['MailMessage'][_0xb97f('0x33')]({'where':_0x15c107[_0xb97f('0x56')]})[_0xb97f('0x37')](function(_0x411da9){_0x12218a['count']=_0x411da9;if(_0x4cf7a3['query'][_0xb97f('0x5d')]){_0x15c107[_0xb97f('0x5e')]=[{'all':!![]}];}return db[_0xb97f('0xa3')][_0xb97f('0x5f')](_0x15c107);})[_0xb97f('0x37')](function(_0x3f5268){if(_0x4cf7a3['query'][_0xb97f('0xa6')]==='true'){for(var _0x607afc=0x0;_0x607afc<_0x3f5268['length'];_0x607afc++){_0x3f5268[_0x607afc][_0xb97f('0x66')]=juice(_0x3f5268[_0x607afc]['body']);}}_0x12218a[_0xb97f('0x60')]=_0x3f5268;return _0x12218a;});}})[_0xb97f('0x37')](respondWithFilteredResult(_0xb635db,_0x15c107))[_0xb97f('0x2d')](handleError(_0xb635db,null));};exports[_0xb97f('0x3d')]=function(_0x54caa9,_0x4e7400,_0x1fdaa7){var _0x5a33b2,_0x5ba054={},_0x2d2079;if(_0x54caa9[_0xb97f('0x66')]['to']){_0x2d2079=_0x54caa9[_0xb97f('0x66')]['to'][_0xb97f('0xa5')](',')[0x0];}return db[_0xb97f('0x47')]['find']({'where':{'id':_0x54caa9[_0xb97f('0x62')]['id']},'include':[{'model':db[_0xb97f('0xa7')],'as':'List','include':[{'model':db[_0xb97f('0x92')],'as':_0xb97f('0xa8'),'where':{'email':_0x2d2079},'limit':0x1,'order':[[_0xb97f('0xa9'),_0xb97f('0xaa')]]}]},{'model':db[_0xb97f('0x67')],'as':_0xb97f('0x45'),'raw':!![]}]})[_0xb97f('0x37')](handleEntityNotFound(_0x4e7400,null))[_0xb97f('0x37')](function(_0x529cdc){if(_0x529cdc){_0x5a33b2=_0x529cdc;if(_0x529cdc[_0xb97f('0x45')]){if(_['isNil'](_0x54caa9['body'][_0xb97f('0xab')])){_0x54caa9[_0xb97f('0x66')][_0xb97f('0xab')]=util[_0xb97f('0xac')](_0xb97f('0xad'),_0x529cdc[_0xb97f('0x3c')],_0x529cdc[_0xb97f('0x74')]||_0x529cdc[_0xb97f('0x45')]['user']);}if(_0x54caa9[_0xb97f('0x66')][_0xb97f('0xae')]&&_0x54caa9[_0xb97f('0x66')][_0xb97f('0xae')]['length']){for(var _0x8af361=0x0;_0x8af361<_0x54caa9[_0xb97f('0x66')][_0xb97f('0xae')]['length'];_0x8af361+=0x1){_0x54caa9[_0xb97f('0x66')]['attachments'][_0x8af361]={'filename':_0x54caa9[_0xb97f('0x66')][_0xb97f('0xae')][_0x8af361]['name'],'path':path[_0xb97f('0xaf')](config[_0xb97f('0xb0')],_0xb97f('0xb1'),_0x54caa9['body'][_0xb97f('0xae')][_0x8af361][_0xb97f('0xb2')])};}}var _0x37c49f={'tls':{'rejectUnauthorized':![]}};if(_[_0xb97f('0x76')](_0x529cdc['Smtp'][_0xb97f('0x82')])){if(_0x529cdc[_0xb97f('0x45')]['authentication']){_0x37c49f[_0xb97f('0xb3')]={'user':_0x529cdc['Smtp']['user'],'pass':_0x529cdc[_0xb97f('0x45')][_0xb97f('0x7d')]};}_0x37c49f[_0xb97f('0x80')]=_0x529cdc[_0xb97f('0x45')]['host'];_0x37c49f['port']=_0x529cdc[_0xb97f('0x45')][_0xb97f('0x81')];_0x37c49f['secure']=_0x529cdc[_0xb97f('0x45')][_0xb97f('0xb4')];}else{_0x37c49f[_0xb97f('0x82')]=_0x529cdc['Smtp'][_0xb97f('0x82')];_0x37c49f[_0xb97f('0xb3')]={'user':_0x529cdc[_0xb97f('0x45')][_0xb97f('0x7b')],'pass':_0x529cdc[_0xb97f('0x45')][_0xb97f('0x7d')]};}return respondWithRpcPromise(_0xb97f('0xb5'),_0xb97f('0xb6'),{'account':_0x37c49f,'message':_0x54caa9[_0xb97f('0x66')]});}else{throw new Error('List\x20not\x20found');}}})[_0xb97f('0x37')](function(_0x48890f){if(_0x48890f){_0x5ba054=_0x48890f;if(_0x5a33b2[_0xb97f('0xb7')]){if(_0x5a33b2[_0xb97f('0xb7')][_0xb97f('0xa8')]['length']){return _0x5a33b2[_0xb97f('0xb7')]['Contacts'][0x0];}else{return db['CmContact']['create'](_['defaults'](_0x54caa9[_0xb97f('0x66')],{'firstName':_0x54caa9[_0xb97f('0x66')]['to'],'email':_0x54caa9[_0xb97f('0x66')]['to'],'phone':_0x54caa9[_0xb97f('0x66')]['to'],'ListId':_0x5a33b2['ListId']}));}}else{throw new Error(_0xb97f('0xb8'));}}})[_0xb97f('0x37')](function(_0x2831e9){if(_0x2831e9){var _0x3d6fee={'UserId':_0x54caa9[_0xb97f('0x7b')]['id'],'ContactId':_0x2831e9['id'],'MailAccountId':_0x5a33b2['id'],'inReplyTo':_0x5ba054[_0xb97f('0xb9')],'to':_0x54caa9[_0xb97f('0x66')][_0xb97f('0xab')],'cc':_0x54caa9[_0xb97f('0x66')]['cc'],'subject':_0x54caa9[_0xb97f('0x66')][_0xb97f('0xba')],'attach':_0x54caa9[_0xb97f('0x66')][_0xb97f('0xbb')],'firstMsgDirection':_0xb97f('0xbc'),'lastMsgAt':moment()[_0xb97f('0xac')](_0xb97f('0xbd')),'lastMsgDirection':_0xb97f('0xbc'),'Messages':[_[_0xb97f('0x3e')](_0x54caa9[_0xb97f('0x66')],{'messageId':_0x5ba054[_0xb97f('0xb9')],'sentAt':moment()['format'](_0xb97f('0xbd')),'read':!![],'MailAccountId':_0x5a33b2['id'],'UserId':_0x54caa9[_0xb97f('0x7b')]['id'],'ContactId':_0x2831e9['id']})]};if(_0x54caa9[_0xb97f('0x66')][_0xb97f('0xbe')]){_0x3d6fee=_[_0xb97f('0x3e')](_0x3d6fee,_0x54caa9[_0xb97f('0x66')][_0xb97f('0xbe')]);}return db['MailInteraction'][_0xb97f('0x6c')](_0x3d6fee,{'include':[{'model':db[_0xb97f('0xa3')],'as':_0xb97f('0xbf')}]});}})['then'](respondWithResult(_0x4e7400,null))[_0xb97f('0x2d')](handleError(_0x4e7400,null));};exports[_0xb97f('0xc0')]=function(_0x13ca06,_0x3feece,_0x50a960){return db[_0xb97f('0x47')][_0xb97f('0x65')]({'where':{'id':_0x13ca06['params']['id']},'include':[{'model':db[_0xb97f('0x67')],'as':_0xb97f('0x45'),'raw':!![]}]})[_0xb97f('0x37')](handleEntityNotFound(_0x3feece,null))[_0xb97f('0x37')](function(_0x256905){if(_0x256905&&_0x256905['Smtp']){var _0x1bce9b={'id':_0x256905['id'],'tls':{'rejectUnauthorized':![]}};if(_0x256905[_0xb97f('0x45')][_0xb97f('0x82')]){_0x1bce9b[_0xb97f('0x82')]=_0x256905['Smtp']['service'];}else{_0x1bce9b['host']=_0x256905[_0xb97f('0x45')][_0xb97f('0x80')];_0x1bce9b[_0xb97f('0x81')]=_0x256905['Smtp'][_0xb97f('0x81')];_0x1bce9b[_0xb97f('0xb4')]=_0x256905[_0xb97f('0x45')][_0xb97f('0xb4')];}if(_0x256905[_0xb97f('0x45')][_0xb97f('0x7f')]){_0x1bce9b[_0xb97f('0xb3')]={'user':_0x256905[_0xb97f('0x45')][_0xb97f('0x7b')],'pass':_0x256905[_0xb97f('0x45')][_0xb97f('0x7d')]};}return respondWithRpcPromise('VerifySmtp',_0xb97f('0xc0'),{'account':_0x1bce9b});}})[_0xb97f('0x37')](respondWithResult(_0x3feece,null))[_0xb97f('0x2d')](handleError(_0x3feece,null));};exports[_0xb97f('0x38')]=function(_0x96fbda,_0x4f99cc){return db[_0xb97f('0x47')][_0xb97f('0x65')]({'where':{'id':_0x96fbda['params']['id']}})[_0xb97f('0x37')](handleEntityNotFound(_0x4f99cc,null))['then'](function(_0x2da834){if(_0x2da834&&_0x2da834['service']){throw new db['Sequelize'][(_0xb97f('0xc1'))](_0xb97f('0xc2'));}return _0x2da834;})[_0xb97f('0x37')](removeEntity(_0x4f99cc,null))[_0xb97f('0x2d')](handleError(_0x4f99cc,null));};exports[_0xb97f('0xc3')]=function(_0x11545c,_0x3673e1,_0x590a7f){return db['MailAccount'][_0xb97f('0x65')]({'where':{'id':_0x11545c[_0xb97f('0x62')]['id']}})[_0xb97f('0x37')](handleEntityNotFound(_0x3673e1,null))['then'](function(_0x21dce3){if(_0x21dce3){return _0x21dce3[_0xb97f('0xc3')](_0x11545c[_0xb97f('0x66')][_0xb97f('0x90')],_[_0xb97f('0xc4')](_0x11545c[_0xb97f('0x66')],[_0xb97f('0x90'),'id'])||{})[_0xb97f('0xc5')](function(_0x5c8164){for(var _0x336cca=0x0;_0x336cca<_0x11545c['body'][_0xb97f('0x90')]['length'];_0x336cca+=0x1){socket[_0xb97f('0xc6')](_0xb97f('0xc7'),{'UserId':_0x11545c['body'][_0xb97f('0x90')][_0x336cca],'MailAccountId':_0x11545c[_0xb97f('0x62')]['id']});}return _0x5c8164;});}})['then'](respondWithResult(_0x3673e1,null))['catch'](handleError(_0x3673e1,null));};exports[_0xb97f('0xc8')]=function(_0x137792,_0x4b2fab,_0x1be5d4){return db[_0xb97f('0x47')]['find']({'where':{'id':_0x137792[_0xb97f('0x62')]['id']}})[_0xb97f('0x37')](handleEntityNotFound(_0x4b2fab,null))[_0xb97f('0x37')](function(_0x296244){if(_0x296244){return _0x296244[_0xb97f('0xc8')](_0x137792[_0xb97f('0x4c')][_0xb97f('0x90')])[_0xb97f('0x37')](function(){if(_[_0xb97f('0xc9')](_0x137792['query'][_0xb97f('0x90')])){for(var _0x4a6ae4=0x0;_0x4a6ae4<_0x137792[_0xb97f('0x4c')][_0xb97f('0x90')][_0xb97f('0x50')];_0x4a6ae4+=0x1){socket[_0xb97f('0xc6')]('userMailAccount:remove',{'UserId':Number(_0x137792[_0xb97f('0x4c')][_0xb97f('0x90')][_0x4a6ae4]),'MailAccountId':Number(_0x137792['params']['id'])});}}else{socket[_0xb97f('0xc6')]('userMailAccount:remove',{'UserId':Number(_0x137792[_0xb97f('0x4c')]['ids']),'MailAccountId':Number(_0x137792['params']['id'])});}});}})[_0xb97f('0x37')](respondWithStatusCode(_0x4b2fab,null))['catch'](handleError(_0x4b2fab,null));};exports[_0xb97f('0xca')]=function(_0x26145e,_0x23a7d4,_0x35b904){var _0x1b790e={};var _0x4c1a81={};var _0x1b87cb;var _0x61d7e6;return db[_0xb97f('0x47')][_0xb97f('0x6e')]({'where':{'id':_0x26145e[_0xb97f('0x62')]['id']}})[_0xb97f('0x37')](handleEntityNotFound(_0x23a7d4,null))[_0xb97f('0x37')](function(_0x25963c){if(_0x25963c){_0x1b87cb=_0x25963c;_0x4c1a81[_0xb97f('0x4a')]=_[_0xb97f('0x4b')](db[_0xb97f('0x94')][_0xb97f('0x64')]);_0x4c1a81[_0xb97f('0x4c')]=_['keys'](_0x26145e[_0xb97f('0x4c')]);_0x4c1a81[_0xb97f('0x57')]=_[_0xb97f('0x4d')](_0x4c1a81[_0xb97f('0x4a')],_0x4c1a81[_0xb97f('0x4c')]);_0x1b790e[_0xb97f('0x4e')]=_[_0xb97f('0x4d')](_0x4c1a81[_0xb97f('0x4a')],qs['fields'](_0x26145e[_0xb97f('0x4c')][_0xb97f('0x4f')]));_0x1b790e[_0xb97f('0x4e')]=_0x1b790e['attributes'][_0xb97f('0x50')]?_0x1b790e[_0xb97f('0x4e')]:_0x4c1a81['model'];_0x1b790e[_0xb97f('0x54')]=qs['sort'](_0x26145e[_0xb97f('0x4c')][_0xb97f('0x55')]);_0x1b790e['where']=qs[_0xb97f('0x57')](_[_0xb97f('0x58')](_0x26145e[_0xb97f('0x4c')],_0x4c1a81[_0xb97f('0x57')]));if(_0x26145e[_0xb97f('0x4c')][_0xb97f('0x59')]){_0x1b790e[_0xb97f('0x56')]=_[_0xb97f('0x3e')](_0x1b790e[_0xb97f('0x56')],{'$or':_['map'](_0x1b790e['attributes'],function(_0x5b6df6){var _0x975e98={};_0x975e98[_0x5b6df6]={'$like':'%'+_0x26145e['query'][_0xb97f('0x59')]+'%'};return _0x975e98;})});}_0x1b790e=_[_0xb97f('0x3e')]({},_0x1b790e,_0x26145e[_0xb97f('0x5c')]);return _0x1b87cb[_0xb97f('0xca')](_0x1b790e);}})[_0xb97f('0x37')](function(_0x44621d){if(_0x44621d){_0x61d7e6=_0x44621d[_0xb97f('0x50')];if(!_0x26145e['query'][_0xb97f('0x51')](_0xb97f('0x52'))){_0x1b790e[_0xb97f('0x53')]=qs[_0xb97f('0x53')](_0x26145e['query']['limit']);_0x1b790e[_0xb97f('0x31')]=qs[_0xb97f('0x31')](_0x26145e[_0xb97f('0x4c')][_0xb97f('0x31')]);}return _0x1b87cb[_0xb97f('0xca')](_0x1b790e);}})[_0xb97f('0x37')](function(_0x2cd952){if(_0x2cd952){return _0x2cd952?{'count':_0x61d7e6,'rows':_0x2cd952}:null;}})[_0xb97f('0x37')](respondWithResult(_0x23a7d4,null))[_0xb97f('0x2d')](handleError(_0x23a7d4,null));};
\ No newline at end of file
+var _0xf5f7=['getSmtp','addSmtp','removeSmtp','MailInteraction','getInteractions','CmContact','Contact','Owner','fullname','internal','Tag','Tags','tag','sequelize','transaction','MailApplication','bulkCreate','priority','getApplications','getMessages','$gte','split','format','YYYY-MM-DD\x20HH:mm:ss','MailMessage','inlineCss','send','CmList','List','Contacts','updatedAt','DESC','from','%s\x20<%s>','attachments','join','root','server/files/attachments','auth','secure','List\x20not\x20found','messageId','subject','attach','out','Interaction','Messages','verifySmtp','VerifySmtp','Sequelize','ValidationError','You\x20can\x27t\x20remove\x20the\x20mail\x20service\x20account','addAgents','omit','spread','emit','removeAgents','isArray','userMailAccount:remove','getAgents','User','eml-format','rimraf','zip-dir','request-promise','bluebird','mustache','util','path','sox','to-csv','fs-extra','lodash','squel','jsforce','desk.js','querystring','papaparse','juice','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../mysqldb','redis','defaults','localhost','socket.io-emitter','register','client','then','info','MailAccount,\x20%s,\x20%s','request\x20sent','stringify','error','message','result','catch','status','end','json','offset','undefined','limit','set','apply','reject','save','destroy','get','MailAccounts','UserProfileResource','sendStatus','stack','name','render','merge','body','contact','interaction','index','MailServerIn','MailServerOut','Pause','mandatoryDispositionPause','map','rawAttributes','type','model','query','filters','intersection','fields','attributes','length','hasOwnProperty','nolimit','order','sort','pick','filter','where','MailAccount','count','includeAll','findAll','rows','show','Smtp','keys','include','options','update','find','params','Imap','describe','addDisposition','MailAccountId','Disposition','create','getDispositions','findOne','removeDispositions','ids','CannedAnswer','getAnswers','removeAnswers','key','email','ListId','active','description','isNil','cservice','cauthentication','user','cuser','password','pass','cpassword','authentication','host','port','service','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','getImap','addImap','removeImap','setImap'];(function(_0x410fda,_0x3a5a6f){var _0x3bfb38=function(_0x187d11){while(--_0x187d11){_0x410fda['push'](_0x410fda['shift']());}};_0x3bfb38(++_0x3a5a6f);}(_0xf5f7,0x1c5));var _0x7f5f=function(_0x11e681,_0xa15013){_0x11e681=_0x11e681-0x0;var _0x128c11=_0xf5f7[_0x11e681];return _0x128c11;};'use strict';var emlformat=require(_0x7f5f('0x0'));var rimraf=require(_0x7f5f('0x1'));var zipdir=require(_0x7f5f('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0x7f5f('0x3'));var moment=require('moment');var BPromise=require(_0x7f5f('0x4'));var Mustache=require(_0x7f5f('0x5'));var util=require(_0x7f5f('0x6'));var path=require(_0x7f5f('0x7'));var sox=require(_0x7f5f('0x8'));var csv=require(_0x7f5f('0x9'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x7f5f('0xa'));var _=require(_0x7f5f('0xb'));var squel=require(_0x7f5f('0xc'));var crypto=require('crypto');var jsforce=require(_0x7f5f('0xd'));var deskjs=require(_0x7f5f('0xe'));var toCsv=require(_0x7f5f('0x9'));var querystring=require(_0x7f5f('0xf'));var Papa=require(_0x7f5f('0x10'));var htmlToText=require('html-to-text');var juice=require(_0x7f5f('0x11'));var Redis=require(_0x7f5f('0x12'));var authService=require(_0x7f5f('0x13'));var qs=require(_0x7f5f('0x14'));var as=require(_0x7f5f('0x15'));var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')('api');var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require(_0x7f5f('0x16'))['db'];config[_0x7f5f('0x17')]=_[_0x7f5f('0x18')](config[_0x7f5f('0x17')],{'host':_0x7f5f('0x19'),'port':0x18eb});var socket=require(_0x7f5f('0x1a'))(new Redis(config[_0x7f5f('0x17')]));require('./mailAccount.socket')[_0x7f5f('0x1b')](socket);var jayson=require('jayson/promise');var client=jayson[_0x7f5f('0x1c')]['http']({'port':0x232b});function respondWithRpcPromise(_0x296efa,_0x2e6e77,_0x1e7eaf,_0x3ade7f){return new BPromise(function(_0x1e6dd1,_0x2eecb6){var _0xa5bb59=_0x3ade7f||client;return _0xa5bb59['request'](_0x296efa,_0x1e7eaf)[_0x7f5f('0x1d')](function(_0xeee305){logger[_0x7f5f('0x1e')](_0x7f5f('0x1f'),_0x2e6e77,_0x7f5f('0x20'));logger['debug']('MailAccount,\x20%s,\x20%s,\x20%s',_0x2e6e77,_0x7f5f('0x20'),JSON[_0x7f5f('0x21')](_0xeee305));if(_0xeee305[_0x7f5f('0x22')]){if(_0xeee305[_0x7f5f('0x22')]['code']===0x1f4){logger[_0x7f5f('0x22')](_0x7f5f('0x1f'),_0x2e6e77,_0xeee305['error'][_0x7f5f('0x23')]);return _0x2eecb6(_0xeee305[_0x7f5f('0x22')]['message']);}logger[_0x7f5f('0x22')]('MailAccount,\x20%s,\x20%s',_0x2e6e77,_0xeee305[_0x7f5f('0x22')][_0x7f5f('0x23')]);return _0x1e6dd1(_0xeee305[_0x7f5f('0x22')][_0x7f5f('0x23')]);}else{logger[_0x7f5f('0x1e')](_0x7f5f('0x1f'),_0x2e6e77,_0x7f5f('0x20'));_0x1e6dd1(_0xeee305[_0x7f5f('0x24')][_0x7f5f('0x23')]);}})[_0x7f5f('0x25')](function(_0x14f991){logger[_0x7f5f('0x22')](_0x7f5f('0x1f'),_0x2e6e77,_0x14f991);_0x2eecb6(_0x14f991);});});}function respondWithStatusCode(_0x334fff,_0x34e72a){_0x34e72a=_0x34e72a||0xcc;return function(_0x5ee234){if(_0x5ee234){return _0x334fff['sendStatus'](_0x34e72a);}return _0x334fff[_0x7f5f('0x26')](_0x34e72a)[_0x7f5f('0x27')]();};}function respondWithResult(_0xf7a7ae,_0x323d51){_0x323d51=_0x323d51||0xc8;return function(_0x2d04fd){if(_0x2d04fd){return _0xf7a7ae['status'](_0x323d51)[_0x7f5f('0x28')](_0x2d04fd);}};}function respondWithFilteredResult(_0xa41ab8,_0x1a4cb3){return function(_0x29eec5){if(_0x29eec5){var _0x142770=typeof _0x1a4cb3[_0x7f5f('0x29')]===_0x7f5f('0x2a')&&typeof _0x1a4cb3[_0x7f5f('0x2b')]===_0x7f5f('0x2a');var _0xebc41d=_0x29eec5['count'];var _0x220c79=_0x142770?0x0:_0x1a4cb3[_0x7f5f('0x29')];var _0x460476=_0x142770?_0x29eec5['count']:_0x1a4cb3[_0x7f5f('0x29')]+_0x1a4cb3['limit'];var _0x17da39;if(_0x460476>=_0xebc41d){_0x460476=_0xebc41d;_0x17da39=0xc8;}else{_0x17da39=0xce;}_0xa41ab8['status'](_0x17da39);return _0xa41ab8[_0x7f5f('0x2c')]('Content-Range',_0x220c79+'-'+_0x460476+'/'+_0xebc41d)['json'](_0x29eec5);}return null;};}function patchUpdates(_0x4e64e6){return function(_0x33d341){try{jsonpatch[_0x7f5f('0x2d')](_0x33d341,_0x4e64e6,!![]);}catch(_0x255638){return BPromise[_0x7f5f('0x2e')](_0x255638);}return _0x33d341[_0x7f5f('0x2f')]();};}function saveUpdates(_0x2c6812,_0x284171){return function(_0x492e97){if(_0x492e97){return _0x492e97['update'](_0x2c6812)[_0x7f5f('0x1d')](function(_0x440865){return _0x440865;});}return null;};}function removeEntity(_0x140028,_0xf1880f){return function(_0x2cbb63){if(_0x2cbb63){return _0x2cbb63[_0x7f5f('0x30')]()[_0x7f5f('0x1d')](function(){var _0x14024d=_0x2cbb63[_0x7f5f('0x31')]({'plain':!![]});var _0x13564e=_0x7f5f('0x32');return db[_0x7f5f('0x33')][_0x7f5f('0x30')]({'where':{'type':_0x13564e,'resourceId':_0x14024d['id']}})[_0x7f5f('0x1d')](function(){return _0x2cbb63;});})[_0x7f5f('0x1d')](function(){_0x140028[_0x7f5f('0x26')](0xcc)[_0x7f5f('0x27')]();});}};}function handleEntityNotFound(_0x3a9e13,_0x516fbf){return function(_0x387848){if(!_0x387848){_0x3a9e13[_0x7f5f('0x34')](0x194);}return _0x387848;};}function handleError(_0xbedb56,_0x14f8d8){_0x14f8d8=_0x14f8d8||0x1f4;return function(_0x4744fd){logger['error'](_0x4744fd[_0x7f5f('0x35')]);if(_0x4744fd[_0x7f5f('0x36')]){delete _0x4744fd[_0x7f5f('0x36')];}_0xbedb56[_0x7f5f('0x26')](_0x14f8d8)['send'](_0x4744fd);};}function getMustacheRender(_0x7f1744,_0x8a9fa6){return Mustache[_0x7f5f('0x37')](_0x7f1744,_[_0x7f5f('0x38')](_0x8a9fa6[_0x7f5f('0x39')],{'contact':_0x8a9fa6[_0x7f5f('0x3a')],'message':_0x8a9fa6[_0x7f5f('0x23')],'agent':_0x8a9fa6['agent'],'interaction':_0x8a9fa6[_0x7f5f('0x3b')],'account':_0x8a9fa6['account']}))||'';}exports[_0x7f5f('0x3c')]=function(_0x4b7fcd,_0x2a1852){var _0x8e2e5a={'include':[{'model':db[_0x7f5f('0x3d')],'as':'Imap'},{'model':db[_0x7f5f('0x3e')],'as':'Smtp'},{'model':db[_0x7f5f('0x3f')],'as':_0x7f5f('0x40')}]},_0xf87962={},_0xd8ecfb={'count':0x0,'rows':[]};var _0x1ea650=_[_0x7f5f('0x41')](db['MailAccount'][_0x7f5f('0x42')],function(_0x3e4edc){return{'name':_0x3e4edc['fieldName'],'type':_0x3e4edc[_0x7f5f('0x43')]['key']};});_0xf87962[_0x7f5f('0x44')]=_[_0x7f5f('0x41')](_0x1ea650,_0x7f5f('0x36'));_0xf87962[_0x7f5f('0x45')]=_['keys'](_0x4b7fcd[_0x7f5f('0x45')]);_0xf87962[_0x7f5f('0x46')]=_[_0x7f5f('0x47')](_0xf87962[_0x7f5f('0x44')],_0xf87962['query']);_0x8e2e5a['attributes']=_['intersection'](_0xf87962[_0x7f5f('0x44')],qs['fields'](_0x4b7fcd[_0x7f5f('0x45')][_0x7f5f('0x48')]));_0x8e2e5a['attributes']=_0x8e2e5a[_0x7f5f('0x49')][_0x7f5f('0x4a')]?_0x8e2e5a[_0x7f5f('0x49')]:_0xf87962[_0x7f5f('0x44')];if(!_0x4b7fcd[_0x7f5f('0x45')][_0x7f5f('0x4b')](_0x7f5f('0x4c'))){_0x8e2e5a[_0x7f5f('0x2b')]=qs[_0x7f5f('0x2b')](_0x4b7fcd[_0x7f5f('0x45')][_0x7f5f('0x2b')]);_0x8e2e5a[_0x7f5f('0x29')]=qs['offset'](_0x4b7fcd[_0x7f5f('0x45')]['offset']);}_0x8e2e5a[_0x7f5f('0x4d')]=qs[_0x7f5f('0x4e')](_0x4b7fcd[_0x7f5f('0x45')][_0x7f5f('0x4e')]);_0x8e2e5a['where']=qs[_0x7f5f('0x46')](_[_0x7f5f('0x4f')](_0x4b7fcd[_0x7f5f('0x45')],_0xf87962[_0x7f5f('0x46')]),_0x1ea650);if(_0x4b7fcd[_0x7f5f('0x45')][_0x7f5f('0x50')]){_0x8e2e5a[_0x7f5f('0x51')]=_[_0x7f5f('0x38')](_0x8e2e5a[_0x7f5f('0x51')],{'$or':_[_0x7f5f('0x41')](_0x1ea650,function(_0x26fd36){if(_0x26fd36[_0x7f5f('0x43')]!=='VIRTUAL'){var _0x512c85={};_0x512c85[_0x26fd36[_0x7f5f('0x36')]]={'$like':'%'+_0x4b7fcd[_0x7f5f('0x45')]['filter']+'%'};return _0x512c85;}})});}_0x8e2e5a=_[_0x7f5f('0x38')]({},_0x8e2e5a,_0x4b7fcd['options']);var _0x38e146={'where':_0x8e2e5a[_0x7f5f('0x51')]};return db[_0x7f5f('0x52')][_0x7f5f('0x53')](_0x38e146)[_0x7f5f('0x1d')](function(_0x4a1355){_0xd8ecfb[_0x7f5f('0x53')]=_0x4a1355;if(_0x4b7fcd[_0x7f5f('0x45')][_0x7f5f('0x54')]){_0x8e2e5a['include']=[{'all':!![]}];}return db['MailAccount'][_0x7f5f('0x55')](_0x8e2e5a);})[_0x7f5f('0x1d')](function(_0x222bdf){_0xd8ecfb[_0x7f5f('0x56')]=_0x222bdf;return _0xd8ecfb;})[_0x7f5f('0x1d')](respondWithFilteredResult(_0x2a1852,_0x8e2e5a))[_0x7f5f('0x25')](handleError(_0x2a1852,null));};exports[_0x7f5f('0x57')]=function(_0x226f8e,_0x4b568a){var _0x5b43f5={'raw':![],'where':{'id':_0x226f8e['params']['id']},'include':[{'model':db['MailServerIn'],'as':'Imap'},{'model':db[_0x7f5f('0x3e')],'as':_0x7f5f('0x58')},{'model':db[_0x7f5f('0x3f')],'as':_0x7f5f('0x40')}]},_0x39b057={};_0x39b057[_0x7f5f('0x44')]=_['keys'](db[_0x7f5f('0x52')][_0x7f5f('0x42')]);_0x39b057['query']=_[_0x7f5f('0x59')](_0x226f8e[_0x7f5f('0x45')]);_0x39b057['filters']=_['intersection'](_0x39b057[_0x7f5f('0x44')],_0x39b057[_0x7f5f('0x45')]);_0x5b43f5['attributes']=_['intersection'](_0x39b057[_0x7f5f('0x44')],qs['fields'](_0x226f8e[_0x7f5f('0x45')]['fields']));_0x5b43f5[_0x7f5f('0x49')]=_0x5b43f5[_0x7f5f('0x49')]['length']?_0x5b43f5['attributes']:_0x39b057[_0x7f5f('0x44')];if(_0x226f8e['query'][_0x7f5f('0x54')]){_0x5b43f5[_0x7f5f('0x5a')]=[{'all':!![]}];}_0x5b43f5=_['merge']({},_0x5b43f5,_0x226f8e[_0x7f5f('0x5b')]);return db['MailAccount']['find'](_0x5b43f5)['then'](handleEntityNotFound(_0x4b568a,null))[_0x7f5f('0x1d')](respondWithResult(_0x4b568a,null))[_0x7f5f('0x25')](handleError(_0x4b568a,null));};exports[_0x7f5f('0x5c')]=function(_0x5acc4a,_0x1a9c17){if(_0x5acc4a[_0x7f5f('0x39')]['id']){delete _0x5acc4a[_0x7f5f('0x39')]['id'];}return db[_0x7f5f('0x52')][_0x7f5f('0x5d')]({'where':{'id':_0x5acc4a[_0x7f5f('0x5e')]['id']},'include':[{'model':db[_0x7f5f('0x3d')],'as':_0x7f5f('0x5f')},{'model':db[_0x7f5f('0x3e')],'as':'Smtp'},{'model':db[_0x7f5f('0x3f')],'as':_0x7f5f('0x40')}]})['then'](handleEntityNotFound(_0x1a9c17,null))['then'](saveUpdates(_0x5acc4a[_0x7f5f('0x39')],null))['then'](function(_0x4f7485){if(_0x4f7485&&_0x5acc4a[_0x7f5f('0x39')]['Imap']){return db[_0x7f5f('0x3d')][_0x7f5f('0x5c')](_0x5acc4a[_0x7f5f('0x39')][_0x7f5f('0x5f')],{'where':{'MailAccountId':_0x4f7485['id']}})[_0x7f5f('0x1d')](function(){return _0x4f7485;});}return _0x4f7485;})[_0x7f5f('0x1d')](function(_0x2ed2ee){if(_0x2ed2ee&&_0x5acc4a[_0x7f5f('0x39')][_0x7f5f('0x58')]){return db[_0x7f5f('0x3e')][_0x7f5f('0x5c')](_0x5acc4a[_0x7f5f('0x39')][_0x7f5f('0x58')],{'where':{'MailAccountId':_0x2ed2ee['id']}})['then'](function(){return _0x2ed2ee;});}return _0x2ed2ee;})[_0x7f5f('0x1d')](respondWithResult(_0x1a9c17,null))[_0x7f5f('0x25')](handleError(_0x1a9c17,null));};exports[_0x7f5f('0x60')]=function(_0x241cf9,_0x1a7806){return db['MailAccount'][_0x7f5f('0x60')]()[_0x7f5f('0x1d')](respondWithResult(_0x1a7806,null))[_0x7f5f('0x25')](handleError(_0x1a7806,null));};exports[_0x7f5f('0x61')]=function(_0x18b41d,_0x23277b,_0x2aa7ab){if(_0x18b41d['body']['id']){delete _0x18b41d[_0x7f5f('0x39')]['id'];}return db['MailAccount'][_0x7f5f('0x5d')]({'where':{'id':_0x18b41d[_0x7f5f('0x5e')]['id']}})['then'](handleEntityNotFound(_0x23277b,null))[_0x7f5f('0x1d')](function(_0xc7756b){if(_0xc7756b){_0x18b41d[_0x7f5f('0x39')][_0x7f5f('0x62')]=_0xc7756b['id'];return db[_0x7f5f('0x63')][_0x7f5f('0x64')](_0x18b41d['body']);}})[_0x7f5f('0x1d')](respondWithResult(_0x23277b,null))[_0x7f5f('0x25')](handleError(_0x23277b,null));};exports[_0x7f5f('0x65')]=function(_0x2e1540,_0xb5a313,_0x26bade){var _0x413a16={'raw':![],'where':{}};var _0x282c59={};var _0x5a77b6={'count':0x0,'rows':[]};return db[_0x7f5f('0x52')][_0x7f5f('0x66')]({'where':{'id':_0x2e1540['params']['id']}})[_0x7f5f('0x1d')](handleEntityNotFound(_0xb5a313,null))['then'](function(_0x4d2467){if(_0x4d2467){_0x282c59[_0x7f5f('0x44')]=_[_0x7f5f('0x59')](db[_0x7f5f('0x63')][_0x7f5f('0x42')]);_0x282c59['query']=_[_0x7f5f('0x59')](_0x2e1540[_0x7f5f('0x45')]);_0x282c59['filters']=_['intersection'](_0x282c59[_0x7f5f('0x44')],_0x282c59[_0x7f5f('0x45')]);_0x413a16[_0x7f5f('0x49')]=_[_0x7f5f('0x47')](_0x282c59['model'],qs['fields'](_0x2e1540[_0x7f5f('0x45')][_0x7f5f('0x48')]));_0x413a16['attributes']=_0x413a16['attributes'][_0x7f5f('0x4a')]?_0x413a16[_0x7f5f('0x49')]:_0x282c59['model'];if(!_0x2e1540['query'][_0x7f5f('0x4b')]('nolimit')){_0x413a16[_0x7f5f('0x2b')]=qs[_0x7f5f('0x2b')](_0x2e1540[_0x7f5f('0x45')][_0x7f5f('0x2b')]);_0x413a16[_0x7f5f('0x29')]=qs['offset'](_0x2e1540['query'][_0x7f5f('0x29')]);}_0x413a16[_0x7f5f('0x4d')]=qs[_0x7f5f('0x4e')](_0x2e1540[_0x7f5f('0x45')][_0x7f5f('0x4e')]);_0x413a16[_0x7f5f('0x51')]=qs[_0x7f5f('0x46')](_['pick'](_0x2e1540[_0x7f5f('0x45')],_0x282c59[_0x7f5f('0x46')]));_0x413a16[_0x7f5f('0x51')][_0x7f5f('0x62')]=_0x4d2467['id'];if(_0x2e1540[_0x7f5f('0x45')][_0x7f5f('0x50')]){_0x413a16[_0x7f5f('0x51')]=_[_0x7f5f('0x38')](_0x413a16[_0x7f5f('0x51')],{'$or':_[_0x7f5f('0x41')](_0x413a16[_0x7f5f('0x49')],function(_0xdb7947){var _0x5a745={};_0x5a745[_0xdb7947]={'$like':'%'+_0x2e1540[_0x7f5f('0x45')]['filter']+'%'};return _0x5a745;})});}_0x413a16=_[_0x7f5f('0x38')]({},_0x413a16,_0x2e1540[_0x7f5f('0x5b')]);return db[_0x7f5f('0x63')][_0x7f5f('0x53')]({'where':_0x413a16[_0x7f5f('0x51')]})['then'](function(_0x598be1){_0x5a77b6[_0x7f5f('0x53')]=_0x598be1;if(_0x2e1540[_0x7f5f('0x45')]['includeAll']){_0x413a16[_0x7f5f('0x5a')]=[{'all':!![]}];}return db['Disposition'][_0x7f5f('0x55')](_0x413a16);})['then'](function(_0x19ecdd){_0x5a77b6[_0x7f5f('0x56')]=_0x19ecdd;return _0x5a77b6;});}})[_0x7f5f('0x1d')](respondWithFilteredResult(_0xb5a313,_0x413a16))[_0x7f5f('0x25')](handleError(_0xb5a313,null));};exports[_0x7f5f('0x67')]=function(_0x3124bd,_0x1ce1de,_0x657353){return db[_0x7f5f('0x52')][_0x7f5f('0x5d')]({'where':{'id':_0x3124bd[_0x7f5f('0x5e')]['id']}})[_0x7f5f('0x1d')](handleEntityNotFound(_0x1ce1de,null))[_0x7f5f('0x1d')](function(_0xe8ee2){if(_0xe8ee2){return _0xe8ee2[_0x7f5f('0x67')](_0x3124bd['query'][_0x7f5f('0x68')]);}})[_0x7f5f('0x1d')](respondWithStatusCode(_0x1ce1de,null))['catch'](handleError(_0x1ce1de,null));};exports['addAnswer']=function(_0x402abd,_0x729383,_0x2fbfb0){if(_0x402abd[_0x7f5f('0x39')]['id']){delete _0x402abd[_0x7f5f('0x39')]['id'];}return db['MailAccount']['find']({'where':{'id':_0x402abd['params']['id']}})['then'](handleEntityNotFound(_0x729383,null))[_0x7f5f('0x1d')](function(_0x5002c7){if(_0x5002c7){_0x402abd[_0x7f5f('0x39')][_0x7f5f('0x62')]=_0x5002c7['id'];return db[_0x7f5f('0x69')][_0x7f5f('0x64')](_0x402abd['body']);}})[_0x7f5f('0x1d')](respondWithResult(_0x729383,null))[_0x7f5f('0x25')](handleError(_0x729383,null));};exports[_0x7f5f('0x6a')]=function(_0x1f043b,_0x23eda9,_0x2c6487){var _0x5b7cee={'raw':![],'where':{}};var _0x1975aa={};var _0x34fbf2={'count':0x0,'rows':[]};return db[_0x7f5f('0x52')][_0x7f5f('0x66')]({'where':{'id':_0x1f043b[_0x7f5f('0x5e')]['id']}})[_0x7f5f('0x1d')](handleEntityNotFound(_0x23eda9,null))[_0x7f5f('0x1d')](function(_0xd9ab80){if(_0xd9ab80){_0x1975aa[_0x7f5f('0x44')]=_[_0x7f5f('0x59')](db[_0x7f5f('0x69')][_0x7f5f('0x42')]);_0x1975aa[_0x7f5f('0x45')]=_['keys'](_0x1f043b[_0x7f5f('0x45')]);_0x1975aa[_0x7f5f('0x46')]=_['intersection'](_0x1975aa[_0x7f5f('0x44')],_0x1975aa['query']);_0x5b7cee['attributes']=_[_0x7f5f('0x47')](_0x1975aa['model'],qs[_0x7f5f('0x48')](_0x1f043b[_0x7f5f('0x45')][_0x7f5f('0x48')]));_0x5b7cee[_0x7f5f('0x49')]=_0x5b7cee[_0x7f5f('0x49')][_0x7f5f('0x4a')]?_0x5b7cee[_0x7f5f('0x49')]:_0x1975aa[_0x7f5f('0x44')];if(!_0x1f043b[_0x7f5f('0x45')][_0x7f5f('0x4b')](_0x7f5f('0x4c'))){_0x5b7cee[_0x7f5f('0x2b')]=qs[_0x7f5f('0x2b')](_0x1f043b[_0x7f5f('0x45')][_0x7f5f('0x2b')]);_0x5b7cee[_0x7f5f('0x29')]=qs[_0x7f5f('0x29')](_0x1f043b[_0x7f5f('0x45')][_0x7f5f('0x29')]);}_0x5b7cee[_0x7f5f('0x4d')]=qs[_0x7f5f('0x4e')](_0x1f043b[_0x7f5f('0x45')][_0x7f5f('0x4e')]);_0x5b7cee[_0x7f5f('0x51')]=qs[_0x7f5f('0x46')](_[_0x7f5f('0x4f')](_0x1f043b[_0x7f5f('0x45')],_0x1975aa[_0x7f5f('0x46')]));_0x5b7cee[_0x7f5f('0x51')]['MailAccountId']=_0xd9ab80['id'];if(_0x1f043b[_0x7f5f('0x45')]['filter']){_0x5b7cee[_0x7f5f('0x51')]=_[_0x7f5f('0x38')](_0x5b7cee[_0x7f5f('0x51')],{'$or':_[_0x7f5f('0x41')](_0x5b7cee[_0x7f5f('0x49')],function(_0x2fb62e){var _0x1374ec={};_0x1374ec[_0x2fb62e]={'$like':'%'+_0x1f043b[_0x7f5f('0x45')]['filter']+'%'};return _0x1374ec;})});}_0x5b7cee=_[_0x7f5f('0x38')]({},_0x5b7cee,_0x1f043b[_0x7f5f('0x5b')]);return db[_0x7f5f('0x69')]['count']({'where':_0x5b7cee['where']})['then'](function(_0x27c781){_0x34fbf2[_0x7f5f('0x53')]=_0x27c781;if(_0x1f043b['query'][_0x7f5f('0x54')]){_0x5b7cee[_0x7f5f('0x5a')]=[{'all':!![]}];}return db[_0x7f5f('0x69')][_0x7f5f('0x55')](_0x5b7cee);})['then'](function(_0xf6ea9){_0x34fbf2[_0x7f5f('0x56')]=_0xf6ea9;return _0x34fbf2;});}})[_0x7f5f('0x1d')](respondWithFilteredResult(_0x23eda9,_0x5b7cee))[_0x7f5f('0x25')](handleError(_0x23eda9,null));};exports['removeAnswers']=function(_0x3d1151,_0x54649b,_0x54d30b){return db[_0x7f5f('0x52')][_0x7f5f('0x5d')]({'where':{'id':_0x3d1151[_0x7f5f('0x5e')]['id']}})[_0x7f5f('0x1d')](handleEntityNotFound(_0x54649b,null))['then'](function(_0x56c463){if(_0x56c463){return _0x56c463[_0x7f5f('0x6b')](_0x3d1151['query']['ids']);}})[_0x7f5f('0x1d')](respondWithStatusCode(_0x54649b,null))[_0x7f5f('0x25')](handleError(_0x54649b,null));};exports[_0x7f5f('0x64')]=function(_0x1a899d,_0x38328f){var _0x46b74b={'name':_0x1a899d[_0x7f5f('0x39')][_0x7f5f('0x36')],'key':_0x1a899d[_0x7f5f('0x39')][_0x7f5f('0x6c')],'email':_0x1a899d[_0x7f5f('0x39')][_0x7f5f('0x6d')],'ListId':_0x1a899d[_0x7f5f('0x39')][_0x7f5f('0x6e')],'active':!_['isNil'](_0x1a899d[_0x7f5f('0x39')]['active'])?_0x1a899d[_0x7f5f('0x39')][_0x7f5f('0x6f')]:!![],'description':_0x1a899d[_0x7f5f('0x39')][_0x7f5f('0x70')]||null,'Imap':{},'Smtp':{}};if(_[_0x7f5f('0x71')](_0x1a899d[_0x7f5f('0x39')][_0x7f5f('0x72')])){if(_0x1a899d[_0x7f5f('0x39')][_0x7f5f('0x73')]){_0x46b74b[_0x7f5f('0x5f')][_0x7f5f('0x74')]=_0x46b74b[_0x7f5f('0x58')][_0x7f5f('0x74')]=_0x1a899d[_0x7f5f('0x39')][_0x7f5f('0x75')];_0x46b74b['Imap'][_0x7f5f('0x76')]=_0x46b74b[_0x7f5f('0x58')][_0x7f5f('0x77')]=_0x1a899d['body'][_0x7f5f('0x78')];}else{_0x46b74b[_0x7f5f('0x5f')][_0x7f5f('0x79')]=_0x46b74b['Smtp'][_0x7f5f('0x79')]=![];}_0x46b74b[_0x7f5f('0x5f')][_0x7f5f('0x7a')]=_0x1a899d[_0x7f5f('0x39')][_0x7f5f('0x5f')][_0x7f5f('0x7a')];_0x46b74b[_0x7f5f('0x5f')][_0x7f5f('0x7b')]=_0x1a899d[_0x7f5f('0x39')]['Imap'][_0x7f5f('0x7b')];_0x46b74b[_0x7f5f('0x58')][_0x7f5f('0x7a')]=_0x1a899d['body']['Smtp'][_0x7f5f('0x7a')];_0x46b74b[_0x7f5f('0x58')][_0x7f5f('0x7b')]=_0x1a899d['body'][_0x7f5f('0x58')][_0x7f5f('0x7b')];}else{_0x46b74b[_0x7f5f('0x5f')][_0x7f5f('0x7c')]=_0x46b74b['Smtp'][_0x7f5f('0x7c')]=_0x1a899d[_0x7f5f('0x39')][_0x7f5f('0x72')];_0x46b74b['Imap'][_0x7f5f('0x74')]=_0x46b74b[_0x7f5f('0x58')][_0x7f5f('0x74')]=_0x1a899d[_0x7f5f('0x39')][_0x7f5f('0x75')];_0x46b74b['Imap'][_0x7f5f('0x76')]=_0x46b74b[_0x7f5f('0x58')][_0x7f5f('0x77')]=_0x1a899d[_0x7f5f('0x39')][_0x7f5f('0x78')];}return db[_0x7f5f('0x52')][_0x7f5f('0x64')](_0x46b74b,{'include':[{'model':db[_0x7f5f('0x3e')],'as':_0x7f5f('0x58')},{'model':db[_0x7f5f('0x3d')],'as':_0x7f5f('0x5f')}]})[_0x7f5f('0x1d')](function(_0xdcff6f){var _0xd67835=_0x1a899d['user'][_0x7f5f('0x31')]({'plain':!![]});if(!_0xd67835)throw new Error(_0x7f5f('0x7d'));if(_0xd67835[_0x7f5f('0x7e')]===_0x7f5f('0x74')){var _0x3dfa63=_0xdcff6f[_0x7f5f('0x31')]({'plain':!![]});return db[_0x7f5f('0x7f')][_0x7f5f('0x5d')]({'where':{'name':_0x7f5f('0x32'),'userProfileId':_0xd67835[_0x7f5f('0x80')]},'raw':!![]})[_0x7f5f('0x1d')](function(_0x10010a){if(_0x10010a&&_0x10010a[_0x7f5f('0x81')]===0x0){return db['UserProfileResource'][_0x7f5f('0x64')]({'name':_0x3dfa63[_0x7f5f('0x36')],'resourceId':_0x3dfa63['id'],'type':_0x10010a[_0x7f5f('0x36')],'sectionId':_0x10010a['id']},{})[_0x7f5f('0x1d')](function(){return _0xdcff6f;});}else{return _0xdcff6f;}})[_0x7f5f('0x25')](function(_0x2a91ec){logger[_0x7f5f('0x22')](_0x7f5f('0x82'),_0x2a91ec);throw _0x2a91ec;});}return _0xdcff6f;})[_0x7f5f('0x1d')](respondWithResult(_0x38328f,0xc9))[_0x7f5f('0x25')](handleError(_0x38328f,null));};exports[_0x7f5f('0x83')]=function(_0x59e16f,_0x15c7e5,_0x202585){return db[_0x7f5f('0x52')][_0x7f5f('0x66')]({'where':{'id':_0x59e16f['params']['id']}})['then'](handleEntityNotFound(_0x15c7e5,null))[_0x7f5f('0x1d')](function(_0x1d479d){if(_0x1d479d){return _0x1d479d['getImap']();}return null;})[_0x7f5f('0x1d')](respondWithResult(_0x15c7e5,null))[_0x7f5f('0x25')](handleError(_0x15c7e5,null));};exports[_0x7f5f('0x84')]=function(_0xc623f1,_0x1d1bae,_0x29f712){if(_0xc623f1[_0x7f5f('0x39')]['id']){delete _0xc623f1[_0x7f5f('0x39')]['id'];}return db[_0x7f5f('0x52')][_0x7f5f('0x5d')]({'where':{'id':_0xc623f1[_0x7f5f('0x5e')]['id']}})[_0x7f5f('0x1d')](handleEntityNotFound(_0x1d1bae,null))['then'](function(_0x3a1419){if(_0x3a1419){_0xc623f1[_0x7f5f('0x39')]['MailAccountId']=_0x3a1419['id'];return db[_0x7f5f('0x3d')][_0x7f5f('0x64')](_0xc623f1[_0x7f5f('0x39')]);}})[_0x7f5f('0x1d')](respondWithResult(_0x1d1bae,null))[_0x7f5f('0x25')](handleError(_0x1d1bae,null));};exports[_0x7f5f('0x85')]=function(_0x45483e,_0x22072e,_0x28c0f3){return db[_0x7f5f('0x52')]['findOne']({'where':{'id':_0x45483e['params']['id']}})[_0x7f5f('0x1d')](handleEntityNotFound(_0x22072e,null))[_0x7f5f('0x1d')](function(_0x31ba4e){if(_0x31ba4e){return _0x31ba4e[_0x7f5f('0x86')](null);}return null;})[_0x7f5f('0x1d')](respondWithStatusCode(_0x22072e,null))[_0x7f5f('0x25')](handleError(_0x22072e,null));};exports[_0x7f5f('0x87')]=function(_0x463e6b,_0x596c2b,_0x66d861){return db[_0x7f5f('0x52')][_0x7f5f('0x66')]({'where':{'id':_0x463e6b[_0x7f5f('0x5e')]['id']}})[_0x7f5f('0x1d')](handleEntityNotFound(_0x596c2b,null))[_0x7f5f('0x1d')](function(_0x475107){if(_0x475107){return _0x475107[_0x7f5f('0x87')]();}return null;})[_0x7f5f('0x1d')](respondWithResult(_0x596c2b,null))[_0x7f5f('0x25')](handleError(_0x596c2b,null));};exports[_0x7f5f('0x88')]=function(_0x91fba8,_0x463956,_0x18704b){if(_0x91fba8[_0x7f5f('0x39')]['id']){delete _0x91fba8[_0x7f5f('0x39')]['id'];}return db[_0x7f5f('0x52')]['find']({'where':{'id':_0x91fba8[_0x7f5f('0x5e')]['id']}})['then'](handleEntityNotFound(_0x463956,null))['then'](function(_0x1f2e79){if(_0x1f2e79){_0x91fba8[_0x7f5f('0x39')]['MailAccountId']=_0x1f2e79['id'];return db['MailServerOut'][_0x7f5f('0x64')](_0x91fba8[_0x7f5f('0x39')]);}})[_0x7f5f('0x1d')](respondWithResult(_0x463956,null))[_0x7f5f('0x25')](handleError(_0x463956,null));};exports[_0x7f5f('0x89')]=function(_0x1eadcc,_0x445349,_0x3d2af8){return db[_0x7f5f('0x52')][_0x7f5f('0x66')]({'where':{'id':_0x1eadcc[_0x7f5f('0x5e')]['id']}})[_0x7f5f('0x1d')](handleEntityNotFound(_0x445349,null))['then'](function(_0x2cbf6a){if(_0x2cbf6a){return _0x2cbf6a['setSmtp'](null);}return null;})[_0x7f5f('0x1d')](respondWithStatusCode(_0x445349,null))[_0x7f5f('0x25')](handleError(_0x445349,null));};exports['addInteraction']=function(_0x1c3315,_0x36175b,_0xd5a4a5){return db[_0x7f5f('0x8a')]['find']({'where':{'id':_0x1c3315[_0x7f5f('0x5e')]['id']}})[_0x7f5f('0x1d')](handleEntityNotFound(_0x36175b,null))['then'](function(_0x287c9e){if(_0x287c9e){return _0x287c9e['addInteraction'](_0x1c3315[_0x7f5f('0x39')]['ids'],_['omit'](_0x1c3315[_0x7f5f('0x39')],[_0x7f5f('0x68'),'id'])||{});}})[_0x7f5f('0x1d')](respondWithResult(_0x36175b,null))[_0x7f5f('0x25')](handleError(_0x36175b,null));};exports[_0x7f5f('0x8b')]=function(_0xea0f09,_0x2058df,_0x416345){var _0x2e3da3={'raw':![],'where':{}};var _0x6850c8={};var _0x453288={'count':0x0,'rows':[]};return db[_0x7f5f('0x52')]['findOne']({'where':{'id':_0xea0f09[_0x7f5f('0x5e')]['id']}})[_0x7f5f('0x1d')](handleEntityNotFound(_0x2058df,null))[_0x7f5f('0x1d')](function(_0x53032f){if(_0x53032f){_0x6850c8[_0x7f5f('0x44')]=_[_0x7f5f('0x59')](db[_0x7f5f('0x8a')][_0x7f5f('0x42')]);_0x6850c8['query']=_['keys'](_0xea0f09[_0x7f5f('0x45')]);_0x6850c8[_0x7f5f('0x46')]=_['intersection'](_0x6850c8['model'],_0x6850c8[_0x7f5f('0x45')]);_0x2e3da3[_0x7f5f('0x49')]=_[_0x7f5f('0x47')](_0x6850c8[_0x7f5f('0x44')],qs['fields'](_0xea0f09[_0x7f5f('0x45')][_0x7f5f('0x48')]));_0x2e3da3[_0x7f5f('0x49')]=_0x2e3da3[_0x7f5f('0x49')]['length']?_0x2e3da3[_0x7f5f('0x49')]:_0x6850c8[_0x7f5f('0x44')];if(!_0xea0f09[_0x7f5f('0x45')][_0x7f5f('0x4b')](_0x7f5f('0x4c'))){_0x2e3da3['limit']=qs['limit'](_0xea0f09[_0x7f5f('0x45')][_0x7f5f('0x2b')]);_0x2e3da3[_0x7f5f('0x29')]=qs[_0x7f5f('0x29')](_0xea0f09[_0x7f5f('0x45')][_0x7f5f('0x29')]);}_0x2e3da3[_0x7f5f('0x4d')]=qs[_0x7f5f('0x4e')](_0xea0f09['query']['sort']);_0x2e3da3[_0x7f5f('0x51')]=qs[_0x7f5f('0x46')](_[_0x7f5f('0x4f')](_0xea0f09[_0x7f5f('0x45')],_0x6850c8[_0x7f5f('0x46')]));_0x2e3da3[_0x7f5f('0x51')][_0x7f5f('0x62')]=_0x53032f['id'];if(_0xea0f09[_0x7f5f('0x45')]['filter']){_0x2e3da3['where']=_[_0x7f5f('0x38')](_0x2e3da3[_0x7f5f('0x51')],{'$or':_[_0x7f5f('0x41')](_0x2e3da3[_0x7f5f('0x49')],function(_0x454f6b){var _0x828395={};_0x828395[_0x454f6b]={'$like':'%'+_0xea0f09['query'][_0x7f5f('0x50')]+'%'};return _0x828395;})});}_0x2e3da3=_[_0x7f5f('0x38')]({},_0x2e3da3,_0xea0f09['options']);return db[_0x7f5f('0x8a')][_0x7f5f('0x53')]({'where':_0x2e3da3[_0x7f5f('0x51')]})[_0x7f5f('0x1d')](function(_0x27798d){_0x453288[_0x7f5f('0x53')]=_0x27798d;if(_0xea0f09[_0x7f5f('0x45')][_0x7f5f('0x54')]){_0x2e3da3['include']=[{'model':db[_0x7f5f('0x8c')],'as':_0x7f5f('0x8d'),'required':![]},{'model':db['User'],'as':_0x7f5f('0x8e'),'attributes':['name',_0x7f5f('0x8f'),_0x7f5f('0x90')],'required':![]},{'model':db[_0x7f5f('0x91')],'as':_0x7f5f('0x92'),'attributes':['id',_0x7f5f('0x36'),'color'],'where':_0xea0f09['query'][_0x7f5f('0x93')]?{'id':_0xea0f09[_0x7f5f('0x45')][_0x7f5f('0x93')]}:undefined,'required':_0xea0f09['query'][_0x7f5f('0x93')]?!![]:![]}];}return db[_0x7f5f('0x8a')][_0x7f5f('0x55')](_0x2e3da3);})[_0x7f5f('0x1d')](function(_0x560e96){_0x453288[_0x7f5f('0x56')]=_0x560e96;return _0x453288;});}})[_0x7f5f('0x1d')](respondWithFilteredResult(_0x2058df,_0x2e3da3))[_0x7f5f('0x25')](handleError(_0x2058df,null));};exports['addApplications']=function(_0x144b38,_0x5efd96,_0x138152){return db[_0x7f5f('0x52')]['findOne']({'where':{'id':_0x144b38[_0x7f5f('0x5e')]['id']}})['then'](handleEntityNotFound(_0x5efd96,null))['then'](function(_0x4e5582){if(_0x4e5582){return db[_0x7f5f('0x94')][_0x7f5f('0x95')](function(_0x176143){return db['MailApplication'][_0x7f5f('0x30')]({'where':{'MailAccountId':_0x144b38[_0x7f5f('0x5e')]['id']},'transaction':_0x176143})[_0x7f5f('0x1d')](function(_0x1f91e5){var _0x3f3c14=_['map'](_0x144b38[_0x7f5f('0x39')],function(_0x26ff54){_0x26ff54[_0x7f5f('0x62')]=_0x144b38['params']['id'];return _0x26ff54;});return db[_0x7f5f('0x96')][_0x7f5f('0x97')](_0x3f3c14,{'transaction':_0x176143});});})['then'](function(){return db[_0x7f5f('0x96')]['findAndCountAll']({'where':{'MailAccountId':_0x144b38[_0x7f5f('0x5e')]['id']},'order':_0x7f5f('0x98')});});}})[_0x7f5f('0x1d')](respondWithResult(_0x5efd96,null))[_0x7f5f('0x25')](handleError(_0x5efd96,null));};exports[_0x7f5f('0x99')]=function(_0x1dc517,_0x6d1229,_0x23673f){var _0xc1812a={};var _0x3b5121={};var _0x125bf4;var _0x41b154;return db['MailAccount']['findOne']({'where':{'id':_0x1dc517[_0x7f5f('0x5e')]['id']}})[_0x7f5f('0x1d')](handleEntityNotFound(_0x6d1229,null))[_0x7f5f('0x1d')](function(_0x3682d9){if(_0x3682d9){_0x125bf4=_0x3682d9;_0x3b5121['model']=_[_0x7f5f('0x59')](db['MailApplication'][_0x7f5f('0x42')]);_0x3b5121[_0x7f5f('0x45')]=_[_0x7f5f('0x59')](_0x1dc517[_0x7f5f('0x45')]);_0x3b5121[_0x7f5f('0x46')]=_[_0x7f5f('0x47')](_0x3b5121[_0x7f5f('0x44')],_0x3b5121[_0x7f5f('0x45')]);_0xc1812a[_0x7f5f('0x49')]=_[_0x7f5f('0x47')](_0x3b5121[_0x7f5f('0x44')],qs[_0x7f5f('0x48')](_0x1dc517[_0x7f5f('0x45')][_0x7f5f('0x48')]));_0xc1812a[_0x7f5f('0x49')]=_0xc1812a[_0x7f5f('0x49')]['length']?_0xc1812a[_0x7f5f('0x49')]:_0x3b5121[_0x7f5f('0x44')];_0xc1812a[_0x7f5f('0x4d')]=qs[_0x7f5f('0x4e')](_0x1dc517['query'][_0x7f5f('0x4e')]);_0xc1812a[_0x7f5f('0x51')]=qs[_0x7f5f('0x46')](_[_0x7f5f('0x4f')](_0x1dc517[_0x7f5f('0x45')],_0x3b5121[_0x7f5f('0x46')]));if(_0x1dc517[_0x7f5f('0x45')]['filter']){_0xc1812a[_0x7f5f('0x51')]=_[_0x7f5f('0x38')](_0xc1812a[_0x7f5f('0x51')],{'$or':_[_0x7f5f('0x41')](_0xc1812a[_0x7f5f('0x49')],function(_0x5a6b4f){var _0x5cf68b={};_0x5cf68b[_0x5a6b4f]={'$like':'%'+_0x1dc517['query'][_0x7f5f('0x50')]+'%'};return _0x5cf68b;})});}_0xc1812a=_['merge']({},_0xc1812a,_0x1dc517[_0x7f5f('0x5b')]);return _0x125bf4[_0x7f5f('0x99')](_0xc1812a);}})[_0x7f5f('0x1d')](function(_0x555a18){if(_0x555a18){_0x41b154=_0x555a18['length'];if(!_0x1dc517['query'][_0x7f5f('0x4b')](_0x7f5f('0x4c'))){_0xc1812a[_0x7f5f('0x2b')]=qs[_0x7f5f('0x2b')](_0x1dc517['query'][_0x7f5f('0x2b')]);_0xc1812a[_0x7f5f('0x29')]=qs[_0x7f5f('0x29')](_0x1dc517[_0x7f5f('0x45')][_0x7f5f('0x29')]);}return _0x125bf4[_0x7f5f('0x99')](_0xc1812a);}})[_0x7f5f('0x1d')](function(_0xe87ead){if(_0xe87ead){return _0xe87ead?{'count':_0x41b154,'rows':_0xe87ead}:null;}})[_0x7f5f('0x1d')](respondWithResult(_0x6d1229,null))[_0x7f5f('0x25')](handleError(_0x6d1229,null));};exports[_0x7f5f('0x9a')]=function(_0x37e8a2,_0x446723,_0x5c731c){var _0x1ce4aa={'raw':!![],'where':{}};var _0x21a62a={};var _0x1f24a3={'count':0x0,'rows':[]};return db[_0x7f5f('0x52')][_0x7f5f('0x66')]({'where':{'id':_0x37e8a2[_0x7f5f('0x5e')]['id']}})[_0x7f5f('0x1d')](handleEntityNotFound(_0x446723,null))['then'](function(_0x35493a){if(_0x35493a){_0x21a62a[_0x7f5f('0x44')]=_[_0x7f5f('0x59')](db['MailMessage'][_0x7f5f('0x42')]);_0x21a62a[_0x7f5f('0x45')]=_[_0x7f5f('0x59')](_0x37e8a2['query']);_0x21a62a[_0x7f5f('0x46')]=_[_0x7f5f('0x47')](_0x21a62a[_0x7f5f('0x44')],_0x21a62a['query']);_0x1ce4aa['attributes']=_[_0x7f5f('0x47')](_0x21a62a[_0x7f5f('0x44')],qs['fields'](_0x37e8a2[_0x7f5f('0x45')][_0x7f5f('0x48')]));_0x1ce4aa[_0x7f5f('0x49')]=_0x1ce4aa[_0x7f5f('0x49')][_0x7f5f('0x4a')]?_0x1ce4aa[_0x7f5f('0x49')]:_0x21a62a[_0x7f5f('0x44')];if(!_0x37e8a2[_0x7f5f('0x45')][_0x7f5f('0x4b')](_0x7f5f('0x4c'))){_0x1ce4aa[_0x7f5f('0x2b')]=qs['limit'](_0x37e8a2[_0x7f5f('0x45')][_0x7f5f('0x2b')]);_0x1ce4aa[_0x7f5f('0x29')]=qs['offset'](_0x37e8a2[_0x7f5f('0x45')][_0x7f5f('0x29')]);}_0x1ce4aa['order']=qs['sort'](_0x37e8a2[_0x7f5f('0x45')]['sort']);_0x1ce4aa[_0x7f5f('0x51')]=qs[_0x7f5f('0x46')](_[_0x7f5f('0x4f')](_0x37e8a2[_0x7f5f('0x45')],_0x21a62a[_0x7f5f('0x46')]));_0x1ce4aa[_0x7f5f('0x51')]['MailAccountId']=_0x35493a['id'];if(_0x37e8a2[_0x7f5f('0x45')]['filter']){_0x1ce4aa[_0x7f5f('0x51')]=_[_0x7f5f('0x38')](_0x1ce4aa[_0x7f5f('0x51')],{'$or':_[_0x7f5f('0x41')](_0x1ce4aa[_0x7f5f('0x49')],function(_0x37f5bf){var _0x471e37={};_0x471e37[_0x37f5bf]={'$like':'%'+_0x37e8a2[_0x7f5f('0x45')]['filter']+'%'};return _0x471e37;})});}if(_0x37e8a2[_0x7f5f('0x45')][_0x7f5f('0x9b')]){var _0x30235c=_0x37e8a2[_0x7f5f('0x45')][_0x7f5f('0x9b')][_0x7f5f('0x9c')](',');var _0x312ce8={};_0x312ce8[_0x30235c[0x0]]={'$gte':moment(_0x30235c[0x1])[_0x7f5f('0x9d')](_0x7f5f('0x9e'))};_0x1ce4aa['where']=_[_0x7f5f('0x38')](_0x1ce4aa['where'],_0x312ce8);}_0x1ce4aa=_[_0x7f5f('0x38')]({},_0x1ce4aa,_0x37e8a2[_0x7f5f('0x5b')]);return db[_0x7f5f('0x9f')][_0x7f5f('0x53')]({'where':_0x1ce4aa['where']})[_0x7f5f('0x1d')](function(_0x434976){_0x1f24a3['count']=_0x434976;if(_0x37e8a2['query'][_0x7f5f('0x54')]){_0x1ce4aa[_0x7f5f('0x5a')]=[{'all':!![]}];}return db[_0x7f5f('0x9f')][_0x7f5f('0x55')](_0x1ce4aa);})[_0x7f5f('0x1d')](function(_0x115fae){if(_0x37e8a2[_0x7f5f('0x45')][_0x7f5f('0xa0')]==='true'){for(var _0x8614b8=0x0;_0x8614b8<_0x115fae[_0x7f5f('0x4a')];_0x8614b8++){_0x115fae[_0x8614b8][_0x7f5f('0x39')]=juice(_0x115fae[_0x8614b8][_0x7f5f('0x39')]);}}_0x1f24a3[_0x7f5f('0x56')]=_0x115fae;return _0x1f24a3;});}})[_0x7f5f('0x1d')](respondWithFilteredResult(_0x446723,_0x1ce4aa))[_0x7f5f('0x25')](handleError(_0x446723,null));};exports[_0x7f5f('0xa1')]=function(_0x2e1d67,_0x319216,_0x5355f9){var _0x5b0549,_0x1717e2={},_0x880788;if(_0x2e1d67[_0x7f5f('0x39')]['to']){_0x880788=_0x2e1d67[_0x7f5f('0x39')]['to'][_0x7f5f('0x9c')](',')[0x0];}return db[_0x7f5f('0x52')][_0x7f5f('0x5d')]({'where':{'id':_0x2e1d67[_0x7f5f('0x5e')]['id']},'include':[{'model':db[_0x7f5f('0xa2')],'as':_0x7f5f('0xa3'),'include':[{'model':db[_0x7f5f('0x8c')],'as':_0x7f5f('0xa4'),'where':{'email':_0x880788},'limit':0x1,'order':[[_0x7f5f('0xa5'),_0x7f5f('0xa6')]]}]},{'model':db['MailServerOut'],'as':_0x7f5f('0x58'),'raw':!![]}]})['then'](handleEntityNotFound(_0x319216,null))[_0x7f5f('0x1d')](function(_0x5d123b){if(_0x5d123b){_0x5b0549=_0x5d123b;if(_0x5d123b['Smtp']){if(_[_0x7f5f('0x71')](_0x2e1d67[_0x7f5f('0x39')][_0x7f5f('0xa7')])){_0x2e1d67[_0x7f5f('0x39')][_0x7f5f('0xa7')]=util[_0x7f5f('0x9d')](_0x7f5f('0xa8'),_0x5d123b[_0x7f5f('0x36')],_0x5d123b[_0x7f5f('0x6d')]||_0x5d123b[_0x7f5f('0x58')][_0x7f5f('0x74')]);}if(_0x2e1d67[_0x7f5f('0x39')]['attachments']&&_0x2e1d67['body'][_0x7f5f('0xa9')]['length']){for(var _0x127370=0x0;_0x127370<_0x2e1d67[_0x7f5f('0x39')][_0x7f5f('0xa9')]['length'];_0x127370+=0x1){_0x2e1d67[_0x7f5f('0x39')][_0x7f5f('0xa9')][_0x127370]={'filename':_0x2e1d67[_0x7f5f('0x39')][_0x7f5f('0xa9')][_0x127370]['name'],'path':path[_0x7f5f('0xaa')](config[_0x7f5f('0xab')],_0x7f5f('0xac'),_0x2e1d67[_0x7f5f('0x39')][_0x7f5f('0xa9')][_0x127370]['basename'])};}}var _0x210bdf={'tls':{'rejectUnauthorized':![]}};if(_[_0x7f5f('0x71')](_0x5d123b[_0x7f5f('0x58')][_0x7f5f('0x7c')])){if(_0x5d123b[_0x7f5f('0x58')]['authentication']){_0x210bdf[_0x7f5f('0xad')]={'user':_0x5d123b[_0x7f5f('0x58')][_0x7f5f('0x74')],'pass':_0x5d123b[_0x7f5f('0x58')]['pass']};}_0x210bdf['host']=_0x5d123b['Smtp'][_0x7f5f('0x7a')];_0x210bdf[_0x7f5f('0x7b')]=_0x5d123b[_0x7f5f('0x58')][_0x7f5f('0x7b')];_0x210bdf[_0x7f5f('0xae')]=_0x5d123b[_0x7f5f('0x58')]['secure'];}else{_0x210bdf[_0x7f5f('0x7c')]=_0x5d123b[_0x7f5f('0x58')][_0x7f5f('0x7c')];_0x210bdf['auth']={'user':_0x5d123b[_0x7f5f('0x58')][_0x7f5f('0x74')],'pass':_0x5d123b[_0x7f5f('0x58')][_0x7f5f('0x77')]};}return respondWithRpcPromise('SendMail','sendMail',{'account':_0x210bdf,'message':_0x2e1d67[_0x7f5f('0x39')]});}else{throw new Error(_0x7f5f('0xaf'));}}})['then'](function(_0xf59a44){if(_0xf59a44){_0x1717e2=_0xf59a44;if(_0x5b0549[_0x7f5f('0xa3')]){if(_0x5b0549[_0x7f5f('0xa3')][_0x7f5f('0xa4')]['length']){return _0x5b0549['List']['Contacts'][0x0];}else{return db['CmContact']['create'](_['defaults'](_0x2e1d67['body'],{'firstName':_0x2e1d67['body']['to'],'email':_0x2e1d67['body']['to'],'phone':_0x2e1d67[_0x7f5f('0x39')]['to'],'ListId':_0x5b0549[_0x7f5f('0x6e')]}));}}else{throw new Error('List\x20not\x20found');}}})[_0x7f5f('0x1d')](function(_0x2d597f){if(_0x2d597f){var _0x4a65d6={'UserId':_0x2e1d67['user']['id'],'ContactId':_0x2d597f['id'],'MailAccountId':_0x5b0549['id'],'inReplyTo':_0x1717e2[_0x7f5f('0xb0')],'to':_0x2e1d67[_0x7f5f('0x39')][_0x7f5f('0xa7')],'cc':_0x2e1d67[_0x7f5f('0x39')]['cc'],'subject':_0x2e1d67[_0x7f5f('0x39')][_0x7f5f('0xb1')],'attach':_0x2e1d67['body'][_0x7f5f('0xb2')],'firstMsgDirection':'out','lastMsgAt':moment()[_0x7f5f('0x9d')](_0x7f5f('0x9e')),'lastMsgDirection':_0x7f5f('0xb3'),'Messages':[_[_0x7f5f('0x38')](_0x2e1d67[_0x7f5f('0x39')],{'messageId':_0x1717e2['messageId'],'sentAt':moment()[_0x7f5f('0x9d')]('YYYY-MM-DD\x20HH:mm:ss'),'read':!![],'MailAccountId':_0x5b0549['id'],'UserId':_0x2e1d67[_0x7f5f('0x74')]['id'],'ContactId':_0x2d597f['id']})]};if(_0x2e1d67['body']['Interaction']){_0x4a65d6=_[_0x7f5f('0x38')](_0x4a65d6,_0x2e1d67['body'][_0x7f5f('0xb4')]);}return db[_0x7f5f('0x8a')][_0x7f5f('0x64')](_0x4a65d6,{'include':[{'model':db[_0x7f5f('0x9f')],'as':_0x7f5f('0xb5')}]});}})['then'](respondWithResult(_0x319216,null))[_0x7f5f('0x25')](handleError(_0x319216,null));};exports[_0x7f5f('0xb6')]=function(_0x5b2eda,_0x2c7c52,_0x484b5c){return db['MailAccount'][_0x7f5f('0x5d')]({'where':{'id':_0x5b2eda[_0x7f5f('0x5e')]['id']},'include':[{'model':db[_0x7f5f('0x3e')],'as':'Smtp','raw':!![]}]})[_0x7f5f('0x1d')](handleEntityNotFound(_0x2c7c52,null))[_0x7f5f('0x1d')](function(_0x1d9157){if(_0x1d9157&&_0x1d9157[_0x7f5f('0x58')]){var _0x3eac7f={'id':_0x1d9157['id'],'tls':{'rejectUnauthorized':![]}};if(_0x1d9157['Smtp']['service']){_0x3eac7f[_0x7f5f('0x7c')]=_0x1d9157[_0x7f5f('0x58')][_0x7f5f('0x7c')];}else{_0x3eac7f[_0x7f5f('0x7a')]=_0x1d9157[_0x7f5f('0x58')]['host'];_0x3eac7f['port']=_0x1d9157[_0x7f5f('0x58')][_0x7f5f('0x7b')];_0x3eac7f[_0x7f5f('0xae')]=_0x1d9157[_0x7f5f('0x58')][_0x7f5f('0xae')];}if(_0x1d9157[_0x7f5f('0x58')][_0x7f5f('0x79')]){_0x3eac7f[_0x7f5f('0xad')]={'user':_0x1d9157[_0x7f5f('0x58')][_0x7f5f('0x74')],'pass':_0x1d9157[_0x7f5f('0x58')][_0x7f5f('0x77')]};}return respondWithRpcPromise(_0x7f5f('0xb7'),_0x7f5f('0xb6'),{'account':_0x3eac7f});}})['then'](respondWithResult(_0x2c7c52,null))[_0x7f5f('0x25')](handleError(_0x2c7c52,null));};exports[_0x7f5f('0x30')]=function(_0x52f140,_0x43646a){return db[_0x7f5f('0x52')][_0x7f5f('0x5d')]({'where':{'id':_0x52f140[_0x7f5f('0x5e')]['id']}})[_0x7f5f('0x1d')](handleEntityNotFound(_0x43646a,null))[_0x7f5f('0x1d')](function(_0x26e0f8){if(_0x26e0f8&&_0x26e0f8['service']){throw new db[(_0x7f5f('0xb8'))][(_0x7f5f('0xb9'))](_0x7f5f('0xba'));}return _0x26e0f8;})[_0x7f5f('0x1d')](removeEntity(_0x43646a,null))['catch'](handleError(_0x43646a,null));};exports['addAgents']=function(_0x36466,_0x192aaf,_0x772d03){return db[_0x7f5f('0x52')][_0x7f5f('0x5d')]({'where':{'id':_0x36466[_0x7f5f('0x5e')]['id']}})[_0x7f5f('0x1d')](handleEntityNotFound(_0x192aaf,null))[_0x7f5f('0x1d')](function(_0x27a022){if(_0x27a022){return _0x27a022[_0x7f5f('0xbb')](_0x36466[_0x7f5f('0x39')][_0x7f5f('0x68')],_[_0x7f5f('0xbc')](_0x36466['body'],[_0x7f5f('0x68'),'id'])||{})[_0x7f5f('0xbd')](function(_0x510adc){for(var _0x4dcf89=0x0;_0x4dcf89<_0x36466['body'][_0x7f5f('0x68')]['length'];_0x4dcf89+=0x1){socket[_0x7f5f('0xbe')]('userMailAccount:save',{'UserId':_0x36466[_0x7f5f('0x39')][_0x7f5f('0x68')][_0x4dcf89],'MailAccountId':_0x36466['params']['id']});}return _0x510adc;});}})[_0x7f5f('0x1d')](respondWithResult(_0x192aaf,null))[_0x7f5f('0x25')](handleError(_0x192aaf,null));};exports[_0x7f5f('0xbf')]=function(_0x3317a2,_0x54d728,_0xd2b94c){return db[_0x7f5f('0x52')][_0x7f5f('0x5d')]({'where':{'id':_0x3317a2[_0x7f5f('0x5e')]['id']}})[_0x7f5f('0x1d')](handleEntityNotFound(_0x54d728,null))[_0x7f5f('0x1d')](function(_0xc2c175){if(_0xc2c175){return _0xc2c175[_0x7f5f('0xbf')](_0x3317a2[_0x7f5f('0x45')][_0x7f5f('0x68')])['then'](function(){if(_[_0x7f5f('0xc0')](_0x3317a2[_0x7f5f('0x45')][_0x7f5f('0x68')])){for(var _0x3d655f=0x0;_0x3d655f<_0x3317a2[_0x7f5f('0x45')][_0x7f5f('0x68')][_0x7f5f('0x4a')];_0x3d655f+=0x1){socket[_0x7f5f('0xbe')](_0x7f5f('0xc1'),{'UserId':Number(_0x3317a2[_0x7f5f('0x45')][_0x7f5f('0x68')][_0x3d655f]),'MailAccountId':Number(_0x3317a2[_0x7f5f('0x5e')]['id'])});}}else{socket[_0x7f5f('0xbe')](_0x7f5f('0xc1'),{'UserId':Number(_0x3317a2['query'][_0x7f5f('0x68')]),'MailAccountId':Number(_0x3317a2[_0x7f5f('0x5e')]['id'])});}});}})[_0x7f5f('0x1d')](respondWithStatusCode(_0x54d728,null))[_0x7f5f('0x25')](handleError(_0x54d728,null));};exports[_0x7f5f('0xc2')]=function(_0x5bef39,_0x480c92,_0xd4854a){var _0x5233a3={};var _0x4346ba={};var _0xbaf667;var _0x5404c1;return db[_0x7f5f('0x52')][_0x7f5f('0x66')]({'where':{'id':_0x5bef39[_0x7f5f('0x5e')]['id']}})[_0x7f5f('0x1d')](handleEntityNotFound(_0x480c92,null))[_0x7f5f('0x1d')](function(_0x4cf947){if(_0x4cf947){_0xbaf667=_0x4cf947;_0x4346ba['model']=_[_0x7f5f('0x59')](db[_0x7f5f('0xc3')][_0x7f5f('0x42')]);_0x4346ba[_0x7f5f('0x45')]=_[_0x7f5f('0x59')](_0x5bef39['query']);_0x4346ba[_0x7f5f('0x46')]=_[_0x7f5f('0x47')](_0x4346ba[_0x7f5f('0x44')],_0x4346ba[_0x7f5f('0x45')]);_0x5233a3[_0x7f5f('0x49')]=_[_0x7f5f('0x47')](_0x4346ba['model'],qs[_0x7f5f('0x48')](_0x5bef39[_0x7f5f('0x45')][_0x7f5f('0x48')]));_0x5233a3[_0x7f5f('0x49')]=_0x5233a3[_0x7f5f('0x49')][_0x7f5f('0x4a')]?_0x5233a3['attributes']:_0x4346ba[_0x7f5f('0x44')];_0x5233a3[_0x7f5f('0x4d')]=qs[_0x7f5f('0x4e')](_0x5bef39[_0x7f5f('0x45')][_0x7f5f('0x4e')]);_0x5233a3['where']=qs[_0x7f5f('0x46')](_[_0x7f5f('0x4f')](_0x5bef39[_0x7f5f('0x45')],_0x4346ba[_0x7f5f('0x46')]));if(_0x5bef39['query']['filter']){_0x5233a3[_0x7f5f('0x51')]=_['merge'](_0x5233a3['where'],{'$or':_[_0x7f5f('0x41')](_0x5233a3[_0x7f5f('0x49')],function(_0x55d9ba){var _0x528a8e={};_0x528a8e[_0x55d9ba]={'$like':'%'+_0x5bef39['query'][_0x7f5f('0x50')]+'%'};return _0x528a8e;})});}_0x5233a3=_[_0x7f5f('0x38')]({},_0x5233a3,_0x5bef39[_0x7f5f('0x5b')]);return _0xbaf667[_0x7f5f('0xc2')](_0x5233a3);}})[_0x7f5f('0x1d')](function(_0x537ba2){if(_0x537ba2){_0x5404c1=_0x537ba2[_0x7f5f('0x4a')];if(!_0x5bef39[_0x7f5f('0x45')]['hasOwnProperty']('nolimit')){_0x5233a3[_0x7f5f('0x2b')]=qs[_0x7f5f('0x2b')](_0x5bef39[_0x7f5f('0x45')][_0x7f5f('0x2b')]);_0x5233a3[_0x7f5f('0x29')]=qs[_0x7f5f('0x29')](_0x5bef39['query'][_0x7f5f('0x29')]);}return _0xbaf667[_0x7f5f('0xc2')](_0x5233a3);}})['then'](function(_0x5f58da){if(_0x5f58da){return _0x5f58da?{'count':_0x5404c1,'rows':_0x5f58da}:null;}})[_0x7f5f('0x1d')](respondWithResult(_0x480c92,null))['catch'](handleError(_0x480c92,null));};
\ No newline at end of file