Built motion from commit e6806ed6.|2.6.0
[motion2.git] / server / api / cmList / cmList.controller.js
index b75433b..17e82d0 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xef8c=['querystring','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','localhost','register','sendStatus','status','end','undefined','limit','count','offset','Content-Range','apply','reject','save','update','then','destroy','get','Lists','UserProfileResource','stack','name','send','map','CmList','rawAttributes','fieldName','type','key','model','query','keys','intersection','attributes','fields','length','hasOwnProperty','sort','where','filters','pick','filter','VIRTUAL','includeAll','include','findAll','catch','params','find','create','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','autoAssociation','error','body','describe','addDisposition','ListId','getDispositions','Disposition','nolimit','order','merge','options','removeDispositions','ids','addContacts','CmContact','tags','join','isArray','push','json','Malformed\x20request\x20syntax','getContacts','CmCustomField','CustomFields','concat','format','cf_%d','getContactsCsv','raw','isEmpty','now','/tmp/list_%d_%s.csv','setHeader','Content-disposition','attachment;\x20filename=','list_%d_%s.csv','Content-type','text/csv','download','addCustomField','sequelize','transaction','addCustomFields','text','Sequelize','TEXT','switch','BOOLEAN','defaultValue','queryInterface','addColumn','cm_contacts','findAndCountAll','addAgents','spread','emit','removeAgents','userCmList:remove','findOne','User','getAgents','eml-format','zip-dir','request-promise','moment','bluebird','mustache','util','path','sox','ejs','fs-extra','lodash','crypto','jsforce','desk.js'];(function(_0x4fefc2,_0x4ea655){var _0x1e4192=function(_0x328108){while(--_0x328108){_0x4fefc2['push'](_0x4fefc2['shift']());}};_0x1e4192(++_0x4ea655);}(_0xef8c,0x195));var _0xcef8=function(_0x16b667,_0xadec02){_0x16b667=_0x16b667-0x0;var _0x58620e=_0xef8c[_0x16b667];return _0x58620e;};'use strict';var emlformat=require(_0xcef8('0x0'));var rimraf=require('rimraf');var zipdir=require(_0xcef8('0x1'));var jsonpatch=require('fast-json-patch');var rp=require(_0xcef8('0x2'));var moment=require(_0xcef8('0x3'));var BPromise=require(_0xcef8('0x4'));var Mustache=require(_0xcef8('0x5'));var util=require(_0xcef8('0x6'));var path=require(_0xcef8('0x7'));var sox=require(_0xcef8('0x8'));var csv=require('to-csv');var ejs=require(_0xcef8('0x9'));var fs=require('fs');var fs_extra=require(_0xcef8('0xa'));var _=require(_0xcef8('0xb'));var squel=require('squel');var crypto=require(_0xcef8('0xc'));var jsforce=require(_0xcef8('0xd'));var deskjs=require(_0xcef8('0xe'));var toCsv=require('to-csv');var querystring=require(_0xcef8('0xf'));var Papa=require('papaparse');var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require(_0xcef8('0x10'));var as=require(_0xcef8('0x11'));var hardwareService=require(_0xcef8('0x12'));var logger=require(_0xcef8('0x13'))(_0xcef8('0x14'));var utils=require(_0xcef8('0x15'));var config=require(_0xcef8('0x16'));var licenseUtil=require(_0xcef8('0x17'));var db=require(_0xcef8('0x18'))['db'];config[_0xcef8('0x19')]=_['defaults'](config[_0xcef8('0x19')],{'host':_0xcef8('0x1a'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xcef8('0x19')]));require('./cmList.socket')[_0xcef8('0x1b')](socket);function respondWithStatusCode(_0x272489,_0x5e0167){_0x5e0167=_0x5e0167||0xcc;return function(_0x1fd04d){if(_0x1fd04d){return _0x272489[_0xcef8('0x1c')](_0x5e0167);}return _0x272489[_0xcef8('0x1d')](_0x5e0167)[_0xcef8('0x1e')]();};}function respondWithResult(_0x57b625,_0x5b849f){_0x5b849f=_0x5b849f||0xc8;return function(_0x2099a9){if(_0x2099a9){return _0x57b625[_0xcef8('0x1d')](_0x5b849f)['json'](_0x2099a9);}};}function respondWithFilteredResult(_0x3f9b1c,_0x508925){return function(_0x3db5aa){if(_0x3db5aa){var _0x5a241a=typeof _0x508925['offset']===_0xcef8('0x1f')&&typeof _0x508925[_0xcef8('0x20')]==='undefined';var _0x3dd7d0=_0x3db5aa[_0xcef8('0x21')];var _0x9486f9=_0x5a241a?0x0:_0x508925[_0xcef8('0x22')];var _0x36b443=_0x5a241a?_0x3db5aa[_0xcef8('0x21')]:_0x508925['offset']+_0x508925[_0xcef8('0x20')];var _0x50b5f3;if(_0x36b443>=_0x3dd7d0){_0x36b443=_0x3dd7d0;_0x50b5f3=0xc8;}else{_0x50b5f3=0xce;}_0x3f9b1c['status'](_0x50b5f3);return _0x3f9b1c['set'](_0xcef8('0x23'),_0x9486f9+'-'+_0x36b443+'/'+_0x3dd7d0)['json'](_0x3db5aa);}return null;};}function patchUpdates(_0x4a2dd7){return function(_0xe20a11){try{jsonpatch[_0xcef8('0x24')](_0xe20a11,_0x4a2dd7,!![]);}catch(_0x253fd0){return BPromise[_0xcef8('0x25')](_0x253fd0);}return _0xe20a11[_0xcef8('0x26')]();};}function saveUpdates(_0x1fd2aa,_0x5ea5d3){return function(_0x2e96f7){if(_0x2e96f7){return _0x2e96f7[_0xcef8('0x27')](_0x1fd2aa)[_0xcef8('0x28')](function(_0x5cb083){return _0x5cb083;});}return null;};}function removeEntity(_0x4f596b,_0x1862ff){return function(_0x4442fa){if(_0x4442fa){return _0x4442fa[_0xcef8('0x29')]()['then'](function(){var _0xa126f2=_0x4442fa[_0xcef8('0x2a')]({'plain':!![]});var _0x39c85e=_0xcef8('0x2b');return db[_0xcef8('0x2c')][_0xcef8('0x29')]({'where':{'type':_0x39c85e,'resourceId':_0xa126f2['id']}})[_0xcef8('0x28')](function(){return _0x4442fa;});})[_0xcef8('0x28')](function(){_0x4f596b[_0xcef8('0x1d')](0xcc)[_0xcef8('0x1e')]();});}};}function handleEntityNotFound(_0x2b6d75,_0x3db549){return function(_0x15cecb){if(!_0x15cecb){_0x2b6d75[_0xcef8('0x1c')](0x194);}return _0x15cecb;};}function handleError(_0xc24079,_0x37e0cc){_0x37e0cc=_0x37e0cc||0x1f4;return function(_0xff733e){logger['error'](_0xff733e[_0xcef8('0x2d')]);if(_0xff733e['name']){delete _0xff733e[_0xcef8('0x2e')];}_0xc24079['status'](_0x37e0cc)[_0xcef8('0x2f')](_0xff733e);};}exports['index']=function(_0x52cbeb,_0x5c619e){var _0x15779f={},_0x2a023d={},_0x2a5b0a={'count':0x0,'rows':[]};var _0x3782ce=_[_0xcef8('0x30')](db[_0xcef8('0x31')][_0xcef8('0x32')],function(_0x5c1164){return{'name':_0x5c1164[_0xcef8('0x33')],'type':_0x5c1164[_0xcef8('0x34')][_0xcef8('0x35')]};});_0x2a023d[_0xcef8('0x36')]=_[_0xcef8('0x30')](_0x3782ce,_0xcef8('0x2e'));_0x2a023d[_0xcef8('0x37')]=_[_0xcef8('0x38')](_0x52cbeb['query']);_0x2a023d['filters']=_[_0xcef8('0x39')](_0x2a023d['model'],_0x2a023d['query']);_0x15779f[_0xcef8('0x3a')]=_[_0xcef8('0x39')](_0x2a023d['model'],qs[_0xcef8('0x3b')](_0x52cbeb[_0xcef8('0x37')][_0xcef8('0x3b')]));_0x15779f[_0xcef8('0x3a')]=_0x15779f[_0xcef8('0x3a')][_0xcef8('0x3c')]?_0x15779f[_0xcef8('0x3a')]:_0x2a023d[_0xcef8('0x36')];if(!_0x52cbeb['query'][_0xcef8('0x3d')]('nolimit')){_0x15779f['limit']=qs[_0xcef8('0x20')](_0x52cbeb[_0xcef8('0x37')]['limit']);_0x15779f['offset']=qs[_0xcef8('0x22')](_0x52cbeb[_0xcef8('0x37')]['offset']);}_0x15779f['order']=qs[_0xcef8('0x3e')](_0x52cbeb[_0xcef8('0x37')][_0xcef8('0x3e')]);_0x15779f[_0xcef8('0x3f')]=qs[_0xcef8('0x40')](_[_0xcef8('0x41')](_0x52cbeb[_0xcef8('0x37')],_0x2a023d[_0xcef8('0x40')]),_0x3782ce);if(_0x52cbeb['query'][_0xcef8('0x42')]){_0x15779f['where']=_['merge'](_0x15779f[_0xcef8('0x3f')],{'$or':_['map'](_0x3782ce,function(_0x54ff45){if(_0x54ff45[_0xcef8('0x34')]!==_0xcef8('0x43')){var _0x49671a={};_0x49671a[_0x54ff45['name']]={'$like':'%'+_0x52cbeb['query'][_0xcef8('0x42')]+'%'};return _0x49671a;}})});}_0x15779f=_['merge']({},_0x15779f,_0x52cbeb['options']);var _0x4e9bda={'where':_0x15779f[_0xcef8('0x3f')]};return db[_0xcef8('0x31')][_0xcef8('0x21')](_0x4e9bda)['then'](function(_0x4b77e6){_0x2a5b0a[_0xcef8('0x21')]=_0x4b77e6;if(_0x52cbeb['query'][_0xcef8('0x44')]){_0x15779f[_0xcef8('0x45')]=[{'all':!![]}];}return db[_0xcef8('0x31')][_0xcef8('0x46')](_0x15779f);})['then'](function(_0x8a1891){_0x2a5b0a['rows']=_0x8a1891;return _0x2a5b0a;})[_0xcef8('0x28')](respondWithFilteredResult(_0x5c619e,_0x15779f))[_0xcef8('0x47')](handleError(_0x5c619e,null));};exports['show']=function(_0x16ff36,_0xaeca66){var _0x288a61={'raw':![],'where':{'id':_0x16ff36[_0xcef8('0x48')]['id']}},_0x1b60de={};_0x1b60de[_0xcef8('0x36')]=_[_0xcef8('0x38')](db[_0xcef8('0x31')][_0xcef8('0x32')]);_0x1b60de[_0xcef8('0x37')]=_[_0xcef8('0x38')](_0x16ff36[_0xcef8('0x37')]);_0x1b60de[_0xcef8('0x40')]=_['intersection'](_0x1b60de['model'],_0x1b60de[_0xcef8('0x37')]);_0x288a61[_0xcef8('0x3a')]=_['intersection'](_0x1b60de[_0xcef8('0x36')],qs[_0xcef8('0x3b')](_0x16ff36['query'][_0xcef8('0x3b')]));_0x288a61[_0xcef8('0x3a')]=_0x288a61['attributes']['length']?_0x288a61[_0xcef8('0x3a')]:_0x1b60de[_0xcef8('0x36')];if(_0x16ff36[_0xcef8('0x37')][_0xcef8('0x44')]){_0x288a61['include']=[{'all':!![]}];}_0x288a61=_['merge']({},_0x288a61,_0x16ff36['options']);return db['CmList'][_0xcef8('0x49')](_0x288a61)[_0xcef8('0x28')](handleEntityNotFound(_0xaeca66,null))[_0xcef8('0x28')](respondWithResult(_0xaeca66,null))['catch'](handleError(_0xaeca66,null));};exports[_0xcef8('0x4a')]=function(_0x907d6c,_0x49019b){return db[_0xcef8('0x31')][_0xcef8('0x4a')](_0x907d6c['body'],{})[_0xcef8('0x28')](function(_0x4f0472){var _0x8457ca=_0x907d6c[_0xcef8('0x4b')][_0xcef8('0x2a')]({'plain':!![]});if(!_0x8457ca)throw new Error(_0xcef8('0x4c'));if(_0x8457ca[_0xcef8('0x4d')]===_0xcef8('0x4b')){var _0x30c727=_0x4f0472[_0xcef8('0x2a')]({'plain':!![]});var _0x4b56c1=_0xcef8('0x2b');return db['UserProfileSection']['find']({'where':{'name':_0x4b56c1,'userProfileId':_0x8457ca['userProfileId']},'raw':!![]})[_0xcef8('0x28')](function(_0x32b272){if(_0x32b272&&_0x32b272[_0xcef8('0x4e')]===0x0){return db['UserProfileResource'][_0xcef8('0x4a')]({'name':_0x30c727['name'],'resourceId':_0x30c727['id'],'type':_0x32b272[_0xcef8('0x2e')],'sectionId':_0x32b272['id']},{})[_0xcef8('0x28')](function(){return _0x4f0472;});}else{return _0x4f0472;}})['catch'](function(_0xc5794e){logger[_0xcef8('0x4f')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0xc5794e);throw _0xc5794e;});}return _0x4f0472;})[_0xcef8('0x28')](respondWithResult(_0x49019b,0xc9))[_0xcef8('0x47')](handleError(_0x49019b,null));};exports['update']=function(_0x34b19,_0x1ca854){if(_0x34b19[_0xcef8('0x50')]['id']){delete _0x34b19[_0xcef8('0x50')]['id'];}return db['CmList'][_0xcef8('0x49')]({'where':{'id':_0x34b19[_0xcef8('0x48')]['id']}})[_0xcef8('0x28')](handleEntityNotFound(_0x1ca854,null))[_0xcef8('0x28')](saveUpdates(_0x34b19[_0xcef8('0x50')],null))[_0xcef8('0x28')](respondWithResult(_0x1ca854,null))[_0xcef8('0x47')](handleError(_0x1ca854,null));};exports['destroy']=function(_0x131430,_0x486a49){return db[_0xcef8('0x31')][_0xcef8('0x49')]({'where':{'id':_0x131430[_0xcef8('0x48')]['id']}})['then'](handleEntityNotFound(_0x486a49,null))[_0xcef8('0x28')](removeEntity(_0x486a49,null))['catch'](handleError(_0x486a49,null));};exports['describe']=function(_0x5d7fc9,_0x2ef096){return db[_0xcef8('0x31')][_0xcef8('0x51')]()[_0xcef8('0x28')](respondWithResult(_0x2ef096,null))[_0xcef8('0x47')](handleError(_0x2ef096,null));};exports[_0xcef8('0x52')]=function(_0x29efa2,_0x43da93,_0x3ae031){if(_0x29efa2[_0xcef8('0x50')]['id']){delete _0x29efa2['body']['id'];}return db[_0xcef8('0x31')]['find']({'where':{'id':_0x29efa2[_0xcef8('0x48')]['id']}})['then'](handleEntityNotFound(_0x43da93,null))[_0xcef8('0x28')](function(_0x2ffa98){if(_0x2ffa98){_0x29efa2[_0xcef8('0x50')][_0xcef8('0x53')]=_0x2ffa98['id'];return db['Disposition'][_0xcef8('0x4a')](_0x29efa2[_0xcef8('0x50')]);}})[_0xcef8('0x28')](respondWithResult(_0x43da93,null))['catch'](handleError(_0x43da93,null));};exports[_0xcef8('0x54')]=function(_0x5e8829,_0x3a90ed,_0x5a19ad){var _0x4245ad={'raw':![],'where':{}};var _0x280957={};var _0x9666fd={'count':0x0,'rows':[]};return db[_0xcef8('0x31')]['findOne']({'where':{'id':_0x5e8829[_0xcef8('0x48')]['id']}})[_0xcef8('0x28')](handleEntityNotFound(_0x3a90ed,null))[_0xcef8('0x28')](function(_0xcab1da){if(_0xcab1da){_0x280957['model']=_[_0xcef8('0x38')](db[_0xcef8('0x55')][_0xcef8('0x32')]);_0x280957[_0xcef8('0x37')]=_[_0xcef8('0x38')](_0x5e8829[_0xcef8('0x37')]);_0x280957[_0xcef8('0x40')]=_['intersection'](_0x280957[_0xcef8('0x36')],_0x280957[_0xcef8('0x37')]);_0x4245ad[_0xcef8('0x3a')]=_[_0xcef8('0x39')](_0x280957['model'],qs[_0xcef8('0x3b')](_0x5e8829[_0xcef8('0x37')]['fields']));_0x4245ad[_0xcef8('0x3a')]=_0x4245ad[_0xcef8('0x3a')]['length']?_0x4245ad[_0xcef8('0x3a')]:_0x280957['model'];if(!_0x5e8829[_0xcef8('0x37')]['hasOwnProperty'](_0xcef8('0x56'))){_0x4245ad[_0xcef8('0x20')]=qs[_0xcef8('0x20')](_0x5e8829[_0xcef8('0x37')]['limit']);_0x4245ad['offset']=qs[_0xcef8('0x22')](_0x5e8829['query'][_0xcef8('0x22')]);}_0x4245ad[_0xcef8('0x57')]=qs[_0xcef8('0x3e')](_0x5e8829[_0xcef8('0x37')][_0xcef8('0x3e')]);_0x4245ad[_0xcef8('0x3f')]=qs[_0xcef8('0x40')](_[_0xcef8('0x41')](_0x5e8829[_0xcef8('0x37')],_0x280957[_0xcef8('0x40')]));_0x4245ad['where'][_0xcef8('0x53')]=_0xcab1da['id'];if(_0x5e8829['query'][_0xcef8('0x42')]){_0x4245ad[_0xcef8('0x3f')]=_['merge'](_0x4245ad['where'],{'$or':_[_0xcef8('0x30')](_0x4245ad[_0xcef8('0x3a')],function(_0x29c3e4){var _0xef015e={};_0xef015e[_0x29c3e4]={'$like':'%'+_0x5e8829[_0xcef8('0x37')]['filter']+'%'};return _0xef015e;})});}_0x4245ad=_[_0xcef8('0x58')]({},_0x4245ad,_0x5e8829[_0xcef8('0x59')]);return db[_0xcef8('0x55')][_0xcef8('0x21')]({'where':_0x4245ad['where']})[_0xcef8('0x28')](function(_0x16c17e){_0x9666fd[_0xcef8('0x21')]=_0x16c17e;if(_0x5e8829[_0xcef8('0x37')][_0xcef8('0x44')]){_0x4245ad[_0xcef8('0x45')]=[{'all':!![]}];}return db['Disposition'][_0xcef8('0x46')](_0x4245ad);})[_0xcef8('0x28')](function(_0x380db8){_0x9666fd['rows']=_0x380db8;return _0x9666fd;});}})[_0xcef8('0x28')](respondWithFilteredResult(_0x3a90ed,_0x4245ad))[_0xcef8('0x47')](handleError(_0x3a90ed,null));};exports[_0xcef8('0x5a')]=function(_0x478c85,_0x519dae,_0x10eb57){return db[_0xcef8('0x31')][_0xcef8('0x49')]({'where':{'id':_0x478c85[_0xcef8('0x48')]['id']}})[_0xcef8('0x28')](handleEntityNotFound(_0x519dae,null))[_0xcef8('0x28')](function(_0x108201){if(_0x108201){return _0x108201[_0xcef8('0x5a')](_0x478c85[_0xcef8('0x37')][_0xcef8('0x5b')]);}})['then'](respondWithStatusCode(_0x519dae,null))[_0xcef8('0x47')](handleError(_0x519dae,null));};exports[_0xcef8('0x5c')]=function(_0x139da5,_0x43cdf9,_0x2510bf){return db[_0xcef8('0x31')][_0xcef8('0x49')]({'where':{'id':_0x139da5[_0xcef8('0x48')]['id']}})['then'](handleEntityNotFound(_0x43cdf9,null))[_0xcef8('0x28')](function(_0x152aaf){if(_0x152aaf){var _0x5a67dc=[];var _0x31c3a1={'success':[],'errors':[]};return db[_0xcef8('0x5d')][_0xcef8('0x51')]()[_0xcef8('0x28')](function(_0x5619a9){if(_0x139da5[_0xcef8('0x50')][_0xcef8('0x5e')]&&_['isArray'](_0x139da5['body'][_0xcef8('0x5e')])){if(_0x139da5['body'][_0xcef8('0x5e')]['length']){_0x139da5[_0xcef8('0x50')][_0xcef8('0x5e')]=_0x139da5[_0xcef8('0x50')]['tags'][_0xcef8('0x5f')](';')+';';}else{_0x139da5[_0xcef8('0x50')][_0xcef8('0x5e')]=null;}}else{_0x139da5[_0xcef8('0x50')]['tags']=null;}if(_0x139da5['body']&&_[_0xcef8('0x60')](_0x139da5[_0xcef8('0x50')])){for(var _0x25083b=0x0;_0x25083b<_0x139da5['body'][_0xcef8('0x3c')];_0x25083b+=0x1){_0x139da5[_0xcef8('0x50')][_0x25083b][_0xcef8('0x53')]=_0x139da5['params']['id'];_0x5a67dc[_0xcef8('0x61')](_0x139da5['body'][_0x25083b]);}return BPromise['each'](_0x5a67dc,function(_0x5144fd){return db['CmContact']['create'](_['omit'](_0x5144fd,[_0xcef8('0x5b'),'id'])||{},{'fields':_['keys'](_0x5619a9),'raw':!![]})[_0xcef8('0x28')](function(_0x307106){_0x31c3a1['success'][_0xcef8('0x61')](_0x307106['dataValues']);})[_0xcef8('0x47')](function(_0x2b3f87){_0x31c3a1['errors'][_0xcef8('0x61')]({'data':_0x5144fd,'error':_0x2b3f87['message']});});})[_0xcef8('0x28')](function(_0x26f984){return _0x31c3a1;})['catch'](function(_0x55b76a){return _0x55b76a;});}else{_0x43cdf9[_0xcef8('0x1d')](0x190)[_0xcef8('0x62')]({'message':_0xcef8('0x63')});}});}})[_0xcef8('0x28')](respondWithResult(_0x43cdf9,null))[_0xcef8('0x47')](handleError(_0x43cdf9,null));};exports[_0xcef8('0x64')]=function(_0x2d4185,_0x234bfa,_0x598f48){var _0x546cc8;return db[_0xcef8('0x31')][_0xcef8('0x49')]({'where':{'id':_0x2d4185[_0xcef8('0x48')]['id']},'include':[{'model':db[_0xcef8('0x65')],'as':_0xcef8('0x66')}]})[_0xcef8('0x28')](handleEntityNotFound(_0x234bfa,null))[_0xcef8('0x28')](function(_0x343a3e){if(_0x343a3e){_0x546cc8=_0x343a3e;return db[_0xcef8('0x5d')]['rawAttributes'];}})[_0xcef8('0x28')](function(_0x2dfd3a){if(_0x2dfd3a){var _0x48e1ee={};var _0x4e8b9a={};_0x4e8b9a[_0xcef8('0x36')]=_[_0xcef8('0x67')](_[_0xcef8('0x38')](_0x2dfd3a),_[_0xcef8('0x30')](_0x546cc8[_0xcef8('0x66')],function(_0x31c3a0){return util[_0xcef8('0x68')](_0xcef8('0x69'),_0x31c3a0['id']);}));_0x4e8b9a[_0xcef8('0x37')]=_['keys'](_0x2d4185[_0xcef8('0x37')]);_0x4e8b9a['filters']=_[_0xcef8('0x39')](_0x4e8b9a['model'],_0x4e8b9a['query']);_0x48e1ee[_0xcef8('0x3a')]=_['intersection'](_0x4e8b9a[_0xcef8('0x36')],qs[_0xcef8('0x3b')](_0x2d4185[_0xcef8('0x37')][_0xcef8('0x3b')]));_0x48e1ee[_0xcef8('0x3a')]=_0x48e1ee[_0xcef8('0x3a')][_0xcef8('0x3c')]?_0x48e1ee[_0xcef8('0x3a')]:_0x4e8b9a['model'];if(!_0x2d4185['query'][_0xcef8('0x3d')](_0xcef8('0x56'))){_0x48e1ee[_0xcef8('0x20')]=qs[_0xcef8('0x20')](_0x2d4185[_0xcef8('0x37')][_0xcef8('0x20')]);_0x48e1ee[_0xcef8('0x22')]=qs[_0xcef8('0x22')](_0x2d4185[_0xcef8('0x37')][_0xcef8('0x22')]);}_0x48e1ee[_0xcef8('0x57')]=qs[_0xcef8('0x3e')](_0x2d4185['query'][_0xcef8('0x3e')]);_0x48e1ee[_0xcef8('0x3f')]=qs[_0xcef8('0x40')](_[_0xcef8('0x41')](_0x2d4185[_0xcef8('0x37')],_0x4e8b9a[_0xcef8('0x40')]));_0x48e1ee['raw']=!![];if(_0x2d4185[_0xcef8('0x37')][_0xcef8('0x42')]){_0x48e1ee['where']=_[_0xcef8('0x58')](_0x48e1ee[_0xcef8('0x3f')],{'$or':_['map'](_0x48e1ee[_0xcef8('0x3a')],function(_0x51d61c){var _0x4c3636={};_0x4c3636[_0x51d61c]={'$like':'%'+_0x2d4185['query'][_0xcef8('0x42')]+'%'};return _0x4c3636;})});}_0x48e1ee=_[_0xcef8('0x58')]({},_0x48e1ee,_0x2d4185['options']);return _0x546cc8[_0xcef8('0x64')](_0x48e1ee);}})[_0xcef8('0x28')](respondWithResult(_0x234bfa,null))[_0xcef8('0x47')](handleError(_0x234bfa,null));};exports[_0xcef8('0x6a')]=function(_0x5b1c62,_0x15dced,_0xf63a20){var _0x193132;return db[_0xcef8('0x31')][_0xcef8('0x49')]({'where':{'id':_0x5b1c62[_0xcef8('0x48')]['id']},'include':[{'model':db['CmCustomField'],'as':_0xcef8('0x66')}]})[_0xcef8('0x28')](handleEntityNotFound(_0x15dced,null))[_0xcef8('0x28')](function(_0x130570){if(_0x130570){_0x193132=_0x130570;return db[_0xcef8('0x5d')][_0xcef8('0x32')];}})[_0xcef8('0x28')](function(_0x2c0114){if(_0x2c0114){var _0x2601cb={};var _0x772b8d={};_0x772b8d[_0xcef8('0x36')]=_[_0xcef8('0x67')](_[_0xcef8('0x38')](_0x2c0114),_[_0xcef8('0x30')](_0x193132[_0xcef8('0x66')],function(_0x9561c){return util[_0xcef8('0x68')](_0xcef8('0x69'),_0x9561c['id']);}));_0x772b8d[_0xcef8('0x37')]=_['keys'](_0x5b1c62[_0xcef8('0x37')]);_0x772b8d['filters']=_[_0xcef8('0x39')](_0x772b8d[_0xcef8('0x36')],_0x772b8d[_0xcef8('0x37')]);_0x2601cb['attributes']=_[_0xcef8('0x39')](_0x772b8d[_0xcef8('0x36')],qs[_0xcef8('0x3b')](_0x5b1c62[_0xcef8('0x37')][_0xcef8('0x3b')]));_0x2601cb[_0xcef8('0x3a')]=_0x2601cb[_0xcef8('0x3a')][_0xcef8('0x3c')]?_0x2601cb['attributes']:_0x772b8d['model'];if(!_0x5b1c62[_0xcef8('0x37')][_0xcef8('0x3d')]('nolimit')){_0x2601cb['limit']=qs[_0xcef8('0x20')](_0x5b1c62[_0xcef8('0x37')][_0xcef8('0x20')]);_0x2601cb['offset']=qs[_0xcef8('0x22')](_0x5b1c62[_0xcef8('0x37')][_0xcef8('0x22')]);}_0x2601cb[_0xcef8('0x57')]=qs[_0xcef8('0x3e')](_0x5b1c62[_0xcef8('0x37')]['sort']);_0x2601cb[_0xcef8('0x3f')]=qs[_0xcef8('0x40')](_[_0xcef8('0x41')](_0x5b1c62['query'],_0x772b8d['filters']));_0x2601cb[_0xcef8('0x6b')]=!![];if(_0x5b1c62[_0xcef8('0x37')]['filter']){_0x2601cb[_0xcef8('0x3f')]=_[_0xcef8('0x58')](_0x2601cb[_0xcef8('0x3f')],{'$or':_[_0xcef8('0x30')](_0x2601cb[_0xcef8('0x3a')],function(_0x27e2d3){var _0x3d7821={};_0x3d7821[_0x27e2d3]={'$like':'%'+_0x5b1c62[_0xcef8('0x37')][_0xcef8('0x42')]+'%'};return _0x3d7821;})});}_0x2601cb=_[_0xcef8('0x58')]({},_0x2601cb,_0x5b1c62[_0xcef8('0x59')]);return _0x193132[_0xcef8('0x64')](_0x2601cb);}})[_0xcef8('0x28')](function(_0x36c992){if(!_[_0xcef8('0x6c')](_0x36c992)){var _0x3766f0=toCsv(_0x36c992);var _0x531e6b=Date[_0xcef8('0x6d')]();fs['writeFileSync'](util['format'](_0xcef8('0x6e'),_0x193132['id'],_0x531e6b),_0x3766f0);_0x15dced[_0xcef8('0x6f')](_0xcef8('0x70'),_0xcef8('0x71')+util[_0xcef8('0x68')](_0xcef8('0x72'),_0x193132['id'],_0x531e6b));_0x15dced[_0xcef8('0x6f')](_0xcef8('0x73'),_0xcef8('0x74'));return _0x15dced[_0xcef8('0x75')](util[_0xcef8('0x68')]('/tmp/list_%d_%s.csv',_0x193132['id'],_0x531e6b));}else{return _0x15dced[_0xcef8('0x1c')](0xcc);}})[_0xcef8('0x47')](handleError(_0x15dced,null));};exports[_0xcef8('0x76')]=function(_0x542c7f,_0x410e88,_0x142a8f){var _0x2dbe94;delete _0x542c7f[_0xcef8('0x50')]['id'];return db['CmList']['findOne']({'where':{'id':_0x542c7f['params']['id']}})['then'](handleEntityNotFound(_0x410e88,null))[_0xcef8('0x28')](function(_0x168388){if(_0x168388){return db[_0xcef8('0x77')][_0xcef8('0x78')](function(_0xcff59c){return db[_0xcef8('0x65')][_0xcef8('0x4a')](_0x542c7f['body'],{'transaction':_0xcff59c})[_0xcef8('0x28')](function(_0x2616d0){_0x2dbe94=_0x2616d0;return _0x168388[_0xcef8('0x79')](_0x2616d0,{'transaction':_0xcff59c});})[_0xcef8('0x28')](function(){var _0x1f53e2={'type':db['Sequelize']['TEXT'],'transaction':_0xcff59c};switch(_0x542c7f[_0xcef8('0x50')][_0xcef8('0x34')]){case _0xcef8('0x7a'):_0x1f53e2[_0xcef8('0x34')]=db[_0xcef8('0x7b')][_0xcef8('0x7c')];break;case'number':_0x1f53e2[_0xcef8('0x34')]=db[_0xcef8('0x7b')]['INTEGER'];break;case _0xcef8('0x7d'):_0x1f53e2[_0xcef8('0x34')]=db[_0xcef8('0x7b')][_0xcef8('0x7e')];_0x1f53e2[_0xcef8('0x7f')]=![];break;default:}return db[_0xcef8('0x77')][_0xcef8('0x80')][_0xcef8('0x81')](_0xcef8('0x82'),util[_0xcef8('0x68')]('cf_%s',_0x2dbe94['id']),_0x1f53e2);})[_0xcef8('0x28')](function(){return _0x2dbe94;});});}})['then'](respondWithResult(_0x410e88,null))['catch'](handleError(_0x410e88,null));};exports['getCustomFields']=function(_0x5d1262,_0x217a80,_0x3f67de){var _0xbc0d85={};var _0x4c0a54={};var _0x4fce5e;var _0x4faf5d;return db[_0xcef8('0x31')]['findOne']({'where':{'id':_0x5d1262['params']['id']}})['then'](handleEntityNotFound(_0x217a80,null))[_0xcef8('0x28')](function(_0x3c8274){if(_0x3c8274){_0x4fce5e=_0x3c8274;_0x4c0a54[_0xcef8('0x36')]=_[_0xcef8('0x38')](db['CmCustomField'][_0xcef8('0x32')]);_0x4c0a54[_0xcef8('0x37')]=_[_0xcef8('0x38')](_0x5d1262[_0xcef8('0x37')]);_0x4c0a54[_0xcef8('0x40')]=_[_0xcef8('0x39')](_0x4c0a54[_0xcef8('0x36')],_0x4c0a54[_0xcef8('0x37')]);_0xbc0d85[_0xcef8('0x3a')]=_[_0xcef8('0x39')](_0x4c0a54[_0xcef8('0x36')],qs[_0xcef8('0x3b')](_0x5d1262[_0xcef8('0x37')][_0xcef8('0x3b')]));_0xbc0d85[_0xcef8('0x3a')]=_0xbc0d85[_0xcef8('0x3a')][_0xcef8('0x3c')]?_0xbc0d85['attributes']:_0x4c0a54[_0xcef8('0x36')];_0xbc0d85[_0xcef8('0x57')]=qs['sort'](_0x5d1262[_0xcef8('0x37')]['sort']);_0xbc0d85[_0xcef8('0x3f')]=qs['filters'](_[_0xcef8('0x41')](_0x5d1262[_0xcef8('0x37')],_0x4c0a54[_0xcef8('0x40')]));_0xbc0d85['where']=_['merge'](_0xbc0d85[_0xcef8('0x3f')],{'$or':[{'ListId':_0x3c8274['id']},{'ListId':null}]});if(_0x5d1262[_0xcef8('0x37')]['filter']){_0xbc0d85[_0xcef8('0x3f')]=_[_0xcef8('0x58')](_0xbc0d85['where'],{'$or':_[_0xcef8('0x30')](_0xbc0d85[_0xcef8('0x3a')],function(_0x47f7d8){var _0x48ff48={};_0x48ff48[_0x47f7d8]={'$like':'%'+_0x5d1262[_0xcef8('0x37')][_0xcef8('0x42')]+'%'};return _0x48ff48;})});}_0xbc0d85=_[_0xcef8('0x58')]({},_0xbc0d85,_0x5d1262['options']);return db[_0xcef8('0x65')][_0xcef8('0x83')](_0xbc0d85);}})[_0xcef8('0x28')](respondWithResult(_0x217a80,null))[_0xcef8('0x47')](handleError(_0x217a80,null));};exports[_0xcef8('0x84')]=function(_0x4f4d62,_0x322529,_0x768cac){return db[_0xcef8('0x31')][_0xcef8('0x49')]({'where':{'id':_0x4f4d62[_0xcef8('0x48')]['id']}})[_0xcef8('0x28')](handleEntityNotFound(_0x322529,null))[_0xcef8('0x28')](function(_0x21120f){if(_0x21120f){return _0x21120f[_0xcef8('0x84')](_0x4f4d62[_0xcef8('0x50')][_0xcef8('0x5b')],_['omit'](_0x4f4d62[_0xcef8('0x50')],[_0xcef8('0x5b'),'id'])||{})[_0xcef8('0x85')](function(_0x559a41){for(var _0x4f8336=0x0;_0x4f8336<_0x4f4d62['body'][_0xcef8('0x5b')][_0xcef8('0x3c')];_0x4f8336+=0x1){socket[_0xcef8('0x86')]('userCmList:save',{'UserId':Number(_0x4f4d62[_0xcef8('0x50')]['ids'][_0x4f8336]),'CmListId':Number(_0x4f4d62[_0xcef8('0x48')]['id'])});}return _0x559a41;});}})[_0xcef8('0x28')](respondWithResult(_0x322529,null))[_0xcef8('0x47')](handleError(_0x322529,null));};exports['removeAgents']=function(_0x31b0c2,_0x1d7173,_0x474258){return db[_0xcef8('0x31')][_0xcef8('0x49')]({'where':{'id':_0x31b0c2[_0xcef8('0x48')]['id']}})['then'](handleEntityNotFound(_0x1d7173,null))['then'](function(_0x3dcb3a){if(_0x3dcb3a){return _0x3dcb3a[_0xcef8('0x87')](_0x31b0c2[_0xcef8('0x37')][_0xcef8('0x5b')])[_0xcef8('0x28')](function(){if(_['isArray'](_0x31b0c2[_0xcef8('0x37')]['ids'])){for(var _0x4acdcc=0x0;_0x4acdcc<_0x31b0c2[_0xcef8('0x37')][_0xcef8('0x5b')][_0xcef8('0x3c')];_0x4acdcc+=0x1){socket['emit'](_0xcef8('0x88'),{'UserId':Number(_0x31b0c2['query'][_0xcef8('0x5b')][_0x4acdcc]),'CmListId':Number(_0x31b0c2['params']['id'])});}}else{socket['emit']('userCmList:remove',{'UserId':Number(_0x31b0c2[_0xcef8('0x37')][_0xcef8('0x5b')]),'CmListId':Number(_0x31b0c2['params']['id'])});}});}})[_0xcef8('0x28')](respondWithStatusCode(_0x1d7173,null))[_0xcef8('0x47')](handleError(_0x1d7173,null));};exports['getAgents']=function(_0x4007fc,_0x29fbe0,_0x4a2768){var _0x2b6ba3={};var _0x3999ce={};var _0x3d7057;var _0x291164;return db['CmList'][_0xcef8('0x89')]({'where':{'id':_0x4007fc[_0xcef8('0x48')]['id']}})[_0xcef8('0x28')](handleEntityNotFound(_0x29fbe0,null))['then'](function(_0x28f250){if(_0x28f250){_0x3d7057=_0x28f250;_0x3999ce[_0xcef8('0x36')]=_['keys'](db[_0xcef8('0x8a')][_0xcef8('0x32')]);_0x3999ce[_0xcef8('0x37')]=_[_0xcef8('0x38')](_0x4007fc[_0xcef8('0x37')]);_0x3999ce['filters']=_[_0xcef8('0x39')](_0x3999ce[_0xcef8('0x36')],_0x3999ce[_0xcef8('0x37')]);_0x2b6ba3[_0xcef8('0x3a')]=_[_0xcef8('0x39')](_0x3999ce[_0xcef8('0x36')],qs[_0xcef8('0x3b')](_0x4007fc['query']['fields']));_0x2b6ba3[_0xcef8('0x3a')]=_0x2b6ba3[_0xcef8('0x3a')][_0xcef8('0x3c')]?_0x2b6ba3[_0xcef8('0x3a')]:_0x3999ce[_0xcef8('0x36')];_0x2b6ba3[_0xcef8('0x57')]=qs['sort'](_0x4007fc[_0xcef8('0x37')][_0xcef8('0x3e')]);_0x2b6ba3[_0xcef8('0x3f')]=qs[_0xcef8('0x40')](_['pick'](_0x4007fc[_0xcef8('0x37')],_0x3999ce['filters']));if(_0x4007fc[_0xcef8('0x37')]['filter']){_0x2b6ba3[_0xcef8('0x3f')]=_[_0xcef8('0x58')](_0x2b6ba3[_0xcef8('0x3f')],{'$or':_['map'](_0x2b6ba3[_0xcef8('0x3a')],function(_0x2b66c0){var _0x1a97a7={};_0x1a97a7[_0x2b66c0]={'$like':'%'+_0x4007fc[_0xcef8('0x37')][_0xcef8('0x42')]+'%'};return _0x1a97a7;})});}_0x2b6ba3=_[_0xcef8('0x58')]({},_0x2b6ba3,_0x4007fc['options']);return _0x3d7057[_0xcef8('0x8b')](_0x2b6ba3);}})[_0xcef8('0x28')](function(_0xb1a9d7){if(_0xb1a9d7){_0x291164=_0xb1a9d7['length'];if(!_0x4007fc[_0xcef8('0x37')][_0xcef8('0x3d')]('nolimit')){_0x2b6ba3['limit']=qs[_0xcef8('0x20')](_0x4007fc['query'][_0xcef8('0x20')]);_0x2b6ba3[_0xcef8('0x22')]=qs[_0xcef8('0x22')](_0x4007fc[_0xcef8('0x37')]['offset']);}return _0x3d7057['getAgents'](_0x2b6ba3);}})[_0xcef8('0x28')](function(_0x390094){if(_0x390094){return _0x390094?{'count':_0x291164,'rows':_0x390094}:null;}})['then'](respondWithResult(_0x29fbe0,null))['catch'](handleError(_0x29fbe0,null));};
\ No newline at end of file
+var _0x8f93=['CmCustomField','CustomFields','format','cf_%d','raw','getContacts','getContactsCsv','ContactItemType','OrderBy','alias','select','from','cm_contacts','c.ListId\x20=\x20?','c.deletedAt\x20is\x20null','field','cm_contact_has_items','ItemTypeId\x20=\x20?','CmContactId\x20=\x20c.id','additionalPhone_','description_additionalPhone_','toString','isEmpty','now','writeFileSync','/tmp/list_%d_%s.csv','setHeader','list_%d_%s.csv','text/csv','download','transaction','addCustomFields','Sequelize','TEXT','number','type','switch','BOOLEAN','sequelize','addColumn','cf_%s','findAndCountAll','getGlobalCustomFields','addAgents','spread','userCmList:save','removeAgents','emit','userCmList:remove','getAgents','User','info','message','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','util','sox','to-csv','ejs','fs-extra','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','../../config/utils','../../config/environment','../../mysqldb','redis','defaults','localhost','./cmList.socket','sendStatus','status','end','offset','undefined','limit','count','Content-Range','reject','save','then','destroy','get','UserProfileResource','error','stack','send','index','rawAttributes','fieldName','key','model','map','name','query','keys','filters','intersection','attributes','hasOwnProperty','sort','where','pick','merge','VIRTUAL','filter','options','CmList','includeAll','include','findAll','catch','show','params','fields','create','body','role','Lists','UserProfileSection','find','userProfileId','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','update','describe','addDisposition','ListId','findOne','Disposition','length','nolimit','order','rows','removeDispositions','ids','addContacts','CmContact','isArray','tags','join','push','each','omit','success','dataValues','json'];(function(_0x5d5bcb,_0x25e2ea){var _0x4ea5eb=function(_0x36782b){while(--_0x36782b){_0x5d5bcb['push'](_0x5d5bcb['shift']());}};_0x4ea5eb(++_0x25e2ea);}(_0x8f93,0xd4));var _0x38f9=function(_0x40a045,_0x516f0e){_0x40a045=_0x40a045-0x0;var _0x1a687c=_0x8f93[_0x40a045];return _0x1a687c;};'use strict';var emlformat=require(_0x38f9('0x0'));var rimraf=require(_0x38f9('0x1'));var zipdir=require(_0x38f9('0x2'));var jsonpatch=require(_0x38f9('0x3'));var rp=require(_0x38f9('0x4'));var moment=require(_0x38f9('0x5'));var BPromise=require(_0x38f9('0x6'));var Mustache=require('mustache');var util=require(_0x38f9('0x7'));var path=require('path');var sox=require(_0x38f9('0x8'));var csv=require(_0x38f9('0x9'));var ejs=require(_0x38f9('0xa'));var fs=require('fs');var fs_extra=require(_0x38f9('0xb'));var _=require('lodash');var squel=require(_0x38f9('0xc'));var crypto=require(_0x38f9('0xd'));var jsforce=require(_0x38f9('0xe'));var deskjs=require(_0x38f9('0xf'));var toCsv=require(_0x38f9('0x9'));var querystring=require(_0x38f9('0x10'));var Papa=require(_0x38f9('0x11'));var Redis=require(_0x38f9('0x12'));var authService=require(_0x38f9('0x13'));var qs=require(_0x38f9('0x14'));var as=require(_0x38f9('0x15'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x38f9('0x16'))('api');var utils=require(_0x38f9('0x17'));var config=require(_0x38f9('0x18'));var licenseUtil=require('../../config/license/util');var db=require(_0x38f9('0x19'))['db'];var csv_results;config[_0x38f9('0x1a')]=_[_0x38f9('0x1b')](config[_0x38f9('0x1a')],{'host':_0x38f9('0x1c'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x38f9('0x1a')]));require(_0x38f9('0x1d'))['register'](socket);function respondWithStatusCode(_0x356d6b,_0x540235){_0x540235=_0x540235||0xcc;return function(_0x219f74){if(_0x219f74){return _0x356d6b[_0x38f9('0x1e')](_0x540235);}return _0x356d6b[_0x38f9('0x1f')](_0x540235)[_0x38f9('0x20')]();};}function respondWithResult(_0x1711ba,_0x12909f){_0x12909f=_0x12909f||0xc8;return function(_0x50d0ee){if(_0x50d0ee){return _0x1711ba[_0x38f9('0x1f')](_0x12909f)['json'](_0x50d0ee);}};}function respondWithFilteredResult(_0x22ff34,_0x223206){return function(_0x3b96d2){if(_0x3b96d2){var _0x5c21bc=typeof _0x223206[_0x38f9('0x21')]===_0x38f9('0x22')&&typeof _0x223206[_0x38f9('0x23')]===_0x38f9('0x22');var _0x3bbcc2=_0x3b96d2[_0x38f9('0x24')];var _0x40d217=_0x5c21bc?0x0:_0x223206[_0x38f9('0x21')];var _0x3e79de=_0x5c21bc?_0x3b96d2[_0x38f9('0x24')]:_0x223206['offset']+_0x223206[_0x38f9('0x23')];var _0x486c99;if(_0x3e79de>=_0x3bbcc2){_0x3e79de=_0x3bbcc2;_0x486c99=0xc8;}else{_0x486c99=0xce;}_0x22ff34['status'](_0x486c99);return _0x22ff34['set'](_0x38f9('0x25'),_0x40d217+'-'+_0x3e79de+'/'+_0x3bbcc2)['json'](_0x3b96d2);}return null;};}function patchUpdates(_0x300097){return function(_0x2edf68){try{jsonpatch['apply'](_0x2edf68,_0x300097,!![]);}catch(_0x49e6cb){return BPromise[_0x38f9('0x26')](_0x49e6cb);}return _0x2edf68[_0x38f9('0x27')]();};}function saveUpdates(_0x2373fd,_0x286558){return function(_0x159673){if(_0x159673){return _0x159673['update'](_0x2373fd)[_0x38f9('0x28')](function(_0x5ce441){return _0x5ce441;});}return null;};}function removeEntity(_0x29fb86,_0x4ef68a){return function(_0x45b92a){if(_0x45b92a){return _0x45b92a[_0x38f9('0x29')]()[_0x38f9('0x28')](function(){var _0x3ff098=_0x45b92a[_0x38f9('0x2a')]({'plain':!![]});var _0x5a9233='Lists';return db[_0x38f9('0x2b')][_0x38f9('0x29')]({'where':{'type':_0x5a9233,'resourceId':_0x3ff098['id']}})[_0x38f9('0x28')](function(){return _0x45b92a;});})[_0x38f9('0x28')](function(){_0x29fb86[_0x38f9('0x1f')](0xcc)[_0x38f9('0x20')]();});}};}function handleEntityNotFound(_0x2d7f32,_0x30047a){return function(_0x517484){if(!_0x517484){_0x2d7f32[_0x38f9('0x1e')](0x194);}return _0x517484;};}function handleError(_0x3e74db,_0x4c4997){_0x4c4997=_0x4c4997||0x1f4;return function(_0xf55627){logger[_0x38f9('0x2c')](_0xf55627[_0x38f9('0x2d')]);if(_0xf55627['name']){delete _0xf55627['name'];}_0x3e74db[_0x38f9('0x1f')](_0x4c4997)[_0x38f9('0x2e')](_0xf55627);};}exports[_0x38f9('0x2f')]=function(_0x295f17,_0x273309){var _0x5768cf={},_0x26bdbe={},_0x1feafe={'count':0x0,'rows':[]};var _0x5ebf4f=_['map'](db['CmList'][_0x38f9('0x30')],function(_0x4c4600){return{'name':_0x4c4600[_0x38f9('0x31')],'type':_0x4c4600['type'][_0x38f9('0x32')]};});_0x26bdbe[_0x38f9('0x33')]=_[_0x38f9('0x34')](_0x5ebf4f,_0x38f9('0x35'));_0x26bdbe[_0x38f9('0x36')]=_[_0x38f9('0x37')](_0x295f17[_0x38f9('0x36')]);_0x26bdbe[_0x38f9('0x38')]=_[_0x38f9('0x39')](_0x26bdbe[_0x38f9('0x33')],_0x26bdbe[_0x38f9('0x36')]);_0x5768cf[_0x38f9('0x3a')]=_[_0x38f9('0x39')](_0x26bdbe[_0x38f9('0x33')],qs['fields'](_0x295f17[_0x38f9('0x36')]['fields']));_0x5768cf[_0x38f9('0x3a')]=_0x5768cf[_0x38f9('0x3a')]['length']?_0x5768cf[_0x38f9('0x3a')]:_0x26bdbe[_0x38f9('0x33')];if(!_0x295f17[_0x38f9('0x36')][_0x38f9('0x3b')]('nolimit')){_0x5768cf['limit']=qs[_0x38f9('0x23')](_0x295f17[_0x38f9('0x36')][_0x38f9('0x23')]);_0x5768cf[_0x38f9('0x21')]=qs[_0x38f9('0x21')](_0x295f17[_0x38f9('0x36')][_0x38f9('0x21')]);}_0x5768cf['order']=qs[_0x38f9('0x3c')](_0x295f17['query'][_0x38f9('0x3c')]);_0x5768cf[_0x38f9('0x3d')]=qs[_0x38f9('0x38')](_[_0x38f9('0x3e')](_0x295f17['query'],_0x26bdbe[_0x38f9('0x38')]),_0x5ebf4f);if(_0x295f17[_0x38f9('0x36')]['filter']){_0x5768cf[_0x38f9('0x3d')]=_[_0x38f9('0x3f')](_0x5768cf[_0x38f9('0x3d')],{'$or':_[_0x38f9('0x34')](_0x5ebf4f,function(_0x52cc92){if(_0x52cc92['type']!==_0x38f9('0x40')){var _0xdefcee={};_0xdefcee[_0x52cc92[_0x38f9('0x35')]]={'$like':'%'+_0x295f17[_0x38f9('0x36')][_0x38f9('0x41')]+'%'};return _0xdefcee;}})});}_0x5768cf=_[_0x38f9('0x3f')]({},_0x5768cf,_0x295f17[_0x38f9('0x42')]);var _0x54d1ef={'where':_0x5768cf[_0x38f9('0x3d')]};return db[_0x38f9('0x43')][_0x38f9('0x24')](_0x54d1ef)[_0x38f9('0x28')](function(_0x66a777){_0x1feafe[_0x38f9('0x24')]=_0x66a777;if(_0x295f17['query'][_0x38f9('0x44')]){_0x5768cf[_0x38f9('0x45')]=[{'all':!![]}];}return db['CmList'][_0x38f9('0x46')](_0x5768cf);})[_0x38f9('0x28')](function(_0x170b6a){_0x1feafe['rows']=_0x170b6a;return _0x1feafe;})[_0x38f9('0x28')](respondWithFilteredResult(_0x273309,_0x5768cf))[_0x38f9('0x47')](handleError(_0x273309,null));};exports[_0x38f9('0x48')]=function(_0x1a8261,_0x1561d7){var _0x17a00={'raw':![],'where':{'id':_0x1a8261[_0x38f9('0x49')]['id']}},_0x15e653={};_0x15e653[_0x38f9('0x33')]=_[_0x38f9('0x37')](db[_0x38f9('0x43')][_0x38f9('0x30')]);_0x15e653['query']=_[_0x38f9('0x37')](_0x1a8261['query']);_0x15e653[_0x38f9('0x38')]=_[_0x38f9('0x39')](_0x15e653[_0x38f9('0x33')],_0x15e653[_0x38f9('0x36')]);_0x17a00[_0x38f9('0x3a')]=_[_0x38f9('0x39')](_0x15e653[_0x38f9('0x33')],qs['fields'](_0x1a8261[_0x38f9('0x36')][_0x38f9('0x4a')]));_0x17a00[_0x38f9('0x3a')]=_0x17a00[_0x38f9('0x3a')]['length']?_0x17a00[_0x38f9('0x3a')]:_0x15e653[_0x38f9('0x33')];if(_0x1a8261[_0x38f9('0x36')]['includeAll']){_0x17a00[_0x38f9('0x45')]=[{'all':!![]}];}_0x17a00=_[_0x38f9('0x3f')]({},_0x17a00,_0x1a8261[_0x38f9('0x42')]);return db[_0x38f9('0x43')]['find'](_0x17a00)[_0x38f9('0x28')](handleEntityNotFound(_0x1561d7,null))[_0x38f9('0x28')](respondWithResult(_0x1561d7,null))['catch'](handleError(_0x1561d7,null));};exports[_0x38f9('0x4b')]=function(_0x4065fe,_0xc2cab9){return db[_0x38f9('0x43')][_0x38f9('0x4b')](_0x4065fe[_0x38f9('0x4c')],{})[_0x38f9('0x28')](function(_0x5173cd){var _0x78e602=_0x4065fe['user']['get']({'plain':!![]});if(!_0x78e602)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x78e602[_0x38f9('0x4d')]==='user'){var _0x1765e7=_0x5173cd[_0x38f9('0x2a')]({'plain':!![]});var _0x13d23a=_0x38f9('0x4e');return db[_0x38f9('0x4f')][_0x38f9('0x50')]({'where':{'name':_0x13d23a,'userProfileId':_0x78e602[_0x38f9('0x51')]},'raw':!![]})[_0x38f9('0x28')](function(_0x48f529){if(_0x48f529&&_0x48f529['autoAssociation']===0x0){return db[_0x38f9('0x2b')]['create']({'name':_0x1765e7[_0x38f9('0x35')],'resourceId':_0x1765e7['id'],'type':_0x48f529[_0x38f9('0x35')],'sectionId':_0x48f529['id']},{})[_0x38f9('0x28')](function(){return _0x5173cd;});}else{return _0x5173cd;}})['catch'](function(_0x328ce0){logger['error'](_0x38f9('0x52'),_0x328ce0);throw _0x328ce0;});}return _0x5173cd;})[_0x38f9('0x28')](respondWithResult(_0xc2cab9,0xc9))[_0x38f9('0x47')](handleError(_0xc2cab9,null));};exports[_0x38f9('0x53')]=function(_0x3fefb9,_0x1a17f5){if(_0x3fefb9[_0x38f9('0x4c')]['id']){delete _0x3fefb9['body']['id'];}return db[_0x38f9('0x43')][_0x38f9('0x50')]({'where':{'id':_0x3fefb9[_0x38f9('0x49')]['id']}})['then'](handleEntityNotFound(_0x1a17f5,null))[_0x38f9('0x28')](saveUpdates(_0x3fefb9[_0x38f9('0x4c')],null))['then'](respondWithResult(_0x1a17f5,null))[_0x38f9('0x47')](handleError(_0x1a17f5,null));};exports['destroy']=function(_0x5783c1,_0x10aa42){return db['CmList'][_0x38f9('0x50')]({'where':{'id':_0x5783c1['params']['id']}})[_0x38f9('0x28')](handleEntityNotFound(_0x10aa42,null))[_0x38f9('0x28')](removeEntity(_0x10aa42,null))[_0x38f9('0x47')](handleError(_0x10aa42,null));};exports[_0x38f9('0x54')]=function(_0x89fc80,_0x2b2813){return db['CmList']['describe']()[_0x38f9('0x28')](respondWithResult(_0x2b2813,null))['catch'](handleError(_0x2b2813,null));};exports[_0x38f9('0x55')]=function(_0x371d4d,_0x383f3a,_0x360781){if(_0x371d4d[_0x38f9('0x4c')]['id']){delete _0x371d4d[_0x38f9('0x4c')]['id'];}return db[_0x38f9('0x43')][_0x38f9('0x50')]({'where':{'id':_0x371d4d[_0x38f9('0x49')]['id']}})[_0x38f9('0x28')](handleEntityNotFound(_0x383f3a,null))[_0x38f9('0x28')](function(_0x300fbd){if(_0x300fbd){_0x371d4d[_0x38f9('0x4c')][_0x38f9('0x56')]=_0x300fbd['id'];return db['Disposition'][_0x38f9('0x4b')](_0x371d4d[_0x38f9('0x4c')]);}})[_0x38f9('0x28')](respondWithResult(_0x383f3a,null))['catch'](handleError(_0x383f3a,null));};exports['getDispositions']=function(_0x4303c9,_0x373914,_0x232c6f){var _0x36c664={'raw':![],'where':{}};var _0x3ef01f={};var _0x368868={'count':0x0,'rows':[]};return db[_0x38f9('0x43')][_0x38f9('0x57')]({'where':{'id':_0x4303c9[_0x38f9('0x49')]['id']}})[_0x38f9('0x28')](handleEntityNotFound(_0x373914,null))[_0x38f9('0x28')](function(_0x1dc7fa){if(_0x1dc7fa){_0x3ef01f[_0x38f9('0x33')]=_[_0x38f9('0x37')](db[_0x38f9('0x58')][_0x38f9('0x30')]);_0x3ef01f[_0x38f9('0x36')]=_[_0x38f9('0x37')](_0x4303c9[_0x38f9('0x36')]);_0x3ef01f[_0x38f9('0x38')]=_[_0x38f9('0x39')](_0x3ef01f[_0x38f9('0x33')],_0x3ef01f[_0x38f9('0x36')]);_0x36c664[_0x38f9('0x3a')]=_[_0x38f9('0x39')](_0x3ef01f[_0x38f9('0x33')],qs['fields'](_0x4303c9['query']['fields']));_0x36c664[_0x38f9('0x3a')]=_0x36c664['attributes'][_0x38f9('0x59')]?_0x36c664[_0x38f9('0x3a')]:_0x3ef01f[_0x38f9('0x33')];if(!_0x4303c9['query'][_0x38f9('0x3b')](_0x38f9('0x5a'))){_0x36c664[_0x38f9('0x23')]=qs[_0x38f9('0x23')](_0x4303c9[_0x38f9('0x36')]['limit']);_0x36c664[_0x38f9('0x21')]=qs[_0x38f9('0x21')](_0x4303c9[_0x38f9('0x36')][_0x38f9('0x21')]);}_0x36c664[_0x38f9('0x5b')]=qs['sort'](_0x4303c9['query'][_0x38f9('0x3c')]);_0x36c664[_0x38f9('0x3d')]=qs[_0x38f9('0x38')](_[_0x38f9('0x3e')](_0x4303c9[_0x38f9('0x36')],_0x3ef01f['filters']));_0x36c664[_0x38f9('0x3d')][_0x38f9('0x56')]=_0x1dc7fa['id'];if(_0x4303c9[_0x38f9('0x36')][_0x38f9('0x41')]){_0x36c664[_0x38f9('0x3d')]=_['merge'](_0x36c664['where'],{'$or':_[_0x38f9('0x34')](_0x36c664[_0x38f9('0x3a')],function(_0x31e92e){var _0x50ea54={};_0x50ea54[_0x31e92e]={'$like':'%'+_0x4303c9[_0x38f9('0x36')][_0x38f9('0x41')]+'%'};return _0x50ea54;})});}_0x36c664=_['merge']({},_0x36c664,_0x4303c9[_0x38f9('0x42')]);return db[_0x38f9('0x58')][_0x38f9('0x24')]({'where':_0x36c664[_0x38f9('0x3d')]})[_0x38f9('0x28')](function(_0x5d34f6){_0x368868['count']=_0x5d34f6;if(_0x4303c9[_0x38f9('0x36')]['includeAll']){_0x36c664['include']=[{'all':!![]}];}return db[_0x38f9('0x58')][_0x38f9('0x46')](_0x36c664);})[_0x38f9('0x28')](function(_0x9d7ce2){_0x368868[_0x38f9('0x5c')]=_0x9d7ce2;return _0x368868;});}})[_0x38f9('0x28')](respondWithFilteredResult(_0x373914,_0x36c664))[_0x38f9('0x47')](handleError(_0x373914,null));};exports[_0x38f9('0x5d')]=function(_0x5e23c6,_0x489568,_0x3d4cea){return db['CmList'][_0x38f9('0x50')]({'where':{'id':_0x5e23c6[_0x38f9('0x49')]['id']}})['then'](handleEntityNotFound(_0x489568,null))['then'](function(_0x19796d){if(_0x19796d){return _0x19796d[_0x38f9('0x5d')](_0x5e23c6[_0x38f9('0x36')][_0x38f9('0x5e')]);}})['then'](respondWithStatusCode(_0x489568,null))[_0x38f9('0x47')](handleError(_0x489568,null));};exports[_0x38f9('0x5f')]=function(_0x5b7ad4,_0x128f6b,_0x38fdb2){return db[_0x38f9('0x43')][_0x38f9('0x50')]({'where':{'id':_0x5b7ad4[_0x38f9('0x49')]['id']}})[_0x38f9('0x28')](handleEntityNotFound(_0x128f6b,null))[_0x38f9('0x28')](function(_0x12279f){if(_0x12279f){var _0x24ab3e=[];var _0x84d4={'success':[],'errors':[]};return db[_0x38f9('0x60')][_0x38f9('0x54')]()[_0x38f9('0x28')](function(_0x236cc7){if(_0x5b7ad4[_0x38f9('0x4c')]['tags']&&_[_0x38f9('0x61')](_0x5b7ad4[_0x38f9('0x4c')][_0x38f9('0x62')])){if(_0x5b7ad4[_0x38f9('0x4c')][_0x38f9('0x62')][_0x38f9('0x59')]){_0x5b7ad4[_0x38f9('0x4c')][_0x38f9('0x62')]=_0x5b7ad4[_0x38f9('0x4c')][_0x38f9('0x62')][_0x38f9('0x63')](';')+';';}else{_0x5b7ad4[_0x38f9('0x4c')][_0x38f9('0x62')]=null;}}else{_0x5b7ad4['body'][_0x38f9('0x62')]=null;}if(_0x5b7ad4[_0x38f9('0x4c')]&&_[_0x38f9('0x61')](_0x5b7ad4[_0x38f9('0x4c')])){for(var _0x5b55a1=0x0;_0x5b55a1<_0x5b7ad4[_0x38f9('0x4c')][_0x38f9('0x59')];_0x5b55a1+=0x1){_0x5b7ad4[_0x38f9('0x4c')][_0x5b55a1][_0x38f9('0x56')]=_0x5b7ad4[_0x38f9('0x49')]['id'];_0x24ab3e[_0x38f9('0x64')](_0x5b7ad4['body'][_0x5b55a1]);}return BPromise[_0x38f9('0x65')](_0x24ab3e,function(_0x541b6c){return db['CmContact'][_0x38f9('0x4b')](_[_0x38f9('0x66')](_0x541b6c,['ids','id'])||{},{'fields':_[_0x38f9('0x37')](_0x236cc7),'raw':!![]})['then'](function(_0x112c6b){_0x84d4[_0x38f9('0x67')][_0x38f9('0x64')](_0x112c6b[_0x38f9('0x68')]);})[_0x38f9('0x47')](function(_0x46077a){_0x84d4['errors'][_0x38f9('0x64')]({'data':_0x541b6c,'error':_0x46077a['message']});});})[_0x38f9('0x28')](function(_0x562d39){return _0x84d4;})['catch'](function(_0x48971d){return _0x48971d;});}else{_0x128f6b[_0x38f9('0x1f')](0x190)[_0x38f9('0x69')]({'message':'Malformed\x20request\x20syntax'});}});}})[_0x38f9('0x28')](respondWithResult(_0x128f6b,null))[_0x38f9('0x47')](handleError(_0x128f6b,null));};exports['getContacts']=function(_0x3763f6,_0x421632,_0x153caa){var _0x166f17;return db[_0x38f9('0x43')][_0x38f9('0x50')]({'where':{'id':_0x3763f6[_0x38f9('0x49')]['id']},'include':[{'model':db[_0x38f9('0x6a')],'as':_0x38f9('0x6b')}]})[_0x38f9('0x28')](handleEntityNotFound(_0x421632,null))[_0x38f9('0x28')](function(_0x11f463){if(_0x11f463){_0x166f17=_0x11f463;return db[_0x38f9('0x60')]['rawAttributes'];}})[_0x38f9('0x28')](function(_0x1bdd1e){if(_0x1bdd1e){var _0x27f5ed={};var _0xca412b={};_0xca412b[_0x38f9('0x33')]=_['concat'](_[_0x38f9('0x37')](_0x1bdd1e),_[_0x38f9('0x34')](_0x166f17['CustomFields'],function(_0x489a1a){return util[_0x38f9('0x6c')](_0x38f9('0x6d'),_0x489a1a['id']);}));_0xca412b[_0x38f9('0x36')]=_['keys'](_0x3763f6[_0x38f9('0x36')]);_0xca412b[_0x38f9('0x38')]=_['intersection'](_0xca412b['model'],_0xca412b[_0x38f9('0x36')]);_0x27f5ed[_0x38f9('0x3a')]=_[_0x38f9('0x39')](_0xca412b[_0x38f9('0x33')],qs['fields'](_0x3763f6['query'][_0x38f9('0x4a')]));_0x27f5ed[_0x38f9('0x3a')]=_0x27f5ed[_0x38f9('0x3a')][_0x38f9('0x59')]?_0x27f5ed[_0x38f9('0x3a')]:_0xca412b[_0x38f9('0x33')];if(!_0x3763f6[_0x38f9('0x36')][_0x38f9('0x3b')](_0x38f9('0x5a'))){_0x27f5ed[_0x38f9('0x23')]=qs[_0x38f9('0x23')](_0x3763f6[_0x38f9('0x36')][_0x38f9('0x23')]);_0x27f5ed[_0x38f9('0x21')]=qs[_0x38f9('0x21')](_0x3763f6[_0x38f9('0x36')][_0x38f9('0x21')]);}_0x27f5ed[_0x38f9('0x5b')]=qs[_0x38f9('0x3c')](_0x3763f6[_0x38f9('0x36')][_0x38f9('0x3c')]);_0x27f5ed[_0x38f9('0x3d')]=qs[_0x38f9('0x38')](_[_0x38f9('0x3e')](_0x3763f6[_0x38f9('0x36')],_0xca412b[_0x38f9('0x38')]));_0x27f5ed[_0x38f9('0x6e')]=!![];if(_0x3763f6[_0x38f9('0x36')][_0x38f9('0x41')]){_0x27f5ed['where']=_['merge'](_0x27f5ed[_0x38f9('0x3d')],{'$or':_[_0x38f9('0x34')](_0x27f5ed['attributes'],function(_0x257ee7){var _0x563136={};_0x563136[_0x257ee7]={'$like':'%'+_0x3763f6['query'][_0x38f9('0x41')]+'%'};return _0x563136;})});}_0x27f5ed=_[_0x38f9('0x3f')]({},_0x27f5ed,_0x3763f6[_0x38f9('0x42')]);return _0x166f17[_0x38f9('0x6f')](_0x27f5ed);}})[_0x38f9('0x28')](respondWithResult(_0x421632,null))[_0x38f9('0x47')](handleError(_0x421632,null));};exports[_0x38f9('0x70')]=function(_0x1dc379,_0x265fdf,_0x17bfdf){var _0x163423;var _0x35a582;var _0x265b14;var _0x392673=_0x1dc379[_0x38f9('0x49')]['id'];csv_results=[];return db[_0x38f9('0x71')][_0x38f9('0x46')]({'attributes':['id',_0x38f9('0x35')],'raw':!![],'order':[_0x38f9('0x72')]})[_0x38f9('0x28')](function(_0x30db3a){_0x163423=_0x30db3a;var _0x3e9799=_['keys'](db[_0x38f9('0x60')][_0x38f9('0x30')]);return db[_0x38f9('0x6a')][_0x38f9('0x46')]({'raw':!![],'attributes':['id',_0x38f9('0x73')]})[_0x38f9('0x28')](function(_0x44e9d4){_0x35a582=_0x44e9d4;var _0x3f0c12=squel[_0x38f9('0x74')]()[_0x38f9('0x4a')](_0x3e9799)[_0x38f9('0x75')](_0x38f9('0x76'),'c')[_0x38f9('0x3d')](_0x38f9('0x77'),_0x392673)[_0x38f9('0x3d')](_0x38f9('0x78'))['distinct']();for(var _0x1607c7=0x0;_0x1607c7<_0x35a582['length'];_0x1607c7++){_0x3f0c12[_0x38f9('0x79')]('c.cf_'+_0x35a582[_0x1607c7]['id'],'customField_'+_0x35a582[_0x1607c7]['alias']);}for(var _0x1607c7=0x0;_0x1607c7<_0x163423['length'];_0x1607c7++){_0x3f0c12[_0x38f9('0x79')](squel[_0x38f9('0x74')]()['field']('item')[_0x38f9('0x75')](_0x38f9('0x7a'))[_0x38f9('0x3d')](_0x38f9('0x7b'),_0x163423[_0x1607c7]['id'])[_0x38f9('0x3d')](_0x38f9('0x7c')),_0x38f9('0x7d')+_0x163423[_0x1607c7][_0x38f9('0x35')]);_0x3f0c12[_0x38f9('0x79')](squel[_0x38f9('0x74')]()['field']('description')[_0x38f9('0x75')](_0x38f9('0x7a'))[_0x38f9('0x3d')]('ItemTypeId\x20=\x20?',_0x163423[_0x1607c7]['id'])[_0x38f9('0x3d')](_0x38f9('0x7c')),_0x38f9('0x7e')+_0x163423[_0x1607c7][_0x38f9('0x35')]);}var _0x8eecb=[];_0x8eecb['push'](_0x3f0c12[_0x38f9('0x7f')]());BPromise[_0x38f9('0x65')](_0x8eecb,handleQuery)['then'](function(_0x4be6ad){handleQuery(_0x3f0c12[_0x38f9('0x7f')]());var _0x856e52=csv_results[0x0];if(!_[_0x38f9('0x80')](_0x856e52)){var _0x134c4f=toCsv(_0x856e52);var _0x27d8a3=Date[_0x38f9('0x81')]();fs[_0x38f9('0x82')](util[_0x38f9('0x6c')](_0x38f9('0x83'),_0x392673,_0x27d8a3),_0x134c4f);_0x265fdf[_0x38f9('0x84')]('Content-disposition','attachment;\x20filename='+util['format'](_0x38f9('0x85'),_0x392673,_0x27d8a3));_0x265fdf['setHeader']('Content-type',_0x38f9('0x86'));return _0x265fdf[_0x38f9('0x87')](util[_0x38f9('0x6c')]('/tmp/list_%d_%s.csv',_0x392673,_0x27d8a3));}else{return _0x265fdf[_0x38f9('0x1e')](0xcc);}});});});};exports['addCustomField']=function(_0x591f87,_0x1ec282,_0x24d9c5){var _0x4aadd0;delete _0x591f87['body']['id'];return db[_0x38f9('0x43')][_0x38f9('0x57')]({'where':{'id':_0x591f87[_0x38f9('0x49')]['id']}})['then'](handleEntityNotFound(_0x1ec282,null))[_0x38f9('0x28')](function(_0x3dee9c){if(_0x3dee9c){return db['sequelize'][_0x38f9('0x88')](function(_0x4e445c){return db[_0x38f9('0x6a')][_0x38f9('0x4b')](_0x591f87['body'],{'transaction':_0x4e445c})[_0x38f9('0x28')](function(_0x422d50){_0x4aadd0=_0x422d50;return _0x3dee9c[_0x38f9('0x89')](_0x422d50,{'transaction':_0x4e445c});})['then'](function(){var _0x5c6449={'type':db[_0x38f9('0x8a')][_0x38f9('0x8b')],'transaction':_0x4e445c};switch(_0x591f87[_0x38f9('0x4c')]['type']){case'text':_0x5c6449['type']=db[_0x38f9('0x8a')][_0x38f9('0x8b')];break;case _0x38f9('0x8c'):_0x5c6449[_0x38f9('0x8d')]=db[_0x38f9('0x8a')]['INTEGER'];break;case _0x38f9('0x8e'):_0x5c6449['type']=db[_0x38f9('0x8a')][_0x38f9('0x8f')];_0x5c6449['defaultValue']=![];break;default:}return db[_0x38f9('0x90')]['queryInterface'][_0x38f9('0x91')](_0x38f9('0x76'),util[_0x38f9('0x6c')](_0x38f9('0x92'),_0x4aadd0['id']),_0x5c6449);})[_0x38f9('0x28')](function(){return _0x4aadd0;});});}})[_0x38f9('0x28')](respondWithResult(_0x1ec282,null))[_0x38f9('0x47')](handleError(_0x1ec282,null));};exports['getCustomFields']=function(_0x376b4e,_0x202397,_0x2dc079){var _0x422303={};var _0x376595={};var _0x3f3d8a;var _0x307af2;return db['CmList']['findOne']({'where':{'id':_0x376b4e[_0x38f9('0x49')]['id']}})[_0x38f9('0x28')](handleEntityNotFound(_0x202397,null))[_0x38f9('0x28')](function(_0x512a89){if(_0x512a89){_0x3f3d8a=_0x512a89;_0x376595[_0x38f9('0x33')]=_[_0x38f9('0x37')](db[_0x38f9('0x6a')][_0x38f9('0x30')]);_0x376595[_0x38f9('0x36')]=_[_0x38f9('0x37')](_0x376b4e['query']);_0x376595['filters']=_['intersection'](_0x376595['model'],_0x376595[_0x38f9('0x36')]);_0x422303[_0x38f9('0x3a')]=_[_0x38f9('0x39')](_0x376595[_0x38f9('0x33')],qs[_0x38f9('0x4a')](_0x376b4e[_0x38f9('0x36')][_0x38f9('0x4a')]));_0x422303[_0x38f9('0x3a')]=_0x422303[_0x38f9('0x3a')][_0x38f9('0x59')]?_0x422303['attributes']:_0x376595[_0x38f9('0x33')];_0x422303[_0x38f9('0x5b')]=qs['sort'](_0x376b4e[_0x38f9('0x36')]['sort']);_0x422303[_0x38f9('0x3d')]=qs[_0x38f9('0x38')](_[_0x38f9('0x3e')](_0x376b4e[_0x38f9('0x36')],_0x376595[_0x38f9('0x38')]));_0x422303[_0x38f9('0x3d')]=_['merge'](_0x422303[_0x38f9('0x3d')],{'$or':[{'ListId':_0x512a89['id']},{'ListId':null}]});if(_0x376b4e[_0x38f9('0x36')][_0x38f9('0x41')]){_0x422303[_0x38f9('0x3d')]=_[_0x38f9('0x3f')](_0x422303[_0x38f9('0x3d')],{'$or':_['map'](_0x422303[_0x38f9('0x3a')],function(_0x454f27){var _0x385e32={};_0x385e32[_0x454f27]={'$like':'%'+_0x376b4e[_0x38f9('0x36')][_0x38f9('0x41')]+'%'};return _0x385e32;})});}_0x422303=_['merge']({},_0x422303,_0x376b4e[_0x38f9('0x42')]);return db[_0x38f9('0x6a')][_0x38f9('0x93')](_0x422303);}})[_0x38f9('0x28')](respondWithResult(_0x202397,null))[_0x38f9('0x47')](handleError(_0x202397,null));};exports[_0x38f9('0x94')]=function(_0x4fa087,_0x5a0cae){return db[_0x38f9('0x6a')][_0x38f9('0x93')]({'where':{'ListId':null}})[_0x38f9('0x28')](handleEntityNotFound(_0x5a0cae,null))[_0x38f9('0x28')](function(_0x466d41){return _0x466d41;})[_0x38f9('0x28')](respondWithResult(_0x5a0cae,null))[_0x38f9('0x47')](handleError(_0x5a0cae,null));};exports['addAgents']=function(_0x27c6a1,_0x53b47f,_0x3cced7){return db[_0x38f9('0x43')][_0x38f9('0x50')]({'where':{'id':_0x27c6a1[_0x38f9('0x49')]['id']}})['then'](handleEntityNotFound(_0x53b47f,null))[_0x38f9('0x28')](function(_0x3d4552){if(_0x3d4552){return _0x3d4552[_0x38f9('0x95')](_0x27c6a1['body']['ids'],_[_0x38f9('0x66')](_0x27c6a1[_0x38f9('0x4c')],[_0x38f9('0x5e'),'id'])||{})[_0x38f9('0x96')](function(_0x2d313b){for(var _0x5ac13c=0x0;_0x5ac13c<_0x27c6a1['body'][_0x38f9('0x5e')]['length'];_0x5ac13c+=0x1){socket['emit'](_0x38f9('0x97'),{'UserId':Number(_0x27c6a1['body'][_0x38f9('0x5e')][_0x5ac13c]),'CmListId':Number(_0x27c6a1[_0x38f9('0x49')]['id'])});}return _0x2d313b;});}})[_0x38f9('0x28')](respondWithResult(_0x53b47f,null))[_0x38f9('0x47')](handleError(_0x53b47f,null));};exports[_0x38f9('0x98')]=function(_0xa4a82f,_0xe0f020,_0x1dd685){return db[_0x38f9('0x43')][_0x38f9('0x50')]({'where':{'id':_0xa4a82f[_0x38f9('0x49')]['id']}})[_0x38f9('0x28')](handleEntityNotFound(_0xe0f020,null))['then'](function(_0x272a11){if(_0x272a11){return _0x272a11['removeAgents'](_0xa4a82f['query']['ids'])[_0x38f9('0x28')](function(){if(_[_0x38f9('0x61')](_0xa4a82f[_0x38f9('0x36')][_0x38f9('0x5e')])){for(var _0x566723=0x0;_0x566723<_0xa4a82f[_0x38f9('0x36')][_0x38f9('0x5e')][_0x38f9('0x59')];_0x566723+=0x1){socket[_0x38f9('0x99')](_0x38f9('0x9a'),{'UserId':Number(_0xa4a82f[_0x38f9('0x36')][_0x38f9('0x5e')][_0x566723]),'CmListId':Number(_0xa4a82f[_0x38f9('0x49')]['id'])});}}else{socket['emit'](_0x38f9('0x9a'),{'UserId':Number(_0xa4a82f['query'][_0x38f9('0x5e')]),'CmListId':Number(_0xa4a82f[_0x38f9('0x49')]['id'])});}});}})[_0x38f9('0x28')](respondWithStatusCode(_0xe0f020,null))[_0x38f9('0x47')](handleError(_0xe0f020,null));};exports[_0x38f9('0x9b')]=function(_0x32c15b,_0x57e515,_0x4fa6b0){var _0x24b5c8={};var _0x45afa6={};var _0x84ff05;var _0x5647e3;return db[_0x38f9('0x43')]['findOne']({'where':{'id':_0x32c15b[_0x38f9('0x49')]['id']}})[_0x38f9('0x28')](handleEntityNotFound(_0x57e515,null))[_0x38f9('0x28')](function(_0x13d04b){if(_0x13d04b){_0x84ff05=_0x13d04b;_0x45afa6[_0x38f9('0x33')]=_[_0x38f9('0x37')](db[_0x38f9('0x9c')][_0x38f9('0x30')]);_0x45afa6[_0x38f9('0x36')]=_[_0x38f9('0x37')](_0x32c15b[_0x38f9('0x36')]);_0x45afa6[_0x38f9('0x38')]=_[_0x38f9('0x39')](_0x45afa6[_0x38f9('0x33')],_0x45afa6[_0x38f9('0x36')]);_0x24b5c8[_0x38f9('0x3a')]=_[_0x38f9('0x39')](_0x45afa6[_0x38f9('0x33')],qs[_0x38f9('0x4a')](_0x32c15b[_0x38f9('0x36')][_0x38f9('0x4a')]));_0x24b5c8[_0x38f9('0x3a')]=_0x24b5c8[_0x38f9('0x3a')][_0x38f9('0x59')]?_0x24b5c8[_0x38f9('0x3a')]:_0x45afa6[_0x38f9('0x33')];_0x24b5c8[_0x38f9('0x5b')]=qs[_0x38f9('0x3c')](_0x32c15b[_0x38f9('0x36')]['sort']);_0x24b5c8[_0x38f9('0x3d')]=qs['filters'](_[_0x38f9('0x3e')](_0x32c15b[_0x38f9('0x36')],_0x45afa6['filters']));if(_0x32c15b[_0x38f9('0x36')]['filter']){_0x24b5c8[_0x38f9('0x3d')]=_[_0x38f9('0x3f')](_0x24b5c8[_0x38f9('0x3d')],{'$or':_[_0x38f9('0x34')](_0x24b5c8[_0x38f9('0x3a')],function(_0x49a81e){var _0x393d3e={};_0x393d3e[_0x49a81e]={'$like':'%'+_0x32c15b[_0x38f9('0x36')][_0x38f9('0x41')]+'%'};return _0x393d3e;})});}_0x24b5c8=_['merge']({},_0x24b5c8,_0x32c15b[_0x38f9('0x42')]);return _0x84ff05[_0x38f9('0x9b')](_0x24b5c8);}})[_0x38f9('0x28')](function(_0x1194b7){if(_0x1194b7){_0x5647e3=_0x1194b7[_0x38f9('0x59')];if(!_0x32c15b[_0x38f9('0x36')][_0x38f9('0x3b')](_0x38f9('0x5a'))){_0x24b5c8['limit']=qs['limit'](_0x32c15b[_0x38f9('0x36')][_0x38f9('0x23')]);_0x24b5c8[_0x38f9('0x21')]=qs[_0x38f9('0x21')](_0x32c15b[_0x38f9('0x36')]['offset']);}return _0x84ff05[_0x38f9('0x9b')](_0x24b5c8);}})[_0x38f9('0x28')](function(_0x2ee4b4){if(_0x2ee4b4){return _0x2ee4b4?{'count':_0x5647e3,'rows':_0x2ee4b4}:null;}})[_0x38f9('0x28')](respondWithResult(_0x57e515,null))[_0x38f9('0x47')](handleError(_0x57e515,null));};function handleQuery(_0x1d6299){logger[_0x38f9('0x9d')](_0x1d6299);return db[_0x38f9('0x90')][_0x38f9('0x36')](_0x1d6299)[_0x38f9('0x96')](function(_0x48acc7){csv_results[_0x38f9('0x64')](_0x48acc7);})[_0x38f9('0x47')](function(_0x13dce7){logger[_0x38f9('0x2c')](_0x13dce7[_0x38f9('0x9e')]);});}
\ No newline at end of file