Built motion from commit c116dc8b.|2.6.30
[motion2.git] / server / api / cmList / cmList.controller.js
index db1d3e3..9e2ed6f 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xf180=['addContacts','CmContact','tags','isArray','join','push','each','dataValues','errors','message','CmCustomField','CustomFields','concat','format','raw','getContacts','getContactsCsv','cf_%d','isEmpty','now','/tmp/list_%d_%s.csv','setHeader','Content-disposition','attachment;\x20filename=','list_%d_%s.csv','Content-type','text/csv','download','transaction','Sequelize','TEXT','number','INTEGER','BOOLEAN','defaultValue','queryInterface','addColumn','cf_%s','findAndCountAll','addAgents','omit','spread','emit','userCmList:save','removeAgents','userCmList:remove','getAgents','User','eml-format','rimraf','zip-dir','request-promise','mustache','util','path','sox','ejs','fs-extra','squel','crypto','jsforce','desk.js','to-csv','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','socket.io-emitter','sendStatus','status','end','json','undefined','limit','count','set','Content-Range','apply','save','update','then','get','Lists','UserProfileResource','destroy','error','stack','name','send','index','map','rawAttributes','fieldName','type','query','model','attributes','intersection','fields','length','hasOwnProperty','nolimit','offset','order','sort','where','pick','filters','filter','merge','VIRTUAL','options','include','CmList','findAll','rows','catch','params','keys','includeAll','find','create','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','body','describe','Disposition','getDispositions','findOne','ListId','removeDispositions','ids'];(function(_0x5cc51f,_0x22c480){var _0x315a2f=function(_0x4f93bd){while(--_0x4f93bd){_0x5cc51f['push'](_0x5cc51f['shift']());}};_0x315a2f(++_0x22c480);}(_0xf180,0xc0));var _0x0f18=function(_0x433a86,_0x175b5c){_0x433a86=_0x433a86-0x0;var _0x23000c=_0xf180[_0x433a86];return _0x23000c;};'use strict';var emlformat=require(_0x0f18('0x0'));var rimraf=require(_0x0f18('0x1'));var zipdir=require(_0x0f18('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0x0f18('0x3'));var moment=require('moment');var BPromise=require('bluebird');var Mustache=require(_0x0f18('0x4'));var util=require(_0x0f18('0x5'));var path=require(_0x0f18('0x6'));var sox=require(_0x0f18('0x7'));var csv=require('to-csv');var ejs=require(_0x0f18('0x8'));var fs=require('fs');var fs_extra=require(_0x0f18('0x9'));var _=require('lodash');var squel=require(_0x0f18('0xa'));var crypto=require(_0x0f18('0xb'));var jsforce=require(_0x0f18('0xc'));var deskjs=require(_0x0f18('0xd'));var toCsv=require(_0x0f18('0xe'));var querystring=require(_0x0f18('0xf'));var Papa=require(_0x0f18('0x10'));var Redis=require('ioredis');var authService=require(_0x0f18('0x11'));var qs=require(_0x0f18('0x12'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x0f18('0x13'));var logger=require(_0x0f18('0x14'))('api');var utils=require(_0x0f18('0x15'));var config=require(_0x0f18('0x16'));var licenseUtil=require(_0x0f18('0x17'));var db=require(_0x0f18('0x18'))['db'];config[_0x0f18('0x19')]=_['defaults'](config['redis'],{'host':'localhost','port':0x18eb});var socket=require(_0x0f18('0x1a'))(new Redis(config[_0x0f18('0x19')]));require('./cmList.socket')['register'](socket);function respondWithStatusCode(_0x5be473,_0x314bb7){_0x314bb7=_0x314bb7||0xcc;return function(_0x53605b){if(_0x53605b){return _0x5be473[_0x0f18('0x1b')](_0x314bb7);}return _0x5be473[_0x0f18('0x1c')](_0x314bb7)[_0x0f18('0x1d')]();};}function respondWithResult(_0x511408,_0x3152a8){_0x3152a8=_0x3152a8||0xc8;return function(_0x110437){if(_0x110437){return _0x511408[_0x0f18('0x1c')](_0x3152a8)[_0x0f18('0x1e')](_0x110437);}};}function respondWithFilteredResult(_0x51087f,_0x19008c){return function(_0x27f501){if(_0x27f501){var _0x421afa=typeof _0x19008c['offset']===_0x0f18('0x1f')&&typeof _0x19008c[_0x0f18('0x20')]===_0x0f18('0x1f');var _0x4d523c=_0x27f501[_0x0f18('0x21')];var _0x373c7a=_0x421afa?0x0:_0x19008c['offset'];var _0x28b343=_0x421afa?_0x27f501[_0x0f18('0x21')]:_0x19008c['offset']+_0x19008c[_0x0f18('0x20')];var _0x27bf26;if(_0x28b343>=_0x4d523c){_0x28b343=_0x4d523c;_0x27bf26=0xc8;}else{_0x27bf26=0xce;}_0x51087f[_0x0f18('0x1c')](_0x27bf26);return _0x51087f[_0x0f18('0x22')](_0x0f18('0x23'),_0x373c7a+'-'+_0x28b343+'/'+_0x4d523c)[_0x0f18('0x1e')](_0x27f501);}return null;};}function patchUpdates(_0xbaf3cc){return function(_0x1b14f7){try{jsonpatch[_0x0f18('0x24')](_0x1b14f7,_0xbaf3cc,!![]);}catch(_0x20b837){return BPromise['reject'](_0x20b837);}return _0x1b14f7[_0x0f18('0x25')]();};}function saveUpdates(_0x4c0cd6,_0x10aca8){return function(_0x3af5b3){if(_0x3af5b3){return _0x3af5b3[_0x0f18('0x26')](_0x4c0cd6)[_0x0f18('0x27')](function(_0xfd85c4){return _0xfd85c4;});}return null;};}function removeEntity(_0x22b2c8,_0x3abc57){return function(_0x873e0b){if(_0x873e0b){return _0x873e0b['destroy']()[_0x0f18('0x27')](function(){var _0x58c2c2=_0x873e0b[_0x0f18('0x28')]({'plain':!![]});var _0x1a621f=_0x0f18('0x29');return db[_0x0f18('0x2a')][_0x0f18('0x2b')]({'where':{'type':_0x1a621f,'resourceId':_0x58c2c2['id']}})['then'](function(){return _0x873e0b;});})[_0x0f18('0x27')](function(){_0x22b2c8[_0x0f18('0x1c')](0xcc)[_0x0f18('0x1d')]();});}};}function handleEntityNotFound(_0x42e27d,_0x5ea587){return function(_0x388b26){if(!_0x388b26){_0x42e27d[_0x0f18('0x1b')](0x194);}return _0x388b26;};}function handleError(_0x48513e,_0xe69a94){_0xe69a94=_0xe69a94||0x1f4;return function(_0x2df346){logger[_0x0f18('0x2c')](_0x2df346[_0x0f18('0x2d')]);if(_0x2df346[_0x0f18('0x2e')]){delete _0x2df346[_0x0f18('0x2e')];}_0x48513e['status'](_0xe69a94)[_0x0f18('0x2f')](_0x2df346);};}exports[_0x0f18('0x30')]=function(_0x474838,_0xc54624){var _0x3ea509={},_0x1303f3={},_0x1a0ed6={'count':0x0,'rows':[]};var _0x10638b=_[_0x0f18('0x31')](db['CmList'][_0x0f18('0x32')],function(_0x41c349){return{'name':_0x41c349[_0x0f18('0x33')],'type':_0x41c349[_0x0f18('0x34')]['key']};});_0x1303f3['model']=_[_0x0f18('0x31')](_0x10638b,_0x0f18('0x2e'));_0x1303f3[_0x0f18('0x35')]=_['keys'](_0x474838[_0x0f18('0x35')]);_0x1303f3['filters']=_['intersection'](_0x1303f3[_0x0f18('0x36')],_0x1303f3[_0x0f18('0x35')]);_0x3ea509[_0x0f18('0x37')]=_[_0x0f18('0x38')](_0x1303f3[_0x0f18('0x36')],qs[_0x0f18('0x39')](_0x474838[_0x0f18('0x35')]['fields']));_0x3ea509[_0x0f18('0x37')]=_0x3ea509['attributes'][_0x0f18('0x3a')]?_0x3ea509[_0x0f18('0x37')]:_0x1303f3[_0x0f18('0x36')];if(!_0x474838['query'][_0x0f18('0x3b')](_0x0f18('0x3c'))){_0x3ea509[_0x0f18('0x20')]=qs['limit'](_0x474838[_0x0f18('0x35')][_0x0f18('0x20')]);_0x3ea509[_0x0f18('0x3d')]=qs[_0x0f18('0x3d')](_0x474838[_0x0f18('0x35')][_0x0f18('0x3d')]);}_0x3ea509[_0x0f18('0x3e')]=qs[_0x0f18('0x3f')](_0x474838[_0x0f18('0x35')]['sort']);_0x3ea509[_0x0f18('0x40')]=qs['filters'](_[_0x0f18('0x41')](_0x474838['query'],_0x1303f3[_0x0f18('0x42')]),_0x10638b);if(_0x474838[_0x0f18('0x35')][_0x0f18('0x43')]){_0x3ea509['where']=_[_0x0f18('0x44')](_0x3ea509[_0x0f18('0x40')],{'$or':_[_0x0f18('0x31')](_0x10638b,function(_0x47cfe2){if(_0x47cfe2[_0x0f18('0x34')]!==_0x0f18('0x45')){var _0x1d9268={};_0x1d9268[_0x47cfe2[_0x0f18('0x2e')]]={'$like':'%'+_0x474838[_0x0f18('0x35')][_0x0f18('0x43')]+'%'};return _0x1d9268;}})});}_0x3ea509=_[_0x0f18('0x44')]({},_0x3ea509,_0x474838[_0x0f18('0x46')]);var _0x43ee7b={'where':_0x3ea509[_0x0f18('0x40')]};return db['CmList']['count'](_0x43ee7b)[_0x0f18('0x27')](function(_0x2ce635){_0x1a0ed6[_0x0f18('0x21')]=_0x2ce635;if(_0x474838[_0x0f18('0x35')]['includeAll']){_0x3ea509[_0x0f18('0x47')]=[{'all':!![]}];}return db[_0x0f18('0x48')][_0x0f18('0x49')](_0x3ea509);})[_0x0f18('0x27')](function(_0x4b22e5){_0x1a0ed6[_0x0f18('0x4a')]=_0x4b22e5;return _0x1a0ed6;})[_0x0f18('0x27')](respondWithFilteredResult(_0xc54624,_0x3ea509))[_0x0f18('0x4b')](handleError(_0xc54624,null));};exports['show']=function(_0x40e8fe,_0x3931a1){var _0x4ec4f2={'raw':![],'where':{'id':_0x40e8fe[_0x0f18('0x4c')]['id']}},_0xa8d0b6={};_0xa8d0b6[_0x0f18('0x36')]=_[_0x0f18('0x4d')](db[_0x0f18('0x48')][_0x0f18('0x32')]);_0xa8d0b6[_0x0f18('0x35')]=_[_0x0f18('0x4d')](_0x40e8fe[_0x0f18('0x35')]);_0xa8d0b6[_0x0f18('0x42')]=_[_0x0f18('0x38')](_0xa8d0b6['model'],_0xa8d0b6[_0x0f18('0x35')]);_0x4ec4f2[_0x0f18('0x37')]=_[_0x0f18('0x38')](_0xa8d0b6[_0x0f18('0x36')],qs[_0x0f18('0x39')](_0x40e8fe[_0x0f18('0x35')]['fields']));_0x4ec4f2[_0x0f18('0x37')]=_0x4ec4f2[_0x0f18('0x37')][_0x0f18('0x3a')]?_0x4ec4f2['attributes']:_0xa8d0b6[_0x0f18('0x36')];if(_0x40e8fe[_0x0f18('0x35')][_0x0f18('0x4e')]){_0x4ec4f2[_0x0f18('0x47')]=[{'all':!![]}];}_0x4ec4f2=_['merge']({},_0x4ec4f2,_0x40e8fe[_0x0f18('0x46')]);return db['CmList'][_0x0f18('0x4f')](_0x4ec4f2)[_0x0f18('0x27')](handleEntityNotFound(_0x3931a1,null))[_0x0f18('0x27')](respondWithResult(_0x3931a1,null))[_0x0f18('0x4b')](handleError(_0x3931a1,null));};exports['create']=function(_0x5e1479,_0x5e9daa){return db[_0x0f18('0x48')][_0x0f18('0x50')](_0x5e1479['body'],{})[_0x0f18('0x27')](function(_0x23d6fb){var _0x59f83a=_0x5e1479[_0x0f18('0x51')][_0x0f18('0x28')]({'plain':!![]});if(!_0x59f83a)throw new Error(_0x0f18('0x52'));if(_0x59f83a[_0x0f18('0x53')]===_0x0f18('0x51')){var _0x409c22=_0x23d6fb[_0x0f18('0x28')]({'plain':!![]});var _0x340234=_0x0f18('0x29');return db[_0x0f18('0x54')][_0x0f18('0x4f')]({'where':{'name':_0x340234,'userProfileId':_0x59f83a[_0x0f18('0x55')]},'raw':!![]})[_0x0f18('0x27')](function(_0x5d4f82){if(_0x5d4f82&&_0x5d4f82[_0x0f18('0x56')]===0x0){return db[_0x0f18('0x2a')][_0x0f18('0x50')]({'name':_0x409c22[_0x0f18('0x2e')],'resourceId':_0x409c22['id'],'type':_0x5d4f82['name'],'sectionId':_0x5d4f82['id']},{})[_0x0f18('0x27')](function(){return _0x23d6fb;});}else{return _0x23d6fb;}})[_0x0f18('0x4b')](function(_0x636152){logger[_0x0f18('0x2c')](_0x0f18('0x57'),_0x636152);throw _0x636152;});}return _0x23d6fb;})[_0x0f18('0x27')](respondWithResult(_0x5e9daa,0xc9))[_0x0f18('0x4b')](handleError(_0x5e9daa,null));};exports['update']=function(_0x577713,_0x4d5ca5){if(_0x577713['body']['id']){delete _0x577713['body']['id'];}return db[_0x0f18('0x48')]['find']({'where':{'id':_0x577713[_0x0f18('0x4c')]['id']}})[_0x0f18('0x27')](handleEntityNotFound(_0x4d5ca5,null))[_0x0f18('0x27')](saveUpdates(_0x577713[_0x0f18('0x58')],null))[_0x0f18('0x27')](respondWithResult(_0x4d5ca5,null))[_0x0f18('0x4b')](handleError(_0x4d5ca5,null));};exports[_0x0f18('0x2b')]=function(_0x3c0c8e,_0x3ca0a2){return db[_0x0f18('0x48')][_0x0f18('0x4f')]({'where':{'id':_0x3c0c8e[_0x0f18('0x4c')]['id']}})[_0x0f18('0x27')](handleEntityNotFound(_0x3ca0a2,null))[_0x0f18('0x27')](removeEntity(_0x3ca0a2,null))['catch'](handleError(_0x3ca0a2,null));};exports[_0x0f18('0x59')]=function(_0x5451bc,_0x1255f1){return db['CmList'][_0x0f18('0x59')]()[_0x0f18('0x27')](respondWithResult(_0x1255f1,null))['catch'](handleError(_0x1255f1,null));};exports['addDisposition']=function(_0x5f104f,_0x283f64,_0xcf6885){if(_0x5f104f[_0x0f18('0x58')]['id']){delete _0x5f104f[_0x0f18('0x58')]['id'];}return db['CmList'][_0x0f18('0x4f')]({'where':{'id':_0x5f104f[_0x0f18('0x4c')]['id']}})[_0x0f18('0x27')](handleEntityNotFound(_0x283f64,null))[_0x0f18('0x27')](function(_0x3c8950){if(_0x3c8950){_0x5f104f[_0x0f18('0x58')]['ListId']=_0x3c8950['id'];return db[_0x0f18('0x5a')][_0x0f18('0x50')](_0x5f104f['body']);}})[_0x0f18('0x27')](respondWithResult(_0x283f64,null))[_0x0f18('0x4b')](handleError(_0x283f64,null));};exports[_0x0f18('0x5b')]=function(_0x2326cf,_0x175c23,_0x1bd26a){var _0x24e0a0={'raw':![],'where':{}};var _0x3f5826={};var _0x2a2beb={'count':0x0,'rows':[]};return db[_0x0f18('0x48')][_0x0f18('0x5c')]({'where':{'id':_0x2326cf[_0x0f18('0x4c')]['id']}})['then'](handleEntityNotFound(_0x175c23,null))[_0x0f18('0x27')](function(_0xd8a83){if(_0xd8a83){_0x3f5826[_0x0f18('0x36')]=_[_0x0f18('0x4d')](db['Disposition'][_0x0f18('0x32')]);_0x3f5826['query']=_[_0x0f18('0x4d')](_0x2326cf['query']);_0x3f5826[_0x0f18('0x42')]=_[_0x0f18('0x38')](_0x3f5826[_0x0f18('0x36')],_0x3f5826['query']);_0x24e0a0[_0x0f18('0x37')]=_[_0x0f18('0x38')](_0x3f5826[_0x0f18('0x36')],qs[_0x0f18('0x39')](_0x2326cf['query'][_0x0f18('0x39')]));_0x24e0a0[_0x0f18('0x37')]=_0x24e0a0['attributes'][_0x0f18('0x3a')]?_0x24e0a0[_0x0f18('0x37')]:_0x3f5826[_0x0f18('0x36')];if(!_0x2326cf[_0x0f18('0x35')][_0x0f18('0x3b')](_0x0f18('0x3c'))){_0x24e0a0['limit']=qs[_0x0f18('0x20')](_0x2326cf['query'][_0x0f18('0x20')]);_0x24e0a0[_0x0f18('0x3d')]=qs[_0x0f18('0x3d')](_0x2326cf['query'][_0x0f18('0x3d')]);}_0x24e0a0[_0x0f18('0x3e')]=qs['sort'](_0x2326cf['query'][_0x0f18('0x3f')]);_0x24e0a0['where']=qs[_0x0f18('0x42')](_[_0x0f18('0x41')](_0x2326cf['query'],_0x3f5826[_0x0f18('0x42')]));_0x24e0a0[_0x0f18('0x40')][_0x0f18('0x5d')]=_0xd8a83['id'];if(_0x2326cf['query'][_0x0f18('0x43')]){_0x24e0a0[_0x0f18('0x40')]=_['merge'](_0x24e0a0[_0x0f18('0x40')],{'$or':_['map'](_0x24e0a0[_0x0f18('0x37')],function(_0x2f3596){var _0x5c4f96={};_0x5c4f96[_0x2f3596]={'$like':'%'+_0x2326cf[_0x0f18('0x35')][_0x0f18('0x43')]+'%'};return _0x5c4f96;})});}_0x24e0a0=_[_0x0f18('0x44')]({},_0x24e0a0,_0x2326cf[_0x0f18('0x46')]);return db['Disposition'][_0x0f18('0x21')]({'where':_0x24e0a0[_0x0f18('0x40')]})[_0x0f18('0x27')](function(_0x94065d){_0x2a2beb[_0x0f18('0x21')]=_0x94065d;if(_0x2326cf[_0x0f18('0x35')]['includeAll']){_0x24e0a0[_0x0f18('0x47')]=[{'all':!![]}];}return db[_0x0f18('0x5a')]['findAll'](_0x24e0a0);})[_0x0f18('0x27')](function(_0x426a97){_0x2a2beb[_0x0f18('0x4a')]=_0x426a97;return _0x2a2beb;});}})[_0x0f18('0x27')](respondWithFilteredResult(_0x175c23,_0x24e0a0))[_0x0f18('0x4b')](handleError(_0x175c23,null));};exports[_0x0f18('0x5e')]=function(_0x1577a8,_0x5ae941,_0x520121){return db[_0x0f18('0x48')][_0x0f18('0x4f')]({'where':{'id':_0x1577a8['params']['id']}})['then'](handleEntityNotFound(_0x5ae941,null))['then'](function(_0xf9e5f1){if(_0xf9e5f1){return _0xf9e5f1[_0x0f18('0x5e')](_0x1577a8['query'][_0x0f18('0x5f')]);}})['then'](respondWithStatusCode(_0x5ae941,null))[_0x0f18('0x4b')](handleError(_0x5ae941,null));};exports[_0x0f18('0x60')]=function(_0x9c52bf,_0x39e95d,_0x1c19d9){return db[_0x0f18('0x48')]['find']({'where':{'id':_0x9c52bf['params']['id']}})['then'](handleEntityNotFound(_0x39e95d,null))[_0x0f18('0x27')](function(_0x352b8b){if(_0x352b8b){var _0x39d8ba=[];var _0x5ae78e={'success':[],'errors':[]};return db[_0x0f18('0x61')][_0x0f18('0x59')]()['then'](function(_0x3e9e1d){if(_0x9c52bf[_0x0f18('0x58')][_0x0f18('0x62')]&&_[_0x0f18('0x63')](_0x9c52bf[_0x0f18('0x58')][_0x0f18('0x62')])){if(_0x9c52bf['body']['tags']['length']){_0x9c52bf[_0x0f18('0x58')][_0x0f18('0x62')]=_0x9c52bf['body'][_0x0f18('0x62')][_0x0f18('0x64')](';')+';';}else{_0x9c52bf[_0x0f18('0x58')][_0x0f18('0x62')]=null;}}else{_0x9c52bf['body'][_0x0f18('0x62')]=null;}if(_0x9c52bf[_0x0f18('0x58')]&&_[_0x0f18('0x63')](_0x9c52bf[_0x0f18('0x58')])){for(var _0x59c33e=0x0;_0x59c33e<_0x9c52bf[_0x0f18('0x58')][_0x0f18('0x3a')];_0x59c33e+=0x1){_0x9c52bf[_0x0f18('0x58')][_0x59c33e][_0x0f18('0x5d')]=_0x9c52bf[_0x0f18('0x4c')]['id'];_0x39d8ba[_0x0f18('0x65')](_0x9c52bf[_0x0f18('0x58')][_0x59c33e]);}return BPromise[_0x0f18('0x66')](_0x39d8ba,function(_0x3dd5b8){return db['CmContact'][_0x0f18('0x50')](_['omit'](_0x3dd5b8,[_0x0f18('0x5f'),'id'])||{},{'fields':_[_0x0f18('0x4d')](_0x3e9e1d),'raw':!![]})['then'](function(_0x17cb0f){_0x5ae78e['success'][_0x0f18('0x65')](_0x17cb0f[_0x0f18('0x67')]);})[_0x0f18('0x4b')](function(_0x1f3f48){_0x5ae78e[_0x0f18('0x68')][_0x0f18('0x65')]({'data':_0x3dd5b8,'error':_0x1f3f48[_0x0f18('0x69')]});});})['then'](function(_0x517b3c){return _0x5ae78e;})[_0x0f18('0x4b')](function(_0x1fd278){return _0x1fd278;});}else{_0x39e95d[_0x0f18('0x1c')](0x190)[_0x0f18('0x1e')]({'message':'Malformed\x20request\x20syntax'});}});}})[_0x0f18('0x27')](respondWithResult(_0x39e95d,null))['catch'](handleError(_0x39e95d,null));};exports['getContacts']=function(_0x1cba77,_0x2b7891,_0x1e925d){var _0x267bec;return db[_0x0f18('0x48')]['find']({'where':{'id':_0x1cba77[_0x0f18('0x4c')]['id']},'include':[{'model':db[_0x0f18('0x6a')],'as':_0x0f18('0x6b')}]})[_0x0f18('0x27')](handleEntityNotFound(_0x2b7891,null))[_0x0f18('0x27')](function(_0x16d586){if(_0x16d586){_0x267bec=_0x16d586;return db[_0x0f18('0x61')][_0x0f18('0x32')];}})[_0x0f18('0x27')](function(_0x6bc172){if(_0x6bc172){var _0x26e7b7={};var _0x553068={};_0x553068[_0x0f18('0x36')]=_[_0x0f18('0x6c')](_[_0x0f18('0x4d')](_0x6bc172),_[_0x0f18('0x31')](_0x267bec[_0x0f18('0x6b')],function(_0x3feb2f){return util[_0x0f18('0x6d')]('cf_%d',_0x3feb2f['id']);}));_0x553068[_0x0f18('0x35')]=_[_0x0f18('0x4d')](_0x1cba77[_0x0f18('0x35')]);_0x553068[_0x0f18('0x42')]=_[_0x0f18('0x38')](_0x553068[_0x0f18('0x36')],_0x553068['query']);_0x26e7b7[_0x0f18('0x37')]=_[_0x0f18('0x38')](_0x553068[_0x0f18('0x36')],qs[_0x0f18('0x39')](_0x1cba77[_0x0f18('0x35')][_0x0f18('0x39')]));_0x26e7b7['attributes']=_0x26e7b7['attributes'][_0x0f18('0x3a')]?_0x26e7b7[_0x0f18('0x37')]:_0x553068[_0x0f18('0x36')];if(!_0x1cba77[_0x0f18('0x35')][_0x0f18('0x3b')](_0x0f18('0x3c'))){_0x26e7b7[_0x0f18('0x20')]=qs['limit'](_0x1cba77[_0x0f18('0x35')]['limit']);_0x26e7b7[_0x0f18('0x3d')]=qs['offset'](_0x1cba77[_0x0f18('0x35')][_0x0f18('0x3d')]);}_0x26e7b7['order']=qs[_0x0f18('0x3f')](_0x1cba77[_0x0f18('0x35')][_0x0f18('0x3f')]);_0x26e7b7[_0x0f18('0x40')]=qs['filters'](_[_0x0f18('0x41')](_0x1cba77['query'],_0x553068['filters']));_0x26e7b7[_0x0f18('0x6e')]=!![];if(_0x1cba77[_0x0f18('0x35')][_0x0f18('0x43')]){_0x26e7b7['where']=_[_0x0f18('0x44')](_0x26e7b7['where'],{'$or':_['map'](_0x26e7b7[_0x0f18('0x37')],function(_0x577d0b){var _0x2e024a={};_0x2e024a[_0x577d0b]={'$like':'%'+_0x1cba77[_0x0f18('0x35')]['filter']+'%'};return _0x2e024a;})});}_0x26e7b7=_['merge']({},_0x26e7b7,_0x1cba77[_0x0f18('0x46')]);return _0x267bec[_0x0f18('0x6f')](_0x26e7b7);}})[_0x0f18('0x27')](respondWithResult(_0x2b7891,null))[_0x0f18('0x4b')](handleError(_0x2b7891,null));};exports[_0x0f18('0x70')]=function(_0x1b4480,_0x407237,_0x212670){var _0x4b8c3d;return db['CmList'][_0x0f18('0x4f')]({'where':{'id':_0x1b4480[_0x0f18('0x4c')]['id']},'include':[{'model':db[_0x0f18('0x6a')],'as':_0x0f18('0x6b')}]})[_0x0f18('0x27')](handleEntityNotFound(_0x407237,null))['then'](function(_0x36235c){if(_0x36235c){_0x4b8c3d=_0x36235c;return db[_0x0f18('0x61')][_0x0f18('0x32')];}})['then'](function(_0x5b9300){if(_0x5b9300){var _0x4dfa3c={};var _0x29f967={};_0x29f967[_0x0f18('0x36')]=_[_0x0f18('0x6c')](_[_0x0f18('0x4d')](_0x5b9300),_['map'](_0x4b8c3d['CustomFields'],function(_0x1440a5){return util['format'](_0x0f18('0x71'),_0x1440a5['id']);}));_0x29f967['query']=_[_0x0f18('0x4d')](_0x1b4480['query']);_0x29f967['filters']=_[_0x0f18('0x38')](_0x29f967['model'],_0x29f967['query']);_0x4dfa3c[_0x0f18('0x37')]=_[_0x0f18('0x38')](_0x29f967[_0x0f18('0x36')],qs['fields'](_0x1b4480[_0x0f18('0x35')][_0x0f18('0x39')]));_0x4dfa3c['attributes']=_0x4dfa3c[_0x0f18('0x37')]['length']?_0x4dfa3c[_0x0f18('0x37')]:_0x29f967[_0x0f18('0x36')];if(!_0x1b4480[_0x0f18('0x35')]['hasOwnProperty'](_0x0f18('0x3c'))){_0x4dfa3c[_0x0f18('0x20')]=qs['limit'](_0x1b4480[_0x0f18('0x35')][_0x0f18('0x20')]);_0x4dfa3c[_0x0f18('0x3d')]=qs[_0x0f18('0x3d')](_0x1b4480['query'][_0x0f18('0x3d')]);}_0x4dfa3c[_0x0f18('0x3e')]=qs[_0x0f18('0x3f')](_0x1b4480[_0x0f18('0x35')][_0x0f18('0x3f')]);_0x4dfa3c[_0x0f18('0x40')]=qs[_0x0f18('0x42')](_['pick'](_0x1b4480[_0x0f18('0x35')],_0x29f967['filters']));_0x4dfa3c[_0x0f18('0x6e')]=!![];if(_0x1b4480[_0x0f18('0x35')][_0x0f18('0x43')]){_0x4dfa3c['where']=_[_0x0f18('0x44')](_0x4dfa3c[_0x0f18('0x40')],{'$or':_[_0x0f18('0x31')](_0x4dfa3c[_0x0f18('0x37')],function(_0x180b81){var _0x27bb56={};_0x27bb56[_0x180b81]={'$like':'%'+_0x1b4480[_0x0f18('0x35')][_0x0f18('0x43')]+'%'};return _0x27bb56;})});}_0x4dfa3c=_[_0x0f18('0x44')]({},_0x4dfa3c,_0x1b4480[_0x0f18('0x46')]);return _0x4b8c3d['getContacts'](_0x4dfa3c);}})[_0x0f18('0x27')](function(_0x3ac1af){if(!_[_0x0f18('0x72')](_0x3ac1af)){var _0x5c5632=toCsv(_0x3ac1af);var _0x4553f2=Date[_0x0f18('0x73')]();fs['writeFileSync'](util[_0x0f18('0x6d')](_0x0f18('0x74'),_0x4b8c3d['id'],_0x4553f2),_0x5c5632);_0x407237[_0x0f18('0x75')](_0x0f18('0x76'),_0x0f18('0x77')+util[_0x0f18('0x6d')](_0x0f18('0x78'),_0x4b8c3d['id'],_0x4553f2));_0x407237[_0x0f18('0x75')](_0x0f18('0x79'),_0x0f18('0x7a'));return _0x407237[_0x0f18('0x7b')](util[_0x0f18('0x6d')](_0x0f18('0x74'),_0x4b8c3d['id'],_0x4553f2));}else{return _0x407237[_0x0f18('0x1b')](0xcc);}})[_0x0f18('0x4b')](handleError(_0x407237,null));};exports['addCustomField']=function(_0x542098,_0x9c34f2,_0x599e48){var _0x18f3bc;delete _0x542098['body']['id'];return db[_0x0f18('0x48')][_0x0f18('0x5c')]({'where':{'id':_0x542098[_0x0f18('0x4c')]['id']}})[_0x0f18('0x27')](handleEntityNotFound(_0x9c34f2,null))[_0x0f18('0x27')](function(_0xe56190){if(_0xe56190){return db['sequelize'][_0x0f18('0x7c')](function(_0x26fd58){return db['CmCustomField']['create'](_0x542098['body'],{'transaction':_0x26fd58})['then'](function(_0x527347){_0x18f3bc=_0x527347;return _0xe56190['addCustomFields'](_0x527347,{'transaction':_0x26fd58});})['then'](function(){var _0x4f293b={'type':db[_0x0f18('0x7d')][_0x0f18('0x7e')],'transaction':_0x26fd58};switch(_0x542098[_0x0f18('0x58')][_0x0f18('0x34')]){case'text':_0x4f293b[_0x0f18('0x34')]=db[_0x0f18('0x7d')]['TEXT'];break;case _0x0f18('0x7f'):_0x4f293b[_0x0f18('0x34')]=db['Sequelize'][_0x0f18('0x80')];break;case'switch':_0x4f293b[_0x0f18('0x34')]=db[_0x0f18('0x7d')][_0x0f18('0x81')];_0x4f293b[_0x0f18('0x82')]=![];break;default:}return db['sequelize'][_0x0f18('0x83')][_0x0f18('0x84')]('cm_contacts',util[_0x0f18('0x6d')](_0x0f18('0x85'),_0x18f3bc['id']),_0x4f293b);})['then'](function(){return _0x18f3bc;});});}})[_0x0f18('0x27')](respondWithResult(_0x9c34f2,null))[_0x0f18('0x4b')](handleError(_0x9c34f2,null));};exports['getCustomFields']=function(_0x4e0572,_0x47b2db,_0x251f66){var _0xc96b5e={};var _0xf02255={};var _0x1880be;var _0xb57e31;return db['CmList']['findOne']({'where':{'id':_0x4e0572[_0x0f18('0x4c')]['id']}})['then'](handleEntityNotFound(_0x47b2db,null))[_0x0f18('0x27')](function(_0x16f7c9){if(_0x16f7c9){_0x1880be=_0x16f7c9;_0xf02255[_0x0f18('0x36')]=_[_0x0f18('0x4d')](db['CmCustomField']['rawAttributes']);_0xf02255[_0x0f18('0x35')]=_[_0x0f18('0x4d')](_0x4e0572[_0x0f18('0x35')]);_0xf02255['filters']=_[_0x0f18('0x38')](_0xf02255[_0x0f18('0x36')],_0xf02255[_0x0f18('0x35')]);_0xc96b5e[_0x0f18('0x37')]=_[_0x0f18('0x38')](_0xf02255['model'],qs[_0x0f18('0x39')](_0x4e0572[_0x0f18('0x35')]['fields']));_0xc96b5e[_0x0f18('0x37')]=_0xc96b5e[_0x0f18('0x37')][_0x0f18('0x3a')]?_0xc96b5e[_0x0f18('0x37')]:_0xf02255[_0x0f18('0x36')];_0xc96b5e[_0x0f18('0x3e')]=qs[_0x0f18('0x3f')](_0x4e0572[_0x0f18('0x35')][_0x0f18('0x3f')]);_0xc96b5e['where']=qs[_0x0f18('0x42')](_[_0x0f18('0x41')](_0x4e0572['query'],_0xf02255[_0x0f18('0x42')]));_0xc96b5e[_0x0f18('0x40')]=_[_0x0f18('0x44')](_0xc96b5e[_0x0f18('0x40')],{'$or':[{'ListId':_0x16f7c9['id']},{'ListId':null}]});if(_0x4e0572['query'][_0x0f18('0x43')]){_0xc96b5e[_0x0f18('0x40')]=_[_0x0f18('0x44')](_0xc96b5e['where'],{'$or':_[_0x0f18('0x31')](_0xc96b5e[_0x0f18('0x37')],function(_0x506198){var _0x578547={};_0x578547[_0x506198]={'$like':'%'+_0x4e0572[_0x0f18('0x35')][_0x0f18('0x43')]+'%'};return _0x578547;})});}_0xc96b5e=_[_0x0f18('0x44')]({},_0xc96b5e,_0x4e0572[_0x0f18('0x46')]);return db[_0x0f18('0x6a')][_0x0f18('0x86')](_0xc96b5e);}})[_0x0f18('0x27')](respondWithResult(_0x47b2db,null))[_0x0f18('0x4b')](handleError(_0x47b2db,null));};exports[_0x0f18('0x87')]=function(_0x2e0c1b,_0x253996,_0x204788){return db[_0x0f18('0x48')]['find']({'where':{'id':_0x2e0c1b[_0x0f18('0x4c')]['id']}})[_0x0f18('0x27')](handleEntityNotFound(_0x253996,null))[_0x0f18('0x27')](function(_0x25a76f){if(_0x25a76f){return _0x25a76f[_0x0f18('0x87')](_0x2e0c1b[_0x0f18('0x58')][_0x0f18('0x5f')],_[_0x0f18('0x88')](_0x2e0c1b[_0x0f18('0x58')],[_0x0f18('0x5f'),'id'])||{})[_0x0f18('0x89')](function(_0x5cb4d3){for(var _0x596d25=0x0;_0x596d25<_0x2e0c1b[_0x0f18('0x58')][_0x0f18('0x5f')]['length'];_0x596d25+=0x1){socket[_0x0f18('0x8a')](_0x0f18('0x8b'),{'UserId':_0x2e0c1b[_0x0f18('0x58')][_0x0f18('0x5f')][_0x596d25],'CmListId':_0x2e0c1b[_0x0f18('0x4c')]['id']});}return _0x5cb4d3;});}})[_0x0f18('0x27')](respondWithResult(_0x253996,null))[_0x0f18('0x4b')](handleError(_0x253996,null));};exports[_0x0f18('0x8c')]=function(_0x3f1743,_0x55bfdb,_0x1b4ff6){return db[_0x0f18('0x48')][_0x0f18('0x4f')]({'where':{'id':_0x3f1743[_0x0f18('0x4c')]['id']}})[_0x0f18('0x27')](handleEntityNotFound(_0x55bfdb,null))[_0x0f18('0x27')](function(_0xb835c8){if(_0xb835c8){return _0xb835c8['removeAgents'](_0x3f1743['query']['ids'])[_0x0f18('0x27')](function(){if(_[_0x0f18('0x63')](_0x3f1743[_0x0f18('0x35')]['ids'])){for(var _0x7dd49e=0x0;_0x7dd49e<_0x3f1743[_0x0f18('0x35')][_0x0f18('0x5f')]['length'];_0x7dd49e+=0x1){socket[_0x0f18('0x8a')](_0x0f18('0x8d'),{'UserId':Number(_0x3f1743[_0x0f18('0x35')][_0x0f18('0x5f')][_0x7dd49e]),'CmListId':Number(_0x3f1743[_0x0f18('0x4c')]['id'])});}}else{socket['emit'](_0x0f18('0x8d'),{'UserId':Number(_0x3f1743[_0x0f18('0x35')][_0x0f18('0x5f')]),'CmListId':Number(_0x3f1743[_0x0f18('0x4c')]['id'])});}});}})[_0x0f18('0x27')](respondWithStatusCode(_0x55bfdb,null))[_0x0f18('0x4b')](handleError(_0x55bfdb,null));};exports[_0x0f18('0x8e')]=function(_0xb913b2,_0x599c36,_0x566f4f){var _0x4d2a6b={};var _0x11b5d6={};var _0x5d966b;var _0x23ea7c;return db['CmList'][_0x0f18('0x5c')]({'where':{'id':_0xb913b2[_0x0f18('0x4c')]['id']}})[_0x0f18('0x27')](handleEntityNotFound(_0x599c36,null))['then'](function(_0x38560a){if(_0x38560a){_0x5d966b=_0x38560a;_0x11b5d6[_0x0f18('0x36')]=_[_0x0f18('0x4d')](db[_0x0f18('0x8f')]['rawAttributes']);_0x11b5d6['query']=_[_0x0f18('0x4d')](_0xb913b2[_0x0f18('0x35')]);_0x11b5d6[_0x0f18('0x42')]=_[_0x0f18('0x38')](_0x11b5d6[_0x0f18('0x36')],_0x11b5d6['query']);_0x4d2a6b['attributes']=_[_0x0f18('0x38')](_0x11b5d6[_0x0f18('0x36')],qs['fields'](_0xb913b2['query'][_0x0f18('0x39')]));_0x4d2a6b['attributes']=_0x4d2a6b[_0x0f18('0x37')][_0x0f18('0x3a')]?_0x4d2a6b[_0x0f18('0x37')]:_0x11b5d6[_0x0f18('0x36')];_0x4d2a6b[_0x0f18('0x3e')]=qs[_0x0f18('0x3f')](_0xb913b2['query']['sort']);_0x4d2a6b[_0x0f18('0x40')]=qs['filters'](_['pick'](_0xb913b2[_0x0f18('0x35')],_0x11b5d6[_0x0f18('0x42')]));if(_0xb913b2[_0x0f18('0x35')][_0x0f18('0x43')]){_0x4d2a6b[_0x0f18('0x40')]=_[_0x0f18('0x44')](_0x4d2a6b['where'],{'$or':_['map'](_0x4d2a6b[_0x0f18('0x37')],function(_0x1b9452){var _0x4a5142={};_0x4a5142[_0x1b9452]={'$like':'%'+_0xb913b2[_0x0f18('0x35')][_0x0f18('0x43')]+'%'};return _0x4a5142;})});}_0x4d2a6b=_[_0x0f18('0x44')]({},_0x4d2a6b,_0xb913b2[_0x0f18('0x46')]);return _0x5d966b['getAgents'](_0x4d2a6b);}})['then'](function(_0x484963){if(_0x484963){_0x23ea7c=_0x484963[_0x0f18('0x3a')];if(!_0xb913b2[_0x0f18('0x35')][_0x0f18('0x3b')](_0x0f18('0x3c'))){_0x4d2a6b[_0x0f18('0x20')]=qs[_0x0f18('0x20')](_0xb913b2[_0x0f18('0x35')]['limit']);_0x4d2a6b[_0x0f18('0x3d')]=qs[_0x0f18('0x3d')](_0xb913b2[_0x0f18('0x35')][_0x0f18('0x3d')]);}return _0x5d966b[_0x0f18('0x8e')](_0x4d2a6b);}})[_0x0f18('0x27')](function(_0x47df07){if(_0x47df07){return _0x47df07?{'count':_0x23ea7c,'rows':_0x47df07}:null;}})[_0x0f18('0x27')](respondWithResult(_0x599c36,null))[_0x0f18('0x4b')](handleError(_0x599c36,null));};
\ No newline at end of file
+var _0xad95=['keys','filters','intersection','query','attributes','length','hasOwnProperty','nolimit','sort','where','pick','filter','VIRTUAL','merge','options','includeAll','include','findAll','rows','catch','show','fields','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','UserProfileSection','find','userProfileId','UserProfileResource','create','error','body','params','describe','addDisposition','ListId','Disposition','getDispositions','findOne','order','removeDispositions','ids','addContacts','CmContact','tags','isArray','join','each','omit','success','push','errors','message','Malformed\x20request\x20syntax','getContacts','CmCustomField','CustomFields','concat','getContactsCsv','OrderBy','alias','select','cm_contacts','c.ListId\x20=\x20?','field','c.cf_','item','from','cm_contact_has_items','ItemTypeId\x20=\x20?','CmContactId\x20=\x20c.id','additionalPhone_','description','description_additionalPhone_','toString','isEmpty','now','writeFileSync','format','/tmp/list_%d_%s.csv','list_%d_%s.csv','setHeader','Content-type','text/csv','download','transaction','addCustomFields','text','Sequelize','TEXT','number','INTEGER','defaultValue','sequelize','queryInterface','addColumn','cf_%s','getCustomFields','findAndCountAll','getGlobalCustomFields','addAgents','spread','emit','userCmList:save','removeAgents','userCmList:remove','getAgents','User','eml-format','zip-dir','bluebird','mustache','util','path','sox','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','to-csv','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/environment','../../mysqldb','redis','defaults','socket.io-emitter','./cmList.socket','register','sendStatus','end','status','offset','limit','undefined','count','set','Content-Range','json','apply','update','then','destroy','get','Lists','stack','name','send','index','map','CmList','rawAttributes','fieldName','type','key','model'];(function(_0x2a4fe2,_0x3ec53a){var _0x225c4a=function(_0x1eccfa){while(--_0x1eccfa){_0x2a4fe2['push'](_0x2a4fe2['shift']());}};_0x225c4a(++_0x3ec53a);}(_0xad95,0x1b1));var _0x5ad9=function(_0x2bc34d,_0x6c5eef){_0x2bc34d=_0x2bc34d-0x0;var _0x18ce7d=_0xad95[_0x2bc34d];return _0x18ce7d;};'use strict';var emlformat=require(_0x5ad9('0x0'));var rimraf=require('rimraf');var zipdir=require(_0x5ad9('0x1'));var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require('moment');var BPromise=require(_0x5ad9('0x2'));var Mustache=require(_0x5ad9('0x3'));var util=require(_0x5ad9('0x4'));var path=require(_0x5ad9('0x5'));var sox=require(_0x5ad9('0x6'));var csv=require('to-csv');var ejs=require(_0x5ad9('0x7'));var fs=require('fs');var fs_extra=require(_0x5ad9('0x8'));var _=require(_0x5ad9('0x9'));var squel=require(_0x5ad9('0xa'));var crypto=require(_0x5ad9('0xb'));var jsforce=require(_0x5ad9('0xc'));var deskjs=require(_0x5ad9('0xd'));var toCsv=require(_0x5ad9('0xe'));var querystring=require('querystring');var Papa=require(_0x5ad9('0xf'));var Redis=require('ioredis');var authService=require(_0x5ad9('0x10'));var qs=require(_0x5ad9('0x11'));var as=require(_0x5ad9('0x12'));var hardwareService=require(_0x5ad9('0x13'));var logger=require(_0x5ad9('0x14'))(_0x5ad9('0x15'));var utils=require('../../config/utils');var config=require(_0x5ad9('0x16'));var licenseUtil=require('../../config/license/util');var db=require(_0x5ad9('0x17'))['db'];var csv_results;config[_0x5ad9('0x18')]=_[_0x5ad9('0x19')](config['redis'],{'host':'localhost','port':0x18eb});var socket=require(_0x5ad9('0x1a'))(new Redis(config[_0x5ad9('0x18')]));require(_0x5ad9('0x1b'))[_0x5ad9('0x1c')](socket);function respondWithStatusCode(_0x4ade7f,_0x1e7d86){_0x1e7d86=_0x1e7d86||0xcc;return function(_0x3d70ee){if(_0x3d70ee){return _0x4ade7f[_0x5ad9('0x1d')](_0x1e7d86);}return _0x4ade7f['status'](_0x1e7d86)[_0x5ad9('0x1e')]();};}function respondWithResult(_0x219490,_0x489832){_0x489832=_0x489832||0xc8;return function(_0x20025f){if(_0x20025f){return _0x219490[_0x5ad9('0x1f')](_0x489832)['json'](_0x20025f);}};}function respondWithFilteredResult(_0x410830,_0x3d54de){return function(_0x2693b1){if(_0x2693b1){var _0x20e6f6=typeof _0x3d54de[_0x5ad9('0x20')]==='undefined'&&typeof _0x3d54de[_0x5ad9('0x21')]===_0x5ad9('0x22');var _0x5efa03=_0x2693b1[_0x5ad9('0x23')];var _0x585f7e=_0x20e6f6?0x0:_0x3d54de[_0x5ad9('0x20')];var _0x52688a=_0x20e6f6?_0x2693b1[_0x5ad9('0x23')]:_0x3d54de[_0x5ad9('0x20')]+_0x3d54de[_0x5ad9('0x21')];var _0x624a6;if(_0x52688a>=_0x5efa03){_0x52688a=_0x5efa03;_0x624a6=0xc8;}else{_0x624a6=0xce;}_0x410830[_0x5ad9('0x1f')](_0x624a6);return _0x410830[_0x5ad9('0x24')](_0x5ad9('0x25'),_0x585f7e+'-'+_0x52688a+'/'+_0x5efa03)[_0x5ad9('0x26')](_0x2693b1);}return null;};}function patchUpdates(_0x449971){return function(_0x2327ea){try{jsonpatch[_0x5ad9('0x27')](_0x2327ea,_0x449971,!![]);}catch(_0x1a4e55){return BPromise['reject'](_0x1a4e55);}return _0x2327ea['save']();};}function saveUpdates(_0x361ee1,_0x2e1cc8){return function(_0x3cf29f){if(_0x3cf29f){return _0x3cf29f[_0x5ad9('0x28')](_0x361ee1)[_0x5ad9('0x29')](function(_0x483081){return _0x483081;});}return null;};}function removeEntity(_0x2e1a55,_0x36ba95){return function(_0x3a4980){if(_0x3a4980){return _0x3a4980[_0x5ad9('0x2a')]()['then'](function(){var _0x264be8=_0x3a4980[_0x5ad9('0x2b')]({'plain':!![]});var _0x385de7=_0x5ad9('0x2c');return db['UserProfileResource'][_0x5ad9('0x2a')]({'where':{'type':_0x385de7,'resourceId':_0x264be8['id']}})[_0x5ad9('0x29')](function(){return _0x3a4980;});})[_0x5ad9('0x29')](function(){_0x2e1a55[_0x5ad9('0x1f')](0xcc)[_0x5ad9('0x1e')]();});}};}function handleEntityNotFound(_0x32f79b,_0x4688f8){return function(_0x3417e5){if(!_0x3417e5){_0x32f79b['sendStatus'](0x194);}return _0x3417e5;};}function handleError(_0x3692ee,_0x4f86c9){_0x4f86c9=_0x4f86c9||0x1f4;return function(_0x3d38dd){logger['error'](_0x3d38dd[_0x5ad9('0x2d')]);if(_0x3d38dd[_0x5ad9('0x2e')]){delete _0x3d38dd['name'];}_0x3692ee['status'](_0x4f86c9)[_0x5ad9('0x2f')](_0x3d38dd);};}exports[_0x5ad9('0x30')]=function(_0x1f8130,_0x546a4b){var _0x3b171f={},_0x9d4bef={},_0x3c5ae2={'count':0x0,'rows':[]};var _0x4f3e68=_[_0x5ad9('0x31')](db[_0x5ad9('0x32')][_0x5ad9('0x33')],function(_0x86b044){return{'name':_0x86b044[_0x5ad9('0x34')],'type':_0x86b044[_0x5ad9('0x35')][_0x5ad9('0x36')]};});_0x9d4bef[_0x5ad9('0x37')]=_[_0x5ad9('0x31')](_0x4f3e68,_0x5ad9('0x2e'));_0x9d4bef['query']=_[_0x5ad9('0x38')](_0x1f8130['query']);_0x9d4bef[_0x5ad9('0x39')]=_[_0x5ad9('0x3a')](_0x9d4bef[_0x5ad9('0x37')],_0x9d4bef[_0x5ad9('0x3b')]);_0x3b171f[_0x5ad9('0x3c')]=_[_0x5ad9('0x3a')](_0x9d4bef[_0x5ad9('0x37')],qs['fields'](_0x1f8130[_0x5ad9('0x3b')]['fields']));_0x3b171f[_0x5ad9('0x3c')]=_0x3b171f['attributes'][_0x5ad9('0x3d')]?_0x3b171f[_0x5ad9('0x3c')]:_0x9d4bef[_0x5ad9('0x37')];if(!_0x1f8130['query'][_0x5ad9('0x3e')](_0x5ad9('0x3f'))){_0x3b171f[_0x5ad9('0x21')]=qs[_0x5ad9('0x21')](_0x1f8130[_0x5ad9('0x3b')][_0x5ad9('0x21')]);_0x3b171f[_0x5ad9('0x20')]=qs[_0x5ad9('0x20')](_0x1f8130['query']['offset']);}_0x3b171f['order']=qs[_0x5ad9('0x40')](_0x1f8130[_0x5ad9('0x3b')]['sort']);_0x3b171f[_0x5ad9('0x41')]=qs[_0x5ad9('0x39')](_[_0x5ad9('0x42')](_0x1f8130[_0x5ad9('0x3b')],_0x9d4bef['filters']),_0x4f3e68);if(_0x1f8130[_0x5ad9('0x3b')][_0x5ad9('0x43')]){_0x3b171f[_0x5ad9('0x41')]=_['merge'](_0x3b171f[_0x5ad9('0x41')],{'$or':_[_0x5ad9('0x31')](_0x4f3e68,function(_0x44273){if(_0x44273[_0x5ad9('0x35')]!==_0x5ad9('0x44')){var _0x3991b6={};_0x3991b6[_0x44273[_0x5ad9('0x2e')]]={'$like':'%'+_0x1f8130[_0x5ad9('0x3b')][_0x5ad9('0x43')]+'%'};return _0x3991b6;}})});}_0x3b171f=_[_0x5ad9('0x45')]({},_0x3b171f,_0x1f8130[_0x5ad9('0x46')]);var _0x20502f={'where':_0x3b171f['where']};return db['CmList'][_0x5ad9('0x23')](_0x20502f)[_0x5ad9('0x29')](function(_0x2ab120){_0x3c5ae2[_0x5ad9('0x23')]=_0x2ab120;if(_0x1f8130[_0x5ad9('0x3b')][_0x5ad9('0x47')]){_0x3b171f[_0x5ad9('0x48')]=[{'all':!![]}];}return db['CmList'][_0x5ad9('0x49')](_0x3b171f);})[_0x5ad9('0x29')](function(_0x2bfc39){_0x3c5ae2[_0x5ad9('0x4a')]=_0x2bfc39;return _0x3c5ae2;})['then'](respondWithFilteredResult(_0x546a4b,_0x3b171f))[_0x5ad9('0x4b')](handleError(_0x546a4b,null));};exports[_0x5ad9('0x4c')]=function(_0x4fbf8f,_0x1e37f5){var _0x1155dc={'raw':![],'where':{'id':_0x4fbf8f['params']['id']}},_0x1c9952={};_0x1c9952['model']=_[_0x5ad9('0x38')](db[_0x5ad9('0x32')][_0x5ad9('0x33')]);_0x1c9952[_0x5ad9('0x3b')]=_[_0x5ad9('0x38')](_0x4fbf8f[_0x5ad9('0x3b')]);_0x1c9952['filters']=_[_0x5ad9('0x3a')](_0x1c9952[_0x5ad9('0x37')],_0x1c9952[_0x5ad9('0x3b')]);_0x1155dc[_0x5ad9('0x3c')]=_[_0x5ad9('0x3a')](_0x1c9952[_0x5ad9('0x37')],qs[_0x5ad9('0x4d')](_0x4fbf8f[_0x5ad9('0x3b')]['fields']));_0x1155dc[_0x5ad9('0x3c')]=_0x1155dc[_0x5ad9('0x3c')][_0x5ad9('0x3d')]?_0x1155dc[_0x5ad9('0x3c')]:_0x1c9952[_0x5ad9('0x37')];if(_0x4fbf8f[_0x5ad9('0x3b')][_0x5ad9('0x47')]){_0x1155dc[_0x5ad9('0x48')]=[{'all':!![]}];}_0x1155dc=_[_0x5ad9('0x45')]({},_0x1155dc,_0x4fbf8f[_0x5ad9('0x46')]);return db[_0x5ad9('0x32')]['find'](_0x1155dc)['then'](handleEntityNotFound(_0x1e37f5,null))['then'](respondWithResult(_0x1e37f5,null))[_0x5ad9('0x4b')](handleError(_0x1e37f5,null));};exports['create']=function(_0xea5641,_0x17f0bb){return db[_0x5ad9('0x32')]['create'](_0xea5641['body'],{})[_0x5ad9('0x29')](function(_0x548557){var _0x13f315=_0xea5641[_0x5ad9('0x4e')][_0x5ad9('0x2b')]({'plain':!![]});if(!_0x13f315)throw new Error(_0x5ad9('0x4f'));if(_0x13f315['role']===_0x5ad9('0x4e')){var _0x25c076=_0x548557['get']({'plain':!![]});var _0x2e48e7=_0x5ad9('0x2c');return db[_0x5ad9('0x50')][_0x5ad9('0x51')]({'where':{'name':_0x2e48e7,'userProfileId':_0x13f315[_0x5ad9('0x52')]},'raw':!![]})[_0x5ad9('0x29')](function(_0x3d95a6){if(_0x3d95a6&&_0x3d95a6['autoAssociation']===0x0){return db[_0x5ad9('0x53')][_0x5ad9('0x54')]({'name':_0x25c076[_0x5ad9('0x2e')],'resourceId':_0x25c076['id'],'type':_0x3d95a6['name'],'sectionId':_0x3d95a6['id']},{})[_0x5ad9('0x29')](function(){return _0x548557;});}else{return _0x548557;}})['catch'](function(_0x1c8abb){logger[_0x5ad9('0x55')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x1c8abb);throw _0x1c8abb;});}return _0x548557;})[_0x5ad9('0x29')](respondWithResult(_0x17f0bb,0xc9))[_0x5ad9('0x4b')](handleError(_0x17f0bb,null));};exports[_0x5ad9('0x28')]=function(_0x13fe71,_0x5c1c4d){if(_0x13fe71[_0x5ad9('0x56')]['id']){delete _0x13fe71[_0x5ad9('0x56')]['id'];}return db['CmList'][_0x5ad9('0x51')]({'where':{'id':_0x13fe71[_0x5ad9('0x57')]['id']}})[_0x5ad9('0x29')](handleEntityNotFound(_0x5c1c4d,null))[_0x5ad9('0x29')](saveUpdates(_0x13fe71['body'],null))['then'](respondWithResult(_0x5c1c4d,null))[_0x5ad9('0x4b')](handleError(_0x5c1c4d,null));};exports[_0x5ad9('0x2a')]=function(_0x99314a,_0xff3722){return db[_0x5ad9('0x32')][_0x5ad9('0x51')]({'where':{'id':_0x99314a['params']['id']}})[_0x5ad9('0x29')](handleEntityNotFound(_0xff3722,null))['then'](removeEntity(_0xff3722,null))['catch'](handleError(_0xff3722,null));};exports['describe']=function(_0x20a1a4,_0x3b2649){return db[_0x5ad9('0x32')][_0x5ad9('0x58')]()[_0x5ad9('0x29')](respondWithResult(_0x3b2649,null))[_0x5ad9('0x4b')](handleError(_0x3b2649,null));};exports[_0x5ad9('0x59')]=function(_0x2dcb9f,_0x165079,_0x534fb7){if(_0x2dcb9f[_0x5ad9('0x56')]['id']){delete _0x2dcb9f['body']['id'];}return db[_0x5ad9('0x32')][_0x5ad9('0x51')]({'where':{'id':_0x2dcb9f['params']['id']}})['then'](handleEntityNotFound(_0x165079,null))['then'](function(_0x2f09cd){if(_0x2f09cd){_0x2dcb9f['body'][_0x5ad9('0x5a')]=_0x2f09cd['id'];return db[_0x5ad9('0x5b')]['create'](_0x2dcb9f[_0x5ad9('0x56')]);}})['then'](respondWithResult(_0x165079,null))['catch'](handleError(_0x165079,null));};exports[_0x5ad9('0x5c')]=function(_0x2215a0,_0x436df6,_0x3008aa){var _0xd393d9={'raw':![],'where':{}};var _0xba7981={};var _0x5e4284={'count':0x0,'rows':[]};return db[_0x5ad9('0x32')][_0x5ad9('0x5d')]({'where':{'id':_0x2215a0[_0x5ad9('0x57')]['id']}})[_0x5ad9('0x29')](handleEntityNotFound(_0x436df6,null))[_0x5ad9('0x29')](function(_0x38ee0a){if(_0x38ee0a){_0xba7981[_0x5ad9('0x37')]=_[_0x5ad9('0x38')](db[_0x5ad9('0x5b')][_0x5ad9('0x33')]);_0xba7981[_0x5ad9('0x3b')]=_['keys'](_0x2215a0[_0x5ad9('0x3b')]);_0xba7981[_0x5ad9('0x39')]=_[_0x5ad9('0x3a')](_0xba7981[_0x5ad9('0x37')],_0xba7981['query']);_0xd393d9[_0x5ad9('0x3c')]=_[_0x5ad9('0x3a')](_0xba7981[_0x5ad9('0x37')],qs['fields'](_0x2215a0[_0x5ad9('0x3b')]['fields']));_0xd393d9['attributes']=_0xd393d9[_0x5ad9('0x3c')][_0x5ad9('0x3d')]?_0xd393d9[_0x5ad9('0x3c')]:_0xba7981[_0x5ad9('0x37')];if(!_0x2215a0[_0x5ad9('0x3b')][_0x5ad9('0x3e')](_0x5ad9('0x3f'))){_0xd393d9[_0x5ad9('0x21')]=qs[_0x5ad9('0x21')](_0x2215a0[_0x5ad9('0x3b')][_0x5ad9('0x21')]);_0xd393d9[_0x5ad9('0x20')]=qs['offset'](_0x2215a0[_0x5ad9('0x3b')][_0x5ad9('0x20')]);}_0xd393d9[_0x5ad9('0x5e')]=qs[_0x5ad9('0x40')](_0x2215a0['query']['sort']);_0xd393d9[_0x5ad9('0x41')]=qs['filters'](_[_0x5ad9('0x42')](_0x2215a0[_0x5ad9('0x3b')],_0xba7981[_0x5ad9('0x39')]));_0xd393d9[_0x5ad9('0x41')][_0x5ad9('0x5a')]=_0x38ee0a['id'];if(_0x2215a0['query'][_0x5ad9('0x43')]){_0xd393d9[_0x5ad9('0x41')]=_[_0x5ad9('0x45')](_0xd393d9[_0x5ad9('0x41')],{'$or':_[_0x5ad9('0x31')](_0xd393d9['attributes'],function(_0x4f635f){var _0x8cd69f={};_0x8cd69f[_0x4f635f]={'$like':'%'+_0x2215a0[_0x5ad9('0x3b')]['filter']+'%'};return _0x8cd69f;})});}_0xd393d9=_[_0x5ad9('0x45')]({},_0xd393d9,_0x2215a0[_0x5ad9('0x46')]);return db[_0x5ad9('0x5b')][_0x5ad9('0x23')]({'where':_0xd393d9[_0x5ad9('0x41')]})[_0x5ad9('0x29')](function(_0x4966ca){_0x5e4284['count']=_0x4966ca;if(_0x2215a0[_0x5ad9('0x3b')][_0x5ad9('0x47')]){_0xd393d9['include']=[{'all':!![]}];}return db['Disposition'][_0x5ad9('0x49')](_0xd393d9);})[_0x5ad9('0x29')](function(_0x5a082b){_0x5e4284['rows']=_0x5a082b;return _0x5e4284;});}})[_0x5ad9('0x29')](respondWithFilteredResult(_0x436df6,_0xd393d9))[_0x5ad9('0x4b')](handleError(_0x436df6,null));};exports[_0x5ad9('0x5f')]=function(_0x326688,_0x2efe1e,_0x4df4c4){return db[_0x5ad9('0x32')]['find']({'where':{'id':_0x326688[_0x5ad9('0x57')]['id']}})[_0x5ad9('0x29')](handleEntityNotFound(_0x2efe1e,null))[_0x5ad9('0x29')](function(_0x30f354){if(_0x30f354){return _0x30f354['removeDispositions'](_0x326688[_0x5ad9('0x3b')][_0x5ad9('0x60')]);}})[_0x5ad9('0x29')](respondWithStatusCode(_0x2efe1e,null))[_0x5ad9('0x4b')](handleError(_0x2efe1e,null));};exports[_0x5ad9('0x61')]=function(_0x60efc1,_0xddc989,_0x561342){return db[_0x5ad9('0x32')][_0x5ad9('0x51')]({'where':{'id':_0x60efc1[_0x5ad9('0x57')]['id']}})[_0x5ad9('0x29')](handleEntityNotFound(_0xddc989,null))[_0x5ad9('0x29')](function(_0x595114){if(_0x595114){var _0x4155c6=[];var _0x5404af={'success':[],'errors':[]};return db[_0x5ad9('0x62')][_0x5ad9('0x58')]()[_0x5ad9('0x29')](function(_0x330784){if(_0x60efc1['body'][_0x5ad9('0x63')]&&_[_0x5ad9('0x64')](_0x60efc1[_0x5ad9('0x56')]['tags'])){if(_0x60efc1[_0x5ad9('0x56')][_0x5ad9('0x63')]['length']){_0x60efc1[_0x5ad9('0x56')]['tags']=_0x60efc1[_0x5ad9('0x56')]['tags'][_0x5ad9('0x65')](';')+';';}else{_0x60efc1[_0x5ad9('0x56')]['tags']=null;}}else{_0x60efc1['body']['tags']=null;}if(_0x60efc1[_0x5ad9('0x56')]&&_[_0x5ad9('0x64')](_0x60efc1['body'])){for(var _0x4ff148=0x0;_0x4ff148<_0x60efc1['body']['length'];_0x4ff148+=0x1){_0x60efc1[_0x5ad9('0x56')][_0x4ff148][_0x5ad9('0x5a')]=_0x60efc1[_0x5ad9('0x57')]['id'];_0x4155c6['push'](_0x60efc1[_0x5ad9('0x56')][_0x4ff148]);}return BPromise[_0x5ad9('0x66')](_0x4155c6,function(_0x15ff10){return db[_0x5ad9('0x62')][_0x5ad9('0x54')](_[_0x5ad9('0x67')](_0x15ff10,[_0x5ad9('0x60'),'id'])||{},{'fields':_[_0x5ad9('0x38')](_0x330784),'raw':!![]})['then'](function(_0x1391fe){_0x5404af[_0x5ad9('0x68')][_0x5ad9('0x69')](_0x1391fe['dataValues']);})['catch'](function(_0x43da5e){_0x5404af[_0x5ad9('0x6a')][_0x5ad9('0x69')]({'data':_0x15ff10,'error':_0x43da5e[_0x5ad9('0x6b')]});});})[_0x5ad9('0x29')](function(_0x200ff9){return _0x5404af;})[_0x5ad9('0x4b')](function(_0x540b88){return _0x540b88;});}else{_0xddc989[_0x5ad9('0x1f')](0x190)['json']({'message':_0x5ad9('0x6c')});}});}})[_0x5ad9('0x29')](respondWithResult(_0xddc989,null))[_0x5ad9('0x4b')](handleError(_0xddc989,null));};exports[_0x5ad9('0x6d')]=function(_0x49b8e7,_0x50dc78,_0x390a65){var _0x2c80ac;return db[_0x5ad9('0x32')][_0x5ad9('0x51')]({'where':{'id':_0x49b8e7['params']['id']},'include':[{'model':db[_0x5ad9('0x6e')],'as':_0x5ad9('0x6f')}]})[_0x5ad9('0x29')](handleEntityNotFound(_0x50dc78,null))[_0x5ad9('0x29')](function(_0x55d7d5){if(_0x55d7d5){_0x2c80ac=_0x55d7d5;return db[_0x5ad9('0x62')][_0x5ad9('0x33')];}})[_0x5ad9('0x29')](function(_0x2c3f71){if(_0x2c3f71){var _0x357e9f={};var _0x33e63c={};_0x33e63c[_0x5ad9('0x37')]=_[_0x5ad9('0x70')](_[_0x5ad9('0x38')](_0x2c3f71),_[_0x5ad9('0x31')](_0x2c80ac[_0x5ad9('0x6f')],function(_0x3e5496){return util['format']('cf_%d',_0x3e5496['id']);}));_0x33e63c['query']=_[_0x5ad9('0x38')](_0x49b8e7[_0x5ad9('0x3b')]);_0x33e63c['filters']=_['intersection'](_0x33e63c[_0x5ad9('0x37')],_0x33e63c[_0x5ad9('0x3b')]);_0x357e9f[_0x5ad9('0x3c')]=_[_0x5ad9('0x3a')](_0x33e63c['model'],qs[_0x5ad9('0x4d')](_0x49b8e7[_0x5ad9('0x3b')][_0x5ad9('0x4d')]));_0x357e9f[_0x5ad9('0x3c')]=_0x357e9f['attributes'][_0x5ad9('0x3d')]?_0x357e9f[_0x5ad9('0x3c')]:_0x33e63c[_0x5ad9('0x37')];if(!_0x49b8e7[_0x5ad9('0x3b')][_0x5ad9('0x3e')](_0x5ad9('0x3f'))){_0x357e9f[_0x5ad9('0x21')]=qs['limit'](_0x49b8e7[_0x5ad9('0x3b')]['limit']);_0x357e9f['offset']=qs[_0x5ad9('0x20')](_0x49b8e7[_0x5ad9('0x3b')]['offset']);}_0x357e9f['order']=qs[_0x5ad9('0x40')](_0x49b8e7['query'][_0x5ad9('0x40')]);_0x357e9f[_0x5ad9('0x41')]=qs['filters'](_[_0x5ad9('0x42')](_0x49b8e7[_0x5ad9('0x3b')],_0x33e63c['filters']));_0x357e9f['raw']=!![];if(_0x49b8e7['query'][_0x5ad9('0x43')]){_0x357e9f[_0x5ad9('0x41')]=_[_0x5ad9('0x45')](_0x357e9f['where'],{'$or':_[_0x5ad9('0x31')](_0x357e9f[_0x5ad9('0x3c')],function(_0x276870){var _0x2523ec={};_0x2523ec[_0x276870]={'$like':'%'+_0x49b8e7['query'][_0x5ad9('0x43')]+'%'};return _0x2523ec;})});}_0x357e9f=_[_0x5ad9('0x45')]({},_0x357e9f,_0x49b8e7['options']);return _0x2c80ac[_0x5ad9('0x6d')](_0x357e9f);}})[_0x5ad9('0x29')](respondWithResult(_0x50dc78,null))[_0x5ad9('0x4b')](handleError(_0x50dc78,null));};exports[_0x5ad9('0x71')]=function(_0x37e5ea,_0x29885d,_0x472ee7){var _0x495321;var _0x3064f0;var _0x42c796;var _0x74d691=_0x37e5ea['params']['id'];csv_results=[];return db['ContactItemType'][_0x5ad9('0x49')]({'attributes':['id','name'],'raw':!![],'order':[_0x5ad9('0x72')]})[_0x5ad9('0x29')](function(_0x3cdc0c){_0x495321=_0x3cdc0c;var _0x49c0db=_['keys'](db[_0x5ad9('0x62')]['rawAttributes']);return db[_0x5ad9('0x6e')]['findAll']({'raw':!![],'attributes':['id',_0x5ad9('0x73')]})[_0x5ad9('0x29')](function(_0x157c36){_0x3064f0=_0x157c36;var _0x42a285=squel[_0x5ad9('0x74')]()['fields'](_0x49c0db)['from'](_0x5ad9('0x75'),'c')[_0x5ad9('0x41')](_0x5ad9('0x76'),_0x74d691)[_0x5ad9('0x41')]('c.deletedAt\x20is\x20null')['distinct']();for(var _0x1b9b4a=0x0;_0x1b9b4a<_0x3064f0[_0x5ad9('0x3d')];_0x1b9b4a++){_0x42a285[_0x5ad9('0x77')](_0x5ad9('0x78')+_0x3064f0[_0x1b9b4a]['id'],'customField_'+_0x3064f0[_0x1b9b4a][_0x5ad9('0x73')]);}for(var _0x1b9b4a=0x0;_0x1b9b4a<_0x495321['length'];_0x1b9b4a++){_0x42a285['field'](squel[_0x5ad9('0x74')]()[_0x5ad9('0x77')](_0x5ad9('0x79'))[_0x5ad9('0x7a')](_0x5ad9('0x7b'))['where'](_0x5ad9('0x7c'),_0x495321[_0x1b9b4a]['id'])[_0x5ad9('0x41')](_0x5ad9('0x7d')),_0x5ad9('0x7e')+_0x495321[_0x1b9b4a][_0x5ad9('0x2e')]);_0x42a285['field'](squel['select']()[_0x5ad9('0x77')](_0x5ad9('0x7f'))[_0x5ad9('0x7a')](_0x5ad9('0x7b'))[_0x5ad9('0x41')](_0x5ad9('0x7c'),_0x495321[_0x1b9b4a]['id'])[_0x5ad9('0x41')](_0x5ad9('0x7d')),_0x5ad9('0x80')+_0x495321[_0x1b9b4a][_0x5ad9('0x2e')]);}var _0x4a8965=[];_0x4a8965['push'](_0x42a285[_0x5ad9('0x81')]());BPromise[_0x5ad9('0x66')](_0x4a8965,handleQuery)[_0x5ad9('0x29')](function(_0x28c24b){handleQuery(_0x42a285[_0x5ad9('0x81')]());var _0x520239=csv_results[0x0];if(!_[_0x5ad9('0x82')](_0x520239)){var _0x382ece=toCsv(_0x520239);var _0x5a7388=Date[_0x5ad9('0x83')]();fs[_0x5ad9('0x84')](util[_0x5ad9('0x85')](_0x5ad9('0x86'),_0x74d691,_0x5a7388),_0x382ece);_0x29885d['setHeader']('Content-disposition','attachment;\x20filename='+util[_0x5ad9('0x85')](_0x5ad9('0x87'),_0x74d691,_0x5a7388));_0x29885d[_0x5ad9('0x88')](_0x5ad9('0x89'),_0x5ad9('0x8a'));return _0x29885d[_0x5ad9('0x8b')](util[_0x5ad9('0x85')](_0x5ad9('0x86'),_0x74d691,_0x5a7388));}else{return _0x29885d[_0x5ad9('0x1d')](0xcc);}});});});};exports['addCustomField']=function(_0xa358ef,_0xe9f757,_0x2dcf61){var _0x5da1a5;delete _0xa358ef[_0x5ad9('0x56')]['id'];return db[_0x5ad9('0x32')][_0x5ad9('0x5d')]({'where':{'id':_0xa358ef[_0x5ad9('0x57')]['id']}})[_0x5ad9('0x29')](handleEntityNotFound(_0xe9f757,null))[_0x5ad9('0x29')](function(_0x45f17c){if(_0x45f17c){return db['sequelize'][_0x5ad9('0x8c')](function(_0x1f32c3){return db[_0x5ad9('0x6e')][_0x5ad9('0x54')](_0xa358ef[_0x5ad9('0x56')],{'transaction':_0x1f32c3})[_0x5ad9('0x29')](function(_0x13ec36){_0x5da1a5=_0x13ec36;return _0x45f17c[_0x5ad9('0x8d')](_0x13ec36,{'transaction':_0x1f32c3});})['then'](function(){var _0x23509e={'type':db['Sequelize']['TEXT'],'transaction':_0x1f32c3};switch(_0xa358ef['body'][_0x5ad9('0x35')]){case _0x5ad9('0x8e'):_0x23509e[_0x5ad9('0x35')]=db[_0x5ad9('0x8f')][_0x5ad9('0x90')];break;case _0x5ad9('0x91'):_0x23509e[_0x5ad9('0x35')]=db['Sequelize'][_0x5ad9('0x92')];break;case'switch':_0x23509e[_0x5ad9('0x35')]=db[_0x5ad9('0x8f')]['BOOLEAN'];_0x23509e[_0x5ad9('0x93')]=![];break;default:}return db[_0x5ad9('0x94')][_0x5ad9('0x95')][_0x5ad9('0x96')](_0x5ad9('0x75'),util['format'](_0x5ad9('0x97'),_0x5da1a5['id']),_0x23509e);})[_0x5ad9('0x29')](function(){return _0x5da1a5;});});}})[_0x5ad9('0x29')](respondWithResult(_0xe9f757,null))[_0x5ad9('0x4b')](handleError(_0xe9f757,null));};exports[_0x5ad9('0x98')]=function(_0x5aad61,_0xbbebbd,_0x38412a){var _0x553e82={};var _0x40e641={};var _0x2f5082;var _0x1c82db;return db[_0x5ad9('0x32')][_0x5ad9('0x5d')]({'where':{'id':_0x5aad61['params']['id']}})[_0x5ad9('0x29')](handleEntityNotFound(_0xbbebbd,null))[_0x5ad9('0x29')](function(_0x4edff5){if(_0x4edff5){_0x2f5082=_0x4edff5;_0x40e641[_0x5ad9('0x37')]=_[_0x5ad9('0x38')](db[_0x5ad9('0x6e')][_0x5ad9('0x33')]);_0x40e641[_0x5ad9('0x3b')]=_[_0x5ad9('0x38')](_0x5aad61[_0x5ad9('0x3b')]);_0x40e641['filters']=_[_0x5ad9('0x3a')](_0x40e641[_0x5ad9('0x37')],_0x40e641['query']);_0x553e82[_0x5ad9('0x3c')]=_['intersection'](_0x40e641['model'],qs[_0x5ad9('0x4d')](_0x5aad61[_0x5ad9('0x3b')][_0x5ad9('0x4d')]));_0x553e82[_0x5ad9('0x3c')]=_0x553e82[_0x5ad9('0x3c')][_0x5ad9('0x3d')]?_0x553e82[_0x5ad9('0x3c')]:_0x40e641[_0x5ad9('0x37')];_0x553e82[_0x5ad9('0x5e')]=qs[_0x5ad9('0x40')](_0x5aad61[_0x5ad9('0x3b')][_0x5ad9('0x40')]);_0x553e82[_0x5ad9('0x41')]=qs['filters'](_[_0x5ad9('0x42')](_0x5aad61[_0x5ad9('0x3b')],_0x40e641[_0x5ad9('0x39')]));_0x553e82['where']=_['merge'](_0x553e82[_0x5ad9('0x41')],{'$or':[{'ListId':_0x4edff5['id']},{'ListId':null}]});if(_0x5aad61[_0x5ad9('0x3b')][_0x5ad9('0x43')]){_0x553e82['where']=_['merge'](_0x553e82[_0x5ad9('0x41')],{'$or':_['map'](_0x553e82[_0x5ad9('0x3c')],function(_0x3bc8c8){var _0x1781fa={};_0x1781fa[_0x3bc8c8]={'$like':'%'+_0x5aad61[_0x5ad9('0x3b')][_0x5ad9('0x43')]+'%'};return _0x1781fa;})});}_0x553e82=_[_0x5ad9('0x45')]({},_0x553e82,_0x5aad61[_0x5ad9('0x46')]);return db[_0x5ad9('0x6e')][_0x5ad9('0x99')](_0x553e82);}})[_0x5ad9('0x29')](respondWithResult(_0xbbebbd,null))['catch'](handleError(_0xbbebbd,null));};exports[_0x5ad9('0x9a')]=function(_0x3fc293,_0x1407f0){return db[_0x5ad9('0x6e')][_0x5ad9('0x99')]({'where':{'ListId':null}})[_0x5ad9('0x29')](handleEntityNotFound(_0x1407f0,null))['then'](function(_0x4a69a7){return _0x4a69a7;})[_0x5ad9('0x29')](respondWithResult(_0x1407f0,null))['catch'](handleError(_0x1407f0,null));};exports[_0x5ad9('0x9b')]=function(_0x5e13a0,_0x57d657,_0x230935){return db['CmList']['find']({'where':{'id':_0x5e13a0[_0x5ad9('0x57')]['id']}})[_0x5ad9('0x29')](handleEntityNotFound(_0x57d657,null))['then'](function(_0x408730){if(_0x408730){return _0x408730[_0x5ad9('0x9b')](_0x5e13a0['body']['ids'],_[_0x5ad9('0x67')](_0x5e13a0[_0x5ad9('0x56')],[_0x5ad9('0x60'),'id'])||{})[_0x5ad9('0x9c')](function(_0x19aaf0){for(var _0x1aaf1e=0x0;_0x1aaf1e<_0x5e13a0['body']['ids'][_0x5ad9('0x3d')];_0x1aaf1e+=0x1){socket[_0x5ad9('0x9d')](_0x5ad9('0x9e'),{'UserId':Number(_0x5e13a0['body'][_0x5ad9('0x60')][_0x1aaf1e]),'CmListId':Number(_0x5e13a0[_0x5ad9('0x57')]['id'])});}return _0x19aaf0;});}})['then'](respondWithResult(_0x57d657,null))[_0x5ad9('0x4b')](handleError(_0x57d657,null));};exports[_0x5ad9('0x9f')]=function(_0x5db655,_0x4548b8,_0x1843a5){return db[_0x5ad9('0x32')][_0x5ad9('0x51')]({'where':{'id':_0x5db655[_0x5ad9('0x57')]['id']}})[_0x5ad9('0x29')](handleEntityNotFound(_0x4548b8,null))[_0x5ad9('0x29')](function(_0x39afe5){if(_0x39afe5){return _0x39afe5['removeAgents'](_0x5db655[_0x5ad9('0x3b')][_0x5ad9('0x60')])[_0x5ad9('0x29')](function(){if(_['isArray'](_0x5db655[_0x5ad9('0x3b')][_0x5ad9('0x60')])){for(var _0xcabea8=0x0;_0xcabea8<_0x5db655[_0x5ad9('0x3b')][_0x5ad9('0x60')]['length'];_0xcabea8+=0x1){socket[_0x5ad9('0x9d')]('userCmList:remove',{'UserId':Number(_0x5db655[_0x5ad9('0x3b')][_0x5ad9('0x60')][_0xcabea8]),'CmListId':Number(_0x5db655['params']['id'])});}}else{socket[_0x5ad9('0x9d')](_0x5ad9('0xa0'),{'UserId':Number(_0x5db655[_0x5ad9('0x3b')][_0x5ad9('0x60')]),'CmListId':Number(_0x5db655['params']['id'])});}});}})['then'](respondWithStatusCode(_0x4548b8,null))[_0x5ad9('0x4b')](handleError(_0x4548b8,null));};exports[_0x5ad9('0xa1')]=function(_0x462538,_0x345532,_0x11eaa3){var _0x3dd2ad={};var _0x1e074e={};var _0x19425d;var _0x12f6d5;return db['CmList'][_0x5ad9('0x5d')]({'where':{'id':_0x462538[_0x5ad9('0x57')]['id']}})[_0x5ad9('0x29')](handleEntityNotFound(_0x345532,null))['then'](function(_0x27859b){if(_0x27859b){_0x19425d=_0x27859b;_0x1e074e['model']=_[_0x5ad9('0x38')](db[_0x5ad9('0xa2')][_0x5ad9('0x33')]);_0x1e074e[_0x5ad9('0x3b')]=_['keys'](_0x462538[_0x5ad9('0x3b')]);_0x1e074e[_0x5ad9('0x39')]=_[_0x5ad9('0x3a')](_0x1e074e['model'],_0x1e074e[_0x5ad9('0x3b')]);_0x3dd2ad[_0x5ad9('0x3c')]=_[_0x5ad9('0x3a')](_0x1e074e[_0x5ad9('0x37')],qs[_0x5ad9('0x4d')](_0x462538[_0x5ad9('0x3b')][_0x5ad9('0x4d')]));_0x3dd2ad['attributes']=_0x3dd2ad[_0x5ad9('0x3c')]['length']?_0x3dd2ad[_0x5ad9('0x3c')]:_0x1e074e[_0x5ad9('0x37')];_0x3dd2ad[_0x5ad9('0x5e')]=qs[_0x5ad9('0x40')](_0x462538[_0x5ad9('0x3b')][_0x5ad9('0x40')]);_0x3dd2ad[_0x5ad9('0x41')]=qs[_0x5ad9('0x39')](_[_0x5ad9('0x42')](_0x462538[_0x5ad9('0x3b')],_0x1e074e['filters']));if(_0x462538[_0x5ad9('0x3b')][_0x5ad9('0x43')]){_0x3dd2ad['where']=_[_0x5ad9('0x45')](_0x3dd2ad[_0x5ad9('0x41')],{'$or':_[_0x5ad9('0x31')](_0x3dd2ad[_0x5ad9('0x3c')],function(_0x5a213e){var _0x151c46={};_0x151c46[_0x5a213e]={'$like':'%'+_0x462538[_0x5ad9('0x3b')]['filter']+'%'};return _0x151c46;})});}_0x3dd2ad=_['merge']({},_0x3dd2ad,_0x462538[_0x5ad9('0x46')]);return _0x19425d[_0x5ad9('0xa1')](_0x3dd2ad);}})[_0x5ad9('0x29')](function(_0xd09953){if(_0xd09953){_0x12f6d5=_0xd09953[_0x5ad9('0x3d')];if(!_0x462538[_0x5ad9('0x3b')][_0x5ad9('0x3e')](_0x5ad9('0x3f'))){_0x3dd2ad['limit']=qs[_0x5ad9('0x21')](_0x462538['query'][_0x5ad9('0x21')]);_0x3dd2ad['offset']=qs[_0x5ad9('0x20')](_0x462538[_0x5ad9('0x3b')]['offset']);}return _0x19425d['getAgents'](_0x3dd2ad);}})[_0x5ad9('0x29')](function(_0x441947){if(_0x441947){return _0x441947?{'count':_0x12f6d5,'rows':_0x441947}:null;}})['then'](respondWithResult(_0x345532,null))[_0x5ad9('0x4b')](handleError(_0x345532,null));};function handleQuery(_0x115ebc){logger['info'](_0x115ebc);return db[_0x5ad9('0x94')]['query'](_0x115ebc)[_0x5ad9('0x9c')](function(_0x461ebe){csv_results['push'](_0x461ebe);})[_0x5ad9('0x4b')](function(_0xb66c5e){logger[_0x5ad9('0x55')](_0xb66c5e[_0x5ad9('0x6b')]);});}
\ No newline at end of file