Built motion from commit 00bf23f6.|2.6.16
[motion2.git] / server / api / cmList / cmList.controller.js
index d692c6f..b894806 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x8a67=['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','Sequelize','text','TEXT','number','INTEGER','BOOLEAN','queryInterface','addColumn','cm_contacts','cf_%s','getCustomFields','findAndCountAll','spread','emit','userCmList:save','removeAgents','userCmList:remove','User','getAgents','html-pdf','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','util','path','sox','to-csv','ejs','lodash','squel','crypto','desk.js','querystring','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/environment','../../config/license/util','redis','defaults','socket.io-emitter','./cmList.socket','register','sendStatus','status','end','json','offset','set','Content-Range','save','then','destroy','UserProfileResource','error','stack','name','send','map','CmList','type','key','query','keys','filters','intersection','model','attributes','fields','length','hasOwnProperty','nolimit','limit','sort','where','pick','filter','merge','VIRTUAL','options','count','rows','catch','show','params','includeAll','include','find','create','body','user','get','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','update','describe','addDisposition','ListId','findOne','Disposition','findAll','removeDispositions','CmContact','tags','isArray','push','omit','ids','dataValues','errors','message','Malformed\x20request\x20syntax','getContacts','CustomFields','rawAttributes','concat','format','cf_%d','order','raw','CmCustomField'];(function(_0x156510,_0xdc8b52){var _0xdee5e7=function(_0x1eee23){while(--_0x1eee23){_0x156510['push'](_0x156510['shift']());}};_0xdee5e7(++_0xdc8b52);}(_0x8a67,0x1c5));var _0x78a6=function(_0x27c52f,_0x17c613){_0x27c52f=_0x27c52f-0x0;var _0x331364=_0x8a67[_0x27c52f];return _0x331364;};'use strict';var pdf=require(_0x78a6('0x0'));var emlformat=require('eml-format');var rimraf=require(_0x78a6('0x1'));var zipdir=require(_0x78a6('0x2'));var jsonpatch=require(_0x78a6('0x3'));var rp=require(_0x78a6('0x4'));var moment=require(_0x78a6('0x5'));var BPromise=require(_0x78a6('0x6'));var Mustache=require('mustache');var util=require(_0x78a6('0x7'));var path=require(_0x78a6('0x8'));var sox=require(_0x78a6('0x9'));var csv=require(_0x78a6('0xa'));var ejs=require(_0x78a6('0xb'));var fs=require('fs');var _=require(_0x78a6('0xc'));var squel=require(_0x78a6('0xd'));var crypto=require(_0x78a6('0xe'));var jsforce=require('jsforce');var deskjs=require(_0x78a6('0xf'));var toCsv=require(_0x78a6('0xa'));var querystring=require(_0x78a6('0x10'));var Papa=require('papaparse');var Redis=require(_0x78a6('0x11'));var authService=require(_0x78a6('0x12'));var qs=require('../../components/parsers/qs');var as=require(_0x78a6('0x13'));var hardwareService=require(_0x78a6('0x14'));var logger=require(_0x78a6('0x15'))('api');var utils=require('../../config/utils');var config=require(_0x78a6('0x16'));var licenseUtil=require(_0x78a6('0x17'));var db=require('../../mysqldb')['db'];config[_0x78a6('0x18')]=_[_0x78a6('0x19')](config[_0x78a6('0x18')],{'host':'localhost','port':0x18eb});var socket=require(_0x78a6('0x1a'))(new Redis(config[_0x78a6('0x18')]));require(_0x78a6('0x1b'))[_0x78a6('0x1c')](socket);function respondWithStatusCode(_0x460729,_0x407f02){_0x407f02=_0x407f02||0xcc;return function(_0x35b4ba){if(_0x35b4ba){return _0x460729[_0x78a6('0x1d')](_0x407f02);}return _0x460729[_0x78a6('0x1e')](_0x407f02)[_0x78a6('0x1f')]();};}function respondWithResult(_0x50c809,_0x2f7d36){_0x2f7d36=_0x2f7d36||0xc8;return function(_0x557ff8){if(_0x557ff8){return _0x50c809['status'](_0x2f7d36)[_0x78a6('0x20')](_0x557ff8);}};}function respondWithFilteredResult(_0x264d75,_0x2ca732){return function(_0x2c3cf4){if(_0x2c3cf4){var _0x1a7267=_0x2c3cf4['count'],_0x5040ba=_0x2ca732[_0x78a6('0x21')],_0x5a44c7=_0x2ca732[_0x78a6('0x21')]+_0x2ca732['limit'],_0x27adfa;if(_0x5a44c7>=_0x1a7267){_0x5a44c7=_0x1a7267;_0x27adfa=0xc8;}else{_0x27adfa=0xce;}_0x264d75['status'](_0x27adfa);return _0x264d75[_0x78a6('0x22')](_0x78a6('0x23'),_0x5040ba+'-'+_0x5a44c7+'/'+_0x1a7267)[_0x78a6('0x20')](_0x2c3cf4);}return null;};}function patchUpdates(_0x15f286){return function(_0x4570c2){try{jsonpatch['apply'](_0x4570c2,_0x15f286,!![]);}catch(_0x2556f8){return BPromise['reject'](_0x2556f8);}return _0x4570c2[_0x78a6('0x24')]();};}function saveUpdates(_0x344eb7,_0x1bcfcd){return function(_0x374962){if(_0x374962){return _0x374962['update'](_0x344eb7)[_0x78a6('0x25')](function(_0x46a797){return _0x46a797;});}return null;};}function removeEntity(_0x13abaa,_0x2048df){return function(_0x1170f2){if(_0x1170f2){return _0x1170f2[_0x78a6('0x26')]()[_0x78a6('0x25')](function(){var _0xff85e2=_0x1170f2['get']({'plain':!![]});var _0x7c7480='Lists';return db[_0x78a6('0x27')][_0x78a6('0x26')]({'where':{'type':_0x7c7480,'resourceId':_0xff85e2['id']}})[_0x78a6('0x25')](function(){return _0x1170f2;});})['then'](function(){_0x13abaa[_0x78a6('0x1e')](0xcc)[_0x78a6('0x1f')]();});}};}function handleEntityNotFound(_0x1e95ef,_0x3a1f6e){return function(_0x52dcc5){if(!_0x52dcc5){_0x1e95ef[_0x78a6('0x1d')](0x194);}return _0x52dcc5;};}function handleError(_0x397a4d,_0x3e7058){_0x3e7058=_0x3e7058||0x1f4;return function(_0x5e43ca){logger[_0x78a6('0x28')](_0x5e43ca[_0x78a6('0x29')]);if(_0x5e43ca[_0x78a6('0x2a')]){delete _0x5e43ca[_0x78a6('0x2a')];}_0x397a4d[_0x78a6('0x1e')](_0x3e7058)[_0x78a6('0x2b')](_0x5e43ca);};}exports['index']=function(_0x428a55,_0xe741a2){var _0x14372e={},_0x1595f3={},_0x2585e6={'count':0x0,'rows':[]};var _0x464c82=_[_0x78a6('0x2c')](db[_0x78a6('0x2d')]['rawAttributes'],function(_0x308869){return{'name':_0x308869['fieldName'],'type':_0x308869[_0x78a6('0x2e')][_0x78a6('0x2f')]};});_0x1595f3['model']=_[_0x78a6('0x2c')](_0x464c82,'name');_0x1595f3[_0x78a6('0x30')]=_[_0x78a6('0x31')](_0x428a55['query']);_0x1595f3[_0x78a6('0x32')]=_[_0x78a6('0x33')](_0x1595f3[_0x78a6('0x34')],_0x1595f3[_0x78a6('0x30')]);_0x14372e[_0x78a6('0x35')]=_[_0x78a6('0x33')](_0x1595f3[_0x78a6('0x34')],qs[_0x78a6('0x36')](_0x428a55[_0x78a6('0x30')][_0x78a6('0x36')]));_0x14372e['attributes']=_0x14372e['attributes'][_0x78a6('0x37')]?_0x14372e[_0x78a6('0x35')]:_0x1595f3[_0x78a6('0x34')];if(!_0x428a55[_0x78a6('0x30')][_0x78a6('0x38')](_0x78a6('0x39'))){_0x14372e[_0x78a6('0x3a')]=qs['limit'](_0x428a55['query'][_0x78a6('0x3a')]);_0x14372e[_0x78a6('0x21')]=qs['offset'](_0x428a55[_0x78a6('0x30')]['offset']);}_0x14372e['order']=qs[_0x78a6('0x3b')](_0x428a55[_0x78a6('0x30')]['sort']);_0x14372e[_0x78a6('0x3c')]=qs[_0x78a6('0x32')](_[_0x78a6('0x3d')](_0x428a55[_0x78a6('0x30')],_0x1595f3[_0x78a6('0x32')]),_0x464c82);if(_0x428a55['query'][_0x78a6('0x3e')]){_0x14372e[_0x78a6('0x3c')]=_[_0x78a6('0x3f')](_0x14372e['where'],{'$or':_[_0x78a6('0x2c')](_0x464c82,function(_0x82c012){if(_0x82c012[_0x78a6('0x2e')]!==_0x78a6('0x40')){var _0x3bb4de={};_0x3bb4de[_0x82c012['name']]={'$like':'%'+_0x428a55['query'][_0x78a6('0x3e')]+'%'};return _0x3bb4de;}})});}_0x14372e=_['merge']({},_0x14372e,_0x428a55[_0x78a6('0x41')]);var _0x2618d9={'where':_0x14372e['where']};return db['CmList']['count'](_0x2618d9)['then'](function(_0x51290e){_0x2585e6[_0x78a6('0x42')]=_0x51290e;if(_0x428a55['query']['includeAll']){_0x14372e['include']=[{'all':!![]}];}return db[_0x78a6('0x2d')]['findAll'](_0x14372e);})[_0x78a6('0x25')](function(_0xd7fe0c){_0x2585e6[_0x78a6('0x43')]=_0xd7fe0c;return _0x2585e6;})[_0x78a6('0x25')](respondWithFilteredResult(_0xe741a2,_0x14372e))[_0x78a6('0x44')](handleError(_0xe741a2,null));};exports[_0x78a6('0x45')]=function(_0x1897f9,_0x545f42){var _0x2041b6={'raw':![],'where':{'id':_0x1897f9[_0x78a6('0x46')]['id']}},_0x3b6954={};_0x3b6954[_0x78a6('0x34')]=_[_0x78a6('0x31')](db[_0x78a6('0x2d')]['rawAttributes']);_0x3b6954[_0x78a6('0x30')]=_[_0x78a6('0x31')](_0x1897f9[_0x78a6('0x30')]);_0x3b6954[_0x78a6('0x32')]=_[_0x78a6('0x33')](_0x3b6954[_0x78a6('0x34')],_0x3b6954['query']);_0x2041b6[_0x78a6('0x35')]=_[_0x78a6('0x33')](_0x3b6954[_0x78a6('0x34')],qs[_0x78a6('0x36')](_0x1897f9[_0x78a6('0x30')][_0x78a6('0x36')]));_0x2041b6[_0x78a6('0x35')]=_0x2041b6[_0x78a6('0x35')][_0x78a6('0x37')]?_0x2041b6['attributes']:_0x3b6954['model'];if(_0x1897f9['query'][_0x78a6('0x47')]){_0x2041b6[_0x78a6('0x48')]=[{'all':!![]}];}_0x2041b6=_[_0x78a6('0x3f')]({},_0x2041b6,_0x1897f9[_0x78a6('0x41')]);return db[_0x78a6('0x2d')][_0x78a6('0x49')](_0x2041b6)[_0x78a6('0x25')](handleEntityNotFound(_0x545f42,null))['then'](respondWithResult(_0x545f42,null))[_0x78a6('0x44')](handleError(_0x545f42,null));};exports[_0x78a6('0x4a')]=function(_0xa4691e,_0x2bdce8){return db[_0x78a6('0x2d')][_0x78a6('0x4a')](_0xa4691e[_0x78a6('0x4b')],{})[_0x78a6('0x25')](function(_0x29e65d){var _0x5de17a=_0xa4691e[_0x78a6('0x4c')][_0x78a6('0x4d')]({'plain':!![]});if(!_0x5de17a)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x5de17a['role']===_0x78a6('0x4c')){var _0x31a8d7=_0x29e65d[_0x78a6('0x4d')]({'plain':!![]});var _0x25797e='Lists';return db['UserProfileSection'][_0x78a6('0x49')]({'where':{'name':_0x25797e,'userProfileId':_0x5de17a['userProfileId']},'raw':!![]})['then'](function(_0x19f073){if(_0x19f073&&_0x19f073[_0x78a6('0x4e')]===0x0){return db[_0x78a6('0x27')]['create']({'name':_0x31a8d7[_0x78a6('0x2a')],'resourceId':_0x31a8d7['id'],'type':_0x19f073['name'],'sectionId':_0x19f073['id']},{})['then'](function(){return _0x29e65d;});}else{return _0x29e65d;}})[_0x78a6('0x44')](function(_0x9a1076){logger[_0x78a6('0x28')](_0x78a6('0x4f'),_0x9a1076);throw _0x9a1076;});}return _0x29e65d;})[_0x78a6('0x25')](respondWithResult(_0x2bdce8,0xc9))[_0x78a6('0x44')](handleError(_0x2bdce8,null));};exports[_0x78a6('0x50')]=function(_0x5debc6,_0x3802bb){if(_0x5debc6[_0x78a6('0x4b')]['id']){delete _0x5debc6[_0x78a6('0x4b')]['id'];}return db[_0x78a6('0x2d')]['find']({'where':{'id':_0x5debc6[_0x78a6('0x46')]['id']}})[_0x78a6('0x25')](handleEntityNotFound(_0x3802bb,null))[_0x78a6('0x25')](saveUpdates(_0x5debc6['body'],null))[_0x78a6('0x25')](respondWithResult(_0x3802bb,null))[_0x78a6('0x44')](handleError(_0x3802bb,null));};exports['destroy']=function(_0x41e101,_0x317b3e){return db[_0x78a6('0x2d')][_0x78a6('0x49')]({'where':{'id':_0x41e101[_0x78a6('0x46')]['id']}})[_0x78a6('0x25')](handleEntityNotFound(_0x317b3e,null))['then'](removeEntity(_0x317b3e,null))[_0x78a6('0x44')](handleError(_0x317b3e,null));};exports[_0x78a6('0x51')]=function(_0x4a5439,_0x535b17){return db[_0x78a6('0x2d')][_0x78a6('0x51')]()[_0x78a6('0x25')](respondWithResult(_0x535b17,null))[_0x78a6('0x44')](handleError(_0x535b17,null));};exports[_0x78a6('0x52')]=function(_0x16bf69,_0x188e3b,_0x39bf31){if(_0x16bf69['body']['id']){delete _0x16bf69['body']['id'];}return db[_0x78a6('0x2d')][_0x78a6('0x49')]({'where':{'id':_0x16bf69[_0x78a6('0x46')]['id']}})[_0x78a6('0x25')](handleEntityNotFound(_0x188e3b,null))['then'](function(_0x2148c0){if(_0x2148c0){_0x16bf69[_0x78a6('0x4b')][_0x78a6('0x53')]=_0x2148c0['id'];return db['Disposition'][_0x78a6('0x4a')](_0x16bf69[_0x78a6('0x4b')]);}})[_0x78a6('0x25')](respondWithResult(_0x188e3b,null))[_0x78a6('0x44')](handleError(_0x188e3b,null));};exports['getDispositions']=function(_0x412e84,_0x31e8d9,_0x46f56f){var _0x1961b8={'raw':![],'where':{}};var _0x1d3266={};var _0x5aed77={'count':0x0,'rows':[]};return db[_0x78a6('0x2d')][_0x78a6('0x54')]({'where':{'id':_0x412e84[_0x78a6('0x46')]['id']}})['then'](handleEntityNotFound(_0x31e8d9,null))[_0x78a6('0x25')](function(_0x484b01){if(_0x484b01){_0x1d3266[_0x78a6('0x34')]=_['keys'](db[_0x78a6('0x55')]['rawAttributes']);_0x1d3266[_0x78a6('0x30')]=_['keys'](_0x412e84[_0x78a6('0x30')]);_0x1d3266[_0x78a6('0x32')]=_[_0x78a6('0x33')](_0x1d3266[_0x78a6('0x34')],_0x1d3266[_0x78a6('0x30')]);_0x1961b8[_0x78a6('0x35')]=_['intersection'](_0x1d3266[_0x78a6('0x34')],qs['fields'](_0x412e84['query'][_0x78a6('0x36')]));_0x1961b8[_0x78a6('0x35')]=_0x1961b8[_0x78a6('0x35')][_0x78a6('0x37')]?_0x1961b8[_0x78a6('0x35')]:_0x1d3266[_0x78a6('0x34')];if(!_0x412e84[_0x78a6('0x30')]['hasOwnProperty'](_0x78a6('0x39'))){_0x1961b8[_0x78a6('0x3a')]=qs[_0x78a6('0x3a')](_0x412e84[_0x78a6('0x30')][_0x78a6('0x3a')]);_0x1961b8['offset']=qs[_0x78a6('0x21')](_0x412e84[_0x78a6('0x30')][_0x78a6('0x21')]);}_0x1961b8['order']=qs['sort'](_0x412e84[_0x78a6('0x30')][_0x78a6('0x3b')]);_0x1961b8['where']=qs[_0x78a6('0x32')](_[_0x78a6('0x3d')](_0x412e84[_0x78a6('0x30')],_0x1d3266[_0x78a6('0x32')]));_0x1961b8['where'][_0x78a6('0x53')]=_0x484b01['id'];if(_0x412e84[_0x78a6('0x30')][_0x78a6('0x3e')]){_0x1961b8[_0x78a6('0x3c')]=_[_0x78a6('0x3f')](_0x1961b8['where'],{'$or':_[_0x78a6('0x2c')](_0x1961b8['attributes'],function(_0x5af176){var _0x43572b={};_0x43572b[_0x5af176]={'$like':'%'+_0x412e84[_0x78a6('0x30')]['filter']+'%'};return _0x43572b;})});}_0x1961b8=_[_0x78a6('0x3f')]({},_0x1961b8,_0x412e84[_0x78a6('0x41')]);return db[_0x78a6('0x55')][_0x78a6('0x42')]({'where':_0x1961b8['where']})[_0x78a6('0x25')](function(_0x38f931){_0x5aed77[_0x78a6('0x42')]=_0x38f931;if(_0x412e84[_0x78a6('0x30')][_0x78a6('0x47')]){_0x1961b8[_0x78a6('0x48')]=[{'all':!![]}];}return db[_0x78a6('0x55')][_0x78a6('0x56')](_0x1961b8);})['then'](function(_0x4609d8){_0x5aed77['rows']=_0x4609d8;return _0x5aed77;});}})[_0x78a6('0x25')](respondWithFilteredResult(_0x31e8d9,_0x1961b8))[_0x78a6('0x44')](handleError(_0x31e8d9,null));};exports[_0x78a6('0x57')]=function(_0x307bcd,_0x388f9a,_0x585307){return db[_0x78a6('0x2d')][_0x78a6('0x49')]({'where':{'id':_0x307bcd[_0x78a6('0x46')]['id']}})[_0x78a6('0x25')](handleEntityNotFound(_0x388f9a,null))[_0x78a6('0x25')](function(_0x2ce066){if(_0x2ce066){return _0x2ce066[_0x78a6('0x57')](_0x307bcd['query']['ids']);}})[_0x78a6('0x25')](respondWithStatusCode(_0x388f9a,null))[_0x78a6('0x44')](handleError(_0x388f9a,null));};exports['addContacts']=function(_0x57f54a,_0x2159c1,_0x4f2cac){return db[_0x78a6('0x2d')][_0x78a6('0x49')]({'where':{'id':_0x57f54a[_0x78a6('0x46')]['id']}})['then'](handleEntityNotFound(_0x2159c1,null))[_0x78a6('0x25')](function(_0x35dadd){if(_0x35dadd){var _0x1b17b2=[];var _0x55a086={'success':[],'errors':[]};return db[_0x78a6('0x58')][_0x78a6('0x51')]()[_0x78a6('0x25')](function(_0x270bcf){if(_0x57f54a[_0x78a6('0x4b')][_0x78a6('0x59')]&&_[_0x78a6('0x5a')](_0x57f54a[_0x78a6('0x4b')][_0x78a6('0x59')])){if(_0x57f54a['body']['tags'][_0x78a6('0x37')]){_0x57f54a[_0x78a6('0x4b')][_0x78a6('0x59')]=_0x57f54a[_0x78a6('0x4b')]['tags']['join'](';')+';';}else{_0x57f54a[_0x78a6('0x4b')][_0x78a6('0x59')]=null;}}else{_0x57f54a[_0x78a6('0x4b')][_0x78a6('0x59')]=null;}if(_0x57f54a[_0x78a6('0x4b')]&&_[_0x78a6('0x5a')](_0x57f54a[_0x78a6('0x4b')])){for(var _0x3904cf=0x0;_0x3904cf<_0x57f54a['body'][_0x78a6('0x37')];_0x3904cf+=0x1){_0x57f54a['body'][_0x3904cf][_0x78a6('0x53')]=_0x57f54a[_0x78a6('0x46')]['id'];_0x1b17b2[_0x78a6('0x5b')](_0x57f54a[_0x78a6('0x4b')][_0x3904cf]);}return BPromise['each'](_0x1b17b2,function(_0x14c21f){return db[_0x78a6('0x58')]['create'](_[_0x78a6('0x5c')](_0x14c21f,[_0x78a6('0x5d'),'id'])||{},{'fields':_[_0x78a6('0x31')](_0x270bcf),'raw':!![]})[_0x78a6('0x25')](function(_0xbf4b23){_0x55a086['success']['push'](_0xbf4b23[_0x78a6('0x5e')]);})['catch'](function(_0x19fe84){_0x55a086[_0x78a6('0x5f')]['push']({'data':_0x14c21f,'error':_0x19fe84[_0x78a6('0x60')]});});})[_0x78a6('0x25')](function(_0x49cbed){return _0x55a086;})[_0x78a6('0x44')](function(_0x5b7566){return _0x5b7566;});}else{_0x2159c1[_0x78a6('0x1e')](0x190)[_0x78a6('0x20')]({'message':_0x78a6('0x61')});}});}})[_0x78a6('0x25')](respondWithResult(_0x2159c1,null))['catch'](handleError(_0x2159c1,null));};exports[_0x78a6('0x62')]=function(_0x50fbe2,_0x1305be,_0x2e223b){var _0x26b33e;return db[_0x78a6('0x2d')][_0x78a6('0x49')]({'where':{'id':_0x50fbe2[_0x78a6('0x46')]['id']},'include':[{'model':db['CmCustomField'],'as':_0x78a6('0x63')}]})['then'](handleEntityNotFound(_0x1305be,null))[_0x78a6('0x25')](function(_0x7f4ba5){if(_0x7f4ba5){_0x26b33e=_0x7f4ba5;return db['CmContact'][_0x78a6('0x64')];}})[_0x78a6('0x25')](function(_0x504a3c){if(_0x504a3c){var _0x187167={};var _0x3d242a={};_0x3d242a[_0x78a6('0x34')]=_[_0x78a6('0x65')](_[_0x78a6('0x31')](_0x504a3c),_['map'](_0x26b33e[_0x78a6('0x63')],function(_0xcf4fa0){return util[_0x78a6('0x66')](_0x78a6('0x67'),_0xcf4fa0['id']);}));_0x3d242a[_0x78a6('0x30')]=_[_0x78a6('0x31')](_0x50fbe2['query']);_0x3d242a['filters']=_[_0x78a6('0x33')](_0x3d242a[_0x78a6('0x34')],_0x3d242a[_0x78a6('0x30')]);_0x187167[_0x78a6('0x35')]=_[_0x78a6('0x33')](_0x3d242a[_0x78a6('0x34')],qs[_0x78a6('0x36')](_0x50fbe2[_0x78a6('0x30')]['fields']));_0x187167[_0x78a6('0x35')]=_0x187167[_0x78a6('0x35')][_0x78a6('0x37')]?_0x187167[_0x78a6('0x35')]:_0x3d242a[_0x78a6('0x34')];if(!_0x50fbe2[_0x78a6('0x30')][_0x78a6('0x38')](_0x78a6('0x39'))){_0x187167['limit']=qs['limit'](_0x50fbe2[_0x78a6('0x30')]['limit']);_0x187167[_0x78a6('0x21')]=qs[_0x78a6('0x21')](_0x50fbe2['query']['offset']);}_0x187167[_0x78a6('0x68')]=qs[_0x78a6('0x3b')](_0x50fbe2[_0x78a6('0x30')]['sort']);_0x187167[_0x78a6('0x3c')]=qs[_0x78a6('0x32')](_['pick'](_0x50fbe2[_0x78a6('0x30')],_0x3d242a['filters']));_0x187167[_0x78a6('0x69')]=!![];if(_0x50fbe2['query'][_0x78a6('0x3e')]){_0x187167[_0x78a6('0x3c')]=_[_0x78a6('0x3f')](_0x187167[_0x78a6('0x3c')],{'$or':_[_0x78a6('0x2c')](_0x187167[_0x78a6('0x35')],function(_0x4ae534){var _0x56fa3d={};_0x56fa3d[_0x4ae534]={'$like':'%'+_0x50fbe2[_0x78a6('0x30')]['filter']+'%'};return _0x56fa3d;})});}_0x187167=_[_0x78a6('0x3f')]({},_0x187167,_0x50fbe2['options']);return _0x26b33e[_0x78a6('0x62')](_0x187167);}})[_0x78a6('0x25')](respondWithResult(_0x1305be,null))['catch'](handleError(_0x1305be,null));};exports['getContactsCsv']=function(_0x2d6cc5,_0x337931,_0x566012){var _0x3e4d7e;return db['CmList'][_0x78a6('0x49')]({'where':{'id':_0x2d6cc5[_0x78a6('0x46')]['id']},'include':[{'model':db[_0x78a6('0x6a')],'as':_0x78a6('0x63')}]})[_0x78a6('0x25')](handleEntityNotFound(_0x337931,null))[_0x78a6('0x25')](function(_0x3381fc){if(_0x3381fc){_0x3e4d7e=_0x3381fc;return db['CmContact'][_0x78a6('0x64')];}})[_0x78a6('0x25')](function(_0x3cafab){if(_0x3cafab){var _0x538176={};var _0x3676d6={};_0x3676d6[_0x78a6('0x34')]=_[_0x78a6('0x65')](_[_0x78a6('0x31')](_0x3cafab),_['map'](_0x3e4d7e[_0x78a6('0x63')],function(_0x5713dc){return util[_0x78a6('0x66')](_0x78a6('0x67'),_0x5713dc['id']);}));_0x3676d6[_0x78a6('0x30')]=_[_0x78a6('0x31')](_0x2d6cc5[_0x78a6('0x30')]);_0x3676d6[_0x78a6('0x32')]=_[_0x78a6('0x33')](_0x3676d6[_0x78a6('0x34')],_0x3676d6['query']);_0x538176[_0x78a6('0x35')]=_['intersection'](_0x3676d6[_0x78a6('0x34')],qs[_0x78a6('0x36')](_0x2d6cc5['query']['fields']));_0x538176[_0x78a6('0x35')]=_0x538176[_0x78a6('0x35')][_0x78a6('0x37')]?_0x538176[_0x78a6('0x35')]:_0x3676d6[_0x78a6('0x34')];if(!_0x2d6cc5['query'][_0x78a6('0x38')](_0x78a6('0x39'))){_0x538176[_0x78a6('0x3a')]=qs[_0x78a6('0x3a')](_0x2d6cc5['query'][_0x78a6('0x3a')]);_0x538176[_0x78a6('0x21')]=qs[_0x78a6('0x21')](_0x2d6cc5[_0x78a6('0x30')]['offset']);}_0x538176[_0x78a6('0x68')]=qs[_0x78a6('0x3b')](_0x2d6cc5[_0x78a6('0x30')]['sort']);_0x538176[_0x78a6('0x3c')]=qs['filters'](_[_0x78a6('0x3d')](_0x2d6cc5[_0x78a6('0x30')],_0x3676d6[_0x78a6('0x32')]));_0x538176[_0x78a6('0x69')]=!![];if(_0x2d6cc5[_0x78a6('0x30')][_0x78a6('0x3e')]){_0x538176[_0x78a6('0x3c')]=_['merge'](_0x538176[_0x78a6('0x3c')],{'$or':_[_0x78a6('0x2c')](_0x538176['attributes'],function(_0xfbce7b){var _0x589c6e={};_0x589c6e[_0xfbce7b]={'$like':'%'+_0x2d6cc5[_0x78a6('0x30')][_0x78a6('0x3e')]+'%'};return _0x589c6e;})});}_0x538176=_[_0x78a6('0x3f')]({},_0x538176,_0x2d6cc5['options']);return _0x3e4d7e['getContacts'](_0x538176);}})['then'](function(_0x4e7cb5){if(!_[_0x78a6('0x6b')](_0x4e7cb5)){var _0x3f950a=toCsv(_0x4e7cb5);var _0x1abf08=Date[_0x78a6('0x6c')]();fs['writeFileSync'](util[_0x78a6('0x66')](_0x78a6('0x6d'),_0x3e4d7e['id'],_0x1abf08),_0x3f950a);_0x337931[_0x78a6('0x6e')](_0x78a6('0x6f'),_0x78a6('0x70')+util[_0x78a6('0x66')](_0x78a6('0x71'),_0x3e4d7e['id'],_0x1abf08));_0x337931[_0x78a6('0x6e')](_0x78a6('0x72'),_0x78a6('0x73'));return _0x337931[_0x78a6('0x74')](util[_0x78a6('0x66')](_0x78a6('0x6d'),_0x3e4d7e['id'],_0x1abf08));}else{return _0x337931['sendStatus'](0xcc);}})[_0x78a6('0x44')](handleError(_0x337931,null));};exports[_0x78a6('0x75')]=function(_0x115676,_0x1bee4a,_0x401cc6){var _0x2acf7a;delete _0x115676[_0x78a6('0x4b')]['id'];return db[_0x78a6('0x2d')][_0x78a6('0x54')]({'where':{'id':_0x115676[_0x78a6('0x46')]['id']}})['then'](handleEntityNotFound(_0x1bee4a,null))[_0x78a6('0x25')](function(_0x604aaf){if(_0x604aaf){return db[_0x78a6('0x76')][_0x78a6('0x77')](function(_0x491a97){return db[_0x78a6('0x6a')][_0x78a6('0x4a')](_0x115676[_0x78a6('0x4b')],{'transaction':_0x491a97})[_0x78a6('0x25')](function(_0x971b37){_0x2acf7a=_0x971b37;return _0x604aaf[_0x78a6('0x78')](_0x971b37,{'transaction':_0x491a97});})[_0x78a6('0x25')](function(){var _0x2f4a9c={'type':db[_0x78a6('0x79')]['TEXT'],'transaction':_0x491a97};switch(_0x115676[_0x78a6('0x4b')][_0x78a6('0x2e')]){case _0x78a6('0x7a'):_0x2f4a9c['type']=db[_0x78a6('0x79')][_0x78a6('0x7b')];break;case _0x78a6('0x7c'):_0x2f4a9c[_0x78a6('0x2e')]=db['Sequelize'][_0x78a6('0x7d')];break;case'switch':_0x2f4a9c['type']=db['Sequelize'][_0x78a6('0x7e')];_0x2f4a9c['defaultValue']=![];break;default:}return db[_0x78a6('0x76')][_0x78a6('0x7f')][_0x78a6('0x80')](_0x78a6('0x81'),util[_0x78a6('0x66')](_0x78a6('0x82'),_0x2acf7a['id']),_0x2f4a9c);})['then'](function(){return _0x2acf7a;});});}})[_0x78a6('0x25')](respondWithResult(_0x1bee4a,null))['catch'](handleError(_0x1bee4a,null));};exports[_0x78a6('0x83')]=function(_0x2bc9c2,_0x35a089,_0x599971){var _0x54f9ce={};var _0x310021={};var _0x56d8f9;var _0x190e87;return db[_0x78a6('0x2d')][_0x78a6('0x54')]({'where':{'id':_0x2bc9c2[_0x78a6('0x46')]['id']}})[_0x78a6('0x25')](handleEntityNotFound(_0x35a089,null))[_0x78a6('0x25')](function(_0x2600a5){if(_0x2600a5){_0x56d8f9=_0x2600a5;_0x310021['model']=_[_0x78a6('0x31')](db[_0x78a6('0x6a')]['rawAttributes']);_0x310021[_0x78a6('0x30')]=_[_0x78a6('0x31')](_0x2bc9c2[_0x78a6('0x30')]);_0x310021[_0x78a6('0x32')]=_['intersection'](_0x310021[_0x78a6('0x34')],_0x310021[_0x78a6('0x30')]);_0x54f9ce[_0x78a6('0x35')]=_['intersection'](_0x310021['model'],qs[_0x78a6('0x36')](_0x2bc9c2[_0x78a6('0x30')][_0x78a6('0x36')]));_0x54f9ce[_0x78a6('0x35')]=_0x54f9ce['attributes'][_0x78a6('0x37')]?_0x54f9ce['attributes']:_0x310021['model'];_0x54f9ce[_0x78a6('0x68')]=qs[_0x78a6('0x3b')](_0x2bc9c2[_0x78a6('0x30')][_0x78a6('0x3b')]);_0x54f9ce[_0x78a6('0x3c')]=qs['filters'](_[_0x78a6('0x3d')](_0x2bc9c2['query'],_0x310021['filters']));_0x54f9ce['where']=_['merge'](_0x54f9ce['where'],{'$or':[{'ListId':_0x2600a5['id']},{'ListId':null}]});if(_0x2bc9c2[_0x78a6('0x30')][_0x78a6('0x3e')]){_0x54f9ce[_0x78a6('0x3c')]=_[_0x78a6('0x3f')](_0x54f9ce[_0x78a6('0x3c')],{'$or':_[_0x78a6('0x2c')](_0x54f9ce[_0x78a6('0x35')],function(_0x20256d){var _0xdce20={};_0xdce20[_0x20256d]={'$like':'%'+_0x2bc9c2['query'][_0x78a6('0x3e')]+'%'};return _0xdce20;})});}_0x54f9ce=_[_0x78a6('0x3f')]({},_0x54f9ce,_0x2bc9c2[_0x78a6('0x41')]);return db['CmCustomField'][_0x78a6('0x84')](_0x54f9ce);}})[_0x78a6('0x25')](respondWithResult(_0x35a089,null))[_0x78a6('0x44')](handleError(_0x35a089,null));};exports['addAgents']=function(_0xbf274d,_0x268fc5,_0x42b2c0){return db['CmList']['find']({'where':{'id':_0xbf274d['params']['id']}})[_0x78a6('0x25')](handleEntityNotFound(_0x268fc5,null))[_0x78a6('0x25')](function(_0x485feb){if(_0x485feb){return _0x485feb['addAgents'](_0xbf274d[_0x78a6('0x4b')][_0x78a6('0x5d')],_[_0x78a6('0x5c')](_0xbf274d[_0x78a6('0x4b')],[_0x78a6('0x5d'),'id'])||{})[_0x78a6('0x85')](function(_0x470ed3){for(var _0x198256=0x0;_0x198256<_0xbf274d[_0x78a6('0x4b')][_0x78a6('0x5d')][_0x78a6('0x37')];_0x198256+=0x1){socket[_0x78a6('0x86')](_0x78a6('0x87'),{'UserId':_0xbf274d[_0x78a6('0x4b')][_0x78a6('0x5d')][_0x198256],'CmListId':_0xbf274d[_0x78a6('0x46')]['id']});}return _0x470ed3;});}})[_0x78a6('0x25')](respondWithResult(_0x268fc5,null))[_0x78a6('0x44')](handleError(_0x268fc5,null));};exports[_0x78a6('0x88')]=function(_0x3d9757,_0x59d754,_0x2a5a48){return db[_0x78a6('0x2d')][_0x78a6('0x49')]({'where':{'id':_0x3d9757[_0x78a6('0x46')]['id']}})[_0x78a6('0x25')](handleEntityNotFound(_0x59d754,null))['then'](function(_0xd20a3c){if(_0xd20a3c){return _0xd20a3c[_0x78a6('0x88')](_0x3d9757[_0x78a6('0x30')][_0x78a6('0x5d')])['then'](function(){if(_['isArray'](_0x3d9757[_0x78a6('0x30')][_0x78a6('0x5d')])){for(var _0x42d8b3=0x0;_0x42d8b3<_0x3d9757[_0x78a6('0x30')][_0x78a6('0x5d')]['length'];_0x42d8b3+=0x1){socket['emit']('userCmList:remove',{'UserId':Number(_0x3d9757['query'][_0x78a6('0x5d')][_0x42d8b3]),'CmListId':Number(_0x3d9757[_0x78a6('0x46')]['id'])});}}else{socket[_0x78a6('0x86')](_0x78a6('0x89'),{'UserId':Number(_0x3d9757['query'][_0x78a6('0x5d')]),'CmListId':Number(_0x3d9757[_0x78a6('0x46')]['id'])});}});}})[_0x78a6('0x25')](respondWithStatusCode(_0x59d754,null))[_0x78a6('0x44')](handleError(_0x59d754,null));};exports['getAgents']=function(_0xbe249d,_0x4f99f8,_0x2f0442){var _0x3bbf3f={};var _0x5ba5a2={};var _0x1cc3e6;var _0x1e0a93;return db[_0x78a6('0x2d')][_0x78a6('0x54')]({'where':{'id':_0xbe249d[_0x78a6('0x46')]['id']}})['then'](handleEntityNotFound(_0x4f99f8,null))[_0x78a6('0x25')](function(_0x4afd98){if(_0x4afd98){_0x1cc3e6=_0x4afd98;_0x5ba5a2[_0x78a6('0x34')]=_[_0x78a6('0x31')](db[_0x78a6('0x8a')][_0x78a6('0x64')]);_0x5ba5a2[_0x78a6('0x30')]=_[_0x78a6('0x31')](_0xbe249d[_0x78a6('0x30')]);_0x5ba5a2[_0x78a6('0x32')]=_[_0x78a6('0x33')](_0x5ba5a2['model'],_0x5ba5a2['query']);_0x3bbf3f[_0x78a6('0x35')]=_[_0x78a6('0x33')](_0x5ba5a2[_0x78a6('0x34')],qs[_0x78a6('0x36')](_0xbe249d[_0x78a6('0x30')]['fields']));_0x3bbf3f[_0x78a6('0x35')]=_0x3bbf3f[_0x78a6('0x35')][_0x78a6('0x37')]?_0x3bbf3f['attributes']:_0x5ba5a2['model'];_0x3bbf3f[_0x78a6('0x68')]=qs[_0x78a6('0x3b')](_0xbe249d[_0x78a6('0x30')][_0x78a6('0x3b')]);_0x3bbf3f['where']=qs['filters'](_[_0x78a6('0x3d')](_0xbe249d[_0x78a6('0x30')],_0x5ba5a2[_0x78a6('0x32')]));if(_0xbe249d[_0x78a6('0x30')][_0x78a6('0x3e')]){_0x3bbf3f[_0x78a6('0x3c')]=_[_0x78a6('0x3f')](_0x3bbf3f[_0x78a6('0x3c')],{'$or':_['map'](_0x3bbf3f[_0x78a6('0x35')],function(_0x46e302){var _0x46fefa={};_0x46fefa[_0x46e302]={'$like':'%'+_0xbe249d[_0x78a6('0x30')][_0x78a6('0x3e')]+'%'};return _0x46fefa;})});}_0x3bbf3f=_[_0x78a6('0x3f')]({},_0x3bbf3f,_0xbe249d[_0x78a6('0x41')]);return _0x1cc3e6[_0x78a6('0x8b')](_0x3bbf3f);}})[_0x78a6('0x25')](function(_0x24d6dd){if(_0x24d6dd){_0x1e0a93=_0x24d6dd[_0x78a6('0x37')];if(!_0xbe249d[_0x78a6('0x30')][_0x78a6('0x38')]('nolimit')){_0x3bbf3f[_0x78a6('0x3a')]=qs['limit'](_0xbe249d[_0x78a6('0x30')][_0x78a6('0x3a')]);_0x3bbf3f[_0x78a6('0x21')]=qs['offset'](_0xbe249d[_0x78a6('0x30')][_0x78a6('0x21')]);}return _0x1cc3e6['getAgents'](_0x3bbf3f);}})[_0x78a6('0x25')](function(_0x59e38b){if(_0x59e38b){return _0x59e38b?{'count':_0x1e0a93,'rows':_0x59e38b}:null;}})[_0x78a6('0x25')](respondWithResult(_0x4f99f8,null))['catch'](handleError(_0x4f99f8,null));};
\ No newline at end of file
+var _0x0796=['getGlobalCustomFields','addAgents','spread','emit','userCmList:save','userCmList:remove','getAgents','User','rimraf','request-promise','mustache','sox','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','to-csv','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/utils','../../config/environment','../../mysqldb','redis','defaults','localhost','./cmList.socket','register','status','offset','undefined','limit','count','set','Content-Range','reject','save','then','destroy','UserProfileResource','end','sendStatus','stack','name','send','fieldName','type','key','model','map','query','keys','filters','intersection','attributes','fields','nolimit','order','sort','where','filter','merge','options','includeAll','include','CmList','findAll','params','find','catch','create','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','get','Lists','UserProfileSection','userProfileId','autoAssociation','error','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','update','body','describe','addDisposition','ListId','Disposition','getDispositions','findOne','rawAttributes','length','hasOwnProperty','pick','rows','removeDispositions','ids','addContacts','tags','isArray','join','push','each','CmContact','success','dataValues','errors','message','json','Malformed\x20request\x20syntax','getContacts','CustomFields','concat','cf_%d','ContactItemType','CmCustomField','alias','from','cm_contacts','c.ListId\x20=\x20?','distinct','field','c.cf_','customField_','select','cm_contact_has_items','ItemTypeId\x20=\x20?','CmContactId\x20=\x20c.id','additionalPhone_','description','description_additionalPhone_','toString','isEmpty','writeFileSync','format','/tmp/list_%d_%s.csv','setHeader','Content-disposition','Content-type','text/csv','addCustomField','sequelize','transaction','addCustomFields','Sequelize','TEXT','number','switch','BOOLEAN','defaultValue','queryInterface','addColumn','cf_%s','getCustomFields','findAndCountAll'];(function(_0x2ee83c,_0x220f7d){var _0x1734d8=function(_0x5dfb10){while(--_0x5dfb10){_0x2ee83c['push'](_0x2ee83c['shift']());}};_0x1734d8(++_0x220f7d);}(_0x0796,0x148));var _0x6079=function(_0x45c1f7,_0x4ede39){_0x45c1f7=_0x45c1f7-0x0;var _0x4659cd=_0x0796[_0x45c1f7];return _0x4659cd;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x6079('0x0'));var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require(_0x6079('0x1'));var moment=require('moment');var BPromise=require('bluebird');var Mustache=require(_0x6079('0x2'));var util=require('util');var path=require('path');var sox=require(_0x6079('0x3'));var csv=require('to-csv');var ejs=require(_0x6079('0x4'));var fs=require('fs');var fs_extra=require(_0x6079('0x5'));var _=require(_0x6079('0x6'));var squel=require(_0x6079('0x7'));var crypto=require(_0x6079('0x8'));var jsforce=require(_0x6079('0x9'));var deskjs=require(_0x6079('0xa'));var toCsv=require(_0x6079('0xb'));var querystring=require(_0x6079('0xc'));var Papa=require(_0x6079('0xd'));var Redis=require(_0x6079('0xe'));var authService=require('../../components/auth/service');var qs=require(_0x6079('0xf'));var as=require(_0x6079('0x10'));var hardwareService=require(_0x6079('0x11'));var logger=require('../../config/logger')('api');var utils=require(_0x6079('0x12'));var config=require(_0x6079('0x13'));var licenseUtil=require('../../config/license/util');var db=require(_0x6079('0x14'))['db'];var csv_results;config[_0x6079('0x15')]=_[_0x6079('0x16')](config[_0x6079('0x15')],{'host':_0x6079('0x17'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x6079('0x15')]));require(_0x6079('0x18'))[_0x6079('0x19')](socket);function respondWithStatusCode(_0x23186e,_0x438b4e){_0x438b4e=_0x438b4e||0xcc;return function(_0xf1336c){if(_0xf1336c){return _0x23186e['sendStatus'](_0x438b4e);}return _0x23186e[_0x6079('0x1a')](_0x438b4e)['end']();};}function respondWithResult(_0xf1b783,_0x54095b){_0x54095b=_0x54095b||0xc8;return function(_0x16adfd){if(_0x16adfd){return _0xf1b783[_0x6079('0x1a')](_0x54095b)['json'](_0x16adfd);}};}function respondWithFilteredResult(_0x1909bd,_0x34dbd9){return function(_0x4e58d4){if(_0x4e58d4){var _0x2f1f44=typeof _0x34dbd9[_0x6079('0x1b')]===_0x6079('0x1c')&&typeof _0x34dbd9[_0x6079('0x1d')]===_0x6079('0x1c');var _0x26706c=_0x4e58d4[_0x6079('0x1e')];var _0xd82cef=_0x2f1f44?0x0:_0x34dbd9[_0x6079('0x1b')];var _0x27e9c7=_0x2f1f44?_0x4e58d4[_0x6079('0x1e')]:_0x34dbd9[_0x6079('0x1b')]+_0x34dbd9[_0x6079('0x1d')];var _0x40f3cd;if(_0x27e9c7>=_0x26706c){_0x27e9c7=_0x26706c;_0x40f3cd=0xc8;}else{_0x40f3cd=0xce;}_0x1909bd[_0x6079('0x1a')](_0x40f3cd);return _0x1909bd[_0x6079('0x1f')](_0x6079('0x20'),_0xd82cef+'-'+_0x27e9c7+'/'+_0x26706c)['json'](_0x4e58d4);}return null;};}function patchUpdates(_0x547f0d){return function(_0x5b64a7){try{jsonpatch['apply'](_0x5b64a7,_0x547f0d,!![]);}catch(_0x42f9cf){return BPromise[_0x6079('0x21')](_0x42f9cf);}return _0x5b64a7[_0x6079('0x22')]();};}function saveUpdates(_0x1e12af,_0x1f9a62){return function(_0x3a3096){if(_0x3a3096){return _0x3a3096['update'](_0x1e12af)[_0x6079('0x23')](function(_0x1117aa){return _0x1117aa;});}return null;};}function removeEntity(_0x1ff094,_0x45b159){return function(_0x213585){if(_0x213585){return _0x213585[_0x6079('0x24')]()[_0x6079('0x23')](function(){var _0x1f7bff=_0x213585['get']({'plain':!![]});var _0x2c2464='Lists';return db[_0x6079('0x25')][_0x6079('0x24')]({'where':{'type':_0x2c2464,'resourceId':_0x1f7bff['id']}})[_0x6079('0x23')](function(){return _0x213585;});})[_0x6079('0x23')](function(){_0x1ff094[_0x6079('0x1a')](0xcc)[_0x6079('0x26')]();});}};}function handleEntityNotFound(_0x2b06d9,_0x228c8b){return function(_0x1758a5){if(!_0x1758a5){_0x2b06d9[_0x6079('0x27')](0x194);}return _0x1758a5;};}function handleError(_0x4c7fef,_0x1cd1c6){_0x1cd1c6=_0x1cd1c6||0x1f4;return function(_0x4ac078){logger['error'](_0x4ac078[_0x6079('0x28')]);if(_0x4ac078['name']){delete _0x4ac078[_0x6079('0x29')];}_0x4c7fef[_0x6079('0x1a')](_0x1cd1c6)[_0x6079('0x2a')](_0x4ac078);};}exports['index']=function(_0x42f87b,_0x303753){var _0x2f9122={},_0x41d750={},_0x347a91={'count':0x0,'rows':[]};var _0x576d50=_['map'](db['CmList']['rawAttributes'],function(_0x4911b7){return{'name':_0x4911b7[_0x6079('0x2b')],'type':_0x4911b7[_0x6079('0x2c')][_0x6079('0x2d')]};});_0x41d750[_0x6079('0x2e')]=_[_0x6079('0x2f')](_0x576d50,_0x6079('0x29'));_0x41d750[_0x6079('0x30')]=_[_0x6079('0x31')](_0x42f87b['query']);_0x41d750[_0x6079('0x32')]=_[_0x6079('0x33')](_0x41d750[_0x6079('0x2e')],_0x41d750[_0x6079('0x30')]);_0x2f9122[_0x6079('0x34')]=_['intersection'](_0x41d750[_0x6079('0x2e')],qs[_0x6079('0x35')](_0x42f87b[_0x6079('0x30')]['fields']));_0x2f9122[_0x6079('0x34')]=_0x2f9122[_0x6079('0x34')]['length']?_0x2f9122[_0x6079('0x34')]:_0x41d750['model'];if(!_0x42f87b[_0x6079('0x30')]['hasOwnProperty'](_0x6079('0x36'))){_0x2f9122[_0x6079('0x1d')]=qs[_0x6079('0x1d')](_0x42f87b[_0x6079('0x30')]['limit']);_0x2f9122[_0x6079('0x1b')]=qs[_0x6079('0x1b')](_0x42f87b[_0x6079('0x30')]['offset']);}_0x2f9122[_0x6079('0x37')]=qs[_0x6079('0x38')](_0x42f87b[_0x6079('0x30')][_0x6079('0x38')]);_0x2f9122[_0x6079('0x39')]=qs[_0x6079('0x32')](_['pick'](_0x42f87b[_0x6079('0x30')],_0x41d750['filters']),_0x576d50);if(_0x42f87b[_0x6079('0x30')][_0x6079('0x3a')]){_0x2f9122['where']=_[_0x6079('0x3b')](_0x2f9122[_0x6079('0x39')],{'$or':_[_0x6079('0x2f')](_0x576d50,function(_0x4f15ad){if(_0x4f15ad[_0x6079('0x2c')]!=='VIRTUAL'){var _0xdff935={};_0xdff935[_0x4f15ad[_0x6079('0x29')]]={'$like':'%'+_0x42f87b['query'][_0x6079('0x3a')]+'%'};return _0xdff935;}})});}_0x2f9122=_[_0x6079('0x3b')]({},_0x2f9122,_0x42f87b[_0x6079('0x3c')]);var _0x3e6efa={'where':_0x2f9122['where']};return db['CmList']['count'](_0x3e6efa)['then'](function(_0x3b7b41){_0x347a91[_0x6079('0x1e')]=_0x3b7b41;if(_0x42f87b['query'][_0x6079('0x3d')]){_0x2f9122[_0x6079('0x3e')]=[{'all':!![]}];}return db[_0x6079('0x3f')][_0x6079('0x40')](_0x2f9122);})[_0x6079('0x23')](function(_0xfb1914){_0x347a91['rows']=_0xfb1914;return _0x347a91;})[_0x6079('0x23')](respondWithFilteredResult(_0x303753,_0x2f9122))['catch'](handleError(_0x303753,null));};exports['show']=function(_0x3f3e1c,_0x48e8b8){var _0x3fbf6a={'raw':![],'where':{'id':_0x3f3e1c[_0x6079('0x41')]['id']}},_0x313d95={};_0x313d95['model']=_[_0x6079('0x31')](db[_0x6079('0x3f')]['rawAttributes']);_0x313d95['query']=_[_0x6079('0x31')](_0x3f3e1c[_0x6079('0x30')]);_0x313d95['filters']=_[_0x6079('0x33')](_0x313d95[_0x6079('0x2e')],_0x313d95['query']);_0x3fbf6a[_0x6079('0x34')]=_[_0x6079('0x33')](_0x313d95[_0x6079('0x2e')],qs[_0x6079('0x35')](_0x3f3e1c['query']['fields']));_0x3fbf6a[_0x6079('0x34')]=_0x3fbf6a[_0x6079('0x34')]['length']?_0x3fbf6a['attributes']:_0x313d95['model'];if(_0x3f3e1c['query']['includeAll']){_0x3fbf6a[_0x6079('0x3e')]=[{'all':!![]}];}_0x3fbf6a=_[_0x6079('0x3b')]({},_0x3fbf6a,_0x3f3e1c[_0x6079('0x3c')]);return db[_0x6079('0x3f')][_0x6079('0x42')](_0x3fbf6a)[_0x6079('0x23')](handleEntityNotFound(_0x48e8b8,null))[_0x6079('0x23')](respondWithResult(_0x48e8b8,null))[_0x6079('0x43')](handleError(_0x48e8b8,null));};exports[_0x6079('0x44')]=function(_0x576259,_0x2a93a4){return db['CmList'][_0x6079('0x44')](_0x576259['body'],{})['then'](function(_0x366d1a){var _0x5a92d7=_0x576259[_0x6079('0x45')]['get']({'plain':!![]});if(!_0x5a92d7)throw new Error(_0x6079('0x46'));if(_0x5a92d7[_0x6079('0x47')]===_0x6079('0x45')){var _0x122b18=_0x366d1a[_0x6079('0x48')]({'plain':!![]});var _0x2ee823=_0x6079('0x49');return db[_0x6079('0x4a')]['find']({'where':{'name':_0x2ee823,'userProfileId':_0x5a92d7[_0x6079('0x4b')]},'raw':!![]})['then'](function(_0x2d6cbb){if(_0x2d6cbb&&_0x2d6cbb[_0x6079('0x4c')]===0x0){return db[_0x6079('0x25')]['create']({'name':_0x122b18['name'],'resourceId':_0x122b18['id'],'type':_0x2d6cbb[_0x6079('0x29')],'sectionId':_0x2d6cbb['id']},{})[_0x6079('0x23')](function(){return _0x366d1a;});}else{return _0x366d1a;}})[_0x6079('0x43')](function(_0x4dfedb){logger[_0x6079('0x4d')](_0x6079('0x4e'),_0x4dfedb);throw _0x4dfedb;});}return _0x366d1a;})[_0x6079('0x23')](respondWithResult(_0x2a93a4,0xc9))[_0x6079('0x43')](handleError(_0x2a93a4,null));};exports[_0x6079('0x4f')]=function(_0x1dfc1d,_0x30413d){if(_0x1dfc1d[_0x6079('0x50')]['id']){delete _0x1dfc1d[_0x6079('0x50')]['id'];}return db[_0x6079('0x3f')][_0x6079('0x42')]({'where':{'id':_0x1dfc1d[_0x6079('0x41')]['id']}})[_0x6079('0x23')](handleEntityNotFound(_0x30413d,null))[_0x6079('0x23')](saveUpdates(_0x1dfc1d[_0x6079('0x50')],null))[_0x6079('0x23')](respondWithResult(_0x30413d,null))[_0x6079('0x43')](handleError(_0x30413d,null));};exports[_0x6079('0x24')]=function(_0x287702,_0x125f75){return db['CmList']['find']({'where':{'id':_0x287702[_0x6079('0x41')]['id']}})[_0x6079('0x23')](handleEntityNotFound(_0x125f75,null))[_0x6079('0x23')](removeEntity(_0x125f75,null))[_0x6079('0x43')](handleError(_0x125f75,null));};exports[_0x6079('0x51')]=function(_0x5e1497,_0x3f65cc){return db[_0x6079('0x3f')][_0x6079('0x51')]()[_0x6079('0x23')](respondWithResult(_0x3f65cc,null))[_0x6079('0x43')](handleError(_0x3f65cc,null));};exports[_0x6079('0x52')]=function(_0x46b153,_0x5b9b32,_0x1c8cc1){if(_0x46b153[_0x6079('0x50')]['id']){delete _0x46b153[_0x6079('0x50')]['id'];}return db[_0x6079('0x3f')][_0x6079('0x42')]({'where':{'id':_0x46b153[_0x6079('0x41')]['id']}})[_0x6079('0x23')](handleEntityNotFound(_0x5b9b32,null))[_0x6079('0x23')](function(_0x1bfa38){if(_0x1bfa38){_0x46b153['body'][_0x6079('0x53')]=_0x1bfa38['id'];return db[_0x6079('0x54')][_0x6079('0x44')](_0x46b153[_0x6079('0x50')]);}})['then'](respondWithResult(_0x5b9b32,null))['catch'](handleError(_0x5b9b32,null));};exports[_0x6079('0x55')]=function(_0x173abc,_0x99ea99,_0x23c33a){var _0xd2e5dd={'raw':![],'where':{}};var _0x487847={};var _0x579456={'count':0x0,'rows':[]};return db[_0x6079('0x3f')][_0x6079('0x56')]({'where':{'id':_0x173abc['params']['id']}})[_0x6079('0x23')](handleEntityNotFound(_0x99ea99,null))[_0x6079('0x23')](function(_0x3d9be8){if(_0x3d9be8){_0x487847[_0x6079('0x2e')]=_[_0x6079('0x31')](db[_0x6079('0x54')][_0x6079('0x57')]);_0x487847[_0x6079('0x30')]=_['keys'](_0x173abc['query']);_0x487847[_0x6079('0x32')]=_['intersection'](_0x487847[_0x6079('0x2e')],_0x487847[_0x6079('0x30')]);_0xd2e5dd[_0x6079('0x34')]=_[_0x6079('0x33')](_0x487847[_0x6079('0x2e')],qs[_0x6079('0x35')](_0x173abc[_0x6079('0x30')][_0x6079('0x35')]));_0xd2e5dd['attributes']=_0xd2e5dd[_0x6079('0x34')][_0x6079('0x58')]?_0xd2e5dd[_0x6079('0x34')]:_0x487847['model'];if(!_0x173abc[_0x6079('0x30')][_0x6079('0x59')](_0x6079('0x36'))){_0xd2e5dd[_0x6079('0x1d')]=qs[_0x6079('0x1d')](_0x173abc[_0x6079('0x30')]['limit']);_0xd2e5dd[_0x6079('0x1b')]=qs[_0x6079('0x1b')](_0x173abc[_0x6079('0x30')][_0x6079('0x1b')]);}_0xd2e5dd[_0x6079('0x37')]=qs['sort'](_0x173abc[_0x6079('0x30')]['sort']);_0xd2e5dd[_0x6079('0x39')]=qs[_0x6079('0x32')](_[_0x6079('0x5a')](_0x173abc['query'],_0x487847[_0x6079('0x32')]));_0xd2e5dd[_0x6079('0x39')][_0x6079('0x53')]=_0x3d9be8['id'];if(_0x173abc['query'][_0x6079('0x3a')]){_0xd2e5dd[_0x6079('0x39')]=_['merge'](_0xd2e5dd[_0x6079('0x39')],{'$or':_[_0x6079('0x2f')](_0xd2e5dd[_0x6079('0x34')],function(_0x4a6f56){var _0x506ebc={};_0x506ebc[_0x4a6f56]={'$like':'%'+_0x173abc[_0x6079('0x30')][_0x6079('0x3a')]+'%'};return _0x506ebc;})});}_0xd2e5dd=_[_0x6079('0x3b')]({},_0xd2e5dd,_0x173abc[_0x6079('0x3c')]);return db[_0x6079('0x54')][_0x6079('0x1e')]({'where':_0xd2e5dd[_0x6079('0x39')]})['then'](function(_0xd7ea7a){_0x579456[_0x6079('0x1e')]=_0xd7ea7a;if(_0x173abc['query'][_0x6079('0x3d')]){_0xd2e5dd[_0x6079('0x3e')]=[{'all':!![]}];}return db[_0x6079('0x54')]['findAll'](_0xd2e5dd);})[_0x6079('0x23')](function(_0x140f87){_0x579456[_0x6079('0x5b')]=_0x140f87;return _0x579456;});}})[_0x6079('0x23')](respondWithFilteredResult(_0x99ea99,_0xd2e5dd))['catch'](handleError(_0x99ea99,null));};exports['removeDispositions']=function(_0x24bcc5,_0x5814f9,_0x541d29){return db[_0x6079('0x3f')][_0x6079('0x42')]({'where':{'id':_0x24bcc5['params']['id']}})[_0x6079('0x23')](handleEntityNotFound(_0x5814f9,null))[_0x6079('0x23')](function(_0xccc422){if(_0xccc422){return _0xccc422[_0x6079('0x5c')](_0x24bcc5[_0x6079('0x30')][_0x6079('0x5d')]);}})[_0x6079('0x23')](respondWithStatusCode(_0x5814f9,null))[_0x6079('0x43')](handleError(_0x5814f9,null));};exports[_0x6079('0x5e')]=function(_0x1e0322,_0x322789,_0x4adb49){return db['CmList']['find']({'where':{'id':_0x1e0322[_0x6079('0x41')]['id']}})[_0x6079('0x23')](handleEntityNotFound(_0x322789,null))[_0x6079('0x23')](function(_0x2d05c6){if(_0x2d05c6){var _0x56eda2=[];var _0x1becff={'success':[],'errors':[]};return db['CmContact'][_0x6079('0x51')]()[_0x6079('0x23')](function(_0x3f1c71){if(_0x1e0322[_0x6079('0x50')][_0x6079('0x5f')]&&_[_0x6079('0x60')](_0x1e0322[_0x6079('0x50')]['tags'])){if(_0x1e0322[_0x6079('0x50')][_0x6079('0x5f')][_0x6079('0x58')]){_0x1e0322[_0x6079('0x50')]['tags']=_0x1e0322[_0x6079('0x50')][_0x6079('0x5f')][_0x6079('0x61')](';')+';';}else{_0x1e0322[_0x6079('0x50')][_0x6079('0x5f')]=null;}}else{_0x1e0322[_0x6079('0x50')][_0x6079('0x5f')]=null;}if(_0x1e0322[_0x6079('0x50')]&&_[_0x6079('0x60')](_0x1e0322[_0x6079('0x50')])){for(var _0xc30440=0x0;_0xc30440<_0x1e0322[_0x6079('0x50')][_0x6079('0x58')];_0xc30440+=0x1){_0x1e0322[_0x6079('0x50')][_0xc30440]['ListId']=_0x1e0322['params']['id'];_0x56eda2[_0x6079('0x62')](_0x1e0322[_0x6079('0x50')][_0xc30440]);}return BPromise[_0x6079('0x63')](_0x56eda2,function(_0x532254){return db[_0x6079('0x64')][_0x6079('0x44')](_['omit'](_0x532254,['ids','id'])||{},{'fields':_[_0x6079('0x31')](_0x3f1c71),'raw':!![]})[_0x6079('0x23')](function(_0x6a3d28){_0x1becff[_0x6079('0x65')][_0x6079('0x62')](_0x6a3d28[_0x6079('0x66')]);})[_0x6079('0x43')](function(_0x499bc1){_0x1becff[_0x6079('0x67')][_0x6079('0x62')]({'data':_0x532254,'error':_0x499bc1[_0x6079('0x68')]});});})[_0x6079('0x23')](function(_0x2d0b8f){return _0x1becff;})[_0x6079('0x43')](function(_0x686c05){return _0x686c05;});}else{_0x322789[_0x6079('0x1a')](0x190)[_0x6079('0x69')]({'message':_0x6079('0x6a')});}});}})[_0x6079('0x23')](respondWithResult(_0x322789,null))[_0x6079('0x43')](handleError(_0x322789,null));};exports[_0x6079('0x6b')]=function(_0x5def84,_0x15136b,_0x1524ac){var _0x513881;return db[_0x6079('0x3f')][_0x6079('0x42')]({'where':{'id':_0x5def84['params']['id']},'include':[{'model':db['CmCustomField'],'as':_0x6079('0x6c')}]})[_0x6079('0x23')](handleEntityNotFound(_0x15136b,null))[_0x6079('0x23')](function(_0x4b7cd5){if(_0x4b7cd5){_0x513881=_0x4b7cd5;return db[_0x6079('0x64')][_0x6079('0x57')];}})[_0x6079('0x23')](function(_0x30ccc6){if(_0x30ccc6){var _0x56d03c={};var _0x36ebee={};_0x36ebee[_0x6079('0x2e')]=_[_0x6079('0x6d')](_['keys'](_0x30ccc6),_[_0x6079('0x2f')](_0x513881[_0x6079('0x6c')],function(_0x2fa04d){return util['format'](_0x6079('0x6e'),_0x2fa04d['id']);}));_0x36ebee[_0x6079('0x30')]=_[_0x6079('0x31')](_0x5def84[_0x6079('0x30')]);_0x36ebee[_0x6079('0x32')]=_['intersection'](_0x36ebee['model'],_0x36ebee[_0x6079('0x30')]);_0x56d03c[_0x6079('0x34')]=_[_0x6079('0x33')](_0x36ebee[_0x6079('0x2e')],qs[_0x6079('0x35')](_0x5def84['query'][_0x6079('0x35')]));_0x56d03c[_0x6079('0x34')]=_0x56d03c[_0x6079('0x34')][_0x6079('0x58')]?_0x56d03c['attributes']:_0x36ebee[_0x6079('0x2e')];if(!_0x5def84[_0x6079('0x30')][_0x6079('0x59')](_0x6079('0x36'))){_0x56d03c[_0x6079('0x1d')]=qs['limit'](_0x5def84[_0x6079('0x30')][_0x6079('0x1d')]);_0x56d03c[_0x6079('0x1b')]=qs[_0x6079('0x1b')](_0x5def84[_0x6079('0x30')][_0x6079('0x1b')]);}_0x56d03c['order']=qs['sort'](_0x5def84[_0x6079('0x30')][_0x6079('0x38')]);_0x56d03c[_0x6079('0x39')]=qs['filters'](_[_0x6079('0x5a')](_0x5def84[_0x6079('0x30')],_0x36ebee[_0x6079('0x32')]));_0x56d03c['raw']=!![];if(_0x5def84['query']['filter']){_0x56d03c[_0x6079('0x39')]=_[_0x6079('0x3b')](_0x56d03c[_0x6079('0x39')],{'$or':_[_0x6079('0x2f')](_0x56d03c[_0x6079('0x34')],function(_0x5393ac){var _0x5cec7a={};_0x5cec7a[_0x5393ac]={'$like':'%'+_0x5def84[_0x6079('0x30')][_0x6079('0x3a')]+'%'};return _0x5cec7a;})});}_0x56d03c=_['merge']({},_0x56d03c,_0x5def84[_0x6079('0x3c')]);return _0x513881['getContacts'](_0x56d03c);}})[_0x6079('0x23')](respondWithResult(_0x15136b,null))[_0x6079('0x43')](handleError(_0x15136b,null));};exports['getContactsCsv']=function(_0x4b58ed,_0x59bd95,_0x235d2c){var _0x556b25;var _0x508faa;var _0x29aea8;var _0x138519=_0x4b58ed['params']['id'];csv_results=[];return db[_0x6079('0x6f')][_0x6079('0x40')]({'attributes':['id',_0x6079('0x29')],'raw':!![],'order':['OrderBy']})[_0x6079('0x23')](function(_0x57bd12){_0x556b25=_0x57bd12;var _0x1a55e3=_['keys'](db[_0x6079('0x64')]['rawAttributes']);return db[_0x6079('0x70')][_0x6079('0x40')]({'raw':!![],'attributes':['id',_0x6079('0x71')]})[_0x6079('0x23')](function(_0x214a0a){_0x508faa=_0x214a0a;var _0x29d58f=squel['select']()[_0x6079('0x35')](_0x1a55e3)[_0x6079('0x72')](_0x6079('0x73'),'c')[_0x6079('0x39')](_0x6079('0x74'),_0x138519)[_0x6079('0x39')]('c.deletedAt\x20is\x20null')[_0x6079('0x75')]();for(var _0x490e01=0x0;_0x490e01<_0x508faa[_0x6079('0x58')];_0x490e01++){_0x29d58f[_0x6079('0x76')](_0x6079('0x77')+_0x508faa[_0x490e01]['id'],_0x6079('0x78')+_0x508faa[_0x490e01][_0x6079('0x71')]);}for(var _0x490e01=0x0;_0x490e01<_0x556b25[_0x6079('0x58')];_0x490e01++){_0x29d58f[_0x6079('0x76')](squel[_0x6079('0x79')]()[_0x6079('0x76')]('item')[_0x6079('0x72')](_0x6079('0x7a'))[_0x6079('0x39')](_0x6079('0x7b'),_0x556b25[_0x490e01]['id'])[_0x6079('0x39')](_0x6079('0x7c')),_0x6079('0x7d')+_0x556b25[_0x490e01][_0x6079('0x29')]);_0x29d58f[_0x6079('0x76')](squel[_0x6079('0x79')]()[_0x6079('0x76')](_0x6079('0x7e'))[_0x6079('0x72')](_0x6079('0x7a'))[_0x6079('0x39')](_0x6079('0x7b'),_0x556b25[_0x490e01]['id'])[_0x6079('0x39')]('CmContactId\x20=\x20c.id'),_0x6079('0x7f')+_0x556b25[_0x490e01][_0x6079('0x29')]);}var _0x12a790=[];_0x12a790[_0x6079('0x62')](_0x29d58f[_0x6079('0x80')]());BPromise[_0x6079('0x63')](_0x12a790,handleQuery)[_0x6079('0x23')](function(_0x31f85){handleQuery(_0x29d58f['toString']());var _0x4b0b29=csv_results[0x0];if(!_[_0x6079('0x81')](_0x4b0b29)){var _0x5975d9=toCsv(_0x4b0b29);var _0x505f4f=Date['now']();fs[_0x6079('0x82')](util[_0x6079('0x83')](_0x6079('0x84'),_0x138519,_0x505f4f),_0x5975d9);_0x59bd95[_0x6079('0x85')](_0x6079('0x86'),'attachment;\x20filename='+util[_0x6079('0x83')]('list_%d_%s.csv',_0x138519,_0x505f4f));_0x59bd95[_0x6079('0x85')](_0x6079('0x87'),_0x6079('0x88'));return _0x59bd95['download'](util[_0x6079('0x83')](_0x6079('0x84'),_0x138519,_0x505f4f));}else{return _0x59bd95[_0x6079('0x27')](0xcc);}});});});};exports[_0x6079('0x89')]=function(_0x33c970,_0x2f98c9,_0x30beca){var _0x3391b2;delete _0x33c970['body']['id'];return db['CmList'][_0x6079('0x56')]({'where':{'id':_0x33c970[_0x6079('0x41')]['id']}})['then'](handleEntityNotFound(_0x2f98c9,null))['then'](function(_0x2acf96){if(_0x2acf96){return db[_0x6079('0x8a')][_0x6079('0x8b')](function(_0x3f5850){return db[_0x6079('0x70')][_0x6079('0x44')](_0x33c970['body'],{'transaction':_0x3f5850})[_0x6079('0x23')](function(_0x15513c){_0x3391b2=_0x15513c;return _0x2acf96[_0x6079('0x8c')](_0x15513c,{'transaction':_0x3f5850});})['then'](function(){var _0x454598={'type':db[_0x6079('0x8d')][_0x6079('0x8e')],'transaction':_0x3f5850};switch(_0x33c970[_0x6079('0x50')]['type']){case'text':_0x454598[_0x6079('0x2c')]=db[_0x6079('0x8d')]['TEXT'];break;case _0x6079('0x8f'):_0x454598[_0x6079('0x2c')]=db[_0x6079('0x8d')]['INTEGER'];break;case _0x6079('0x90'):_0x454598[_0x6079('0x2c')]=db[_0x6079('0x8d')][_0x6079('0x91')];_0x454598[_0x6079('0x92')]=![];break;default:}return db[_0x6079('0x8a')][_0x6079('0x93')][_0x6079('0x94')](_0x6079('0x73'),util['format'](_0x6079('0x95'),_0x3391b2['id']),_0x454598);})[_0x6079('0x23')](function(){return _0x3391b2;});});}})[_0x6079('0x23')](respondWithResult(_0x2f98c9,null))['catch'](handleError(_0x2f98c9,null));};exports[_0x6079('0x96')]=function(_0x28486f,_0x578f19,_0x10f56c){var _0x264b41={};var _0x357c0e={};var _0x367a62;var _0x3295e6;return db[_0x6079('0x3f')][_0x6079('0x56')]({'where':{'id':_0x28486f[_0x6079('0x41')]['id']}})[_0x6079('0x23')](handleEntityNotFound(_0x578f19,null))[_0x6079('0x23')](function(_0x3a0f51){if(_0x3a0f51){_0x367a62=_0x3a0f51;_0x357c0e[_0x6079('0x2e')]=_[_0x6079('0x31')](db[_0x6079('0x70')]['rawAttributes']);_0x357c0e['query']=_[_0x6079('0x31')](_0x28486f[_0x6079('0x30')]);_0x357c0e[_0x6079('0x32')]=_[_0x6079('0x33')](_0x357c0e[_0x6079('0x2e')],_0x357c0e[_0x6079('0x30')]);_0x264b41[_0x6079('0x34')]=_[_0x6079('0x33')](_0x357c0e[_0x6079('0x2e')],qs['fields'](_0x28486f[_0x6079('0x30')]['fields']));_0x264b41[_0x6079('0x34')]=_0x264b41[_0x6079('0x34')][_0x6079('0x58')]?_0x264b41['attributes']:_0x357c0e[_0x6079('0x2e')];_0x264b41[_0x6079('0x37')]=qs[_0x6079('0x38')](_0x28486f[_0x6079('0x30')][_0x6079('0x38')]);_0x264b41[_0x6079('0x39')]=qs[_0x6079('0x32')](_[_0x6079('0x5a')](_0x28486f['query'],_0x357c0e[_0x6079('0x32')]));_0x264b41['where']=_[_0x6079('0x3b')](_0x264b41[_0x6079('0x39')],{'$or':[{'ListId':_0x3a0f51['id']},{'ListId':null}]});if(_0x28486f['query'][_0x6079('0x3a')]){_0x264b41[_0x6079('0x39')]=_['merge'](_0x264b41[_0x6079('0x39')],{'$or':_[_0x6079('0x2f')](_0x264b41[_0x6079('0x34')],function(_0x2e78c6){var _0x26156e={};_0x26156e[_0x2e78c6]={'$like':'%'+_0x28486f[_0x6079('0x30')][_0x6079('0x3a')]+'%'};return _0x26156e;})});}_0x264b41=_[_0x6079('0x3b')]({},_0x264b41,_0x28486f[_0x6079('0x3c')]);return db[_0x6079('0x70')][_0x6079('0x97')](_0x264b41);}})['then'](respondWithResult(_0x578f19,null))[_0x6079('0x43')](handleError(_0x578f19,null));};exports[_0x6079('0x98')]=function(_0xc3ddf5,_0x131149){return db[_0x6079('0x70')][_0x6079('0x97')]({'where':{'ListId':null}})[_0x6079('0x23')](handleEntityNotFound(_0x131149,null))[_0x6079('0x23')](function(_0x4265bc){return _0x4265bc;})[_0x6079('0x23')](respondWithResult(_0x131149,null))['catch'](handleError(_0x131149,null));};exports[_0x6079('0x99')]=function(_0x592510,_0x24d5c6,_0x103e04){return db[_0x6079('0x3f')][_0x6079('0x42')]({'where':{'id':_0x592510['params']['id']}})['then'](handleEntityNotFound(_0x24d5c6,null))[_0x6079('0x23')](function(_0x2f5a40){if(_0x2f5a40){return _0x2f5a40['addAgents'](_0x592510['body'][_0x6079('0x5d')],_['omit'](_0x592510[_0x6079('0x50')],[_0x6079('0x5d'),'id'])||{})[_0x6079('0x9a')](function(_0x4a09d2){for(var _0x3aea5f=0x0;_0x3aea5f<_0x592510['body'][_0x6079('0x5d')][_0x6079('0x58')];_0x3aea5f+=0x1){socket[_0x6079('0x9b')](_0x6079('0x9c'),{'UserId':Number(_0x592510[_0x6079('0x50')][_0x6079('0x5d')][_0x3aea5f]),'CmListId':Number(_0x592510['params']['id'])});}return _0x4a09d2;});}})[_0x6079('0x23')](respondWithResult(_0x24d5c6,null))['catch'](handleError(_0x24d5c6,null));};exports['removeAgents']=function(_0x309852,_0x40c7ff,_0x19f8b7){return db[_0x6079('0x3f')]['find']({'where':{'id':_0x309852[_0x6079('0x41')]['id']}})[_0x6079('0x23')](handleEntityNotFound(_0x40c7ff,null))['then'](function(_0xa7ad3a){if(_0xa7ad3a){return _0xa7ad3a['removeAgents'](_0x309852[_0x6079('0x30')]['ids'])[_0x6079('0x23')](function(){if(_[_0x6079('0x60')](_0x309852['query'][_0x6079('0x5d')])){for(var _0x504980=0x0;_0x504980<_0x309852[_0x6079('0x30')][_0x6079('0x5d')][_0x6079('0x58')];_0x504980+=0x1){socket['emit']('userCmList:remove',{'UserId':Number(_0x309852[_0x6079('0x30')]['ids'][_0x504980]),'CmListId':Number(_0x309852[_0x6079('0x41')]['id'])});}}else{socket[_0x6079('0x9b')](_0x6079('0x9d'),{'UserId':Number(_0x309852['query'][_0x6079('0x5d')]),'CmListId':Number(_0x309852[_0x6079('0x41')]['id'])});}});}})[_0x6079('0x23')](respondWithStatusCode(_0x40c7ff,null))[_0x6079('0x43')](handleError(_0x40c7ff,null));};exports[_0x6079('0x9e')]=function(_0x12fce1,_0x413ac9,_0x56eeb4){var _0x5e121c={};var _0x366809={};var _0x58bd14;var _0x7652c9;return db[_0x6079('0x3f')][_0x6079('0x56')]({'where':{'id':_0x12fce1[_0x6079('0x41')]['id']}})['then'](handleEntityNotFound(_0x413ac9,null))[_0x6079('0x23')](function(_0x545ae6){if(_0x545ae6){_0x58bd14=_0x545ae6;_0x366809[_0x6079('0x2e')]=_[_0x6079('0x31')](db[_0x6079('0x9f')][_0x6079('0x57')]);_0x366809[_0x6079('0x30')]=_['keys'](_0x12fce1[_0x6079('0x30')]);_0x366809[_0x6079('0x32')]=_[_0x6079('0x33')](_0x366809[_0x6079('0x2e')],_0x366809[_0x6079('0x30')]);_0x5e121c[_0x6079('0x34')]=_[_0x6079('0x33')](_0x366809[_0x6079('0x2e')],qs[_0x6079('0x35')](_0x12fce1[_0x6079('0x30')][_0x6079('0x35')]));_0x5e121c['attributes']=_0x5e121c[_0x6079('0x34')]['length']?_0x5e121c[_0x6079('0x34')]:_0x366809['model'];_0x5e121c[_0x6079('0x37')]=qs['sort'](_0x12fce1[_0x6079('0x30')][_0x6079('0x38')]);_0x5e121c[_0x6079('0x39')]=qs[_0x6079('0x32')](_[_0x6079('0x5a')](_0x12fce1[_0x6079('0x30')],_0x366809[_0x6079('0x32')]));if(_0x12fce1[_0x6079('0x30')]['filter']){_0x5e121c[_0x6079('0x39')]=_[_0x6079('0x3b')](_0x5e121c['where'],{'$or':_[_0x6079('0x2f')](_0x5e121c[_0x6079('0x34')],function(_0xd80c7d){var _0x1aba94={};_0x1aba94[_0xd80c7d]={'$like':'%'+_0x12fce1['query'][_0x6079('0x3a')]+'%'};return _0x1aba94;})});}_0x5e121c=_[_0x6079('0x3b')]({},_0x5e121c,_0x12fce1[_0x6079('0x3c')]);return _0x58bd14[_0x6079('0x9e')](_0x5e121c);}})['then'](function(_0x505288){if(_0x505288){_0x7652c9=_0x505288[_0x6079('0x58')];if(!_0x12fce1['query'][_0x6079('0x59')]('nolimit')){_0x5e121c[_0x6079('0x1d')]=qs['limit'](_0x12fce1[_0x6079('0x30')][_0x6079('0x1d')]);_0x5e121c['offset']=qs['offset'](_0x12fce1[_0x6079('0x30')][_0x6079('0x1b')]);}return _0x58bd14['getAgents'](_0x5e121c);}})[_0x6079('0x23')](function(_0x4abe33){if(_0x4abe33){return _0x4abe33?{'count':_0x7652c9,'rows':_0x4abe33}:null;}})[_0x6079('0x23')](respondWithResult(_0x413ac9,null))[_0x6079('0x43')](handleError(_0x413ac9,null));};function handleQuery(_0x48f632){logger['info'](_0x48f632);return db['sequelize']['query'](_0x48f632)[_0x6079('0x9a')](function(_0xdac2c){csv_results[_0x6079('0x62')](_0xdac2c);})[_0x6079('0x43')](function(_0x3af5b0){logger['error'](_0x3af5b0['message']);});}
\ No newline at end of file