Built motion from commit (unavailable).|2.5.14
[motion2.git] / server / api / cmList / cmList.controller.js
index 2265607..0f24375 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 _0x1192=['count','offset','set','Content-Range','apply','reject','save','update','then','destroy','Lists','error','stack','name','send','index','map','fieldName','type','key','model','keys','query','filters','intersection','attributes','length','hasOwnProperty','nolimit','limit','order','sort','pick','filter','where','merge','options','CmList','includeAll','include','findAll','rows','catch','show','rawAttributes','fields','find','create','user','get','UserProfileSection','autoAssociation','UserProfileResource','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','params','body','describe','addDisposition','ListId','Disposition','getDispositions','findOne','removeDispositions','ids','addContacts','CmContact','isArray','tags','join','push','each','omit','success','dataValues','message','Malformed\x20request\x20syntax','getContacts','CustomFields','concat','format','cf_%d','CmCustomField','raw','now','writeFileSync','/tmp/list_%d_%s.csv','setHeader','list_%d_%s.csv','Content-type','download','addCustomField','sequelize','transaction','addCustomFields','text','Sequelize','TEXT','number','INTEGER','switch','BOOLEAN','defaultValue','queryInterface','addColumn','cm_contacts','cf_%s','addAgents','spread','emit','removeAgents','userCmList:remove','getAgents','User','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/license/util','../../mysqldb','redis','defaults','localhost','./cmList.socket','sendStatus','end','status','json'];(function(_0x4243a3,_0x447337){var _0x1b2a33=function(_0x6a8200){while(--_0x6a8200){_0x4243a3['push'](_0x4243a3['shift']());}};_0x1b2a33(++_0x447337);}(_0x1192,0x71));var _0x2119=function(_0x45b36c,_0x4efbfe){_0x45b36c=_0x45b36c-0x0;var _0x1dad2f=_0x1192[_0x45b36c];return _0x1dad2f;};'use strict';var pdf=require(_0x2119('0x0'));var emlformat=require(_0x2119('0x1'));var rimraf=require(_0x2119('0x2'));var zipdir=require(_0x2119('0x3'));var jsonpatch=require(_0x2119('0x4'));var rp=require(_0x2119('0x5'));var moment=require(_0x2119('0x6'));var BPromise=require(_0x2119('0x7'));var Mustache=require(_0x2119('0x8'));var util=require(_0x2119('0x9'));var path=require(_0x2119('0xa'));var sox=require(_0x2119('0xb'));var csv=require(_0x2119('0xc'));var ejs=require(_0x2119('0xd'));var fs=require('fs');var _=require(_0x2119('0xe'));var squel=require(_0x2119('0xf'));var crypto=require(_0x2119('0x10'));var jsforce=require(_0x2119('0x11'));var deskjs=require(_0x2119('0x12'));var toCsv=require('to-csv');var querystring=require(_0x2119('0x13'));var Papa=require(_0x2119('0x14'));var Redis=require('ioredis');var authService=require(_0x2119('0x15'));var qs=require(_0x2119('0x16'));var as=require(_0x2119('0x17'));var hardwareService=require(_0x2119('0x18'));var logger=require(_0x2119('0x19'))(_0x2119('0x1a'));var utils=require(_0x2119('0x1b'));var config=require('../../config/environment');var licenseUtil=require(_0x2119('0x1c'));var db=require(_0x2119('0x1d'))['db'];config[_0x2119('0x1e')]=_[_0x2119('0x1f')](config[_0x2119('0x1e')],{'host':_0x2119('0x20'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x2119('0x1e')]));require(_0x2119('0x21'))['register'](socket);function respondWithStatusCode(_0x40ccc5,_0x3275cd){_0x3275cd=_0x3275cd||0xcc;return function(_0x4160be){if(_0x4160be){return _0x40ccc5[_0x2119('0x22')](_0x3275cd);}return _0x40ccc5['status'](_0x3275cd)[_0x2119('0x23')]();};}function respondWithResult(_0x407622,_0x2dc351){_0x2dc351=_0x2dc351||0xc8;return function(_0x2da5cb){if(_0x2da5cb){return _0x407622[_0x2119('0x24')](_0x2dc351)[_0x2119('0x25')](_0x2da5cb);}};}function respondWithFilteredResult(_0xb3d5e2,_0x4c68b6){return function(_0x1275aa){if(_0x1275aa){var _0x12be49=_0x1275aa[_0x2119('0x26')],_0x5ab410=_0x4c68b6[_0x2119('0x27')],_0x170a9f=_0x4c68b6[_0x2119('0x27')]+_0x4c68b6['limit'],_0x57be46;if(_0x170a9f>=_0x12be49){_0x170a9f=_0x12be49;_0x57be46=0xc8;}else{_0x57be46=0xce;}_0xb3d5e2[_0x2119('0x24')](_0x57be46);return _0xb3d5e2[_0x2119('0x28')](_0x2119('0x29'),_0x5ab410+'-'+_0x170a9f+'/'+_0x12be49)[_0x2119('0x25')](_0x1275aa);}return null;};}function patchUpdates(_0x4c4b95){return function(_0x3bda1c){try{jsonpatch[_0x2119('0x2a')](_0x3bda1c,_0x4c4b95,!![]);}catch(_0xa87c9f){return BPromise[_0x2119('0x2b')](_0xa87c9f);}return _0x3bda1c[_0x2119('0x2c')]();};}function saveUpdates(_0xbfc9d9,_0x6bd311){return function(_0x19a913){if(_0x19a913){return _0x19a913[_0x2119('0x2d')](_0xbfc9d9)[_0x2119('0x2e')](function(_0xaf159c){return _0xaf159c;});}return null;};}function removeEntity(_0xb0c05c,_0x332413){return function(_0x19f2f4){if(_0x19f2f4){return _0x19f2f4[_0x2119('0x2f')]()[_0x2119('0x2e')](function(){var _0x96ab72=_0x19f2f4['get']({'plain':!![]});var _0x1a5d81=_0x2119('0x30');return db['UserProfileResource'][_0x2119('0x2f')]({'where':{'type':_0x1a5d81,'resourceId':_0x96ab72['id']}})[_0x2119('0x2e')](function(){return _0x19f2f4;});})[_0x2119('0x2e')](function(){_0xb0c05c[_0x2119('0x24')](0xcc)['end']();});}};}function handleEntityNotFound(_0x2dbf67,_0x19b2a0){return function(_0x25f5c7){if(!_0x25f5c7){_0x2dbf67[_0x2119('0x22')](0x194);}return _0x25f5c7;};}function handleError(_0x4b3c18,_0x5eeb81){_0x5eeb81=_0x5eeb81||0x1f4;return function(_0x557a30){logger[_0x2119('0x31')](_0x557a30[_0x2119('0x32')]);if(_0x557a30[_0x2119('0x33')]){delete _0x557a30[_0x2119('0x33')];}_0x4b3c18[_0x2119('0x24')](_0x5eeb81)[_0x2119('0x34')](_0x557a30);};}exports[_0x2119('0x35')]=function(_0x2afbd8,_0x100bb9){var _0x23cca4={},_0x21d476={},_0x25a539={'count':0x0,'rows':[]};var _0x3af735=_[_0x2119('0x36')](db['CmList']['rawAttributes'],function(_0x132c55){return{'name':_0x132c55[_0x2119('0x37')],'type':_0x132c55[_0x2119('0x38')][_0x2119('0x39')]};});_0x21d476[_0x2119('0x3a')]=_['map'](_0x3af735,_0x2119('0x33'));_0x21d476['query']=_[_0x2119('0x3b')](_0x2afbd8[_0x2119('0x3c')]);_0x21d476[_0x2119('0x3d')]=_[_0x2119('0x3e')](_0x21d476['model'],_0x21d476['query']);_0x23cca4['attributes']=_['intersection'](_0x21d476[_0x2119('0x3a')],qs['fields'](_0x2afbd8[_0x2119('0x3c')]['fields']));_0x23cca4[_0x2119('0x3f')]=_0x23cca4[_0x2119('0x3f')][_0x2119('0x40')]?_0x23cca4[_0x2119('0x3f')]:_0x21d476[_0x2119('0x3a')];if(!_0x2afbd8[_0x2119('0x3c')][_0x2119('0x41')](_0x2119('0x42'))){_0x23cca4[_0x2119('0x43')]=qs['limit'](_0x2afbd8['query']['limit']);_0x23cca4[_0x2119('0x27')]=qs['offset'](_0x2afbd8[_0x2119('0x3c')][_0x2119('0x27')]);}_0x23cca4[_0x2119('0x44')]=qs[_0x2119('0x45')](_0x2afbd8[_0x2119('0x3c')]['sort']);_0x23cca4['where']=qs[_0x2119('0x3d')](_[_0x2119('0x46')](_0x2afbd8[_0x2119('0x3c')],_0x21d476[_0x2119('0x3d')]),_0x3af735);if(_0x2afbd8[_0x2119('0x3c')][_0x2119('0x47')]){_0x23cca4[_0x2119('0x48')]=_[_0x2119('0x49')](_0x23cca4[_0x2119('0x48')],{'$or':_[_0x2119('0x36')](_0x3af735,function(_0x147eaf){if(_0x147eaf[_0x2119('0x38')]!=='VIRTUAL'){var _0x319941={};_0x319941[_0x147eaf[_0x2119('0x33')]]={'$like':'%'+_0x2afbd8[_0x2119('0x3c')][_0x2119('0x47')]+'%'};return _0x319941;}})});}_0x23cca4=_[_0x2119('0x49')]({},_0x23cca4,_0x2afbd8[_0x2119('0x4a')]);var _0x2ed15a={'where':_0x23cca4[_0x2119('0x48')]};return db[_0x2119('0x4b')][_0x2119('0x26')](_0x2ed15a)[_0x2119('0x2e')](function(_0x27301e){_0x25a539[_0x2119('0x26')]=_0x27301e;if(_0x2afbd8[_0x2119('0x3c')][_0x2119('0x4c')]){_0x23cca4[_0x2119('0x4d')]=[{'all':!![]}];}return db[_0x2119('0x4b')][_0x2119('0x4e')](_0x23cca4);})[_0x2119('0x2e')](function(_0x19800a){_0x25a539[_0x2119('0x4f')]=_0x19800a;return _0x25a539;})[_0x2119('0x2e')](respondWithFilteredResult(_0x100bb9,_0x23cca4))[_0x2119('0x50')](handleError(_0x100bb9,null));};exports[_0x2119('0x51')]=function(_0x521de6,_0x31cb41){var _0x1bc22c={'raw':![],'where':{'id':_0x521de6['params']['id']}},_0x6960fe={};_0x6960fe[_0x2119('0x3a')]=_[_0x2119('0x3b')](db[_0x2119('0x4b')][_0x2119('0x52')]);_0x6960fe[_0x2119('0x3c')]=_['keys'](_0x521de6['query']);_0x6960fe['filters']=_[_0x2119('0x3e')](_0x6960fe[_0x2119('0x3a')],_0x6960fe['query']);_0x1bc22c[_0x2119('0x3f')]=_['intersection'](_0x6960fe[_0x2119('0x3a')],qs[_0x2119('0x53')](_0x521de6[_0x2119('0x3c')][_0x2119('0x53')]));_0x1bc22c[_0x2119('0x3f')]=_0x1bc22c[_0x2119('0x3f')][_0x2119('0x40')]?_0x1bc22c[_0x2119('0x3f')]:_0x6960fe[_0x2119('0x3a')];if(_0x521de6[_0x2119('0x3c')][_0x2119('0x4c')]){_0x1bc22c['include']=[{'all':!![]}];}_0x1bc22c=_[_0x2119('0x49')]({},_0x1bc22c,_0x521de6[_0x2119('0x4a')]);return db[_0x2119('0x4b')][_0x2119('0x54')](_0x1bc22c)[_0x2119('0x2e')](handleEntityNotFound(_0x31cb41,null))[_0x2119('0x2e')](respondWithResult(_0x31cb41,null))[_0x2119('0x50')](handleError(_0x31cb41,null));};exports[_0x2119('0x55')]=function(_0xab2a70,_0x217e42){return db['CmList'][_0x2119('0x55')](_0xab2a70['body'],{})[_0x2119('0x2e')](function(_0x365053){var _0x3d29cf=_0xab2a70[_0x2119('0x56')][_0x2119('0x57')]({'plain':!![]});if(!_0x3d29cf)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x3d29cf['role']==='user'){var _0x2a4bc6=_0x365053[_0x2119('0x57')]({'plain':!![]});var _0x45471c=_0x2119('0x30');return db[_0x2119('0x58')][_0x2119('0x54')]({'where':{'name':_0x45471c,'userProfileId':_0x3d29cf['userProfileId']},'raw':!![]})[_0x2119('0x2e')](function(_0x4c72e0){if(_0x4c72e0&&_0x4c72e0[_0x2119('0x59')]===0x0){return db[_0x2119('0x5a')][_0x2119('0x55')]({'name':_0x2a4bc6['name'],'resourceId':_0x2a4bc6['id'],'type':_0x4c72e0[_0x2119('0x33')],'sectionId':_0x4c72e0['id']},{})[_0x2119('0x2e')](function(){return _0x365053;});}else{return _0x365053;}})[_0x2119('0x50')](function(_0x34d128){logger[_0x2119('0x31')](_0x2119('0x5b'),_0x34d128);throw _0x34d128;});}return _0x365053;})['then'](respondWithResult(_0x217e42,0xc9))[_0x2119('0x50')](handleError(_0x217e42,null));};exports[_0x2119('0x2d')]=function(_0x4b27ea,_0x28c963){if(_0x4b27ea['body']['id']){delete _0x4b27ea['body']['id'];}return db[_0x2119('0x4b')][_0x2119('0x54')]({'where':{'id':_0x4b27ea[_0x2119('0x5c')]['id']}})[_0x2119('0x2e')](handleEntityNotFound(_0x28c963,null))['then'](saveUpdates(_0x4b27ea[_0x2119('0x5d')],null))[_0x2119('0x2e')](respondWithResult(_0x28c963,null))[_0x2119('0x50')](handleError(_0x28c963,null));};exports[_0x2119('0x2f')]=function(_0x5c4b67,_0x141b20){return db[_0x2119('0x4b')]['find']({'where':{'id':_0x5c4b67[_0x2119('0x5c')]['id']}})[_0x2119('0x2e')](handleEntityNotFound(_0x141b20,null))['then'](removeEntity(_0x141b20,null))[_0x2119('0x50')](handleError(_0x141b20,null));};exports[_0x2119('0x5e')]=function(_0x286167,_0x2d41be){return db[_0x2119('0x4b')][_0x2119('0x5e')]()[_0x2119('0x2e')](respondWithResult(_0x2d41be,null))[_0x2119('0x50')](handleError(_0x2d41be,null));};exports[_0x2119('0x5f')]=function(_0x3c6366,_0x52d4f3,_0x18aef4){if(_0x3c6366[_0x2119('0x5d')]['id']){delete _0x3c6366['body']['id'];}return db[_0x2119('0x4b')]['find']({'where':{'id':_0x3c6366[_0x2119('0x5c')]['id']}})[_0x2119('0x2e')](handleEntityNotFound(_0x52d4f3,null))[_0x2119('0x2e')](function(_0x2acd3a){if(_0x2acd3a){_0x3c6366['body'][_0x2119('0x60')]=_0x2acd3a['id'];return db[_0x2119('0x61')]['create'](_0x3c6366[_0x2119('0x5d')]);}})[_0x2119('0x2e')](respondWithResult(_0x52d4f3,null))[_0x2119('0x50')](handleError(_0x52d4f3,null));};exports[_0x2119('0x62')]=function(_0x5061e2,_0xd1a955,_0x34e585){var _0x3bd697={'raw':![],'where':{}};var _0xefc5dc={};var _0x324938={'count':0x0,'rows':[]};return db['CmList'][_0x2119('0x63')]({'where':{'id':_0x5061e2[_0x2119('0x5c')]['id']}})['then'](handleEntityNotFound(_0xd1a955,null))['then'](function(_0x28fb67){if(_0x28fb67){_0xefc5dc[_0x2119('0x3a')]=_[_0x2119('0x3b')](db[_0x2119('0x61')][_0x2119('0x52')]);_0xefc5dc['query']=_[_0x2119('0x3b')](_0x5061e2[_0x2119('0x3c')]);_0xefc5dc[_0x2119('0x3d')]=_[_0x2119('0x3e')](_0xefc5dc['model'],_0xefc5dc[_0x2119('0x3c')]);_0x3bd697[_0x2119('0x3f')]=_[_0x2119('0x3e')](_0xefc5dc[_0x2119('0x3a')],qs[_0x2119('0x53')](_0x5061e2[_0x2119('0x3c')]['fields']));_0x3bd697[_0x2119('0x3f')]=_0x3bd697[_0x2119('0x3f')]['length']?_0x3bd697['attributes']:_0xefc5dc[_0x2119('0x3a')];if(!_0x5061e2['query'][_0x2119('0x41')]('nolimit')){_0x3bd697[_0x2119('0x43')]=qs[_0x2119('0x43')](_0x5061e2[_0x2119('0x3c')][_0x2119('0x43')]);_0x3bd697[_0x2119('0x27')]=qs[_0x2119('0x27')](_0x5061e2[_0x2119('0x3c')][_0x2119('0x27')]);}_0x3bd697['order']=qs['sort'](_0x5061e2[_0x2119('0x3c')]['sort']);_0x3bd697['where']=qs['filters'](_[_0x2119('0x46')](_0x5061e2[_0x2119('0x3c')],_0xefc5dc[_0x2119('0x3d')]));_0x3bd697[_0x2119('0x48')][_0x2119('0x60')]=_0x28fb67['id'];if(_0x5061e2[_0x2119('0x3c')][_0x2119('0x47')]){_0x3bd697['where']=_[_0x2119('0x49')](_0x3bd697[_0x2119('0x48')],{'$or':_[_0x2119('0x36')](_0x3bd697[_0x2119('0x3f')],function(_0x5c382e){var _0x3c390e={};_0x3c390e[_0x5c382e]={'$like':'%'+_0x5061e2[_0x2119('0x3c')]['filter']+'%'};return _0x3c390e;})});}_0x3bd697=_['merge']({},_0x3bd697,_0x5061e2[_0x2119('0x4a')]);return db[_0x2119('0x61')][_0x2119('0x26')]({'where':_0x3bd697[_0x2119('0x48')]})[_0x2119('0x2e')](function(_0x1b45e5){_0x324938[_0x2119('0x26')]=_0x1b45e5;if(_0x5061e2[_0x2119('0x3c')][_0x2119('0x4c')]){_0x3bd697[_0x2119('0x4d')]=[{'all':!![]}];}return db[_0x2119('0x61')]['findAll'](_0x3bd697);})[_0x2119('0x2e')](function(_0x1e8f52){_0x324938[_0x2119('0x4f')]=_0x1e8f52;return _0x324938;});}})['then'](respondWithFilteredResult(_0xd1a955,_0x3bd697))[_0x2119('0x50')](handleError(_0xd1a955,null));};exports[_0x2119('0x64')]=function(_0x1f25ab,_0x40a135,_0x32cc0e){return db[_0x2119('0x4b')][_0x2119('0x54')]({'where':{'id':_0x1f25ab['params']['id']}})[_0x2119('0x2e')](handleEntityNotFound(_0x40a135,null))['then'](function(_0x1314c4){if(_0x1314c4){return _0x1314c4[_0x2119('0x64')](_0x1f25ab[_0x2119('0x3c')][_0x2119('0x65')]);}})[_0x2119('0x2e')](respondWithStatusCode(_0x40a135,null))[_0x2119('0x50')](handleError(_0x40a135,null));};exports[_0x2119('0x66')]=function(_0x1bf5be,_0x5313a9,_0x5cfb8f){return db['CmList']['find']({'where':{'id':_0x1bf5be[_0x2119('0x5c')]['id']}})[_0x2119('0x2e')](handleEntityNotFound(_0x5313a9,null))[_0x2119('0x2e')](function(_0x18172d){if(_0x18172d){var _0x182e43=[];var _0x3f2ef1={'success':[],'errors':[]};return db[_0x2119('0x67')]['describe']()[_0x2119('0x2e')](function(_0xfaae23){if(_0x1bf5be[_0x2119('0x5d')]['tags']&&_[_0x2119('0x68')](_0x1bf5be[_0x2119('0x5d')][_0x2119('0x69')])){if(_0x1bf5be[_0x2119('0x5d')][_0x2119('0x69')][_0x2119('0x40')]){_0x1bf5be[_0x2119('0x5d')][_0x2119('0x69')]=_0x1bf5be[_0x2119('0x5d')][_0x2119('0x69')][_0x2119('0x6a')](';')+';';}else{_0x1bf5be['body']['tags']=null;}}else{_0x1bf5be[_0x2119('0x5d')][_0x2119('0x69')]=null;}if(_0x1bf5be['body']&&_['isArray'](_0x1bf5be[_0x2119('0x5d')])){for(var _0x349bbd=0x0;_0x349bbd<_0x1bf5be[_0x2119('0x5d')][_0x2119('0x40')];_0x349bbd+=0x1){_0x1bf5be[_0x2119('0x5d')][_0x349bbd][_0x2119('0x60')]=_0x1bf5be[_0x2119('0x5c')]['id'];_0x182e43[_0x2119('0x6b')](_0x1bf5be[_0x2119('0x5d')][_0x349bbd]);}return BPromise[_0x2119('0x6c')](_0x182e43,function(_0x559b5b){return db[_0x2119('0x67')][_0x2119('0x55')](_[_0x2119('0x6d')](_0x559b5b,[_0x2119('0x65'),'id'])||{},{'fields':_[_0x2119('0x3b')](_0xfaae23),'raw':!![]})['then'](function(_0x5dd21d){_0x3f2ef1[_0x2119('0x6e')][_0x2119('0x6b')](_0x5dd21d[_0x2119('0x6f')]);})[_0x2119('0x50')](function(_0x5410a3){_0x3f2ef1['errors'][_0x2119('0x6b')]({'data':_0x559b5b,'error':_0x5410a3[_0x2119('0x70')]});});})[_0x2119('0x2e')](function(_0x359099){return _0x3f2ef1;})[_0x2119('0x50')](function(_0x1760fa){return _0x1760fa;});}else{_0x5313a9['status'](0x190)[_0x2119('0x25')]({'message':_0x2119('0x71')});}});}})[_0x2119('0x2e')](respondWithResult(_0x5313a9,null))[_0x2119('0x50')](handleError(_0x5313a9,null));};exports[_0x2119('0x72')]=function(_0x374921,_0xb82688,_0x10cd2d){var _0x31c5b0;return db[_0x2119('0x4b')][_0x2119('0x54')]({'where':{'id':_0x374921[_0x2119('0x5c')]['id']},'include':[{'model':db['CmCustomField'],'as':_0x2119('0x73')}]})[_0x2119('0x2e')](handleEntityNotFound(_0xb82688,null))['then'](function(_0x4cde75){if(_0x4cde75){_0x31c5b0=_0x4cde75;return db['CmContact'][_0x2119('0x52')];}})['then'](function(_0x1e364f){if(_0x1e364f){var _0x1461c3={};var _0x1a729f={};_0x1a729f[_0x2119('0x3a')]=_[_0x2119('0x74')](_[_0x2119('0x3b')](_0x1e364f),_[_0x2119('0x36')](_0x31c5b0[_0x2119('0x73')],function(_0x2f8906){return util[_0x2119('0x75')](_0x2119('0x76'),_0x2f8906['id']);}));_0x1a729f['query']=_[_0x2119('0x3b')](_0x374921['query']);_0x1a729f[_0x2119('0x3d')]=_['intersection'](_0x1a729f['model'],_0x1a729f[_0x2119('0x3c')]);_0x1461c3[_0x2119('0x3f')]=_['intersection'](_0x1a729f['model'],qs[_0x2119('0x53')](_0x374921[_0x2119('0x3c')][_0x2119('0x53')]));_0x1461c3[_0x2119('0x3f')]=_0x1461c3[_0x2119('0x3f')][_0x2119('0x40')]?_0x1461c3[_0x2119('0x3f')]:_0x1a729f[_0x2119('0x3a')];if(!_0x374921[_0x2119('0x3c')][_0x2119('0x41')](_0x2119('0x42'))){_0x1461c3[_0x2119('0x43')]=qs[_0x2119('0x43')](_0x374921['query']['limit']);_0x1461c3[_0x2119('0x27')]=qs[_0x2119('0x27')](_0x374921['query'][_0x2119('0x27')]);}_0x1461c3[_0x2119('0x44')]=qs[_0x2119('0x45')](_0x374921[_0x2119('0x3c')][_0x2119('0x45')]);_0x1461c3[_0x2119('0x48')]=qs[_0x2119('0x3d')](_[_0x2119('0x46')](_0x374921[_0x2119('0x3c')],_0x1a729f[_0x2119('0x3d')]));_0x1461c3['raw']=!![];if(_0x374921[_0x2119('0x3c')][_0x2119('0x47')]){_0x1461c3[_0x2119('0x48')]=_['merge'](_0x1461c3['where'],{'$or':_[_0x2119('0x36')](_0x1461c3['attributes'],function(_0x23c788){var _0x1a690c={};_0x1a690c[_0x23c788]={'$like':'%'+_0x374921[_0x2119('0x3c')][_0x2119('0x47')]+'%'};return _0x1a690c;})});}_0x1461c3=_['merge']({},_0x1461c3,_0x374921[_0x2119('0x4a')]);return _0x31c5b0[_0x2119('0x72')](_0x1461c3);}})[_0x2119('0x2e')](respondWithResult(_0xb82688,null))[_0x2119('0x50')](handleError(_0xb82688,null));};exports['getContactsCsv']=function(_0x5e86ff,_0x3888ec,_0x372fb4){var _0x19033f;return db[_0x2119('0x4b')][_0x2119('0x54')]({'where':{'id':_0x5e86ff[_0x2119('0x5c')]['id']},'include':[{'model':db[_0x2119('0x77')],'as':'CustomFields'}]})['then'](handleEntityNotFound(_0x3888ec,null))[_0x2119('0x2e')](function(_0x5a0a46){if(_0x5a0a46){_0x19033f=_0x5a0a46;return db[_0x2119('0x67')][_0x2119('0x52')];}})[_0x2119('0x2e')](function(_0x32e753){if(_0x32e753){var _0xd14bd9={};var _0x3b8ac6={};_0x3b8ac6['model']=_[_0x2119('0x74')](_[_0x2119('0x3b')](_0x32e753),_[_0x2119('0x36')](_0x19033f[_0x2119('0x73')],function(_0x99f770){return util[_0x2119('0x75')](_0x2119('0x76'),_0x99f770['id']);}));_0x3b8ac6[_0x2119('0x3c')]=_[_0x2119('0x3b')](_0x5e86ff[_0x2119('0x3c')]);_0x3b8ac6['filters']=_['intersection'](_0x3b8ac6[_0x2119('0x3a')],_0x3b8ac6[_0x2119('0x3c')]);_0xd14bd9[_0x2119('0x3f')]=_[_0x2119('0x3e')](_0x3b8ac6[_0x2119('0x3a')],qs[_0x2119('0x53')](_0x5e86ff[_0x2119('0x3c')][_0x2119('0x53')]));_0xd14bd9['attributes']=_0xd14bd9['attributes']['length']?_0xd14bd9[_0x2119('0x3f')]:_0x3b8ac6['model'];if(!_0x5e86ff[_0x2119('0x3c')][_0x2119('0x41')]('nolimit')){_0xd14bd9[_0x2119('0x43')]=qs[_0x2119('0x43')](_0x5e86ff[_0x2119('0x3c')]['limit']);_0xd14bd9[_0x2119('0x27')]=qs[_0x2119('0x27')](_0x5e86ff['query']['offset']);}_0xd14bd9[_0x2119('0x44')]=qs['sort'](_0x5e86ff[_0x2119('0x3c')]['sort']);_0xd14bd9['where']=qs[_0x2119('0x3d')](_[_0x2119('0x46')](_0x5e86ff['query'],_0x3b8ac6[_0x2119('0x3d')]));_0xd14bd9[_0x2119('0x78')]=!![];if(_0x5e86ff[_0x2119('0x3c')][_0x2119('0x47')]){_0xd14bd9[_0x2119('0x48')]=_[_0x2119('0x49')](_0xd14bd9[_0x2119('0x48')],{'$or':_[_0x2119('0x36')](_0xd14bd9[_0x2119('0x3f')],function(_0x5c0173){var _0x1af33b={};_0x1af33b[_0x5c0173]={'$like':'%'+_0x5e86ff[_0x2119('0x3c')][_0x2119('0x47')]+'%'};return _0x1af33b;})});}_0xd14bd9=_[_0x2119('0x49')]({},_0xd14bd9,_0x5e86ff[_0x2119('0x4a')]);return _0x19033f['getContacts'](_0xd14bd9);}})[_0x2119('0x2e')](function(_0x5ac320){if(!_['isEmpty'](_0x5ac320)){var _0x447283=toCsv(_0x5ac320);var _0x3d818a=Date[_0x2119('0x79')]();fs[_0x2119('0x7a')](util[_0x2119('0x75')](_0x2119('0x7b'),_0x19033f['id'],_0x3d818a),_0x447283);_0x3888ec[_0x2119('0x7c')]('Content-disposition','attachment;\x20filename='+util[_0x2119('0x75')](_0x2119('0x7d'),_0x19033f['id'],_0x3d818a));_0x3888ec[_0x2119('0x7c')](_0x2119('0x7e'),'text/csv');return _0x3888ec[_0x2119('0x7f')](util[_0x2119('0x75')](_0x2119('0x7b'),_0x19033f['id'],_0x3d818a));}else{return _0x3888ec['sendStatus'](0xcc);}})[_0x2119('0x50')](handleError(_0x3888ec,null));};exports[_0x2119('0x80')]=function(_0x2ab945,_0x2e3866,_0x416612){var _0x9bb937;delete _0x2ab945[_0x2119('0x5d')]['id'];return db[_0x2119('0x4b')][_0x2119('0x63')]({'where':{'id':_0x2ab945[_0x2119('0x5c')]['id']}})[_0x2119('0x2e')](handleEntityNotFound(_0x2e3866,null))[_0x2119('0x2e')](function(_0x788a6){if(_0x788a6){return db[_0x2119('0x81')][_0x2119('0x82')](function(_0x5350e2){return db[_0x2119('0x77')]['create'](_0x2ab945[_0x2119('0x5d')],{'transaction':_0x5350e2})['then'](function(_0x3eaf12){_0x9bb937=_0x3eaf12;return _0x788a6[_0x2119('0x83')](_0x3eaf12,{'transaction':_0x5350e2});})[_0x2119('0x2e')](function(){var _0x42c059={'type':db['Sequelize']['TEXT'],'transaction':_0x5350e2};switch(_0x2ab945[_0x2119('0x5d')][_0x2119('0x38')]){case _0x2119('0x84'):_0x42c059['type']=db[_0x2119('0x85')][_0x2119('0x86')];break;case _0x2119('0x87'):_0x42c059[_0x2119('0x38')]=db[_0x2119('0x85')][_0x2119('0x88')];break;case _0x2119('0x89'):_0x42c059[_0x2119('0x38')]=db['Sequelize'][_0x2119('0x8a')];_0x42c059[_0x2119('0x8b')]=![];break;default:}return db[_0x2119('0x81')][_0x2119('0x8c')][_0x2119('0x8d')](_0x2119('0x8e'),util[_0x2119('0x75')](_0x2119('0x8f'),_0x9bb937['id']),_0x42c059);})[_0x2119('0x2e')](function(){return _0x9bb937;});});}})[_0x2119('0x2e')](respondWithResult(_0x2e3866,null))[_0x2119('0x50')](handleError(_0x2e3866,null));};exports['getCustomFields']=function(_0x48a3df,_0x2d6455,_0x25b3f6){var _0x359ec8={};var _0x4cd628={};var _0x36bc18;var _0x17bc9f;return db[_0x2119('0x4b')][_0x2119('0x63')]({'where':{'id':_0x48a3df[_0x2119('0x5c')]['id']}})['then'](handleEntityNotFound(_0x2d6455,null))['then'](function(_0x5bef71){if(_0x5bef71){_0x36bc18=_0x5bef71;_0x4cd628[_0x2119('0x3a')]=_[_0x2119('0x3b')](db['CmCustomField'][_0x2119('0x52')]);_0x4cd628[_0x2119('0x3c')]=_[_0x2119('0x3b')](_0x48a3df[_0x2119('0x3c')]);_0x4cd628[_0x2119('0x3d')]=_[_0x2119('0x3e')](_0x4cd628['model'],_0x4cd628['query']);_0x359ec8[_0x2119('0x3f')]=_[_0x2119('0x3e')](_0x4cd628[_0x2119('0x3a')],qs['fields'](_0x48a3df[_0x2119('0x3c')][_0x2119('0x53')]));_0x359ec8['attributes']=_0x359ec8[_0x2119('0x3f')][_0x2119('0x40')]?_0x359ec8[_0x2119('0x3f')]:_0x4cd628[_0x2119('0x3a')];_0x359ec8['order']=qs['sort'](_0x48a3df['query'][_0x2119('0x45')]);_0x359ec8['where']=qs[_0x2119('0x3d')](_['pick'](_0x48a3df[_0x2119('0x3c')],_0x4cd628['filters']));_0x359ec8[_0x2119('0x48')]=_['merge'](_0x359ec8[_0x2119('0x48')],{'$or':[{'ListId':_0x5bef71['id']},{'ListId':null}]});if(_0x48a3df['query'][_0x2119('0x47')]){_0x359ec8[_0x2119('0x48')]=_[_0x2119('0x49')](_0x359ec8[_0x2119('0x48')],{'$or':_[_0x2119('0x36')](_0x359ec8[_0x2119('0x3f')],function(_0x53e071){var _0x1d6746={};_0x1d6746[_0x53e071]={'$like':'%'+_0x48a3df[_0x2119('0x3c')][_0x2119('0x47')]+'%'};return _0x1d6746;})});}_0x359ec8=_[_0x2119('0x49')]({},_0x359ec8,_0x48a3df[_0x2119('0x4a')]);return db[_0x2119('0x77')]['findAndCountAll'](_0x359ec8);}})[_0x2119('0x2e')](respondWithResult(_0x2d6455,null))[_0x2119('0x50')](handleError(_0x2d6455,null));};exports[_0x2119('0x90')]=function(_0x532a05,_0x393f8f,_0x5efabe){return db['CmList'][_0x2119('0x54')]({'where':{'id':_0x532a05[_0x2119('0x5c')]['id']}})['then'](handleEntityNotFound(_0x393f8f,null))['then'](function(_0x20bf8e){if(_0x20bf8e){return _0x20bf8e[_0x2119('0x90')](_0x532a05['body'][_0x2119('0x65')],_[_0x2119('0x6d')](_0x532a05[_0x2119('0x5d')],[_0x2119('0x65'),'id'])||{})[_0x2119('0x91')](function(_0x42eb54){for(var _0x250992=0x0;_0x250992<_0x532a05[_0x2119('0x5d')][_0x2119('0x65')][_0x2119('0x40')];_0x250992+=0x1){socket[_0x2119('0x92')]('userCmList:save',{'UserId':_0x532a05[_0x2119('0x5d')][_0x2119('0x65')][_0x250992],'CmListId':_0x532a05[_0x2119('0x5c')]['id']});}return _0x42eb54;});}})['then'](respondWithResult(_0x393f8f,null))['catch'](handleError(_0x393f8f,null));};exports[_0x2119('0x93')]=function(_0x551b54,_0x53d400,_0xf9d398){return db[_0x2119('0x4b')][_0x2119('0x54')]({'where':{'id':_0x551b54[_0x2119('0x5c')]['id']}})['then'](handleEntityNotFound(_0x53d400,null))[_0x2119('0x2e')](function(_0x25a23d){if(_0x25a23d){return _0x25a23d[_0x2119('0x93')](_0x551b54[_0x2119('0x3c')][_0x2119('0x65')])[_0x2119('0x2e')](function(){if(_[_0x2119('0x68')](_0x551b54[_0x2119('0x3c')][_0x2119('0x65')])){for(var _0x2d311f=0x0;_0x2d311f<_0x551b54[_0x2119('0x3c')][_0x2119('0x65')][_0x2119('0x40')];_0x2d311f+=0x1){socket['emit'](_0x2119('0x94'),{'UserId':Number(_0x551b54['query'][_0x2119('0x65')][_0x2d311f]),'CmListId':Number(_0x551b54['params']['id'])});}}else{socket[_0x2119('0x92')](_0x2119('0x94'),{'UserId':Number(_0x551b54['query'][_0x2119('0x65')]),'CmListId':Number(_0x551b54[_0x2119('0x5c')]['id'])});}});}})[_0x2119('0x2e')](respondWithStatusCode(_0x53d400,null))[_0x2119('0x50')](handleError(_0x53d400,null));};exports[_0x2119('0x95')]=function(_0x3a2a9a,_0x50df5e,_0x38ec96){var _0x365949={};var _0x4d8501={};var _0xc7bd54;var _0x5f1d79;return db[_0x2119('0x4b')]['findOne']({'where':{'id':_0x3a2a9a[_0x2119('0x5c')]['id']}})[_0x2119('0x2e')](handleEntityNotFound(_0x50df5e,null))['then'](function(_0x45a4de){if(_0x45a4de){_0xc7bd54=_0x45a4de;_0x4d8501[_0x2119('0x3a')]=_[_0x2119('0x3b')](db[_0x2119('0x96')][_0x2119('0x52')]);_0x4d8501['query']=_[_0x2119('0x3b')](_0x3a2a9a[_0x2119('0x3c')]);_0x4d8501[_0x2119('0x3d')]=_[_0x2119('0x3e')](_0x4d8501[_0x2119('0x3a')],_0x4d8501[_0x2119('0x3c')]);_0x365949[_0x2119('0x3f')]=_['intersection'](_0x4d8501[_0x2119('0x3a')],qs['fields'](_0x3a2a9a[_0x2119('0x3c')][_0x2119('0x53')]));_0x365949[_0x2119('0x3f')]=_0x365949[_0x2119('0x3f')][_0x2119('0x40')]?_0x365949[_0x2119('0x3f')]:_0x4d8501[_0x2119('0x3a')];_0x365949['order']=qs['sort'](_0x3a2a9a['query'][_0x2119('0x45')]);_0x365949[_0x2119('0x48')]=qs['filters'](_['pick'](_0x3a2a9a[_0x2119('0x3c')],_0x4d8501[_0x2119('0x3d')]));if(_0x3a2a9a[_0x2119('0x3c')][_0x2119('0x47')]){_0x365949[_0x2119('0x48')]=_[_0x2119('0x49')](_0x365949[_0x2119('0x48')],{'$or':_[_0x2119('0x36')](_0x365949[_0x2119('0x3f')],function(_0x14a898){var _0x304eb5={};_0x304eb5[_0x14a898]={'$like':'%'+_0x3a2a9a['query'][_0x2119('0x47')]+'%'};return _0x304eb5;})});}_0x365949=_[_0x2119('0x49')]({},_0x365949,_0x3a2a9a[_0x2119('0x4a')]);return _0xc7bd54['getAgents'](_0x365949);}})[_0x2119('0x2e')](function(_0x19b045){if(_0x19b045){_0x5f1d79=_0x19b045[_0x2119('0x40')];if(!_0x3a2a9a['query'][_0x2119('0x41')]('nolimit')){_0x365949[_0x2119('0x43')]=qs[_0x2119('0x43')](_0x3a2a9a[_0x2119('0x3c')][_0x2119('0x43')]);_0x365949[_0x2119('0x27')]=qs['offset'](_0x3a2a9a[_0x2119('0x3c')]['offset']);}return _0xc7bd54['getAgents'](_0x365949);}})[_0x2119('0x2e')](function(_0x51c69e){if(_0x51c69e){return _0x51c69e?{'count':_0x5f1d79,'rows':_0x51c69e}:null;}})[_0x2119('0x2e')](respondWithResult(_0x50df5e,null))[_0x2119('0x50')](handleError(_0x50df5e,null));};
\ No newline at end of file