Built motion from commit e1760111.|2.6.18
[motion2.git] / server / api / cmList / cmList.controller.js
index c6e92a1..bc08e83 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x25fb=['../../config/environment','../../mysqldb','redis','defaults','localhost','socket.io-emitter','./cmList.socket','register','sendStatus','status','json','offset','undefined','limit','count','Content-Range','apply','reject','save','update','then','get','Lists','UserProfileResource','destroy','end','name','send','map','CmList','rawAttributes','fieldName','type','key','model','query','filters','intersection','fields','attributes','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','options','includeAll','include','findAll','rows','catch','show','params','keys','find','create','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','autoAssociation','error','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','body','describe','addDisposition','ListId','Disposition','getDispositions','removeDispositions','ids','addContacts','CmContact','tags','join','isArray','push','each','omit','success','dataValues','errors','Malformed\x20request\x20syntax','CmCustomField','CustomFields','concat','format','cf_%d','raw','getContacts','ContactItemType','OrderBy','alias','cm_contacts','c.ListId\x20=\x20?','c.deletedAt\x20is\x20null','field','customField_','item','from','CmContactId\x20=\x20c.id','additionalPhone_','description','ItemTypeId\x20=\x20?','toString','now','writeFileSync','setHeader','Content-disposition','list_%d_%s.csv','Content-type','text/csv','download','/tmp/list_%d_%s.csv','addCustomField','sequelize','transaction','addCustomFields','TEXT','text','Sequelize','number','switch','BOOLEAN','defaultValue','queryInterface','addColumn','cf_%s','getCustomFields','findAndCountAll','addAgents','spread','emit','userCmList:save','removeAgents','userCmList:remove','getAgents','findOne','rimraf','zip-dir','moment','bluebird','mustache','util','ejs','fs-extra','lodash','squel','jsforce','desk.js','to-csv','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils'];(function(_0x3041ce,_0x382f98){var _0x68a7f9=function(_0x3acbfa){while(--_0x3acbfa){_0x3041ce['push'](_0x3041ce['shift']());}};_0x68a7f9(++_0x382f98);}(_0x25fb,0x132));var _0xb25f=function(_0xdb71c,_0x4b2785){_0xdb71c=_0xdb71c-0x0;var _0x4c3eed=_0x25fb[_0xdb71c];return _0x4c3eed;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0xb25f('0x0'));var zipdir=require(_0xb25f('0x1'));var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require(_0xb25f('0x2'));var BPromise=require(_0xb25f('0x3'));var Mustache=require(_0xb25f('0x4'));var util=require(_0xb25f('0x5'));var path=require('path');var sox=require('sox');var csv=require('to-csv');var ejs=require(_0xb25f('0x6'));var fs=require('fs');var fs_extra=require(_0xb25f('0x7'));var _=require(_0xb25f('0x8'));var squel=require(_0xb25f('0x9'));var crypto=require('crypto');var jsforce=require(_0xb25f('0xa'));var deskjs=require(_0xb25f('0xb'));var toCsv=require(_0xb25f('0xc'));var querystring=require('querystring');var Papa=require('papaparse');var Redis=require(_0xb25f('0xd'));var authService=require(_0xb25f('0xe'));var qs=require('../../components/parsers/qs');var as=require(_0xb25f('0xf'));var hardwareService=require(_0xb25f('0x10'));var logger=require(_0xb25f('0x11'))(_0xb25f('0x12'));var utils=require(_0xb25f('0x13'));var config=require(_0xb25f('0x14'));var licenseUtil=require('../../config/license/util');var db=require(_0xb25f('0x15'))['db'];var csv_results;config[_0xb25f('0x16')]=_[_0xb25f('0x17')](config['redis'],{'host':_0xb25f('0x18'),'port':0x18eb});var socket=require(_0xb25f('0x19'))(new Redis(config[_0xb25f('0x16')]));require(_0xb25f('0x1a'))[_0xb25f('0x1b')](socket);function respondWithStatusCode(_0x2fe2cb,_0x5f5997){_0x5f5997=_0x5f5997||0xcc;return function(_0x77e03d){if(_0x77e03d){return _0x2fe2cb[_0xb25f('0x1c')](_0x5f5997);}return _0x2fe2cb[_0xb25f('0x1d')](_0x5f5997)['end']();};}function respondWithResult(_0x1e40b5,_0x5de79e){_0x5de79e=_0x5de79e||0xc8;return function(_0x2823b1){if(_0x2823b1){return _0x1e40b5[_0xb25f('0x1d')](_0x5de79e)[_0xb25f('0x1e')](_0x2823b1);}};}function respondWithFilteredResult(_0x215005,_0x45df74){return function(_0x1e2b5a){if(_0x1e2b5a){var _0x32e352=typeof _0x45df74[_0xb25f('0x1f')]===_0xb25f('0x20')&&typeof _0x45df74[_0xb25f('0x21')]==='undefined';var _0x3c34c8=_0x1e2b5a[_0xb25f('0x22')];var _0x5a8904=_0x32e352?0x0:_0x45df74[_0xb25f('0x1f')];var _0x54b975=_0x32e352?_0x1e2b5a[_0xb25f('0x22')]:_0x45df74['offset']+_0x45df74[_0xb25f('0x21')];var _0x5ee021;if(_0x54b975>=_0x3c34c8){_0x54b975=_0x3c34c8;_0x5ee021=0xc8;}else{_0x5ee021=0xce;}_0x215005['status'](_0x5ee021);return _0x215005['set'](_0xb25f('0x23'),_0x5a8904+'-'+_0x54b975+'/'+_0x3c34c8)[_0xb25f('0x1e')](_0x1e2b5a);}return null;};}function patchUpdates(_0x456353){return function(_0x1802fa){try{jsonpatch[_0xb25f('0x24')](_0x1802fa,_0x456353,!![]);}catch(_0x42815a){return BPromise[_0xb25f('0x25')](_0x42815a);}return _0x1802fa[_0xb25f('0x26')]();};}function saveUpdates(_0x109a42,_0x1dd3c8){return function(_0xa79941){if(_0xa79941){return _0xa79941[_0xb25f('0x27')](_0x109a42)[_0xb25f('0x28')](function(_0x41b0be){return _0x41b0be;});}return null;};}function removeEntity(_0x332bf5,_0x433fd7){return function(_0x22d388){if(_0x22d388){return _0x22d388['destroy']()[_0xb25f('0x28')](function(){var _0x3a9997=_0x22d388[_0xb25f('0x29')]({'plain':!![]});var _0x391c26=_0xb25f('0x2a');return db[_0xb25f('0x2b')][_0xb25f('0x2c')]({'where':{'type':_0x391c26,'resourceId':_0x3a9997['id']}})[_0xb25f('0x28')](function(){return _0x22d388;});})[_0xb25f('0x28')](function(){_0x332bf5[_0xb25f('0x1d')](0xcc)[_0xb25f('0x2d')]();});}};}function handleEntityNotFound(_0x19563b,_0x3fcf0e){return function(_0x37478e){if(!_0x37478e){_0x19563b[_0xb25f('0x1c')](0x194);}return _0x37478e;};}function handleError(_0x20b66e,_0x24e47e){_0x24e47e=_0x24e47e||0x1f4;return function(_0x21c1fa){logger['error'](_0x21c1fa['stack']);if(_0x21c1fa[_0xb25f('0x2e')]){delete _0x21c1fa['name'];}_0x20b66e[_0xb25f('0x1d')](_0x24e47e)[_0xb25f('0x2f')](_0x21c1fa);};}exports['index']=function(_0x2c27d4,_0x308e3e){var _0x1f63bd={},_0x317ab3={},_0x13c428={'count':0x0,'rows':[]};var _0x4443d1=_[_0xb25f('0x30')](db[_0xb25f('0x31')][_0xb25f('0x32')],function(_0x4c0a24){return{'name':_0x4c0a24[_0xb25f('0x33')],'type':_0x4c0a24[_0xb25f('0x34')][_0xb25f('0x35')]};});_0x317ab3[_0xb25f('0x36')]=_[_0xb25f('0x30')](_0x4443d1,'name');_0x317ab3[_0xb25f('0x37')]=_['keys'](_0x2c27d4[_0xb25f('0x37')]);_0x317ab3[_0xb25f('0x38')]=_[_0xb25f('0x39')](_0x317ab3[_0xb25f('0x36')],_0x317ab3['query']);_0x1f63bd['attributes']=_['intersection'](_0x317ab3[_0xb25f('0x36')],qs[_0xb25f('0x3a')](_0x2c27d4['query'][_0xb25f('0x3a')]));_0x1f63bd['attributes']=_0x1f63bd[_0xb25f('0x3b')][_0xb25f('0x3c')]?_0x1f63bd[_0xb25f('0x3b')]:_0x317ab3[_0xb25f('0x36')];if(!_0x2c27d4[_0xb25f('0x37')][_0xb25f('0x3d')](_0xb25f('0x3e'))){_0x1f63bd[_0xb25f('0x21')]=qs[_0xb25f('0x21')](_0x2c27d4['query']['limit']);_0x1f63bd[_0xb25f('0x1f')]=qs[_0xb25f('0x1f')](_0x2c27d4[_0xb25f('0x37')][_0xb25f('0x1f')]);}_0x1f63bd[_0xb25f('0x3f')]=qs[_0xb25f('0x40')](_0x2c27d4['query'][_0xb25f('0x40')]);_0x1f63bd[_0xb25f('0x41')]=qs['filters'](_[_0xb25f('0x42')](_0x2c27d4[_0xb25f('0x37')],_0x317ab3[_0xb25f('0x38')]),_0x4443d1);if(_0x2c27d4[_0xb25f('0x37')][_0xb25f('0x43')]){_0x1f63bd[_0xb25f('0x41')]=_[_0xb25f('0x44')](_0x1f63bd[_0xb25f('0x41')],{'$or':_['map'](_0x4443d1,function(_0x25a779){if(_0x25a779['type']!==_0xb25f('0x45')){var _0x1b883c={};_0x1b883c[_0x25a779[_0xb25f('0x2e')]]={'$like':'%'+_0x2c27d4[_0xb25f('0x37')][_0xb25f('0x43')]+'%'};return _0x1b883c;}})});}_0x1f63bd=_[_0xb25f('0x44')]({},_0x1f63bd,_0x2c27d4[_0xb25f('0x46')]);var _0x5eeab7={'where':_0x1f63bd[_0xb25f('0x41')]};return db[_0xb25f('0x31')][_0xb25f('0x22')](_0x5eeab7)[_0xb25f('0x28')](function(_0x50517a){_0x13c428[_0xb25f('0x22')]=_0x50517a;if(_0x2c27d4[_0xb25f('0x37')][_0xb25f('0x47')]){_0x1f63bd[_0xb25f('0x48')]=[{'all':!![]}];}return db[_0xb25f('0x31')][_0xb25f('0x49')](_0x1f63bd);})[_0xb25f('0x28')](function(_0x2637dc){_0x13c428[_0xb25f('0x4a')]=_0x2637dc;return _0x13c428;})[_0xb25f('0x28')](respondWithFilteredResult(_0x308e3e,_0x1f63bd))[_0xb25f('0x4b')](handleError(_0x308e3e,null));};exports[_0xb25f('0x4c')]=function(_0x44b9b9,_0x569c7b){var _0x79fcb6={'raw':![],'where':{'id':_0x44b9b9[_0xb25f('0x4d')]['id']}},_0x15fb1b={};_0x15fb1b[_0xb25f('0x36')]=_[_0xb25f('0x4e')](db['CmList'][_0xb25f('0x32')]);_0x15fb1b['query']=_['keys'](_0x44b9b9[_0xb25f('0x37')]);_0x15fb1b[_0xb25f('0x38')]=_['intersection'](_0x15fb1b[_0xb25f('0x36')],_0x15fb1b[_0xb25f('0x37')]);_0x79fcb6[_0xb25f('0x3b')]=_[_0xb25f('0x39')](_0x15fb1b['model'],qs[_0xb25f('0x3a')](_0x44b9b9[_0xb25f('0x37')][_0xb25f('0x3a')]));_0x79fcb6[_0xb25f('0x3b')]=_0x79fcb6['attributes'][_0xb25f('0x3c')]?_0x79fcb6[_0xb25f('0x3b')]:_0x15fb1b[_0xb25f('0x36')];if(_0x44b9b9[_0xb25f('0x37')][_0xb25f('0x47')]){_0x79fcb6[_0xb25f('0x48')]=[{'all':!![]}];}_0x79fcb6=_['merge']({},_0x79fcb6,_0x44b9b9[_0xb25f('0x46')]);return db[_0xb25f('0x31')][_0xb25f('0x4f')](_0x79fcb6)['then'](handleEntityNotFound(_0x569c7b,null))['then'](respondWithResult(_0x569c7b,null))[_0xb25f('0x4b')](handleError(_0x569c7b,null));};exports[_0xb25f('0x50')]=function(_0x32d736,_0xeab490){return db[_0xb25f('0x31')][_0xb25f('0x50')](_0x32d736['body'],{})['then'](function(_0xb6313e){var _0x24a859=_0x32d736[_0xb25f('0x51')][_0xb25f('0x29')]({'plain':!![]});if(!_0x24a859)throw new Error(_0xb25f('0x52'));if(_0x24a859[_0xb25f('0x53')]===_0xb25f('0x51')){var _0x5d3498=_0xb6313e[_0xb25f('0x29')]({'plain':!![]});var _0x3106fc=_0xb25f('0x2a');return db[_0xb25f('0x54')][_0xb25f('0x4f')]({'where':{'name':_0x3106fc,'userProfileId':_0x24a859['userProfileId']},'raw':!![]})[_0xb25f('0x28')](function(_0x5be484){if(_0x5be484&&_0x5be484[_0xb25f('0x55')]===0x0){return db[_0xb25f('0x2b')]['create']({'name':_0x5d3498[_0xb25f('0x2e')],'resourceId':_0x5d3498['id'],'type':_0x5be484['name'],'sectionId':_0x5be484['id']},{})[_0xb25f('0x28')](function(){return _0xb6313e;});}else{return _0xb6313e;}})[_0xb25f('0x4b')](function(_0x539652){logger[_0xb25f('0x56')](_0xb25f('0x57'),_0x539652);throw _0x539652;});}return _0xb6313e;})[_0xb25f('0x28')](respondWithResult(_0xeab490,0xc9))['catch'](handleError(_0xeab490,null));};exports['update']=function(_0x90a61e,_0x301b72){if(_0x90a61e[_0xb25f('0x58')]['id']){delete _0x90a61e[_0xb25f('0x58')]['id'];}return db[_0xb25f('0x31')][_0xb25f('0x4f')]({'where':{'id':_0x90a61e[_0xb25f('0x4d')]['id']}})[_0xb25f('0x28')](handleEntityNotFound(_0x301b72,null))['then'](saveUpdates(_0x90a61e[_0xb25f('0x58')],null))['then'](respondWithResult(_0x301b72,null))[_0xb25f('0x4b')](handleError(_0x301b72,null));};exports['destroy']=function(_0x5adee5,_0x1adca4){return db['CmList'][_0xb25f('0x4f')]({'where':{'id':_0x5adee5[_0xb25f('0x4d')]['id']}})[_0xb25f('0x28')](handleEntityNotFound(_0x1adca4,null))[_0xb25f('0x28')](removeEntity(_0x1adca4,null))[_0xb25f('0x4b')](handleError(_0x1adca4,null));};exports[_0xb25f('0x59')]=function(_0x6e86a1,_0x5b711e){return db['CmList'][_0xb25f('0x59')]()['then'](respondWithResult(_0x5b711e,null))[_0xb25f('0x4b')](handleError(_0x5b711e,null));};exports[_0xb25f('0x5a')]=function(_0x1dc3f0,_0x12aff7,_0x11cd7c){if(_0x1dc3f0[_0xb25f('0x58')]['id']){delete _0x1dc3f0[_0xb25f('0x58')]['id'];}return db['CmList'][_0xb25f('0x4f')]({'where':{'id':_0x1dc3f0[_0xb25f('0x4d')]['id']}})[_0xb25f('0x28')](handleEntityNotFound(_0x12aff7,null))['then'](function(_0x301e46){if(_0x301e46){_0x1dc3f0[_0xb25f('0x58')][_0xb25f('0x5b')]=_0x301e46['id'];return db[_0xb25f('0x5c')][_0xb25f('0x50')](_0x1dc3f0[_0xb25f('0x58')]);}})[_0xb25f('0x28')](respondWithResult(_0x12aff7,null))['catch'](handleError(_0x12aff7,null));};exports[_0xb25f('0x5d')]=function(_0x396f75,_0x352d6d,_0x183e77){var _0x37fac8={'raw':![],'where':{}};var _0x3b5bdf={};var _0x23c43b={'count':0x0,'rows':[]};return db['CmList']['findOne']({'where':{'id':_0x396f75['params']['id']}})[_0xb25f('0x28')](handleEntityNotFound(_0x352d6d,null))[_0xb25f('0x28')](function(_0x16e2d4){if(_0x16e2d4){_0x3b5bdf[_0xb25f('0x36')]=_[_0xb25f('0x4e')](db[_0xb25f('0x5c')][_0xb25f('0x32')]);_0x3b5bdf[_0xb25f('0x37')]=_['keys'](_0x396f75['query']);_0x3b5bdf[_0xb25f('0x38')]=_[_0xb25f('0x39')](_0x3b5bdf['model'],_0x3b5bdf[_0xb25f('0x37')]);_0x37fac8[_0xb25f('0x3b')]=_[_0xb25f('0x39')](_0x3b5bdf[_0xb25f('0x36')],qs['fields'](_0x396f75[_0xb25f('0x37')]['fields']));_0x37fac8[_0xb25f('0x3b')]=_0x37fac8[_0xb25f('0x3b')][_0xb25f('0x3c')]?_0x37fac8[_0xb25f('0x3b')]:_0x3b5bdf['model'];if(!_0x396f75['query']['hasOwnProperty']('nolimit')){_0x37fac8[_0xb25f('0x21')]=qs['limit'](_0x396f75[_0xb25f('0x37')]['limit']);_0x37fac8[_0xb25f('0x1f')]=qs['offset'](_0x396f75[_0xb25f('0x37')][_0xb25f('0x1f')]);}_0x37fac8['order']=qs[_0xb25f('0x40')](_0x396f75[_0xb25f('0x37')][_0xb25f('0x40')]);_0x37fac8[_0xb25f('0x41')]=qs[_0xb25f('0x38')](_[_0xb25f('0x42')](_0x396f75[_0xb25f('0x37')],_0x3b5bdf[_0xb25f('0x38')]));_0x37fac8['where']['ListId']=_0x16e2d4['id'];if(_0x396f75['query'][_0xb25f('0x43')]){_0x37fac8[_0xb25f('0x41')]=_[_0xb25f('0x44')](_0x37fac8[_0xb25f('0x41')],{'$or':_[_0xb25f('0x30')](_0x37fac8[_0xb25f('0x3b')],function(_0x46ea3b){var _0x324ec9={};_0x324ec9[_0x46ea3b]={'$like':'%'+_0x396f75[_0xb25f('0x37')][_0xb25f('0x43')]+'%'};return _0x324ec9;})});}_0x37fac8=_['merge']({},_0x37fac8,_0x396f75[_0xb25f('0x46')]);return db[_0xb25f('0x5c')][_0xb25f('0x22')]({'where':_0x37fac8[_0xb25f('0x41')]})['then'](function(_0x2fdcd9){_0x23c43b[_0xb25f('0x22')]=_0x2fdcd9;if(_0x396f75['query']['includeAll']){_0x37fac8[_0xb25f('0x48')]=[{'all':!![]}];}return db[_0xb25f('0x5c')][_0xb25f('0x49')](_0x37fac8);})[_0xb25f('0x28')](function(_0x1cbcb3){_0x23c43b[_0xb25f('0x4a')]=_0x1cbcb3;return _0x23c43b;});}})[_0xb25f('0x28')](respondWithFilteredResult(_0x352d6d,_0x37fac8))['catch'](handleError(_0x352d6d,null));};exports[_0xb25f('0x5e')]=function(_0x42012b,_0x3cf90a,_0x2608f4){return db[_0xb25f('0x31')]['find']({'where':{'id':_0x42012b['params']['id']}})[_0xb25f('0x28')](handleEntityNotFound(_0x3cf90a,null))[_0xb25f('0x28')](function(_0x83c932){if(_0x83c932){return _0x83c932[_0xb25f('0x5e')](_0x42012b['query'][_0xb25f('0x5f')]);}})[_0xb25f('0x28')](respondWithStatusCode(_0x3cf90a,null))[_0xb25f('0x4b')](handleError(_0x3cf90a,null));};exports[_0xb25f('0x60')]=function(_0x4f20e1,_0x180e3f,_0x2558a9){return db[_0xb25f('0x31')][_0xb25f('0x4f')]({'where':{'id':_0x4f20e1[_0xb25f('0x4d')]['id']}})[_0xb25f('0x28')](handleEntityNotFound(_0x180e3f,null))[_0xb25f('0x28')](function(_0x2120e7){if(_0x2120e7){var _0x3b4cfc=[];var _0x5617be={'success':[],'errors':[]};return db[_0xb25f('0x61')][_0xb25f('0x59')]()['then'](function(_0x18264d){if(_0x4f20e1[_0xb25f('0x58')][_0xb25f('0x62')]&&_['isArray'](_0x4f20e1[_0xb25f('0x58')][_0xb25f('0x62')])){if(_0x4f20e1['body'][_0xb25f('0x62')][_0xb25f('0x3c')]){_0x4f20e1[_0xb25f('0x58')][_0xb25f('0x62')]=_0x4f20e1[_0xb25f('0x58')][_0xb25f('0x62')][_0xb25f('0x63')](';')+';';}else{_0x4f20e1[_0xb25f('0x58')][_0xb25f('0x62')]=null;}}else{_0x4f20e1[_0xb25f('0x58')][_0xb25f('0x62')]=null;}if(_0x4f20e1[_0xb25f('0x58')]&&_[_0xb25f('0x64')](_0x4f20e1[_0xb25f('0x58')])){for(var _0xd1f5aa=0x0;_0xd1f5aa<_0x4f20e1[_0xb25f('0x58')]['length'];_0xd1f5aa+=0x1){_0x4f20e1['body'][_0xd1f5aa][_0xb25f('0x5b')]=_0x4f20e1[_0xb25f('0x4d')]['id'];_0x3b4cfc[_0xb25f('0x65')](_0x4f20e1['body'][_0xd1f5aa]);}return BPromise[_0xb25f('0x66')](_0x3b4cfc,function(_0x2c0afc){return db[_0xb25f('0x61')][_0xb25f('0x50')](_[_0xb25f('0x67')](_0x2c0afc,[_0xb25f('0x5f'),'id'])||{},{'fields':_[_0xb25f('0x4e')](_0x18264d),'raw':!![]})[_0xb25f('0x28')](function(_0x41f658){_0x5617be[_0xb25f('0x68')][_0xb25f('0x65')](_0x41f658[_0xb25f('0x69')]);})[_0xb25f('0x4b')](function(_0x26c513){_0x5617be[_0xb25f('0x6a')]['push']({'data':_0x2c0afc,'error':_0x26c513['message']});});})[_0xb25f('0x28')](function(_0x52ff86){return _0x5617be;})[_0xb25f('0x4b')](function(_0xc4f160){return _0xc4f160;});}else{_0x180e3f[_0xb25f('0x1d')](0x190)[_0xb25f('0x1e')]({'message':_0xb25f('0x6b')});}});}})[_0xb25f('0x28')](respondWithResult(_0x180e3f,null))['catch'](handleError(_0x180e3f,null));};exports['getContacts']=function(_0x106718,_0x4cf21d,_0x72c935){var _0x284374;return db[_0xb25f('0x31')][_0xb25f('0x4f')]({'where':{'id':_0x106718[_0xb25f('0x4d')]['id']},'include':[{'model':db[_0xb25f('0x6c')],'as':_0xb25f('0x6d')}]})[_0xb25f('0x28')](handleEntityNotFound(_0x4cf21d,null))[_0xb25f('0x28')](function(_0x99d08b){if(_0x99d08b){_0x284374=_0x99d08b;return db[_0xb25f('0x61')][_0xb25f('0x32')];}})['then'](function(_0x3e4f7f){if(_0x3e4f7f){var _0x797ff4={};var _0x2e1b1e={};_0x2e1b1e[_0xb25f('0x36')]=_[_0xb25f('0x6e')](_[_0xb25f('0x4e')](_0x3e4f7f),_[_0xb25f('0x30')](_0x284374[_0xb25f('0x6d')],function(_0x354bc5){return util[_0xb25f('0x6f')](_0xb25f('0x70'),_0x354bc5['id']);}));_0x2e1b1e['query']=_['keys'](_0x106718[_0xb25f('0x37')]);_0x2e1b1e[_0xb25f('0x38')]=_['intersection'](_0x2e1b1e[_0xb25f('0x36')],_0x2e1b1e[_0xb25f('0x37')]);_0x797ff4[_0xb25f('0x3b')]=_['intersection'](_0x2e1b1e[_0xb25f('0x36')],qs[_0xb25f('0x3a')](_0x106718[_0xb25f('0x37')][_0xb25f('0x3a')]));_0x797ff4[_0xb25f('0x3b')]=_0x797ff4['attributes'][_0xb25f('0x3c')]?_0x797ff4[_0xb25f('0x3b')]:_0x2e1b1e[_0xb25f('0x36')];if(!_0x106718['query'][_0xb25f('0x3d')](_0xb25f('0x3e'))){_0x797ff4[_0xb25f('0x21')]=qs[_0xb25f('0x21')](_0x106718['query'][_0xb25f('0x21')]);_0x797ff4['offset']=qs[_0xb25f('0x1f')](_0x106718[_0xb25f('0x37')]['offset']);}_0x797ff4['order']=qs[_0xb25f('0x40')](_0x106718[_0xb25f('0x37')][_0xb25f('0x40')]);_0x797ff4[_0xb25f('0x41')]=qs[_0xb25f('0x38')](_['pick'](_0x106718[_0xb25f('0x37')],_0x2e1b1e[_0xb25f('0x38')]));_0x797ff4[_0xb25f('0x71')]=!![];if(_0x106718[_0xb25f('0x37')][_0xb25f('0x43')]){_0x797ff4['where']=_[_0xb25f('0x44')](_0x797ff4['where'],{'$or':_['map'](_0x797ff4[_0xb25f('0x3b')],function(_0x591624){var _0x1091da={};_0x1091da[_0x591624]={'$like':'%'+_0x106718['query'][_0xb25f('0x43')]+'%'};return _0x1091da;})});}_0x797ff4=_['merge']({},_0x797ff4,_0x106718[_0xb25f('0x46')]);return _0x284374[_0xb25f('0x72')](_0x797ff4);}})[_0xb25f('0x28')](respondWithResult(_0x4cf21d,null))['catch'](handleError(_0x4cf21d,null));};exports['getContactsCsv']=function(_0x4ab0f5,_0x2f08af,_0x1d376a){var _0x570138;var _0x9ceb2b;var _0xa69276;var _0x2ce134=_0x4ab0f5[_0xb25f('0x4d')]['id'];csv_results=[];return db[_0xb25f('0x73')][_0xb25f('0x49')]({'attributes':['id','name'],'raw':!![],'order':[_0xb25f('0x74')]})[_0xb25f('0x28')](function(_0x484827){_0x570138=_0x484827;var _0x7da176=_[_0xb25f('0x4e')](db['CmContact'][_0xb25f('0x32')]);return db[_0xb25f('0x6c')][_0xb25f('0x49')]({'raw':!![],'attributes':['id',_0xb25f('0x75')]})[_0xb25f('0x28')](function(_0x52aa29){_0x9ceb2b=_0x52aa29;var _0x4952e9=squel['select']()['fields'](_0x7da176)['from'](_0xb25f('0x76'),'c')[_0xb25f('0x41')](_0xb25f('0x77'),_0x2ce134)[_0xb25f('0x41')](_0xb25f('0x78'))['distinct']();for(var _0xa64e94=0x0;_0xa64e94<_0x9ceb2b[_0xb25f('0x3c')];_0xa64e94++){_0x4952e9[_0xb25f('0x79')]('c.cf_'+_0x9ceb2b[_0xa64e94]['id'],_0xb25f('0x7a')+_0x9ceb2b[_0xa64e94][_0xb25f('0x75')]);}for(var _0xa64e94=0x0;_0xa64e94<_0x570138['length'];_0xa64e94++){_0x4952e9[_0xb25f('0x79')](squel['select']()['field'](_0xb25f('0x7b'))[_0xb25f('0x7c')]('cm_contact_has_items')[_0xb25f('0x41')]('ItemTypeId\x20=\x20?',_0x570138[_0xa64e94]['id'])[_0xb25f('0x41')](_0xb25f('0x7d')),_0xb25f('0x7e')+_0x570138[_0xa64e94][_0xb25f('0x2e')]);_0x4952e9[_0xb25f('0x79')](squel['select']()[_0xb25f('0x79')](_0xb25f('0x7f'))[_0xb25f('0x7c')]('cm_contact_has_items')['where'](_0xb25f('0x80'),_0x570138[_0xa64e94]['id'])['where']('CmContactId\x20=\x20c.id'),'description_additionalPhone_'+_0x570138[_0xa64e94]['name']);}var _0x167397=[];_0x167397['push'](_0x4952e9['toString']());BPromise[_0xb25f('0x66')](_0x167397,handleQuery)[_0xb25f('0x28')](function(_0x441bfc){handleQuery(_0x4952e9[_0xb25f('0x81')]());var _0x4d7cf3=csv_results[0x0];if(!_['isEmpty'](_0x4d7cf3)){var _0x2dda24=toCsv(_0x4d7cf3);var _0x3c38db=Date[_0xb25f('0x82')]();fs[_0xb25f('0x83')](util['format']('/tmp/list_%d_%s.csv',_0x2ce134,_0x3c38db),_0x2dda24);_0x2f08af[_0xb25f('0x84')](_0xb25f('0x85'),'attachment;\x20filename='+util[_0xb25f('0x6f')](_0xb25f('0x86'),_0x2ce134,_0x3c38db));_0x2f08af[_0xb25f('0x84')](_0xb25f('0x87'),_0xb25f('0x88'));return _0x2f08af[_0xb25f('0x89')](util[_0xb25f('0x6f')](_0xb25f('0x8a'),_0x2ce134,_0x3c38db));}else{return _0x2f08af[_0xb25f('0x1c')](0xcc);}});});});};exports[_0xb25f('0x8b')]=function(_0x459cb9,_0x34e395,_0x1f608d){var _0x4371cc;delete _0x459cb9[_0xb25f('0x58')]['id'];return db[_0xb25f('0x31')]['findOne']({'where':{'id':_0x459cb9[_0xb25f('0x4d')]['id']}})[_0xb25f('0x28')](handleEntityNotFound(_0x34e395,null))[_0xb25f('0x28')](function(_0x4132c8){if(_0x4132c8){return db[_0xb25f('0x8c')][_0xb25f('0x8d')](function(_0x19b452){return db[_0xb25f('0x6c')]['create'](_0x459cb9['body'],{'transaction':_0x19b452})[_0xb25f('0x28')](function(_0x421072){_0x4371cc=_0x421072;return _0x4132c8[_0xb25f('0x8e')](_0x421072,{'transaction':_0x19b452});})[_0xb25f('0x28')](function(){var _0x5ebeb0={'type':db['Sequelize'][_0xb25f('0x8f')],'transaction':_0x19b452};switch(_0x459cb9[_0xb25f('0x58')][_0xb25f('0x34')]){case _0xb25f('0x90'):_0x5ebeb0['type']=db[_0xb25f('0x91')][_0xb25f('0x8f')];break;case _0xb25f('0x92'):_0x5ebeb0[_0xb25f('0x34')]=db[_0xb25f('0x91')]['INTEGER'];break;case _0xb25f('0x93'):_0x5ebeb0[_0xb25f('0x34')]=db[_0xb25f('0x91')][_0xb25f('0x94')];_0x5ebeb0[_0xb25f('0x95')]=![];break;default:}return db[_0xb25f('0x8c')][_0xb25f('0x96')][_0xb25f('0x97')](_0xb25f('0x76'),util[_0xb25f('0x6f')](_0xb25f('0x98'),_0x4371cc['id']),_0x5ebeb0);})[_0xb25f('0x28')](function(){return _0x4371cc;});});}})[_0xb25f('0x28')](respondWithResult(_0x34e395,null))[_0xb25f('0x4b')](handleError(_0x34e395,null));};exports[_0xb25f('0x99')]=function(_0x6c1ca0,_0x1433b3,_0xf33f18){var _0x972ca0={};var _0x1abfd8={};var _0x5b16d3;var _0x45ea45;return db[_0xb25f('0x31')]['findOne']({'where':{'id':_0x6c1ca0[_0xb25f('0x4d')]['id']}})[_0xb25f('0x28')](handleEntityNotFound(_0x1433b3,null))[_0xb25f('0x28')](function(_0x2817e1){if(_0x2817e1){_0x5b16d3=_0x2817e1;_0x1abfd8[_0xb25f('0x36')]=_[_0xb25f('0x4e')](db[_0xb25f('0x6c')][_0xb25f('0x32')]);_0x1abfd8[_0xb25f('0x37')]=_['keys'](_0x6c1ca0[_0xb25f('0x37')]);_0x1abfd8['filters']=_[_0xb25f('0x39')](_0x1abfd8[_0xb25f('0x36')],_0x1abfd8[_0xb25f('0x37')]);_0x972ca0[_0xb25f('0x3b')]=_[_0xb25f('0x39')](_0x1abfd8[_0xb25f('0x36')],qs[_0xb25f('0x3a')](_0x6c1ca0['query'][_0xb25f('0x3a')]));_0x972ca0[_0xb25f('0x3b')]=_0x972ca0[_0xb25f('0x3b')][_0xb25f('0x3c')]?_0x972ca0[_0xb25f('0x3b')]:_0x1abfd8[_0xb25f('0x36')];_0x972ca0[_0xb25f('0x3f')]=qs['sort'](_0x6c1ca0[_0xb25f('0x37')][_0xb25f('0x40')]);_0x972ca0[_0xb25f('0x41')]=qs[_0xb25f('0x38')](_[_0xb25f('0x42')](_0x6c1ca0['query'],_0x1abfd8[_0xb25f('0x38')]));_0x972ca0[_0xb25f('0x41')]=_['merge'](_0x972ca0['where'],{'$or':[{'ListId':_0x2817e1['id']},{'ListId':null}]});if(_0x6c1ca0['query'][_0xb25f('0x43')]){_0x972ca0[_0xb25f('0x41')]=_[_0xb25f('0x44')](_0x972ca0['where'],{'$or':_[_0xb25f('0x30')](_0x972ca0[_0xb25f('0x3b')],function(_0x3d11de){var _0x4611f7={};_0x4611f7[_0x3d11de]={'$like':'%'+_0x6c1ca0[_0xb25f('0x37')][_0xb25f('0x43')]+'%'};return _0x4611f7;})});}_0x972ca0=_[_0xb25f('0x44')]({},_0x972ca0,_0x6c1ca0[_0xb25f('0x46')]);return db[_0xb25f('0x6c')][_0xb25f('0x9a')](_0x972ca0);}})[_0xb25f('0x28')](respondWithResult(_0x1433b3,null))['catch'](handleError(_0x1433b3,null));};exports['getGlobalCustomFields']=function(_0x5e9f5d,_0xc971ca){return db['CmCustomField'][_0xb25f('0x9a')]({'where':{'ListId':null}})[_0xb25f('0x28')](handleEntityNotFound(_0xc971ca,null))[_0xb25f('0x28')](function(_0x57fba5){return _0x57fba5;})['then'](respondWithResult(_0xc971ca,null))[_0xb25f('0x4b')](handleError(_0xc971ca,null));};exports[_0xb25f('0x9b')]=function(_0x4f773e,_0x15d935,_0x43039e){return db[_0xb25f('0x31')]['find']({'where':{'id':_0x4f773e[_0xb25f('0x4d')]['id']}})['then'](handleEntityNotFound(_0x15d935,null))['then'](function(_0x5d47d5){if(_0x5d47d5){return _0x5d47d5[_0xb25f('0x9b')](_0x4f773e[_0xb25f('0x58')]['ids'],_[_0xb25f('0x67')](_0x4f773e['body'],[_0xb25f('0x5f'),'id'])||{})[_0xb25f('0x9c')](function(_0x3954ed){for(var _0x580a75=0x0;_0x580a75<_0x4f773e['body']['ids'][_0xb25f('0x3c')];_0x580a75+=0x1){socket[_0xb25f('0x9d')](_0xb25f('0x9e'),{'UserId':Number(_0x4f773e[_0xb25f('0x58')]['ids'][_0x580a75]),'CmListId':Number(_0x4f773e[_0xb25f('0x4d')]['id'])});}return _0x3954ed;});}})[_0xb25f('0x28')](respondWithResult(_0x15d935,null))[_0xb25f('0x4b')](handleError(_0x15d935,null));};exports[_0xb25f('0x9f')]=function(_0x1455d0,_0x1cc801,_0x66f228){return db[_0xb25f('0x31')][_0xb25f('0x4f')]({'where':{'id':_0x1455d0[_0xb25f('0x4d')]['id']}})[_0xb25f('0x28')](handleEntityNotFound(_0x1cc801,null))['then'](function(_0x11a207){if(_0x11a207){return _0x11a207['removeAgents'](_0x1455d0['query'][_0xb25f('0x5f')])[_0xb25f('0x28')](function(){if(_[_0xb25f('0x64')](_0x1455d0[_0xb25f('0x37')][_0xb25f('0x5f')])){for(var _0x222509=0x0;_0x222509<_0x1455d0[_0xb25f('0x37')]['ids'][_0xb25f('0x3c')];_0x222509+=0x1){socket['emit'](_0xb25f('0xa0'),{'UserId':Number(_0x1455d0[_0xb25f('0x37')][_0xb25f('0x5f')][_0x222509]),'CmListId':Number(_0x1455d0['params']['id'])});}}else{socket[_0xb25f('0x9d')](_0xb25f('0xa0'),{'UserId':Number(_0x1455d0[_0xb25f('0x37')][_0xb25f('0x5f')]),'CmListId':Number(_0x1455d0[_0xb25f('0x4d')]['id'])});}});}})['then'](respondWithStatusCode(_0x1cc801,null))[_0xb25f('0x4b')](handleError(_0x1cc801,null));};exports[_0xb25f('0xa1')]=function(_0x57464a,_0x2197a2,_0x42b29a){var _0x47ee32={};var _0x317eb0={};var _0xef6506;var _0x1898ca;return db[_0xb25f('0x31')][_0xb25f('0xa2')]({'where':{'id':_0x57464a[_0xb25f('0x4d')]['id']}})[_0xb25f('0x28')](handleEntityNotFound(_0x2197a2,null))[_0xb25f('0x28')](function(_0x5a71ac){if(_0x5a71ac){_0xef6506=_0x5a71ac;_0x317eb0['model']=_[_0xb25f('0x4e')](db['User'][_0xb25f('0x32')]);_0x317eb0[_0xb25f('0x37')]=_['keys'](_0x57464a[_0xb25f('0x37')]);_0x317eb0['filters']=_[_0xb25f('0x39')](_0x317eb0[_0xb25f('0x36')],_0x317eb0[_0xb25f('0x37')]);_0x47ee32[_0xb25f('0x3b')]=_['intersection'](_0x317eb0[_0xb25f('0x36')],qs['fields'](_0x57464a['query'][_0xb25f('0x3a')]));_0x47ee32[_0xb25f('0x3b')]=_0x47ee32['attributes'][_0xb25f('0x3c')]?_0x47ee32['attributes']:_0x317eb0[_0xb25f('0x36')];_0x47ee32[_0xb25f('0x3f')]=qs['sort'](_0x57464a[_0xb25f('0x37')][_0xb25f('0x40')]);_0x47ee32[_0xb25f('0x41')]=qs[_0xb25f('0x38')](_[_0xb25f('0x42')](_0x57464a['query'],_0x317eb0[_0xb25f('0x38')]));if(_0x57464a['query']['filter']){_0x47ee32[_0xb25f('0x41')]=_['merge'](_0x47ee32[_0xb25f('0x41')],{'$or':_[_0xb25f('0x30')](_0x47ee32['attributes'],function(_0x25dbcb){var _0x17e864={};_0x17e864[_0x25dbcb]={'$like':'%'+_0x57464a['query']['filter']+'%'};return _0x17e864;})});}_0x47ee32=_[_0xb25f('0x44')]({},_0x47ee32,_0x57464a[_0xb25f('0x46')]);return _0xef6506[_0xb25f('0xa1')](_0x47ee32);}})[_0xb25f('0x28')](function(_0x29f4d2){if(_0x29f4d2){_0x1898ca=_0x29f4d2[_0xb25f('0x3c')];if(!_0x57464a[_0xb25f('0x37')][_0xb25f('0x3d')](_0xb25f('0x3e'))){_0x47ee32[_0xb25f('0x21')]=qs[_0xb25f('0x21')](_0x57464a[_0xb25f('0x37')]['limit']);_0x47ee32[_0xb25f('0x1f')]=qs['offset'](_0x57464a['query']['offset']);}return _0xef6506[_0xb25f('0xa1')](_0x47ee32);}})['then'](function(_0x53ef15){if(_0x53ef15){return _0x53ef15?{'count':_0x1898ca,'rows':_0x53ef15}:null;}})[_0xb25f('0x28')](respondWithResult(_0x2197a2,null))[_0xb25f('0x4b')](handleError(_0x2197a2,null));};function handleQuery(_0x4610a5){logger['info'](_0x4610a5);return db['sequelize'][_0xb25f('0x37')](_0x4610a5)[_0xb25f('0x9c')](function(_0x338e21){csv_results[_0xb25f('0x65')](_0x338e21);})[_0xb25f('0x4b')](function(_0x12bc02){logger[_0xb25f('0x56')](_0x12bc02['message']);});}
\ No newline at end of file
+var _0xf715=['setHeader','Content-disposition','attachment;\x20filename=','list_%d_%s.csv','Content-type','text/csv','download','addCustomField','sequelize','transaction','addCustomFields','Sequelize','TEXT','number','INTEGER','BOOLEAN','defaultValue','queryInterface','addColumn','cf_%s','getCustomFields','findAndCountAll','getGlobalCustomFields','addAgents','spread','emit','userCmList:save','removeAgents','userCmList:remove','getAgents','User','info','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','to-csv','ejs','squel','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/environment','../../config/license/util','../../mysqldb','defaults','redis','localhost','socket.io-emitter','./cmList.socket','register','sendStatus','end','json','offset','undefined','limit','count','set','Content-Range','apply','reject','save','update','then','destroy','get','Lists','status','error','stack','name','send','index','rawAttributes','fieldName','type','map','query','keys','filters','intersection','model','fields','attributes','hasOwnProperty','nolimit','sort','where','pick','filter','merge','options','CmList','includeAll','include','findAll','rows','catch','params','length','find','create','body','role','autoAssociation','UserProfileResource','describe','addDisposition','ListId','getDispositions','findOne','Disposition','order','removeDispositions','ids','addContacts','CmContact','tags','isArray','join','omit','push','errors','message','Malformed\x20request\x20syntax','getContacts','CmCustomField','CustomFields','concat','raw','ContactItemType','OrderBy','select','from','cm_contacts','c.ListId\x20=\x20?','c.deletedAt\x20is\x20null','distinct','field','customField_','alias','item','cm_contact_has_items','ItemTypeId\x20=\x20?','additionalPhone_','description_additionalPhone_','each','toString','isEmpty','writeFileSync','format','/tmp/list_%d_%s.csv'];(function(_0x38aece,_0x5a66e3){var _0x2e06e4=function(_0x4f9d09){while(--_0x4f9d09){_0x38aece['push'](_0x38aece['shift']());}};_0x2e06e4(++_0x5a66e3);}(_0xf715,0xc5));var _0x5f71=function(_0x5b410d,_0x2f8be5){_0x5b410d=_0x5b410d-0x0;var _0x5edf1a=_0xf715[_0x5b410d];return _0x5edf1a;};'use strict';var emlformat=require(_0x5f71('0x0'));var rimraf=require(_0x5f71('0x1'));var zipdir=require(_0x5f71('0x2'));var jsonpatch=require(_0x5f71('0x3'));var rp=require(_0x5f71('0x4'));var moment=require(_0x5f71('0x5'));var BPromise=require(_0x5f71('0x6'));var Mustache=require(_0x5f71('0x7'));var util=require(_0x5f71('0x8'));var path=require('path');var sox=require('sox');var csv=require(_0x5f71('0x9'));var ejs=require(_0x5f71('0xa'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require('lodash');var squel=require(_0x5f71('0xb'));var crypto=require('crypto');var jsforce=require(_0x5f71('0xc'));var deskjs=require(_0x5f71('0xd'));var toCsv=require(_0x5f71('0x9'));var querystring=require(_0x5f71('0xe'));var Papa=require(_0x5f71('0xf'));var Redis=require(_0x5f71('0x10'));var authService=require(_0x5f71('0x11'));var qs=require('../../components/parsers/qs');var as=require(_0x5f71('0x12'));var hardwareService=require(_0x5f71('0x13'));var logger=require(_0x5f71('0x14'))(_0x5f71('0x15'));var utils=require('../../config/utils');var config=require(_0x5f71('0x16'));var licenseUtil=require(_0x5f71('0x17'));var db=require(_0x5f71('0x18'))['db'];var csv_results;config['redis']=_[_0x5f71('0x19')](config[_0x5f71('0x1a')],{'host':_0x5f71('0x1b'),'port':0x18eb});var socket=require(_0x5f71('0x1c'))(new Redis(config[_0x5f71('0x1a')]));require(_0x5f71('0x1d'))[_0x5f71('0x1e')](socket);function respondWithStatusCode(_0x2b6923,_0x152bb4){_0x152bb4=_0x152bb4||0xcc;return function(_0x2167ca){if(_0x2167ca){return _0x2b6923[_0x5f71('0x1f')](_0x152bb4);}return _0x2b6923['status'](_0x152bb4)[_0x5f71('0x20')]();};}function respondWithResult(_0xcc8f0a,_0x564710){_0x564710=_0x564710||0xc8;return function(_0x2a244a){if(_0x2a244a){return _0xcc8f0a['status'](_0x564710)[_0x5f71('0x21')](_0x2a244a);}};}function respondWithFilteredResult(_0x42d30b,_0x318004){return function(_0x170949){if(_0x170949){var _0x3026f7=typeof _0x318004[_0x5f71('0x22')]===_0x5f71('0x23')&&typeof _0x318004[_0x5f71('0x24')]==='undefined';var _0x76ec93=_0x170949[_0x5f71('0x25')];var _0x4cd991=_0x3026f7?0x0:_0x318004[_0x5f71('0x22')];var _0x40ea4=_0x3026f7?_0x170949[_0x5f71('0x25')]:_0x318004[_0x5f71('0x22')]+_0x318004[_0x5f71('0x24')];var _0x3ee9d5;if(_0x40ea4>=_0x76ec93){_0x40ea4=_0x76ec93;_0x3ee9d5=0xc8;}else{_0x3ee9d5=0xce;}_0x42d30b['status'](_0x3ee9d5);return _0x42d30b[_0x5f71('0x26')](_0x5f71('0x27'),_0x4cd991+'-'+_0x40ea4+'/'+_0x76ec93)[_0x5f71('0x21')](_0x170949);}return null;};}function patchUpdates(_0xfd6b1c){return function(_0xd8b5ba){try{jsonpatch[_0x5f71('0x28')](_0xd8b5ba,_0xfd6b1c,!![]);}catch(_0x51612b){return BPromise[_0x5f71('0x29')](_0x51612b);}return _0xd8b5ba[_0x5f71('0x2a')]();};}function saveUpdates(_0xe8fcbc,_0x26f8fc){return function(_0x5d6875){if(_0x5d6875){return _0x5d6875[_0x5f71('0x2b')](_0xe8fcbc)[_0x5f71('0x2c')](function(_0xbc8926){return _0xbc8926;});}return null;};}function removeEntity(_0x22918e,_0x5bd54f){return function(_0x53d900){if(_0x53d900){return _0x53d900[_0x5f71('0x2d')]()[_0x5f71('0x2c')](function(){var _0x17f821=_0x53d900[_0x5f71('0x2e')]({'plain':!![]});var _0x10e354=_0x5f71('0x2f');return db['UserProfileResource'][_0x5f71('0x2d')]({'where':{'type':_0x10e354,'resourceId':_0x17f821['id']}})[_0x5f71('0x2c')](function(){return _0x53d900;});})[_0x5f71('0x2c')](function(){_0x22918e[_0x5f71('0x30')](0xcc)[_0x5f71('0x20')]();});}};}function handleEntityNotFound(_0x328b52,_0xdd4b15){return function(_0x50a66f){if(!_0x50a66f){_0x328b52[_0x5f71('0x1f')](0x194);}return _0x50a66f;};}function handleError(_0x2f85d9,_0x51019f){_0x51019f=_0x51019f||0x1f4;return function(_0x3f6151){logger[_0x5f71('0x31')](_0x3f6151[_0x5f71('0x32')]);if(_0x3f6151['name']){delete _0x3f6151[_0x5f71('0x33')];}_0x2f85d9[_0x5f71('0x30')](_0x51019f)[_0x5f71('0x34')](_0x3f6151);};}exports[_0x5f71('0x35')]=function(_0x41f26d,_0xf2a709){var _0x176ac5={},_0x302ec3={},_0x26df6a={'count':0x0,'rows':[]};var _0x5c5834=_['map'](db['CmList'][_0x5f71('0x36')],function(_0x2b3b11){return{'name':_0x2b3b11[_0x5f71('0x37')],'type':_0x2b3b11[_0x5f71('0x38')]['key']};});_0x302ec3['model']=_[_0x5f71('0x39')](_0x5c5834,'name');_0x302ec3[_0x5f71('0x3a')]=_[_0x5f71('0x3b')](_0x41f26d[_0x5f71('0x3a')]);_0x302ec3[_0x5f71('0x3c')]=_[_0x5f71('0x3d')](_0x302ec3[_0x5f71('0x3e')],_0x302ec3[_0x5f71('0x3a')]);_0x176ac5['attributes']=_[_0x5f71('0x3d')](_0x302ec3[_0x5f71('0x3e')],qs['fields'](_0x41f26d[_0x5f71('0x3a')][_0x5f71('0x3f')]));_0x176ac5[_0x5f71('0x40')]=_0x176ac5[_0x5f71('0x40')]['length']?_0x176ac5['attributes']:_0x302ec3[_0x5f71('0x3e')];if(!_0x41f26d[_0x5f71('0x3a')][_0x5f71('0x41')](_0x5f71('0x42'))){_0x176ac5[_0x5f71('0x24')]=qs[_0x5f71('0x24')](_0x41f26d[_0x5f71('0x3a')][_0x5f71('0x24')]);_0x176ac5[_0x5f71('0x22')]=qs['offset'](_0x41f26d[_0x5f71('0x3a')][_0x5f71('0x22')]);}_0x176ac5['order']=qs['sort'](_0x41f26d[_0x5f71('0x3a')][_0x5f71('0x43')]);_0x176ac5[_0x5f71('0x44')]=qs['filters'](_[_0x5f71('0x45')](_0x41f26d[_0x5f71('0x3a')],_0x302ec3['filters']),_0x5c5834);if(_0x41f26d[_0x5f71('0x3a')][_0x5f71('0x46')]){_0x176ac5[_0x5f71('0x44')]=_[_0x5f71('0x47')](_0x176ac5[_0x5f71('0x44')],{'$or':_[_0x5f71('0x39')](_0x5c5834,function(_0x38a25d){if(_0x38a25d[_0x5f71('0x38')]!=='VIRTUAL'){var _0x3d3e5={};_0x3d3e5[_0x38a25d[_0x5f71('0x33')]]={'$like':'%'+_0x41f26d[_0x5f71('0x3a')][_0x5f71('0x46')]+'%'};return _0x3d3e5;}})});}_0x176ac5=_[_0x5f71('0x47')]({},_0x176ac5,_0x41f26d[_0x5f71('0x48')]);var _0xe28d24={'where':_0x176ac5['where']};return db[_0x5f71('0x49')][_0x5f71('0x25')](_0xe28d24)['then'](function(_0x4a94bd){_0x26df6a[_0x5f71('0x25')]=_0x4a94bd;if(_0x41f26d[_0x5f71('0x3a')][_0x5f71('0x4a')]){_0x176ac5[_0x5f71('0x4b')]=[{'all':!![]}];}return db['CmList'][_0x5f71('0x4c')](_0x176ac5);})[_0x5f71('0x2c')](function(_0x14ef24){_0x26df6a[_0x5f71('0x4d')]=_0x14ef24;return _0x26df6a;})['then'](respondWithFilteredResult(_0xf2a709,_0x176ac5))[_0x5f71('0x4e')](handleError(_0xf2a709,null));};exports['show']=function(_0x5957c6,_0x18b3dc){var _0x5e930d={'raw':![],'where':{'id':_0x5957c6[_0x5f71('0x4f')]['id']}},_0x46b849={};_0x46b849[_0x5f71('0x3e')]=_['keys'](db[_0x5f71('0x49')][_0x5f71('0x36')]);_0x46b849[_0x5f71('0x3a')]=_['keys'](_0x5957c6[_0x5f71('0x3a')]);_0x46b849[_0x5f71('0x3c')]=_[_0x5f71('0x3d')](_0x46b849['model'],_0x46b849['query']);_0x5e930d[_0x5f71('0x40')]=_[_0x5f71('0x3d')](_0x46b849[_0x5f71('0x3e')],qs[_0x5f71('0x3f')](_0x5957c6['query']['fields']));_0x5e930d[_0x5f71('0x40')]=_0x5e930d[_0x5f71('0x40')][_0x5f71('0x50')]?_0x5e930d[_0x5f71('0x40')]:_0x46b849[_0x5f71('0x3e')];if(_0x5957c6['query'][_0x5f71('0x4a')]){_0x5e930d[_0x5f71('0x4b')]=[{'all':!![]}];}_0x5e930d=_['merge']({},_0x5e930d,_0x5957c6[_0x5f71('0x48')]);return db[_0x5f71('0x49')][_0x5f71('0x51')](_0x5e930d)[_0x5f71('0x2c')](handleEntityNotFound(_0x18b3dc,null))[_0x5f71('0x2c')](respondWithResult(_0x18b3dc,null))[_0x5f71('0x4e')](handleError(_0x18b3dc,null));};exports[_0x5f71('0x52')]=function(_0x44ea85,_0x28b48f){return db['CmList'][_0x5f71('0x52')](_0x44ea85[_0x5f71('0x53')],{})['then'](function(_0xa19060){var _0x48c837=_0x44ea85['user'][_0x5f71('0x2e')]({'plain':!![]});if(!_0x48c837)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x48c837[_0x5f71('0x54')]==='user'){var _0x5dd48c=_0xa19060['get']({'plain':!![]});var _0x4fceba='Lists';return db['UserProfileSection'][_0x5f71('0x51')]({'where':{'name':_0x4fceba,'userProfileId':_0x48c837['userProfileId']},'raw':!![]})[_0x5f71('0x2c')](function(_0x4a2bc3){if(_0x4a2bc3&&_0x4a2bc3[_0x5f71('0x55')]===0x0){return db[_0x5f71('0x56')][_0x5f71('0x52')]({'name':_0x5dd48c[_0x5f71('0x33')],'resourceId':_0x5dd48c['id'],'type':_0x4a2bc3[_0x5f71('0x33')],'sectionId':_0x4a2bc3['id']},{})['then'](function(){return _0xa19060;});}else{return _0xa19060;}})[_0x5f71('0x4e')](function(_0x45d528){logger[_0x5f71('0x31')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x45d528);throw _0x45d528;});}return _0xa19060;})['then'](respondWithResult(_0x28b48f,0xc9))[_0x5f71('0x4e')](handleError(_0x28b48f,null));};exports[_0x5f71('0x2b')]=function(_0x189df5,_0x4f6e4f){if(_0x189df5[_0x5f71('0x53')]['id']){delete _0x189df5[_0x5f71('0x53')]['id'];}return db[_0x5f71('0x49')][_0x5f71('0x51')]({'where':{'id':_0x189df5[_0x5f71('0x4f')]['id']}})[_0x5f71('0x2c')](handleEntityNotFound(_0x4f6e4f,null))[_0x5f71('0x2c')](saveUpdates(_0x189df5[_0x5f71('0x53')],null))[_0x5f71('0x2c')](respondWithResult(_0x4f6e4f,null))['catch'](handleError(_0x4f6e4f,null));};exports[_0x5f71('0x2d')]=function(_0x28d967,_0x478674){return db[_0x5f71('0x49')][_0x5f71('0x51')]({'where':{'id':_0x28d967['params']['id']}})[_0x5f71('0x2c')](handleEntityNotFound(_0x478674,null))[_0x5f71('0x2c')](removeEntity(_0x478674,null))['catch'](handleError(_0x478674,null));};exports[_0x5f71('0x57')]=function(_0x1a9c97,_0x28f28b){return db[_0x5f71('0x49')][_0x5f71('0x57')]()[_0x5f71('0x2c')](respondWithResult(_0x28f28b,null))[_0x5f71('0x4e')](handleError(_0x28f28b,null));};exports[_0x5f71('0x58')]=function(_0x505bb7,_0x5d481b,_0x356a15){if(_0x505bb7[_0x5f71('0x53')]['id']){delete _0x505bb7['body']['id'];}return db['CmList']['find']({'where':{'id':_0x505bb7['params']['id']}})['then'](handleEntityNotFound(_0x5d481b,null))[_0x5f71('0x2c')](function(_0x5e685e){if(_0x5e685e){_0x505bb7['body'][_0x5f71('0x59')]=_0x5e685e['id'];return db['Disposition'][_0x5f71('0x52')](_0x505bb7[_0x5f71('0x53')]);}})[_0x5f71('0x2c')](respondWithResult(_0x5d481b,null))[_0x5f71('0x4e')](handleError(_0x5d481b,null));};exports[_0x5f71('0x5a')]=function(_0x3ee2de,_0x185754,_0x3b09d7){var _0x57e462={'raw':![],'where':{}};var _0x4edf8a={};var _0x481aca={'count':0x0,'rows':[]};return db[_0x5f71('0x49')][_0x5f71('0x5b')]({'where':{'id':_0x3ee2de['params']['id']}})['then'](handleEntityNotFound(_0x185754,null))[_0x5f71('0x2c')](function(_0x1389c9){if(_0x1389c9){_0x4edf8a[_0x5f71('0x3e')]=_[_0x5f71('0x3b')](db[_0x5f71('0x5c')][_0x5f71('0x36')]);_0x4edf8a[_0x5f71('0x3a')]=_[_0x5f71('0x3b')](_0x3ee2de[_0x5f71('0x3a')]);_0x4edf8a[_0x5f71('0x3c')]=_[_0x5f71('0x3d')](_0x4edf8a[_0x5f71('0x3e')],_0x4edf8a['query']);_0x57e462[_0x5f71('0x40')]=_['intersection'](_0x4edf8a[_0x5f71('0x3e')],qs[_0x5f71('0x3f')](_0x3ee2de['query']['fields']));_0x57e462[_0x5f71('0x40')]=_0x57e462[_0x5f71('0x40')][_0x5f71('0x50')]?_0x57e462[_0x5f71('0x40')]:_0x4edf8a['model'];if(!_0x3ee2de[_0x5f71('0x3a')][_0x5f71('0x41')](_0x5f71('0x42'))){_0x57e462[_0x5f71('0x24')]=qs[_0x5f71('0x24')](_0x3ee2de['query'][_0x5f71('0x24')]);_0x57e462[_0x5f71('0x22')]=qs[_0x5f71('0x22')](_0x3ee2de[_0x5f71('0x3a')][_0x5f71('0x22')]);}_0x57e462[_0x5f71('0x5d')]=qs[_0x5f71('0x43')](_0x3ee2de[_0x5f71('0x3a')][_0x5f71('0x43')]);_0x57e462['where']=qs[_0x5f71('0x3c')](_[_0x5f71('0x45')](_0x3ee2de[_0x5f71('0x3a')],_0x4edf8a[_0x5f71('0x3c')]));_0x57e462['where'][_0x5f71('0x59')]=_0x1389c9['id'];if(_0x3ee2de[_0x5f71('0x3a')]['filter']){_0x57e462[_0x5f71('0x44')]=_[_0x5f71('0x47')](_0x57e462[_0x5f71('0x44')],{'$or':_[_0x5f71('0x39')](_0x57e462['attributes'],function(_0x54933f){var _0x3a1974={};_0x3a1974[_0x54933f]={'$like':'%'+_0x3ee2de[_0x5f71('0x3a')][_0x5f71('0x46')]+'%'};return _0x3a1974;})});}_0x57e462=_[_0x5f71('0x47')]({},_0x57e462,_0x3ee2de[_0x5f71('0x48')]);return db['Disposition'][_0x5f71('0x25')]({'where':_0x57e462[_0x5f71('0x44')]})[_0x5f71('0x2c')](function(_0x3bef6f){_0x481aca[_0x5f71('0x25')]=_0x3bef6f;if(_0x3ee2de['query']['includeAll']){_0x57e462[_0x5f71('0x4b')]=[{'all':!![]}];}return db['Disposition'][_0x5f71('0x4c')](_0x57e462);})['then'](function(_0x14fd59){_0x481aca[_0x5f71('0x4d')]=_0x14fd59;return _0x481aca;});}})[_0x5f71('0x2c')](respondWithFilteredResult(_0x185754,_0x57e462))['catch'](handleError(_0x185754,null));};exports[_0x5f71('0x5e')]=function(_0x34b5e7,_0x26e3d8,_0xf6ec95){return db['CmList'][_0x5f71('0x51')]({'where':{'id':_0x34b5e7[_0x5f71('0x4f')]['id']}})['then'](handleEntityNotFound(_0x26e3d8,null))[_0x5f71('0x2c')](function(_0x54c838){if(_0x54c838){return _0x54c838[_0x5f71('0x5e')](_0x34b5e7[_0x5f71('0x3a')][_0x5f71('0x5f')]);}})[_0x5f71('0x2c')](respondWithStatusCode(_0x26e3d8,null))[_0x5f71('0x4e')](handleError(_0x26e3d8,null));};exports[_0x5f71('0x60')]=function(_0x146b6f,_0x4b61f1,_0x14be25){return db[_0x5f71('0x49')]['find']({'where':{'id':_0x146b6f[_0x5f71('0x4f')]['id']}})[_0x5f71('0x2c')](handleEntityNotFound(_0x4b61f1,null))['then'](function(_0x191d92){if(_0x191d92){var _0x436199=[];var _0x253c38={'success':[],'errors':[]};return db[_0x5f71('0x61')][_0x5f71('0x57')]()[_0x5f71('0x2c')](function(_0x21f251){if(_0x146b6f[_0x5f71('0x53')][_0x5f71('0x62')]&&_[_0x5f71('0x63')](_0x146b6f[_0x5f71('0x53')][_0x5f71('0x62')])){if(_0x146b6f['body'][_0x5f71('0x62')][_0x5f71('0x50')]){_0x146b6f[_0x5f71('0x53')][_0x5f71('0x62')]=_0x146b6f['body']['tags'][_0x5f71('0x64')](';')+';';}else{_0x146b6f['body'][_0x5f71('0x62')]=null;}}else{_0x146b6f[_0x5f71('0x53')]['tags']=null;}if(_0x146b6f['body']&&_[_0x5f71('0x63')](_0x146b6f['body'])){for(var _0x2c2b08=0x0;_0x2c2b08<_0x146b6f[_0x5f71('0x53')]['length'];_0x2c2b08+=0x1){_0x146b6f[_0x5f71('0x53')][_0x2c2b08][_0x5f71('0x59')]=_0x146b6f[_0x5f71('0x4f')]['id'];_0x436199['push'](_0x146b6f[_0x5f71('0x53')][_0x2c2b08]);}return BPromise['each'](_0x436199,function(_0x569ccc){return db[_0x5f71('0x61')][_0x5f71('0x52')](_[_0x5f71('0x65')](_0x569ccc,['ids','id'])||{},{'fields':_[_0x5f71('0x3b')](_0x21f251),'raw':!![]})[_0x5f71('0x2c')](function(_0x3beb8e){_0x253c38['success'][_0x5f71('0x66')](_0x3beb8e['dataValues']);})['catch'](function(_0x3ad52f){_0x253c38[_0x5f71('0x67')][_0x5f71('0x66')]({'data':_0x569ccc,'error':_0x3ad52f[_0x5f71('0x68')]});});})[_0x5f71('0x2c')](function(_0x5aaebc){return _0x253c38;})[_0x5f71('0x4e')](function(_0x2d645c){return _0x2d645c;});}else{_0x4b61f1[_0x5f71('0x30')](0x190)[_0x5f71('0x21')]({'message':_0x5f71('0x69')});}});}})[_0x5f71('0x2c')](respondWithResult(_0x4b61f1,null))[_0x5f71('0x4e')](handleError(_0x4b61f1,null));};exports[_0x5f71('0x6a')]=function(_0x1c2acc,_0x32b024,_0x23ec9f){var _0x332a85;return db[_0x5f71('0x49')][_0x5f71('0x51')]({'where':{'id':_0x1c2acc[_0x5f71('0x4f')]['id']},'include':[{'model':db[_0x5f71('0x6b')],'as':_0x5f71('0x6c')}]})[_0x5f71('0x2c')](handleEntityNotFound(_0x32b024,null))[_0x5f71('0x2c')](function(_0xfd76af){if(_0xfd76af){_0x332a85=_0xfd76af;return db[_0x5f71('0x61')][_0x5f71('0x36')];}})[_0x5f71('0x2c')](function(_0x13d1c3){if(_0x13d1c3){var _0xadf9e8={};var _0x4190f0={};_0x4190f0[_0x5f71('0x3e')]=_[_0x5f71('0x6d')](_[_0x5f71('0x3b')](_0x13d1c3),_['map'](_0x332a85[_0x5f71('0x6c')],function(_0x56a466){return util['format']('cf_%d',_0x56a466['id']);}));_0x4190f0[_0x5f71('0x3a')]=_[_0x5f71('0x3b')](_0x1c2acc[_0x5f71('0x3a')]);_0x4190f0[_0x5f71('0x3c')]=_[_0x5f71('0x3d')](_0x4190f0[_0x5f71('0x3e')],_0x4190f0[_0x5f71('0x3a')]);_0xadf9e8[_0x5f71('0x40')]=_[_0x5f71('0x3d')](_0x4190f0[_0x5f71('0x3e')],qs['fields'](_0x1c2acc[_0x5f71('0x3a')][_0x5f71('0x3f')]));_0xadf9e8[_0x5f71('0x40')]=_0xadf9e8['attributes'][_0x5f71('0x50')]?_0xadf9e8[_0x5f71('0x40')]:_0x4190f0[_0x5f71('0x3e')];if(!_0x1c2acc[_0x5f71('0x3a')][_0x5f71('0x41')]('nolimit')){_0xadf9e8[_0x5f71('0x24')]=qs[_0x5f71('0x24')](_0x1c2acc[_0x5f71('0x3a')][_0x5f71('0x24')]);_0xadf9e8[_0x5f71('0x22')]=qs[_0x5f71('0x22')](_0x1c2acc[_0x5f71('0x3a')][_0x5f71('0x22')]);}_0xadf9e8[_0x5f71('0x5d')]=qs[_0x5f71('0x43')](_0x1c2acc[_0x5f71('0x3a')][_0x5f71('0x43')]);_0xadf9e8[_0x5f71('0x44')]=qs[_0x5f71('0x3c')](_[_0x5f71('0x45')](_0x1c2acc[_0x5f71('0x3a')],_0x4190f0[_0x5f71('0x3c')]));_0xadf9e8[_0x5f71('0x6e')]=!![];if(_0x1c2acc[_0x5f71('0x3a')][_0x5f71('0x46')]){_0xadf9e8[_0x5f71('0x44')]=_[_0x5f71('0x47')](_0xadf9e8['where'],{'$or':_['map'](_0xadf9e8[_0x5f71('0x40')],function(_0xf7bf1f){var _0x4f911c={};_0x4f911c[_0xf7bf1f]={'$like':'%'+_0x1c2acc[_0x5f71('0x3a')][_0x5f71('0x46')]+'%'};return _0x4f911c;})});}_0xadf9e8=_[_0x5f71('0x47')]({},_0xadf9e8,_0x1c2acc[_0x5f71('0x48')]);return _0x332a85[_0x5f71('0x6a')](_0xadf9e8);}})[_0x5f71('0x2c')](respondWithResult(_0x32b024,null))[_0x5f71('0x4e')](handleError(_0x32b024,null));};exports['getContactsCsv']=function(_0x52b6ff,_0x5f3f2e,_0x474259){var _0x2a0666;var _0x34cc7e;var _0x23b6ae;var _0x141d39=_0x52b6ff[_0x5f71('0x4f')]['id'];csv_results=[];return db[_0x5f71('0x6f')][_0x5f71('0x4c')]({'attributes':['id',_0x5f71('0x33')],'raw':!![],'order':[_0x5f71('0x70')]})['then'](function(_0x32ee38){_0x2a0666=_0x32ee38;var _0x39c59c=_[_0x5f71('0x3b')](db[_0x5f71('0x61')]['rawAttributes']);return db['CmCustomField'][_0x5f71('0x4c')]({'raw':!![],'attributes':['id','alias']})[_0x5f71('0x2c')](function(_0x119c42){_0x34cc7e=_0x119c42;var _0x212374=squel[_0x5f71('0x71')]()[_0x5f71('0x3f')](_0x39c59c)[_0x5f71('0x72')](_0x5f71('0x73'),'c')['where'](_0x5f71('0x74'),_0x141d39)[_0x5f71('0x44')](_0x5f71('0x75'))[_0x5f71('0x76')]();for(var _0x194bab=0x0;_0x194bab<_0x34cc7e[_0x5f71('0x50')];_0x194bab++){_0x212374[_0x5f71('0x77')]('c.cf_'+_0x34cc7e[_0x194bab]['id'],_0x5f71('0x78')+_0x34cc7e[_0x194bab][_0x5f71('0x79')]);}for(var _0x194bab=0x0;_0x194bab<_0x2a0666[_0x5f71('0x50')];_0x194bab++){_0x212374[_0x5f71('0x77')](squel[_0x5f71('0x71')]()[_0x5f71('0x77')](_0x5f71('0x7a'))[_0x5f71('0x72')](_0x5f71('0x7b'))['where'](_0x5f71('0x7c'),_0x2a0666[_0x194bab]['id'])[_0x5f71('0x44')]('CmContactId\x20=\x20c.id'),_0x5f71('0x7d')+_0x2a0666[_0x194bab][_0x5f71('0x33')]);_0x212374['field'](squel['select']()[_0x5f71('0x77')]('description')['from'](_0x5f71('0x7b'))[_0x5f71('0x44')](_0x5f71('0x7c'),_0x2a0666[_0x194bab]['id'])[_0x5f71('0x44')]('CmContactId\x20=\x20c.id'),_0x5f71('0x7e')+_0x2a0666[_0x194bab][_0x5f71('0x33')]);}var _0x2af28f=[];_0x2af28f[_0x5f71('0x66')](_0x212374['toString']());BPromise[_0x5f71('0x7f')](_0x2af28f,handleQuery)[_0x5f71('0x2c')](function(_0x23a413){handleQuery(_0x212374[_0x5f71('0x80')]());var _0x13ae39=csv_results[0x0];if(!_[_0x5f71('0x81')](_0x13ae39)){var _0x4a7c9e=toCsv(_0x13ae39);var _0x4d41b7=Date['now']();fs[_0x5f71('0x82')](util[_0x5f71('0x83')](_0x5f71('0x84'),_0x141d39,_0x4d41b7),_0x4a7c9e);_0x5f3f2e[_0x5f71('0x85')](_0x5f71('0x86'),_0x5f71('0x87')+util['format'](_0x5f71('0x88'),_0x141d39,_0x4d41b7));_0x5f3f2e['setHeader'](_0x5f71('0x89'),_0x5f71('0x8a'));return _0x5f3f2e[_0x5f71('0x8b')](util['format']('/tmp/list_%d_%s.csv',_0x141d39,_0x4d41b7));}else{return _0x5f3f2e['sendStatus'](0xcc);}});});});};exports[_0x5f71('0x8c')]=function(_0x187f54,_0x537482,_0x2d98b5){var _0x21db44;delete _0x187f54[_0x5f71('0x53')]['id'];return db[_0x5f71('0x49')][_0x5f71('0x5b')]({'where':{'id':_0x187f54['params']['id']}})[_0x5f71('0x2c')](handleEntityNotFound(_0x537482,null))[_0x5f71('0x2c')](function(_0x18a24b){if(_0x18a24b){return db[_0x5f71('0x8d')][_0x5f71('0x8e')](function(_0x5c6cf0){return db[_0x5f71('0x6b')][_0x5f71('0x52')](_0x187f54[_0x5f71('0x53')],{'transaction':_0x5c6cf0})[_0x5f71('0x2c')](function(_0x16a049){_0x21db44=_0x16a049;return _0x18a24b[_0x5f71('0x8f')](_0x16a049,{'transaction':_0x5c6cf0});})[_0x5f71('0x2c')](function(){var _0x57fd44={'type':db[_0x5f71('0x90')][_0x5f71('0x91')],'transaction':_0x5c6cf0};switch(_0x187f54[_0x5f71('0x53')][_0x5f71('0x38')]){case'text':_0x57fd44[_0x5f71('0x38')]=db[_0x5f71('0x90')]['TEXT'];break;case _0x5f71('0x92'):_0x57fd44[_0x5f71('0x38')]=db[_0x5f71('0x90')][_0x5f71('0x93')];break;case'switch':_0x57fd44[_0x5f71('0x38')]=db['Sequelize'][_0x5f71('0x94')];_0x57fd44[_0x5f71('0x95')]=![];break;default:}return db[_0x5f71('0x8d')][_0x5f71('0x96')][_0x5f71('0x97')](_0x5f71('0x73'),util[_0x5f71('0x83')](_0x5f71('0x98'),_0x21db44['id']),_0x57fd44);})['then'](function(){return _0x21db44;});});}})[_0x5f71('0x2c')](respondWithResult(_0x537482,null))[_0x5f71('0x4e')](handleError(_0x537482,null));};exports[_0x5f71('0x99')]=function(_0x15699e,_0x228aa1,_0x4fc53f){var _0x5ba3b2={};var _0x21a673={};var _0x18368d;var _0x5055d1;return db[_0x5f71('0x49')][_0x5f71('0x5b')]({'where':{'id':_0x15699e[_0x5f71('0x4f')]['id']}})['then'](handleEntityNotFound(_0x228aa1,null))['then'](function(_0x103414){if(_0x103414){_0x18368d=_0x103414;_0x21a673[_0x5f71('0x3e')]=_['keys'](db[_0x5f71('0x6b')]['rawAttributes']);_0x21a673['query']=_[_0x5f71('0x3b')](_0x15699e[_0x5f71('0x3a')]);_0x21a673[_0x5f71('0x3c')]=_[_0x5f71('0x3d')](_0x21a673[_0x5f71('0x3e')],_0x21a673[_0x5f71('0x3a')]);_0x5ba3b2['attributes']=_[_0x5f71('0x3d')](_0x21a673[_0x5f71('0x3e')],qs['fields'](_0x15699e[_0x5f71('0x3a')][_0x5f71('0x3f')]));_0x5ba3b2[_0x5f71('0x40')]=_0x5ba3b2[_0x5f71('0x40')]['length']?_0x5ba3b2[_0x5f71('0x40')]:_0x21a673[_0x5f71('0x3e')];_0x5ba3b2[_0x5f71('0x5d')]=qs[_0x5f71('0x43')](_0x15699e[_0x5f71('0x3a')][_0x5f71('0x43')]);_0x5ba3b2[_0x5f71('0x44')]=qs['filters'](_[_0x5f71('0x45')](_0x15699e[_0x5f71('0x3a')],_0x21a673[_0x5f71('0x3c')]));_0x5ba3b2[_0x5f71('0x44')]=_[_0x5f71('0x47')](_0x5ba3b2[_0x5f71('0x44')],{'$or':[{'ListId':_0x103414['id']},{'ListId':null}]});if(_0x15699e['query']['filter']){_0x5ba3b2[_0x5f71('0x44')]=_[_0x5f71('0x47')](_0x5ba3b2['where'],{'$or':_['map'](_0x5ba3b2[_0x5f71('0x40')],function(_0x23b011){var _0x425e57={};_0x425e57[_0x23b011]={'$like':'%'+_0x15699e[_0x5f71('0x3a')]['filter']+'%'};return _0x425e57;})});}_0x5ba3b2=_['merge']({},_0x5ba3b2,_0x15699e['options']);return db[_0x5f71('0x6b')][_0x5f71('0x9a')](_0x5ba3b2);}})[_0x5f71('0x2c')](respondWithResult(_0x228aa1,null))[_0x5f71('0x4e')](handleError(_0x228aa1,null));};exports[_0x5f71('0x9b')]=function(_0x10837,_0x56de01){return db[_0x5f71('0x6b')][_0x5f71('0x9a')]({'where':{'ListId':null}})['then'](handleEntityNotFound(_0x56de01,null))['then'](function(_0x295c5b){return _0x295c5b;})[_0x5f71('0x2c')](respondWithResult(_0x56de01,null))[_0x5f71('0x4e')](handleError(_0x56de01,null));};exports[_0x5f71('0x9c')]=function(_0x5db02b,_0x2f55f2,_0x2f944f){return db[_0x5f71('0x49')][_0x5f71('0x51')]({'where':{'id':_0x5db02b['params']['id']}})['then'](handleEntityNotFound(_0x2f55f2,null))['then'](function(_0x1f5d0e){if(_0x1f5d0e){return _0x1f5d0e[_0x5f71('0x9c')](_0x5db02b[_0x5f71('0x53')][_0x5f71('0x5f')],_[_0x5f71('0x65')](_0x5db02b[_0x5f71('0x53')],[_0x5f71('0x5f'),'id'])||{})[_0x5f71('0x9d')](function(_0x3e40a7){for(var _0x68f2a=0x0;_0x68f2a<_0x5db02b[_0x5f71('0x53')][_0x5f71('0x5f')][_0x5f71('0x50')];_0x68f2a+=0x1){socket[_0x5f71('0x9e')](_0x5f71('0x9f'),{'UserId':Number(_0x5db02b['body'][_0x5f71('0x5f')][_0x68f2a]),'CmListId':Number(_0x5db02b[_0x5f71('0x4f')]['id'])});}return _0x3e40a7;});}})[_0x5f71('0x2c')](respondWithResult(_0x2f55f2,null))[_0x5f71('0x4e')](handleError(_0x2f55f2,null));};exports[_0x5f71('0xa0')]=function(_0x3f1a2e,_0x13000d,_0x274da9){return db[_0x5f71('0x49')][_0x5f71('0x51')]({'where':{'id':_0x3f1a2e[_0x5f71('0x4f')]['id']}})[_0x5f71('0x2c')](handleEntityNotFound(_0x13000d,null))[_0x5f71('0x2c')](function(_0x3cfecc){if(_0x3cfecc){return _0x3cfecc['removeAgents'](_0x3f1a2e[_0x5f71('0x3a')][_0x5f71('0x5f')])[_0x5f71('0x2c')](function(){if(_[_0x5f71('0x63')](_0x3f1a2e['query'][_0x5f71('0x5f')])){for(var _0x1a99e5=0x0;_0x1a99e5<_0x3f1a2e[_0x5f71('0x3a')]['ids'][_0x5f71('0x50')];_0x1a99e5+=0x1){socket[_0x5f71('0x9e')]('userCmList:remove',{'UserId':Number(_0x3f1a2e[_0x5f71('0x3a')][_0x5f71('0x5f')][_0x1a99e5]),'CmListId':Number(_0x3f1a2e['params']['id'])});}}else{socket[_0x5f71('0x9e')](_0x5f71('0xa1'),{'UserId':Number(_0x3f1a2e[_0x5f71('0x3a')]['ids']),'CmListId':Number(_0x3f1a2e[_0x5f71('0x4f')]['id'])});}});}})['then'](respondWithStatusCode(_0x13000d,null))['catch'](handleError(_0x13000d,null));};exports[_0x5f71('0xa2')]=function(_0x153810,_0x2b3e5,_0x10c96c){var _0x50e6fa={};var _0x518fad={};var _0xb1e082;var _0x4b0539;return db[_0x5f71('0x49')][_0x5f71('0x5b')]({'where':{'id':_0x153810[_0x5f71('0x4f')]['id']}})['then'](handleEntityNotFound(_0x2b3e5,null))[_0x5f71('0x2c')](function(_0xf2fbe5){if(_0xf2fbe5){_0xb1e082=_0xf2fbe5;_0x518fad[_0x5f71('0x3e')]=_[_0x5f71('0x3b')](db[_0x5f71('0xa3')][_0x5f71('0x36')]);_0x518fad[_0x5f71('0x3a')]=_['keys'](_0x153810[_0x5f71('0x3a')]);_0x518fad[_0x5f71('0x3c')]=_[_0x5f71('0x3d')](_0x518fad[_0x5f71('0x3e')],_0x518fad['query']);_0x50e6fa[_0x5f71('0x40')]=_[_0x5f71('0x3d')](_0x518fad[_0x5f71('0x3e')],qs[_0x5f71('0x3f')](_0x153810['query']['fields']));_0x50e6fa[_0x5f71('0x40')]=_0x50e6fa[_0x5f71('0x40')][_0x5f71('0x50')]?_0x50e6fa[_0x5f71('0x40')]:_0x518fad['model'];_0x50e6fa[_0x5f71('0x5d')]=qs[_0x5f71('0x43')](_0x153810[_0x5f71('0x3a')][_0x5f71('0x43')]);_0x50e6fa[_0x5f71('0x44')]=qs['filters'](_[_0x5f71('0x45')](_0x153810[_0x5f71('0x3a')],_0x518fad[_0x5f71('0x3c')]));if(_0x153810[_0x5f71('0x3a')]['filter']){_0x50e6fa[_0x5f71('0x44')]=_[_0x5f71('0x47')](_0x50e6fa[_0x5f71('0x44')],{'$or':_[_0x5f71('0x39')](_0x50e6fa[_0x5f71('0x40')],function(_0x1de84d){var _0x113843={};_0x113843[_0x1de84d]={'$like':'%'+_0x153810['query']['filter']+'%'};return _0x113843;})});}_0x50e6fa=_[_0x5f71('0x47')]({},_0x50e6fa,_0x153810[_0x5f71('0x48')]);return _0xb1e082[_0x5f71('0xa2')](_0x50e6fa);}})[_0x5f71('0x2c')](function(_0x5133fa){if(_0x5133fa){_0x4b0539=_0x5133fa[_0x5f71('0x50')];if(!_0x153810[_0x5f71('0x3a')][_0x5f71('0x41')](_0x5f71('0x42'))){_0x50e6fa['limit']=qs['limit'](_0x153810[_0x5f71('0x3a')][_0x5f71('0x24')]);_0x50e6fa[_0x5f71('0x22')]=qs['offset'](_0x153810[_0x5f71('0x3a')]['offset']);}return _0xb1e082[_0x5f71('0xa2')](_0x50e6fa);}})[_0x5f71('0x2c')](function(_0x78515f){if(_0x78515f){return _0x78515f?{'count':_0x4b0539,'rows':_0x78515f}:null;}})[_0x5f71('0x2c')](respondWithResult(_0x2b3e5,null))[_0x5f71('0x4e')](handleError(_0x2b3e5,null));};function handleQuery(_0x4d0c73){logger[_0x5f71('0xa4')](_0x4d0c73);return db[_0x5f71('0x8d')][_0x5f71('0x3a')](_0x4d0c73)[_0x5f71('0x9d')](function(_0x664c8e){csv_results[_0x5f71('0x66')](_0x664c8e);})[_0x5f71('0x4e')](function(_0x76362a){logger[_0x5f71('0x31')](_0x76362a[_0x5f71('0x68')]);});}
\ No newline at end of file