Built motion from commit da24aabd.|2.6.20
[motion2.git] / server / api / cmList / cmList.controller.js
index b75433b..7354c03 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xef8c=['querystring','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','localhost','register','sendStatus','status','end','undefined','limit','count','offset','Content-Range','apply','reject','save','update','then','destroy','get','Lists','UserProfileResource','stack','name','send','map','CmList','rawAttributes','fieldName','type','key','model','query','keys','intersection','attributes','fields','length','hasOwnProperty','sort','where','filters','pick','filter','VIRTUAL','includeAll','include','findAll','catch','params','find','create','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','autoAssociation','error','body','describe','addDisposition','ListId','getDispositions','Disposition','nolimit','order','merge','options','removeDispositions','ids','addContacts','CmContact','tags','join','isArray','push','json','Malformed\x20request\x20syntax','getContacts','CmCustomField','CustomFields','concat','format','cf_%d','getContactsCsv','raw','isEmpty','now','/tmp/list_%d_%s.csv','setHeader','Content-disposition','attachment;\x20filename=','list_%d_%s.csv','Content-type','text/csv','download','addCustomField','sequelize','transaction','addCustomFields','text','Sequelize','TEXT','switch','BOOLEAN','defaultValue','queryInterface','addColumn','cm_contacts','findAndCountAll','addAgents','spread','emit','removeAgents','userCmList:remove','findOne','User','getAgents','eml-format','zip-dir','request-promise','moment','bluebird','mustache','util','path','sox','ejs','fs-extra','lodash','crypto','jsforce','desk.js'];(function(_0x4fefc2,_0x4ea655){var _0x1e4192=function(_0x328108){while(--_0x328108){_0x4fefc2['push'](_0x4fefc2['shift']());}};_0x1e4192(++_0x4ea655);}(_0xef8c,0x195));var _0xcef8=function(_0x16b667,_0xadec02){_0x16b667=_0x16b667-0x0;var _0x58620e=_0xef8c[_0x16b667];return _0x58620e;};'use strict';var emlformat=require(_0xcef8('0x0'));var rimraf=require('rimraf');var zipdir=require(_0xcef8('0x1'));var jsonpatch=require('fast-json-patch');var rp=require(_0xcef8('0x2'));var moment=require(_0xcef8('0x3'));var BPromise=require(_0xcef8('0x4'));var Mustache=require(_0xcef8('0x5'));var util=require(_0xcef8('0x6'));var path=require(_0xcef8('0x7'));var sox=require(_0xcef8('0x8'));var csv=require('to-csv');var ejs=require(_0xcef8('0x9'));var fs=require('fs');var fs_extra=require(_0xcef8('0xa'));var _=require(_0xcef8('0xb'));var squel=require('squel');var crypto=require(_0xcef8('0xc'));var jsforce=require(_0xcef8('0xd'));var deskjs=require(_0xcef8('0xe'));var toCsv=require('to-csv');var querystring=require(_0xcef8('0xf'));var Papa=require('papaparse');var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require(_0xcef8('0x10'));var as=require(_0xcef8('0x11'));var hardwareService=require(_0xcef8('0x12'));var logger=require(_0xcef8('0x13'))(_0xcef8('0x14'));var utils=require(_0xcef8('0x15'));var config=require(_0xcef8('0x16'));var licenseUtil=require(_0xcef8('0x17'));var db=require(_0xcef8('0x18'))['db'];config[_0xcef8('0x19')]=_['defaults'](config[_0xcef8('0x19')],{'host':_0xcef8('0x1a'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xcef8('0x19')]));require('./cmList.socket')[_0xcef8('0x1b')](socket);function respondWithStatusCode(_0x272489,_0x5e0167){_0x5e0167=_0x5e0167||0xcc;return function(_0x1fd04d){if(_0x1fd04d){return _0x272489[_0xcef8('0x1c')](_0x5e0167);}return _0x272489[_0xcef8('0x1d')](_0x5e0167)[_0xcef8('0x1e')]();};}function respondWithResult(_0x57b625,_0x5b849f){_0x5b849f=_0x5b849f||0xc8;return function(_0x2099a9){if(_0x2099a9){return _0x57b625[_0xcef8('0x1d')](_0x5b849f)['json'](_0x2099a9);}};}function respondWithFilteredResult(_0x3f9b1c,_0x508925){return function(_0x3db5aa){if(_0x3db5aa){var _0x5a241a=typeof _0x508925['offset']===_0xcef8('0x1f')&&typeof _0x508925[_0xcef8('0x20')]==='undefined';var _0x3dd7d0=_0x3db5aa[_0xcef8('0x21')];var _0x9486f9=_0x5a241a?0x0:_0x508925[_0xcef8('0x22')];var _0x36b443=_0x5a241a?_0x3db5aa[_0xcef8('0x21')]:_0x508925['offset']+_0x508925[_0xcef8('0x20')];var _0x50b5f3;if(_0x36b443>=_0x3dd7d0){_0x36b443=_0x3dd7d0;_0x50b5f3=0xc8;}else{_0x50b5f3=0xce;}_0x3f9b1c['status'](_0x50b5f3);return _0x3f9b1c['set'](_0xcef8('0x23'),_0x9486f9+'-'+_0x36b443+'/'+_0x3dd7d0)['json'](_0x3db5aa);}return null;};}function patchUpdates(_0x4a2dd7){return function(_0xe20a11){try{jsonpatch[_0xcef8('0x24')](_0xe20a11,_0x4a2dd7,!![]);}catch(_0x253fd0){return BPromise[_0xcef8('0x25')](_0x253fd0);}return _0xe20a11[_0xcef8('0x26')]();};}function saveUpdates(_0x1fd2aa,_0x5ea5d3){return function(_0x2e96f7){if(_0x2e96f7){return _0x2e96f7[_0xcef8('0x27')](_0x1fd2aa)[_0xcef8('0x28')](function(_0x5cb083){return _0x5cb083;});}return null;};}function removeEntity(_0x4f596b,_0x1862ff){return function(_0x4442fa){if(_0x4442fa){return _0x4442fa[_0xcef8('0x29')]()['then'](function(){var _0xa126f2=_0x4442fa[_0xcef8('0x2a')]({'plain':!![]});var _0x39c85e=_0xcef8('0x2b');return db[_0xcef8('0x2c')][_0xcef8('0x29')]({'where':{'type':_0x39c85e,'resourceId':_0xa126f2['id']}})[_0xcef8('0x28')](function(){return _0x4442fa;});})[_0xcef8('0x28')](function(){_0x4f596b[_0xcef8('0x1d')](0xcc)[_0xcef8('0x1e')]();});}};}function handleEntityNotFound(_0x2b6d75,_0x3db549){return function(_0x15cecb){if(!_0x15cecb){_0x2b6d75[_0xcef8('0x1c')](0x194);}return _0x15cecb;};}function handleError(_0xc24079,_0x37e0cc){_0x37e0cc=_0x37e0cc||0x1f4;return function(_0xff733e){logger['error'](_0xff733e[_0xcef8('0x2d')]);if(_0xff733e['name']){delete _0xff733e[_0xcef8('0x2e')];}_0xc24079['status'](_0x37e0cc)[_0xcef8('0x2f')](_0xff733e);};}exports['index']=function(_0x52cbeb,_0x5c619e){var _0x15779f={},_0x2a023d={},_0x2a5b0a={'count':0x0,'rows':[]};var _0x3782ce=_[_0xcef8('0x30')](db[_0xcef8('0x31')][_0xcef8('0x32')],function(_0x5c1164){return{'name':_0x5c1164[_0xcef8('0x33')],'type':_0x5c1164[_0xcef8('0x34')][_0xcef8('0x35')]};});_0x2a023d[_0xcef8('0x36')]=_[_0xcef8('0x30')](_0x3782ce,_0xcef8('0x2e'));_0x2a023d[_0xcef8('0x37')]=_[_0xcef8('0x38')](_0x52cbeb['query']);_0x2a023d['filters']=_[_0xcef8('0x39')](_0x2a023d['model'],_0x2a023d['query']);_0x15779f[_0xcef8('0x3a')]=_[_0xcef8('0x39')](_0x2a023d['model'],qs[_0xcef8('0x3b')](_0x52cbeb[_0xcef8('0x37')][_0xcef8('0x3b')]));_0x15779f[_0xcef8('0x3a')]=_0x15779f[_0xcef8('0x3a')][_0xcef8('0x3c')]?_0x15779f[_0xcef8('0x3a')]:_0x2a023d[_0xcef8('0x36')];if(!_0x52cbeb['query'][_0xcef8('0x3d')]('nolimit')){_0x15779f['limit']=qs[_0xcef8('0x20')](_0x52cbeb[_0xcef8('0x37')]['limit']);_0x15779f['offset']=qs[_0xcef8('0x22')](_0x52cbeb[_0xcef8('0x37')]['offset']);}_0x15779f['order']=qs[_0xcef8('0x3e')](_0x52cbeb[_0xcef8('0x37')][_0xcef8('0x3e')]);_0x15779f[_0xcef8('0x3f')]=qs[_0xcef8('0x40')](_[_0xcef8('0x41')](_0x52cbeb[_0xcef8('0x37')],_0x2a023d[_0xcef8('0x40')]),_0x3782ce);if(_0x52cbeb['query'][_0xcef8('0x42')]){_0x15779f['where']=_['merge'](_0x15779f[_0xcef8('0x3f')],{'$or':_['map'](_0x3782ce,function(_0x54ff45){if(_0x54ff45[_0xcef8('0x34')]!==_0xcef8('0x43')){var _0x49671a={};_0x49671a[_0x54ff45['name']]={'$like':'%'+_0x52cbeb['query'][_0xcef8('0x42')]+'%'};return _0x49671a;}})});}_0x15779f=_['merge']({},_0x15779f,_0x52cbeb['options']);var _0x4e9bda={'where':_0x15779f[_0xcef8('0x3f')]};return db[_0xcef8('0x31')][_0xcef8('0x21')](_0x4e9bda)['then'](function(_0x4b77e6){_0x2a5b0a[_0xcef8('0x21')]=_0x4b77e6;if(_0x52cbeb['query'][_0xcef8('0x44')]){_0x15779f[_0xcef8('0x45')]=[{'all':!![]}];}return db[_0xcef8('0x31')][_0xcef8('0x46')](_0x15779f);})['then'](function(_0x8a1891){_0x2a5b0a['rows']=_0x8a1891;return _0x2a5b0a;})[_0xcef8('0x28')](respondWithFilteredResult(_0x5c619e,_0x15779f))[_0xcef8('0x47')](handleError(_0x5c619e,null));};exports['show']=function(_0x16ff36,_0xaeca66){var _0x288a61={'raw':![],'where':{'id':_0x16ff36[_0xcef8('0x48')]['id']}},_0x1b60de={};_0x1b60de[_0xcef8('0x36')]=_[_0xcef8('0x38')](db[_0xcef8('0x31')][_0xcef8('0x32')]);_0x1b60de[_0xcef8('0x37')]=_[_0xcef8('0x38')](_0x16ff36[_0xcef8('0x37')]);_0x1b60de[_0xcef8('0x40')]=_['intersection'](_0x1b60de['model'],_0x1b60de[_0xcef8('0x37')]);_0x288a61[_0xcef8('0x3a')]=_['intersection'](_0x1b60de[_0xcef8('0x36')],qs[_0xcef8('0x3b')](_0x16ff36['query'][_0xcef8('0x3b')]));_0x288a61[_0xcef8('0x3a')]=_0x288a61['attributes']['length']?_0x288a61[_0xcef8('0x3a')]:_0x1b60de[_0xcef8('0x36')];if(_0x16ff36[_0xcef8('0x37')][_0xcef8('0x44')]){_0x288a61['include']=[{'all':!![]}];}_0x288a61=_['merge']({},_0x288a61,_0x16ff36['options']);return db['CmList'][_0xcef8('0x49')](_0x288a61)[_0xcef8('0x28')](handleEntityNotFound(_0xaeca66,null))[_0xcef8('0x28')](respondWithResult(_0xaeca66,null))['catch'](handleError(_0xaeca66,null));};exports[_0xcef8('0x4a')]=function(_0x907d6c,_0x49019b){return db[_0xcef8('0x31')][_0xcef8('0x4a')](_0x907d6c['body'],{})[_0xcef8('0x28')](function(_0x4f0472){var _0x8457ca=_0x907d6c[_0xcef8('0x4b')][_0xcef8('0x2a')]({'plain':!![]});if(!_0x8457ca)throw new Error(_0xcef8('0x4c'));if(_0x8457ca[_0xcef8('0x4d')]===_0xcef8('0x4b')){var _0x30c727=_0x4f0472[_0xcef8('0x2a')]({'plain':!![]});var _0x4b56c1=_0xcef8('0x2b');return db['UserProfileSection']['find']({'where':{'name':_0x4b56c1,'userProfileId':_0x8457ca['userProfileId']},'raw':!![]})[_0xcef8('0x28')](function(_0x32b272){if(_0x32b272&&_0x32b272[_0xcef8('0x4e')]===0x0){return db['UserProfileResource'][_0xcef8('0x4a')]({'name':_0x30c727['name'],'resourceId':_0x30c727['id'],'type':_0x32b272[_0xcef8('0x2e')],'sectionId':_0x32b272['id']},{})[_0xcef8('0x28')](function(){return _0x4f0472;});}else{return _0x4f0472;}})['catch'](function(_0xc5794e){logger[_0xcef8('0x4f')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0xc5794e);throw _0xc5794e;});}return _0x4f0472;})[_0xcef8('0x28')](respondWithResult(_0x49019b,0xc9))[_0xcef8('0x47')](handleError(_0x49019b,null));};exports['update']=function(_0x34b19,_0x1ca854){if(_0x34b19[_0xcef8('0x50')]['id']){delete _0x34b19[_0xcef8('0x50')]['id'];}return db['CmList'][_0xcef8('0x49')]({'where':{'id':_0x34b19[_0xcef8('0x48')]['id']}})[_0xcef8('0x28')](handleEntityNotFound(_0x1ca854,null))[_0xcef8('0x28')](saveUpdates(_0x34b19[_0xcef8('0x50')],null))[_0xcef8('0x28')](respondWithResult(_0x1ca854,null))[_0xcef8('0x47')](handleError(_0x1ca854,null));};exports['destroy']=function(_0x131430,_0x486a49){return db[_0xcef8('0x31')][_0xcef8('0x49')]({'where':{'id':_0x131430[_0xcef8('0x48')]['id']}})['then'](handleEntityNotFound(_0x486a49,null))[_0xcef8('0x28')](removeEntity(_0x486a49,null))['catch'](handleError(_0x486a49,null));};exports['describe']=function(_0x5d7fc9,_0x2ef096){return db[_0xcef8('0x31')][_0xcef8('0x51')]()[_0xcef8('0x28')](respondWithResult(_0x2ef096,null))[_0xcef8('0x47')](handleError(_0x2ef096,null));};exports[_0xcef8('0x52')]=function(_0x29efa2,_0x43da93,_0x3ae031){if(_0x29efa2[_0xcef8('0x50')]['id']){delete _0x29efa2['body']['id'];}return db[_0xcef8('0x31')]['find']({'where':{'id':_0x29efa2[_0xcef8('0x48')]['id']}})['then'](handleEntityNotFound(_0x43da93,null))[_0xcef8('0x28')](function(_0x2ffa98){if(_0x2ffa98){_0x29efa2[_0xcef8('0x50')][_0xcef8('0x53')]=_0x2ffa98['id'];return db['Disposition'][_0xcef8('0x4a')](_0x29efa2[_0xcef8('0x50')]);}})[_0xcef8('0x28')](respondWithResult(_0x43da93,null))['catch'](handleError(_0x43da93,null));};exports[_0xcef8('0x54')]=function(_0x5e8829,_0x3a90ed,_0x5a19ad){var _0x4245ad={'raw':![],'where':{}};var _0x280957={};var _0x9666fd={'count':0x0,'rows':[]};return db[_0xcef8('0x31')]['findOne']({'where':{'id':_0x5e8829[_0xcef8('0x48')]['id']}})[_0xcef8('0x28')](handleEntityNotFound(_0x3a90ed,null))[_0xcef8('0x28')](function(_0xcab1da){if(_0xcab1da){_0x280957['model']=_[_0xcef8('0x38')](db[_0xcef8('0x55')][_0xcef8('0x32')]);_0x280957[_0xcef8('0x37')]=_[_0xcef8('0x38')](_0x5e8829[_0xcef8('0x37')]);_0x280957[_0xcef8('0x40')]=_['intersection'](_0x280957[_0xcef8('0x36')],_0x280957[_0xcef8('0x37')]);_0x4245ad[_0xcef8('0x3a')]=_[_0xcef8('0x39')](_0x280957['model'],qs[_0xcef8('0x3b')](_0x5e8829[_0xcef8('0x37')]['fields']));_0x4245ad[_0xcef8('0x3a')]=_0x4245ad[_0xcef8('0x3a')]['length']?_0x4245ad[_0xcef8('0x3a')]:_0x280957['model'];if(!_0x5e8829[_0xcef8('0x37')]['hasOwnProperty'](_0xcef8('0x56'))){_0x4245ad[_0xcef8('0x20')]=qs[_0xcef8('0x20')](_0x5e8829[_0xcef8('0x37')]['limit']);_0x4245ad['offset']=qs[_0xcef8('0x22')](_0x5e8829['query'][_0xcef8('0x22')]);}_0x4245ad[_0xcef8('0x57')]=qs[_0xcef8('0x3e')](_0x5e8829[_0xcef8('0x37')][_0xcef8('0x3e')]);_0x4245ad[_0xcef8('0x3f')]=qs[_0xcef8('0x40')](_[_0xcef8('0x41')](_0x5e8829[_0xcef8('0x37')],_0x280957[_0xcef8('0x40')]));_0x4245ad['where'][_0xcef8('0x53')]=_0xcab1da['id'];if(_0x5e8829['query'][_0xcef8('0x42')]){_0x4245ad[_0xcef8('0x3f')]=_['merge'](_0x4245ad['where'],{'$or':_[_0xcef8('0x30')](_0x4245ad[_0xcef8('0x3a')],function(_0x29c3e4){var _0xef015e={};_0xef015e[_0x29c3e4]={'$like':'%'+_0x5e8829[_0xcef8('0x37')]['filter']+'%'};return _0xef015e;})});}_0x4245ad=_[_0xcef8('0x58')]({},_0x4245ad,_0x5e8829[_0xcef8('0x59')]);return db[_0xcef8('0x55')][_0xcef8('0x21')]({'where':_0x4245ad['where']})[_0xcef8('0x28')](function(_0x16c17e){_0x9666fd[_0xcef8('0x21')]=_0x16c17e;if(_0x5e8829[_0xcef8('0x37')][_0xcef8('0x44')]){_0x4245ad[_0xcef8('0x45')]=[{'all':!![]}];}return db['Disposition'][_0xcef8('0x46')](_0x4245ad);})[_0xcef8('0x28')](function(_0x380db8){_0x9666fd['rows']=_0x380db8;return _0x9666fd;});}})[_0xcef8('0x28')](respondWithFilteredResult(_0x3a90ed,_0x4245ad))[_0xcef8('0x47')](handleError(_0x3a90ed,null));};exports[_0xcef8('0x5a')]=function(_0x478c85,_0x519dae,_0x10eb57){return db[_0xcef8('0x31')][_0xcef8('0x49')]({'where':{'id':_0x478c85[_0xcef8('0x48')]['id']}})[_0xcef8('0x28')](handleEntityNotFound(_0x519dae,null))[_0xcef8('0x28')](function(_0x108201){if(_0x108201){return _0x108201[_0xcef8('0x5a')](_0x478c85[_0xcef8('0x37')][_0xcef8('0x5b')]);}})['then'](respondWithStatusCode(_0x519dae,null))[_0xcef8('0x47')](handleError(_0x519dae,null));};exports[_0xcef8('0x5c')]=function(_0x139da5,_0x43cdf9,_0x2510bf){return db[_0xcef8('0x31')][_0xcef8('0x49')]({'where':{'id':_0x139da5[_0xcef8('0x48')]['id']}})['then'](handleEntityNotFound(_0x43cdf9,null))[_0xcef8('0x28')](function(_0x152aaf){if(_0x152aaf){var _0x5a67dc=[];var _0x31c3a1={'success':[],'errors':[]};return db[_0xcef8('0x5d')][_0xcef8('0x51')]()[_0xcef8('0x28')](function(_0x5619a9){if(_0x139da5[_0xcef8('0x50')][_0xcef8('0x5e')]&&_['isArray'](_0x139da5['body'][_0xcef8('0x5e')])){if(_0x139da5['body'][_0xcef8('0x5e')]['length']){_0x139da5[_0xcef8('0x50')][_0xcef8('0x5e')]=_0x139da5[_0xcef8('0x50')]['tags'][_0xcef8('0x5f')](';')+';';}else{_0x139da5[_0xcef8('0x50')][_0xcef8('0x5e')]=null;}}else{_0x139da5[_0xcef8('0x50')]['tags']=null;}if(_0x139da5['body']&&_[_0xcef8('0x60')](_0x139da5[_0xcef8('0x50')])){for(var _0x25083b=0x0;_0x25083b<_0x139da5['body'][_0xcef8('0x3c')];_0x25083b+=0x1){_0x139da5[_0xcef8('0x50')][_0x25083b][_0xcef8('0x53')]=_0x139da5['params']['id'];_0x5a67dc[_0xcef8('0x61')](_0x139da5['body'][_0x25083b]);}return BPromise['each'](_0x5a67dc,function(_0x5144fd){return db['CmContact']['create'](_['omit'](_0x5144fd,[_0xcef8('0x5b'),'id'])||{},{'fields':_['keys'](_0x5619a9),'raw':!![]})[_0xcef8('0x28')](function(_0x307106){_0x31c3a1['success'][_0xcef8('0x61')](_0x307106['dataValues']);})[_0xcef8('0x47')](function(_0x2b3f87){_0x31c3a1['errors'][_0xcef8('0x61')]({'data':_0x5144fd,'error':_0x2b3f87['message']});});})[_0xcef8('0x28')](function(_0x26f984){return _0x31c3a1;})['catch'](function(_0x55b76a){return _0x55b76a;});}else{_0x43cdf9[_0xcef8('0x1d')](0x190)[_0xcef8('0x62')]({'message':_0xcef8('0x63')});}});}})[_0xcef8('0x28')](respondWithResult(_0x43cdf9,null))[_0xcef8('0x47')](handleError(_0x43cdf9,null));};exports[_0xcef8('0x64')]=function(_0x2d4185,_0x234bfa,_0x598f48){var _0x546cc8;return db[_0xcef8('0x31')][_0xcef8('0x49')]({'where':{'id':_0x2d4185[_0xcef8('0x48')]['id']},'include':[{'model':db[_0xcef8('0x65')],'as':_0xcef8('0x66')}]})[_0xcef8('0x28')](handleEntityNotFound(_0x234bfa,null))[_0xcef8('0x28')](function(_0x343a3e){if(_0x343a3e){_0x546cc8=_0x343a3e;return db[_0xcef8('0x5d')]['rawAttributes'];}})[_0xcef8('0x28')](function(_0x2dfd3a){if(_0x2dfd3a){var _0x48e1ee={};var _0x4e8b9a={};_0x4e8b9a[_0xcef8('0x36')]=_[_0xcef8('0x67')](_[_0xcef8('0x38')](_0x2dfd3a),_[_0xcef8('0x30')](_0x546cc8[_0xcef8('0x66')],function(_0x31c3a0){return util[_0xcef8('0x68')](_0xcef8('0x69'),_0x31c3a0['id']);}));_0x4e8b9a[_0xcef8('0x37')]=_['keys'](_0x2d4185[_0xcef8('0x37')]);_0x4e8b9a['filters']=_[_0xcef8('0x39')](_0x4e8b9a['model'],_0x4e8b9a['query']);_0x48e1ee[_0xcef8('0x3a')]=_['intersection'](_0x4e8b9a[_0xcef8('0x36')],qs[_0xcef8('0x3b')](_0x2d4185[_0xcef8('0x37')][_0xcef8('0x3b')]));_0x48e1ee[_0xcef8('0x3a')]=_0x48e1ee[_0xcef8('0x3a')][_0xcef8('0x3c')]?_0x48e1ee[_0xcef8('0x3a')]:_0x4e8b9a['model'];if(!_0x2d4185['query'][_0xcef8('0x3d')](_0xcef8('0x56'))){_0x48e1ee[_0xcef8('0x20')]=qs[_0xcef8('0x20')](_0x2d4185[_0xcef8('0x37')][_0xcef8('0x20')]);_0x48e1ee[_0xcef8('0x22')]=qs[_0xcef8('0x22')](_0x2d4185[_0xcef8('0x37')][_0xcef8('0x22')]);}_0x48e1ee[_0xcef8('0x57')]=qs[_0xcef8('0x3e')](_0x2d4185['query'][_0xcef8('0x3e')]);_0x48e1ee[_0xcef8('0x3f')]=qs[_0xcef8('0x40')](_[_0xcef8('0x41')](_0x2d4185[_0xcef8('0x37')],_0x4e8b9a[_0xcef8('0x40')]));_0x48e1ee['raw']=!![];if(_0x2d4185[_0xcef8('0x37')][_0xcef8('0x42')]){_0x48e1ee['where']=_[_0xcef8('0x58')](_0x48e1ee[_0xcef8('0x3f')],{'$or':_['map'](_0x48e1ee[_0xcef8('0x3a')],function(_0x51d61c){var _0x4c3636={};_0x4c3636[_0x51d61c]={'$like':'%'+_0x2d4185['query'][_0xcef8('0x42')]+'%'};return _0x4c3636;})});}_0x48e1ee=_[_0xcef8('0x58')]({},_0x48e1ee,_0x2d4185['options']);return _0x546cc8[_0xcef8('0x64')](_0x48e1ee);}})[_0xcef8('0x28')](respondWithResult(_0x234bfa,null))[_0xcef8('0x47')](handleError(_0x234bfa,null));};exports[_0xcef8('0x6a')]=function(_0x5b1c62,_0x15dced,_0xf63a20){var _0x193132;return db[_0xcef8('0x31')][_0xcef8('0x49')]({'where':{'id':_0x5b1c62[_0xcef8('0x48')]['id']},'include':[{'model':db['CmCustomField'],'as':_0xcef8('0x66')}]})[_0xcef8('0x28')](handleEntityNotFound(_0x15dced,null))[_0xcef8('0x28')](function(_0x130570){if(_0x130570){_0x193132=_0x130570;return db[_0xcef8('0x5d')][_0xcef8('0x32')];}})[_0xcef8('0x28')](function(_0x2c0114){if(_0x2c0114){var _0x2601cb={};var _0x772b8d={};_0x772b8d[_0xcef8('0x36')]=_[_0xcef8('0x67')](_[_0xcef8('0x38')](_0x2c0114),_[_0xcef8('0x30')](_0x193132[_0xcef8('0x66')],function(_0x9561c){return util[_0xcef8('0x68')](_0xcef8('0x69'),_0x9561c['id']);}));_0x772b8d[_0xcef8('0x37')]=_['keys'](_0x5b1c62[_0xcef8('0x37')]);_0x772b8d['filters']=_[_0xcef8('0x39')](_0x772b8d[_0xcef8('0x36')],_0x772b8d[_0xcef8('0x37')]);_0x2601cb['attributes']=_[_0xcef8('0x39')](_0x772b8d[_0xcef8('0x36')],qs[_0xcef8('0x3b')](_0x5b1c62[_0xcef8('0x37')][_0xcef8('0x3b')]));_0x2601cb[_0xcef8('0x3a')]=_0x2601cb[_0xcef8('0x3a')][_0xcef8('0x3c')]?_0x2601cb['attributes']:_0x772b8d['model'];if(!_0x5b1c62[_0xcef8('0x37')][_0xcef8('0x3d')]('nolimit')){_0x2601cb['limit']=qs[_0xcef8('0x20')](_0x5b1c62[_0xcef8('0x37')][_0xcef8('0x20')]);_0x2601cb['offset']=qs[_0xcef8('0x22')](_0x5b1c62[_0xcef8('0x37')][_0xcef8('0x22')]);}_0x2601cb[_0xcef8('0x57')]=qs[_0xcef8('0x3e')](_0x5b1c62[_0xcef8('0x37')]['sort']);_0x2601cb[_0xcef8('0x3f')]=qs[_0xcef8('0x40')](_[_0xcef8('0x41')](_0x5b1c62['query'],_0x772b8d['filters']));_0x2601cb[_0xcef8('0x6b')]=!![];if(_0x5b1c62[_0xcef8('0x37')]['filter']){_0x2601cb[_0xcef8('0x3f')]=_[_0xcef8('0x58')](_0x2601cb[_0xcef8('0x3f')],{'$or':_[_0xcef8('0x30')](_0x2601cb[_0xcef8('0x3a')],function(_0x27e2d3){var _0x3d7821={};_0x3d7821[_0x27e2d3]={'$like':'%'+_0x5b1c62[_0xcef8('0x37')][_0xcef8('0x42')]+'%'};return _0x3d7821;})});}_0x2601cb=_[_0xcef8('0x58')]({},_0x2601cb,_0x5b1c62[_0xcef8('0x59')]);return _0x193132[_0xcef8('0x64')](_0x2601cb);}})[_0xcef8('0x28')](function(_0x36c992){if(!_[_0xcef8('0x6c')](_0x36c992)){var _0x3766f0=toCsv(_0x36c992);var _0x531e6b=Date[_0xcef8('0x6d')]();fs['writeFileSync'](util['format'](_0xcef8('0x6e'),_0x193132['id'],_0x531e6b),_0x3766f0);_0x15dced[_0xcef8('0x6f')](_0xcef8('0x70'),_0xcef8('0x71')+util[_0xcef8('0x68')](_0xcef8('0x72'),_0x193132['id'],_0x531e6b));_0x15dced[_0xcef8('0x6f')](_0xcef8('0x73'),_0xcef8('0x74'));return _0x15dced[_0xcef8('0x75')](util[_0xcef8('0x68')]('/tmp/list_%d_%s.csv',_0x193132['id'],_0x531e6b));}else{return _0x15dced[_0xcef8('0x1c')](0xcc);}})[_0xcef8('0x47')](handleError(_0x15dced,null));};exports[_0xcef8('0x76')]=function(_0x542c7f,_0x410e88,_0x142a8f){var _0x2dbe94;delete _0x542c7f[_0xcef8('0x50')]['id'];return db['CmList']['findOne']({'where':{'id':_0x542c7f['params']['id']}})['then'](handleEntityNotFound(_0x410e88,null))[_0xcef8('0x28')](function(_0x168388){if(_0x168388){return db[_0xcef8('0x77')][_0xcef8('0x78')](function(_0xcff59c){return db[_0xcef8('0x65')][_0xcef8('0x4a')](_0x542c7f['body'],{'transaction':_0xcff59c})[_0xcef8('0x28')](function(_0x2616d0){_0x2dbe94=_0x2616d0;return _0x168388[_0xcef8('0x79')](_0x2616d0,{'transaction':_0xcff59c});})[_0xcef8('0x28')](function(){var _0x1f53e2={'type':db['Sequelize']['TEXT'],'transaction':_0xcff59c};switch(_0x542c7f[_0xcef8('0x50')][_0xcef8('0x34')]){case _0xcef8('0x7a'):_0x1f53e2[_0xcef8('0x34')]=db[_0xcef8('0x7b')][_0xcef8('0x7c')];break;case'number':_0x1f53e2[_0xcef8('0x34')]=db[_0xcef8('0x7b')]['INTEGER'];break;case _0xcef8('0x7d'):_0x1f53e2[_0xcef8('0x34')]=db[_0xcef8('0x7b')][_0xcef8('0x7e')];_0x1f53e2[_0xcef8('0x7f')]=![];break;default:}return db[_0xcef8('0x77')][_0xcef8('0x80')][_0xcef8('0x81')](_0xcef8('0x82'),util[_0xcef8('0x68')]('cf_%s',_0x2dbe94['id']),_0x1f53e2);})[_0xcef8('0x28')](function(){return _0x2dbe94;});});}})['then'](respondWithResult(_0x410e88,null))['catch'](handleError(_0x410e88,null));};exports['getCustomFields']=function(_0x5d1262,_0x217a80,_0x3f67de){var _0xbc0d85={};var _0x4c0a54={};var _0x4fce5e;var _0x4faf5d;return db[_0xcef8('0x31')]['findOne']({'where':{'id':_0x5d1262['params']['id']}})['then'](handleEntityNotFound(_0x217a80,null))[_0xcef8('0x28')](function(_0x3c8274){if(_0x3c8274){_0x4fce5e=_0x3c8274;_0x4c0a54[_0xcef8('0x36')]=_[_0xcef8('0x38')](db['CmCustomField'][_0xcef8('0x32')]);_0x4c0a54[_0xcef8('0x37')]=_[_0xcef8('0x38')](_0x5d1262[_0xcef8('0x37')]);_0x4c0a54[_0xcef8('0x40')]=_[_0xcef8('0x39')](_0x4c0a54[_0xcef8('0x36')],_0x4c0a54[_0xcef8('0x37')]);_0xbc0d85[_0xcef8('0x3a')]=_[_0xcef8('0x39')](_0x4c0a54[_0xcef8('0x36')],qs[_0xcef8('0x3b')](_0x5d1262[_0xcef8('0x37')][_0xcef8('0x3b')]));_0xbc0d85[_0xcef8('0x3a')]=_0xbc0d85[_0xcef8('0x3a')][_0xcef8('0x3c')]?_0xbc0d85['attributes']:_0x4c0a54[_0xcef8('0x36')];_0xbc0d85[_0xcef8('0x57')]=qs['sort'](_0x5d1262[_0xcef8('0x37')]['sort']);_0xbc0d85[_0xcef8('0x3f')]=qs['filters'](_[_0xcef8('0x41')](_0x5d1262[_0xcef8('0x37')],_0x4c0a54[_0xcef8('0x40')]));_0xbc0d85['where']=_['merge'](_0xbc0d85[_0xcef8('0x3f')],{'$or':[{'ListId':_0x3c8274['id']},{'ListId':null}]});if(_0x5d1262[_0xcef8('0x37')]['filter']){_0xbc0d85[_0xcef8('0x3f')]=_[_0xcef8('0x58')](_0xbc0d85['where'],{'$or':_[_0xcef8('0x30')](_0xbc0d85[_0xcef8('0x3a')],function(_0x47f7d8){var _0x48ff48={};_0x48ff48[_0x47f7d8]={'$like':'%'+_0x5d1262[_0xcef8('0x37')][_0xcef8('0x42')]+'%'};return _0x48ff48;})});}_0xbc0d85=_[_0xcef8('0x58')]({},_0xbc0d85,_0x5d1262['options']);return db[_0xcef8('0x65')][_0xcef8('0x83')](_0xbc0d85);}})[_0xcef8('0x28')](respondWithResult(_0x217a80,null))[_0xcef8('0x47')](handleError(_0x217a80,null));};exports[_0xcef8('0x84')]=function(_0x4f4d62,_0x322529,_0x768cac){return db[_0xcef8('0x31')][_0xcef8('0x49')]({'where':{'id':_0x4f4d62[_0xcef8('0x48')]['id']}})[_0xcef8('0x28')](handleEntityNotFound(_0x322529,null))[_0xcef8('0x28')](function(_0x21120f){if(_0x21120f){return _0x21120f[_0xcef8('0x84')](_0x4f4d62[_0xcef8('0x50')][_0xcef8('0x5b')],_['omit'](_0x4f4d62[_0xcef8('0x50')],[_0xcef8('0x5b'),'id'])||{})[_0xcef8('0x85')](function(_0x559a41){for(var _0x4f8336=0x0;_0x4f8336<_0x4f4d62['body'][_0xcef8('0x5b')][_0xcef8('0x3c')];_0x4f8336+=0x1){socket[_0xcef8('0x86')]('userCmList:save',{'UserId':Number(_0x4f4d62[_0xcef8('0x50')]['ids'][_0x4f8336]),'CmListId':Number(_0x4f4d62[_0xcef8('0x48')]['id'])});}return _0x559a41;});}})[_0xcef8('0x28')](respondWithResult(_0x322529,null))[_0xcef8('0x47')](handleError(_0x322529,null));};exports['removeAgents']=function(_0x31b0c2,_0x1d7173,_0x474258){return db[_0xcef8('0x31')][_0xcef8('0x49')]({'where':{'id':_0x31b0c2[_0xcef8('0x48')]['id']}})['then'](handleEntityNotFound(_0x1d7173,null))['then'](function(_0x3dcb3a){if(_0x3dcb3a){return _0x3dcb3a[_0xcef8('0x87')](_0x31b0c2[_0xcef8('0x37')][_0xcef8('0x5b')])[_0xcef8('0x28')](function(){if(_['isArray'](_0x31b0c2[_0xcef8('0x37')]['ids'])){for(var _0x4acdcc=0x0;_0x4acdcc<_0x31b0c2[_0xcef8('0x37')][_0xcef8('0x5b')][_0xcef8('0x3c')];_0x4acdcc+=0x1){socket['emit'](_0xcef8('0x88'),{'UserId':Number(_0x31b0c2['query'][_0xcef8('0x5b')][_0x4acdcc]),'CmListId':Number(_0x31b0c2['params']['id'])});}}else{socket['emit']('userCmList:remove',{'UserId':Number(_0x31b0c2[_0xcef8('0x37')][_0xcef8('0x5b')]),'CmListId':Number(_0x31b0c2['params']['id'])});}});}})[_0xcef8('0x28')](respondWithStatusCode(_0x1d7173,null))[_0xcef8('0x47')](handleError(_0x1d7173,null));};exports['getAgents']=function(_0x4007fc,_0x29fbe0,_0x4a2768){var _0x2b6ba3={};var _0x3999ce={};var _0x3d7057;var _0x291164;return db['CmList'][_0xcef8('0x89')]({'where':{'id':_0x4007fc[_0xcef8('0x48')]['id']}})[_0xcef8('0x28')](handleEntityNotFound(_0x29fbe0,null))['then'](function(_0x28f250){if(_0x28f250){_0x3d7057=_0x28f250;_0x3999ce[_0xcef8('0x36')]=_['keys'](db[_0xcef8('0x8a')][_0xcef8('0x32')]);_0x3999ce[_0xcef8('0x37')]=_[_0xcef8('0x38')](_0x4007fc[_0xcef8('0x37')]);_0x3999ce['filters']=_[_0xcef8('0x39')](_0x3999ce[_0xcef8('0x36')],_0x3999ce[_0xcef8('0x37')]);_0x2b6ba3[_0xcef8('0x3a')]=_[_0xcef8('0x39')](_0x3999ce[_0xcef8('0x36')],qs[_0xcef8('0x3b')](_0x4007fc['query']['fields']));_0x2b6ba3[_0xcef8('0x3a')]=_0x2b6ba3[_0xcef8('0x3a')][_0xcef8('0x3c')]?_0x2b6ba3[_0xcef8('0x3a')]:_0x3999ce[_0xcef8('0x36')];_0x2b6ba3[_0xcef8('0x57')]=qs['sort'](_0x4007fc[_0xcef8('0x37')][_0xcef8('0x3e')]);_0x2b6ba3[_0xcef8('0x3f')]=qs[_0xcef8('0x40')](_['pick'](_0x4007fc[_0xcef8('0x37')],_0x3999ce['filters']));if(_0x4007fc[_0xcef8('0x37')]['filter']){_0x2b6ba3[_0xcef8('0x3f')]=_[_0xcef8('0x58')](_0x2b6ba3[_0xcef8('0x3f')],{'$or':_['map'](_0x2b6ba3[_0xcef8('0x3a')],function(_0x2b66c0){var _0x1a97a7={};_0x1a97a7[_0x2b66c0]={'$like':'%'+_0x4007fc[_0xcef8('0x37')][_0xcef8('0x42')]+'%'};return _0x1a97a7;})});}_0x2b6ba3=_[_0xcef8('0x58')]({},_0x2b6ba3,_0x4007fc['options']);return _0x3d7057[_0xcef8('0x8b')](_0x2b6ba3);}})[_0xcef8('0x28')](function(_0xb1a9d7){if(_0xb1a9d7){_0x291164=_0xb1a9d7['length'];if(!_0x4007fc[_0xcef8('0x37')][_0xcef8('0x3d')]('nolimit')){_0x2b6ba3['limit']=qs[_0xcef8('0x20')](_0x4007fc['query'][_0xcef8('0x20')]);_0x2b6ba3[_0xcef8('0x22')]=qs[_0xcef8('0x22')](_0x4007fc[_0xcef8('0x37')]['offset']);}return _0x3d7057['getAgents'](_0x2b6ba3);}})[_0xcef8('0x28')](function(_0x390094){if(_0x390094){return _0x390094?{'count':_0x291164,'rows':_0x390094}:null;}})['then'](respondWithResult(_0x29fbe0,null))['catch'](handleError(_0x29fbe0,null));};
\ No newline at end of file
+var _0x7a8d=['api','../../config/utils','../../config/environment','../../mysqldb','redis','defaults','localhost','socket.io-emitter','./cmList.socket','register','sendStatus','status','end','offset','limit','undefined','count','set','Content-Range','json','apply','reject','save','update','then','destroy','get','UserProfileResource','error','stack','name','index','map','rawAttributes','type','key','query','keys','model','attributes','intersection','fields','length','hasOwnProperty','nolimit','order','sort','where','filters','pick','filter','merge','VIRTUAL','options','CmList','includeAll','include','findAll','rows','catch','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','Lists','UserProfileSection','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','params','describe','addDisposition','ListId','Disposition','findOne','removeDispositions','ids','addContacts','tags','isArray','push','omit','success','dataValues','errors','Malformed\x20request\x20syntax','CmCustomField','CustomFields','CmContact','cf_%d','raw','getContacts','getContactsCsv','alias','cm_contacts','distinct','field','c.cf_','customField_','select','item','from','cm_contact_has_items','ItemTypeId\x20=\x20?','description','CmContactId\x20=\x20c.id','description_additionalPhone_','toString','now','writeFileSync','format','/tmp/list_%d_%s.csv','setHeader','Content-disposition','list_%d_%s.csv','text/csv','download','addCustomField','sequelize','transaction','addCustomFields','Sequelize','TEXT','text','number','INTEGER','switch','BOOLEAN','defaultValue','addColumn','cf_%s','findAndCountAll','getGlobalCustomFields','addAgents','emit','userCmList:save','removeAgents','userCmList:remove','getAgents','User','message','eml-format','rimraf','fast-json-patch','request-promise','moment','mustache','util','path','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger'];(function(_0x5ca1f5,_0x245726){var _0x9b8aa4=function(_0x310862){while(--_0x310862){_0x5ca1f5['push'](_0x5ca1f5['shift']());}};_0x9b8aa4(++_0x245726);}(_0x7a8d,0x8d));var _0xd7a8=function(_0x22b2b8,_0x49e83d){_0x22b2b8=_0x22b2b8-0x0;var _0x514365=_0x7a8d[_0x22b2b8];return _0x514365;};'use strict';var emlformat=require(_0xd7a8('0x0'));var rimraf=require(_0xd7a8('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0xd7a8('0x2'));var rp=require(_0xd7a8('0x3'));var moment=require(_0xd7a8('0x4'));var BPromise=require('bluebird');var Mustache=require(_0xd7a8('0x5'));var util=require(_0xd7a8('0x6'));var path=require(_0xd7a8('0x7'));var sox=require(_0xd7a8('0x8'));var csv=require(_0xd7a8('0x9'));var ejs=require(_0xd7a8('0xa'));var fs=require('fs');var fs_extra=require(_0xd7a8('0xb'));var _=require(_0xd7a8('0xc'));var squel=require(_0xd7a8('0xd'));var crypto=require(_0xd7a8('0xe'));var jsforce=require(_0xd7a8('0xf'));var deskjs=require(_0xd7a8('0x10'));var toCsv=require('to-csv');var querystring=require(_0xd7a8('0x11'));var Papa=require('papaparse');var Redis=require(_0xd7a8('0x12'));var authService=require(_0xd7a8('0x13'));var qs=require(_0xd7a8('0x14'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xd7a8('0x15'));var logger=require(_0xd7a8('0x16'))(_0xd7a8('0x17'));var utils=require(_0xd7a8('0x18'));var config=require(_0xd7a8('0x19'));var licenseUtil=require('../../config/license/util');var db=require(_0xd7a8('0x1a'))['db'];var csv_results;config[_0xd7a8('0x1b')]=_[_0xd7a8('0x1c')](config['redis'],{'host':_0xd7a8('0x1d'),'port':0x18eb});var socket=require(_0xd7a8('0x1e'))(new Redis(config[_0xd7a8('0x1b')]));require(_0xd7a8('0x1f'))[_0xd7a8('0x20')](socket);function respondWithStatusCode(_0x3be159,_0x344a10){_0x344a10=_0x344a10||0xcc;return function(_0x36dda1){if(_0x36dda1){return _0x3be159[_0xd7a8('0x21')](_0x344a10);}return _0x3be159[_0xd7a8('0x22')](_0x344a10)[_0xd7a8('0x23')]();};}function respondWithResult(_0x176714,_0x4f13f8){_0x4f13f8=_0x4f13f8||0xc8;return function(_0x21d7d0){if(_0x21d7d0){return _0x176714[_0xd7a8('0x22')](_0x4f13f8)['json'](_0x21d7d0);}};}function respondWithFilteredResult(_0xdfd7c9,_0x1c23df){return function(_0x3d7be7){if(_0x3d7be7){var _0x48dab2=typeof _0x1c23df[_0xd7a8('0x24')]==='undefined'&&typeof _0x1c23df[_0xd7a8('0x25')]===_0xd7a8('0x26');var _0x3a5c3b=_0x3d7be7[_0xd7a8('0x27')];var _0xd53a48=_0x48dab2?0x0:_0x1c23df[_0xd7a8('0x24')];var _0x14b6b9=_0x48dab2?_0x3d7be7['count']:_0x1c23df['offset']+_0x1c23df[_0xd7a8('0x25')];var _0x187fd9;if(_0x14b6b9>=_0x3a5c3b){_0x14b6b9=_0x3a5c3b;_0x187fd9=0xc8;}else{_0x187fd9=0xce;}_0xdfd7c9['status'](_0x187fd9);return _0xdfd7c9[_0xd7a8('0x28')](_0xd7a8('0x29'),_0xd53a48+'-'+_0x14b6b9+'/'+_0x3a5c3b)[_0xd7a8('0x2a')](_0x3d7be7);}return null;};}function patchUpdates(_0x2f73ec){return function(_0x391cb7){try{jsonpatch[_0xd7a8('0x2b')](_0x391cb7,_0x2f73ec,!![]);}catch(_0x13cce2){return BPromise[_0xd7a8('0x2c')](_0x13cce2);}return _0x391cb7[_0xd7a8('0x2d')]();};}function saveUpdates(_0x51636a,_0x44b3c9){return function(_0x3995ed){if(_0x3995ed){return _0x3995ed[_0xd7a8('0x2e')](_0x51636a)[_0xd7a8('0x2f')](function(_0x5746e3){return _0x5746e3;});}return null;};}function removeEntity(_0x39bfa1,_0xc0101c){return function(_0x434a65){if(_0x434a65){return _0x434a65[_0xd7a8('0x30')]()[_0xd7a8('0x2f')](function(){var _0x52d355=_0x434a65[_0xd7a8('0x31')]({'plain':!![]});var _0x2c5835='Lists';return db[_0xd7a8('0x32')][_0xd7a8('0x30')]({'where':{'type':_0x2c5835,'resourceId':_0x52d355['id']}})[_0xd7a8('0x2f')](function(){return _0x434a65;});})[_0xd7a8('0x2f')](function(){_0x39bfa1[_0xd7a8('0x22')](0xcc)[_0xd7a8('0x23')]();});}};}function handleEntityNotFound(_0x370333,_0x1858a3){return function(_0x3fc0e2){if(!_0x3fc0e2){_0x370333['sendStatus'](0x194);}return _0x3fc0e2;};}function handleError(_0x47fbdc,_0x2eb298){_0x2eb298=_0x2eb298||0x1f4;return function(_0x524fd5){logger[_0xd7a8('0x33')](_0x524fd5[_0xd7a8('0x34')]);if(_0x524fd5[_0xd7a8('0x35')]){delete _0x524fd5['name'];}_0x47fbdc[_0xd7a8('0x22')](_0x2eb298)['send'](_0x524fd5);};}exports[_0xd7a8('0x36')]=function(_0x303e09,_0x1a6b45){var _0x584d54={},_0x13f96d={},_0x4f793e={'count':0x0,'rows':[]};var _0x204a60=_[_0xd7a8('0x37')](db['CmList'][_0xd7a8('0x38')],function(_0x30b0ac){return{'name':_0x30b0ac['fieldName'],'type':_0x30b0ac[_0xd7a8('0x39')][_0xd7a8('0x3a')]};});_0x13f96d['model']=_['map'](_0x204a60,'name');_0x13f96d[_0xd7a8('0x3b')]=_[_0xd7a8('0x3c')](_0x303e09[_0xd7a8('0x3b')]);_0x13f96d['filters']=_['intersection'](_0x13f96d[_0xd7a8('0x3d')],_0x13f96d[_0xd7a8('0x3b')]);_0x584d54[_0xd7a8('0x3e')]=_[_0xd7a8('0x3f')](_0x13f96d[_0xd7a8('0x3d')],qs[_0xd7a8('0x40')](_0x303e09[_0xd7a8('0x3b')][_0xd7a8('0x40')]));_0x584d54['attributes']=_0x584d54[_0xd7a8('0x3e')][_0xd7a8('0x41')]?_0x584d54[_0xd7a8('0x3e')]:_0x13f96d[_0xd7a8('0x3d')];if(!_0x303e09[_0xd7a8('0x3b')][_0xd7a8('0x42')](_0xd7a8('0x43'))){_0x584d54[_0xd7a8('0x25')]=qs[_0xd7a8('0x25')](_0x303e09[_0xd7a8('0x3b')][_0xd7a8('0x25')]);_0x584d54[_0xd7a8('0x24')]=qs['offset'](_0x303e09[_0xd7a8('0x3b')][_0xd7a8('0x24')]);}_0x584d54[_0xd7a8('0x44')]=qs[_0xd7a8('0x45')](_0x303e09['query'][_0xd7a8('0x45')]);_0x584d54[_0xd7a8('0x46')]=qs[_0xd7a8('0x47')](_[_0xd7a8('0x48')](_0x303e09['query'],_0x13f96d['filters']),_0x204a60);if(_0x303e09[_0xd7a8('0x3b')][_0xd7a8('0x49')]){_0x584d54['where']=_[_0xd7a8('0x4a')](_0x584d54[_0xd7a8('0x46')],{'$or':_['map'](_0x204a60,function(_0x53ab93){if(_0x53ab93[_0xd7a8('0x39')]!==_0xd7a8('0x4b')){var _0x36c700={};_0x36c700[_0x53ab93[_0xd7a8('0x35')]]={'$like':'%'+_0x303e09[_0xd7a8('0x3b')][_0xd7a8('0x49')]+'%'};return _0x36c700;}})});}_0x584d54=_[_0xd7a8('0x4a')]({},_0x584d54,_0x303e09[_0xd7a8('0x4c')]);var _0x53ee1d={'where':_0x584d54[_0xd7a8('0x46')]};return db[_0xd7a8('0x4d')]['count'](_0x53ee1d)[_0xd7a8('0x2f')](function(_0x31b616){_0x4f793e[_0xd7a8('0x27')]=_0x31b616;if(_0x303e09[_0xd7a8('0x3b')][_0xd7a8('0x4e')]){_0x584d54[_0xd7a8('0x4f')]=[{'all':!![]}];}return db[_0xd7a8('0x4d')][_0xd7a8('0x50')](_0x584d54);})[_0xd7a8('0x2f')](function(_0x159662){_0x4f793e[_0xd7a8('0x51')]=_0x159662;return _0x4f793e;})[_0xd7a8('0x2f')](respondWithFilteredResult(_0x1a6b45,_0x584d54))[_0xd7a8('0x52')](handleError(_0x1a6b45,null));};exports['show']=function(_0x5f362b,_0x19e020){var _0xb28677={'raw':![],'where':{'id':_0x5f362b['params']['id']}},_0x20d1e0={};_0x20d1e0[_0xd7a8('0x3d')]=_[_0xd7a8('0x3c')](db[_0xd7a8('0x4d')][_0xd7a8('0x38')]);_0x20d1e0[_0xd7a8('0x3b')]=_[_0xd7a8('0x3c')](_0x5f362b[_0xd7a8('0x3b')]);_0x20d1e0[_0xd7a8('0x47')]=_[_0xd7a8('0x3f')](_0x20d1e0[_0xd7a8('0x3d')],_0x20d1e0[_0xd7a8('0x3b')]);_0xb28677[_0xd7a8('0x3e')]=_['intersection'](_0x20d1e0[_0xd7a8('0x3d')],qs['fields'](_0x5f362b[_0xd7a8('0x3b')][_0xd7a8('0x40')]));_0xb28677[_0xd7a8('0x3e')]=_0xb28677[_0xd7a8('0x3e')][_0xd7a8('0x41')]?_0xb28677[_0xd7a8('0x3e')]:_0x20d1e0[_0xd7a8('0x3d')];if(_0x5f362b[_0xd7a8('0x3b')][_0xd7a8('0x4e')]){_0xb28677[_0xd7a8('0x4f')]=[{'all':!![]}];}_0xb28677=_[_0xd7a8('0x4a')]({},_0xb28677,_0x5f362b[_0xd7a8('0x4c')]);return db[_0xd7a8('0x4d')][_0xd7a8('0x53')](_0xb28677)['then'](handleEntityNotFound(_0x19e020,null))[_0xd7a8('0x2f')](respondWithResult(_0x19e020,null))[_0xd7a8('0x52')](handleError(_0x19e020,null));};exports['create']=function(_0x9730f3,_0xfe2189){return db['CmList'][_0xd7a8('0x54')](_0x9730f3[_0xd7a8('0x55')],{})[_0xd7a8('0x2f')](function(_0x282050){var _0x165103=_0x9730f3[_0xd7a8('0x56')][_0xd7a8('0x31')]({'plain':!![]});if(!_0x165103)throw new Error(_0xd7a8('0x57'));if(_0x165103[_0xd7a8('0x58')]===_0xd7a8('0x56')){var _0xbb295d=_0x282050['get']({'plain':!![]});var _0x2895e6=_0xd7a8('0x59');return db[_0xd7a8('0x5a')][_0xd7a8('0x53')]({'where':{'name':_0x2895e6,'userProfileId':_0x165103['userProfileId']},'raw':!![]})[_0xd7a8('0x2f')](function(_0x5afb00){if(_0x5afb00&&_0x5afb00['autoAssociation']===0x0){return db[_0xd7a8('0x32')][_0xd7a8('0x54')]({'name':_0xbb295d[_0xd7a8('0x35')],'resourceId':_0xbb295d['id'],'type':_0x5afb00[_0xd7a8('0x35')],'sectionId':_0x5afb00['id']},{})[_0xd7a8('0x2f')](function(){return _0x282050;});}else{return _0x282050;}})['catch'](function(_0x333c36){logger[_0xd7a8('0x33')](_0xd7a8('0x5b'),_0x333c36);throw _0x333c36;});}return _0x282050;})[_0xd7a8('0x2f')](respondWithResult(_0xfe2189,0xc9))[_0xd7a8('0x52')](handleError(_0xfe2189,null));};exports[_0xd7a8('0x2e')]=function(_0xb20cc3,_0x186856){if(_0xb20cc3[_0xd7a8('0x55')]['id']){delete _0xb20cc3[_0xd7a8('0x55')]['id'];}return db[_0xd7a8('0x4d')][_0xd7a8('0x53')]({'where':{'id':_0xb20cc3[_0xd7a8('0x5c')]['id']}})[_0xd7a8('0x2f')](handleEntityNotFound(_0x186856,null))[_0xd7a8('0x2f')](saveUpdates(_0xb20cc3[_0xd7a8('0x55')],null))[_0xd7a8('0x2f')](respondWithResult(_0x186856,null))[_0xd7a8('0x52')](handleError(_0x186856,null));};exports[_0xd7a8('0x30')]=function(_0x511e83,_0x383d93){return db[_0xd7a8('0x4d')][_0xd7a8('0x53')]({'where':{'id':_0x511e83[_0xd7a8('0x5c')]['id']}})[_0xd7a8('0x2f')](handleEntityNotFound(_0x383d93,null))[_0xd7a8('0x2f')](removeEntity(_0x383d93,null))[_0xd7a8('0x52')](handleError(_0x383d93,null));};exports[_0xd7a8('0x5d')]=function(_0x5ae80f,_0x3fda7e){return db[_0xd7a8('0x4d')]['describe']()['then'](respondWithResult(_0x3fda7e,null))['catch'](handleError(_0x3fda7e,null));};exports[_0xd7a8('0x5e')]=function(_0x2daade,_0x3bea06,_0x4d27e9){if(_0x2daade[_0xd7a8('0x55')]['id']){delete _0x2daade['body']['id'];}return db[_0xd7a8('0x4d')]['find']({'where':{'id':_0x2daade[_0xd7a8('0x5c')]['id']}})[_0xd7a8('0x2f')](handleEntityNotFound(_0x3bea06,null))[_0xd7a8('0x2f')](function(_0x23d664){if(_0x23d664){_0x2daade[_0xd7a8('0x55')][_0xd7a8('0x5f')]=_0x23d664['id'];return db[_0xd7a8('0x60')][_0xd7a8('0x54')](_0x2daade['body']);}})[_0xd7a8('0x2f')](respondWithResult(_0x3bea06,null))['catch'](handleError(_0x3bea06,null));};exports['getDispositions']=function(_0x49b304,_0x420613,_0x126f3a){var _0x586e8a={'raw':![],'where':{}};var _0x341619={};var _0x4c1988={'count':0x0,'rows':[]};return db[_0xd7a8('0x4d')][_0xd7a8('0x61')]({'where':{'id':_0x49b304[_0xd7a8('0x5c')]['id']}})[_0xd7a8('0x2f')](handleEntityNotFound(_0x420613,null))[_0xd7a8('0x2f')](function(_0x3265d0){if(_0x3265d0){_0x341619['model']=_[_0xd7a8('0x3c')](db[_0xd7a8('0x60')]['rawAttributes']);_0x341619[_0xd7a8('0x3b')]=_['keys'](_0x49b304[_0xd7a8('0x3b')]);_0x341619[_0xd7a8('0x47')]=_[_0xd7a8('0x3f')](_0x341619[_0xd7a8('0x3d')],_0x341619[_0xd7a8('0x3b')]);_0x586e8a['attributes']=_[_0xd7a8('0x3f')](_0x341619[_0xd7a8('0x3d')],qs['fields'](_0x49b304[_0xd7a8('0x3b')][_0xd7a8('0x40')]));_0x586e8a[_0xd7a8('0x3e')]=_0x586e8a['attributes'][_0xd7a8('0x41')]?_0x586e8a[_0xd7a8('0x3e')]:_0x341619['model'];if(!_0x49b304['query']['hasOwnProperty']('nolimit')){_0x586e8a[_0xd7a8('0x25')]=qs['limit'](_0x49b304['query']['limit']);_0x586e8a[_0xd7a8('0x24')]=qs['offset'](_0x49b304[_0xd7a8('0x3b')][_0xd7a8('0x24')]);}_0x586e8a[_0xd7a8('0x44')]=qs[_0xd7a8('0x45')](_0x49b304[_0xd7a8('0x3b')][_0xd7a8('0x45')]);_0x586e8a[_0xd7a8('0x46')]=qs[_0xd7a8('0x47')](_['pick'](_0x49b304[_0xd7a8('0x3b')],_0x341619['filters']));_0x586e8a[_0xd7a8('0x46')][_0xd7a8('0x5f')]=_0x3265d0['id'];if(_0x49b304[_0xd7a8('0x3b')]['filter']){_0x586e8a[_0xd7a8('0x46')]=_[_0xd7a8('0x4a')](_0x586e8a[_0xd7a8('0x46')],{'$or':_[_0xd7a8('0x37')](_0x586e8a[_0xd7a8('0x3e')],function(_0x4ebf3a){var _0x16b3fd={};_0x16b3fd[_0x4ebf3a]={'$like':'%'+_0x49b304[_0xd7a8('0x3b')]['filter']+'%'};return _0x16b3fd;})});}_0x586e8a=_[_0xd7a8('0x4a')]({},_0x586e8a,_0x49b304[_0xd7a8('0x4c')]);return db[_0xd7a8('0x60')][_0xd7a8('0x27')]({'where':_0x586e8a[_0xd7a8('0x46')]})[_0xd7a8('0x2f')](function(_0x3ba485){_0x4c1988[_0xd7a8('0x27')]=_0x3ba485;if(_0x49b304['query'][_0xd7a8('0x4e')]){_0x586e8a[_0xd7a8('0x4f')]=[{'all':!![]}];}return db[_0xd7a8('0x60')][_0xd7a8('0x50')](_0x586e8a);})[_0xd7a8('0x2f')](function(_0x55f343){_0x4c1988[_0xd7a8('0x51')]=_0x55f343;return _0x4c1988;});}})[_0xd7a8('0x2f')](respondWithFilteredResult(_0x420613,_0x586e8a))['catch'](handleError(_0x420613,null));};exports[_0xd7a8('0x62')]=function(_0x3fd4ba,_0x27c89c,_0x530c42){return db[_0xd7a8('0x4d')]['find']({'where':{'id':_0x3fd4ba[_0xd7a8('0x5c')]['id']}})[_0xd7a8('0x2f')](handleEntityNotFound(_0x27c89c,null))['then'](function(_0x175d9c){if(_0x175d9c){return _0x175d9c[_0xd7a8('0x62')](_0x3fd4ba[_0xd7a8('0x3b')][_0xd7a8('0x63')]);}})[_0xd7a8('0x2f')](respondWithStatusCode(_0x27c89c,null))['catch'](handleError(_0x27c89c,null));};exports[_0xd7a8('0x64')]=function(_0xf0d27d,_0x52351c,_0xc9a2c4){return db[_0xd7a8('0x4d')][_0xd7a8('0x53')]({'where':{'id':_0xf0d27d[_0xd7a8('0x5c')]['id']}})[_0xd7a8('0x2f')](handleEntityNotFound(_0x52351c,null))['then'](function(_0x26d3bf){if(_0x26d3bf){var _0x4e60af=[];var _0x5d12ed={'success':[],'errors':[]};return db['CmContact'][_0xd7a8('0x5d')]()[_0xd7a8('0x2f')](function(_0x3b8740){if(_0xf0d27d['body'][_0xd7a8('0x65')]&&_[_0xd7a8('0x66')](_0xf0d27d[_0xd7a8('0x55')]['tags'])){if(_0xf0d27d[_0xd7a8('0x55')][_0xd7a8('0x65')][_0xd7a8('0x41')]){_0xf0d27d[_0xd7a8('0x55')][_0xd7a8('0x65')]=_0xf0d27d[_0xd7a8('0x55')]['tags']['join'](';')+';';}else{_0xf0d27d[_0xd7a8('0x55')][_0xd7a8('0x65')]=null;}}else{_0xf0d27d[_0xd7a8('0x55')][_0xd7a8('0x65')]=null;}if(_0xf0d27d[_0xd7a8('0x55')]&&_[_0xd7a8('0x66')](_0xf0d27d[_0xd7a8('0x55')])){for(var _0x302507=0x0;_0x302507<_0xf0d27d[_0xd7a8('0x55')][_0xd7a8('0x41')];_0x302507+=0x1){_0xf0d27d['body'][_0x302507][_0xd7a8('0x5f')]=_0xf0d27d[_0xd7a8('0x5c')]['id'];_0x4e60af[_0xd7a8('0x67')](_0xf0d27d['body'][_0x302507]);}return BPromise['each'](_0x4e60af,function(_0x378172){return db['CmContact']['create'](_[_0xd7a8('0x68')](_0x378172,[_0xd7a8('0x63'),'id'])||{},{'fields':_[_0xd7a8('0x3c')](_0x3b8740),'raw':!![]})[_0xd7a8('0x2f')](function(_0x181c1c){_0x5d12ed[_0xd7a8('0x69')][_0xd7a8('0x67')](_0x181c1c[_0xd7a8('0x6a')]);})['catch'](function(_0x35ce40){_0x5d12ed[_0xd7a8('0x6b')][_0xd7a8('0x67')]({'data':_0x378172,'error':_0x35ce40['message']});});})[_0xd7a8('0x2f')](function(_0x5c4f7b){return _0x5d12ed;})['catch'](function(_0x9c0e94){return _0x9c0e94;});}else{_0x52351c[_0xd7a8('0x22')](0x190)[_0xd7a8('0x2a')]({'message':_0xd7a8('0x6c')});}});}})['then'](respondWithResult(_0x52351c,null))[_0xd7a8('0x52')](handleError(_0x52351c,null));};exports['getContacts']=function(_0x8b0931,_0x80121c,_0x1e3fd4){var _0x2a0a1a;return db[_0xd7a8('0x4d')][_0xd7a8('0x53')]({'where':{'id':_0x8b0931['params']['id']},'include':[{'model':db[_0xd7a8('0x6d')],'as':_0xd7a8('0x6e')}]})['then'](handleEntityNotFound(_0x80121c,null))[_0xd7a8('0x2f')](function(_0x31f733){if(_0x31f733){_0x2a0a1a=_0x31f733;return db[_0xd7a8('0x6f')][_0xd7a8('0x38')];}})['then'](function(_0x29c9c6){if(_0x29c9c6){var _0x43dcb2={};var _0x2147c2={};_0x2147c2['model']=_['concat'](_[_0xd7a8('0x3c')](_0x29c9c6),_[_0xd7a8('0x37')](_0x2a0a1a[_0xd7a8('0x6e')],function(_0x3681a3){return util['format'](_0xd7a8('0x70'),_0x3681a3['id']);}));_0x2147c2[_0xd7a8('0x3b')]=_[_0xd7a8('0x3c')](_0x8b0931[_0xd7a8('0x3b')]);_0x2147c2['filters']=_[_0xd7a8('0x3f')](_0x2147c2[_0xd7a8('0x3d')],_0x2147c2[_0xd7a8('0x3b')]);_0x43dcb2[_0xd7a8('0x3e')]=_[_0xd7a8('0x3f')](_0x2147c2[_0xd7a8('0x3d')],qs[_0xd7a8('0x40')](_0x8b0931[_0xd7a8('0x3b')][_0xd7a8('0x40')]));_0x43dcb2[_0xd7a8('0x3e')]=_0x43dcb2[_0xd7a8('0x3e')][_0xd7a8('0x41')]?_0x43dcb2[_0xd7a8('0x3e')]:_0x2147c2[_0xd7a8('0x3d')];if(!_0x8b0931['query'][_0xd7a8('0x42')]('nolimit')){_0x43dcb2['limit']=qs[_0xd7a8('0x25')](_0x8b0931[_0xd7a8('0x3b')]['limit']);_0x43dcb2[_0xd7a8('0x24')]=qs[_0xd7a8('0x24')](_0x8b0931[_0xd7a8('0x3b')][_0xd7a8('0x24')]);}_0x43dcb2[_0xd7a8('0x44')]=qs[_0xd7a8('0x45')](_0x8b0931[_0xd7a8('0x3b')][_0xd7a8('0x45')]);_0x43dcb2[_0xd7a8('0x46')]=qs[_0xd7a8('0x47')](_[_0xd7a8('0x48')](_0x8b0931[_0xd7a8('0x3b')],_0x2147c2['filters']));_0x43dcb2[_0xd7a8('0x71')]=!![];if(_0x8b0931[_0xd7a8('0x3b')][_0xd7a8('0x49')]){_0x43dcb2[_0xd7a8('0x46')]=_[_0xd7a8('0x4a')](_0x43dcb2[_0xd7a8('0x46')],{'$or':_['map'](_0x43dcb2[_0xd7a8('0x3e')],function(_0x1ea595){var _0xd0f993={};_0xd0f993[_0x1ea595]={'$like':'%'+_0x8b0931[_0xd7a8('0x3b')][_0xd7a8('0x49')]+'%'};return _0xd0f993;})});}_0x43dcb2=_['merge']({},_0x43dcb2,_0x8b0931[_0xd7a8('0x4c')]);return _0x2a0a1a[_0xd7a8('0x72')](_0x43dcb2);}})[_0xd7a8('0x2f')](respondWithResult(_0x80121c,null))[_0xd7a8('0x52')](handleError(_0x80121c,null));};exports[_0xd7a8('0x73')]=function(_0x4f0c42,_0x441ba9,_0x28b024){var _0x32e09e;var _0x27cc9e;var _0x297a75;var _0x49aefa=_0x4f0c42['params']['id'];csv_results=[];return db['ContactItemType'][_0xd7a8('0x50')]({'attributes':['id',_0xd7a8('0x35')],'raw':!![],'order':['OrderBy']})[_0xd7a8('0x2f')](function(_0x52f019){_0x32e09e=_0x52f019;var _0x2be92d=_[_0xd7a8('0x3c')](db['CmContact'][_0xd7a8('0x38')]);return db[_0xd7a8('0x6d')][_0xd7a8('0x50')]({'raw':!![],'attributes':['id',_0xd7a8('0x74')]})['then'](function(_0x5b4bdc){_0x27cc9e=_0x5b4bdc;var _0x5cf299=squel['select']()[_0xd7a8('0x40')](_0x2be92d)['from'](_0xd7a8('0x75'),'c')[_0xd7a8('0x46')]('c.ListId\x20=\x20?',_0x49aefa)[_0xd7a8('0x46')]('c.deletedAt\x20is\x20null')[_0xd7a8('0x76')]();for(var _0x2c175c=0x0;_0x2c175c<_0x27cc9e[_0xd7a8('0x41')];_0x2c175c++){_0x5cf299[_0xd7a8('0x77')](_0xd7a8('0x78')+_0x27cc9e[_0x2c175c]['id'],_0xd7a8('0x79')+_0x27cc9e[_0x2c175c][_0xd7a8('0x74')]);}for(var _0x2c175c=0x0;_0x2c175c<_0x32e09e['length'];_0x2c175c++){_0x5cf299[_0xd7a8('0x77')](squel[_0xd7a8('0x7a')]()[_0xd7a8('0x77')](_0xd7a8('0x7b'))[_0xd7a8('0x7c')](_0xd7a8('0x7d'))[_0xd7a8('0x46')](_0xd7a8('0x7e'),_0x32e09e[_0x2c175c]['id'])[_0xd7a8('0x46')]('CmContactId\x20=\x20c.id'),'additionalPhone_'+_0x32e09e[_0x2c175c][_0xd7a8('0x35')]);_0x5cf299['field'](squel[_0xd7a8('0x7a')]()['field'](_0xd7a8('0x7f'))[_0xd7a8('0x7c')](_0xd7a8('0x7d'))[_0xd7a8('0x46')]('ItemTypeId\x20=\x20?',_0x32e09e[_0x2c175c]['id'])[_0xd7a8('0x46')](_0xd7a8('0x80')),_0xd7a8('0x81')+_0x32e09e[_0x2c175c][_0xd7a8('0x35')]);}var _0x4ac24b=[];_0x4ac24b[_0xd7a8('0x67')](_0x5cf299[_0xd7a8('0x82')]());BPromise['each'](_0x4ac24b,handleQuery)[_0xd7a8('0x2f')](function(_0xcac1f3){handleQuery(_0x5cf299[_0xd7a8('0x82')]());var _0x421dbe=csv_results[0x0];if(!_['isEmpty'](_0x421dbe)){var _0x948c16=toCsv(_0x421dbe);var _0x2db9ce=Date[_0xd7a8('0x83')]();fs[_0xd7a8('0x84')](util[_0xd7a8('0x85')](_0xd7a8('0x86'),_0x49aefa,_0x2db9ce),_0x948c16);_0x441ba9[_0xd7a8('0x87')](_0xd7a8('0x88'),'attachment;\x20filename='+util['format'](_0xd7a8('0x89'),_0x49aefa,_0x2db9ce));_0x441ba9[_0xd7a8('0x87')]('Content-type',_0xd7a8('0x8a'));return _0x441ba9[_0xd7a8('0x8b')](util['format'](_0xd7a8('0x86'),_0x49aefa,_0x2db9ce));}else{return _0x441ba9[_0xd7a8('0x21')](0xcc);}});});});};exports[_0xd7a8('0x8c')]=function(_0x53289c,_0x2f14f1,_0x5621ce){var _0x5a425f;delete _0x53289c[_0xd7a8('0x55')]['id'];return db['CmList'][_0xd7a8('0x61')]({'where':{'id':_0x53289c[_0xd7a8('0x5c')]['id']}})[_0xd7a8('0x2f')](handleEntityNotFound(_0x2f14f1,null))[_0xd7a8('0x2f')](function(_0xb1df09){if(_0xb1df09){return db[_0xd7a8('0x8d')][_0xd7a8('0x8e')](function(_0x3f14fe){return db[_0xd7a8('0x6d')][_0xd7a8('0x54')](_0x53289c['body'],{'transaction':_0x3f14fe})['then'](function(_0x8ecf6b){_0x5a425f=_0x8ecf6b;return _0xb1df09[_0xd7a8('0x8f')](_0x8ecf6b,{'transaction':_0x3f14fe});})[_0xd7a8('0x2f')](function(){var _0x42e60e={'type':db[_0xd7a8('0x90')][_0xd7a8('0x91')],'transaction':_0x3f14fe};switch(_0x53289c['body'][_0xd7a8('0x39')]){case _0xd7a8('0x92'):_0x42e60e['type']=db['Sequelize'][_0xd7a8('0x91')];break;case _0xd7a8('0x93'):_0x42e60e[_0xd7a8('0x39')]=db[_0xd7a8('0x90')][_0xd7a8('0x94')];break;case _0xd7a8('0x95'):_0x42e60e['type']=db[_0xd7a8('0x90')][_0xd7a8('0x96')];_0x42e60e[_0xd7a8('0x97')]=![];break;default:}return db[_0xd7a8('0x8d')]['queryInterface'][_0xd7a8('0x98')](_0xd7a8('0x75'),util[_0xd7a8('0x85')](_0xd7a8('0x99'),_0x5a425f['id']),_0x42e60e);})[_0xd7a8('0x2f')](function(){return _0x5a425f;});});}})[_0xd7a8('0x2f')](respondWithResult(_0x2f14f1,null))[_0xd7a8('0x52')](handleError(_0x2f14f1,null));};exports['getCustomFields']=function(_0xdbadc1,_0x218718,_0x4b4a03){var _0xfdba74={};var _0x10d943={};var _0x1f33af;var _0x2daeed;return db[_0xd7a8('0x4d')]['findOne']({'where':{'id':_0xdbadc1[_0xd7a8('0x5c')]['id']}})[_0xd7a8('0x2f')](handleEntityNotFound(_0x218718,null))[_0xd7a8('0x2f')](function(_0x3f0f17){if(_0x3f0f17){_0x1f33af=_0x3f0f17;_0x10d943['model']=_[_0xd7a8('0x3c')](db[_0xd7a8('0x6d')][_0xd7a8('0x38')]);_0x10d943['query']=_[_0xd7a8('0x3c')](_0xdbadc1[_0xd7a8('0x3b')]);_0x10d943['filters']=_['intersection'](_0x10d943[_0xd7a8('0x3d')],_0x10d943[_0xd7a8('0x3b')]);_0xfdba74[_0xd7a8('0x3e')]=_['intersection'](_0x10d943[_0xd7a8('0x3d')],qs[_0xd7a8('0x40')](_0xdbadc1[_0xd7a8('0x3b')][_0xd7a8('0x40')]));_0xfdba74['attributes']=_0xfdba74[_0xd7a8('0x3e')][_0xd7a8('0x41')]?_0xfdba74[_0xd7a8('0x3e')]:_0x10d943[_0xd7a8('0x3d')];_0xfdba74['order']=qs['sort'](_0xdbadc1[_0xd7a8('0x3b')]['sort']);_0xfdba74[_0xd7a8('0x46')]=qs[_0xd7a8('0x47')](_['pick'](_0xdbadc1[_0xd7a8('0x3b')],_0x10d943[_0xd7a8('0x47')]));_0xfdba74[_0xd7a8('0x46')]=_['merge'](_0xfdba74['where'],{'$or':[{'ListId':_0x3f0f17['id']},{'ListId':null}]});if(_0xdbadc1['query'][_0xd7a8('0x49')]){_0xfdba74[_0xd7a8('0x46')]=_[_0xd7a8('0x4a')](_0xfdba74[_0xd7a8('0x46')],{'$or':_[_0xd7a8('0x37')](_0xfdba74[_0xd7a8('0x3e')],function(_0x18921b){var _0x4b97b8={};_0x4b97b8[_0x18921b]={'$like':'%'+_0xdbadc1['query'][_0xd7a8('0x49')]+'%'};return _0x4b97b8;})});}_0xfdba74=_['merge']({},_0xfdba74,_0xdbadc1['options']);return db[_0xd7a8('0x6d')][_0xd7a8('0x9a')](_0xfdba74);}})[_0xd7a8('0x2f')](respondWithResult(_0x218718,null))[_0xd7a8('0x52')](handleError(_0x218718,null));};exports[_0xd7a8('0x9b')]=function(_0xe78f58,_0x104283){return db[_0xd7a8('0x6d')][_0xd7a8('0x9a')]({'where':{'ListId':null}})['then'](handleEntityNotFound(_0x104283,null))[_0xd7a8('0x2f')](function(_0x2c41b7){return _0x2c41b7;})[_0xd7a8('0x2f')](respondWithResult(_0x104283,null))[_0xd7a8('0x52')](handleError(_0x104283,null));};exports[_0xd7a8('0x9c')]=function(_0x4136b8,_0x46579e,_0x2de9c5){return db[_0xd7a8('0x4d')][_0xd7a8('0x53')]({'where':{'id':_0x4136b8['params']['id']}})[_0xd7a8('0x2f')](handleEntityNotFound(_0x46579e,null))[_0xd7a8('0x2f')](function(_0x147431){if(_0x147431){return _0x147431[_0xd7a8('0x9c')](_0x4136b8['body']['ids'],_[_0xd7a8('0x68')](_0x4136b8[_0xd7a8('0x55')],[_0xd7a8('0x63'),'id'])||{})['spread'](function(_0x26c16d){for(var _0x31c6d3=0x0;_0x31c6d3<_0x4136b8['body'][_0xd7a8('0x63')][_0xd7a8('0x41')];_0x31c6d3+=0x1){socket[_0xd7a8('0x9d')](_0xd7a8('0x9e'),{'UserId':Number(_0x4136b8[_0xd7a8('0x55')][_0xd7a8('0x63')][_0x31c6d3]),'CmListId':Number(_0x4136b8[_0xd7a8('0x5c')]['id'])});}return _0x26c16d;});}})[_0xd7a8('0x2f')](respondWithResult(_0x46579e,null))[_0xd7a8('0x52')](handleError(_0x46579e,null));};exports[_0xd7a8('0x9f')]=function(_0x13b1e4,_0x498eec,_0x57bc91){return db[_0xd7a8('0x4d')][_0xd7a8('0x53')]({'where':{'id':_0x13b1e4['params']['id']}})[_0xd7a8('0x2f')](handleEntityNotFound(_0x498eec,null))[_0xd7a8('0x2f')](function(_0x32d361){if(_0x32d361){return _0x32d361['removeAgents'](_0x13b1e4['query'][_0xd7a8('0x63')])[_0xd7a8('0x2f')](function(){if(_[_0xd7a8('0x66')](_0x13b1e4[_0xd7a8('0x3b')][_0xd7a8('0x63')])){for(var _0x5516ce=0x0;_0x5516ce<_0x13b1e4[_0xd7a8('0x3b')]['ids'][_0xd7a8('0x41')];_0x5516ce+=0x1){socket[_0xd7a8('0x9d')](_0xd7a8('0xa0'),{'UserId':Number(_0x13b1e4[_0xd7a8('0x3b')]['ids'][_0x5516ce]),'CmListId':Number(_0x13b1e4[_0xd7a8('0x5c')]['id'])});}}else{socket[_0xd7a8('0x9d')](_0xd7a8('0xa0'),{'UserId':Number(_0x13b1e4['query']['ids']),'CmListId':Number(_0x13b1e4['params']['id'])});}});}})[_0xd7a8('0x2f')](respondWithStatusCode(_0x498eec,null))[_0xd7a8('0x52')](handleError(_0x498eec,null));};exports[_0xd7a8('0xa1')]=function(_0x2bdba1,_0x4b9795,_0x5d0c8b){var _0x1f61b3={};var _0x3aa147={};var _0xde480d;var _0x29296e;return db[_0xd7a8('0x4d')]['findOne']({'where':{'id':_0x2bdba1[_0xd7a8('0x5c')]['id']}})[_0xd7a8('0x2f')](handleEntityNotFound(_0x4b9795,null))[_0xd7a8('0x2f')](function(_0x4ec72d){if(_0x4ec72d){_0xde480d=_0x4ec72d;_0x3aa147['model']=_[_0xd7a8('0x3c')](db[_0xd7a8('0xa2')][_0xd7a8('0x38')]);_0x3aa147[_0xd7a8('0x3b')]=_[_0xd7a8('0x3c')](_0x2bdba1['query']);_0x3aa147[_0xd7a8('0x47')]=_[_0xd7a8('0x3f')](_0x3aa147['model'],_0x3aa147['query']);_0x1f61b3[_0xd7a8('0x3e')]=_['intersection'](_0x3aa147[_0xd7a8('0x3d')],qs[_0xd7a8('0x40')](_0x2bdba1['query'][_0xd7a8('0x40')]));_0x1f61b3['attributes']=_0x1f61b3[_0xd7a8('0x3e')][_0xd7a8('0x41')]?_0x1f61b3[_0xd7a8('0x3e')]:_0x3aa147['model'];_0x1f61b3[_0xd7a8('0x44')]=qs[_0xd7a8('0x45')](_0x2bdba1[_0xd7a8('0x3b')]['sort']);_0x1f61b3[_0xd7a8('0x46')]=qs['filters'](_['pick'](_0x2bdba1[_0xd7a8('0x3b')],_0x3aa147[_0xd7a8('0x47')]));if(_0x2bdba1[_0xd7a8('0x3b')]['filter']){_0x1f61b3[_0xd7a8('0x46')]=_['merge'](_0x1f61b3[_0xd7a8('0x46')],{'$or':_[_0xd7a8('0x37')](_0x1f61b3[_0xd7a8('0x3e')],function(_0x488b96){var _0x30f0e3={};_0x30f0e3[_0x488b96]={'$like':'%'+_0x2bdba1['query'][_0xd7a8('0x49')]+'%'};return _0x30f0e3;})});}_0x1f61b3=_[_0xd7a8('0x4a')]({},_0x1f61b3,_0x2bdba1['options']);return _0xde480d['getAgents'](_0x1f61b3);}})[_0xd7a8('0x2f')](function(_0x4f5f17){if(_0x4f5f17){_0x29296e=_0x4f5f17[_0xd7a8('0x41')];if(!_0x2bdba1['query'][_0xd7a8('0x42')]('nolimit')){_0x1f61b3[_0xd7a8('0x25')]=qs['limit'](_0x2bdba1[_0xd7a8('0x3b')][_0xd7a8('0x25')]);_0x1f61b3[_0xd7a8('0x24')]=qs['offset'](_0x2bdba1[_0xd7a8('0x3b')][_0xd7a8('0x24')]);}return _0xde480d['getAgents'](_0x1f61b3);}})[_0xd7a8('0x2f')](function(_0x4e3718){if(_0x4e3718){return _0x4e3718?{'count':_0x29296e,'rows':_0x4e3718}:null;}})[_0xd7a8('0x2f')](respondWithResult(_0x4b9795,null))[_0xd7a8('0x52')](handleError(_0x4b9795,null));};function handleQuery(_0x49384d){logger['info'](_0x49384d);return db[_0xd7a8('0x8d')]['query'](_0x49384d)['spread'](function(_0x66009c){csv_results[_0xd7a8('0x67')](_0x66009c);})['catch'](function(_0x1a99ea){logger[_0xd7a8('0x33')](_0x1a99ea[_0xd7a8('0xa3')]);});}
\ No newline at end of file