Built motion from commit 14588770.|2.5.38
[motion2.git] / server / api / cmList / cmList.controller.js
index 35c15d2..a3e3d10 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xf062=['role','UserProfileSection','autoAssociation','create','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','ListId','getDispositions','findOne','Disposition','hasOwnProperty','nolimit','where','includeAll','removeDispositions','ids','addContacts','CmContact','isArray','tags','join','push','each','success','dataValues','errors','message','CustomFields','concat','format','getContacts','getContactsCsv','CmCustomField','cf_%d','isEmpty','/tmp/list_%d_%s.csv','list_%d_%s.csv','setHeader','Content-type','text/csv','download','addCustomField','sequelize','transaction','Sequelize','text','TEXT','switch','BOOLEAN','addColumn','cf_%s','getCustomFields','findAndCountAll','addAgents','omit','spread','userCmList:save','removeAgents','emit','userCmList:remove','getAgents','User','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','mustache','util','path','sox','to-csv','ejs','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/license/util','../../mysqldb','redis','defaults','localhost','./cmList.socket','register','end','json','count','offset','limit','status','set','Content-Range','apply','reject','update','then','get','Lists','UserProfileResource','destroy','sendStatus','error','stack','name','send','map','fieldName','type','key','model','query','keys','filters','attributes','intersection','fields','length','order','sort','pick','merge','VIRTUAL','filter','options','CmList','findAll','rows','show','params','rawAttributes','find','catch','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user'];(function(_0x48ca86,_0x3f22cd){var _0x5ce419=function(_0x343ab4){while(--_0x343ab4){_0x48ca86['push'](_0x48ca86['shift']());}};_0x5ce419(++_0x3f22cd);}(_0xf062,0x162));var _0x2f06=function(_0x35758a,_0x2a7bcb){_0x35758a=_0x35758a-0x0;var _0x5db829=_0xf062[_0x35758a];return _0x5db829;};'use strict';var pdf=require(_0x2f06('0x0'));var emlformat=require(_0x2f06('0x1'));var rimraf=require(_0x2f06('0x2'));var zipdir=require(_0x2f06('0x3'));var jsonpatch=require(_0x2f06('0x4'));var rp=require(_0x2f06('0x5'));var moment=require('moment');var BPromise=require('bluebird');var Mustache=require(_0x2f06('0x6'));var util=require(_0x2f06('0x7'));var path=require(_0x2f06('0x8'));var sox=require(_0x2f06('0x9'));var csv=require(_0x2f06('0xa'));var ejs=require(_0x2f06('0xb'));var fs=require('fs');var _=require(_0x2f06('0xc'));var squel=require(_0x2f06('0xd'));var crypto=require(_0x2f06('0xe'));var jsforce=require(_0x2f06('0xf'));var deskjs=require(_0x2f06('0x10'));var toCsv=require(_0x2f06('0xa'));var querystring=require(_0x2f06('0x11'));var Papa=require(_0x2f06('0x12'));var Redis=require(_0x2f06('0x13'));var authService=require(_0x2f06('0x14'));var qs=require(_0x2f06('0x15'));var as=require(_0x2f06('0x16'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x2f06('0x17'))(_0x2f06('0x18'));var utils=require(_0x2f06('0x19'));var config=require('../../config/environment');var licenseUtil=require(_0x2f06('0x1a'));var db=require(_0x2f06('0x1b'))['db'];config[_0x2f06('0x1c')]=_[_0x2f06('0x1d')](config[_0x2f06('0x1c')],{'host':_0x2f06('0x1e'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x2f06('0x1c')]));require(_0x2f06('0x1f'))[_0x2f06('0x20')](socket);function respondWithStatusCode(_0x5913fd,_0x1aedbd){_0x1aedbd=_0x1aedbd||0xcc;return function(_0x17f5ca){if(_0x17f5ca){return _0x5913fd['sendStatus'](_0x1aedbd);}return _0x5913fd['status'](_0x1aedbd)[_0x2f06('0x21')]();};}function respondWithResult(_0xf8adef,_0x1f863c){_0x1f863c=_0x1f863c||0xc8;return function(_0x3f8281){if(_0x3f8281){return _0xf8adef['status'](_0x1f863c)[_0x2f06('0x22')](_0x3f8281);}};}function respondWithFilteredResult(_0x220e23,_0x2a9209){return function(_0x5b3ac9){if(_0x5b3ac9){var _0x15ba18=_0x5b3ac9[_0x2f06('0x23')],_0xa19baa=_0x2a9209[_0x2f06('0x24')],_0x4ef4db=_0x2a9209[_0x2f06('0x24')]+_0x2a9209[_0x2f06('0x25')],_0x35aed3;if(_0x4ef4db>=_0x15ba18){_0x4ef4db=_0x15ba18;_0x35aed3=0xc8;}else{_0x35aed3=0xce;}_0x220e23[_0x2f06('0x26')](_0x35aed3);return _0x220e23[_0x2f06('0x27')](_0x2f06('0x28'),_0xa19baa+'-'+_0x4ef4db+'/'+_0x15ba18)[_0x2f06('0x22')](_0x5b3ac9);}return null;};}function patchUpdates(_0x275f8b){return function(_0x808944){try{jsonpatch[_0x2f06('0x29')](_0x808944,_0x275f8b,!![]);}catch(_0x246286){return BPromise[_0x2f06('0x2a')](_0x246286);}return _0x808944['save']();};}function saveUpdates(_0x54ac12,_0x256780){return function(_0x51a739){if(_0x51a739){return _0x51a739[_0x2f06('0x2b')](_0x54ac12)[_0x2f06('0x2c')](function(_0x41c1a7){return _0x41c1a7;});}return null;};}function removeEntity(_0x114735,_0xd21b7e){return function(_0x1dee5c){if(_0x1dee5c){return _0x1dee5c['destroy']()['then'](function(){var _0x3e476e=_0x1dee5c[_0x2f06('0x2d')]({'plain':!![]});var _0x550478=_0x2f06('0x2e');return db[_0x2f06('0x2f')][_0x2f06('0x30')]({'where':{'type':_0x550478,'resourceId':_0x3e476e['id']}})[_0x2f06('0x2c')](function(){return _0x1dee5c;});})[_0x2f06('0x2c')](function(){_0x114735['status'](0xcc)[_0x2f06('0x21')]();});}};}function handleEntityNotFound(_0x2c6953,_0x3f39da){return function(_0x15e47d){if(!_0x15e47d){_0x2c6953[_0x2f06('0x31')](0x194);}return _0x15e47d;};}function handleError(_0x1cd5ea,_0xfa5259){_0xfa5259=_0xfa5259||0x1f4;return function(_0xc4d83f){logger[_0x2f06('0x32')](_0xc4d83f[_0x2f06('0x33')]);if(_0xc4d83f[_0x2f06('0x34')]){delete _0xc4d83f['name'];}_0x1cd5ea[_0x2f06('0x26')](_0xfa5259)[_0x2f06('0x35')](_0xc4d83f);};}exports['index']=function(_0x443210,_0x285cb6){var _0x1c3000={},_0x393049={},_0xa1f87={'count':0x0,'rows':[]};var _0xd13f29=_[_0x2f06('0x36')](db['CmList']['rawAttributes'],function(_0x51b03a){return{'name':_0x51b03a[_0x2f06('0x37')],'type':_0x51b03a[_0x2f06('0x38')][_0x2f06('0x39')]};});_0x393049[_0x2f06('0x3a')]=_[_0x2f06('0x36')](_0xd13f29,_0x2f06('0x34'));_0x393049[_0x2f06('0x3b')]=_[_0x2f06('0x3c')](_0x443210[_0x2f06('0x3b')]);_0x393049[_0x2f06('0x3d')]=_['intersection'](_0x393049['model'],_0x393049['query']);_0x1c3000[_0x2f06('0x3e')]=_[_0x2f06('0x3f')](_0x393049[_0x2f06('0x3a')],qs['fields'](_0x443210[_0x2f06('0x3b')][_0x2f06('0x40')]));_0x1c3000[_0x2f06('0x3e')]=_0x1c3000['attributes'][_0x2f06('0x41')]?_0x1c3000[_0x2f06('0x3e')]:_0x393049[_0x2f06('0x3a')];if(!_0x443210[_0x2f06('0x3b')]['hasOwnProperty']('nolimit')){_0x1c3000[_0x2f06('0x25')]=qs[_0x2f06('0x25')](_0x443210['query']['limit']);_0x1c3000[_0x2f06('0x24')]=qs[_0x2f06('0x24')](_0x443210[_0x2f06('0x3b')][_0x2f06('0x24')]);}_0x1c3000[_0x2f06('0x42')]=qs['sort'](_0x443210[_0x2f06('0x3b')][_0x2f06('0x43')]);_0x1c3000['where']=qs[_0x2f06('0x3d')](_[_0x2f06('0x44')](_0x443210['query'],_0x393049[_0x2f06('0x3d')]),_0xd13f29);if(_0x443210[_0x2f06('0x3b')]['filter']){_0x1c3000['where']=_[_0x2f06('0x45')](_0x1c3000['where'],{'$or':_['map'](_0xd13f29,function(_0x3c4170){if(_0x3c4170['type']!==_0x2f06('0x46')){var _0x41b335={};_0x41b335[_0x3c4170[_0x2f06('0x34')]]={'$like':'%'+_0x443210[_0x2f06('0x3b')][_0x2f06('0x47')]+'%'};return _0x41b335;}})});}_0x1c3000=_[_0x2f06('0x45')]({},_0x1c3000,_0x443210[_0x2f06('0x48')]);var _0x4f9dcd={'where':_0x1c3000['where']};return db['CmList'][_0x2f06('0x23')](_0x4f9dcd)[_0x2f06('0x2c')](function(_0x42662b){_0xa1f87[_0x2f06('0x23')]=_0x42662b;if(_0x443210[_0x2f06('0x3b')]['includeAll']){_0x1c3000['include']=[{'all':!![]}];}return db[_0x2f06('0x49')][_0x2f06('0x4a')](_0x1c3000);})[_0x2f06('0x2c')](function(_0x49134d){_0xa1f87[_0x2f06('0x4b')]=_0x49134d;return _0xa1f87;})[_0x2f06('0x2c')](respondWithFilteredResult(_0x285cb6,_0x1c3000))['catch'](handleError(_0x285cb6,null));};exports[_0x2f06('0x4c')]=function(_0x2145bc,_0x52fc6a){var _0x5acff9={'raw':![],'where':{'id':_0x2145bc[_0x2f06('0x4d')]['id']}},_0xf49826={};_0xf49826[_0x2f06('0x3a')]=_[_0x2f06('0x3c')](db[_0x2f06('0x49')][_0x2f06('0x4e')]);_0xf49826[_0x2f06('0x3b')]=_[_0x2f06('0x3c')](_0x2145bc[_0x2f06('0x3b')]);_0xf49826[_0x2f06('0x3d')]=_['intersection'](_0xf49826[_0x2f06('0x3a')],_0xf49826[_0x2f06('0x3b')]);_0x5acff9[_0x2f06('0x3e')]=_['intersection'](_0xf49826['model'],qs[_0x2f06('0x40')](_0x2145bc[_0x2f06('0x3b')][_0x2f06('0x40')]));_0x5acff9[_0x2f06('0x3e')]=_0x5acff9[_0x2f06('0x3e')][_0x2f06('0x41')]?_0x5acff9[_0x2f06('0x3e')]:_0xf49826['model'];if(_0x2145bc['query']['includeAll']){_0x5acff9['include']=[{'all':!![]}];}_0x5acff9=_[_0x2f06('0x45')]({},_0x5acff9,_0x2145bc[_0x2f06('0x48')]);return db[_0x2f06('0x49')][_0x2f06('0x4f')](_0x5acff9)['then'](handleEntityNotFound(_0x52fc6a,null))[_0x2f06('0x2c')](respondWithResult(_0x52fc6a,null))[_0x2f06('0x50')](handleError(_0x52fc6a,null));};exports['create']=function(_0x5af10a,_0x374b5d){return db[_0x2f06('0x49')]['create'](_0x5af10a[_0x2f06('0x51')],{})['then'](function(_0x3e3485){var _0x47bd5a=_0x5af10a[_0x2f06('0x52')][_0x2f06('0x2d')]({'plain':!![]});if(!_0x47bd5a)throw new Error(_0x2f06('0x53'));if(_0x47bd5a[_0x2f06('0x54')]===_0x2f06('0x52')){var _0x178506=_0x3e3485[_0x2f06('0x2d')]({'plain':!![]});var _0xcebc2b=_0x2f06('0x2e');return db[_0x2f06('0x55')][_0x2f06('0x4f')]({'where':{'name':_0xcebc2b,'userProfileId':_0x47bd5a['userProfileId']},'raw':!![]})[_0x2f06('0x2c')](function(_0x2abead){if(_0x2abead&&_0x2abead[_0x2f06('0x56')]===0x0){return db[_0x2f06('0x2f')][_0x2f06('0x57')]({'name':_0x178506['name'],'resourceId':_0x178506['id'],'type':_0x2abead[_0x2f06('0x34')],'sectionId':_0x2abead['id']},{})[_0x2f06('0x2c')](function(){return _0x3e3485;});}else{return _0x3e3485;}})['catch'](function(_0x550f6d){logger['error'](_0x2f06('0x58'),_0x550f6d);throw _0x550f6d;});}return _0x3e3485;})['then'](respondWithResult(_0x374b5d,0xc9))['catch'](handleError(_0x374b5d,null));};exports[_0x2f06('0x2b')]=function(_0x4e1810,_0x341ad5){if(_0x4e1810[_0x2f06('0x51')]['id']){delete _0x4e1810[_0x2f06('0x51')]['id'];}return db['CmList'][_0x2f06('0x4f')]({'where':{'id':_0x4e1810[_0x2f06('0x4d')]['id']}})['then'](handleEntityNotFound(_0x341ad5,null))['then'](saveUpdates(_0x4e1810[_0x2f06('0x51')],null))[_0x2f06('0x2c')](respondWithResult(_0x341ad5,null))[_0x2f06('0x50')](handleError(_0x341ad5,null));};exports[_0x2f06('0x30')]=function(_0x5c7da6,_0xc64733){return db[_0x2f06('0x49')][_0x2f06('0x4f')]({'where':{'id':_0x5c7da6[_0x2f06('0x4d')]['id']}})[_0x2f06('0x2c')](handleEntityNotFound(_0xc64733,null))[_0x2f06('0x2c')](removeEntity(_0xc64733,null))['catch'](handleError(_0xc64733,null));};exports[_0x2f06('0x59')]=function(_0x14d749,_0x5bb1b3){return db[_0x2f06('0x49')][_0x2f06('0x59')]()[_0x2f06('0x2c')](respondWithResult(_0x5bb1b3,null))['catch'](handleError(_0x5bb1b3,null));};exports['addDisposition']=function(_0x3ed00f,_0x48edc1,_0x12d133){if(_0x3ed00f[_0x2f06('0x51')]['id']){delete _0x3ed00f[_0x2f06('0x51')]['id'];}return db[_0x2f06('0x49')][_0x2f06('0x4f')]({'where':{'id':_0x3ed00f[_0x2f06('0x4d')]['id']}})[_0x2f06('0x2c')](handleEntityNotFound(_0x48edc1,null))['then'](function(_0x306c40){if(_0x306c40){_0x3ed00f[_0x2f06('0x51')][_0x2f06('0x5a')]=_0x306c40['id'];return db['Disposition'][_0x2f06('0x57')](_0x3ed00f['body']);}})[_0x2f06('0x2c')](respondWithResult(_0x48edc1,null))[_0x2f06('0x50')](handleError(_0x48edc1,null));};exports[_0x2f06('0x5b')]=function(_0x32581a,_0x211676,_0x290e57){var _0x8f064b={'raw':![],'where':{}};var _0x4dfff8={};var _0x2d255e={'count':0x0,'rows':[]};return db[_0x2f06('0x49')][_0x2f06('0x5c')]({'where':{'id':_0x32581a[_0x2f06('0x4d')]['id']}})[_0x2f06('0x2c')](handleEntityNotFound(_0x211676,null))['then'](function(_0x49e9c0){if(_0x49e9c0){_0x4dfff8[_0x2f06('0x3a')]=_[_0x2f06('0x3c')](db[_0x2f06('0x5d')]['rawAttributes']);_0x4dfff8[_0x2f06('0x3b')]=_[_0x2f06('0x3c')](_0x32581a[_0x2f06('0x3b')]);_0x4dfff8[_0x2f06('0x3d')]=_[_0x2f06('0x3f')](_0x4dfff8[_0x2f06('0x3a')],_0x4dfff8[_0x2f06('0x3b')]);_0x8f064b[_0x2f06('0x3e')]=_[_0x2f06('0x3f')](_0x4dfff8[_0x2f06('0x3a')],qs['fields'](_0x32581a[_0x2f06('0x3b')][_0x2f06('0x40')]));_0x8f064b['attributes']=_0x8f064b[_0x2f06('0x3e')]['length']?_0x8f064b[_0x2f06('0x3e')]:_0x4dfff8['model'];if(!_0x32581a[_0x2f06('0x3b')][_0x2f06('0x5e')](_0x2f06('0x5f'))){_0x8f064b[_0x2f06('0x25')]=qs[_0x2f06('0x25')](_0x32581a[_0x2f06('0x3b')][_0x2f06('0x25')]);_0x8f064b[_0x2f06('0x24')]=qs[_0x2f06('0x24')](_0x32581a[_0x2f06('0x3b')][_0x2f06('0x24')]);}_0x8f064b[_0x2f06('0x42')]=qs[_0x2f06('0x43')](_0x32581a[_0x2f06('0x3b')][_0x2f06('0x43')]);_0x8f064b['where']=qs[_0x2f06('0x3d')](_[_0x2f06('0x44')](_0x32581a[_0x2f06('0x3b')],_0x4dfff8[_0x2f06('0x3d')]));_0x8f064b['where'][_0x2f06('0x5a')]=_0x49e9c0['id'];if(_0x32581a[_0x2f06('0x3b')][_0x2f06('0x47')]){_0x8f064b[_0x2f06('0x60')]=_[_0x2f06('0x45')](_0x8f064b['where'],{'$or':_[_0x2f06('0x36')](_0x8f064b[_0x2f06('0x3e')],function(_0x5c42ec){var _0x3975ab={};_0x3975ab[_0x5c42ec]={'$like':'%'+_0x32581a[_0x2f06('0x3b')][_0x2f06('0x47')]+'%'};return _0x3975ab;})});}_0x8f064b=_[_0x2f06('0x45')]({},_0x8f064b,_0x32581a[_0x2f06('0x48')]);return db['Disposition'][_0x2f06('0x23')]({'where':_0x8f064b[_0x2f06('0x60')]})[_0x2f06('0x2c')](function(_0x4ce99d){_0x2d255e[_0x2f06('0x23')]=_0x4ce99d;if(_0x32581a['query'][_0x2f06('0x61')]){_0x8f064b['include']=[{'all':!![]}];}return db[_0x2f06('0x5d')][_0x2f06('0x4a')](_0x8f064b);})[_0x2f06('0x2c')](function(_0x9652a5){_0x2d255e['rows']=_0x9652a5;return _0x2d255e;});}})[_0x2f06('0x2c')](respondWithFilteredResult(_0x211676,_0x8f064b))[_0x2f06('0x50')](handleError(_0x211676,null));};exports[_0x2f06('0x62')]=function(_0xe17716,_0x46cba1,_0xcc1ac8){return db[_0x2f06('0x49')][_0x2f06('0x4f')]({'where':{'id':_0xe17716['params']['id']}})[_0x2f06('0x2c')](handleEntityNotFound(_0x46cba1,null))['then'](function(_0xfd3172){if(_0xfd3172){return _0xfd3172[_0x2f06('0x62')](_0xe17716[_0x2f06('0x3b')][_0x2f06('0x63')]);}})[_0x2f06('0x2c')](respondWithStatusCode(_0x46cba1,null))[_0x2f06('0x50')](handleError(_0x46cba1,null));};exports[_0x2f06('0x64')]=function(_0x1e1d02,_0x356dd2,_0x176150){return db['CmList']['find']({'where':{'id':_0x1e1d02[_0x2f06('0x4d')]['id']}})[_0x2f06('0x2c')](handleEntityNotFound(_0x356dd2,null))[_0x2f06('0x2c')](function(_0x333192){if(_0x333192){var _0x3fb6fb=[];var _0x1e22aa={'success':[],'errors':[]};return db[_0x2f06('0x65')][_0x2f06('0x59')]()[_0x2f06('0x2c')](function(_0x4bfebb){if(_0x1e1d02[_0x2f06('0x51')]['tags']&&_[_0x2f06('0x66')](_0x1e1d02[_0x2f06('0x51')][_0x2f06('0x67')])){if(_0x1e1d02[_0x2f06('0x51')][_0x2f06('0x67')][_0x2f06('0x41')]){_0x1e1d02[_0x2f06('0x51')]['tags']=_0x1e1d02['body'][_0x2f06('0x67')][_0x2f06('0x68')](';')+';';}else{_0x1e1d02[_0x2f06('0x51')][_0x2f06('0x67')]=null;}}else{_0x1e1d02[_0x2f06('0x51')][_0x2f06('0x67')]=null;}if(_0x1e1d02[_0x2f06('0x51')]&&_['isArray'](_0x1e1d02[_0x2f06('0x51')])){for(var _0x111088=0x0;_0x111088<_0x1e1d02[_0x2f06('0x51')]['length'];_0x111088+=0x1){_0x1e1d02[_0x2f06('0x51')][_0x111088][_0x2f06('0x5a')]=_0x1e1d02[_0x2f06('0x4d')]['id'];_0x3fb6fb[_0x2f06('0x69')](_0x1e1d02[_0x2f06('0x51')][_0x111088]);}return BPromise[_0x2f06('0x6a')](_0x3fb6fb,function(_0xbc9427){return db[_0x2f06('0x65')]['create'](_['omit'](_0xbc9427,[_0x2f06('0x63'),'id'])||{},{'fields':_['keys'](_0x4bfebb),'raw':!![]})[_0x2f06('0x2c')](function(_0x21a0ce){_0x1e22aa[_0x2f06('0x6b')][_0x2f06('0x69')](_0x21a0ce[_0x2f06('0x6c')]);})[_0x2f06('0x50')](function(_0x586d93){_0x1e22aa[_0x2f06('0x6d')][_0x2f06('0x69')]({'data':_0xbc9427,'error':_0x586d93[_0x2f06('0x6e')]});});})[_0x2f06('0x2c')](function(_0x4f046d){return _0x1e22aa;})['catch'](function(_0x225d00){return _0x225d00;});}else{_0x356dd2[_0x2f06('0x26')](0x190)[_0x2f06('0x22')]({'message':'Malformed\x20request\x20syntax'});}});}})[_0x2f06('0x2c')](respondWithResult(_0x356dd2,null))['catch'](handleError(_0x356dd2,null));};exports['getContacts']=function(_0x388870,_0x114493,_0x2cf3c7){var _0x44f72e;return db[_0x2f06('0x49')][_0x2f06('0x4f')]({'where':{'id':_0x388870['params']['id']},'include':[{'model':db['CmCustomField'],'as':_0x2f06('0x6f')}]})[_0x2f06('0x2c')](handleEntityNotFound(_0x114493,null))[_0x2f06('0x2c')](function(_0x30ad5c){if(_0x30ad5c){_0x44f72e=_0x30ad5c;return db[_0x2f06('0x65')][_0x2f06('0x4e')];}})[_0x2f06('0x2c')](function(_0x2ffc2e){if(_0x2ffc2e){var _0x2ff318={};var _0x44ecc3={};_0x44ecc3['model']=_[_0x2f06('0x70')](_[_0x2f06('0x3c')](_0x2ffc2e),_[_0x2f06('0x36')](_0x44f72e[_0x2f06('0x6f')],function(_0x141483){return util[_0x2f06('0x71')]('cf_%d',_0x141483['id']);}));_0x44ecc3[_0x2f06('0x3b')]=_[_0x2f06('0x3c')](_0x388870[_0x2f06('0x3b')]);_0x44ecc3[_0x2f06('0x3d')]=_[_0x2f06('0x3f')](_0x44ecc3['model'],_0x44ecc3[_0x2f06('0x3b')]);_0x2ff318['attributes']=_[_0x2f06('0x3f')](_0x44ecc3[_0x2f06('0x3a')],qs[_0x2f06('0x40')](_0x388870[_0x2f06('0x3b')]['fields']));_0x2ff318['attributes']=_0x2ff318[_0x2f06('0x3e')]['length']?_0x2ff318['attributes']:_0x44ecc3['model'];if(!_0x388870[_0x2f06('0x3b')]['hasOwnProperty']('nolimit')){_0x2ff318[_0x2f06('0x25')]=qs['limit'](_0x388870[_0x2f06('0x3b')][_0x2f06('0x25')]);_0x2ff318['offset']=qs[_0x2f06('0x24')](_0x388870[_0x2f06('0x3b')][_0x2f06('0x24')]);}_0x2ff318[_0x2f06('0x42')]=qs[_0x2f06('0x43')](_0x388870[_0x2f06('0x3b')][_0x2f06('0x43')]);_0x2ff318['where']=qs[_0x2f06('0x3d')](_['pick'](_0x388870['query'],_0x44ecc3[_0x2f06('0x3d')]));_0x2ff318['raw']=!![];if(_0x388870[_0x2f06('0x3b')][_0x2f06('0x47')]){_0x2ff318[_0x2f06('0x60')]=_[_0x2f06('0x45')](_0x2ff318['where'],{'$or':_[_0x2f06('0x36')](_0x2ff318[_0x2f06('0x3e')],function(_0x4898bf){var _0x4dc659={};_0x4dc659[_0x4898bf]={'$like':'%'+_0x388870[_0x2f06('0x3b')][_0x2f06('0x47')]+'%'};return _0x4dc659;})});}_0x2ff318=_[_0x2f06('0x45')]({},_0x2ff318,_0x388870['options']);return _0x44f72e[_0x2f06('0x72')](_0x2ff318);}})[_0x2f06('0x2c')](respondWithResult(_0x114493,null))[_0x2f06('0x50')](handleError(_0x114493,null));};exports[_0x2f06('0x73')]=function(_0x3788b4,_0x1502f3,_0x12ad4f){var _0x207b7f;return db[_0x2f06('0x49')][_0x2f06('0x4f')]({'where':{'id':_0x3788b4[_0x2f06('0x4d')]['id']},'include':[{'model':db[_0x2f06('0x74')],'as':_0x2f06('0x6f')}]})[_0x2f06('0x2c')](handleEntityNotFound(_0x1502f3,null))['then'](function(_0x43761c){if(_0x43761c){_0x207b7f=_0x43761c;return db[_0x2f06('0x65')]['rawAttributes'];}})[_0x2f06('0x2c')](function(_0x21d33e){if(_0x21d33e){var _0x383121={};var _0x2ff125={};_0x2ff125[_0x2f06('0x3a')]=_['concat'](_['keys'](_0x21d33e),_[_0x2f06('0x36')](_0x207b7f[_0x2f06('0x6f')],function(_0x5cb518){return util[_0x2f06('0x71')](_0x2f06('0x75'),_0x5cb518['id']);}));_0x2ff125['query']=_['keys'](_0x3788b4['query']);_0x2ff125[_0x2f06('0x3d')]=_['intersection'](_0x2ff125[_0x2f06('0x3a')],_0x2ff125[_0x2f06('0x3b')]);_0x383121[_0x2f06('0x3e')]=_[_0x2f06('0x3f')](_0x2ff125['model'],qs[_0x2f06('0x40')](_0x3788b4['query']['fields']));_0x383121[_0x2f06('0x3e')]=_0x383121[_0x2f06('0x3e')][_0x2f06('0x41')]?_0x383121['attributes']:_0x2ff125[_0x2f06('0x3a')];if(!_0x3788b4[_0x2f06('0x3b')][_0x2f06('0x5e')](_0x2f06('0x5f'))){_0x383121[_0x2f06('0x25')]=qs[_0x2f06('0x25')](_0x3788b4[_0x2f06('0x3b')][_0x2f06('0x25')]);_0x383121[_0x2f06('0x24')]=qs[_0x2f06('0x24')](_0x3788b4['query'][_0x2f06('0x24')]);}_0x383121[_0x2f06('0x42')]=qs[_0x2f06('0x43')](_0x3788b4[_0x2f06('0x3b')]['sort']);_0x383121[_0x2f06('0x60')]=qs[_0x2f06('0x3d')](_[_0x2f06('0x44')](_0x3788b4['query'],_0x2ff125[_0x2f06('0x3d')]));_0x383121['raw']=!![];if(_0x3788b4[_0x2f06('0x3b')][_0x2f06('0x47')]){_0x383121[_0x2f06('0x60')]=_[_0x2f06('0x45')](_0x383121[_0x2f06('0x60')],{'$or':_['map'](_0x383121[_0x2f06('0x3e')],function(_0x4fa8c4){var _0x19cc18={};_0x19cc18[_0x4fa8c4]={'$like':'%'+_0x3788b4[_0x2f06('0x3b')]['filter']+'%'};return _0x19cc18;})});}_0x383121=_[_0x2f06('0x45')]({},_0x383121,_0x3788b4[_0x2f06('0x48')]);return _0x207b7f['getContacts'](_0x383121);}})[_0x2f06('0x2c')](function(_0x218b91){if(!_[_0x2f06('0x76')](_0x218b91)){var _0x351490=toCsv(_0x218b91);var _0x2c18cc=Date['now']();fs['writeFileSync'](util[_0x2f06('0x71')](_0x2f06('0x77'),_0x207b7f['id'],_0x2c18cc),_0x351490);_0x1502f3['setHeader']('Content-disposition','attachment;\x20filename='+util[_0x2f06('0x71')](_0x2f06('0x78'),_0x207b7f['id'],_0x2c18cc));_0x1502f3[_0x2f06('0x79')](_0x2f06('0x7a'),_0x2f06('0x7b'));return _0x1502f3[_0x2f06('0x7c')](util['format'](_0x2f06('0x77'),_0x207b7f['id'],_0x2c18cc));}else{return _0x1502f3[_0x2f06('0x31')](0xcc);}})['catch'](handleError(_0x1502f3,null));};exports[_0x2f06('0x7d')]=function(_0x1375b4,_0x3e750c,_0x3285ba){var _0x5538c8;delete _0x1375b4[_0x2f06('0x51')]['id'];return db[_0x2f06('0x49')][_0x2f06('0x5c')]({'where':{'id':_0x1375b4[_0x2f06('0x4d')]['id']}})[_0x2f06('0x2c')](handleEntityNotFound(_0x3e750c,null))[_0x2f06('0x2c')](function(_0x3c4d47){if(_0x3c4d47){return db[_0x2f06('0x7e')][_0x2f06('0x7f')](function(_0x5c593f){return db[_0x2f06('0x74')][_0x2f06('0x57')](_0x1375b4['body'],{'transaction':_0x5c593f})['then'](function(_0x2137ee){_0x5538c8=_0x2137ee;return _0x3c4d47['addCustomFields'](_0x2137ee,{'transaction':_0x5c593f});})[_0x2f06('0x2c')](function(){var _0x4cea96={'type':db[_0x2f06('0x80')]['TEXT'],'transaction':_0x5c593f};switch(_0x1375b4[_0x2f06('0x51')][_0x2f06('0x38')]){case _0x2f06('0x81'):_0x4cea96[_0x2f06('0x38')]=db[_0x2f06('0x80')][_0x2f06('0x82')];break;case'number':_0x4cea96[_0x2f06('0x38')]=db[_0x2f06('0x80')]['INTEGER'];break;case _0x2f06('0x83'):_0x4cea96[_0x2f06('0x38')]=db[_0x2f06('0x80')][_0x2f06('0x84')];_0x4cea96['defaultValue']=![];break;default:}return db['sequelize']['queryInterface'][_0x2f06('0x85')]('cm_contacts',util[_0x2f06('0x71')](_0x2f06('0x86'),_0x5538c8['id']),_0x4cea96);})[_0x2f06('0x2c')](function(){return _0x5538c8;});});}})[_0x2f06('0x2c')](respondWithResult(_0x3e750c,null))['catch'](handleError(_0x3e750c,null));};exports[_0x2f06('0x87')]=function(_0x1973cc,_0x553f3a,_0x127173){var _0x1d6725={};var _0x590265={};var _0x15c4bd;var _0x246579;return db[_0x2f06('0x49')][_0x2f06('0x5c')]({'where':{'id':_0x1973cc['params']['id']}})[_0x2f06('0x2c')](handleEntityNotFound(_0x553f3a,null))[_0x2f06('0x2c')](function(_0x441cb3){if(_0x441cb3){_0x15c4bd=_0x441cb3;_0x590265[_0x2f06('0x3a')]=_['keys'](db[_0x2f06('0x74')]['rawAttributes']);_0x590265[_0x2f06('0x3b')]=_[_0x2f06('0x3c')](_0x1973cc['query']);_0x590265['filters']=_[_0x2f06('0x3f')](_0x590265[_0x2f06('0x3a')],_0x590265[_0x2f06('0x3b')]);_0x1d6725[_0x2f06('0x3e')]=_['intersection'](_0x590265[_0x2f06('0x3a')],qs['fields'](_0x1973cc['query'][_0x2f06('0x40')]));_0x1d6725['attributes']=_0x1d6725[_0x2f06('0x3e')][_0x2f06('0x41')]?_0x1d6725['attributes']:_0x590265[_0x2f06('0x3a')];_0x1d6725['order']=qs[_0x2f06('0x43')](_0x1973cc['query']['sort']);_0x1d6725[_0x2f06('0x60')]=qs[_0x2f06('0x3d')](_['pick'](_0x1973cc[_0x2f06('0x3b')],_0x590265[_0x2f06('0x3d')]));_0x1d6725[_0x2f06('0x60')]=_[_0x2f06('0x45')](_0x1d6725[_0x2f06('0x60')],{'$or':[{'ListId':_0x441cb3['id']},{'ListId':null}]});if(_0x1973cc[_0x2f06('0x3b')][_0x2f06('0x47')]){_0x1d6725[_0x2f06('0x60')]=_[_0x2f06('0x45')](_0x1d6725[_0x2f06('0x60')],{'$or':_[_0x2f06('0x36')](_0x1d6725[_0x2f06('0x3e')],function(_0x45955f){var _0x7a7edb={};_0x7a7edb[_0x45955f]={'$like':'%'+_0x1973cc['query'][_0x2f06('0x47')]+'%'};return _0x7a7edb;})});}_0x1d6725=_[_0x2f06('0x45')]({},_0x1d6725,_0x1973cc[_0x2f06('0x48')]);return db[_0x2f06('0x74')][_0x2f06('0x88')](_0x1d6725);}})[_0x2f06('0x2c')](respondWithResult(_0x553f3a,null))[_0x2f06('0x50')](handleError(_0x553f3a,null));};exports[_0x2f06('0x89')]=function(_0x4131fd,_0x241733,_0x3f8138){return db[_0x2f06('0x49')][_0x2f06('0x4f')]({'where':{'id':_0x4131fd[_0x2f06('0x4d')]['id']}})[_0x2f06('0x2c')](handleEntityNotFound(_0x241733,null))['then'](function(_0x3358a6){if(_0x3358a6){return _0x3358a6[_0x2f06('0x89')](_0x4131fd[_0x2f06('0x51')]['ids'],_[_0x2f06('0x8a')](_0x4131fd[_0x2f06('0x51')],[_0x2f06('0x63'),'id'])||{})[_0x2f06('0x8b')](function(_0x42d350){for(var _0x3447c5=0x0;_0x3447c5<_0x4131fd['body'][_0x2f06('0x63')][_0x2f06('0x41')];_0x3447c5+=0x1){socket['emit'](_0x2f06('0x8c'),{'UserId':_0x4131fd[_0x2f06('0x51')][_0x2f06('0x63')][_0x3447c5],'CmListId':_0x4131fd[_0x2f06('0x4d')]['id']});}return _0x42d350;});}})[_0x2f06('0x2c')](respondWithResult(_0x241733,null))[_0x2f06('0x50')](handleError(_0x241733,null));};exports[_0x2f06('0x8d')]=function(_0x447f6a,_0x399dd9,_0x9c27da){return db['CmList']['find']({'where':{'id':_0x447f6a[_0x2f06('0x4d')]['id']}})[_0x2f06('0x2c')](handleEntityNotFound(_0x399dd9,null))[_0x2f06('0x2c')](function(_0x4e769a){if(_0x4e769a){return _0x4e769a['removeAgents'](_0x447f6a['query'][_0x2f06('0x63')])[_0x2f06('0x2c')](function(){if(_[_0x2f06('0x66')](_0x447f6a[_0x2f06('0x3b')][_0x2f06('0x63')])){for(var _0x8338d9=0x0;_0x8338d9<_0x447f6a['query'][_0x2f06('0x63')][_0x2f06('0x41')];_0x8338d9+=0x1){socket[_0x2f06('0x8e')]('userCmList:remove',{'UserId':Number(_0x447f6a[_0x2f06('0x3b')][_0x2f06('0x63')][_0x8338d9]),'CmListId':Number(_0x447f6a[_0x2f06('0x4d')]['id'])});}}else{socket['emit'](_0x2f06('0x8f'),{'UserId':Number(_0x447f6a[_0x2f06('0x3b')][_0x2f06('0x63')]),'CmListId':Number(_0x447f6a['params']['id'])});}});}})[_0x2f06('0x2c')](respondWithStatusCode(_0x399dd9,null))['catch'](handleError(_0x399dd9,null));};exports[_0x2f06('0x90')]=function(_0x3f1dfd,_0x195065,_0x464090){var _0x1bd329={};var _0x215d9f={};var _0x3735e1;var _0x1e7d97;return db[_0x2f06('0x49')][_0x2f06('0x5c')]({'where':{'id':_0x3f1dfd[_0x2f06('0x4d')]['id']}})[_0x2f06('0x2c')](handleEntityNotFound(_0x195065,null))[_0x2f06('0x2c')](function(_0x44dcb3){if(_0x44dcb3){_0x3735e1=_0x44dcb3;_0x215d9f[_0x2f06('0x3a')]=_[_0x2f06('0x3c')](db[_0x2f06('0x91')][_0x2f06('0x4e')]);_0x215d9f[_0x2f06('0x3b')]=_[_0x2f06('0x3c')](_0x3f1dfd[_0x2f06('0x3b')]);_0x215d9f[_0x2f06('0x3d')]=_[_0x2f06('0x3f')](_0x215d9f[_0x2f06('0x3a')],_0x215d9f[_0x2f06('0x3b')]);_0x1bd329[_0x2f06('0x3e')]=_[_0x2f06('0x3f')](_0x215d9f[_0x2f06('0x3a')],qs[_0x2f06('0x40')](_0x3f1dfd[_0x2f06('0x3b')]['fields']));_0x1bd329[_0x2f06('0x3e')]=_0x1bd329[_0x2f06('0x3e')][_0x2f06('0x41')]?_0x1bd329[_0x2f06('0x3e')]:_0x215d9f[_0x2f06('0x3a')];_0x1bd329[_0x2f06('0x42')]=qs[_0x2f06('0x43')](_0x3f1dfd[_0x2f06('0x3b')][_0x2f06('0x43')]);_0x1bd329['where']=qs[_0x2f06('0x3d')](_[_0x2f06('0x44')](_0x3f1dfd[_0x2f06('0x3b')],_0x215d9f['filters']));if(_0x3f1dfd[_0x2f06('0x3b')][_0x2f06('0x47')]){_0x1bd329['where']=_[_0x2f06('0x45')](_0x1bd329[_0x2f06('0x60')],{'$or':_[_0x2f06('0x36')](_0x1bd329[_0x2f06('0x3e')],function(_0x57a8ce){var _0x1df704={};_0x1df704[_0x57a8ce]={'$like':'%'+_0x3f1dfd[_0x2f06('0x3b')][_0x2f06('0x47')]+'%'};return _0x1df704;})});}_0x1bd329=_[_0x2f06('0x45')]({},_0x1bd329,_0x3f1dfd[_0x2f06('0x48')]);return _0x3735e1[_0x2f06('0x90')](_0x1bd329);}})[_0x2f06('0x2c')](function(_0x557ce2){if(_0x557ce2){_0x1e7d97=_0x557ce2[_0x2f06('0x41')];if(!_0x3f1dfd[_0x2f06('0x3b')][_0x2f06('0x5e')]('nolimit')){_0x1bd329[_0x2f06('0x25')]=qs['limit'](_0x3f1dfd['query']['limit']);_0x1bd329[_0x2f06('0x24')]=qs[_0x2f06('0x24')](_0x3f1dfd[_0x2f06('0x3b')][_0x2f06('0x24')]);}return _0x3735e1[_0x2f06('0x90')](_0x1bd329);}})['then'](function(_0x289652){if(_0x289652){return _0x289652?{'count':_0x1e7d97,'rows':_0x289652}:null;}})[_0x2f06('0x2c')](respondWithResult(_0x195065,null))['catch'](handleError(_0x195065,null));};
\ No newline at end of file
+var _0x4143=['../../config/license/util','../../mysqldb','redis','defaults','localhost','socket.io-emitter','./cmList.socket','register','status','json','offset','undefined','limit','count','set','Content-Range','apply','reject','save','update','then','get','Lists','destroy','error','stack','name','send','map','rawAttributes','fieldName','type','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','pick','filter','where','merge','options','CmList','includeAll','include','findAll','rows','show','catch','create','body','Unable\x20to\x20retrieve\x20the\x20current\x20user','user','UserProfileSection','find','autoAssociation','UserProfileResource','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','params','describe','addDisposition','ListId','findOne','Disposition','removeDispositions','ids','addContacts','CmContact','tags','isArray','join','push','each','omit','dataValues','errors','message','CmCustomField','CustomFields','concat','raw','getContacts','getContactsCsv','format','isEmpty','setHeader','Content-disposition','attachment;\x20filename=','list_%d_%s.csv','Content-type','text/csv','download','sendStatus','transaction','addCustomFields','Sequelize','TEXT','number','INTEGER','switch','defaultValue','queryInterface','addColumn','cm_contacts','addAgents','spread','emit','userCmList:save','removeAgents','userCmList:remove','getAgents','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','to-csv','ejs','lodash','squel','jsforce','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment'];(function(_0x3054be,_0x1bdc8b){var _0x3df150=function(_0x56cfbf){while(--_0x56cfbf){_0x3054be['push'](_0x3054be['shift']());}};_0x3df150(++_0x1bdc8b);}(_0x4143,0x106));var _0x3414=function(_0x1ac595,_0x5d2081){_0x1ac595=_0x1ac595-0x0;var _0x455fff=_0x4143[_0x1ac595];return _0x455fff;};'use strict';var emlformat=require(_0x3414('0x0'));var rimraf=require(_0x3414('0x1'));var zipdir=require(_0x3414('0x2'));var jsonpatch=require(_0x3414('0x3'));var rp=require(_0x3414('0x4'));var moment=require(_0x3414('0x5'));var BPromise=require(_0x3414('0x6'));var Mustache=require(_0x3414('0x7'));var util=require(_0x3414('0x8'));var path=require('path');var sox=require('sox');var csv=require(_0x3414('0x9'));var ejs=require(_0x3414('0xa'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x3414('0xb'));var squel=require(_0x3414('0xc'));var crypto=require('crypto');var jsforce=require(_0x3414('0xd'));var deskjs=require('desk.js');var toCsv=require(_0x3414('0x9'));var querystring=require(_0x3414('0xe'));var Papa=require(_0x3414('0xf'));var Redis=require(_0x3414('0x10'));var authService=require(_0x3414('0x11'));var qs=require('../../components/parsers/qs');var as=require(_0x3414('0x12'));var hardwareService=require(_0x3414('0x13'));var logger=require(_0x3414('0x14'))(_0x3414('0x15'));var utils=require(_0x3414('0x16'));var config=require(_0x3414('0x17'));var licenseUtil=require(_0x3414('0x18'));var db=require(_0x3414('0x19'))['db'];config[_0x3414('0x1a')]=_[_0x3414('0x1b')](config['redis'],{'host':_0x3414('0x1c'),'port':0x18eb});var socket=require(_0x3414('0x1d'))(new Redis(config[_0x3414('0x1a')]));require(_0x3414('0x1e'))[_0x3414('0x1f')](socket);function respondWithStatusCode(_0xe86160,_0x4e7bb3){_0x4e7bb3=_0x4e7bb3||0xcc;return function(_0x19396d){if(_0x19396d){return _0xe86160['sendStatus'](_0x4e7bb3);}return _0xe86160[_0x3414('0x20')](_0x4e7bb3)['end']();};}function respondWithResult(_0x595b27,_0x335cdd){_0x335cdd=_0x335cdd||0xc8;return function(_0x50ea3d){if(_0x50ea3d){return _0x595b27[_0x3414('0x20')](_0x335cdd)[_0x3414('0x21')](_0x50ea3d);}};}function respondWithFilteredResult(_0x656dd9,_0x380903){return function(_0x279733){if(_0x279733){var _0x542762=typeof _0x380903[_0x3414('0x22')]===_0x3414('0x23')&&typeof _0x380903[_0x3414('0x24')]===_0x3414('0x23');var _0x226513=_0x279733['count'];var _0x3e5f54=_0x542762?0x0:_0x380903['offset'];var _0xee09e6=_0x542762?_0x279733[_0x3414('0x25')]:_0x380903[_0x3414('0x22')]+_0x380903[_0x3414('0x24')];var _0x5f2ab3;if(_0xee09e6>=_0x226513){_0xee09e6=_0x226513;_0x5f2ab3=0xc8;}else{_0x5f2ab3=0xce;}_0x656dd9[_0x3414('0x20')](_0x5f2ab3);return _0x656dd9[_0x3414('0x26')](_0x3414('0x27'),_0x3e5f54+'-'+_0xee09e6+'/'+_0x226513)['json'](_0x279733);}return null;};}function patchUpdates(_0x384798){return function(_0x387ea5){try{jsonpatch[_0x3414('0x28')](_0x387ea5,_0x384798,!![]);}catch(_0x284fac){return BPromise[_0x3414('0x29')](_0x284fac);}return _0x387ea5[_0x3414('0x2a')]();};}function saveUpdates(_0x53aacb,_0x321d6e){return function(_0x6f2ff0){if(_0x6f2ff0){return _0x6f2ff0[_0x3414('0x2b')](_0x53aacb)[_0x3414('0x2c')](function(_0x17104e){return _0x17104e;});}return null;};}function removeEntity(_0x3024bd,_0x19dd6f){return function(_0x1ac1a1){if(_0x1ac1a1){return _0x1ac1a1['destroy']()[_0x3414('0x2c')](function(){var _0x3f7df4=_0x1ac1a1[_0x3414('0x2d')]({'plain':!![]});var _0x388c6f=_0x3414('0x2e');return db['UserProfileResource'][_0x3414('0x2f')]({'where':{'type':_0x388c6f,'resourceId':_0x3f7df4['id']}})[_0x3414('0x2c')](function(){return _0x1ac1a1;});})[_0x3414('0x2c')](function(){_0x3024bd[_0x3414('0x20')](0xcc)['end']();});}};}function handleEntityNotFound(_0x850c33,_0x291ae1){return function(_0x2d0fac){if(!_0x2d0fac){_0x850c33['sendStatus'](0x194);}return _0x2d0fac;};}function handleError(_0x35828d,_0xbc46f1){_0xbc46f1=_0xbc46f1||0x1f4;return function(_0x13fc1b){logger[_0x3414('0x30')](_0x13fc1b[_0x3414('0x31')]);if(_0x13fc1b[_0x3414('0x32')]){delete _0x13fc1b[_0x3414('0x32')];}_0x35828d[_0x3414('0x20')](_0xbc46f1)[_0x3414('0x33')](_0x13fc1b);};}exports['index']=function(_0xa13ddf,_0x5dec04){var _0x168d76={},_0x21548c={},_0x2ac19a={'count':0x0,'rows':[]};var _0x34169a=_[_0x3414('0x34')](db['CmList'][_0x3414('0x35')],function(_0x431d03){return{'name':_0x431d03[_0x3414('0x36')],'type':_0x431d03[_0x3414('0x37')][_0x3414('0x38')]};});_0x21548c[_0x3414('0x39')]=_[_0x3414('0x34')](_0x34169a,_0x3414('0x32'));_0x21548c[_0x3414('0x3a')]=_[_0x3414('0x3b')](_0xa13ddf[_0x3414('0x3a')]);_0x21548c[_0x3414('0x3c')]=_[_0x3414('0x3d')](_0x21548c[_0x3414('0x39')],_0x21548c[_0x3414('0x3a')]);_0x168d76[_0x3414('0x3e')]=_[_0x3414('0x3d')](_0x21548c[_0x3414('0x39')],qs[_0x3414('0x3f')](_0xa13ddf[_0x3414('0x3a')][_0x3414('0x3f')]));_0x168d76['attributes']=_0x168d76['attributes'][_0x3414('0x40')]?_0x168d76['attributes']:_0x21548c[_0x3414('0x39')];if(!_0xa13ddf[_0x3414('0x3a')][_0x3414('0x41')](_0x3414('0x42'))){_0x168d76[_0x3414('0x24')]=qs[_0x3414('0x24')](_0xa13ddf[_0x3414('0x3a')][_0x3414('0x24')]);_0x168d76[_0x3414('0x22')]=qs[_0x3414('0x22')](_0xa13ddf[_0x3414('0x3a')]['offset']);}_0x168d76[_0x3414('0x43')]=qs[_0x3414('0x44')](_0xa13ddf[_0x3414('0x3a')][_0x3414('0x44')]);_0x168d76['where']=qs[_0x3414('0x3c')](_[_0x3414('0x45')](_0xa13ddf[_0x3414('0x3a')],_0x21548c[_0x3414('0x3c')]),_0x34169a);if(_0xa13ddf[_0x3414('0x3a')][_0x3414('0x46')]){_0x168d76[_0x3414('0x47')]=_[_0x3414('0x48')](_0x168d76[_0x3414('0x47')],{'$or':_[_0x3414('0x34')](_0x34169a,function(_0x40f8b1){if(_0x40f8b1[_0x3414('0x37')]!=='VIRTUAL'){var _0x5544a5={};_0x5544a5[_0x40f8b1[_0x3414('0x32')]]={'$like':'%'+_0xa13ddf[_0x3414('0x3a')][_0x3414('0x46')]+'%'};return _0x5544a5;}})});}_0x168d76=_[_0x3414('0x48')]({},_0x168d76,_0xa13ddf[_0x3414('0x49')]);var _0x4931e2={'where':_0x168d76[_0x3414('0x47')]};return db[_0x3414('0x4a')][_0x3414('0x25')](_0x4931e2)['then'](function(_0x47dd37){_0x2ac19a[_0x3414('0x25')]=_0x47dd37;if(_0xa13ddf[_0x3414('0x3a')][_0x3414('0x4b')]){_0x168d76[_0x3414('0x4c')]=[{'all':!![]}];}return db[_0x3414('0x4a')][_0x3414('0x4d')](_0x168d76);})['then'](function(_0x532683){_0x2ac19a[_0x3414('0x4e')]=_0x532683;return _0x2ac19a;})[_0x3414('0x2c')](respondWithFilteredResult(_0x5dec04,_0x168d76))['catch'](handleError(_0x5dec04,null));};exports[_0x3414('0x4f')]=function(_0x3864b9,_0x1c26a3){var _0x283ce2={'raw':![],'where':{'id':_0x3864b9['params']['id']}},_0x50fba9={};_0x50fba9[_0x3414('0x39')]=_['keys'](db[_0x3414('0x4a')]['rawAttributes']);_0x50fba9[_0x3414('0x3a')]=_['keys'](_0x3864b9['query']);_0x50fba9[_0x3414('0x3c')]=_['intersection'](_0x50fba9[_0x3414('0x39')],_0x50fba9[_0x3414('0x3a')]);_0x283ce2['attributes']=_['intersection'](_0x50fba9[_0x3414('0x39')],qs[_0x3414('0x3f')](_0x3864b9[_0x3414('0x3a')]['fields']));_0x283ce2[_0x3414('0x3e')]=_0x283ce2[_0x3414('0x3e')][_0x3414('0x40')]?_0x283ce2['attributes']:_0x50fba9['model'];if(_0x3864b9[_0x3414('0x3a')][_0x3414('0x4b')]){_0x283ce2[_0x3414('0x4c')]=[{'all':!![]}];}_0x283ce2=_[_0x3414('0x48')]({},_0x283ce2,_0x3864b9[_0x3414('0x49')]);return db[_0x3414('0x4a')]['find'](_0x283ce2)[_0x3414('0x2c')](handleEntityNotFound(_0x1c26a3,null))[_0x3414('0x2c')](respondWithResult(_0x1c26a3,null))[_0x3414('0x50')](handleError(_0x1c26a3,null));};exports['create']=function(_0x3a4e8b,_0x234fd7){return db['CmList'][_0x3414('0x51')](_0x3a4e8b[_0x3414('0x52')],{})[_0x3414('0x2c')](function(_0x263edd){var _0x346f81=_0x3a4e8b['user'][_0x3414('0x2d')]({'plain':!![]});if(!_0x346f81)throw new Error(_0x3414('0x53'));if(_0x346f81['role']===_0x3414('0x54')){var _0x53e572=_0x263edd[_0x3414('0x2d')]({'plain':!![]});var _0x3216cc='Lists';return db[_0x3414('0x55')][_0x3414('0x56')]({'where':{'name':_0x3216cc,'userProfileId':_0x346f81['userProfileId']},'raw':!![]})[_0x3414('0x2c')](function(_0xcf0033){if(_0xcf0033&&_0xcf0033[_0x3414('0x57')]===0x0){return db[_0x3414('0x58')][_0x3414('0x51')]({'name':_0x53e572['name'],'resourceId':_0x53e572['id'],'type':_0xcf0033[_0x3414('0x32')],'sectionId':_0xcf0033['id']},{})[_0x3414('0x2c')](function(){return _0x263edd;});}else{return _0x263edd;}})[_0x3414('0x50')](function(_0x27c082){logger[_0x3414('0x30')](_0x3414('0x59'),_0x27c082);throw _0x27c082;});}return _0x263edd;})[_0x3414('0x2c')](respondWithResult(_0x234fd7,0xc9))[_0x3414('0x50')](handleError(_0x234fd7,null));};exports[_0x3414('0x2b')]=function(_0x1f0b05,_0x5ef2f7){if(_0x1f0b05[_0x3414('0x52')]['id']){delete _0x1f0b05['body']['id'];}return db[_0x3414('0x4a')][_0x3414('0x56')]({'where':{'id':_0x1f0b05[_0x3414('0x5a')]['id']}})['then'](handleEntityNotFound(_0x5ef2f7,null))['then'](saveUpdates(_0x1f0b05[_0x3414('0x52')],null))['then'](respondWithResult(_0x5ef2f7,null))[_0x3414('0x50')](handleError(_0x5ef2f7,null));};exports[_0x3414('0x2f')]=function(_0x7bbcc5,_0x138a57){return db[_0x3414('0x4a')]['find']({'where':{'id':_0x7bbcc5[_0x3414('0x5a')]['id']}})[_0x3414('0x2c')](handleEntityNotFound(_0x138a57,null))[_0x3414('0x2c')](removeEntity(_0x138a57,null))[_0x3414('0x50')](handleError(_0x138a57,null));};exports[_0x3414('0x5b')]=function(_0x32e11a,_0x3bb56c){return db[_0x3414('0x4a')][_0x3414('0x5b')]()[_0x3414('0x2c')](respondWithResult(_0x3bb56c,null))[_0x3414('0x50')](handleError(_0x3bb56c,null));};exports[_0x3414('0x5c')]=function(_0x1cac64,_0x5aea99,_0x278bf3){if(_0x1cac64[_0x3414('0x52')]['id']){delete _0x1cac64[_0x3414('0x52')]['id'];}return db[_0x3414('0x4a')]['find']({'where':{'id':_0x1cac64[_0x3414('0x5a')]['id']}})['then'](handleEntityNotFound(_0x5aea99,null))[_0x3414('0x2c')](function(_0x176264){if(_0x176264){_0x1cac64['body'][_0x3414('0x5d')]=_0x176264['id'];return db['Disposition'][_0x3414('0x51')](_0x1cac64[_0x3414('0x52')]);}})['then'](respondWithResult(_0x5aea99,null))[_0x3414('0x50')](handleError(_0x5aea99,null));};exports['getDispositions']=function(_0x312395,_0x1c2fbd,_0x2a7de3){var _0x29c6cd={'raw':![],'where':{}};var _0x4bd11e={};var _0x2603c2={'count':0x0,'rows':[]};return db[_0x3414('0x4a')][_0x3414('0x5e')]({'where':{'id':_0x312395[_0x3414('0x5a')]['id']}})[_0x3414('0x2c')](handleEntityNotFound(_0x1c2fbd,null))['then'](function(_0x20cd06){if(_0x20cd06){_0x4bd11e[_0x3414('0x39')]=_[_0x3414('0x3b')](db[_0x3414('0x5f')][_0x3414('0x35')]);_0x4bd11e[_0x3414('0x3a')]=_[_0x3414('0x3b')](_0x312395['query']);_0x4bd11e[_0x3414('0x3c')]=_[_0x3414('0x3d')](_0x4bd11e[_0x3414('0x39')],_0x4bd11e[_0x3414('0x3a')]);_0x29c6cd[_0x3414('0x3e')]=_[_0x3414('0x3d')](_0x4bd11e[_0x3414('0x39')],qs[_0x3414('0x3f')](_0x312395[_0x3414('0x3a')][_0x3414('0x3f')]));_0x29c6cd[_0x3414('0x3e')]=_0x29c6cd[_0x3414('0x3e')][_0x3414('0x40')]?_0x29c6cd[_0x3414('0x3e')]:_0x4bd11e[_0x3414('0x39')];if(!_0x312395[_0x3414('0x3a')][_0x3414('0x41')](_0x3414('0x42'))){_0x29c6cd[_0x3414('0x24')]=qs[_0x3414('0x24')](_0x312395[_0x3414('0x3a')][_0x3414('0x24')]);_0x29c6cd[_0x3414('0x22')]=qs[_0x3414('0x22')](_0x312395[_0x3414('0x3a')][_0x3414('0x22')]);}_0x29c6cd[_0x3414('0x43')]=qs[_0x3414('0x44')](_0x312395[_0x3414('0x3a')][_0x3414('0x44')]);_0x29c6cd[_0x3414('0x47')]=qs[_0x3414('0x3c')](_['pick'](_0x312395['query'],_0x4bd11e['filters']));_0x29c6cd[_0x3414('0x47')][_0x3414('0x5d')]=_0x20cd06['id'];if(_0x312395['query'][_0x3414('0x46')]){_0x29c6cd[_0x3414('0x47')]=_[_0x3414('0x48')](_0x29c6cd[_0x3414('0x47')],{'$or':_[_0x3414('0x34')](_0x29c6cd[_0x3414('0x3e')],function(_0x2e257e){var _0x79348f={};_0x79348f[_0x2e257e]={'$like':'%'+_0x312395[_0x3414('0x3a')][_0x3414('0x46')]+'%'};return _0x79348f;})});}_0x29c6cd=_[_0x3414('0x48')]({},_0x29c6cd,_0x312395[_0x3414('0x49')]);return db[_0x3414('0x5f')][_0x3414('0x25')]({'where':_0x29c6cd['where']})[_0x3414('0x2c')](function(_0xdd0b4d){_0x2603c2[_0x3414('0x25')]=_0xdd0b4d;if(_0x312395[_0x3414('0x3a')]['includeAll']){_0x29c6cd[_0x3414('0x4c')]=[{'all':!![]}];}return db[_0x3414('0x5f')][_0x3414('0x4d')](_0x29c6cd);})[_0x3414('0x2c')](function(_0x1fc357){_0x2603c2[_0x3414('0x4e')]=_0x1fc357;return _0x2603c2;});}})['then'](respondWithFilteredResult(_0x1c2fbd,_0x29c6cd))['catch'](handleError(_0x1c2fbd,null));};exports[_0x3414('0x60')]=function(_0x477f49,_0x4d7853,_0x46555d){return db[_0x3414('0x4a')][_0x3414('0x56')]({'where':{'id':_0x477f49[_0x3414('0x5a')]['id']}})['then'](handleEntityNotFound(_0x4d7853,null))[_0x3414('0x2c')](function(_0x105c9a){if(_0x105c9a){return _0x105c9a[_0x3414('0x60')](_0x477f49[_0x3414('0x3a')][_0x3414('0x61')]);}})[_0x3414('0x2c')](respondWithStatusCode(_0x4d7853,null))['catch'](handleError(_0x4d7853,null));};exports[_0x3414('0x62')]=function(_0x2793c2,_0x47459d,_0x3b5e37){return db[_0x3414('0x4a')][_0x3414('0x56')]({'where':{'id':_0x2793c2[_0x3414('0x5a')]['id']}})[_0x3414('0x2c')](handleEntityNotFound(_0x47459d,null))['then'](function(_0x1944e2){if(_0x1944e2){var _0x71257c=[];var _0x58b0d8={'success':[],'errors':[]};return db[_0x3414('0x63')][_0x3414('0x5b')]()['then'](function(_0x4615c7){if(_0x2793c2[_0x3414('0x52')][_0x3414('0x64')]&&_[_0x3414('0x65')](_0x2793c2[_0x3414('0x52')][_0x3414('0x64')])){if(_0x2793c2['body'][_0x3414('0x64')][_0x3414('0x40')]){_0x2793c2[_0x3414('0x52')][_0x3414('0x64')]=_0x2793c2[_0x3414('0x52')][_0x3414('0x64')][_0x3414('0x66')](';')+';';}else{_0x2793c2[_0x3414('0x52')][_0x3414('0x64')]=null;}}else{_0x2793c2[_0x3414('0x52')]['tags']=null;}if(_0x2793c2[_0x3414('0x52')]&&_[_0x3414('0x65')](_0x2793c2[_0x3414('0x52')])){for(var _0x3d035d=0x0;_0x3d035d<_0x2793c2[_0x3414('0x52')][_0x3414('0x40')];_0x3d035d+=0x1){_0x2793c2[_0x3414('0x52')][_0x3d035d][_0x3414('0x5d')]=_0x2793c2[_0x3414('0x5a')]['id'];_0x71257c[_0x3414('0x67')](_0x2793c2[_0x3414('0x52')][_0x3d035d]);}return BPromise[_0x3414('0x68')](_0x71257c,function(_0x33a8d0){return db[_0x3414('0x63')][_0x3414('0x51')](_[_0x3414('0x69')](_0x33a8d0,[_0x3414('0x61'),'id'])||{},{'fields':_[_0x3414('0x3b')](_0x4615c7),'raw':!![]})[_0x3414('0x2c')](function(_0x30c7b0){_0x58b0d8['success']['push'](_0x30c7b0[_0x3414('0x6a')]);})[_0x3414('0x50')](function(_0x357eba){_0x58b0d8[_0x3414('0x6b')][_0x3414('0x67')]({'data':_0x33a8d0,'error':_0x357eba[_0x3414('0x6c')]});});})[_0x3414('0x2c')](function(_0x10cafe){return _0x58b0d8;})['catch'](function(_0x4f98c2){return _0x4f98c2;});}else{_0x47459d[_0x3414('0x20')](0x190)[_0x3414('0x21')]({'message':'Malformed\x20request\x20syntax'});}});}})[_0x3414('0x2c')](respondWithResult(_0x47459d,null))[_0x3414('0x50')](handleError(_0x47459d,null));};exports['getContacts']=function(_0x2e4288,_0x590a79,_0x329fc2){var _0xe1199f;return db[_0x3414('0x4a')][_0x3414('0x56')]({'where':{'id':_0x2e4288[_0x3414('0x5a')]['id']},'include':[{'model':db[_0x3414('0x6d')],'as':_0x3414('0x6e')}]})[_0x3414('0x2c')](handleEntityNotFound(_0x590a79,null))[_0x3414('0x2c')](function(_0x3e183b){if(_0x3e183b){_0xe1199f=_0x3e183b;return db[_0x3414('0x63')][_0x3414('0x35')];}})[_0x3414('0x2c')](function(_0x4e2b87){if(_0x4e2b87){var _0x48f8f7={};var _0x21362f={};_0x21362f['model']=_[_0x3414('0x6f')](_[_0x3414('0x3b')](_0x4e2b87),_[_0x3414('0x34')](_0xe1199f['CustomFields'],function(_0x3ad494){return util['format']('cf_%d',_0x3ad494['id']);}));_0x21362f[_0x3414('0x3a')]=_[_0x3414('0x3b')](_0x2e4288[_0x3414('0x3a')]);_0x21362f[_0x3414('0x3c')]=_['intersection'](_0x21362f[_0x3414('0x39')],_0x21362f[_0x3414('0x3a')]);_0x48f8f7[_0x3414('0x3e')]=_[_0x3414('0x3d')](_0x21362f['model'],qs['fields'](_0x2e4288[_0x3414('0x3a')][_0x3414('0x3f')]));_0x48f8f7['attributes']=_0x48f8f7[_0x3414('0x3e')][_0x3414('0x40')]?_0x48f8f7[_0x3414('0x3e')]:_0x21362f[_0x3414('0x39')];if(!_0x2e4288[_0x3414('0x3a')][_0x3414('0x41')](_0x3414('0x42'))){_0x48f8f7[_0x3414('0x24')]=qs[_0x3414('0x24')](_0x2e4288[_0x3414('0x3a')][_0x3414('0x24')]);_0x48f8f7[_0x3414('0x22')]=qs['offset'](_0x2e4288[_0x3414('0x3a')][_0x3414('0x22')]);}_0x48f8f7['order']=qs[_0x3414('0x44')](_0x2e4288[_0x3414('0x3a')][_0x3414('0x44')]);_0x48f8f7['where']=qs[_0x3414('0x3c')](_[_0x3414('0x45')](_0x2e4288[_0x3414('0x3a')],_0x21362f[_0x3414('0x3c')]));_0x48f8f7[_0x3414('0x70')]=!![];if(_0x2e4288['query'][_0x3414('0x46')]){_0x48f8f7[_0x3414('0x47')]=_[_0x3414('0x48')](_0x48f8f7['where'],{'$or':_[_0x3414('0x34')](_0x48f8f7[_0x3414('0x3e')],function(_0x44f201){var _0x26e809={};_0x26e809[_0x44f201]={'$like':'%'+_0x2e4288[_0x3414('0x3a')][_0x3414('0x46')]+'%'};return _0x26e809;})});}_0x48f8f7=_[_0x3414('0x48')]({},_0x48f8f7,_0x2e4288[_0x3414('0x49')]);return _0xe1199f[_0x3414('0x71')](_0x48f8f7);}})[_0x3414('0x2c')](respondWithResult(_0x590a79,null))[_0x3414('0x50')](handleError(_0x590a79,null));};exports[_0x3414('0x72')]=function(_0x2edbc8,_0x4804f1,_0x200961){var _0x410790;return db[_0x3414('0x4a')][_0x3414('0x56')]({'where':{'id':_0x2edbc8[_0x3414('0x5a')]['id']},'include':[{'model':db[_0x3414('0x6d')],'as':_0x3414('0x6e')}]})[_0x3414('0x2c')](handleEntityNotFound(_0x4804f1,null))['then'](function(_0x16896f){if(_0x16896f){_0x410790=_0x16896f;return db[_0x3414('0x63')]['rawAttributes'];}})['then'](function(_0x55f724){if(_0x55f724){var _0x3f7fe9={};var _0x2733f6={};_0x2733f6[_0x3414('0x39')]=_['concat'](_[_0x3414('0x3b')](_0x55f724),_[_0x3414('0x34')](_0x410790[_0x3414('0x6e')],function(_0x201be7){return util[_0x3414('0x73')]('cf_%d',_0x201be7['id']);}));_0x2733f6[_0x3414('0x3a')]=_['keys'](_0x2edbc8['query']);_0x2733f6[_0x3414('0x3c')]=_['intersection'](_0x2733f6[_0x3414('0x39')],_0x2733f6[_0x3414('0x3a')]);_0x3f7fe9[_0x3414('0x3e')]=_[_0x3414('0x3d')](_0x2733f6['model'],qs[_0x3414('0x3f')](_0x2edbc8[_0x3414('0x3a')][_0x3414('0x3f')]));_0x3f7fe9[_0x3414('0x3e')]=_0x3f7fe9[_0x3414('0x3e')]['length']?_0x3f7fe9[_0x3414('0x3e')]:_0x2733f6[_0x3414('0x39')];if(!_0x2edbc8[_0x3414('0x3a')][_0x3414('0x41')](_0x3414('0x42'))){_0x3f7fe9['limit']=qs[_0x3414('0x24')](_0x2edbc8['query'][_0x3414('0x24')]);_0x3f7fe9['offset']=qs[_0x3414('0x22')](_0x2edbc8[_0x3414('0x3a')]['offset']);}_0x3f7fe9[_0x3414('0x43')]=qs['sort'](_0x2edbc8[_0x3414('0x3a')][_0x3414('0x44')]);_0x3f7fe9[_0x3414('0x47')]=qs['filters'](_[_0x3414('0x45')](_0x2edbc8[_0x3414('0x3a')],_0x2733f6[_0x3414('0x3c')]));_0x3f7fe9[_0x3414('0x70')]=!![];if(_0x2edbc8[_0x3414('0x3a')][_0x3414('0x46')]){_0x3f7fe9[_0x3414('0x47')]=_[_0x3414('0x48')](_0x3f7fe9[_0x3414('0x47')],{'$or':_[_0x3414('0x34')](_0x3f7fe9['attributes'],function(_0x12f71b){var _0x316b13={};_0x316b13[_0x12f71b]={'$like':'%'+_0x2edbc8[_0x3414('0x3a')]['filter']+'%'};return _0x316b13;})});}_0x3f7fe9=_[_0x3414('0x48')]({},_0x3f7fe9,_0x2edbc8['options']);return _0x410790[_0x3414('0x71')](_0x3f7fe9);}})['then'](function(_0x560d1e){if(!_[_0x3414('0x74')](_0x560d1e)){var _0x9299c9=toCsv(_0x560d1e);var _0x303b38=Date['now']();fs['writeFileSync'](util[_0x3414('0x73')]('/tmp/list_%d_%s.csv',_0x410790['id'],_0x303b38),_0x9299c9);_0x4804f1[_0x3414('0x75')](_0x3414('0x76'),_0x3414('0x77')+util['format'](_0x3414('0x78'),_0x410790['id'],_0x303b38));_0x4804f1['setHeader'](_0x3414('0x79'),_0x3414('0x7a'));return _0x4804f1[_0x3414('0x7b')](util[_0x3414('0x73')]('/tmp/list_%d_%s.csv',_0x410790['id'],_0x303b38));}else{return _0x4804f1[_0x3414('0x7c')](0xcc);}})['catch'](handleError(_0x4804f1,null));};exports['addCustomField']=function(_0x3cedb4,_0x541893,_0x59d32e){var _0x3f0686;delete _0x3cedb4[_0x3414('0x52')]['id'];return db['CmList'][_0x3414('0x5e')]({'where':{'id':_0x3cedb4[_0x3414('0x5a')]['id']}})[_0x3414('0x2c')](handleEntityNotFound(_0x541893,null))['then'](function(_0x14a469){if(_0x14a469){return db['sequelize'][_0x3414('0x7d')](function(_0x5bcb4c){return db[_0x3414('0x6d')][_0x3414('0x51')](_0x3cedb4['body'],{'transaction':_0x5bcb4c})['then'](function(_0x2004dc){_0x3f0686=_0x2004dc;return _0x14a469[_0x3414('0x7e')](_0x2004dc,{'transaction':_0x5bcb4c});})['then'](function(){var _0x176740={'type':db[_0x3414('0x7f')][_0x3414('0x80')],'transaction':_0x5bcb4c};switch(_0x3cedb4[_0x3414('0x52')][_0x3414('0x37')]){case'text':_0x176740[_0x3414('0x37')]=db[_0x3414('0x7f')][_0x3414('0x80')];break;case _0x3414('0x81'):_0x176740[_0x3414('0x37')]=db['Sequelize'][_0x3414('0x82')];break;case _0x3414('0x83'):_0x176740[_0x3414('0x37')]=db[_0x3414('0x7f')]['BOOLEAN'];_0x176740[_0x3414('0x84')]=![];break;default:}return db['sequelize'][_0x3414('0x85')][_0x3414('0x86')](_0x3414('0x87'),util[_0x3414('0x73')]('cf_%s',_0x3f0686['id']),_0x176740);})[_0x3414('0x2c')](function(){return _0x3f0686;});});}})[_0x3414('0x2c')](respondWithResult(_0x541893,null))['catch'](handleError(_0x541893,null));};exports['getCustomFields']=function(_0x3ce07b,_0x1a4cf1,_0x3ed2c0){var _0x1473ee={};var _0x165bbe={};var _0xfb3758;var _0x81d79b;return db[_0x3414('0x4a')][_0x3414('0x5e')]({'where':{'id':_0x3ce07b[_0x3414('0x5a')]['id']}})[_0x3414('0x2c')](handleEntityNotFound(_0x1a4cf1,null))['then'](function(_0xa2d092){if(_0xa2d092){_0xfb3758=_0xa2d092;_0x165bbe[_0x3414('0x39')]=_['keys'](db['CmCustomField']['rawAttributes']);_0x165bbe[_0x3414('0x3a')]=_[_0x3414('0x3b')](_0x3ce07b[_0x3414('0x3a')]);_0x165bbe[_0x3414('0x3c')]=_['intersection'](_0x165bbe[_0x3414('0x39')],_0x165bbe[_0x3414('0x3a')]);_0x1473ee[_0x3414('0x3e')]=_[_0x3414('0x3d')](_0x165bbe[_0x3414('0x39')],qs[_0x3414('0x3f')](_0x3ce07b[_0x3414('0x3a')][_0x3414('0x3f')]));_0x1473ee['attributes']=_0x1473ee[_0x3414('0x3e')]['length']?_0x1473ee[_0x3414('0x3e')]:_0x165bbe['model'];_0x1473ee[_0x3414('0x43')]=qs['sort'](_0x3ce07b[_0x3414('0x3a')][_0x3414('0x44')]);_0x1473ee[_0x3414('0x47')]=qs['filters'](_[_0x3414('0x45')](_0x3ce07b[_0x3414('0x3a')],_0x165bbe['filters']));_0x1473ee['where']=_[_0x3414('0x48')](_0x1473ee[_0x3414('0x47')],{'$or':[{'ListId':_0xa2d092['id']},{'ListId':null}]});if(_0x3ce07b[_0x3414('0x3a')][_0x3414('0x46')]){_0x1473ee['where']=_[_0x3414('0x48')](_0x1473ee[_0x3414('0x47')],{'$or':_[_0x3414('0x34')](_0x1473ee[_0x3414('0x3e')],function(_0xa69167){var _0x4f59bf={};_0x4f59bf[_0xa69167]={'$like':'%'+_0x3ce07b[_0x3414('0x3a')][_0x3414('0x46')]+'%'};return _0x4f59bf;})});}_0x1473ee=_[_0x3414('0x48')]({},_0x1473ee,_0x3ce07b[_0x3414('0x49')]);return db[_0x3414('0x6d')]['findAndCountAll'](_0x1473ee);}})[_0x3414('0x2c')](respondWithResult(_0x1a4cf1,null))[_0x3414('0x50')](handleError(_0x1a4cf1,null));};exports[_0x3414('0x88')]=function(_0x36d7ab,_0x7ca8d0,_0x28adeb){return db[_0x3414('0x4a')][_0x3414('0x56')]({'where':{'id':_0x36d7ab[_0x3414('0x5a')]['id']}})[_0x3414('0x2c')](handleEntityNotFound(_0x7ca8d0,null))[_0x3414('0x2c')](function(_0x4ee73b){if(_0x4ee73b){return _0x4ee73b[_0x3414('0x88')](_0x36d7ab[_0x3414('0x52')]['ids'],_[_0x3414('0x69')](_0x36d7ab['body'],[_0x3414('0x61'),'id'])||{})[_0x3414('0x89')](function(_0x2b7f50){for(var _0x57a0a6=0x0;_0x57a0a6<_0x36d7ab[_0x3414('0x52')][_0x3414('0x61')]['length'];_0x57a0a6+=0x1){socket[_0x3414('0x8a')](_0x3414('0x8b'),{'UserId':Number(_0x36d7ab[_0x3414('0x52')]['ids'][_0x57a0a6]),'CmListId':Number(_0x36d7ab[_0x3414('0x5a')]['id'])});}return _0x2b7f50;});}})[_0x3414('0x2c')](respondWithResult(_0x7ca8d0,null))[_0x3414('0x50')](handleError(_0x7ca8d0,null));};exports[_0x3414('0x8c')]=function(_0x29c080,_0x458552,_0x3e7538){return db[_0x3414('0x4a')][_0x3414('0x56')]({'where':{'id':_0x29c080[_0x3414('0x5a')]['id']}})[_0x3414('0x2c')](handleEntityNotFound(_0x458552,null))['then'](function(_0x214908){if(_0x214908){return _0x214908['removeAgents'](_0x29c080[_0x3414('0x3a')]['ids'])['then'](function(){if(_[_0x3414('0x65')](_0x29c080['query'][_0x3414('0x61')])){for(var _0x177f50=0x0;_0x177f50<_0x29c080[_0x3414('0x3a')][_0x3414('0x61')][_0x3414('0x40')];_0x177f50+=0x1){socket[_0x3414('0x8a')](_0x3414('0x8d'),{'UserId':Number(_0x29c080[_0x3414('0x3a')]['ids'][_0x177f50]),'CmListId':Number(_0x29c080[_0x3414('0x5a')]['id'])});}}else{socket[_0x3414('0x8a')](_0x3414('0x8d'),{'UserId':Number(_0x29c080[_0x3414('0x3a')][_0x3414('0x61')]),'CmListId':Number(_0x29c080[_0x3414('0x5a')]['id'])});}});}})['then'](respondWithStatusCode(_0x458552,null))[_0x3414('0x50')](handleError(_0x458552,null));};exports[_0x3414('0x8e')]=function(_0x1dd946,_0x5c06f3,_0x4c1803){var _0x5cc9ab={};var _0x3dba1c={};var _0x37a906;var _0x35902b;return db['CmList'][_0x3414('0x5e')]({'where':{'id':_0x1dd946[_0x3414('0x5a')]['id']}})['then'](handleEntityNotFound(_0x5c06f3,null))[_0x3414('0x2c')](function(_0x76ff13){if(_0x76ff13){_0x37a906=_0x76ff13;_0x3dba1c[_0x3414('0x39')]=_[_0x3414('0x3b')](db['User'][_0x3414('0x35')]);_0x3dba1c['query']=_[_0x3414('0x3b')](_0x1dd946[_0x3414('0x3a')]);_0x3dba1c[_0x3414('0x3c')]=_[_0x3414('0x3d')](_0x3dba1c[_0x3414('0x39')],_0x3dba1c['query']);_0x5cc9ab['attributes']=_[_0x3414('0x3d')](_0x3dba1c[_0x3414('0x39')],qs[_0x3414('0x3f')](_0x1dd946[_0x3414('0x3a')]['fields']));_0x5cc9ab['attributes']=_0x5cc9ab[_0x3414('0x3e')][_0x3414('0x40')]?_0x5cc9ab[_0x3414('0x3e')]:_0x3dba1c[_0x3414('0x39')];_0x5cc9ab[_0x3414('0x43')]=qs[_0x3414('0x44')](_0x1dd946[_0x3414('0x3a')][_0x3414('0x44')]);_0x5cc9ab['where']=qs[_0x3414('0x3c')](_[_0x3414('0x45')](_0x1dd946[_0x3414('0x3a')],_0x3dba1c[_0x3414('0x3c')]));if(_0x1dd946['query'][_0x3414('0x46')]){_0x5cc9ab['where']=_[_0x3414('0x48')](_0x5cc9ab['where'],{'$or':_['map'](_0x5cc9ab['attributes'],function(_0x41e5d8){var _0x49b223={};_0x49b223[_0x41e5d8]={'$like':'%'+_0x1dd946[_0x3414('0x3a')][_0x3414('0x46')]+'%'};return _0x49b223;})});}_0x5cc9ab=_[_0x3414('0x48')]({},_0x5cc9ab,_0x1dd946[_0x3414('0x49')]);return _0x37a906[_0x3414('0x8e')](_0x5cc9ab);}})['then'](function(_0x7b1e12){if(_0x7b1e12){_0x35902b=_0x7b1e12[_0x3414('0x40')];if(!_0x1dd946[_0x3414('0x3a')][_0x3414('0x41')](_0x3414('0x42'))){_0x5cc9ab[_0x3414('0x24')]=qs[_0x3414('0x24')](_0x1dd946[_0x3414('0x3a')][_0x3414('0x24')]);_0x5cc9ab[_0x3414('0x22')]=qs[_0x3414('0x22')](_0x1dd946[_0x3414('0x3a')][_0x3414('0x22')]);}return _0x37a906[_0x3414('0x8e')](_0x5cc9ab);}})['then'](function(_0x23a393){if(_0x23a393){return _0x23a393?{'count':_0x35902b,'rows':_0x23a393}:null;}})['then'](respondWithResult(_0x5c06f3,null))['catch'](handleError(_0x5c06f3,null));};
\ No newline at end of file