Built motion from commit b0a9a629.|2.6.33
[motion2.git] / server / api / cmList / cmList.controller.js
index 2265607..66c9639 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xf4b2=['ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/utils','../../mysqldb','redis','defaults','socket.io-emitter','./cmList.socket','sendStatus','end','status','json','count','offset','limit','Content-Range','apply','reject','update','then','destroy','get','Lists','UserProfileResource','error','stack','name','send','map','rawAttributes','type','key','model','query','filters','intersection','attributes','fields','hasOwnProperty','nolimit','sort','pick','filter','where','merge','includeAll','CmList','findAll','rows','show','params','keys','length','include','find','catch','Unable\x20to\x20retrieve\x20the\x20current\x20user','user','UserProfileSection','create','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','body','describe','addDisposition','ListId','getDispositions','findOne','Disposition','removeDispositions','ids','addContacts','CmContact','isArray','tags','push','each','success','errors','message','Malformed\x20request\x20syntax','getContacts','CmCustomField','CustomFields','concat','format','cf_%d','raw','order','isEmpty','now','writeFileSync','setHeader','Content-disposition','attachment;\x20filename=','Content-type','text/csv','addCustomField','sequelize','addCustomFields','TEXT','number','Sequelize','switch','BOOLEAN','defaultValue','addColumn','cm_contacts','cf_%s','getCustomFields','options','addAgents','spread','emit','userCmList:save','removeAgents','userCmList:remove','User','getAgents','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','util','path','to-csv','ejs','lodash','crypto','jsforce','desk.js','querystring','papaparse'];(function(_0x1859bf,_0x17bb6f){var _0x11843d=function(_0x1bf020){while(--_0x1bf020){_0x1859bf['push'](_0x1859bf['shift']());}};_0x11843d(++_0x17bb6f);}(_0xf4b2,0x105));var _0x2f4b=function(_0x184350,_0x2112a){_0x184350=_0x184350-0x0;var _0x3d4b27=_0xf4b2[_0x184350];return _0x3d4b27;};'use strict';var pdf=require(_0x2f4b('0x0'));var emlformat=require(_0x2f4b('0x1'));var rimraf=require(_0x2f4b('0x2'));var zipdir=require(_0x2f4b('0x3'));var jsonpatch=require(_0x2f4b('0x4'));var rp=require(_0x2f4b('0x5'));var moment=require(_0x2f4b('0x6'));var BPromise=require('bluebird');var Mustache=require('mustache');var util=require(_0x2f4b('0x7'));var path=require(_0x2f4b('0x8'));var sox=require('sox');var csv=require(_0x2f4b('0x9'));var ejs=require(_0x2f4b('0xa'));var fs=require('fs');var _=require(_0x2f4b('0xb'));var squel=require('squel');var crypto=require(_0x2f4b('0xc'));var jsforce=require(_0x2f4b('0xd'));var deskjs=require(_0x2f4b('0xe'));var toCsv=require(_0x2f4b('0x9'));var querystring=require(_0x2f4b('0xf'));var Papa=require(_0x2f4b('0x10'));var Redis=require(_0x2f4b('0x11'));var authService=require(_0x2f4b('0x12'));var qs=require(_0x2f4b('0x13'));var as=require(_0x2f4b('0x14'));var hardwareService=require(_0x2f4b('0x15'));var logger=require('../../config/logger')(_0x2f4b('0x16'));var utils=require(_0x2f4b('0x17'));var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require(_0x2f4b('0x18'))['db'];config[_0x2f4b('0x19')]=_[_0x2f4b('0x1a')](config[_0x2f4b('0x19')],{'host':'localhost','port':0x18eb});var socket=require(_0x2f4b('0x1b'))(new Redis(config[_0x2f4b('0x19')]));require(_0x2f4b('0x1c'))['register'](socket);function respondWithStatusCode(_0x3118a7,_0x300501){_0x300501=_0x300501||0xcc;return function(_0x249423){if(_0x249423){return _0x3118a7[_0x2f4b('0x1d')](_0x300501);}return _0x3118a7['status'](_0x300501)[_0x2f4b('0x1e')]();};}function respondWithResult(_0x23443c,_0x2847b1){_0x2847b1=_0x2847b1||0xc8;return function(_0xf19e23){if(_0xf19e23){return _0x23443c[_0x2f4b('0x1f')](_0x2847b1)[_0x2f4b('0x20')](_0xf19e23);}};}function respondWithFilteredResult(_0x4c458c,_0xf49a56){return function(_0x287a13){if(_0x287a13){var _0x244850=_0x287a13[_0x2f4b('0x21')],_0x168d1f=_0xf49a56[_0x2f4b('0x22')],_0x32f977=_0xf49a56[_0x2f4b('0x22')]+_0xf49a56[_0x2f4b('0x23')],_0x55abf8;if(_0x32f977>=_0x244850){_0x32f977=_0x244850;_0x55abf8=0xc8;}else{_0x55abf8=0xce;}_0x4c458c['status'](_0x55abf8);return _0x4c458c['set'](_0x2f4b('0x24'),_0x168d1f+'-'+_0x32f977+'/'+_0x244850)[_0x2f4b('0x20')](_0x287a13);}return null;};}function patchUpdates(_0x1e1caf){return function(_0x26cc3a){try{jsonpatch[_0x2f4b('0x25')](_0x26cc3a,_0x1e1caf,!![]);}catch(_0x590208){return BPromise[_0x2f4b('0x26')](_0x590208);}return _0x26cc3a['save']();};}function saveUpdates(_0x49528b,_0x405777){return function(_0x50526a){if(_0x50526a){return _0x50526a[_0x2f4b('0x27')](_0x49528b)[_0x2f4b('0x28')](function(_0x4708f5){return _0x4708f5;});}return null;};}function removeEntity(_0x22e3b4,_0x4f9a0b){return function(_0x486e33){if(_0x486e33){return _0x486e33[_0x2f4b('0x29')]()[_0x2f4b('0x28')](function(){var _0x3145fd=_0x486e33[_0x2f4b('0x2a')]({'plain':!![]});var _0x53f01f=_0x2f4b('0x2b');return db[_0x2f4b('0x2c')][_0x2f4b('0x29')]({'where':{'type':_0x53f01f,'resourceId':_0x3145fd['id']}})[_0x2f4b('0x28')](function(){return _0x486e33;});})[_0x2f4b('0x28')](function(){_0x22e3b4[_0x2f4b('0x1f')](0xcc)[_0x2f4b('0x1e')]();});}};}function handleEntityNotFound(_0x5390c8,_0xfa6722){return function(_0x196e8b){if(!_0x196e8b){_0x5390c8['sendStatus'](0x194);}return _0x196e8b;};}function handleError(_0x1e22dd,_0x2a00d9){_0x2a00d9=_0x2a00d9||0x1f4;return function(_0x187623){logger[_0x2f4b('0x2d')](_0x187623[_0x2f4b('0x2e')]);if(_0x187623['name']){delete _0x187623[_0x2f4b('0x2f')];}_0x1e22dd[_0x2f4b('0x1f')](_0x2a00d9)[_0x2f4b('0x30')](_0x187623);};}exports['index']=function(_0x35aa68,_0x14bb73){var _0x539c48={},_0x357378={},_0x397c78={'count':0x0,'rows':[]};var _0x3324fa=_[_0x2f4b('0x31')](db['CmList'][_0x2f4b('0x32')],function(_0x1919f2){return{'name':_0x1919f2['fieldName'],'type':_0x1919f2[_0x2f4b('0x33')][_0x2f4b('0x34')]};});_0x357378[_0x2f4b('0x35')]=_[_0x2f4b('0x31')](_0x3324fa,_0x2f4b('0x2f'));_0x357378[_0x2f4b('0x36')]=_['keys'](_0x35aa68[_0x2f4b('0x36')]);_0x357378[_0x2f4b('0x37')]=_[_0x2f4b('0x38')](_0x357378[_0x2f4b('0x35')],_0x357378['query']);_0x539c48[_0x2f4b('0x39')]=_[_0x2f4b('0x38')](_0x357378['model'],qs[_0x2f4b('0x3a')](_0x35aa68[_0x2f4b('0x36')]['fields']));_0x539c48[_0x2f4b('0x39')]=_0x539c48[_0x2f4b('0x39')]['length']?_0x539c48[_0x2f4b('0x39')]:_0x357378[_0x2f4b('0x35')];if(!_0x35aa68[_0x2f4b('0x36')][_0x2f4b('0x3b')](_0x2f4b('0x3c'))){_0x539c48[_0x2f4b('0x23')]=qs[_0x2f4b('0x23')](_0x35aa68[_0x2f4b('0x36')][_0x2f4b('0x23')]);_0x539c48['offset']=qs['offset'](_0x35aa68[_0x2f4b('0x36')][_0x2f4b('0x22')]);}_0x539c48['order']=qs['sort'](_0x35aa68[_0x2f4b('0x36')][_0x2f4b('0x3d')]);_0x539c48['where']=qs[_0x2f4b('0x37')](_[_0x2f4b('0x3e')](_0x35aa68['query'],_0x357378[_0x2f4b('0x37')]),_0x3324fa);if(_0x35aa68['query'][_0x2f4b('0x3f')]){_0x539c48[_0x2f4b('0x40')]=_[_0x2f4b('0x41')](_0x539c48[_0x2f4b('0x40')],{'$or':_[_0x2f4b('0x31')](_0x3324fa,function(_0x30a678){if(_0x30a678[_0x2f4b('0x33')]!=='VIRTUAL'){var _0xfc1c57={};_0xfc1c57[_0x30a678[_0x2f4b('0x2f')]]={'$like':'%'+_0x35aa68[_0x2f4b('0x36')][_0x2f4b('0x3f')]+'%'};return _0xfc1c57;}})});}_0x539c48=_[_0x2f4b('0x41')]({},_0x539c48,_0x35aa68['options']);var _0xa1fb56={'where':_0x539c48[_0x2f4b('0x40')]};return db['CmList']['count'](_0xa1fb56)[_0x2f4b('0x28')](function(_0x1b06fb){_0x397c78[_0x2f4b('0x21')]=_0x1b06fb;if(_0x35aa68[_0x2f4b('0x36')][_0x2f4b('0x42')]){_0x539c48['include']=[{'all':!![]}];}return db[_0x2f4b('0x43')][_0x2f4b('0x44')](_0x539c48);})[_0x2f4b('0x28')](function(_0x1d418f){_0x397c78[_0x2f4b('0x45')]=_0x1d418f;return _0x397c78;})[_0x2f4b('0x28')](respondWithFilteredResult(_0x14bb73,_0x539c48))['catch'](handleError(_0x14bb73,null));};exports[_0x2f4b('0x46')]=function(_0x1726b5,_0x2b5e3e){var _0x4ec2d4={'raw':![],'where':{'id':_0x1726b5[_0x2f4b('0x47')]['id']}},_0xf98ae={};_0xf98ae[_0x2f4b('0x35')]=_['keys'](db[_0x2f4b('0x43')][_0x2f4b('0x32')]);_0xf98ae['query']=_[_0x2f4b('0x48')](_0x1726b5[_0x2f4b('0x36')]);_0xf98ae['filters']=_[_0x2f4b('0x38')](_0xf98ae[_0x2f4b('0x35')],_0xf98ae[_0x2f4b('0x36')]);_0x4ec2d4['attributes']=_[_0x2f4b('0x38')](_0xf98ae[_0x2f4b('0x35')],qs[_0x2f4b('0x3a')](_0x1726b5[_0x2f4b('0x36')][_0x2f4b('0x3a')]));_0x4ec2d4[_0x2f4b('0x39')]=_0x4ec2d4['attributes'][_0x2f4b('0x49')]?_0x4ec2d4[_0x2f4b('0x39')]:_0xf98ae[_0x2f4b('0x35')];if(_0x1726b5[_0x2f4b('0x36')][_0x2f4b('0x42')]){_0x4ec2d4[_0x2f4b('0x4a')]=[{'all':!![]}];}_0x4ec2d4=_[_0x2f4b('0x41')]({},_0x4ec2d4,_0x1726b5['options']);return db['CmList'][_0x2f4b('0x4b')](_0x4ec2d4)[_0x2f4b('0x28')](handleEntityNotFound(_0x2b5e3e,null))[_0x2f4b('0x28')](respondWithResult(_0x2b5e3e,null))[_0x2f4b('0x4c')](handleError(_0x2b5e3e,null));};exports['create']=function(_0x357303,_0x539fe3){return db[_0x2f4b('0x43')]['create'](_0x357303['body'],{})[_0x2f4b('0x28')](function(_0x1e3f84){var _0x2fdf10=_0x357303['user']['get']({'plain':!![]});if(!_0x2fdf10)throw new Error(_0x2f4b('0x4d'));if(_0x2fdf10['role']===_0x2f4b('0x4e')){var _0x5b9702=_0x1e3f84[_0x2f4b('0x2a')]({'plain':!![]});var _0x2a0a77=_0x2f4b('0x2b');return db[_0x2f4b('0x4f')][_0x2f4b('0x4b')]({'where':{'name':_0x2a0a77,'userProfileId':_0x2fdf10['userProfileId']},'raw':!![]})[_0x2f4b('0x28')](function(_0x3bfdc3){if(_0x3bfdc3&&_0x3bfdc3['autoAssociation']===0x0){return db['UserProfileResource'][_0x2f4b('0x50')]({'name':_0x5b9702[_0x2f4b('0x2f')],'resourceId':_0x5b9702['id'],'type':_0x3bfdc3[_0x2f4b('0x2f')],'sectionId':_0x3bfdc3['id']},{})['then'](function(){return _0x1e3f84;});}else{return _0x1e3f84;}})['catch'](function(_0x3d4b5c){logger[_0x2f4b('0x2d')](_0x2f4b('0x51'),_0x3d4b5c);throw _0x3d4b5c;});}return _0x1e3f84;})[_0x2f4b('0x28')](respondWithResult(_0x539fe3,0xc9))['catch'](handleError(_0x539fe3,null));};exports[_0x2f4b('0x27')]=function(_0x53015d,_0x5cb4ae){if(_0x53015d[_0x2f4b('0x52')]['id']){delete _0x53015d[_0x2f4b('0x52')]['id'];}return db[_0x2f4b('0x43')][_0x2f4b('0x4b')]({'where':{'id':_0x53015d[_0x2f4b('0x47')]['id']}})[_0x2f4b('0x28')](handleEntityNotFound(_0x5cb4ae,null))[_0x2f4b('0x28')](saveUpdates(_0x53015d[_0x2f4b('0x52')],null))[_0x2f4b('0x28')](respondWithResult(_0x5cb4ae,null))[_0x2f4b('0x4c')](handleError(_0x5cb4ae,null));};exports[_0x2f4b('0x29')]=function(_0x2f894d,_0x41290f){return db[_0x2f4b('0x43')][_0x2f4b('0x4b')]({'where':{'id':_0x2f894d[_0x2f4b('0x47')]['id']}})['then'](handleEntityNotFound(_0x41290f,null))[_0x2f4b('0x28')](removeEntity(_0x41290f,null))[_0x2f4b('0x4c')](handleError(_0x41290f,null));};exports[_0x2f4b('0x53')]=function(_0x42062f,_0x230dda){return db[_0x2f4b('0x43')][_0x2f4b('0x53')]()[_0x2f4b('0x28')](respondWithResult(_0x230dda,null))[_0x2f4b('0x4c')](handleError(_0x230dda,null));};exports[_0x2f4b('0x54')]=function(_0x41a827,_0x1d16c3,_0x1abe45){if(_0x41a827['body']['id']){delete _0x41a827[_0x2f4b('0x52')]['id'];}return db[_0x2f4b('0x43')][_0x2f4b('0x4b')]({'where':{'id':_0x41a827[_0x2f4b('0x47')]['id']}})['then'](handleEntityNotFound(_0x1d16c3,null))[_0x2f4b('0x28')](function(_0x1c8332){if(_0x1c8332){_0x41a827[_0x2f4b('0x52')][_0x2f4b('0x55')]=_0x1c8332['id'];return db['Disposition'][_0x2f4b('0x50')](_0x41a827[_0x2f4b('0x52')]);}})[_0x2f4b('0x28')](respondWithResult(_0x1d16c3,null))[_0x2f4b('0x4c')](handleError(_0x1d16c3,null));};exports[_0x2f4b('0x56')]=function(_0x15d2a7,_0x412d99,_0x3fbe20){var _0x341fc5={'raw':![],'where':{}};var _0x3e29b5={};var _0x2c5d35={'count':0x0,'rows':[]};return db[_0x2f4b('0x43')][_0x2f4b('0x57')]({'where':{'id':_0x15d2a7[_0x2f4b('0x47')]['id']}})[_0x2f4b('0x28')](handleEntityNotFound(_0x412d99,null))[_0x2f4b('0x28')](function(_0x58ec95){if(_0x58ec95){_0x3e29b5[_0x2f4b('0x35')]=_[_0x2f4b('0x48')](db[_0x2f4b('0x58')][_0x2f4b('0x32')]);_0x3e29b5['query']=_[_0x2f4b('0x48')](_0x15d2a7[_0x2f4b('0x36')]);_0x3e29b5[_0x2f4b('0x37')]=_[_0x2f4b('0x38')](_0x3e29b5[_0x2f4b('0x35')],_0x3e29b5['query']);_0x341fc5[_0x2f4b('0x39')]=_[_0x2f4b('0x38')](_0x3e29b5[_0x2f4b('0x35')],qs[_0x2f4b('0x3a')](_0x15d2a7[_0x2f4b('0x36')][_0x2f4b('0x3a')]));_0x341fc5[_0x2f4b('0x39')]=_0x341fc5[_0x2f4b('0x39')]['length']?_0x341fc5['attributes']:_0x3e29b5['model'];if(!_0x15d2a7[_0x2f4b('0x36')]['hasOwnProperty']('nolimit')){_0x341fc5[_0x2f4b('0x23')]=qs[_0x2f4b('0x23')](_0x15d2a7[_0x2f4b('0x36')][_0x2f4b('0x23')]);_0x341fc5['offset']=qs['offset'](_0x15d2a7[_0x2f4b('0x36')][_0x2f4b('0x22')]);}_0x341fc5['order']=qs[_0x2f4b('0x3d')](_0x15d2a7[_0x2f4b('0x36')][_0x2f4b('0x3d')]);_0x341fc5[_0x2f4b('0x40')]=qs[_0x2f4b('0x37')](_[_0x2f4b('0x3e')](_0x15d2a7[_0x2f4b('0x36')],_0x3e29b5[_0x2f4b('0x37')]));_0x341fc5[_0x2f4b('0x40')][_0x2f4b('0x55')]=_0x58ec95['id'];if(_0x15d2a7[_0x2f4b('0x36')][_0x2f4b('0x3f')]){_0x341fc5['where']=_[_0x2f4b('0x41')](_0x341fc5[_0x2f4b('0x40')],{'$or':_[_0x2f4b('0x31')](_0x341fc5['attributes'],function(_0x27135d){var _0x63e4dd={};_0x63e4dd[_0x27135d]={'$like':'%'+_0x15d2a7[_0x2f4b('0x36')][_0x2f4b('0x3f')]+'%'};return _0x63e4dd;})});}_0x341fc5=_[_0x2f4b('0x41')]({},_0x341fc5,_0x15d2a7['options']);return db[_0x2f4b('0x58')][_0x2f4b('0x21')]({'where':_0x341fc5[_0x2f4b('0x40')]})[_0x2f4b('0x28')](function(_0x1bf2e9){_0x2c5d35[_0x2f4b('0x21')]=_0x1bf2e9;if(_0x15d2a7[_0x2f4b('0x36')][_0x2f4b('0x42')]){_0x341fc5[_0x2f4b('0x4a')]=[{'all':!![]}];}return db[_0x2f4b('0x58')][_0x2f4b('0x44')](_0x341fc5);})[_0x2f4b('0x28')](function(_0x589dfb){_0x2c5d35[_0x2f4b('0x45')]=_0x589dfb;return _0x2c5d35;});}})[_0x2f4b('0x28')](respondWithFilteredResult(_0x412d99,_0x341fc5))[_0x2f4b('0x4c')](handleError(_0x412d99,null));};exports['removeDispositions']=function(_0x4591aa,_0x26a7f8,_0x19b171){return db['CmList']['find']({'where':{'id':_0x4591aa[_0x2f4b('0x47')]['id']}})['then'](handleEntityNotFound(_0x26a7f8,null))[_0x2f4b('0x28')](function(_0x4c560f){if(_0x4c560f){return _0x4c560f[_0x2f4b('0x59')](_0x4591aa[_0x2f4b('0x36')][_0x2f4b('0x5a')]);}})[_0x2f4b('0x28')](respondWithStatusCode(_0x26a7f8,null))[_0x2f4b('0x4c')](handleError(_0x26a7f8,null));};exports[_0x2f4b('0x5b')]=function(_0x2f27ae,_0x50c6b7,_0xf5f74b){return db['CmList']['find']({'where':{'id':_0x2f27ae[_0x2f4b('0x47')]['id']}})[_0x2f4b('0x28')](handleEntityNotFound(_0x50c6b7,null))['then'](function(_0xa3fa7){if(_0xa3fa7){var _0x1ed647=[];var _0x5e0345={'success':[],'errors':[]};return db[_0x2f4b('0x5c')][_0x2f4b('0x53')]()[_0x2f4b('0x28')](function(_0x16ce34){if(_0x2f27ae[_0x2f4b('0x52')]['tags']&&_[_0x2f4b('0x5d')](_0x2f27ae[_0x2f4b('0x52')][_0x2f4b('0x5e')])){if(_0x2f27ae['body'][_0x2f4b('0x5e')][_0x2f4b('0x49')]){_0x2f27ae['body']['tags']=_0x2f27ae['body']['tags']['join'](';')+';';}else{_0x2f27ae[_0x2f4b('0x52')][_0x2f4b('0x5e')]=null;}}else{_0x2f27ae[_0x2f4b('0x52')][_0x2f4b('0x5e')]=null;}if(_0x2f27ae[_0x2f4b('0x52')]&&_[_0x2f4b('0x5d')](_0x2f27ae[_0x2f4b('0x52')])){for(var _0x570cb9=0x0;_0x570cb9<_0x2f27ae['body']['length'];_0x570cb9+=0x1){_0x2f27ae['body'][_0x570cb9]['ListId']=_0x2f27ae[_0x2f4b('0x47')]['id'];_0x1ed647[_0x2f4b('0x5f')](_0x2f27ae[_0x2f4b('0x52')][_0x570cb9]);}return BPromise[_0x2f4b('0x60')](_0x1ed647,function(_0x4233ca){return db['CmContact'][_0x2f4b('0x50')](_['omit'](_0x4233ca,['ids','id'])||{},{'fields':_[_0x2f4b('0x48')](_0x16ce34),'raw':!![]})[_0x2f4b('0x28')](function(_0x148782){_0x5e0345[_0x2f4b('0x61')][_0x2f4b('0x5f')](_0x148782['dataValues']);})[_0x2f4b('0x4c')](function(_0x5bb20d){_0x5e0345[_0x2f4b('0x62')][_0x2f4b('0x5f')]({'data':_0x4233ca,'error':_0x5bb20d[_0x2f4b('0x63')]});});})[_0x2f4b('0x28')](function(_0x4b7799){return _0x5e0345;})[_0x2f4b('0x4c')](function(_0x39b43b){return _0x39b43b;});}else{_0x50c6b7[_0x2f4b('0x1f')](0x190)['json']({'message':_0x2f4b('0x64')});}});}})[_0x2f4b('0x28')](respondWithResult(_0x50c6b7,null))[_0x2f4b('0x4c')](handleError(_0x50c6b7,null));};exports[_0x2f4b('0x65')]=function(_0x117f2c,_0x533990,_0x36084b){var _0x40faa9;return db[_0x2f4b('0x43')][_0x2f4b('0x4b')]({'where':{'id':_0x117f2c['params']['id']},'include':[{'model':db[_0x2f4b('0x66')],'as':_0x2f4b('0x67')}]})['then'](handleEntityNotFound(_0x533990,null))['then'](function(_0x1f4a91){if(_0x1f4a91){_0x40faa9=_0x1f4a91;return db['CmContact'][_0x2f4b('0x32')];}})[_0x2f4b('0x28')](function(_0x1c4109){if(_0x1c4109){var _0x44d9b8={};var _0x5a40d0={};_0x5a40d0[_0x2f4b('0x35')]=_[_0x2f4b('0x68')](_['keys'](_0x1c4109),_[_0x2f4b('0x31')](_0x40faa9[_0x2f4b('0x67')],function(_0x251178){return util[_0x2f4b('0x69')](_0x2f4b('0x6a'),_0x251178['id']);}));_0x5a40d0[_0x2f4b('0x36')]=_['keys'](_0x117f2c[_0x2f4b('0x36')]);_0x5a40d0[_0x2f4b('0x37')]=_[_0x2f4b('0x38')](_0x5a40d0[_0x2f4b('0x35')],_0x5a40d0['query']);_0x44d9b8[_0x2f4b('0x39')]=_['intersection'](_0x5a40d0['model'],qs[_0x2f4b('0x3a')](_0x117f2c[_0x2f4b('0x36')][_0x2f4b('0x3a')]));_0x44d9b8[_0x2f4b('0x39')]=_0x44d9b8[_0x2f4b('0x39')][_0x2f4b('0x49')]?_0x44d9b8[_0x2f4b('0x39')]:_0x5a40d0[_0x2f4b('0x35')];if(!_0x117f2c[_0x2f4b('0x36')][_0x2f4b('0x3b')](_0x2f4b('0x3c'))){_0x44d9b8[_0x2f4b('0x23')]=qs[_0x2f4b('0x23')](_0x117f2c['query'][_0x2f4b('0x23')]);_0x44d9b8[_0x2f4b('0x22')]=qs[_0x2f4b('0x22')](_0x117f2c[_0x2f4b('0x36')]['offset']);}_0x44d9b8['order']=qs[_0x2f4b('0x3d')](_0x117f2c[_0x2f4b('0x36')][_0x2f4b('0x3d')]);_0x44d9b8[_0x2f4b('0x40')]=qs[_0x2f4b('0x37')](_[_0x2f4b('0x3e')](_0x117f2c[_0x2f4b('0x36')],_0x5a40d0[_0x2f4b('0x37')]));_0x44d9b8[_0x2f4b('0x6b')]=!![];if(_0x117f2c['query'][_0x2f4b('0x3f')]){_0x44d9b8['where']=_[_0x2f4b('0x41')](_0x44d9b8[_0x2f4b('0x40')],{'$or':_[_0x2f4b('0x31')](_0x44d9b8['attributes'],function(_0x16fadd){var _0x1dfe3c={};_0x1dfe3c[_0x16fadd]={'$like':'%'+_0x117f2c[_0x2f4b('0x36')][_0x2f4b('0x3f')]+'%'};return _0x1dfe3c;})});}_0x44d9b8=_[_0x2f4b('0x41')]({},_0x44d9b8,_0x117f2c['options']);return _0x40faa9[_0x2f4b('0x65')](_0x44d9b8);}})[_0x2f4b('0x28')](respondWithResult(_0x533990,null))[_0x2f4b('0x4c')](handleError(_0x533990,null));};exports['getContactsCsv']=function(_0x41a980,_0x33153f,_0x4981a6){var _0x2dcaf6;return db[_0x2f4b('0x43')][_0x2f4b('0x4b')]({'where':{'id':_0x41a980[_0x2f4b('0x47')]['id']},'include':[{'model':db[_0x2f4b('0x66')],'as':_0x2f4b('0x67')}]})[_0x2f4b('0x28')](handleEntityNotFound(_0x33153f,null))[_0x2f4b('0x28')](function(_0x148a6f){if(_0x148a6f){_0x2dcaf6=_0x148a6f;return db[_0x2f4b('0x5c')][_0x2f4b('0x32')];}})[_0x2f4b('0x28')](function(_0x5eaccc){if(_0x5eaccc){var _0xc53d04={};var _0xab51c3={};_0xab51c3[_0x2f4b('0x35')]=_['concat'](_[_0x2f4b('0x48')](_0x5eaccc),_[_0x2f4b('0x31')](_0x2dcaf6[_0x2f4b('0x67')],function(_0x39f421){return util[_0x2f4b('0x69')](_0x2f4b('0x6a'),_0x39f421['id']);}));_0xab51c3['query']=_['keys'](_0x41a980[_0x2f4b('0x36')]);_0xab51c3[_0x2f4b('0x37')]=_[_0x2f4b('0x38')](_0xab51c3[_0x2f4b('0x35')],_0xab51c3[_0x2f4b('0x36')]);_0xc53d04[_0x2f4b('0x39')]=_['intersection'](_0xab51c3[_0x2f4b('0x35')],qs[_0x2f4b('0x3a')](_0x41a980[_0x2f4b('0x36')]['fields']));_0xc53d04[_0x2f4b('0x39')]=_0xc53d04['attributes'][_0x2f4b('0x49')]?_0xc53d04[_0x2f4b('0x39')]:_0xab51c3[_0x2f4b('0x35')];if(!_0x41a980[_0x2f4b('0x36')][_0x2f4b('0x3b')](_0x2f4b('0x3c'))){_0xc53d04[_0x2f4b('0x23')]=qs[_0x2f4b('0x23')](_0x41a980[_0x2f4b('0x36')][_0x2f4b('0x23')]);_0xc53d04[_0x2f4b('0x22')]=qs[_0x2f4b('0x22')](_0x41a980[_0x2f4b('0x36')][_0x2f4b('0x22')]);}_0xc53d04[_0x2f4b('0x6c')]=qs[_0x2f4b('0x3d')](_0x41a980[_0x2f4b('0x36')]['sort']);_0xc53d04[_0x2f4b('0x40')]=qs[_0x2f4b('0x37')](_[_0x2f4b('0x3e')](_0x41a980[_0x2f4b('0x36')],_0xab51c3[_0x2f4b('0x37')]));_0xc53d04[_0x2f4b('0x6b')]=!![];if(_0x41a980[_0x2f4b('0x36')][_0x2f4b('0x3f')]){_0xc53d04[_0x2f4b('0x40')]=_['merge'](_0xc53d04[_0x2f4b('0x40')],{'$or':_[_0x2f4b('0x31')](_0xc53d04[_0x2f4b('0x39')],function(_0x3583ad){var _0x2afe45={};_0x2afe45[_0x3583ad]={'$like':'%'+_0x41a980['query'][_0x2f4b('0x3f')]+'%'};return _0x2afe45;})});}_0xc53d04=_['merge']({},_0xc53d04,_0x41a980['options']);return _0x2dcaf6[_0x2f4b('0x65')](_0xc53d04);}})[_0x2f4b('0x28')](function(_0x48fed5){if(!_[_0x2f4b('0x6d')](_0x48fed5)){var _0x5a4983=toCsv(_0x48fed5);var _0x4b44ef=Date[_0x2f4b('0x6e')]();fs[_0x2f4b('0x6f')](util[_0x2f4b('0x69')]('/tmp/list_%d_%s.csv',_0x2dcaf6['id'],_0x4b44ef),_0x5a4983);_0x33153f[_0x2f4b('0x70')](_0x2f4b('0x71'),_0x2f4b('0x72')+util[_0x2f4b('0x69')]('list_%d_%s.csv',_0x2dcaf6['id'],_0x4b44ef));_0x33153f[_0x2f4b('0x70')](_0x2f4b('0x73'),_0x2f4b('0x74'));return _0x33153f['download'](util[_0x2f4b('0x69')]('/tmp/list_%d_%s.csv',_0x2dcaf6['id'],_0x4b44ef));}else{return _0x33153f['sendStatus'](0xcc);}})[_0x2f4b('0x4c')](handleError(_0x33153f,null));};exports[_0x2f4b('0x75')]=function(_0x12b032,_0x33a3de,_0x41f522){var _0x1415d9;delete _0x12b032[_0x2f4b('0x52')]['id'];return db['CmList'][_0x2f4b('0x57')]({'where':{'id':_0x12b032['params']['id']}})['then'](handleEntityNotFound(_0x33a3de,null))['then'](function(_0x5aaa93){if(_0x5aaa93){return db[_0x2f4b('0x76')]['transaction'](function(_0x392a71){return db['CmCustomField'][_0x2f4b('0x50')](_0x12b032[_0x2f4b('0x52')],{'transaction':_0x392a71})[_0x2f4b('0x28')](function(_0x45fc12){_0x1415d9=_0x45fc12;return _0x5aaa93[_0x2f4b('0x77')](_0x45fc12,{'transaction':_0x392a71});})[_0x2f4b('0x28')](function(){var _0x19d6b3={'type':db['Sequelize'][_0x2f4b('0x78')],'transaction':_0x392a71};switch(_0x12b032[_0x2f4b('0x52')][_0x2f4b('0x33')]){case'text':_0x19d6b3[_0x2f4b('0x33')]=db['Sequelize'][_0x2f4b('0x78')];break;case _0x2f4b('0x79'):_0x19d6b3[_0x2f4b('0x33')]=db[_0x2f4b('0x7a')]['INTEGER'];break;case _0x2f4b('0x7b'):_0x19d6b3[_0x2f4b('0x33')]=db[_0x2f4b('0x7a')][_0x2f4b('0x7c')];_0x19d6b3[_0x2f4b('0x7d')]=![];break;default:}return db[_0x2f4b('0x76')]['queryInterface'][_0x2f4b('0x7e')](_0x2f4b('0x7f'),util[_0x2f4b('0x69')](_0x2f4b('0x80'),_0x1415d9['id']),_0x19d6b3);})[_0x2f4b('0x28')](function(){return _0x1415d9;});});}})[_0x2f4b('0x28')](respondWithResult(_0x33a3de,null))[_0x2f4b('0x4c')](handleError(_0x33a3de,null));};exports[_0x2f4b('0x81')]=function(_0x1472f6,_0x489dad,_0x5c1d44){var _0x5dfe55={};var _0x3cdae5={};var _0x3d07e6;var _0x360aeb;return db['CmList'][_0x2f4b('0x57')]({'where':{'id':_0x1472f6['params']['id']}})[_0x2f4b('0x28')](handleEntityNotFound(_0x489dad,null))[_0x2f4b('0x28')](function(_0x405b3b){if(_0x405b3b){_0x3d07e6=_0x405b3b;_0x3cdae5['model']=_[_0x2f4b('0x48')](db['CmCustomField'][_0x2f4b('0x32')]);_0x3cdae5[_0x2f4b('0x36')]=_[_0x2f4b('0x48')](_0x1472f6['query']);_0x3cdae5[_0x2f4b('0x37')]=_[_0x2f4b('0x38')](_0x3cdae5['model'],_0x3cdae5[_0x2f4b('0x36')]);_0x5dfe55[_0x2f4b('0x39')]=_[_0x2f4b('0x38')](_0x3cdae5[_0x2f4b('0x35')],qs[_0x2f4b('0x3a')](_0x1472f6[_0x2f4b('0x36')][_0x2f4b('0x3a')]));_0x5dfe55[_0x2f4b('0x39')]=_0x5dfe55[_0x2f4b('0x39')]['length']?_0x5dfe55[_0x2f4b('0x39')]:_0x3cdae5[_0x2f4b('0x35')];_0x5dfe55[_0x2f4b('0x6c')]=qs[_0x2f4b('0x3d')](_0x1472f6[_0x2f4b('0x36')][_0x2f4b('0x3d')]);_0x5dfe55[_0x2f4b('0x40')]=qs['filters'](_[_0x2f4b('0x3e')](_0x1472f6[_0x2f4b('0x36')],_0x3cdae5[_0x2f4b('0x37')]));_0x5dfe55[_0x2f4b('0x40')]=_[_0x2f4b('0x41')](_0x5dfe55[_0x2f4b('0x40')],{'$or':[{'ListId':_0x405b3b['id']},{'ListId':null}]});if(_0x1472f6[_0x2f4b('0x36')][_0x2f4b('0x3f')]){_0x5dfe55[_0x2f4b('0x40')]=_[_0x2f4b('0x41')](_0x5dfe55[_0x2f4b('0x40')],{'$or':_[_0x2f4b('0x31')](_0x5dfe55[_0x2f4b('0x39')],function(_0x5ba1fc){var _0x50b621={};_0x50b621[_0x5ba1fc]={'$like':'%'+_0x1472f6[_0x2f4b('0x36')][_0x2f4b('0x3f')]+'%'};return _0x50b621;})});}_0x5dfe55=_['merge']({},_0x5dfe55,_0x1472f6[_0x2f4b('0x82')]);return db[_0x2f4b('0x66')]['findAndCountAll'](_0x5dfe55);}})['then'](respondWithResult(_0x489dad,null))[_0x2f4b('0x4c')](handleError(_0x489dad,null));};exports[_0x2f4b('0x83')]=function(_0x244486,_0x5f3470,_0x29a40a){return db[_0x2f4b('0x43')][_0x2f4b('0x4b')]({'where':{'id':_0x244486[_0x2f4b('0x47')]['id']}})[_0x2f4b('0x28')](handleEntityNotFound(_0x5f3470,null))[_0x2f4b('0x28')](function(_0x2b852b){if(_0x2b852b){return _0x2b852b['addAgents'](_0x244486[_0x2f4b('0x52')][_0x2f4b('0x5a')],_['omit'](_0x244486[_0x2f4b('0x52')],[_0x2f4b('0x5a'),'id'])||{})[_0x2f4b('0x84')](function(_0x28fcb0){for(var _0xa13731=0x0;_0xa13731<_0x244486['body'][_0x2f4b('0x5a')]['length'];_0xa13731+=0x1){socket[_0x2f4b('0x85')](_0x2f4b('0x86'),{'UserId':_0x244486[_0x2f4b('0x52')][_0x2f4b('0x5a')][_0xa13731],'CmListId':_0x244486['params']['id']});}return _0x28fcb0;});}})['then'](respondWithResult(_0x5f3470,null))[_0x2f4b('0x4c')](handleError(_0x5f3470,null));};exports[_0x2f4b('0x87')]=function(_0x1b87b8,_0x585b9d,_0x5049c2){return db['CmList'][_0x2f4b('0x4b')]({'where':{'id':_0x1b87b8[_0x2f4b('0x47')]['id']}})[_0x2f4b('0x28')](handleEntityNotFound(_0x585b9d,null))['then'](function(_0x4c8137){if(_0x4c8137){return _0x4c8137['removeAgents'](_0x1b87b8[_0x2f4b('0x36')][_0x2f4b('0x5a')])['then'](function(){if(_[_0x2f4b('0x5d')](_0x1b87b8['query'][_0x2f4b('0x5a')])){for(var _0x40efc3=0x0;_0x40efc3<_0x1b87b8[_0x2f4b('0x36')]['ids'][_0x2f4b('0x49')];_0x40efc3+=0x1){socket[_0x2f4b('0x85')](_0x2f4b('0x88'),{'UserId':Number(_0x1b87b8['query'][_0x2f4b('0x5a')][_0x40efc3]),'CmListId':Number(_0x1b87b8[_0x2f4b('0x47')]['id'])});}}else{socket[_0x2f4b('0x85')](_0x2f4b('0x88'),{'UserId':Number(_0x1b87b8[_0x2f4b('0x36')][_0x2f4b('0x5a')]),'CmListId':Number(_0x1b87b8[_0x2f4b('0x47')]['id'])});}});}})[_0x2f4b('0x28')](respondWithStatusCode(_0x585b9d,null))['catch'](handleError(_0x585b9d,null));};exports['getAgents']=function(_0x368bce,_0x46c200,_0x2ae4cc){var _0x3a98d6={};var _0x3c7abb={};var _0x1622ad;var _0x4172d9;return db[_0x2f4b('0x43')][_0x2f4b('0x57')]({'where':{'id':_0x368bce[_0x2f4b('0x47')]['id']}})[_0x2f4b('0x28')](handleEntityNotFound(_0x46c200,null))[_0x2f4b('0x28')](function(_0x3b210c){if(_0x3b210c){_0x1622ad=_0x3b210c;_0x3c7abb['model']=_['keys'](db[_0x2f4b('0x89')][_0x2f4b('0x32')]);_0x3c7abb[_0x2f4b('0x36')]=_[_0x2f4b('0x48')](_0x368bce[_0x2f4b('0x36')]);_0x3c7abb['filters']=_[_0x2f4b('0x38')](_0x3c7abb[_0x2f4b('0x35')],_0x3c7abb[_0x2f4b('0x36')]);_0x3a98d6[_0x2f4b('0x39')]=_['intersection'](_0x3c7abb['model'],qs[_0x2f4b('0x3a')](_0x368bce['query'][_0x2f4b('0x3a')]));_0x3a98d6[_0x2f4b('0x39')]=_0x3a98d6['attributes'][_0x2f4b('0x49')]?_0x3a98d6[_0x2f4b('0x39')]:_0x3c7abb[_0x2f4b('0x35')];_0x3a98d6[_0x2f4b('0x6c')]=qs[_0x2f4b('0x3d')](_0x368bce[_0x2f4b('0x36')][_0x2f4b('0x3d')]);_0x3a98d6[_0x2f4b('0x40')]=qs[_0x2f4b('0x37')](_[_0x2f4b('0x3e')](_0x368bce[_0x2f4b('0x36')],_0x3c7abb[_0x2f4b('0x37')]));if(_0x368bce[_0x2f4b('0x36')][_0x2f4b('0x3f')]){_0x3a98d6[_0x2f4b('0x40')]=_['merge'](_0x3a98d6['where'],{'$or':_[_0x2f4b('0x31')](_0x3a98d6[_0x2f4b('0x39')],function(_0x2b9500){var _0xa60627={};_0xa60627[_0x2b9500]={'$like':'%'+_0x368bce[_0x2f4b('0x36')]['filter']+'%'};return _0xa60627;})});}_0x3a98d6=_[_0x2f4b('0x41')]({},_0x3a98d6,_0x368bce[_0x2f4b('0x82')]);return _0x1622ad[_0x2f4b('0x8a')](_0x3a98d6);}})[_0x2f4b('0x28')](function(_0x369b3b){if(_0x369b3b){_0x4172d9=_0x369b3b['length'];if(!_0x368bce[_0x2f4b('0x36')]['hasOwnProperty']('nolimit')){_0x3a98d6[_0x2f4b('0x23')]=qs['limit'](_0x368bce[_0x2f4b('0x36')][_0x2f4b('0x23')]);_0x3a98d6[_0x2f4b('0x22')]=qs[_0x2f4b('0x22')](_0x368bce[_0x2f4b('0x36')][_0x2f4b('0x22')]);}return _0x1622ad['getAgents'](_0x3a98d6);}})['then'](function(_0x14513a){if(_0x14513a){return _0x14513a?{'count':_0x4172d9,'rows':_0x14513a}:null;}})[_0x2f4b('0x28')](respondWithResult(_0x46c200,null))[_0x2f4b('0x4c')](handleError(_0x46c200,null));};
\ No newline at end of file
+var _0x5ac1=['options','count','includeAll','include','findAll','catch','show','params','keys','fields','find','create','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','autoAssociation','UserProfileResource','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','body','describe','addDisposition','ListId','Disposition','getDispositions','findOne','hasOwnProperty','rows','removeDispositions','ids','addContacts','CmContact','tags','isArray','length','join','push','each','dataValues','errors','message','Malformed\x20request\x20syntax','getContacts','concat','format','cf_%d','getContactsCsv','ContactItemType','CmCustomField','alias','select','from','cm_contacts','c.ListId\x20=\x20?','c.deletedAt\x20is\x20null','distinct','field','c.cf_','customField_','cm_contact_has_items','ItemTypeId\x20=\x20?','CmContactId\x20=\x20c.id','additionalPhone_','description','description_additionalPhone_','toString','now','writeFileSync','/tmp/list_%d_%s.csv','setHeader','Content-disposition','attachment;\x20filename=','list_%d_%s.csv','Content-type','download','addCustomField','sequelize','transaction','addCustomFields','Sequelize','TEXT','text','number','INTEGER','switch','defaultValue','queryInterface','addColumn','getCustomFields','findAndCountAll','addAgents','spread','emit','userCmList:save','removeAgents','userCmList:remove','User','getAgents','eml-format','zip-dir','fast-json-patch','util','path','sox','to-csv','fs-extra','lodash','squel','crypto','jsforce','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','socket.io-emitter','./cmList.socket','sendStatus','status','end','json','offset','undefined','limit','set','Content-Range','apply','reject','save','update','destroy','then','get','Lists','error','name','send','index','CmList','rawAttributes','type','key','model','query','filters','attributes','intersection','nolimit','order','sort','where','pick','filter','merge','map','VIRTUAL'];(function(_0x35da42,_0x5c2610){var _0x370035=function(_0x546db5){while(--_0x546db5){_0x35da42['push'](_0x35da42['shift']());}};_0x370035(++_0x5c2610);}(_0x5ac1,0x1a8));var _0x15ac=function(_0x1dce5d,_0x212689){_0x1dce5d=_0x1dce5d-0x0;var _0x1a9ce4=_0x5ac1[_0x1dce5d];return _0x1a9ce4;};'use strict';var emlformat=require(_0x15ac('0x0'));var rimraf=require('rimraf');var zipdir=require(_0x15ac('0x1'));var jsonpatch=require(_0x15ac('0x2'));var rp=require('request-promise');var moment=require('moment');var BPromise=require('bluebird');var Mustache=require('mustache');var util=require(_0x15ac('0x3'));var path=require(_0x15ac('0x4'));var sox=require(_0x15ac('0x5'));var csv=require(_0x15ac('0x6'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x15ac('0x7'));var _=require(_0x15ac('0x8'));var squel=require(_0x15ac('0x9'));var crypto=require(_0x15ac('0xa'));var jsforce=require(_0x15ac('0xb'));var deskjs=require('desk.js');var toCsv=require(_0x15ac('0x6'));var querystring=require('querystring');var Papa=require('papaparse');var Redis=require('ioredis');var authService=require(_0x15ac('0xc'));var qs=require(_0x15ac('0xd'));var as=require(_0x15ac('0xe'));var hardwareService=require(_0x15ac('0xf'));var logger=require(_0x15ac('0x10'))(_0x15ac('0x11'));var utils=require(_0x15ac('0x12'));var config=require(_0x15ac('0x13'));var licenseUtil=require(_0x15ac('0x14'));var db=require(_0x15ac('0x15'))['db'];var csv_results;config[_0x15ac('0x16')]=_[_0x15ac('0x17')](config[_0x15ac('0x16')],{'host':'localhost','port':0x18eb});var socket=require(_0x15ac('0x18'))(new Redis(config[_0x15ac('0x16')]));require(_0x15ac('0x19'))['register'](socket);function respondWithStatusCode(_0x252e13,_0xb9fcef){_0xb9fcef=_0xb9fcef||0xcc;return function(_0x33c4a3){if(_0x33c4a3){return _0x252e13[_0x15ac('0x1a')](_0xb9fcef);}return _0x252e13[_0x15ac('0x1b')](_0xb9fcef)[_0x15ac('0x1c')]();};}function respondWithResult(_0x14ddc6,_0x1a4e8d){_0x1a4e8d=_0x1a4e8d||0xc8;return function(_0x5279b6){if(_0x5279b6){return _0x14ddc6[_0x15ac('0x1b')](_0x1a4e8d)[_0x15ac('0x1d')](_0x5279b6);}};}function respondWithFilteredResult(_0x13c6ea,_0x1426f2){return function(_0x50c316){if(_0x50c316){var _0x13cc17=typeof _0x1426f2[_0x15ac('0x1e')]===_0x15ac('0x1f')&&typeof _0x1426f2[_0x15ac('0x20')]==='undefined';var _0x223af2=_0x50c316['count'];var _0x4fd153=_0x13cc17?0x0:_0x1426f2[_0x15ac('0x1e')];var _0x576ffa=_0x13cc17?_0x50c316['count']:_0x1426f2[_0x15ac('0x1e')]+_0x1426f2[_0x15ac('0x20')];var _0x30eacf;if(_0x576ffa>=_0x223af2){_0x576ffa=_0x223af2;_0x30eacf=0xc8;}else{_0x30eacf=0xce;}_0x13c6ea[_0x15ac('0x1b')](_0x30eacf);return _0x13c6ea[_0x15ac('0x21')](_0x15ac('0x22'),_0x4fd153+'-'+_0x576ffa+'/'+_0x223af2)['json'](_0x50c316);}return null;};}function patchUpdates(_0x447103){return function(_0x2eb1f6){try{jsonpatch[_0x15ac('0x23')](_0x2eb1f6,_0x447103,!![]);}catch(_0x273cf1){return BPromise[_0x15ac('0x24')](_0x273cf1);}return _0x2eb1f6[_0x15ac('0x25')]();};}function saveUpdates(_0x212b33,_0x5ddd85){return function(_0xf2560e){if(_0xf2560e){return _0xf2560e[_0x15ac('0x26')](_0x212b33)['then'](function(_0x148625){return _0x148625;});}return null;};}function removeEntity(_0x2f0273,_0x47c626){return function(_0x33d00a){if(_0x33d00a){return _0x33d00a[_0x15ac('0x27')]()[_0x15ac('0x28')](function(){var _0x15543a=_0x33d00a[_0x15ac('0x29')]({'plain':!![]});var _0x4a79ac=_0x15ac('0x2a');return db['UserProfileResource'][_0x15ac('0x27')]({'where':{'type':_0x4a79ac,'resourceId':_0x15543a['id']}})[_0x15ac('0x28')](function(){return _0x33d00a;});})[_0x15ac('0x28')](function(){_0x2f0273[_0x15ac('0x1b')](0xcc)[_0x15ac('0x1c')]();});}};}function handleEntityNotFound(_0x72600a,_0x57ba69){return function(_0x3cc847){if(!_0x3cc847){_0x72600a[_0x15ac('0x1a')](0x194);}return _0x3cc847;};}function handleError(_0x4375dc,_0x24d216){_0x24d216=_0x24d216||0x1f4;return function(_0x298c72){logger[_0x15ac('0x2b')](_0x298c72['stack']);if(_0x298c72[_0x15ac('0x2c')]){delete _0x298c72[_0x15ac('0x2c')];}_0x4375dc[_0x15ac('0x1b')](_0x24d216)[_0x15ac('0x2d')](_0x298c72);};}exports[_0x15ac('0x2e')]=function(_0x433072,_0x303dce){var _0x11ac51={},_0x314244={},_0x5a8ad5={'count':0x0,'rows':[]};var _0x3cbe1a=_['map'](db[_0x15ac('0x2f')][_0x15ac('0x30')],function(_0x5b6d2c){return{'name':_0x5b6d2c['fieldName'],'type':_0x5b6d2c[_0x15ac('0x31')][_0x15ac('0x32')]};});_0x314244[_0x15ac('0x33')]=_['map'](_0x3cbe1a,_0x15ac('0x2c'));_0x314244[_0x15ac('0x34')]=_['keys'](_0x433072['query']);_0x314244[_0x15ac('0x35')]=_['intersection'](_0x314244[_0x15ac('0x33')],_0x314244[_0x15ac('0x34')]);_0x11ac51[_0x15ac('0x36')]=_[_0x15ac('0x37')](_0x314244['model'],qs['fields'](_0x433072[_0x15ac('0x34')]['fields']));_0x11ac51['attributes']=_0x11ac51[_0x15ac('0x36')]['length']?_0x11ac51[_0x15ac('0x36')]:_0x314244['model'];if(!_0x433072[_0x15ac('0x34')]['hasOwnProperty'](_0x15ac('0x38'))){_0x11ac51[_0x15ac('0x20')]=qs[_0x15ac('0x20')](_0x433072[_0x15ac('0x34')][_0x15ac('0x20')]);_0x11ac51[_0x15ac('0x1e')]=qs[_0x15ac('0x1e')](_0x433072[_0x15ac('0x34')]['offset']);}_0x11ac51[_0x15ac('0x39')]=qs[_0x15ac('0x3a')](_0x433072[_0x15ac('0x34')][_0x15ac('0x3a')]);_0x11ac51[_0x15ac('0x3b')]=qs[_0x15ac('0x35')](_[_0x15ac('0x3c')](_0x433072[_0x15ac('0x34')],_0x314244['filters']),_0x3cbe1a);if(_0x433072[_0x15ac('0x34')][_0x15ac('0x3d')]){_0x11ac51[_0x15ac('0x3b')]=_[_0x15ac('0x3e')](_0x11ac51['where'],{'$or':_[_0x15ac('0x3f')](_0x3cbe1a,function(_0x35d8e4){if(_0x35d8e4['type']!==_0x15ac('0x40')){var _0x4599db={};_0x4599db[_0x35d8e4[_0x15ac('0x2c')]]={'$like':'%'+_0x433072['query'][_0x15ac('0x3d')]+'%'};return _0x4599db;}})});}_0x11ac51=_[_0x15ac('0x3e')]({},_0x11ac51,_0x433072[_0x15ac('0x41')]);var _0x541135={'where':_0x11ac51[_0x15ac('0x3b')]};return db[_0x15ac('0x2f')][_0x15ac('0x42')](_0x541135)[_0x15ac('0x28')](function(_0x291d8e){_0x5a8ad5[_0x15ac('0x42')]=_0x291d8e;if(_0x433072[_0x15ac('0x34')][_0x15ac('0x43')]){_0x11ac51[_0x15ac('0x44')]=[{'all':!![]}];}return db[_0x15ac('0x2f')][_0x15ac('0x45')](_0x11ac51);})[_0x15ac('0x28')](function(_0x5e927f){_0x5a8ad5['rows']=_0x5e927f;return _0x5a8ad5;})[_0x15ac('0x28')](respondWithFilteredResult(_0x303dce,_0x11ac51))[_0x15ac('0x46')](handleError(_0x303dce,null));};exports[_0x15ac('0x47')]=function(_0xdceeb1,_0x43a20c){var _0x42a1f0={'raw':![],'where':{'id':_0xdceeb1[_0x15ac('0x48')]['id']}},_0x3a81de={};_0x3a81de[_0x15ac('0x33')]=_['keys'](db[_0x15ac('0x2f')][_0x15ac('0x30')]);_0x3a81de[_0x15ac('0x34')]=_[_0x15ac('0x49')](_0xdceeb1[_0x15ac('0x34')]);_0x3a81de['filters']=_[_0x15ac('0x37')](_0x3a81de[_0x15ac('0x33')],_0x3a81de['query']);_0x42a1f0['attributes']=_[_0x15ac('0x37')](_0x3a81de[_0x15ac('0x33')],qs[_0x15ac('0x4a')](_0xdceeb1['query'][_0x15ac('0x4a')]));_0x42a1f0['attributes']=_0x42a1f0[_0x15ac('0x36')]['length']?_0x42a1f0[_0x15ac('0x36')]:_0x3a81de['model'];if(_0xdceeb1[_0x15ac('0x34')][_0x15ac('0x43')]){_0x42a1f0['include']=[{'all':!![]}];}_0x42a1f0=_[_0x15ac('0x3e')]({},_0x42a1f0,_0xdceeb1['options']);return db[_0x15ac('0x2f')][_0x15ac('0x4b')](_0x42a1f0)[_0x15ac('0x28')](handleEntityNotFound(_0x43a20c,null))['then'](respondWithResult(_0x43a20c,null))[_0x15ac('0x46')](handleError(_0x43a20c,null));};exports[_0x15ac('0x4c')]=function(_0x5cc5f6,_0x278656){return db['CmList'][_0x15ac('0x4c')](_0x5cc5f6['body'],{})[_0x15ac('0x28')](function(_0x3c83a5){var _0xcdd875=_0x5cc5f6[_0x15ac('0x4d')][_0x15ac('0x29')]({'plain':!![]});if(!_0xcdd875)throw new Error(_0x15ac('0x4e'));if(_0xcdd875[_0x15ac('0x4f')]===_0x15ac('0x4d')){var _0x25466a=_0x3c83a5[_0x15ac('0x29')]({'plain':!![]});var _0x3cd0a0='Lists';return db[_0x15ac('0x50')][_0x15ac('0x4b')]({'where':{'name':_0x3cd0a0,'userProfileId':_0xcdd875['userProfileId']},'raw':!![]})[_0x15ac('0x28')](function(_0x5d0b17){if(_0x5d0b17&&_0x5d0b17[_0x15ac('0x51')]===0x0){return db[_0x15ac('0x52')][_0x15ac('0x4c')]({'name':_0x25466a[_0x15ac('0x2c')],'resourceId':_0x25466a['id'],'type':_0x5d0b17['name'],'sectionId':_0x5d0b17['id']},{})[_0x15ac('0x28')](function(){return _0x3c83a5;});}else{return _0x3c83a5;}})['catch'](function(_0x9a83cf){logger[_0x15ac('0x2b')](_0x15ac('0x53'),_0x9a83cf);throw _0x9a83cf;});}return _0x3c83a5;})[_0x15ac('0x28')](respondWithResult(_0x278656,0xc9))['catch'](handleError(_0x278656,null));};exports[_0x15ac('0x26')]=function(_0x3b1da7,_0x52ea08){if(_0x3b1da7[_0x15ac('0x54')]['id']){delete _0x3b1da7[_0x15ac('0x54')]['id'];}return db[_0x15ac('0x2f')][_0x15ac('0x4b')]({'where':{'id':_0x3b1da7[_0x15ac('0x48')]['id']}})[_0x15ac('0x28')](handleEntityNotFound(_0x52ea08,null))[_0x15ac('0x28')](saveUpdates(_0x3b1da7[_0x15ac('0x54')],null))[_0x15ac('0x28')](respondWithResult(_0x52ea08,null))[_0x15ac('0x46')](handleError(_0x52ea08,null));};exports[_0x15ac('0x27')]=function(_0x2b1811,_0x3333da){return db['CmList'][_0x15ac('0x4b')]({'where':{'id':_0x2b1811[_0x15ac('0x48')]['id']}})[_0x15ac('0x28')](handleEntityNotFound(_0x3333da,null))[_0x15ac('0x28')](removeEntity(_0x3333da,null))['catch'](handleError(_0x3333da,null));};exports['describe']=function(_0x4cb305,_0x38e162){return db[_0x15ac('0x2f')][_0x15ac('0x55')]()[_0x15ac('0x28')](respondWithResult(_0x38e162,null))[_0x15ac('0x46')](handleError(_0x38e162,null));};exports[_0x15ac('0x56')]=function(_0x3f5ae4,_0x10d896,_0x4e22e7){if(_0x3f5ae4[_0x15ac('0x54')]['id']){delete _0x3f5ae4[_0x15ac('0x54')]['id'];}return db[_0x15ac('0x2f')][_0x15ac('0x4b')]({'where':{'id':_0x3f5ae4[_0x15ac('0x48')]['id']}})['then'](handleEntityNotFound(_0x10d896,null))['then'](function(_0x49a91f){if(_0x49a91f){_0x3f5ae4['body'][_0x15ac('0x57')]=_0x49a91f['id'];return db[_0x15ac('0x58')][_0x15ac('0x4c')](_0x3f5ae4[_0x15ac('0x54')]);}})['then'](respondWithResult(_0x10d896,null))[_0x15ac('0x46')](handleError(_0x10d896,null));};exports[_0x15ac('0x59')]=function(_0x3b5c72,_0x5d580f,_0x3019e2){var _0x2dfdaf={'raw':![],'where':{}};var _0x59d012={};var _0x32736f={'count':0x0,'rows':[]};return db['CmList'][_0x15ac('0x5a')]({'where':{'id':_0x3b5c72[_0x15ac('0x48')]['id']}})['then'](handleEntityNotFound(_0x5d580f,null))[_0x15ac('0x28')](function(_0x1513db){if(_0x1513db){_0x59d012[_0x15ac('0x33')]=_[_0x15ac('0x49')](db[_0x15ac('0x58')][_0x15ac('0x30')]);_0x59d012[_0x15ac('0x34')]=_['keys'](_0x3b5c72[_0x15ac('0x34')]);_0x59d012[_0x15ac('0x35')]=_[_0x15ac('0x37')](_0x59d012[_0x15ac('0x33')],_0x59d012[_0x15ac('0x34')]);_0x2dfdaf[_0x15ac('0x36')]=_[_0x15ac('0x37')](_0x59d012[_0x15ac('0x33')],qs['fields'](_0x3b5c72[_0x15ac('0x34')][_0x15ac('0x4a')]));_0x2dfdaf[_0x15ac('0x36')]=_0x2dfdaf[_0x15ac('0x36')]['length']?_0x2dfdaf[_0x15ac('0x36')]:_0x59d012[_0x15ac('0x33')];if(!_0x3b5c72['query'][_0x15ac('0x5b')](_0x15ac('0x38'))){_0x2dfdaf[_0x15ac('0x20')]=qs[_0x15ac('0x20')](_0x3b5c72[_0x15ac('0x34')][_0x15ac('0x20')]);_0x2dfdaf[_0x15ac('0x1e')]=qs[_0x15ac('0x1e')](_0x3b5c72[_0x15ac('0x34')][_0x15ac('0x1e')]);}_0x2dfdaf[_0x15ac('0x39')]=qs[_0x15ac('0x3a')](_0x3b5c72[_0x15ac('0x34')][_0x15ac('0x3a')]);_0x2dfdaf[_0x15ac('0x3b')]=qs[_0x15ac('0x35')](_['pick'](_0x3b5c72[_0x15ac('0x34')],_0x59d012[_0x15ac('0x35')]));_0x2dfdaf[_0x15ac('0x3b')]['ListId']=_0x1513db['id'];if(_0x3b5c72[_0x15ac('0x34')]['filter']){_0x2dfdaf[_0x15ac('0x3b')]=_[_0x15ac('0x3e')](_0x2dfdaf['where'],{'$or':_['map'](_0x2dfdaf[_0x15ac('0x36')],function(_0xa978d9){var _0x1bed49={};_0x1bed49[_0xa978d9]={'$like':'%'+_0x3b5c72[_0x15ac('0x34')][_0x15ac('0x3d')]+'%'};return _0x1bed49;})});}_0x2dfdaf=_[_0x15ac('0x3e')]({},_0x2dfdaf,_0x3b5c72[_0x15ac('0x41')]);return db[_0x15ac('0x58')]['count']({'where':_0x2dfdaf[_0x15ac('0x3b')]})[_0x15ac('0x28')](function(_0x59f67c){_0x32736f[_0x15ac('0x42')]=_0x59f67c;if(_0x3b5c72[_0x15ac('0x34')][_0x15ac('0x43')]){_0x2dfdaf['include']=[{'all':!![]}];}return db[_0x15ac('0x58')][_0x15ac('0x45')](_0x2dfdaf);})['then'](function(_0x2091b2){_0x32736f[_0x15ac('0x5c')]=_0x2091b2;return _0x32736f;});}})[_0x15ac('0x28')](respondWithFilteredResult(_0x5d580f,_0x2dfdaf))[_0x15ac('0x46')](handleError(_0x5d580f,null));};exports[_0x15ac('0x5d')]=function(_0x50d165,_0x5305e8,_0x5d8e36){return db[_0x15ac('0x2f')][_0x15ac('0x4b')]({'where':{'id':_0x50d165['params']['id']}})['then'](handleEntityNotFound(_0x5305e8,null))[_0x15ac('0x28')](function(_0x102fe9){if(_0x102fe9){return _0x102fe9[_0x15ac('0x5d')](_0x50d165[_0x15ac('0x34')][_0x15ac('0x5e')]);}})[_0x15ac('0x28')](respondWithStatusCode(_0x5305e8,null))[_0x15ac('0x46')](handleError(_0x5305e8,null));};exports[_0x15ac('0x5f')]=function(_0x3ccd94,_0x3eed1a,_0x3e72ca){return db['CmList']['find']({'where':{'id':_0x3ccd94['params']['id']}})[_0x15ac('0x28')](handleEntityNotFound(_0x3eed1a,null))[_0x15ac('0x28')](function(_0xb12541){if(_0xb12541){var _0x28b5ed=[];var _0x3f41a6={'success':[],'errors':[]};return db[_0x15ac('0x60')][_0x15ac('0x55')]()['then'](function(_0x48af4d){if(_0x3ccd94[_0x15ac('0x54')][_0x15ac('0x61')]&&_[_0x15ac('0x62')](_0x3ccd94[_0x15ac('0x54')][_0x15ac('0x61')])){if(_0x3ccd94[_0x15ac('0x54')][_0x15ac('0x61')][_0x15ac('0x63')]){_0x3ccd94[_0x15ac('0x54')][_0x15ac('0x61')]=_0x3ccd94[_0x15ac('0x54')][_0x15ac('0x61')][_0x15ac('0x64')](';')+';';}else{_0x3ccd94[_0x15ac('0x54')][_0x15ac('0x61')]=null;}}else{_0x3ccd94[_0x15ac('0x54')][_0x15ac('0x61')]=null;}if(_0x3ccd94[_0x15ac('0x54')]&&_['isArray'](_0x3ccd94['body'])){for(var _0x46a626=0x0;_0x46a626<_0x3ccd94[_0x15ac('0x54')]['length'];_0x46a626+=0x1){_0x3ccd94['body'][_0x46a626][_0x15ac('0x57')]=_0x3ccd94['params']['id'];_0x28b5ed[_0x15ac('0x65')](_0x3ccd94[_0x15ac('0x54')][_0x46a626]);}return BPromise[_0x15ac('0x66')](_0x28b5ed,function(_0x4daaa9){return db[_0x15ac('0x60')][_0x15ac('0x4c')](_['omit'](_0x4daaa9,[_0x15ac('0x5e'),'id'])||{},{'fields':_[_0x15ac('0x49')](_0x48af4d),'raw':!![]})[_0x15ac('0x28')](function(_0x7b93b6){_0x3f41a6['success']['push'](_0x7b93b6[_0x15ac('0x67')]);})[_0x15ac('0x46')](function(_0x5040ce){_0x3f41a6[_0x15ac('0x68')][_0x15ac('0x65')]({'data':_0x4daaa9,'error':_0x5040ce[_0x15ac('0x69')]});});})[_0x15ac('0x28')](function(_0x49c37f){return _0x3f41a6;})[_0x15ac('0x46')](function(_0x4f4fd8){return _0x4f4fd8;});}else{_0x3eed1a[_0x15ac('0x1b')](0x190)[_0x15ac('0x1d')]({'message':_0x15ac('0x6a')});}});}})['then'](respondWithResult(_0x3eed1a,null))[_0x15ac('0x46')](handleError(_0x3eed1a,null));};exports[_0x15ac('0x6b')]=function(_0x5f8486,_0x150be9,_0x1249e7){var _0x42ef66;return db[_0x15ac('0x2f')][_0x15ac('0x4b')]({'where':{'id':_0x5f8486[_0x15ac('0x48')]['id']},'include':[{'model':db['CmCustomField'],'as':'CustomFields'}]})[_0x15ac('0x28')](handleEntityNotFound(_0x150be9,null))[_0x15ac('0x28')](function(_0x577b38){if(_0x577b38){_0x42ef66=_0x577b38;return db['CmContact'][_0x15ac('0x30')];}})[_0x15ac('0x28')](function(_0x28cf10){if(_0x28cf10){var _0x281030={};var _0x23ff81={};_0x23ff81[_0x15ac('0x33')]=_[_0x15ac('0x6c')](_['keys'](_0x28cf10),_['map'](_0x42ef66['CustomFields'],function(_0x4e268b){return util[_0x15ac('0x6d')](_0x15ac('0x6e'),_0x4e268b['id']);}));_0x23ff81[_0x15ac('0x34')]=_[_0x15ac('0x49')](_0x5f8486[_0x15ac('0x34')]);_0x23ff81[_0x15ac('0x35')]=_[_0x15ac('0x37')](_0x23ff81[_0x15ac('0x33')],_0x23ff81[_0x15ac('0x34')]);_0x281030[_0x15ac('0x36')]=_[_0x15ac('0x37')](_0x23ff81[_0x15ac('0x33')],qs['fields'](_0x5f8486['query'][_0x15ac('0x4a')]));_0x281030[_0x15ac('0x36')]=_0x281030['attributes'][_0x15ac('0x63')]?_0x281030[_0x15ac('0x36')]:_0x23ff81[_0x15ac('0x33')];if(!_0x5f8486['query'][_0x15ac('0x5b')](_0x15ac('0x38'))){_0x281030[_0x15ac('0x20')]=qs[_0x15ac('0x20')](_0x5f8486[_0x15ac('0x34')][_0x15ac('0x20')]);_0x281030[_0x15ac('0x1e')]=qs[_0x15ac('0x1e')](_0x5f8486[_0x15ac('0x34')][_0x15ac('0x1e')]);}_0x281030[_0x15ac('0x39')]=qs[_0x15ac('0x3a')](_0x5f8486[_0x15ac('0x34')]['sort']);_0x281030[_0x15ac('0x3b')]=qs[_0x15ac('0x35')](_[_0x15ac('0x3c')](_0x5f8486[_0x15ac('0x34')],_0x23ff81['filters']));_0x281030['raw']=!![];if(_0x5f8486[_0x15ac('0x34')][_0x15ac('0x3d')]){_0x281030[_0x15ac('0x3b')]=_['merge'](_0x281030[_0x15ac('0x3b')],{'$or':_['map'](_0x281030['attributes'],function(_0xc8651f){var _0x4f2348={};_0x4f2348[_0xc8651f]={'$like':'%'+_0x5f8486[_0x15ac('0x34')]['filter']+'%'};return _0x4f2348;})});}_0x281030=_[_0x15ac('0x3e')]({},_0x281030,_0x5f8486[_0x15ac('0x41')]);return _0x42ef66[_0x15ac('0x6b')](_0x281030);}})[_0x15ac('0x28')](respondWithResult(_0x150be9,null))[_0x15ac('0x46')](handleError(_0x150be9,null));};exports[_0x15ac('0x6f')]=function(_0xd74f6b,_0x240580,_0xa61745){var _0x557d24;var _0x340dbe;var _0x3b084f;var _0x505e15=_0xd74f6b[_0x15ac('0x48')]['id'];csv_results=[];return db[_0x15ac('0x70')][_0x15ac('0x45')]({'attributes':['id',_0x15ac('0x2c')],'raw':!![],'order':['OrderBy']})[_0x15ac('0x28')](function(_0xa0ec1a){_0x557d24=_0xa0ec1a;var _0x179e7b=_[_0x15ac('0x49')](db[_0x15ac('0x60')][_0x15ac('0x30')]);return db[_0x15ac('0x71')][_0x15ac('0x45')]({'raw':!![],'attributes':['id',_0x15ac('0x72')]})[_0x15ac('0x28')](function(_0x217638){_0x340dbe=_0x217638;var _0x4e6f70=squel[_0x15ac('0x73')]()['fields'](_0x179e7b)[_0x15ac('0x74')](_0x15ac('0x75'),'c')['where'](_0x15ac('0x76'),_0x505e15)['where'](_0x15ac('0x77'))[_0x15ac('0x78')]();for(var _0x2bddbe=0x0;_0x2bddbe<_0x340dbe['length'];_0x2bddbe++){_0x4e6f70[_0x15ac('0x79')](_0x15ac('0x7a')+_0x340dbe[_0x2bddbe]['id'],_0x15ac('0x7b')+_0x340dbe[_0x2bddbe][_0x15ac('0x72')]);}for(var _0x2bddbe=0x0;_0x2bddbe<_0x557d24[_0x15ac('0x63')];_0x2bddbe++){_0x4e6f70[_0x15ac('0x79')](squel[_0x15ac('0x73')]()[_0x15ac('0x79')]('item')[_0x15ac('0x74')](_0x15ac('0x7c'))[_0x15ac('0x3b')](_0x15ac('0x7d'),_0x557d24[_0x2bddbe]['id'])['where'](_0x15ac('0x7e')),_0x15ac('0x7f')+_0x557d24[_0x2bddbe]['name']);_0x4e6f70[_0x15ac('0x79')](squel[_0x15ac('0x73')]()['field'](_0x15ac('0x80'))[_0x15ac('0x74')](_0x15ac('0x7c'))[_0x15ac('0x3b')]('ItemTypeId\x20=\x20?',_0x557d24[_0x2bddbe]['id'])[_0x15ac('0x3b')]('CmContactId\x20=\x20c.id'),_0x15ac('0x81')+_0x557d24[_0x2bddbe]['name']);}var _0x3ecc8b=[];_0x3ecc8b[_0x15ac('0x65')](_0x4e6f70[_0x15ac('0x82')]());BPromise[_0x15ac('0x66')](_0x3ecc8b,handleQuery)[_0x15ac('0x28')](function(_0x3b5021){handleQuery(_0x4e6f70[_0x15ac('0x82')]());var _0x6feb7c=csv_results[0x0];if(!_['isEmpty'](_0x6feb7c)){var _0x1709eb=toCsv(_0x6feb7c);var _0x5853ab=Date[_0x15ac('0x83')]();fs[_0x15ac('0x84')](util[_0x15ac('0x6d')](_0x15ac('0x85'),_0x505e15,_0x5853ab),_0x1709eb);_0x240580[_0x15ac('0x86')](_0x15ac('0x87'),_0x15ac('0x88')+util['format'](_0x15ac('0x89'),_0x505e15,_0x5853ab));_0x240580[_0x15ac('0x86')](_0x15ac('0x8a'),'text/csv');return _0x240580[_0x15ac('0x8b')](util[_0x15ac('0x6d')](_0x15ac('0x85'),_0x505e15,_0x5853ab));}else{return _0x240580['sendStatus'](0xcc);}});});});};exports[_0x15ac('0x8c')]=function(_0x169135,_0x4b66bf,_0x24eccf){var _0x7b6894;delete _0x169135['body']['id'];return db[_0x15ac('0x2f')][_0x15ac('0x5a')]({'where':{'id':_0x169135['params']['id']}})[_0x15ac('0x28')](handleEntityNotFound(_0x4b66bf,null))[_0x15ac('0x28')](function(_0x85d89){if(_0x85d89){return db[_0x15ac('0x8d')][_0x15ac('0x8e')](function(_0x586e36){return db[_0x15ac('0x71')][_0x15ac('0x4c')](_0x169135[_0x15ac('0x54')],{'transaction':_0x586e36})[_0x15ac('0x28')](function(_0x731a0d){_0x7b6894=_0x731a0d;return _0x85d89[_0x15ac('0x8f')](_0x731a0d,{'transaction':_0x586e36});})['then'](function(){var _0x443385={'type':db[_0x15ac('0x90')][_0x15ac('0x91')],'transaction':_0x586e36};switch(_0x169135[_0x15ac('0x54')][_0x15ac('0x31')]){case _0x15ac('0x92'):_0x443385[_0x15ac('0x31')]=db[_0x15ac('0x90')][_0x15ac('0x91')];break;case _0x15ac('0x93'):_0x443385[_0x15ac('0x31')]=db[_0x15ac('0x90')][_0x15ac('0x94')];break;case _0x15ac('0x95'):_0x443385[_0x15ac('0x31')]=db[_0x15ac('0x90')]['BOOLEAN'];_0x443385[_0x15ac('0x96')]=![];break;default:}return db[_0x15ac('0x8d')][_0x15ac('0x97')][_0x15ac('0x98')](_0x15ac('0x75'),util[_0x15ac('0x6d')]('cf_%s',_0x7b6894['id']),_0x443385);})[_0x15ac('0x28')](function(){return _0x7b6894;});});}})['then'](respondWithResult(_0x4b66bf,null))[_0x15ac('0x46')](handleError(_0x4b66bf,null));};exports[_0x15ac('0x99')]=function(_0xf56e6c,_0x40f045,_0x2381e8){var _0x2cb031={};var _0x388b0a={};var _0x5cc284;var _0x5a0310;return db[_0x15ac('0x2f')][_0x15ac('0x5a')]({'where':{'id':_0xf56e6c[_0x15ac('0x48')]['id']}})[_0x15ac('0x28')](handleEntityNotFound(_0x40f045,null))['then'](function(_0x142f33){if(_0x142f33){_0x5cc284=_0x142f33;_0x388b0a['model']=_[_0x15ac('0x49')](db[_0x15ac('0x71')][_0x15ac('0x30')]);_0x388b0a['query']=_[_0x15ac('0x49')](_0xf56e6c[_0x15ac('0x34')]);_0x388b0a[_0x15ac('0x35')]=_['intersection'](_0x388b0a['model'],_0x388b0a[_0x15ac('0x34')]);_0x2cb031[_0x15ac('0x36')]=_[_0x15ac('0x37')](_0x388b0a[_0x15ac('0x33')],qs[_0x15ac('0x4a')](_0xf56e6c['query'][_0x15ac('0x4a')]));_0x2cb031['attributes']=_0x2cb031['attributes']['length']?_0x2cb031['attributes']:_0x388b0a[_0x15ac('0x33')];_0x2cb031[_0x15ac('0x39')]=qs[_0x15ac('0x3a')](_0xf56e6c[_0x15ac('0x34')][_0x15ac('0x3a')]);_0x2cb031['where']=qs[_0x15ac('0x35')](_[_0x15ac('0x3c')](_0xf56e6c[_0x15ac('0x34')],_0x388b0a['filters']));_0x2cb031[_0x15ac('0x3b')]=_[_0x15ac('0x3e')](_0x2cb031[_0x15ac('0x3b')],{'$or':[{'ListId':_0x142f33['id']},{'ListId':null}]});if(_0xf56e6c[_0x15ac('0x34')][_0x15ac('0x3d')]){_0x2cb031[_0x15ac('0x3b')]=_[_0x15ac('0x3e')](_0x2cb031['where'],{'$or':_[_0x15ac('0x3f')](_0x2cb031['attributes'],function(_0x2fde7a){var _0x5a9630={};_0x5a9630[_0x2fde7a]={'$like':'%'+_0xf56e6c[_0x15ac('0x34')]['filter']+'%'};return _0x5a9630;})});}_0x2cb031=_[_0x15ac('0x3e')]({},_0x2cb031,_0xf56e6c[_0x15ac('0x41')]);return db[_0x15ac('0x71')][_0x15ac('0x9a')](_0x2cb031);}})[_0x15ac('0x28')](respondWithResult(_0x40f045,null))[_0x15ac('0x46')](handleError(_0x40f045,null));};exports['getGlobalCustomFields']=function(_0x5acb93,_0x43ed49){return db['CmCustomField'][_0x15ac('0x9a')]({'where':{'ListId':null}})[_0x15ac('0x28')](handleEntityNotFound(_0x43ed49,null))[_0x15ac('0x28')](function(_0x47736d){return _0x47736d;})[_0x15ac('0x28')](respondWithResult(_0x43ed49,null))[_0x15ac('0x46')](handleError(_0x43ed49,null));};exports[_0x15ac('0x9b')]=function(_0x4313a0,_0x31dd30,_0x354242){return db['CmList']['find']({'where':{'id':_0x4313a0[_0x15ac('0x48')]['id']}})[_0x15ac('0x28')](handleEntityNotFound(_0x31dd30,null))['then'](function(_0x53a1f4){if(_0x53a1f4){return _0x53a1f4['addAgents'](_0x4313a0[_0x15ac('0x54')][_0x15ac('0x5e')],_['omit'](_0x4313a0['body'],[_0x15ac('0x5e'),'id'])||{})[_0x15ac('0x9c')](function(_0x3e283c){for(var _0x45a01a=0x0;_0x45a01a<_0x4313a0[_0x15ac('0x54')][_0x15ac('0x5e')][_0x15ac('0x63')];_0x45a01a+=0x1){socket[_0x15ac('0x9d')](_0x15ac('0x9e'),{'UserId':Number(_0x4313a0[_0x15ac('0x54')]['ids'][_0x45a01a]),'CmListId':Number(_0x4313a0[_0x15ac('0x48')]['id'])});}return _0x3e283c;});}})[_0x15ac('0x28')](respondWithResult(_0x31dd30,null))[_0x15ac('0x46')](handleError(_0x31dd30,null));};exports['removeAgents']=function(_0x31f22b,_0x2dca75,_0x3622c8){return db[_0x15ac('0x2f')][_0x15ac('0x4b')]({'where':{'id':_0x31f22b['params']['id']}})[_0x15ac('0x28')](handleEntityNotFound(_0x2dca75,null))['then'](function(_0x257571){if(_0x257571){return _0x257571[_0x15ac('0x9f')](_0x31f22b[_0x15ac('0x34')][_0x15ac('0x5e')])[_0x15ac('0x28')](function(){if(_['isArray'](_0x31f22b[_0x15ac('0x34')]['ids'])){for(var _0x3427df=0x0;_0x3427df<_0x31f22b[_0x15ac('0x34')][_0x15ac('0x5e')][_0x15ac('0x63')];_0x3427df+=0x1){socket[_0x15ac('0x9d')](_0x15ac('0xa0'),{'UserId':Number(_0x31f22b[_0x15ac('0x34')]['ids'][_0x3427df]),'CmListId':Number(_0x31f22b[_0x15ac('0x48')]['id'])});}}else{socket[_0x15ac('0x9d')]('userCmList:remove',{'UserId':Number(_0x31f22b[_0x15ac('0x34')][_0x15ac('0x5e')]),'CmListId':Number(_0x31f22b[_0x15ac('0x48')]['id'])});}});}})[_0x15ac('0x28')](respondWithStatusCode(_0x2dca75,null))[_0x15ac('0x46')](handleError(_0x2dca75,null));};exports['getAgents']=function(_0x4d809d,_0x53d7da,_0xe71ed9){var _0x1a5e9a={};var _0x9267cf={};var _0x5a2996;var _0x1fbb8e;return db[_0x15ac('0x2f')][_0x15ac('0x5a')]({'where':{'id':_0x4d809d[_0x15ac('0x48')]['id']}})['then'](handleEntityNotFound(_0x53d7da,null))[_0x15ac('0x28')](function(_0x2de20f){if(_0x2de20f){_0x5a2996=_0x2de20f;_0x9267cf[_0x15ac('0x33')]=_[_0x15ac('0x49')](db[_0x15ac('0xa1')][_0x15ac('0x30')]);_0x9267cf[_0x15ac('0x34')]=_[_0x15ac('0x49')](_0x4d809d[_0x15ac('0x34')]);_0x9267cf['filters']=_[_0x15ac('0x37')](_0x9267cf[_0x15ac('0x33')],_0x9267cf[_0x15ac('0x34')]);_0x1a5e9a[_0x15ac('0x36')]=_[_0x15ac('0x37')](_0x9267cf['model'],qs[_0x15ac('0x4a')](_0x4d809d[_0x15ac('0x34')][_0x15ac('0x4a')]));_0x1a5e9a['attributes']=_0x1a5e9a['attributes'][_0x15ac('0x63')]?_0x1a5e9a['attributes']:_0x9267cf[_0x15ac('0x33')];_0x1a5e9a[_0x15ac('0x39')]=qs[_0x15ac('0x3a')](_0x4d809d[_0x15ac('0x34')][_0x15ac('0x3a')]);_0x1a5e9a[_0x15ac('0x3b')]=qs['filters'](_[_0x15ac('0x3c')](_0x4d809d['query'],_0x9267cf['filters']));if(_0x4d809d[_0x15ac('0x34')]['filter']){_0x1a5e9a['where']=_[_0x15ac('0x3e')](_0x1a5e9a[_0x15ac('0x3b')],{'$or':_[_0x15ac('0x3f')](_0x1a5e9a[_0x15ac('0x36')],function(_0x45a0cb){var _0x317461={};_0x317461[_0x45a0cb]={'$like':'%'+_0x4d809d[_0x15ac('0x34')][_0x15ac('0x3d')]+'%'};return _0x317461;})});}_0x1a5e9a=_[_0x15ac('0x3e')]({},_0x1a5e9a,_0x4d809d[_0x15ac('0x41')]);return _0x5a2996[_0x15ac('0xa2')](_0x1a5e9a);}})['then'](function(_0x429986){if(_0x429986){_0x1fbb8e=_0x429986[_0x15ac('0x63')];if(!_0x4d809d[_0x15ac('0x34')][_0x15ac('0x5b')](_0x15ac('0x38'))){_0x1a5e9a[_0x15ac('0x20')]=qs[_0x15ac('0x20')](_0x4d809d['query'][_0x15ac('0x20')]);_0x1a5e9a['offset']=qs['offset'](_0x4d809d[_0x15ac('0x34')][_0x15ac('0x1e')]);}return _0x5a2996['getAgents'](_0x1a5e9a);}})[_0x15ac('0x28')](function(_0x46c4b7){if(_0x46c4b7){return _0x46c4b7?{'count':_0x1fbb8e,'rows':_0x46c4b7}:null;}})[_0x15ac('0x28')](respondWithResult(_0x53d7da,null))[_0x15ac('0x46')](handleError(_0x53d7da,null));};function handleQuery(_0x2bee93){logger['info'](_0x2bee93);return db[_0x15ac('0x8d')]['query'](_0x2bee93)[_0x15ac('0x9c')](function(_0x206751){csv_results[_0x15ac('0x65')](_0x206751);})[_0x15ac('0x46')](function(_0x1e5386){logger['error'](_0x1e5386[_0x15ac('0x69')]);});}
\ No newline at end of file