Built motion from commit 639a1a7f.|2.6.19
[motion2.git] / server / api / cmList / cmList.controller.js
index bc08e83..df9a663 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xf715=['setHeader','Content-disposition','attachment;\x20filename=','list_%d_%s.csv','Content-type','text/csv','download','addCustomField','sequelize','transaction','addCustomFields','Sequelize','TEXT','number','INTEGER','BOOLEAN','defaultValue','queryInterface','addColumn','cf_%s','getCustomFields','findAndCountAll','getGlobalCustomFields','addAgents','spread','emit','userCmList:save','removeAgents','userCmList:remove','getAgents','User','info','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','to-csv','ejs','squel','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/environment','../../config/license/util','../../mysqldb','defaults','redis','localhost','socket.io-emitter','./cmList.socket','register','sendStatus','end','json','offset','undefined','limit','count','set','Content-Range','apply','reject','save','update','then','destroy','get','Lists','status','error','stack','name','send','index','rawAttributes','fieldName','type','map','query','keys','filters','intersection','model','fields','attributes','hasOwnProperty','nolimit','sort','where','pick','filter','merge','options','CmList','includeAll','include','findAll','rows','catch','params','length','find','create','body','role','autoAssociation','UserProfileResource','describe','addDisposition','ListId','getDispositions','findOne','Disposition','order','removeDispositions','ids','addContacts','CmContact','tags','isArray','join','omit','push','errors','message','Malformed\x20request\x20syntax','getContacts','CmCustomField','CustomFields','concat','raw','ContactItemType','OrderBy','select','from','cm_contacts','c.ListId\x20=\x20?','c.deletedAt\x20is\x20null','distinct','field','customField_','alias','item','cm_contact_has_items','ItemTypeId\x20=\x20?','additionalPhone_','description_additionalPhone_','each','toString','isEmpty','writeFileSync','format','/tmp/list_%d_%s.csv'];(function(_0x38aece,_0x5a66e3){var _0x2e06e4=function(_0x4f9d09){while(--_0x4f9d09){_0x38aece['push'](_0x38aece['shift']());}};_0x2e06e4(++_0x5a66e3);}(_0xf715,0xc5));var _0x5f71=function(_0x5b410d,_0x2f8be5){_0x5b410d=_0x5b410d-0x0;var _0x5edf1a=_0xf715[_0x5b410d];return _0x5edf1a;};'use strict';var emlformat=require(_0x5f71('0x0'));var rimraf=require(_0x5f71('0x1'));var zipdir=require(_0x5f71('0x2'));var jsonpatch=require(_0x5f71('0x3'));var rp=require(_0x5f71('0x4'));var moment=require(_0x5f71('0x5'));var BPromise=require(_0x5f71('0x6'));var Mustache=require(_0x5f71('0x7'));var util=require(_0x5f71('0x8'));var path=require('path');var sox=require('sox');var csv=require(_0x5f71('0x9'));var ejs=require(_0x5f71('0xa'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require('lodash');var squel=require(_0x5f71('0xb'));var crypto=require('crypto');var jsforce=require(_0x5f71('0xc'));var deskjs=require(_0x5f71('0xd'));var toCsv=require(_0x5f71('0x9'));var querystring=require(_0x5f71('0xe'));var Papa=require(_0x5f71('0xf'));var Redis=require(_0x5f71('0x10'));var authService=require(_0x5f71('0x11'));var qs=require('../../components/parsers/qs');var as=require(_0x5f71('0x12'));var hardwareService=require(_0x5f71('0x13'));var logger=require(_0x5f71('0x14'))(_0x5f71('0x15'));var utils=require('../../config/utils');var config=require(_0x5f71('0x16'));var licenseUtil=require(_0x5f71('0x17'));var db=require(_0x5f71('0x18'))['db'];var csv_results;config['redis']=_[_0x5f71('0x19')](config[_0x5f71('0x1a')],{'host':_0x5f71('0x1b'),'port':0x18eb});var socket=require(_0x5f71('0x1c'))(new Redis(config[_0x5f71('0x1a')]));require(_0x5f71('0x1d'))[_0x5f71('0x1e')](socket);function respondWithStatusCode(_0x2b6923,_0x152bb4){_0x152bb4=_0x152bb4||0xcc;return function(_0x2167ca){if(_0x2167ca){return _0x2b6923[_0x5f71('0x1f')](_0x152bb4);}return _0x2b6923['status'](_0x152bb4)[_0x5f71('0x20')]();};}function respondWithResult(_0xcc8f0a,_0x564710){_0x564710=_0x564710||0xc8;return function(_0x2a244a){if(_0x2a244a){return _0xcc8f0a['status'](_0x564710)[_0x5f71('0x21')](_0x2a244a);}};}function respondWithFilteredResult(_0x42d30b,_0x318004){return function(_0x170949){if(_0x170949){var _0x3026f7=typeof _0x318004[_0x5f71('0x22')]===_0x5f71('0x23')&&typeof _0x318004[_0x5f71('0x24')]==='undefined';var _0x76ec93=_0x170949[_0x5f71('0x25')];var _0x4cd991=_0x3026f7?0x0:_0x318004[_0x5f71('0x22')];var _0x40ea4=_0x3026f7?_0x170949[_0x5f71('0x25')]:_0x318004[_0x5f71('0x22')]+_0x318004[_0x5f71('0x24')];var _0x3ee9d5;if(_0x40ea4>=_0x76ec93){_0x40ea4=_0x76ec93;_0x3ee9d5=0xc8;}else{_0x3ee9d5=0xce;}_0x42d30b['status'](_0x3ee9d5);return _0x42d30b[_0x5f71('0x26')](_0x5f71('0x27'),_0x4cd991+'-'+_0x40ea4+'/'+_0x76ec93)[_0x5f71('0x21')](_0x170949);}return null;};}function patchUpdates(_0xfd6b1c){return function(_0xd8b5ba){try{jsonpatch[_0x5f71('0x28')](_0xd8b5ba,_0xfd6b1c,!![]);}catch(_0x51612b){return BPromise[_0x5f71('0x29')](_0x51612b);}return _0xd8b5ba[_0x5f71('0x2a')]();};}function saveUpdates(_0xe8fcbc,_0x26f8fc){return function(_0x5d6875){if(_0x5d6875){return _0x5d6875[_0x5f71('0x2b')](_0xe8fcbc)[_0x5f71('0x2c')](function(_0xbc8926){return _0xbc8926;});}return null;};}function removeEntity(_0x22918e,_0x5bd54f){return function(_0x53d900){if(_0x53d900){return _0x53d900[_0x5f71('0x2d')]()[_0x5f71('0x2c')](function(){var _0x17f821=_0x53d900[_0x5f71('0x2e')]({'plain':!![]});var _0x10e354=_0x5f71('0x2f');return db['UserProfileResource'][_0x5f71('0x2d')]({'where':{'type':_0x10e354,'resourceId':_0x17f821['id']}})[_0x5f71('0x2c')](function(){return _0x53d900;});})[_0x5f71('0x2c')](function(){_0x22918e[_0x5f71('0x30')](0xcc)[_0x5f71('0x20')]();});}};}function handleEntityNotFound(_0x328b52,_0xdd4b15){return function(_0x50a66f){if(!_0x50a66f){_0x328b52[_0x5f71('0x1f')](0x194);}return _0x50a66f;};}function handleError(_0x2f85d9,_0x51019f){_0x51019f=_0x51019f||0x1f4;return function(_0x3f6151){logger[_0x5f71('0x31')](_0x3f6151[_0x5f71('0x32')]);if(_0x3f6151['name']){delete _0x3f6151[_0x5f71('0x33')];}_0x2f85d9[_0x5f71('0x30')](_0x51019f)[_0x5f71('0x34')](_0x3f6151);};}exports[_0x5f71('0x35')]=function(_0x41f26d,_0xf2a709){var _0x176ac5={},_0x302ec3={},_0x26df6a={'count':0x0,'rows':[]};var _0x5c5834=_['map'](db['CmList'][_0x5f71('0x36')],function(_0x2b3b11){return{'name':_0x2b3b11[_0x5f71('0x37')],'type':_0x2b3b11[_0x5f71('0x38')]['key']};});_0x302ec3['model']=_[_0x5f71('0x39')](_0x5c5834,'name');_0x302ec3[_0x5f71('0x3a')]=_[_0x5f71('0x3b')](_0x41f26d[_0x5f71('0x3a')]);_0x302ec3[_0x5f71('0x3c')]=_[_0x5f71('0x3d')](_0x302ec3[_0x5f71('0x3e')],_0x302ec3[_0x5f71('0x3a')]);_0x176ac5['attributes']=_[_0x5f71('0x3d')](_0x302ec3[_0x5f71('0x3e')],qs['fields'](_0x41f26d[_0x5f71('0x3a')][_0x5f71('0x3f')]));_0x176ac5[_0x5f71('0x40')]=_0x176ac5[_0x5f71('0x40')]['length']?_0x176ac5['attributes']:_0x302ec3[_0x5f71('0x3e')];if(!_0x41f26d[_0x5f71('0x3a')][_0x5f71('0x41')](_0x5f71('0x42'))){_0x176ac5[_0x5f71('0x24')]=qs[_0x5f71('0x24')](_0x41f26d[_0x5f71('0x3a')][_0x5f71('0x24')]);_0x176ac5[_0x5f71('0x22')]=qs['offset'](_0x41f26d[_0x5f71('0x3a')][_0x5f71('0x22')]);}_0x176ac5['order']=qs['sort'](_0x41f26d[_0x5f71('0x3a')][_0x5f71('0x43')]);_0x176ac5[_0x5f71('0x44')]=qs['filters'](_[_0x5f71('0x45')](_0x41f26d[_0x5f71('0x3a')],_0x302ec3['filters']),_0x5c5834);if(_0x41f26d[_0x5f71('0x3a')][_0x5f71('0x46')]){_0x176ac5[_0x5f71('0x44')]=_[_0x5f71('0x47')](_0x176ac5[_0x5f71('0x44')],{'$or':_[_0x5f71('0x39')](_0x5c5834,function(_0x38a25d){if(_0x38a25d[_0x5f71('0x38')]!=='VIRTUAL'){var _0x3d3e5={};_0x3d3e5[_0x38a25d[_0x5f71('0x33')]]={'$like':'%'+_0x41f26d[_0x5f71('0x3a')][_0x5f71('0x46')]+'%'};return _0x3d3e5;}})});}_0x176ac5=_[_0x5f71('0x47')]({},_0x176ac5,_0x41f26d[_0x5f71('0x48')]);var _0xe28d24={'where':_0x176ac5['where']};return db[_0x5f71('0x49')][_0x5f71('0x25')](_0xe28d24)['then'](function(_0x4a94bd){_0x26df6a[_0x5f71('0x25')]=_0x4a94bd;if(_0x41f26d[_0x5f71('0x3a')][_0x5f71('0x4a')]){_0x176ac5[_0x5f71('0x4b')]=[{'all':!![]}];}return db['CmList'][_0x5f71('0x4c')](_0x176ac5);})[_0x5f71('0x2c')](function(_0x14ef24){_0x26df6a[_0x5f71('0x4d')]=_0x14ef24;return _0x26df6a;})['then'](respondWithFilteredResult(_0xf2a709,_0x176ac5))[_0x5f71('0x4e')](handleError(_0xf2a709,null));};exports['show']=function(_0x5957c6,_0x18b3dc){var _0x5e930d={'raw':![],'where':{'id':_0x5957c6[_0x5f71('0x4f')]['id']}},_0x46b849={};_0x46b849[_0x5f71('0x3e')]=_['keys'](db[_0x5f71('0x49')][_0x5f71('0x36')]);_0x46b849[_0x5f71('0x3a')]=_['keys'](_0x5957c6[_0x5f71('0x3a')]);_0x46b849[_0x5f71('0x3c')]=_[_0x5f71('0x3d')](_0x46b849['model'],_0x46b849['query']);_0x5e930d[_0x5f71('0x40')]=_[_0x5f71('0x3d')](_0x46b849[_0x5f71('0x3e')],qs[_0x5f71('0x3f')](_0x5957c6['query']['fields']));_0x5e930d[_0x5f71('0x40')]=_0x5e930d[_0x5f71('0x40')][_0x5f71('0x50')]?_0x5e930d[_0x5f71('0x40')]:_0x46b849[_0x5f71('0x3e')];if(_0x5957c6['query'][_0x5f71('0x4a')]){_0x5e930d[_0x5f71('0x4b')]=[{'all':!![]}];}_0x5e930d=_['merge']({},_0x5e930d,_0x5957c6[_0x5f71('0x48')]);return db[_0x5f71('0x49')][_0x5f71('0x51')](_0x5e930d)[_0x5f71('0x2c')](handleEntityNotFound(_0x18b3dc,null))[_0x5f71('0x2c')](respondWithResult(_0x18b3dc,null))[_0x5f71('0x4e')](handleError(_0x18b3dc,null));};exports[_0x5f71('0x52')]=function(_0x44ea85,_0x28b48f){return db['CmList'][_0x5f71('0x52')](_0x44ea85[_0x5f71('0x53')],{})['then'](function(_0xa19060){var _0x48c837=_0x44ea85['user'][_0x5f71('0x2e')]({'plain':!![]});if(!_0x48c837)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x48c837[_0x5f71('0x54')]==='user'){var _0x5dd48c=_0xa19060['get']({'plain':!![]});var _0x4fceba='Lists';return db['UserProfileSection'][_0x5f71('0x51')]({'where':{'name':_0x4fceba,'userProfileId':_0x48c837['userProfileId']},'raw':!![]})[_0x5f71('0x2c')](function(_0x4a2bc3){if(_0x4a2bc3&&_0x4a2bc3[_0x5f71('0x55')]===0x0){return db[_0x5f71('0x56')][_0x5f71('0x52')]({'name':_0x5dd48c[_0x5f71('0x33')],'resourceId':_0x5dd48c['id'],'type':_0x4a2bc3[_0x5f71('0x33')],'sectionId':_0x4a2bc3['id']},{})['then'](function(){return _0xa19060;});}else{return _0xa19060;}})[_0x5f71('0x4e')](function(_0x45d528){logger[_0x5f71('0x31')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x45d528);throw _0x45d528;});}return _0xa19060;})['then'](respondWithResult(_0x28b48f,0xc9))[_0x5f71('0x4e')](handleError(_0x28b48f,null));};exports[_0x5f71('0x2b')]=function(_0x189df5,_0x4f6e4f){if(_0x189df5[_0x5f71('0x53')]['id']){delete _0x189df5[_0x5f71('0x53')]['id'];}return db[_0x5f71('0x49')][_0x5f71('0x51')]({'where':{'id':_0x189df5[_0x5f71('0x4f')]['id']}})[_0x5f71('0x2c')](handleEntityNotFound(_0x4f6e4f,null))[_0x5f71('0x2c')](saveUpdates(_0x189df5[_0x5f71('0x53')],null))[_0x5f71('0x2c')](respondWithResult(_0x4f6e4f,null))['catch'](handleError(_0x4f6e4f,null));};exports[_0x5f71('0x2d')]=function(_0x28d967,_0x478674){return db[_0x5f71('0x49')][_0x5f71('0x51')]({'where':{'id':_0x28d967['params']['id']}})[_0x5f71('0x2c')](handleEntityNotFound(_0x478674,null))[_0x5f71('0x2c')](removeEntity(_0x478674,null))['catch'](handleError(_0x478674,null));};exports[_0x5f71('0x57')]=function(_0x1a9c97,_0x28f28b){return db[_0x5f71('0x49')][_0x5f71('0x57')]()[_0x5f71('0x2c')](respondWithResult(_0x28f28b,null))[_0x5f71('0x4e')](handleError(_0x28f28b,null));};exports[_0x5f71('0x58')]=function(_0x505bb7,_0x5d481b,_0x356a15){if(_0x505bb7[_0x5f71('0x53')]['id']){delete _0x505bb7['body']['id'];}return db['CmList']['find']({'where':{'id':_0x505bb7['params']['id']}})['then'](handleEntityNotFound(_0x5d481b,null))[_0x5f71('0x2c')](function(_0x5e685e){if(_0x5e685e){_0x505bb7['body'][_0x5f71('0x59')]=_0x5e685e['id'];return db['Disposition'][_0x5f71('0x52')](_0x505bb7[_0x5f71('0x53')]);}})[_0x5f71('0x2c')](respondWithResult(_0x5d481b,null))[_0x5f71('0x4e')](handleError(_0x5d481b,null));};exports[_0x5f71('0x5a')]=function(_0x3ee2de,_0x185754,_0x3b09d7){var _0x57e462={'raw':![],'where':{}};var _0x4edf8a={};var _0x481aca={'count':0x0,'rows':[]};return db[_0x5f71('0x49')][_0x5f71('0x5b')]({'where':{'id':_0x3ee2de['params']['id']}})['then'](handleEntityNotFound(_0x185754,null))[_0x5f71('0x2c')](function(_0x1389c9){if(_0x1389c9){_0x4edf8a[_0x5f71('0x3e')]=_[_0x5f71('0x3b')](db[_0x5f71('0x5c')][_0x5f71('0x36')]);_0x4edf8a[_0x5f71('0x3a')]=_[_0x5f71('0x3b')](_0x3ee2de[_0x5f71('0x3a')]);_0x4edf8a[_0x5f71('0x3c')]=_[_0x5f71('0x3d')](_0x4edf8a[_0x5f71('0x3e')],_0x4edf8a['query']);_0x57e462[_0x5f71('0x40')]=_['intersection'](_0x4edf8a[_0x5f71('0x3e')],qs[_0x5f71('0x3f')](_0x3ee2de['query']['fields']));_0x57e462[_0x5f71('0x40')]=_0x57e462[_0x5f71('0x40')][_0x5f71('0x50')]?_0x57e462[_0x5f71('0x40')]:_0x4edf8a['model'];if(!_0x3ee2de[_0x5f71('0x3a')][_0x5f71('0x41')](_0x5f71('0x42'))){_0x57e462[_0x5f71('0x24')]=qs[_0x5f71('0x24')](_0x3ee2de['query'][_0x5f71('0x24')]);_0x57e462[_0x5f71('0x22')]=qs[_0x5f71('0x22')](_0x3ee2de[_0x5f71('0x3a')][_0x5f71('0x22')]);}_0x57e462[_0x5f71('0x5d')]=qs[_0x5f71('0x43')](_0x3ee2de[_0x5f71('0x3a')][_0x5f71('0x43')]);_0x57e462['where']=qs[_0x5f71('0x3c')](_[_0x5f71('0x45')](_0x3ee2de[_0x5f71('0x3a')],_0x4edf8a[_0x5f71('0x3c')]));_0x57e462['where'][_0x5f71('0x59')]=_0x1389c9['id'];if(_0x3ee2de[_0x5f71('0x3a')]['filter']){_0x57e462[_0x5f71('0x44')]=_[_0x5f71('0x47')](_0x57e462[_0x5f71('0x44')],{'$or':_[_0x5f71('0x39')](_0x57e462['attributes'],function(_0x54933f){var _0x3a1974={};_0x3a1974[_0x54933f]={'$like':'%'+_0x3ee2de[_0x5f71('0x3a')][_0x5f71('0x46')]+'%'};return _0x3a1974;})});}_0x57e462=_[_0x5f71('0x47')]({},_0x57e462,_0x3ee2de[_0x5f71('0x48')]);return db['Disposition'][_0x5f71('0x25')]({'where':_0x57e462[_0x5f71('0x44')]})[_0x5f71('0x2c')](function(_0x3bef6f){_0x481aca[_0x5f71('0x25')]=_0x3bef6f;if(_0x3ee2de['query']['includeAll']){_0x57e462[_0x5f71('0x4b')]=[{'all':!![]}];}return db['Disposition'][_0x5f71('0x4c')](_0x57e462);})['then'](function(_0x14fd59){_0x481aca[_0x5f71('0x4d')]=_0x14fd59;return _0x481aca;});}})[_0x5f71('0x2c')](respondWithFilteredResult(_0x185754,_0x57e462))['catch'](handleError(_0x185754,null));};exports[_0x5f71('0x5e')]=function(_0x34b5e7,_0x26e3d8,_0xf6ec95){return db['CmList'][_0x5f71('0x51')]({'where':{'id':_0x34b5e7[_0x5f71('0x4f')]['id']}})['then'](handleEntityNotFound(_0x26e3d8,null))[_0x5f71('0x2c')](function(_0x54c838){if(_0x54c838){return _0x54c838[_0x5f71('0x5e')](_0x34b5e7[_0x5f71('0x3a')][_0x5f71('0x5f')]);}})[_0x5f71('0x2c')](respondWithStatusCode(_0x26e3d8,null))[_0x5f71('0x4e')](handleError(_0x26e3d8,null));};exports[_0x5f71('0x60')]=function(_0x146b6f,_0x4b61f1,_0x14be25){return db[_0x5f71('0x49')]['find']({'where':{'id':_0x146b6f[_0x5f71('0x4f')]['id']}})[_0x5f71('0x2c')](handleEntityNotFound(_0x4b61f1,null))['then'](function(_0x191d92){if(_0x191d92){var _0x436199=[];var _0x253c38={'success':[],'errors':[]};return db[_0x5f71('0x61')][_0x5f71('0x57')]()[_0x5f71('0x2c')](function(_0x21f251){if(_0x146b6f[_0x5f71('0x53')][_0x5f71('0x62')]&&_[_0x5f71('0x63')](_0x146b6f[_0x5f71('0x53')][_0x5f71('0x62')])){if(_0x146b6f['body'][_0x5f71('0x62')][_0x5f71('0x50')]){_0x146b6f[_0x5f71('0x53')][_0x5f71('0x62')]=_0x146b6f['body']['tags'][_0x5f71('0x64')](';')+';';}else{_0x146b6f['body'][_0x5f71('0x62')]=null;}}else{_0x146b6f[_0x5f71('0x53')]['tags']=null;}if(_0x146b6f['body']&&_[_0x5f71('0x63')](_0x146b6f['body'])){for(var _0x2c2b08=0x0;_0x2c2b08<_0x146b6f[_0x5f71('0x53')]['length'];_0x2c2b08+=0x1){_0x146b6f[_0x5f71('0x53')][_0x2c2b08][_0x5f71('0x59')]=_0x146b6f[_0x5f71('0x4f')]['id'];_0x436199['push'](_0x146b6f[_0x5f71('0x53')][_0x2c2b08]);}return BPromise['each'](_0x436199,function(_0x569ccc){return db[_0x5f71('0x61')][_0x5f71('0x52')](_[_0x5f71('0x65')](_0x569ccc,['ids','id'])||{},{'fields':_[_0x5f71('0x3b')](_0x21f251),'raw':!![]})[_0x5f71('0x2c')](function(_0x3beb8e){_0x253c38['success'][_0x5f71('0x66')](_0x3beb8e['dataValues']);})['catch'](function(_0x3ad52f){_0x253c38[_0x5f71('0x67')][_0x5f71('0x66')]({'data':_0x569ccc,'error':_0x3ad52f[_0x5f71('0x68')]});});})[_0x5f71('0x2c')](function(_0x5aaebc){return _0x253c38;})[_0x5f71('0x4e')](function(_0x2d645c){return _0x2d645c;});}else{_0x4b61f1[_0x5f71('0x30')](0x190)[_0x5f71('0x21')]({'message':_0x5f71('0x69')});}});}})[_0x5f71('0x2c')](respondWithResult(_0x4b61f1,null))[_0x5f71('0x4e')](handleError(_0x4b61f1,null));};exports[_0x5f71('0x6a')]=function(_0x1c2acc,_0x32b024,_0x23ec9f){var _0x332a85;return db[_0x5f71('0x49')][_0x5f71('0x51')]({'where':{'id':_0x1c2acc[_0x5f71('0x4f')]['id']},'include':[{'model':db[_0x5f71('0x6b')],'as':_0x5f71('0x6c')}]})[_0x5f71('0x2c')](handleEntityNotFound(_0x32b024,null))[_0x5f71('0x2c')](function(_0xfd76af){if(_0xfd76af){_0x332a85=_0xfd76af;return db[_0x5f71('0x61')][_0x5f71('0x36')];}})[_0x5f71('0x2c')](function(_0x13d1c3){if(_0x13d1c3){var _0xadf9e8={};var _0x4190f0={};_0x4190f0[_0x5f71('0x3e')]=_[_0x5f71('0x6d')](_[_0x5f71('0x3b')](_0x13d1c3),_['map'](_0x332a85[_0x5f71('0x6c')],function(_0x56a466){return util['format']('cf_%d',_0x56a466['id']);}));_0x4190f0[_0x5f71('0x3a')]=_[_0x5f71('0x3b')](_0x1c2acc[_0x5f71('0x3a')]);_0x4190f0[_0x5f71('0x3c')]=_[_0x5f71('0x3d')](_0x4190f0[_0x5f71('0x3e')],_0x4190f0[_0x5f71('0x3a')]);_0xadf9e8[_0x5f71('0x40')]=_[_0x5f71('0x3d')](_0x4190f0[_0x5f71('0x3e')],qs['fields'](_0x1c2acc[_0x5f71('0x3a')][_0x5f71('0x3f')]));_0xadf9e8[_0x5f71('0x40')]=_0xadf9e8['attributes'][_0x5f71('0x50')]?_0xadf9e8[_0x5f71('0x40')]:_0x4190f0[_0x5f71('0x3e')];if(!_0x1c2acc[_0x5f71('0x3a')][_0x5f71('0x41')]('nolimit')){_0xadf9e8[_0x5f71('0x24')]=qs[_0x5f71('0x24')](_0x1c2acc[_0x5f71('0x3a')][_0x5f71('0x24')]);_0xadf9e8[_0x5f71('0x22')]=qs[_0x5f71('0x22')](_0x1c2acc[_0x5f71('0x3a')][_0x5f71('0x22')]);}_0xadf9e8[_0x5f71('0x5d')]=qs[_0x5f71('0x43')](_0x1c2acc[_0x5f71('0x3a')][_0x5f71('0x43')]);_0xadf9e8[_0x5f71('0x44')]=qs[_0x5f71('0x3c')](_[_0x5f71('0x45')](_0x1c2acc[_0x5f71('0x3a')],_0x4190f0[_0x5f71('0x3c')]));_0xadf9e8[_0x5f71('0x6e')]=!![];if(_0x1c2acc[_0x5f71('0x3a')][_0x5f71('0x46')]){_0xadf9e8[_0x5f71('0x44')]=_[_0x5f71('0x47')](_0xadf9e8['where'],{'$or':_['map'](_0xadf9e8[_0x5f71('0x40')],function(_0xf7bf1f){var _0x4f911c={};_0x4f911c[_0xf7bf1f]={'$like':'%'+_0x1c2acc[_0x5f71('0x3a')][_0x5f71('0x46')]+'%'};return _0x4f911c;})});}_0xadf9e8=_[_0x5f71('0x47')]({},_0xadf9e8,_0x1c2acc[_0x5f71('0x48')]);return _0x332a85[_0x5f71('0x6a')](_0xadf9e8);}})[_0x5f71('0x2c')](respondWithResult(_0x32b024,null))[_0x5f71('0x4e')](handleError(_0x32b024,null));};exports['getContactsCsv']=function(_0x52b6ff,_0x5f3f2e,_0x474259){var _0x2a0666;var _0x34cc7e;var _0x23b6ae;var _0x141d39=_0x52b6ff[_0x5f71('0x4f')]['id'];csv_results=[];return db[_0x5f71('0x6f')][_0x5f71('0x4c')]({'attributes':['id',_0x5f71('0x33')],'raw':!![],'order':[_0x5f71('0x70')]})['then'](function(_0x32ee38){_0x2a0666=_0x32ee38;var _0x39c59c=_[_0x5f71('0x3b')](db[_0x5f71('0x61')]['rawAttributes']);return db['CmCustomField'][_0x5f71('0x4c')]({'raw':!![],'attributes':['id','alias']})[_0x5f71('0x2c')](function(_0x119c42){_0x34cc7e=_0x119c42;var _0x212374=squel[_0x5f71('0x71')]()[_0x5f71('0x3f')](_0x39c59c)[_0x5f71('0x72')](_0x5f71('0x73'),'c')['where'](_0x5f71('0x74'),_0x141d39)[_0x5f71('0x44')](_0x5f71('0x75'))[_0x5f71('0x76')]();for(var _0x194bab=0x0;_0x194bab<_0x34cc7e[_0x5f71('0x50')];_0x194bab++){_0x212374[_0x5f71('0x77')]('c.cf_'+_0x34cc7e[_0x194bab]['id'],_0x5f71('0x78')+_0x34cc7e[_0x194bab][_0x5f71('0x79')]);}for(var _0x194bab=0x0;_0x194bab<_0x2a0666[_0x5f71('0x50')];_0x194bab++){_0x212374[_0x5f71('0x77')](squel[_0x5f71('0x71')]()[_0x5f71('0x77')](_0x5f71('0x7a'))[_0x5f71('0x72')](_0x5f71('0x7b'))['where'](_0x5f71('0x7c'),_0x2a0666[_0x194bab]['id'])[_0x5f71('0x44')]('CmContactId\x20=\x20c.id'),_0x5f71('0x7d')+_0x2a0666[_0x194bab][_0x5f71('0x33')]);_0x212374['field'](squel['select']()[_0x5f71('0x77')]('description')['from'](_0x5f71('0x7b'))[_0x5f71('0x44')](_0x5f71('0x7c'),_0x2a0666[_0x194bab]['id'])[_0x5f71('0x44')]('CmContactId\x20=\x20c.id'),_0x5f71('0x7e')+_0x2a0666[_0x194bab][_0x5f71('0x33')]);}var _0x2af28f=[];_0x2af28f[_0x5f71('0x66')](_0x212374['toString']());BPromise[_0x5f71('0x7f')](_0x2af28f,handleQuery)[_0x5f71('0x2c')](function(_0x23a413){handleQuery(_0x212374[_0x5f71('0x80')]());var _0x13ae39=csv_results[0x0];if(!_[_0x5f71('0x81')](_0x13ae39)){var _0x4a7c9e=toCsv(_0x13ae39);var _0x4d41b7=Date['now']();fs[_0x5f71('0x82')](util[_0x5f71('0x83')](_0x5f71('0x84'),_0x141d39,_0x4d41b7),_0x4a7c9e);_0x5f3f2e[_0x5f71('0x85')](_0x5f71('0x86'),_0x5f71('0x87')+util['format'](_0x5f71('0x88'),_0x141d39,_0x4d41b7));_0x5f3f2e['setHeader'](_0x5f71('0x89'),_0x5f71('0x8a'));return _0x5f3f2e[_0x5f71('0x8b')](util['format']('/tmp/list_%d_%s.csv',_0x141d39,_0x4d41b7));}else{return _0x5f3f2e['sendStatus'](0xcc);}});});});};exports[_0x5f71('0x8c')]=function(_0x187f54,_0x537482,_0x2d98b5){var _0x21db44;delete _0x187f54[_0x5f71('0x53')]['id'];return db[_0x5f71('0x49')][_0x5f71('0x5b')]({'where':{'id':_0x187f54['params']['id']}})[_0x5f71('0x2c')](handleEntityNotFound(_0x537482,null))[_0x5f71('0x2c')](function(_0x18a24b){if(_0x18a24b){return db[_0x5f71('0x8d')][_0x5f71('0x8e')](function(_0x5c6cf0){return db[_0x5f71('0x6b')][_0x5f71('0x52')](_0x187f54[_0x5f71('0x53')],{'transaction':_0x5c6cf0})[_0x5f71('0x2c')](function(_0x16a049){_0x21db44=_0x16a049;return _0x18a24b[_0x5f71('0x8f')](_0x16a049,{'transaction':_0x5c6cf0});})[_0x5f71('0x2c')](function(){var _0x57fd44={'type':db[_0x5f71('0x90')][_0x5f71('0x91')],'transaction':_0x5c6cf0};switch(_0x187f54[_0x5f71('0x53')][_0x5f71('0x38')]){case'text':_0x57fd44[_0x5f71('0x38')]=db[_0x5f71('0x90')]['TEXT'];break;case _0x5f71('0x92'):_0x57fd44[_0x5f71('0x38')]=db[_0x5f71('0x90')][_0x5f71('0x93')];break;case'switch':_0x57fd44[_0x5f71('0x38')]=db['Sequelize'][_0x5f71('0x94')];_0x57fd44[_0x5f71('0x95')]=![];break;default:}return db[_0x5f71('0x8d')][_0x5f71('0x96')][_0x5f71('0x97')](_0x5f71('0x73'),util[_0x5f71('0x83')](_0x5f71('0x98'),_0x21db44['id']),_0x57fd44);})['then'](function(){return _0x21db44;});});}})[_0x5f71('0x2c')](respondWithResult(_0x537482,null))[_0x5f71('0x4e')](handleError(_0x537482,null));};exports[_0x5f71('0x99')]=function(_0x15699e,_0x228aa1,_0x4fc53f){var _0x5ba3b2={};var _0x21a673={};var _0x18368d;var _0x5055d1;return db[_0x5f71('0x49')][_0x5f71('0x5b')]({'where':{'id':_0x15699e[_0x5f71('0x4f')]['id']}})['then'](handleEntityNotFound(_0x228aa1,null))['then'](function(_0x103414){if(_0x103414){_0x18368d=_0x103414;_0x21a673[_0x5f71('0x3e')]=_['keys'](db[_0x5f71('0x6b')]['rawAttributes']);_0x21a673['query']=_[_0x5f71('0x3b')](_0x15699e[_0x5f71('0x3a')]);_0x21a673[_0x5f71('0x3c')]=_[_0x5f71('0x3d')](_0x21a673[_0x5f71('0x3e')],_0x21a673[_0x5f71('0x3a')]);_0x5ba3b2['attributes']=_[_0x5f71('0x3d')](_0x21a673[_0x5f71('0x3e')],qs['fields'](_0x15699e[_0x5f71('0x3a')][_0x5f71('0x3f')]));_0x5ba3b2[_0x5f71('0x40')]=_0x5ba3b2[_0x5f71('0x40')]['length']?_0x5ba3b2[_0x5f71('0x40')]:_0x21a673[_0x5f71('0x3e')];_0x5ba3b2[_0x5f71('0x5d')]=qs[_0x5f71('0x43')](_0x15699e[_0x5f71('0x3a')][_0x5f71('0x43')]);_0x5ba3b2[_0x5f71('0x44')]=qs['filters'](_[_0x5f71('0x45')](_0x15699e[_0x5f71('0x3a')],_0x21a673[_0x5f71('0x3c')]));_0x5ba3b2[_0x5f71('0x44')]=_[_0x5f71('0x47')](_0x5ba3b2[_0x5f71('0x44')],{'$or':[{'ListId':_0x103414['id']},{'ListId':null}]});if(_0x15699e['query']['filter']){_0x5ba3b2[_0x5f71('0x44')]=_[_0x5f71('0x47')](_0x5ba3b2['where'],{'$or':_['map'](_0x5ba3b2[_0x5f71('0x40')],function(_0x23b011){var _0x425e57={};_0x425e57[_0x23b011]={'$like':'%'+_0x15699e[_0x5f71('0x3a')]['filter']+'%'};return _0x425e57;})});}_0x5ba3b2=_['merge']({},_0x5ba3b2,_0x15699e['options']);return db[_0x5f71('0x6b')][_0x5f71('0x9a')](_0x5ba3b2);}})[_0x5f71('0x2c')](respondWithResult(_0x228aa1,null))[_0x5f71('0x4e')](handleError(_0x228aa1,null));};exports[_0x5f71('0x9b')]=function(_0x10837,_0x56de01){return db[_0x5f71('0x6b')][_0x5f71('0x9a')]({'where':{'ListId':null}})['then'](handleEntityNotFound(_0x56de01,null))['then'](function(_0x295c5b){return _0x295c5b;})[_0x5f71('0x2c')](respondWithResult(_0x56de01,null))[_0x5f71('0x4e')](handleError(_0x56de01,null));};exports[_0x5f71('0x9c')]=function(_0x5db02b,_0x2f55f2,_0x2f944f){return db[_0x5f71('0x49')][_0x5f71('0x51')]({'where':{'id':_0x5db02b['params']['id']}})['then'](handleEntityNotFound(_0x2f55f2,null))['then'](function(_0x1f5d0e){if(_0x1f5d0e){return _0x1f5d0e[_0x5f71('0x9c')](_0x5db02b[_0x5f71('0x53')][_0x5f71('0x5f')],_[_0x5f71('0x65')](_0x5db02b[_0x5f71('0x53')],[_0x5f71('0x5f'),'id'])||{})[_0x5f71('0x9d')](function(_0x3e40a7){for(var _0x68f2a=0x0;_0x68f2a<_0x5db02b[_0x5f71('0x53')][_0x5f71('0x5f')][_0x5f71('0x50')];_0x68f2a+=0x1){socket[_0x5f71('0x9e')](_0x5f71('0x9f'),{'UserId':Number(_0x5db02b['body'][_0x5f71('0x5f')][_0x68f2a]),'CmListId':Number(_0x5db02b[_0x5f71('0x4f')]['id'])});}return _0x3e40a7;});}})[_0x5f71('0x2c')](respondWithResult(_0x2f55f2,null))[_0x5f71('0x4e')](handleError(_0x2f55f2,null));};exports[_0x5f71('0xa0')]=function(_0x3f1a2e,_0x13000d,_0x274da9){return db[_0x5f71('0x49')][_0x5f71('0x51')]({'where':{'id':_0x3f1a2e[_0x5f71('0x4f')]['id']}})[_0x5f71('0x2c')](handleEntityNotFound(_0x13000d,null))[_0x5f71('0x2c')](function(_0x3cfecc){if(_0x3cfecc){return _0x3cfecc['removeAgents'](_0x3f1a2e[_0x5f71('0x3a')][_0x5f71('0x5f')])[_0x5f71('0x2c')](function(){if(_[_0x5f71('0x63')](_0x3f1a2e['query'][_0x5f71('0x5f')])){for(var _0x1a99e5=0x0;_0x1a99e5<_0x3f1a2e[_0x5f71('0x3a')]['ids'][_0x5f71('0x50')];_0x1a99e5+=0x1){socket[_0x5f71('0x9e')]('userCmList:remove',{'UserId':Number(_0x3f1a2e[_0x5f71('0x3a')][_0x5f71('0x5f')][_0x1a99e5]),'CmListId':Number(_0x3f1a2e['params']['id'])});}}else{socket[_0x5f71('0x9e')](_0x5f71('0xa1'),{'UserId':Number(_0x3f1a2e[_0x5f71('0x3a')]['ids']),'CmListId':Number(_0x3f1a2e[_0x5f71('0x4f')]['id'])});}});}})['then'](respondWithStatusCode(_0x13000d,null))['catch'](handleError(_0x13000d,null));};exports[_0x5f71('0xa2')]=function(_0x153810,_0x2b3e5,_0x10c96c){var _0x50e6fa={};var _0x518fad={};var _0xb1e082;var _0x4b0539;return db[_0x5f71('0x49')][_0x5f71('0x5b')]({'where':{'id':_0x153810[_0x5f71('0x4f')]['id']}})['then'](handleEntityNotFound(_0x2b3e5,null))[_0x5f71('0x2c')](function(_0xf2fbe5){if(_0xf2fbe5){_0xb1e082=_0xf2fbe5;_0x518fad[_0x5f71('0x3e')]=_[_0x5f71('0x3b')](db[_0x5f71('0xa3')][_0x5f71('0x36')]);_0x518fad[_0x5f71('0x3a')]=_['keys'](_0x153810[_0x5f71('0x3a')]);_0x518fad[_0x5f71('0x3c')]=_[_0x5f71('0x3d')](_0x518fad[_0x5f71('0x3e')],_0x518fad['query']);_0x50e6fa[_0x5f71('0x40')]=_[_0x5f71('0x3d')](_0x518fad[_0x5f71('0x3e')],qs[_0x5f71('0x3f')](_0x153810['query']['fields']));_0x50e6fa[_0x5f71('0x40')]=_0x50e6fa[_0x5f71('0x40')][_0x5f71('0x50')]?_0x50e6fa[_0x5f71('0x40')]:_0x518fad['model'];_0x50e6fa[_0x5f71('0x5d')]=qs[_0x5f71('0x43')](_0x153810[_0x5f71('0x3a')][_0x5f71('0x43')]);_0x50e6fa[_0x5f71('0x44')]=qs['filters'](_[_0x5f71('0x45')](_0x153810[_0x5f71('0x3a')],_0x518fad[_0x5f71('0x3c')]));if(_0x153810[_0x5f71('0x3a')]['filter']){_0x50e6fa[_0x5f71('0x44')]=_[_0x5f71('0x47')](_0x50e6fa[_0x5f71('0x44')],{'$or':_[_0x5f71('0x39')](_0x50e6fa[_0x5f71('0x40')],function(_0x1de84d){var _0x113843={};_0x113843[_0x1de84d]={'$like':'%'+_0x153810['query']['filter']+'%'};return _0x113843;})});}_0x50e6fa=_[_0x5f71('0x47')]({},_0x50e6fa,_0x153810[_0x5f71('0x48')]);return _0xb1e082[_0x5f71('0xa2')](_0x50e6fa);}})[_0x5f71('0x2c')](function(_0x5133fa){if(_0x5133fa){_0x4b0539=_0x5133fa[_0x5f71('0x50')];if(!_0x153810[_0x5f71('0x3a')][_0x5f71('0x41')](_0x5f71('0x42'))){_0x50e6fa['limit']=qs['limit'](_0x153810[_0x5f71('0x3a')][_0x5f71('0x24')]);_0x50e6fa[_0x5f71('0x22')]=qs['offset'](_0x153810[_0x5f71('0x3a')]['offset']);}return _0xb1e082[_0x5f71('0xa2')](_0x50e6fa);}})[_0x5f71('0x2c')](function(_0x78515f){if(_0x78515f){return _0x78515f?{'count':_0x4b0539,'rows':_0x78515f}:null;}})[_0x5f71('0x2c')](respondWithResult(_0x2b3e5,null))[_0x5f71('0x4e')](handleError(_0x2b3e5,null));};function handleQuery(_0x4d0c73){logger[_0x5f71('0xa4')](_0x4d0c73);return db[_0x5f71('0x8d')][_0x5f71('0x3a')](_0x4d0c73)[_0x5f71('0x9d')](function(_0x664c8e){csv_results[_0x5f71('0x66')](_0x664c8e);})[_0x5f71('0x4e')](function(_0x76362a){logger[_0x5f71('0x31')](_0x76362a[_0x5f71('0x68')]);});}
\ No newline at end of file
+var _0x0d73=['isArray','join','push','each','success','dataValues','errors','message','Malformed\x20request\x20syntax','getContacts','CustomFields','concat','format','cf_%d','pick','getContactsCsv','ContactItemType','OrderBy','CmCustomField','cm_contacts','c.ListId\x20=\x20?','distinct','c.cf_','customField_','alias','item','from','cm_contact_has_items','CmContactId\x20=\x20c.id','additionalPhone_','field','description','ItemTypeId\x20=\x20?','description_additionalPhone_','toString','isEmpty','now','writeFileSync','/tmp/list_%d_%s.csv','Content-disposition','attachment;\x20filename=','list_%d_%s.csv','Content-type','text/csv','download','addCustomField','sequelize','addCustomFields','Sequelize','text','TEXT','number','INTEGER','switch','BOOLEAN','defaultValue','queryInterface','addColumn','cf_%s','findAndCountAll','getGlobalCustomFields','addAgents','omit','spread','emit','removeAgents','userCmList:remove','getAgents','info','eml-format','zip-dir','fast-json-patch','request-promise','moment','mustache','util','sox','to-csv','squel','crypto','jsforce','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/license/util','../../mysqldb','defaults','redis','localhost','socket.io-emitter','register','sendStatus','json','undefined','count','offset','limit','status','set','apply','reject','save','update','destroy','then','get','Lists','UserProfileResource','end','error','stack','name','index','map','rawAttributes','fieldName','type','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','filter','merge','VIRTUAL','options','CmList','includeAll','include','findAll','rows','catch','show','find','create','body','Unable\x20to\x20retrieve\x20the\x20current\x20user','user','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','params','describe','ListId','Disposition','getDispositions','findOne','removeDispositions','ids','addContacts','CmContact','tags'];(function(_0x283b8a,_0x2f4510){var _0x377e36=function(_0x2365d6){while(--_0x2365d6){_0x283b8a['push'](_0x283b8a['shift']());}};_0x377e36(++_0x2f4510);}(_0x0d73,0xe9));var _0x30d7=function(_0x4118d4,_0x4b208d){_0x4118d4=_0x4118d4-0x0;var _0x456fc1=_0x0d73[_0x4118d4];return _0x456fc1;};'use strict';var emlformat=require(_0x30d7('0x0'));var rimraf=require('rimraf');var zipdir=require(_0x30d7('0x1'));var jsonpatch=require(_0x30d7('0x2'));var rp=require(_0x30d7('0x3'));var moment=require(_0x30d7('0x4'));var BPromise=require('bluebird');var Mustache=require(_0x30d7('0x5'));var util=require(_0x30d7('0x6'));var path=require('path');var sox=require(_0x30d7('0x7'));var csv=require(_0x30d7('0x8'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require('fs-extra');var _=require('lodash');var squel=require(_0x30d7('0x9'));var crypto=require(_0x30d7('0xa'));var jsforce=require(_0x30d7('0xb'));var deskjs=require('desk.js');var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require('papaparse');var Redis=require('ioredis');var authService=require(_0x30d7('0xc'));var qs=require(_0x30d7('0xd'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x30d7('0xe'));var logger=require(_0x30d7('0xf'))(_0x30d7('0x10'));var utils=require(_0x30d7('0x11'));var config=require('../../config/environment');var licenseUtil=require(_0x30d7('0x12'));var db=require(_0x30d7('0x13'))['db'];var csv_results;config['redis']=_[_0x30d7('0x14')](config[_0x30d7('0x15')],{'host':_0x30d7('0x16'),'port':0x18eb});var socket=require(_0x30d7('0x17'))(new Redis(config[_0x30d7('0x15')]));require('./cmList.socket')[_0x30d7('0x18')](socket);function respondWithStatusCode(_0x4c2e0d,_0xeccc2f){_0xeccc2f=_0xeccc2f||0xcc;return function(_0x3b43f1){if(_0x3b43f1){return _0x4c2e0d[_0x30d7('0x19')](_0xeccc2f);}return _0x4c2e0d['status'](_0xeccc2f)['end']();};}function respondWithResult(_0x5420a2,_0x507da9){_0x507da9=_0x507da9||0xc8;return function(_0x38ee5e){if(_0x38ee5e){return _0x5420a2['status'](_0x507da9)[_0x30d7('0x1a')](_0x38ee5e);}};}function respondWithFilteredResult(_0x2eec76,_0x242aea){return function(_0x54fb93){if(_0x54fb93){var _0x30fd1c=typeof _0x242aea['offset']===_0x30d7('0x1b')&&typeof _0x242aea['limit']==='undefined';var _0xbabe3a=_0x54fb93[_0x30d7('0x1c')];var _0x516756=_0x30fd1c?0x0:_0x242aea[_0x30d7('0x1d')];var _0x1998db=_0x30fd1c?_0x54fb93[_0x30d7('0x1c')]:_0x242aea['offset']+_0x242aea[_0x30d7('0x1e')];var _0x316026;if(_0x1998db>=_0xbabe3a){_0x1998db=_0xbabe3a;_0x316026=0xc8;}else{_0x316026=0xce;}_0x2eec76[_0x30d7('0x1f')](_0x316026);return _0x2eec76[_0x30d7('0x20')]('Content-Range',_0x516756+'-'+_0x1998db+'/'+_0xbabe3a)['json'](_0x54fb93);}return null;};}function patchUpdates(_0x198703){return function(_0x53f96d){try{jsonpatch[_0x30d7('0x21')](_0x53f96d,_0x198703,!![]);}catch(_0x55311c){return BPromise[_0x30d7('0x22')](_0x55311c);}return _0x53f96d[_0x30d7('0x23')]();};}function saveUpdates(_0x1bf87d,_0x116dd7){return function(_0x2b379b){if(_0x2b379b){return _0x2b379b[_0x30d7('0x24')](_0x1bf87d)['then'](function(_0x5db687){return _0x5db687;});}return null;};}function removeEntity(_0x120e6a,_0x520b16){return function(_0x8956f5){if(_0x8956f5){return _0x8956f5[_0x30d7('0x25')]()[_0x30d7('0x26')](function(){var _0x22e1b8=_0x8956f5[_0x30d7('0x27')]({'plain':!![]});var _0x365d2e=_0x30d7('0x28');return db[_0x30d7('0x29')][_0x30d7('0x25')]({'where':{'type':_0x365d2e,'resourceId':_0x22e1b8['id']}})[_0x30d7('0x26')](function(){return _0x8956f5;});})[_0x30d7('0x26')](function(){_0x120e6a[_0x30d7('0x1f')](0xcc)[_0x30d7('0x2a')]();});}};}function handleEntityNotFound(_0x33e4fa,_0x2d9900){return function(_0x1d5a71){if(!_0x1d5a71){_0x33e4fa[_0x30d7('0x19')](0x194);}return _0x1d5a71;};}function handleError(_0x3a32b2,_0x10e7f6){_0x10e7f6=_0x10e7f6||0x1f4;return function(_0x51e213){logger[_0x30d7('0x2b')](_0x51e213[_0x30d7('0x2c')]);if(_0x51e213['name']){delete _0x51e213[_0x30d7('0x2d')];}_0x3a32b2[_0x30d7('0x1f')](_0x10e7f6)['send'](_0x51e213);};}exports[_0x30d7('0x2e')]=function(_0x347876,_0x4ce189){var _0x549d7a={},_0x2d8b35={},_0x3b7dd6={'count':0x0,'rows':[]};var _0x2880e7=_[_0x30d7('0x2f')](db['CmList'][_0x30d7('0x30')],function(_0x3941b2){return{'name':_0x3941b2[_0x30d7('0x31')],'type':_0x3941b2[_0x30d7('0x32')][_0x30d7('0x33')]};});_0x2d8b35[_0x30d7('0x34')]=_[_0x30d7('0x2f')](_0x2880e7,_0x30d7('0x2d'));_0x2d8b35[_0x30d7('0x35')]=_[_0x30d7('0x36')](_0x347876[_0x30d7('0x35')]);_0x2d8b35[_0x30d7('0x37')]=_[_0x30d7('0x38')](_0x2d8b35['model'],_0x2d8b35[_0x30d7('0x35')]);_0x549d7a[_0x30d7('0x39')]=_[_0x30d7('0x38')](_0x2d8b35['model'],qs[_0x30d7('0x3a')](_0x347876[_0x30d7('0x35')][_0x30d7('0x3a')]));_0x549d7a[_0x30d7('0x39')]=_0x549d7a[_0x30d7('0x39')][_0x30d7('0x3b')]?_0x549d7a[_0x30d7('0x39')]:_0x2d8b35[_0x30d7('0x34')];if(!_0x347876['query'][_0x30d7('0x3c')](_0x30d7('0x3d'))){_0x549d7a[_0x30d7('0x1e')]=qs[_0x30d7('0x1e')](_0x347876[_0x30d7('0x35')][_0x30d7('0x1e')]);_0x549d7a['offset']=qs['offset'](_0x347876['query'][_0x30d7('0x1d')]);}_0x549d7a[_0x30d7('0x3e')]=qs[_0x30d7('0x3f')](_0x347876[_0x30d7('0x35')][_0x30d7('0x3f')]);_0x549d7a[_0x30d7('0x40')]=qs[_0x30d7('0x37')](_['pick'](_0x347876[_0x30d7('0x35')],_0x2d8b35[_0x30d7('0x37')]),_0x2880e7);if(_0x347876['query'][_0x30d7('0x41')]){_0x549d7a[_0x30d7('0x40')]=_[_0x30d7('0x42')](_0x549d7a[_0x30d7('0x40')],{'$or':_[_0x30d7('0x2f')](_0x2880e7,function(_0x5d9c8c){if(_0x5d9c8c[_0x30d7('0x32')]!==_0x30d7('0x43')){var _0x385f6a={};_0x385f6a[_0x5d9c8c[_0x30d7('0x2d')]]={'$like':'%'+_0x347876[_0x30d7('0x35')][_0x30d7('0x41')]+'%'};return _0x385f6a;}})});}_0x549d7a=_['merge']({},_0x549d7a,_0x347876[_0x30d7('0x44')]);var _0x553e53={'where':_0x549d7a[_0x30d7('0x40')]};return db[_0x30d7('0x45')][_0x30d7('0x1c')](_0x553e53)[_0x30d7('0x26')](function(_0x3190c7){_0x3b7dd6[_0x30d7('0x1c')]=_0x3190c7;if(_0x347876[_0x30d7('0x35')][_0x30d7('0x46')]){_0x549d7a[_0x30d7('0x47')]=[{'all':!![]}];}return db['CmList'][_0x30d7('0x48')](_0x549d7a);})[_0x30d7('0x26')](function(_0x5187b4){_0x3b7dd6[_0x30d7('0x49')]=_0x5187b4;return _0x3b7dd6;})[_0x30d7('0x26')](respondWithFilteredResult(_0x4ce189,_0x549d7a))[_0x30d7('0x4a')](handleError(_0x4ce189,null));};exports[_0x30d7('0x4b')]=function(_0x9ce092,_0x10ae70){var _0x281015={'raw':![],'where':{'id':_0x9ce092['params']['id']}},_0x117033={};_0x117033[_0x30d7('0x34')]=_['keys'](db['CmList'][_0x30d7('0x30')]);_0x117033[_0x30d7('0x35')]=_[_0x30d7('0x36')](_0x9ce092[_0x30d7('0x35')]);_0x117033[_0x30d7('0x37')]=_[_0x30d7('0x38')](_0x117033['model'],_0x117033[_0x30d7('0x35')]);_0x281015['attributes']=_['intersection'](_0x117033[_0x30d7('0x34')],qs[_0x30d7('0x3a')](_0x9ce092[_0x30d7('0x35')][_0x30d7('0x3a')]));_0x281015[_0x30d7('0x39')]=_0x281015[_0x30d7('0x39')]['length']?_0x281015['attributes']:_0x117033[_0x30d7('0x34')];if(_0x9ce092['query'][_0x30d7('0x46')]){_0x281015['include']=[{'all':!![]}];}_0x281015=_['merge']({},_0x281015,_0x9ce092[_0x30d7('0x44')]);return db[_0x30d7('0x45')][_0x30d7('0x4c')](_0x281015)[_0x30d7('0x26')](handleEntityNotFound(_0x10ae70,null))[_0x30d7('0x26')](respondWithResult(_0x10ae70,null))[_0x30d7('0x4a')](handleError(_0x10ae70,null));};exports[_0x30d7('0x4d')]=function(_0x495602,_0x1dc661){return db[_0x30d7('0x45')][_0x30d7('0x4d')](_0x495602[_0x30d7('0x4e')],{})['then'](function(_0x176a1c){var _0x49a0e6=_0x495602['user'][_0x30d7('0x27')]({'plain':!![]});if(!_0x49a0e6)throw new Error(_0x30d7('0x4f'));if(_0x49a0e6['role']===_0x30d7('0x50')){var _0x1181c0=_0x176a1c['get']({'plain':!![]});var _0x5cc52e=_0x30d7('0x28');return db['UserProfileSection'][_0x30d7('0x4c')]({'where':{'name':_0x5cc52e,'userProfileId':_0x49a0e6[_0x30d7('0x51')]},'raw':!![]})[_0x30d7('0x26')](function(_0x4b1fb5){if(_0x4b1fb5&&_0x4b1fb5[_0x30d7('0x52')]===0x0){return db['UserProfileResource'][_0x30d7('0x4d')]({'name':_0x1181c0[_0x30d7('0x2d')],'resourceId':_0x1181c0['id'],'type':_0x4b1fb5[_0x30d7('0x2d')],'sectionId':_0x4b1fb5['id']},{})['then'](function(){return _0x176a1c;});}else{return _0x176a1c;}})[_0x30d7('0x4a')](function(_0x24da16){logger[_0x30d7('0x2b')](_0x30d7('0x53'),_0x24da16);throw _0x24da16;});}return _0x176a1c;})['then'](respondWithResult(_0x1dc661,0xc9))[_0x30d7('0x4a')](handleError(_0x1dc661,null));};exports['update']=function(_0x52f097,_0x52b2f2){if(_0x52f097[_0x30d7('0x4e')]['id']){delete _0x52f097[_0x30d7('0x4e')]['id'];}return db[_0x30d7('0x45')][_0x30d7('0x4c')]({'where':{'id':_0x52f097[_0x30d7('0x54')]['id']}})[_0x30d7('0x26')](handleEntityNotFound(_0x52b2f2,null))[_0x30d7('0x26')](saveUpdates(_0x52f097[_0x30d7('0x4e')],null))[_0x30d7('0x26')](respondWithResult(_0x52b2f2,null))[_0x30d7('0x4a')](handleError(_0x52b2f2,null));};exports[_0x30d7('0x25')]=function(_0x39272e,_0x4b490b){return db['CmList'][_0x30d7('0x4c')]({'where':{'id':_0x39272e['params']['id']}})[_0x30d7('0x26')](handleEntityNotFound(_0x4b490b,null))[_0x30d7('0x26')](removeEntity(_0x4b490b,null))[_0x30d7('0x4a')](handleError(_0x4b490b,null));};exports['describe']=function(_0x3150b3,_0x28f3ff){return db[_0x30d7('0x45')][_0x30d7('0x55')]()[_0x30d7('0x26')](respondWithResult(_0x28f3ff,null))['catch'](handleError(_0x28f3ff,null));};exports['addDisposition']=function(_0x120df1,_0x270b02,_0x375665){if(_0x120df1['body']['id']){delete _0x120df1[_0x30d7('0x4e')]['id'];}return db[_0x30d7('0x45')]['find']({'where':{'id':_0x120df1['params']['id']}})[_0x30d7('0x26')](handleEntityNotFound(_0x270b02,null))[_0x30d7('0x26')](function(_0x223cf8){if(_0x223cf8){_0x120df1[_0x30d7('0x4e')][_0x30d7('0x56')]=_0x223cf8['id'];return db[_0x30d7('0x57')][_0x30d7('0x4d')](_0x120df1[_0x30d7('0x4e')]);}})['then'](respondWithResult(_0x270b02,null))[_0x30d7('0x4a')](handleError(_0x270b02,null));};exports[_0x30d7('0x58')]=function(_0x3383da,_0x374fa3,_0x26804d){var _0xb3406f={'raw':![],'where':{}};var _0x49c624={};var _0x549c46={'count':0x0,'rows':[]};return db[_0x30d7('0x45')][_0x30d7('0x59')]({'where':{'id':_0x3383da[_0x30d7('0x54')]['id']}})[_0x30d7('0x26')](handleEntityNotFound(_0x374fa3,null))[_0x30d7('0x26')](function(_0x29148c){if(_0x29148c){_0x49c624['model']=_[_0x30d7('0x36')](db[_0x30d7('0x57')][_0x30d7('0x30')]);_0x49c624[_0x30d7('0x35')]=_[_0x30d7('0x36')](_0x3383da['query']);_0x49c624[_0x30d7('0x37')]=_[_0x30d7('0x38')](_0x49c624[_0x30d7('0x34')],_0x49c624[_0x30d7('0x35')]);_0xb3406f[_0x30d7('0x39')]=_[_0x30d7('0x38')](_0x49c624['model'],qs[_0x30d7('0x3a')](_0x3383da['query']['fields']));_0xb3406f[_0x30d7('0x39')]=_0xb3406f['attributes'][_0x30d7('0x3b')]?_0xb3406f[_0x30d7('0x39')]:_0x49c624['model'];if(!_0x3383da[_0x30d7('0x35')][_0x30d7('0x3c')](_0x30d7('0x3d'))){_0xb3406f['limit']=qs['limit'](_0x3383da[_0x30d7('0x35')][_0x30d7('0x1e')]);_0xb3406f['offset']=qs[_0x30d7('0x1d')](_0x3383da[_0x30d7('0x35')]['offset']);}_0xb3406f[_0x30d7('0x3e')]=qs[_0x30d7('0x3f')](_0x3383da[_0x30d7('0x35')][_0x30d7('0x3f')]);_0xb3406f['where']=qs[_0x30d7('0x37')](_['pick'](_0x3383da[_0x30d7('0x35')],_0x49c624['filters']));_0xb3406f[_0x30d7('0x40')][_0x30d7('0x56')]=_0x29148c['id'];if(_0x3383da['query'][_0x30d7('0x41')]){_0xb3406f['where']=_[_0x30d7('0x42')](_0xb3406f['where'],{'$or':_[_0x30d7('0x2f')](_0xb3406f[_0x30d7('0x39')],function(_0x1420df){var _0x5e0e2a={};_0x5e0e2a[_0x1420df]={'$like':'%'+_0x3383da[_0x30d7('0x35')][_0x30d7('0x41')]+'%'};return _0x5e0e2a;})});}_0xb3406f=_[_0x30d7('0x42')]({},_0xb3406f,_0x3383da[_0x30d7('0x44')]);return db[_0x30d7('0x57')][_0x30d7('0x1c')]({'where':_0xb3406f[_0x30d7('0x40')]})[_0x30d7('0x26')](function(_0x142016){_0x549c46[_0x30d7('0x1c')]=_0x142016;if(_0x3383da[_0x30d7('0x35')][_0x30d7('0x46')]){_0xb3406f[_0x30d7('0x47')]=[{'all':!![]}];}return db[_0x30d7('0x57')]['findAll'](_0xb3406f);})[_0x30d7('0x26')](function(_0x44bfb1){_0x549c46[_0x30d7('0x49')]=_0x44bfb1;return _0x549c46;});}})[_0x30d7('0x26')](respondWithFilteredResult(_0x374fa3,_0xb3406f))['catch'](handleError(_0x374fa3,null));};exports[_0x30d7('0x5a')]=function(_0x12ca8c,_0x329fb6,_0x43a6e4){return db['CmList'][_0x30d7('0x4c')]({'where':{'id':_0x12ca8c[_0x30d7('0x54')]['id']}})['then'](handleEntityNotFound(_0x329fb6,null))['then'](function(_0x534764){if(_0x534764){return _0x534764[_0x30d7('0x5a')](_0x12ca8c[_0x30d7('0x35')][_0x30d7('0x5b')]);}})[_0x30d7('0x26')](respondWithStatusCode(_0x329fb6,null))[_0x30d7('0x4a')](handleError(_0x329fb6,null));};exports[_0x30d7('0x5c')]=function(_0x15c187,_0x22cc98,_0x330a86){return db[_0x30d7('0x45')][_0x30d7('0x4c')]({'where':{'id':_0x15c187[_0x30d7('0x54')]['id']}})[_0x30d7('0x26')](handleEntityNotFound(_0x22cc98,null))['then'](function(_0x56e708){if(_0x56e708){var _0x1c2b2f=[];var _0x397ebe={'success':[],'errors':[]};return db[_0x30d7('0x5d')]['describe']()[_0x30d7('0x26')](function(_0x517e65){if(_0x15c187['body'][_0x30d7('0x5e')]&&_[_0x30d7('0x5f')](_0x15c187[_0x30d7('0x4e')][_0x30d7('0x5e')])){if(_0x15c187[_0x30d7('0x4e')][_0x30d7('0x5e')][_0x30d7('0x3b')]){_0x15c187[_0x30d7('0x4e')][_0x30d7('0x5e')]=_0x15c187['body'][_0x30d7('0x5e')][_0x30d7('0x60')](';')+';';}else{_0x15c187[_0x30d7('0x4e')][_0x30d7('0x5e')]=null;}}else{_0x15c187[_0x30d7('0x4e')][_0x30d7('0x5e')]=null;}if(_0x15c187['body']&&_[_0x30d7('0x5f')](_0x15c187[_0x30d7('0x4e')])){for(var _0x2c4bf8=0x0;_0x2c4bf8<_0x15c187[_0x30d7('0x4e')][_0x30d7('0x3b')];_0x2c4bf8+=0x1){_0x15c187[_0x30d7('0x4e')][_0x2c4bf8]['ListId']=_0x15c187[_0x30d7('0x54')]['id'];_0x1c2b2f[_0x30d7('0x61')](_0x15c187[_0x30d7('0x4e')][_0x2c4bf8]);}return BPromise[_0x30d7('0x62')](_0x1c2b2f,function(_0x42f72a){return db['CmContact']['create'](_['omit'](_0x42f72a,[_0x30d7('0x5b'),'id'])||{},{'fields':_['keys'](_0x517e65),'raw':!![]})['then'](function(_0x1ef3f0){_0x397ebe[_0x30d7('0x63')]['push'](_0x1ef3f0[_0x30d7('0x64')]);})[_0x30d7('0x4a')](function(_0x4c4afc){_0x397ebe[_0x30d7('0x65')][_0x30d7('0x61')]({'data':_0x42f72a,'error':_0x4c4afc[_0x30d7('0x66')]});});})[_0x30d7('0x26')](function(_0x4d6738){return _0x397ebe;})[_0x30d7('0x4a')](function(_0x418f70){return _0x418f70;});}else{_0x22cc98[_0x30d7('0x1f')](0x190)['json']({'message':_0x30d7('0x67')});}});}})[_0x30d7('0x26')](respondWithResult(_0x22cc98,null))['catch'](handleError(_0x22cc98,null));};exports[_0x30d7('0x68')]=function(_0x4f0263,_0x372a18,_0x129c4e){var _0x1c7ba2;return db[_0x30d7('0x45')][_0x30d7('0x4c')]({'where':{'id':_0x4f0263[_0x30d7('0x54')]['id']},'include':[{'model':db['CmCustomField'],'as':_0x30d7('0x69')}]})['then'](handleEntityNotFound(_0x372a18,null))[_0x30d7('0x26')](function(_0x53c4ad){if(_0x53c4ad){_0x1c7ba2=_0x53c4ad;return db[_0x30d7('0x5d')][_0x30d7('0x30')];}})[_0x30d7('0x26')](function(_0x251f61){if(_0x251f61){var _0x48cdb3={};var _0x1b100d={};_0x1b100d[_0x30d7('0x34')]=_[_0x30d7('0x6a')](_[_0x30d7('0x36')](_0x251f61),_[_0x30d7('0x2f')](_0x1c7ba2[_0x30d7('0x69')],function(_0x476da4){return util[_0x30d7('0x6b')](_0x30d7('0x6c'),_0x476da4['id']);}));_0x1b100d[_0x30d7('0x35')]=_[_0x30d7('0x36')](_0x4f0263[_0x30d7('0x35')]);_0x1b100d[_0x30d7('0x37')]=_['intersection'](_0x1b100d['model'],_0x1b100d[_0x30d7('0x35')]);_0x48cdb3[_0x30d7('0x39')]=_['intersection'](_0x1b100d[_0x30d7('0x34')],qs[_0x30d7('0x3a')](_0x4f0263[_0x30d7('0x35')]['fields']));_0x48cdb3[_0x30d7('0x39')]=_0x48cdb3[_0x30d7('0x39')][_0x30d7('0x3b')]?_0x48cdb3[_0x30d7('0x39')]:_0x1b100d['model'];if(!_0x4f0263[_0x30d7('0x35')]['hasOwnProperty']('nolimit')){_0x48cdb3['limit']=qs[_0x30d7('0x1e')](_0x4f0263[_0x30d7('0x35')][_0x30d7('0x1e')]);_0x48cdb3[_0x30d7('0x1d')]=qs[_0x30d7('0x1d')](_0x4f0263[_0x30d7('0x35')][_0x30d7('0x1d')]);}_0x48cdb3['order']=qs[_0x30d7('0x3f')](_0x4f0263[_0x30d7('0x35')][_0x30d7('0x3f')]);_0x48cdb3[_0x30d7('0x40')]=qs[_0x30d7('0x37')](_[_0x30d7('0x6d')](_0x4f0263[_0x30d7('0x35')],_0x1b100d[_0x30d7('0x37')]));_0x48cdb3['raw']=!![];if(_0x4f0263[_0x30d7('0x35')][_0x30d7('0x41')]){_0x48cdb3[_0x30d7('0x40')]=_[_0x30d7('0x42')](_0x48cdb3[_0x30d7('0x40')],{'$or':_['map'](_0x48cdb3[_0x30d7('0x39')],function(_0x4dbcec){var _0x4e21c1={};_0x4e21c1[_0x4dbcec]={'$like':'%'+_0x4f0263[_0x30d7('0x35')][_0x30d7('0x41')]+'%'};return _0x4e21c1;})});}_0x48cdb3=_[_0x30d7('0x42')]({},_0x48cdb3,_0x4f0263[_0x30d7('0x44')]);return _0x1c7ba2[_0x30d7('0x68')](_0x48cdb3);}})[_0x30d7('0x26')](respondWithResult(_0x372a18,null))[_0x30d7('0x4a')](handleError(_0x372a18,null));};exports[_0x30d7('0x6e')]=function(_0x5408b2,_0x54eb00,_0xe56caf){var _0xebb685;var _0x3d3ab7;var _0x5a5880;var _0x427e56=_0x5408b2[_0x30d7('0x54')]['id'];csv_results=[];return db[_0x30d7('0x6f')][_0x30d7('0x48')]({'attributes':['id',_0x30d7('0x2d')],'raw':!![],'order':[_0x30d7('0x70')]})[_0x30d7('0x26')](function(_0x35b3ed){_0xebb685=_0x35b3ed;var _0x1c5eda=_['keys'](db['CmContact'][_0x30d7('0x30')]);return db[_0x30d7('0x71')]['findAll']({'raw':!![],'attributes':['id','alias']})[_0x30d7('0x26')](function(_0x511633){_0x3d3ab7=_0x511633;var _0x400e66=squel['select']()[_0x30d7('0x3a')](_0x1c5eda)['from'](_0x30d7('0x72'),'c')['where'](_0x30d7('0x73'),_0x427e56)[_0x30d7('0x40')]('c.deletedAt\x20is\x20null')[_0x30d7('0x74')]();for(var _0x4d7726=0x0;_0x4d7726<_0x3d3ab7[_0x30d7('0x3b')];_0x4d7726++){_0x400e66['field'](_0x30d7('0x75')+_0x3d3ab7[_0x4d7726]['id'],_0x30d7('0x76')+_0x3d3ab7[_0x4d7726][_0x30d7('0x77')]);}for(var _0x4d7726=0x0;_0x4d7726<_0xebb685[_0x30d7('0x3b')];_0x4d7726++){_0x400e66['field'](squel['select']()['field'](_0x30d7('0x78'))[_0x30d7('0x79')](_0x30d7('0x7a'))[_0x30d7('0x40')]('ItemTypeId\x20=\x20?',_0xebb685[_0x4d7726]['id'])[_0x30d7('0x40')](_0x30d7('0x7b')),_0x30d7('0x7c')+_0xebb685[_0x4d7726]['name']);_0x400e66[_0x30d7('0x7d')](squel['select']()['field'](_0x30d7('0x7e'))[_0x30d7('0x79')](_0x30d7('0x7a'))['where'](_0x30d7('0x7f'),_0xebb685[_0x4d7726]['id'])[_0x30d7('0x40')](_0x30d7('0x7b')),_0x30d7('0x80')+_0xebb685[_0x4d7726][_0x30d7('0x2d')]);}var _0xe9804c=[];_0xe9804c[_0x30d7('0x61')](_0x400e66['toString']());BPromise[_0x30d7('0x62')](_0xe9804c,handleQuery)[_0x30d7('0x26')](function(_0x1d096c){handleQuery(_0x400e66[_0x30d7('0x81')]());var _0x5ec348=csv_results[0x0];if(!_[_0x30d7('0x82')](_0x5ec348)){var _0x124378=toCsv(_0x5ec348);var _0x2d437b=Date[_0x30d7('0x83')]();fs[_0x30d7('0x84')](util[_0x30d7('0x6b')](_0x30d7('0x85'),_0x427e56,_0x2d437b),_0x124378);_0x54eb00['setHeader'](_0x30d7('0x86'),_0x30d7('0x87')+util['format'](_0x30d7('0x88'),_0x427e56,_0x2d437b));_0x54eb00['setHeader'](_0x30d7('0x89'),_0x30d7('0x8a'));return _0x54eb00[_0x30d7('0x8b')](util['format'](_0x30d7('0x85'),_0x427e56,_0x2d437b));}else{return _0x54eb00[_0x30d7('0x19')](0xcc);}});});});};exports[_0x30d7('0x8c')]=function(_0x44a133,_0x37613b,_0x26a337){var _0x4b2909;delete _0x44a133[_0x30d7('0x4e')]['id'];return db[_0x30d7('0x45')][_0x30d7('0x59')]({'where':{'id':_0x44a133[_0x30d7('0x54')]['id']}})[_0x30d7('0x26')](handleEntityNotFound(_0x37613b,null))[_0x30d7('0x26')](function(_0x2a3434){if(_0x2a3434){return db[_0x30d7('0x8d')]['transaction'](function(_0x193f5e){return db['CmCustomField'][_0x30d7('0x4d')](_0x44a133['body'],{'transaction':_0x193f5e})['then'](function(_0x162f12){_0x4b2909=_0x162f12;return _0x2a3434[_0x30d7('0x8e')](_0x162f12,{'transaction':_0x193f5e});})[_0x30d7('0x26')](function(){var _0x2c4e20={'type':db[_0x30d7('0x8f')]['TEXT'],'transaction':_0x193f5e};switch(_0x44a133[_0x30d7('0x4e')]['type']){case _0x30d7('0x90'):_0x2c4e20['type']=db[_0x30d7('0x8f')][_0x30d7('0x91')];break;case _0x30d7('0x92'):_0x2c4e20['type']=db[_0x30d7('0x8f')][_0x30d7('0x93')];break;case _0x30d7('0x94'):_0x2c4e20[_0x30d7('0x32')]=db[_0x30d7('0x8f')][_0x30d7('0x95')];_0x2c4e20[_0x30d7('0x96')]=![];break;default:}return db[_0x30d7('0x8d')][_0x30d7('0x97')][_0x30d7('0x98')]('cm_contacts',util[_0x30d7('0x6b')](_0x30d7('0x99'),_0x4b2909['id']),_0x2c4e20);})['then'](function(){return _0x4b2909;});});}})[_0x30d7('0x26')](respondWithResult(_0x37613b,null))['catch'](handleError(_0x37613b,null));};exports['getCustomFields']=function(_0x5e1fd2,_0x73fc36,_0x3473d7){var _0x179c04={};var _0x12fe3d={};var _0x2595ac;var _0x5c16ab;return db['CmList'][_0x30d7('0x59')]({'where':{'id':_0x5e1fd2[_0x30d7('0x54')]['id']}})[_0x30d7('0x26')](handleEntityNotFound(_0x73fc36,null))[_0x30d7('0x26')](function(_0x5db04c){if(_0x5db04c){_0x2595ac=_0x5db04c;_0x12fe3d[_0x30d7('0x34')]=_[_0x30d7('0x36')](db['CmCustomField'][_0x30d7('0x30')]);_0x12fe3d['query']=_[_0x30d7('0x36')](_0x5e1fd2['query']);_0x12fe3d[_0x30d7('0x37')]=_['intersection'](_0x12fe3d[_0x30d7('0x34')],_0x12fe3d[_0x30d7('0x35')]);_0x179c04['attributes']=_[_0x30d7('0x38')](_0x12fe3d[_0x30d7('0x34')],qs[_0x30d7('0x3a')](_0x5e1fd2[_0x30d7('0x35')][_0x30d7('0x3a')]));_0x179c04[_0x30d7('0x39')]=_0x179c04[_0x30d7('0x39')][_0x30d7('0x3b')]?_0x179c04[_0x30d7('0x39')]:_0x12fe3d['model'];_0x179c04[_0x30d7('0x3e')]=qs['sort'](_0x5e1fd2[_0x30d7('0x35')][_0x30d7('0x3f')]);_0x179c04[_0x30d7('0x40')]=qs['filters'](_[_0x30d7('0x6d')](_0x5e1fd2[_0x30d7('0x35')],_0x12fe3d[_0x30d7('0x37')]));_0x179c04[_0x30d7('0x40')]=_['merge'](_0x179c04['where'],{'$or':[{'ListId':_0x5db04c['id']},{'ListId':null}]});if(_0x5e1fd2[_0x30d7('0x35')]['filter']){_0x179c04[_0x30d7('0x40')]=_['merge'](_0x179c04['where'],{'$or':_[_0x30d7('0x2f')](_0x179c04[_0x30d7('0x39')],function(_0xeb752f){var _0x2bf811={};_0x2bf811[_0xeb752f]={'$like':'%'+_0x5e1fd2[_0x30d7('0x35')][_0x30d7('0x41')]+'%'};return _0x2bf811;})});}_0x179c04=_[_0x30d7('0x42')]({},_0x179c04,_0x5e1fd2[_0x30d7('0x44')]);return db['CmCustomField'][_0x30d7('0x9a')](_0x179c04);}})[_0x30d7('0x26')](respondWithResult(_0x73fc36,null))[_0x30d7('0x4a')](handleError(_0x73fc36,null));};exports[_0x30d7('0x9b')]=function(_0x50b40a,_0x192013){return db[_0x30d7('0x71')]['findAndCountAll']({'where':{'ListId':null}})['then'](handleEntityNotFound(_0x192013,null))[_0x30d7('0x26')](function(_0x5ee6d5){return _0x5ee6d5;})[_0x30d7('0x26')](respondWithResult(_0x192013,null))[_0x30d7('0x4a')](handleError(_0x192013,null));};exports['addAgents']=function(_0x39885c,_0x27b01b,_0x5b2fe1){return db['CmList'][_0x30d7('0x4c')]({'where':{'id':_0x39885c[_0x30d7('0x54')]['id']}})[_0x30d7('0x26')](handleEntityNotFound(_0x27b01b,null))[_0x30d7('0x26')](function(_0x2727f1){if(_0x2727f1){return _0x2727f1[_0x30d7('0x9c')](_0x39885c[_0x30d7('0x4e')][_0x30d7('0x5b')],_[_0x30d7('0x9d')](_0x39885c['body'],['ids','id'])||{})[_0x30d7('0x9e')](function(_0x18fbb1){for(var _0x2d043a=0x0;_0x2d043a<_0x39885c[_0x30d7('0x4e')][_0x30d7('0x5b')][_0x30d7('0x3b')];_0x2d043a+=0x1){socket[_0x30d7('0x9f')]('userCmList:save',{'UserId':Number(_0x39885c[_0x30d7('0x4e')][_0x30d7('0x5b')][_0x2d043a]),'CmListId':Number(_0x39885c['params']['id'])});}return _0x18fbb1;});}})[_0x30d7('0x26')](respondWithResult(_0x27b01b,null))[_0x30d7('0x4a')](handleError(_0x27b01b,null));};exports['removeAgents']=function(_0x4b43f3,_0x56b04b,_0x3b6a0e){return db[_0x30d7('0x45')][_0x30d7('0x4c')]({'where':{'id':_0x4b43f3[_0x30d7('0x54')]['id']}})[_0x30d7('0x26')](handleEntityNotFound(_0x56b04b,null))['then'](function(_0x50cb8b){if(_0x50cb8b){return _0x50cb8b[_0x30d7('0xa0')](_0x4b43f3[_0x30d7('0x35')][_0x30d7('0x5b')])['then'](function(){if(_['isArray'](_0x4b43f3[_0x30d7('0x35')][_0x30d7('0x5b')])){for(var _0x523448=0x0;_0x523448<_0x4b43f3[_0x30d7('0x35')][_0x30d7('0x5b')][_0x30d7('0x3b')];_0x523448+=0x1){socket[_0x30d7('0x9f')](_0x30d7('0xa1'),{'UserId':Number(_0x4b43f3[_0x30d7('0x35')][_0x30d7('0x5b')][_0x523448]),'CmListId':Number(_0x4b43f3[_0x30d7('0x54')]['id'])});}}else{socket['emit'](_0x30d7('0xa1'),{'UserId':Number(_0x4b43f3[_0x30d7('0x35')][_0x30d7('0x5b')]),'CmListId':Number(_0x4b43f3['params']['id'])});}});}})[_0x30d7('0x26')](respondWithStatusCode(_0x56b04b,null))[_0x30d7('0x4a')](handleError(_0x56b04b,null));};exports[_0x30d7('0xa2')]=function(_0x742513,_0x30f260,_0x45b22d){var _0x5b1675={};var _0x3fe4f4={};var _0x1bc07d;var _0xbcbc0d;return db[_0x30d7('0x45')][_0x30d7('0x59')]({'where':{'id':_0x742513[_0x30d7('0x54')]['id']}})[_0x30d7('0x26')](handleEntityNotFound(_0x30f260,null))[_0x30d7('0x26')](function(_0x1e2b21){if(_0x1e2b21){_0x1bc07d=_0x1e2b21;_0x3fe4f4[_0x30d7('0x34')]=_[_0x30d7('0x36')](db['User'][_0x30d7('0x30')]);_0x3fe4f4[_0x30d7('0x35')]=_[_0x30d7('0x36')](_0x742513[_0x30d7('0x35')]);_0x3fe4f4[_0x30d7('0x37')]=_[_0x30d7('0x38')](_0x3fe4f4[_0x30d7('0x34')],_0x3fe4f4[_0x30d7('0x35')]);_0x5b1675[_0x30d7('0x39')]=_['intersection'](_0x3fe4f4[_0x30d7('0x34')],qs['fields'](_0x742513['query']['fields']));_0x5b1675['attributes']=_0x5b1675[_0x30d7('0x39')][_0x30d7('0x3b')]?_0x5b1675['attributes']:_0x3fe4f4[_0x30d7('0x34')];_0x5b1675[_0x30d7('0x3e')]=qs[_0x30d7('0x3f')](_0x742513['query'][_0x30d7('0x3f')]);_0x5b1675['where']=qs[_0x30d7('0x37')](_[_0x30d7('0x6d')](_0x742513[_0x30d7('0x35')],_0x3fe4f4[_0x30d7('0x37')]));if(_0x742513[_0x30d7('0x35')][_0x30d7('0x41')]){_0x5b1675[_0x30d7('0x40')]=_[_0x30d7('0x42')](_0x5b1675['where'],{'$or':_[_0x30d7('0x2f')](_0x5b1675[_0x30d7('0x39')],function(_0x37a422){var _0x57c09f={};_0x57c09f[_0x37a422]={'$like':'%'+_0x742513[_0x30d7('0x35')][_0x30d7('0x41')]+'%'};return _0x57c09f;})});}_0x5b1675=_[_0x30d7('0x42')]({},_0x5b1675,_0x742513[_0x30d7('0x44')]);return _0x1bc07d[_0x30d7('0xa2')](_0x5b1675);}})[_0x30d7('0x26')](function(_0x8e4a7d){if(_0x8e4a7d){_0xbcbc0d=_0x8e4a7d['length'];if(!_0x742513['query'][_0x30d7('0x3c')](_0x30d7('0x3d'))){_0x5b1675[_0x30d7('0x1e')]=qs[_0x30d7('0x1e')](_0x742513[_0x30d7('0x35')]['limit']);_0x5b1675[_0x30d7('0x1d')]=qs[_0x30d7('0x1d')](_0x742513[_0x30d7('0x35')][_0x30d7('0x1d')]);}return _0x1bc07d[_0x30d7('0xa2')](_0x5b1675);}})[_0x30d7('0x26')](function(_0x1f6b7b){if(_0x1f6b7b){return _0x1f6b7b?{'count':_0xbcbc0d,'rows':_0x1f6b7b}:null;}})[_0x30d7('0x26')](respondWithResult(_0x30f260,null))[_0x30d7('0x4a')](handleError(_0x30f260,null));};function handleQuery(_0x1a8dfa){logger[_0x30d7('0xa3')](_0x1a8dfa);return db[_0x30d7('0x8d')][_0x30d7('0x35')](_0x1a8dfa)[_0x30d7('0x9e')](function(_0x4630e4){csv_results['push'](_0x4630e4);})['catch'](function(_0x2926e5){logger[_0x30d7('0x2b')](_0x2926e5['message']);});}
\ No newline at end of file