Built motion from commit 3c2ce842.|2.6.31
[motion2.git] / server / api / cmList / cmList.controller.js
index f740206..5fa06d6 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x853f=['UserProfileResource','end','error','stack','name','index','map','CmList','type','key','model','query','filters','intersection','attributes','fields','length','nolimit','order','where','pick','filter','merge','VIRTUAL','includeAll','include','catch','show','params','rawAttributes','find','create','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','userProfileId','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','body','Disposition','getDispositions','findOne','keys','hasOwnProperty','sort','ListId','options','removeDispositions','ids','addContacts','CmContact','describe','tags','isArray','join','push','each','omit','dataValues','errors','message','Malformed\x20request\x20syntax','getContacts','CmCustomField','concat','CustomFields','format','getContactsCsv','ContactItemType','findAll','alias','cm_contacts','c.ListId\x20=\x20?','c.deletedAt\x20is\x20null','distinct','field','c.cf_','customField_','select','item','ItemTypeId\x20=\x20?','CmContactId\x20=\x20c.id','additionalPhone_','cm_contact_has_items','description_additionalPhone_','toString','writeFileSync','/tmp/list_%d_%s.csv','Content-disposition','list_%d_%s.csv','setHeader','Content-type','text/csv','addCustomField','sequelize','transaction','TEXT','text','Sequelize','number','INTEGER','switch','BOOLEAN','queryInterface','addColumn','cf_%s','getCustomFields','findAndCountAll','getGlobalCustomFields','addAgents','spread','userCmList:save','removeAgents','emit','getAgents','info','eml-format','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','lodash','squel','crypto','jsforce','desk.js','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../config/license/util','redis','defaults','localhost','socket.io-emitter','./cmList.socket','sendStatus','status','json','offset','undefined','limit','count','set','Content-Range','save','update','then','destroy','get','Lists'];(function(_0x4e77c6,_0x4c359c){var _0x3e326c=function(_0x50e425){while(--_0x50e425){_0x4e77c6['push'](_0x4e77c6['shift']());}};_0x3e326c(++_0x4c359c);}(_0x853f,0x1b6));var _0xf853=function(_0x1f182f,_0x3a461b){_0x1f182f=_0x1f182f-0x0;var _0x1671dd=_0x853f[_0x1f182f];return _0x1671dd;};'use strict';var emlformat=require(_0xf853('0x0'));var rimraf=require('rimraf');var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require(_0xf853('0x1'));var moment=require(_0xf853('0x2'));var BPromise=require(_0xf853('0x3'));var Mustache=require(_0xf853('0x4'));var util=require(_0xf853('0x5'));var path=require(_0xf853('0x6'));var sox=require(_0xf853('0x7'));var csv=require(_0xf853('0x8'));var ejs=require(_0xf853('0x9'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0xf853('0xa'));var squel=require(_0xf853('0xb'));var crypto=require(_0xf853('0xc'));var jsforce=require(_0xf853('0xd'));var deskjs=require(_0xf853('0xe'));var toCsv=require(_0xf853('0x8'));var querystring=require('querystring');var Papa=require(_0xf853('0xf'));var Redis=require(_0xf853('0x10'));var authService=require(_0xf853('0x11'));var qs=require(_0xf853('0x12'));var as=require(_0xf853('0x13'));var hardwareService=require(_0xf853('0x14'));var logger=require(_0xf853('0x15'))('api');var utils=require(_0xf853('0x16'));var config=require(_0xf853('0x17'));var licenseUtil=require(_0xf853('0x18'));var db=require('../../mysqldb')['db'];var csv_results;config[_0xf853('0x19')]=_[_0xf853('0x1a')](config[_0xf853('0x19')],{'host':_0xf853('0x1b'),'port':0x18eb});var socket=require(_0xf853('0x1c'))(new Redis(config[_0xf853('0x19')]));require(_0xf853('0x1d'))['register'](socket);function respondWithStatusCode(_0x177e5b,_0x42a27a){_0x42a27a=_0x42a27a||0xcc;return function(_0xa686e9){if(_0xa686e9){return _0x177e5b[_0xf853('0x1e')](_0x42a27a);}return _0x177e5b[_0xf853('0x1f')](_0x42a27a)['end']();};}function respondWithResult(_0x5a92fa,_0x48f88f){_0x48f88f=_0x48f88f||0xc8;return function(_0x496dc2){if(_0x496dc2){return _0x5a92fa[_0xf853('0x1f')](_0x48f88f)[_0xf853('0x20')](_0x496dc2);}};}function respondWithFilteredResult(_0x31c224,_0x57d8eb){return function(_0x34997c){if(_0x34997c){var _0x4d51ba=typeof _0x57d8eb[_0xf853('0x21')]===_0xf853('0x22')&&typeof _0x57d8eb[_0xf853('0x23')]===_0xf853('0x22');var _0x1d2ade=_0x34997c[_0xf853('0x24')];var _0x2d28c2=_0x4d51ba?0x0:_0x57d8eb[_0xf853('0x21')];var _0x2343ef=_0x4d51ba?_0x34997c[_0xf853('0x24')]:_0x57d8eb[_0xf853('0x21')]+_0x57d8eb[_0xf853('0x23')];var _0x217428;if(_0x2343ef>=_0x1d2ade){_0x2343ef=_0x1d2ade;_0x217428=0xc8;}else{_0x217428=0xce;}_0x31c224[_0xf853('0x1f')](_0x217428);return _0x31c224[_0xf853('0x25')](_0xf853('0x26'),_0x2d28c2+'-'+_0x2343ef+'/'+_0x1d2ade)['json'](_0x34997c);}return null;};}function patchUpdates(_0x30c73d){return function(_0x519539){try{jsonpatch['apply'](_0x519539,_0x30c73d,!![]);}catch(_0x3c7313){return BPromise['reject'](_0x3c7313);}return _0x519539[_0xf853('0x27')]();};}function saveUpdates(_0x4049c7,_0x3f404f){return function(_0x2bd230){if(_0x2bd230){return _0x2bd230[_0xf853('0x28')](_0x4049c7)[_0xf853('0x29')](function(_0x1d9c17){return _0x1d9c17;});}return null;};}function removeEntity(_0x4329e8,_0xa89ae){return function(_0x419cdc){if(_0x419cdc){return _0x419cdc[_0xf853('0x2a')]()[_0xf853('0x29')](function(){var _0xe74191=_0x419cdc[_0xf853('0x2b')]({'plain':!![]});var _0x558726=_0xf853('0x2c');return db[_0xf853('0x2d')][_0xf853('0x2a')]({'where':{'type':_0x558726,'resourceId':_0xe74191['id']}})[_0xf853('0x29')](function(){return _0x419cdc;});})['then'](function(){_0x4329e8[_0xf853('0x1f')](0xcc)[_0xf853('0x2e')]();});}};}function handleEntityNotFound(_0xa13d62,_0x30ce2e){return function(_0x27e257){if(!_0x27e257){_0xa13d62['sendStatus'](0x194);}return _0x27e257;};}function handleError(_0xc22042,_0x385df7){_0x385df7=_0x385df7||0x1f4;return function(_0x544526){logger[_0xf853('0x2f')](_0x544526[_0xf853('0x30')]);if(_0x544526[_0xf853('0x31')]){delete _0x544526['name'];}_0xc22042[_0xf853('0x1f')](_0x385df7)['send'](_0x544526);};}exports[_0xf853('0x32')]=function(_0x39ccaa,_0x4e3994){var _0x4f7310={},_0x2b4ca5={},_0xf38f14={'count':0x0,'rows':[]};var _0x48b5f4=_[_0xf853('0x33')](db[_0xf853('0x34')]['rawAttributes'],function(_0x56428e){return{'name':_0x56428e['fieldName'],'type':_0x56428e[_0xf853('0x35')][_0xf853('0x36')]};});_0x2b4ca5[_0xf853('0x37')]=_[_0xf853('0x33')](_0x48b5f4,'name');_0x2b4ca5[_0xf853('0x38')]=_['keys'](_0x39ccaa[_0xf853('0x38')]);_0x2b4ca5[_0xf853('0x39')]=_[_0xf853('0x3a')](_0x2b4ca5[_0xf853('0x37')],_0x2b4ca5[_0xf853('0x38')]);_0x4f7310[_0xf853('0x3b')]=_[_0xf853('0x3a')](_0x2b4ca5[_0xf853('0x37')],qs[_0xf853('0x3c')](_0x39ccaa[_0xf853('0x38')][_0xf853('0x3c')]));_0x4f7310['attributes']=_0x4f7310[_0xf853('0x3b')][_0xf853('0x3d')]?_0x4f7310[_0xf853('0x3b')]:_0x2b4ca5[_0xf853('0x37')];if(!_0x39ccaa['query']['hasOwnProperty'](_0xf853('0x3e'))){_0x4f7310[_0xf853('0x23')]=qs[_0xf853('0x23')](_0x39ccaa[_0xf853('0x38')][_0xf853('0x23')]);_0x4f7310[_0xf853('0x21')]=qs[_0xf853('0x21')](_0x39ccaa['query'][_0xf853('0x21')]);}_0x4f7310[_0xf853('0x3f')]=qs['sort'](_0x39ccaa[_0xf853('0x38')]['sort']);_0x4f7310[_0xf853('0x40')]=qs[_0xf853('0x39')](_[_0xf853('0x41')](_0x39ccaa['query'],_0x2b4ca5[_0xf853('0x39')]),_0x48b5f4);if(_0x39ccaa['query'][_0xf853('0x42')]){_0x4f7310[_0xf853('0x40')]=_[_0xf853('0x43')](_0x4f7310[_0xf853('0x40')],{'$or':_[_0xf853('0x33')](_0x48b5f4,function(_0x365354){if(_0x365354[_0xf853('0x35')]!==_0xf853('0x44')){var _0x4dd437={};_0x4dd437[_0x365354[_0xf853('0x31')]]={'$like':'%'+_0x39ccaa['query'][_0xf853('0x42')]+'%'};return _0x4dd437;}})});}_0x4f7310=_[_0xf853('0x43')]({},_0x4f7310,_0x39ccaa['options']);var _0x50e666={'where':_0x4f7310[_0xf853('0x40')]};return db[_0xf853('0x34')]['count'](_0x50e666)['then'](function(_0x4cc099){_0xf38f14[_0xf853('0x24')]=_0x4cc099;if(_0x39ccaa[_0xf853('0x38')][_0xf853('0x45')]){_0x4f7310[_0xf853('0x46')]=[{'all':!![]}];}return db[_0xf853('0x34')]['findAll'](_0x4f7310);})[_0xf853('0x29')](function(_0x31dd66){_0xf38f14['rows']=_0x31dd66;return _0xf38f14;})[_0xf853('0x29')](respondWithFilteredResult(_0x4e3994,_0x4f7310))[_0xf853('0x47')](handleError(_0x4e3994,null));};exports[_0xf853('0x48')]=function(_0x29d2af,_0xa9d063){var _0x530540={'raw':![],'where':{'id':_0x29d2af[_0xf853('0x49')]['id']}},_0xdca133={};_0xdca133[_0xf853('0x37')]=_['keys'](db[_0xf853('0x34')][_0xf853('0x4a')]);_0xdca133[_0xf853('0x38')]=_['keys'](_0x29d2af[_0xf853('0x38')]);_0xdca133['filters']=_[_0xf853('0x3a')](_0xdca133[_0xf853('0x37')],_0xdca133[_0xf853('0x38')]);_0x530540['attributes']=_['intersection'](_0xdca133[_0xf853('0x37')],qs[_0xf853('0x3c')](_0x29d2af['query'][_0xf853('0x3c')]));_0x530540[_0xf853('0x3b')]=_0x530540['attributes'][_0xf853('0x3d')]?_0x530540[_0xf853('0x3b')]:_0xdca133[_0xf853('0x37')];if(_0x29d2af[_0xf853('0x38')][_0xf853('0x45')]){_0x530540[_0xf853('0x46')]=[{'all':!![]}];}_0x530540=_[_0xf853('0x43')]({},_0x530540,_0x29d2af['options']);return db['CmList'][_0xf853('0x4b')](_0x530540)[_0xf853('0x29')](handleEntityNotFound(_0xa9d063,null))[_0xf853('0x29')](respondWithResult(_0xa9d063,null))[_0xf853('0x47')](handleError(_0xa9d063,null));};exports[_0xf853('0x4c')]=function(_0x4867f3,_0x1ea6ee){return db[_0xf853('0x34')]['create'](_0x4867f3['body'],{})[_0xf853('0x29')](function(_0x43dc69){var _0x4ab28a=_0x4867f3[_0xf853('0x4d')]['get']({'plain':!![]});if(!_0x4ab28a)throw new Error(_0xf853('0x4e'));if(_0x4ab28a[_0xf853('0x4f')]===_0xf853('0x4d')){var _0x10e4c0=_0x43dc69['get']({'plain':!![]});var _0x1eae0b=_0xf853('0x2c');return db[_0xf853('0x50')][_0xf853('0x4b')]({'where':{'name':_0x1eae0b,'userProfileId':_0x4ab28a[_0xf853('0x51')]},'raw':!![]})[_0xf853('0x29')](function(_0x143703){if(_0x143703&&_0x143703['autoAssociation']===0x0){return db[_0xf853('0x2d')]['create']({'name':_0x10e4c0[_0xf853('0x31')],'resourceId':_0x10e4c0['id'],'type':_0x143703['name'],'sectionId':_0x143703['id']},{})[_0xf853('0x29')](function(){return _0x43dc69;});}else{return _0x43dc69;}})[_0xf853('0x47')](function(_0x216955){logger[_0xf853('0x2f')](_0xf853('0x52'),_0x216955);throw _0x216955;});}return _0x43dc69;})['then'](respondWithResult(_0x1ea6ee,0xc9))[_0xf853('0x47')](handleError(_0x1ea6ee,null));};exports[_0xf853('0x28')]=function(_0x353df0,_0x1334eb){if(_0x353df0['body']['id']){delete _0x353df0[_0xf853('0x53')]['id'];}return db[_0xf853('0x34')][_0xf853('0x4b')]({'where':{'id':_0x353df0['params']['id']}})[_0xf853('0x29')](handleEntityNotFound(_0x1334eb,null))[_0xf853('0x29')](saveUpdates(_0x353df0[_0xf853('0x53')],null))[_0xf853('0x29')](respondWithResult(_0x1334eb,null))[_0xf853('0x47')](handleError(_0x1334eb,null));};exports['destroy']=function(_0x256884,_0x14539a){return db['CmList'][_0xf853('0x4b')]({'where':{'id':_0x256884[_0xf853('0x49')]['id']}})[_0xf853('0x29')](handleEntityNotFound(_0x14539a,null))[_0xf853('0x29')](removeEntity(_0x14539a,null))['catch'](handleError(_0x14539a,null));};exports['describe']=function(_0x286e1d,_0x623fa){return db['CmList']['describe']()[_0xf853('0x29')](respondWithResult(_0x623fa,null))[_0xf853('0x47')](handleError(_0x623fa,null));};exports['addDisposition']=function(_0x411014,_0x488504,_0x4f0d87){if(_0x411014[_0xf853('0x53')]['id']){delete _0x411014[_0xf853('0x53')]['id'];}return db[_0xf853('0x34')][_0xf853('0x4b')]({'where':{'id':_0x411014['params']['id']}})[_0xf853('0x29')](handleEntityNotFound(_0x488504,null))[_0xf853('0x29')](function(_0x21c92e){if(_0x21c92e){_0x411014[_0xf853('0x53')]['ListId']=_0x21c92e['id'];return db[_0xf853('0x54')][_0xf853('0x4c')](_0x411014[_0xf853('0x53')]);}})[_0xf853('0x29')](respondWithResult(_0x488504,null))[_0xf853('0x47')](handleError(_0x488504,null));};exports[_0xf853('0x55')]=function(_0x126853,_0xe9578b,_0x48fa7f){var _0x261b3b={'raw':![],'where':{}};var _0x748f9e={};var _0xbac05a={'count':0x0,'rows':[]};return db['CmList'][_0xf853('0x56')]({'where':{'id':_0x126853[_0xf853('0x49')]['id']}})[_0xf853('0x29')](handleEntityNotFound(_0xe9578b,null))[_0xf853('0x29')](function(_0x5e05eb){if(_0x5e05eb){_0x748f9e['model']=_[_0xf853('0x57')](db[_0xf853('0x54')][_0xf853('0x4a')]);_0x748f9e[_0xf853('0x38')]=_[_0xf853('0x57')](_0x126853[_0xf853('0x38')]);_0x748f9e['filters']=_[_0xf853('0x3a')](_0x748f9e[_0xf853('0x37')],_0x748f9e[_0xf853('0x38')]);_0x261b3b[_0xf853('0x3b')]=_[_0xf853('0x3a')](_0x748f9e[_0xf853('0x37')],qs[_0xf853('0x3c')](_0x126853[_0xf853('0x38')][_0xf853('0x3c')]));_0x261b3b[_0xf853('0x3b')]=_0x261b3b[_0xf853('0x3b')][_0xf853('0x3d')]?_0x261b3b[_0xf853('0x3b')]:_0x748f9e['model'];if(!_0x126853[_0xf853('0x38')][_0xf853('0x58')]('nolimit')){_0x261b3b[_0xf853('0x23')]=qs[_0xf853('0x23')](_0x126853[_0xf853('0x38')][_0xf853('0x23')]);_0x261b3b[_0xf853('0x21')]=qs[_0xf853('0x21')](_0x126853['query'][_0xf853('0x21')]);}_0x261b3b[_0xf853('0x3f')]=qs[_0xf853('0x59')](_0x126853[_0xf853('0x38')]['sort']);_0x261b3b[_0xf853('0x40')]=qs[_0xf853('0x39')](_['pick'](_0x126853[_0xf853('0x38')],_0x748f9e[_0xf853('0x39')]));_0x261b3b[_0xf853('0x40')][_0xf853('0x5a')]=_0x5e05eb['id'];if(_0x126853['query'][_0xf853('0x42')]){_0x261b3b['where']=_[_0xf853('0x43')](_0x261b3b['where'],{'$or':_[_0xf853('0x33')](_0x261b3b[_0xf853('0x3b')],function(_0x4f5f11){var _0x492d6e={};_0x492d6e[_0x4f5f11]={'$like':'%'+_0x126853[_0xf853('0x38')]['filter']+'%'};return _0x492d6e;})});}_0x261b3b=_[_0xf853('0x43')]({},_0x261b3b,_0x126853[_0xf853('0x5b')]);return db[_0xf853('0x54')][_0xf853('0x24')]({'where':_0x261b3b[_0xf853('0x40')]})[_0xf853('0x29')](function(_0x4e4424){_0xbac05a[_0xf853('0x24')]=_0x4e4424;if(_0x126853[_0xf853('0x38')][_0xf853('0x45')]){_0x261b3b[_0xf853('0x46')]=[{'all':!![]}];}return db[_0xf853('0x54')]['findAll'](_0x261b3b);})[_0xf853('0x29')](function(_0x5388ff){_0xbac05a['rows']=_0x5388ff;return _0xbac05a;});}})[_0xf853('0x29')](respondWithFilteredResult(_0xe9578b,_0x261b3b))[_0xf853('0x47')](handleError(_0xe9578b,null));};exports[_0xf853('0x5c')]=function(_0x981ebc,_0x42c16c,_0x1ee1f5){return db[_0xf853('0x34')][_0xf853('0x4b')]({'where':{'id':_0x981ebc[_0xf853('0x49')]['id']}})[_0xf853('0x29')](handleEntityNotFound(_0x42c16c,null))[_0xf853('0x29')](function(_0x3cd3bd){if(_0x3cd3bd){return _0x3cd3bd[_0xf853('0x5c')](_0x981ebc[_0xf853('0x38')][_0xf853('0x5d')]);}})[_0xf853('0x29')](respondWithStatusCode(_0x42c16c,null))[_0xf853('0x47')](handleError(_0x42c16c,null));};exports[_0xf853('0x5e')]=function(_0x590d2c,_0x163f83,_0x1a01c3){return db[_0xf853('0x34')][_0xf853('0x4b')]({'where':{'id':_0x590d2c['params']['id']}})[_0xf853('0x29')](handleEntityNotFound(_0x163f83,null))['then'](function(_0x5419f9){if(_0x5419f9){var _0x2bb4a0=[];var _0x4c17b8={'success':[],'errors':[]};return db[_0xf853('0x5f')][_0xf853('0x60')]()['then'](function(_0x4141ec){if(_0x590d2c[_0xf853('0x53')][_0xf853('0x61')]&&_[_0xf853('0x62')](_0x590d2c['body'][_0xf853('0x61')])){if(_0x590d2c['body'][_0xf853('0x61')][_0xf853('0x3d')]){_0x590d2c[_0xf853('0x53')]['tags']=_0x590d2c[_0xf853('0x53')][_0xf853('0x61')][_0xf853('0x63')](';')+';';}else{_0x590d2c[_0xf853('0x53')][_0xf853('0x61')]=null;}}else{_0x590d2c['body']['tags']=null;}if(_0x590d2c[_0xf853('0x53')]&&_[_0xf853('0x62')](_0x590d2c[_0xf853('0x53')])){for(var _0x122308=0x0;_0x122308<_0x590d2c[_0xf853('0x53')][_0xf853('0x3d')];_0x122308+=0x1){_0x590d2c[_0xf853('0x53')][_0x122308]['ListId']=_0x590d2c['params']['id'];_0x2bb4a0[_0xf853('0x64')](_0x590d2c[_0xf853('0x53')][_0x122308]);}return BPromise[_0xf853('0x65')](_0x2bb4a0,function(_0x45bd76){return db[_0xf853('0x5f')]['create'](_[_0xf853('0x66')](_0x45bd76,['ids','id'])||{},{'fields':_[_0xf853('0x57')](_0x4141ec),'raw':!![]})[_0xf853('0x29')](function(_0x13836e){_0x4c17b8['success'][_0xf853('0x64')](_0x13836e[_0xf853('0x67')]);})[_0xf853('0x47')](function(_0x43bf91){_0x4c17b8[_0xf853('0x68')]['push']({'data':_0x45bd76,'error':_0x43bf91[_0xf853('0x69')]});});})[_0xf853('0x29')](function(_0x26464c){return _0x4c17b8;})[_0xf853('0x47')](function(_0x5ace75){return _0x5ace75;});}else{_0x163f83[_0xf853('0x1f')](0x190)[_0xf853('0x20')]({'message':_0xf853('0x6a')});}});}})[_0xf853('0x29')](respondWithResult(_0x163f83,null))[_0xf853('0x47')](handleError(_0x163f83,null));};exports[_0xf853('0x6b')]=function(_0x499a75,_0x40ef39,_0x278a12){var _0x2d772b;return db[_0xf853('0x34')][_0xf853('0x4b')]({'where':{'id':_0x499a75[_0xf853('0x49')]['id']},'include':[{'model':db[_0xf853('0x6c')],'as':'CustomFields'}]})[_0xf853('0x29')](handleEntityNotFound(_0x40ef39,null))['then'](function(_0x5df7e4){if(_0x5df7e4){_0x2d772b=_0x5df7e4;return db[_0xf853('0x5f')]['rawAttributes'];}})[_0xf853('0x29')](function(_0x5a3025){if(_0x5a3025){var _0x54889b={};var _0x482b84={};_0x482b84[_0xf853('0x37')]=_[_0xf853('0x6d')](_[_0xf853('0x57')](_0x5a3025),_[_0xf853('0x33')](_0x2d772b[_0xf853('0x6e')],function(_0x4a393e){return util[_0xf853('0x6f')]('cf_%d',_0x4a393e['id']);}));_0x482b84[_0xf853('0x38')]=_['keys'](_0x499a75['query']);_0x482b84[_0xf853('0x39')]=_['intersection'](_0x482b84['model'],_0x482b84[_0xf853('0x38')]);_0x54889b[_0xf853('0x3b')]=_['intersection'](_0x482b84['model'],qs[_0xf853('0x3c')](_0x499a75['query'][_0xf853('0x3c')]));_0x54889b[_0xf853('0x3b')]=_0x54889b[_0xf853('0x3b')][_0xf853('0x3d')]?_0x54889b[_0xf853('0x3b')]:_0x482b84['model'];if(!_0x499a75['query'][_0xf853('0x58')](_0xf853('0x3e'))){_0x54889b[_0xf853('0x23')]=qs[_0xf853('0x23')](_0x499a75[_0xf853('0x38')][_0xf853('0x23')]);_0x54889b[_0xf853('0x21')]=qs[_0xf853('0x21')](_0x499a75[_0xf853('0x38')][_0xf853('0x21')]);}_0x54889b[_0xf853('0x3f')]=qs[_0xf853('0x59')](_0x499a75[_0xf853('0x38')][_0xf853('0x59')]);_0x54889b[_0xf853('0x40')]=qs[_0xf853('0x39')](_['pick'](_0x499a75[_0xf853('0x38')],_0x482b84[_0xf853('0x39')]));_0x54889b['raw']=!![];if(_0x499a75[_0xf853('0x38')]['filter']){_0x54889b[_0xf853('0x40')]=_[_0xf853('0x43')](_0x54889b[_0xf853('0x40')],{'$or':_[_0xf853('0x33')](_0x54889b['attributes'],function(_0x25c003){var _0x9d6335={};_0x9d6335[_0x25c003]={'$like':'%'+_0x499a75[_0xf853('0x38')][_0xf853('0x42')]+'%'};return _0x9d6335;})});}_0x54889b=_[_0xf853('0x43')]({},_0x54889b,_0x499a75[_0xf853('0x5b')]);return _0x2d772b['getContacts'](_0x54889b);}})[_0xf853('0x29')](respondWithResult(_0x40ef39,null))[_0xf853('0x47')](handleError(_0x40ef39,null));};exports[_0xf853('0x70')]=function(_0x4e2d18,_0x41b05a,_0x25d395){var _0x9c3060;var _0x35b8c6;var _0x2c78e0;var _0x10dec4=_0x4e2d18[_0xf853('0x49')]['id'];csv_results=[];return db[_0xf853('0x71')]['findAll']({'attributes':['id',_0xf853('0x31')],'raw':!![],'order':['OrderBy']})[_0xf853('0x29')](function(_0x1c7c56){_0x9c3060=_0x1c7c56;var _0x3989fb=_[_0xf853('0x57')](db[_0xf853('0x5f')][_0xf853('0x4a')]);return db[_0xf853('0x6c')][_0xf853('0x72')]({'raw':!![],'attributes':['id',_0xf853('0x73')]})[_0xf853('0x29')](function(_0x4c0f96){_0x35b8c6=_0x4c0f96;var _0x2f689e=squel['select']()[_0xf853('0x3c')](_0x3989fb)['from'](_0xf853('0x74'),'c')[_0xf853('0x40')](_0xf853('0x75'),_0x10dec4)[_0xf853('0x40')](_0xf853('0x76'))[_0xf853('0x77')]();for(var _0x5ac24d=0x0;_0x5ac24d<_0x35b8c6[_0xf853('0x3d')];_0x5ac24d++){_0x2f689e[_0xf853('0x78')](_0xf853('0x79')+_0x35b8c6[_0x5ac24d]['id'],_0xf853('0x7a')+_0x35b8c6[_0x5ac24d][_0xf853('0x73')]);}for(var _0x5ac24d=0x0;_0x5ac24d<_0x9c3060[_0xf853('0x3d')];_0x5ac24d++){_0x2f689e['field'](squel[_0xf853('0x7b')]()[_0xf853('0x78')](_0xf853('0x7c'))['from']('cm_contact_has_items')[_0xf853('0x40')](_0xf853('0x7d'),_0x9c3060[_0x5ac24d]['id'])[_0xf853('0x40')](_0xf853('0x7e')),_0xf853('0x7f')+_0x9c3060[_0x5ac24d][_0xf853('0x31')]);_0x2f689e[_0xf853('0x78')](squel[_0xf853('0x7b')]()[_0xf853('0x78')]('description')['from'](_0xf853('0x80'))[_0xf853('0x40')](_0xf853('0x7d'),_0x9c3060[_0x5ac24d]['id'])[_0xf853('0x40')]('CmContactId\x20=\x20c.id'),_0xf853('0x81')+_0x9c3060[_0x5ac24d][_0xf853('0x31')]);}var _0x3136c6=[];_0x3136c6[_0xf853('0x64')](_0x2f689e[_0xf853('0x82')]());BPromise['each'](_0x3136c6,handleQuery)[_0xf853('0x29')](function(_0x1be978){handleQuery(_0x2f689e[_0xf853('0x82')]());var _0x20d72b=csv_results[0x0];if(!_['isEmpty'](_0x20d72b)){var _0x262a16=toCsv(_0x20d72b);var _0x6320e7=Date['now']();fs[_0xf853('0x83')](util[_0xf853('0x6f')](_0xf853('0x84'),_0x10dec4,_0x6320e7),_0x262a16);_0x41b05a['setHeader'](_0xf853('0x85'),'attachment;\x20filename='+util[_0xf853('0x6f')](_0xf853('0x86'),_0x10dec4,_0x6320e7));_0x41b05a[_0xf853('0x87')](_0xf853('0x88'),_0xf853('0x89'));return _0x41b05a['download'](util[_0xf853('0x6f')]('/tmp/list_%d_%s.csv',_0x10dec4,_0x6320e7));}else{return _0x41b05a[_0xf853('0x1e')](0xcc);}});});});};exports[_0xf853('0x8a')]=function(_0x49612e,_0x5b763e,_0x1d060c){var _0xdae17a;delete _0x49612e[_0xf853('0x53')]['id'];return db[_0xf853('0x34')]['findOne']({'where':{'id':_0x49612e[_0xf853('0x49')]['id']}})[_0xf853('0x29')](handleEntityNotFound(_0x5b763e,null))[_0xf853('0x29')](function(_0x869646){if(_0x869646){return db[_0xf853('0x8b')][_0xf853('0x8c')](function(_0x1b6b17){return db['CmCustomField'][_0xf853('0x4c')](_0x49612e[_0xf853('0x53')],{'transaction':_0x1b6b17})[_0xf853('0x29')](function(_0x4e7c2f){_0xdae17a=_0x4e7c2f;return _0x869646['addCustomFields'](_0x4e7c2f,{'transaction':_0x1b6b17});})[_0xf853('0x29')](function(){var _0x5eb886={'type':db['Sequelize'][_0xf853('0x8d')],'transaction':_0x1b6b17};switch(_0x49612e[_0xf853('0x53')][_0xf853('0x35')]){case _0xf853('0x8e'):_0x5eb886[_0xf853('0x35')]=db[_0xf853('0x8f')][_0xf853('0x8d')];break;case _0xf853('0x90'):_0x5eb886[_0xf853('0x35')]=db[_0xf853('0x8f')][_0xf853('0x91')];break;case _0xf853('0x92'):_0x5eb886[_0xf853('0x35')]=db[_0xf853('0x8f')][_0xf853('0x93')];_0x5eb886['defaultValue']=![];break;default:}return db[_0xf853('0x8b')][_0xf853('0x94')][_0xf853('0x95')](_0xf853('0x74'),util[_0xf853('0x6f')](_0xf853('0x96'),_0xdae17a['id']),_0x5eb886);})[_0xf853('0x29')](function(){return _0xdae17a;});});}})['then'](respondWithResult(_0x5b763e,null))[_0xf853('0x47')](handleError(_0x5b763e,null));};exports[_0xf853('0x97')]=function(_0x286405,_0xc214a8,_0x570cb1){var _0x485ef7={};var _0x5cea22={};var _0x43acbc;var _0x3de3af;return db[_0xf853('0x34')][_0xf853('0x56')]({'where':{'id':_0x286405[_0xf853('0x49')]['id']}})['then'](handleEntityNotFound(_0xc214a8,null))['then'](function(_0x5db012){if(_0x5db012){_0x43acbc=_0x5db012;_0x5cea22[_0xf853('0x37')]=_['keys'](db['CmCustomField'][_0xf853('0x4a')]);_0x5cea22[_0xf853('0x38')]=_[_0xf853('0x57')](_0x286405['query']);_0x5cea22[_0xf853('0x39')]=_[_0xf853('0x3a')](_0x5cea22[_0xf853('0x37')],_0x5cea22['query']);_0x485ef7[_0xf853('0x3b')]=_[_0xf853('0x3a')](_0x5cea22[_0xf853('0x37')],qs[_0xf853('0x3c')](_0x286405[_0xf853('0x38')][_0xf853('0x3c')]));_0x485ef7[_0xf853('0x3b')]=_0x485ef7[_0xf853('0x3b')]['length']?_0x485ef7['attributes']:_0x5cea22[_0xf853('0x37')];_0x485ef7[_0xf853('0x3f')]=qs[_0xf853('0x59')](_0x286405[_0xf853('0x38')][_0xf853('0x59')]);_0x485ef7[_0xf853('0x40')]=qs['filters'](_[_0xf853('0x41')](_0x286405[_0xf853('0x38')],_0x5cea22['filters']));_0x485ef7[_0xf853('0x40')]=_[_0xf853('0x43')](_0x485ef7['where'],{'$or':[{'ListId':_0x5db012['id']},{'ListId':null}]});if(_0x286405[_0xf853('0x38')][_0xf853('0x42')]){_0x485ef7[_0xf853('0x40')]=_['merge'](_0x485ef7[_0xf853('0x40')],{'$or':_[_0xf853('0x33')](_0x485ef7[_0xf853('0x3b')],function(_0x212c00){var _0x4a65dc={};_0x4a65dc[_0x212c00]={'$like':'%'+_0x286405[_0xf853('0x38')][_0xf853('0x42')]+'%'};return _0x4a65dc;})});}_0x485ef7=_[_0xf853('0x43')]({},_0x485ef7,_0x286405['options']);return db[_0xf853('0x6c')][_0xf853('0x98')](_0x485ef7);}})[_0xf853('0x29')](respondWithResult(_0xc214a8,null))['catch'](handleError(_0xc214a8,null));};exports[_0xf853('0x99')]=function(_0x34ef0a,_0x17874e){return db[_0xf853('0x6c')][_0xf853('0x98')]({'where':{'ListId':null}})[_0xf853('0x29')](handleEntityNotFound(_0x17874e,null))[_0xf853('0x29')](function(_0x185b1c){return _0x185b1c;})[_0xf853('0x29')](respondWithResult(_0x17874e,null))['catch'](handleError(_0x17874e,null));};exports[_0xf853('0x9a')]=function(_0x42cd92,_0x140285,_0x24fdbb){return db[_0xf853('0x34')][_0xf853('0x4b')]({'where':{'id':_0x42cd92[_0xf853('0x49')]['id']}})[_0xf853('0x29')](handleEntityNotFound(_0x140285,null))[_0xf853('0x29')](function(_0x389345){if(_0x389345){return _0x389345[_0xf853('0x9a')](_0x42cd92[_0xf853('0x53')][_0xf853('0x5d')],_['omit'](_0x42cd92['body'],[_0xf853('0x5d'),'id'])||{})[_0xf853('0x9b')](function(_0x2aba32){for(var _0x43a204=0x0;_0x43a204<_0x42cd92[_0xf853('0x53')][_0xf853('0x5d')][_0xf853('0x3d')];_0x43a204+=0x1){socket['emit'](_0xf853('0x9c'),{'UserId':Number(_0x42cd92['body'][_0xf853('0x5d')][_0x43a204]),'CmListId':Number(_0x42cd92[_0xf853('0x49')]['id'])});}return _0x2aba32;});}})[_0xf853('0x29')](respondWithResult(_0x140285,null))['catch'](handleError(_0x140285,null));};exports[_0xf853('0x9d')]=function(_0x4f857e,_0x364ace,_0x303db2){return db[_0xf853('0x34')][_0xf853('0x4b')]({'where':{'id':_0x4f857e[_0xf853('0x49')]['id']}})[_0xf853('0x29')](handleEntityNotFound(_0x364ace,null))[_0xf853('0x29')](function(_0x2f0169){if(_0x2f0169){return _0x2f0169['removeAgents'](_0x4f857e[_0xf853('0x38')][_0xf853('0x5d')])['then'](function(){if(_[_0xf853('0x62')](_0x4f857e[_0xf853('0x38')][_0xf853('0x5d')])){for(var _0x1a1fd8=0x0;_0x1a1fd8<_0x4f857e[_0xf853('0x38')][_0xf853('0x5d')][_0xf853('0x3d')];_0x1a1fd8+=0x1){socket[_0xf853('0x9e')]('userCmList:remove',{'UserId':Number(_0x4f857e[_0xf853('0x38')][_0xf853('0x5d')][_0x1a1fd8]),'CmListId':Number(_0x4f857e[_0xf853('0x49')]['id'])});}}else{socket[_0xf853('0x9e')]('userCmList:remove',{'UserId':Number(_0x4f857e[_0xf853('0x38')][_0xf853('0x5d')]),'CmListId':Number(_0x4f857e[_0xf853('0x49')]['id'])});}});}})['then'](respondWithStatusCode(_0x364ace,null))[_0xf853('0x47')](handleError(_0x364ace,null));};exports[_0xf853('0x9f')]=function(_0x17ed5b,_0x2d8f7c,_0x5952f1){var _0x23d643={};var _0x39c56d={};var _0x2c81cb;var _0x3eb82c;return db['CmList'][_0xf853('0x56')]({'where':{'id':_0x17ed5b[_0xf853('0x49')]['id']}})[_0xf853('0x29')](handleEntityNotFound(_0x2d8f7c,null))['then'](function(_0x4e5f4e){if(_0x4e5f4e){_0x2c81cb=_0x4e5f4e;_0x39c56d['model']=_['keys'](db['User'][_0xf853('0x4a')]);_0x39c56d[_0xf853('0x38')]=_[_0xf853('0x57')](_0x17ed5b['query']);_0x39c56d[_0xf853('0x39')]=_[_0xf853('0x3a')](_0x39c56d[_0xf853('0x37')],_0x39c56d[_0xf853('0x38')]);_0x23d643[_0xf853('0x3b')]=_[_0xf853('0x3a')](_0x39c56d[_0xf853('0x37')],qs['fields'](_0x17ed5b['query'][_0xf853('0x3c')]));_0x23d643[_0xf853('0x3b')]=_0x23d643[_0xf853('0x3b')]['length']?_0x23d643[_0xf853('0x3b')]:_0x39c56d[_0xf853('0x37')];_0x23d643[_0xf853('0x3f')]=qs[_0xf853('0x59')](_0x17ed5b[_0xf853('0x38')]['sort']);_0x23d643[_0xf853('0x40')]=qs[_0xf853('0x39')](_['pick'](_0x17ed5b[_0xf853('0x38')],_0x39c56d[_0xf853('0x39')]));if(_0x17ed5b[_0xf853('0x38')][_0xf853('0x42')]){_0x23d643[_0xf853('0x40')]=_[_0xf853('0x43')](_0x23d643[_0xf853('0x40')],{'$or':_[_0xf853('0x33')](_0x23d643[_0xf853('0x3b')],function(_0x4de40c){var _0x2ffa36={};_0x2ffa36[_0x4de40c]={'$like':'%'+_0x17ed5b[_0xf853('0x38')][_0xf853('0x42')]+'%'};return _0x2ffa36;})});}_0x23d643=_[_0xf853('0x43')]({},_0x23d643,_0x17ed5b['options']);return _0x2c81cb['getAgents'](_0x23d643);}})[_0xf853('0x29')](function(_0x11fe10){if(_0x11fe10){_0x3eb82c=_0x11fe10['length'];if(!_0x17ed5b[_0xf853('0x38')][_0xf853('0x58')](_0xf853('0x3e'))){_0x23d643[_0xf853('0x23')]=qs[_0xf853('0x23')](_0x17ed5b['query'][_0xf853('0x23')]);_0x23d643[_0xf853('0x21')]=qs[_0xf853('0x21')](_0x17ed5b['query']['offset']);}return _0x2c81cb[_0xf853('0x9f')](_0x23d643);}})['then'](function(_0x41cae3){if(_0x41cae3){return _0x41cae3?{'count':_0x3eb82c,'rows':_0x41cae3}:null;}})[_0xf853('0x29')](respondWithResult(_0x2d8f7c,null))['catch'](handleError(_0x2d8f7c,null));};function handleQuery(_0x4f006d){logger[_0xf853('0xa0')](_0x4f006d);return db[_0xf853('0x8b')][_0xf853('0x38')](_0x4f006d)[_0xf853('0x9b')](function(_0x4dcd89){csv_results[_0xf853('0x64')](_0x4dcd89);})['catch'](function(_0x32108e){logger[_0xf853('0x2f')](_0x32108e[_0xf853('0x69')]);});}
\ No newline at end of file
+var _0xcf6b=['model','map','query','keys','intersection','fields','attributes','length','nolimit','order','sort','filters','filter','where','VIRTUAL','merge','options','includeAll','include','findAll','rows','catch','show','params','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','userProfileId','error','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','find','describe','ListId','Disposition','getDispositions','findOne','rawAttributes','pick','removeDispositions','ids','addContacts','CmContact','tags','isArray','join','push','each','omit','dataValues','errors','Malformed\x20request\x20syntax','getContacts','CustomFields','concat','cf_%d','hasOwnProperty','raw','ContactItemType','OrderBy','CmCustomField','alias','from','c.ListId\x20=\x20?','c.deletedAt\x20is\x20null','field','c.cf_','customField_','cm_contact_has_items','ItemTypeId\x20=\x20?','CmContactId\x20=\x20c.id','additionalPhone_','select','description_additionalPhone_','toString','now','writeFileSync','/tmp/list_%d_%s.csv','setHeader','Content-disposition','attachment;\x20filename=','format','list_%d_%s.csv','Content-type','text/csv','download','sendStatus','addCustomField','sequelize','transaction','addCustomFields','TEXT','text','number','Sequelize','switch','BOOLEAN','defaultValue','queryInterface','cm_contacts','cf_%s','getCustomFields','getGlobalCustomFields','findAndCountAll','addAgents','emit','userCmList:save','removeAgents','userCmList:remove','getAgents','User','spread','eml-format','rimraf','zip-dir','fast-json-patch','moment','bluebird','mustache','util','to-csv','ejs','fs-extra','lodash','squel','desk.js','querystring','ioredis','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','socket.io-emitter','register','status','json','offset','undefined','count','limit','Content-Range','apply','save','update','then','get','Lists','UserProfileResource','destroy','stack','name','CmList','fieldName','type','key'];(function(_0x3ad7be,_0x224585){var _0x2b6c8a=function(_0xa09237){while(--_0xa09237){_0x3ad7be['push'](_0x3ad7be['shift']());}};_0x2b6c8a(++_0x224585);}(_0xcf6b,0x72));var _0xbcf6=function(_0xfae23b,_0x2be4ba){_0xfae23b=_0xfae23b-0x0;var _0x200640=_0xcf6b[_0xfae23b];return _0x200640;};'use strict';var emlformat=require(_0xbcf6('0x0'));var rimraf=require(_0xbcf6('0x1'));var zipdir=require(_0xbcf6('0x2'));var jsonpatch=require(_0xbcf6('0x3'));var rp=require('request-promise');var moment=require(_0xbcf6('0x4'));var BPromise=require(_0xbcf6('0x5'));var Mustache=require(_0xbcf6('0x6'));var util=require(_0xbcf6('0x7'));var path=require('path');var sox=require('sox');var csv=require(_0xbcf6('0x8'));var ejs=require(_0xbcf6('0x9'));var fs=require('fs');var fs_extra=require(_0xbcf6('0xa'));var _=require(_0xbcf6('0xb'));var squel=require(_0xbcf6('0xc'));var crypto=require('crypto');var jsforce=require('jsforce');var deskjs=require(_0xbcf6('0xd'));var toCsv=require(_0xbcf6('0x8'));var querystring=require(_0xbcf6('0xe'));var Papa=require('papaparse');var Redis=require(_0xbcf6('0xf'));var authService=require('../../components/auth/service');var qs=require('../../components/parsers/qs');var as=require(_0xbcf6('0x10'));var hardwareService=require(_0xbcf6('0x11'));var logger=require(_0xbcf6('0x12'))(_0xbcf6('0x13'));var utils=require('../../config/utils');var config=require(_0xbcf6('0x14'));var licenseUtil=require(_0xbcf6('0x15'));var db=require(_0xbcf6('0x16'))['db'];var csv_results;config[_0xbcf6('0x17')]=_[_0xbcf6('0x18')](config[_0xbcf6('0x17')],{'host':'localhost','port':0x18eb});var socket=require(_0xbcf6('0x19'))(new Redis(config[_0xbcf6('0x17')]));require('./cmList.socket')[_0xbcf6('0x1a')](socket);function respondWithStatusCode(_0xaa2d54,_0x26c683){_0x26c683=_0x26c683||0xcc;return function(_0x157db6){if(_0x157db6){return _0xaa2d54['sendStatus'](_0x26c683);}return _0xaa2d54['status'](_0x26c683)['end']();};}function respondWithResult(_0x51537f,_0xdc824d){_0xdc824d=_0xdc824d||0xc8;return function(_0x11e87a){if(_0x11e87a){return _0x51537f[_0xbcf6('0x1b')](_0xdc824d)[_0xbcf6('0x1c')](_0x11e87a);}};}function respondWithFilteredResult(_0x48aa84,_0x1dc6c9){return function(_0x992387){if(_0x992387){var _0x39388e=typeof _0x1dc6c9[_0xbcf6('0x1d')]===_0xbcf6('0x1e')&&typeof _0x1dc6c9['limit']===_0xbcf6('0x1e');var _0x5f1d52=_0x992387[_0xbcf6('0x1f')];var _0x9153c2=_0x39388e?0x0:_0x1dc6c9[_0xbcf6('0x1d')];var _0x340890=_0x39388e?_0x992387[_0xbcf6('0x1f')]:_0x1dc6c9['offset']+_0x1dc6c9[_0xbcf6('0x20')];var _0x5b4061;if(_0x340890>=_0x5f1d52){_0x340890=_0x5f1d52;_0x5b4061=0xc8;}else{_0x5b4061=0xce;}_0x48aa84[_0xbcf6('0x1b')](_0x5b4061);return _0x48aa84['set'](_0xbcf6('0x21'),_0x9153c2+'-'+_0x340890+'/'+_0x5f1d52)[_0xbcf6('0x1c')](_0x992387);}return null;};}function patchUpdates(_0x5b6273){return function(_0x5f03a3){try{jsonpatch[_0xbcf6('0x22')](_0x5f03a3,_0x5b6273,!![]);}catch(_0x34fb4e){return BPromise['reject'](_0x34fb4e);}return _0x5f03a3[_0xbcf6('0x23')]();};}function saveUpdates(_0x95b32c,_0x445d8e){return function(_0x1fbac6){if(_0x1fbac6){return _0x1fbac6[_0xbcf6('0x24')](_0x95b32c)['then'](function(_0x398fe8){return _0x398fe8;});}return null;};}function removeEntity(_0x323021,_0x3bf80a){return function(_0xbc32ec){if(_0xbc32ec){return _0xbc32ec['destroy']()[_0xbcf6('0x25')](function(){var _0x3ea3ad=_0xbc32ec[_0xbcf6('0x26')]({'plain':!![]});var _0x4d0796=_0xbcf6('0x27');return db[_0xbcf6('0x28')][_0xbcf6('0x29')]({'where':{'type':_0x4d0796,'resourceId':_0x3ea3ad['id']}})['then'](function(){return _0xbc32ec;});})[_0xbcf6('0x25')](function(){_0x323021['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x2c1f8d,_0x563bdf){return function(_0x33ad06){if(!_0x33ad06){_0x2c1f8d['sendStatus'](0x194);}return _0x33ad06;};}function handleError(_0x4e894e,_0x4048ed){_0x4048ed=_0x4048ed||0x1f4;return function(_0x1788ea){logger['error'](_0x1788ea[_0xbcf6('0x2a')]);if(_0x1788ea['name']){delete _0x1788ea[_0xbcf6('0x2b')];}_0x4e894e[_0xbcf6('0x1b')](_0x4048ed)['send'](_0x1788ea);};}exports['index']=function(_0x5c44a1,_0x4c859d){var _0x72e391={},_0x242f25={},_0x44a292={'count':0x0,'rows':[]};var _0x2206d3=_['map'](db[_0xbcf6('0x2c')]['rawAttributes'],function(_0x2f9e9f){return{'name':_0x2f9e9f[_0xbcf6('0x2d')],'type':_0x2f9e9f[_0xbcf6('0x2e')][_0xbcf6('0x2f')]};});_0x242f25[_0xbcf6('0x30')]=_[_0xbcf6('0x31')](_0x2206d3,_0xbcf6('0x2b'));_0x242f25[_0xbcf6('0x32')]=_[_0xbcf6('0x33')](_0x5c44a1['query']);_0x242f25['filters']=_[_0xbcf6('0x34')](_0x242f25[_0xbcf6('0x30')],_0x242f25[_0xbcf6('0x32')]);_0x72e391['attributes']=_[_0xbcf6('0x34')](_0x242f25[_0xbcf6('0x30')],qs[_0xbcf6('0x35')](_0x5c44a1['query'][_0xbcf6('0x35')]));_0x72e391[_0xbcf6('0x36')]=_0x72e391[_0xbcf6('0x36')][_0xbcf6('0x37')]?_0x72e391['attributes']:_0x242f25[_0xbcf6('0x30')];if(!_0x5c44a1[_0xbcf6('0x32')]['hasOwnProperty'](_0xbcf6('0x38'))){_0x72e391[_0xbcf6('0x20')]=qs[_0xbcf6('0x20')](_0x5c44a1[_0xbcf6('0x32')][_0xbcf6('0x20')]);_0x72e391[_0xbcf6('0x1d')]=qs[_0xbcf6('0x1d')](_0x5c44a1[_0xbcf6('0x32')]['offset']);}_0x72e391[_0xbcf6('0x39')]=qs[_0xbcf6('0x3a')](_0x5c44a1['query'][_0xbcf6('0x3a')]);_0x72e391['where']=qs[_0xbcf6('0x3b')](_['pick'](_0x5c44a1[_0xbcf6('0x32')],_0x242f25[_0xbcf6('0x3b')]),_0x2206d3);if(_0x5c44a1[_0xbcf6('0x32')][_0xbcf6('0x3c')]){_0x72e391[_0xbcf6('0x3d')]=_['merge'](_0x72e391[_0xbcf6('0x3d')],{'$or':_[_0xbcf6('0x31')](_0x2206d3,function(_0x4c58f5){if(_0x4c58f5[_0xbcf6('0x2e')]!==_0xbcf6('0x3e')){var _0x2055c4={};_0x2055c4[_0x4c58f5['name']]={'$like':'%'+_0x5c44a1[_0xbcf6('0x32')][_0xbcf6('0x3c')]+'%'};return _0x2055c4;}})});}_0x72e391=_[_0xbcf6('0x3f')]({},_0x72e391,_0x5c44a1[_0xbcf6('0x40')]);var _0xeaa133={'where':_0x72e391[_0xbcf6('0x3d')]};return db[_0xbcf6('0x2c')][_0xbcf6('0x1f')](_0xeaa133)[_0xbcf6('0x25')](function(_0x472148){_0x44a292[_0xbcf6('0x1f')]=_0x472148;if(_0x5c44a1['query'][_0xbcf6('0x41')]){_0x72e391[_0xbcf6('0x42')]=[{'all':!![]}];}return db[_0xbcf6('0x2c')][_0xbcf6('0x43')](_0x72e391);})[_0xbcf6('0x25')](function(_0x5eb4c9){_0x44a292[_0xbcf6('0x44')]=_0x5eb4c9;return _0x44a292;})[_0xbcf6('0x25')](respondWithFilteredResult(_0x4c859d,_0x72e391))[_0xbcf6('0x45')](handleError(_0x4c859d,null));};exports[_0xbcf6('0x46')]=function(_0x501c63,_0x25a2a1){var _0x2f4f44={'raw':![],'where':{'id':_0x501c63[_0xbcf6('0x47')]['id']}},_0x5e61af={};_0x5e61af[_0xbcf6('0x30')]=_[_0xbcf6('0x33')](db[_0xbcf6('0x2c')]['rawAttributes']);_0x5e61af[_0xbcf6('0x32')]=_['keys'](_0x501c63[_0xbcf6('0x32')]);_0x5e61af['filters']=_['intersection'](_0x5e61af[_0xbcf6('0x30')],_0x5e61af['query']);_0x2f4f44[_0xbcf6('0x36')]=_[_0xbcf6('0x34')](_0x5e61af[_0xbcf6('0x30')],qs[_0xbcf6('0x35')](_0x501c63['query']['fields']));_0x2f4f44['attributes']=_0x2f4f44[_0xbcf6('0x36')][_0xbcf6('0x37')]?_0x2f4f44[_0xbcf6('0x36')]:_0x5e61af[_0xbcf6('0x30')];if(_0x501c63[_0xbcf6('0x32')]['includeAll']){_0x2f4f44[_0xbcf6('0x42')]=[{'all':!![]}];}_0x2f4f44=_[_0xbcf6('0x3f')]({},_0x2f4f44,_0x501c63[_0xbcf6('0x40')]);return db[_0xbcf6('0x2c')]['find'](_0x2f4f44)['then'](handleEntityNotFound(_0x25a2a1,null))[_0xbcf6('0x25')](respondWithResult(_0x25a2a1,null))[_0xbcf6('0x45')](handleError(_0x25a2a1,null));};exports[_0xbcf6('0x48')]=function(_0x3782ef,_0x4732ee){return db['CmList']['create'](_0x3782ef[_0xbcf6('0x49')],{})[_0xbcf6('0x25')](function(_0x135bfe){var _0x401e7f=_0x3782ef[_0xbcf6('0x4a')][_0xbcf6('0x26')]({'plain':!![]});if(!_0x401e7f)throw new Error(_0xbcf6('0x4b'));if(_0x401e7f[_0xbcf6('0x4c')]===_0xbcf6('0x4a')){var _0x3b9ee7=_0x135bfe['get']({'plain':!![]});var _0x4950f5='Lists';return db[_0xbcf6('0x4d')]['find']({'where':{'name':_0x4950f5,'userProfileId':_0x401e7f[_0xbcf6('0x4e')]},'raw':!![]})[_0xbcf6('0x25')](function(_0x457c83){if(_0x457c83&&_0x457c83['autoAssociation']===0x0){return db['UserProfileResource'][_0xbcf6('0x48')]({'name':_0x3b9ee7['name'],'resourceId':_0x3b9ee7['id'],'type':_0x457c83[_0xbcf6('0x2b')],'sectionId':_0x457c83['id']},{})['then'](function(){return _0x135bfe;});}else{return _0x135bfe;}})['catch'](function(_0x1c48f6){logger[_0xbcf6('0x4f')](_0xbcf6('0x50'),_0x1c48f6);throw _0x1c48f6;});}return _0x135bfe;})[_0xbcf6('0x25')](respondWithResult(_0x4732ee,0xc9))[_0xbcf6('0x45')](handleError(_0x4732ee,null));};exports[_0xbcf6('0x24')]=function(_0x739b82,_0x1724e4){if(_0x739b82[_0xbcf6('0x49')]['id']){delete _0x739b82[_0xbcf6('0x49')]['id'];}return db[_0xbcf6('0x2c')][_0xbcf6('0x51')]({'where':{'id':_0x739b82[_0xbcf6('0x47')]['id']}})[_0xbcf6('0x25')](handleEntityNotFound(_0x1724e4,null))['then'](saveUpdates(_0x739b82[_0xbcf6('0x49')],null))[_0xbcf6('0x25')](respondWithResult(_0x1724e4,null))['catch'](handleError(_0x1724e4,null));};exports[_0xbcf6('0x29')]=function(_0x5b5be0,_0x5dc5dc){return db['CmList'][_0xbcf6('0x51')]({'where':{'id':_0x5b5be0[_0xbcf6('0x47')]['id']}})[_0xbcf6('0x25')](handleEntityNotFound(_0x5dc5dc,null))[_0xbcf6('0x25')](removeEntity(_0x5dc5dc,null))[_0xbcf6('0x45')](handleError(_0x5dc5dc,null));};exports[_0xbcf6('0x52')]=function(_0x5b67fd,_0x180edb){return db['CmList'][_0xbcf6('0x52')]()[_0xbcf6('0x25')](respondWithResult(_0x180edb,null))[_0xbcf6('0x45')](handleError(_0x180edb,null));};exports['addDisposition']=function(_0x35f862,_0x1f423e,_0x21da89){if(_0x35f862[_0xbcf6('0x49')]['id']){delete _0x35f862['body']['id'];}return db[_0xbcf6('0x2c')][_0xbcf6('0x51')]({'where':{'id':_0x35f862[_0xbcf6('0x47')]['id']}})[_0xbcf6('0x25')](handleEntityNotFound(_0x1f423e,null))[_0xbcf6('0x25')](function(_0x234809){if(_0x234809){_0x35f862[_0xbcf6('0x49')][_0xbcf6('0x53')]=_0x234809['id'];return db[_0xbcf6('0x54')][_0xbcf6('0x48')](_0x35f862[_0xbcf6('0x49')]);}})[_0xbcf6('0x25')](respondWithResult(_0x1f423e,null))[_0xbcf6('0x45')](handleError(_0x1f423e,null));};exports[_0xbcf6('0x55')]=function(_0x5d42b0,_0x4edb30,_0x3d433a){var _0x55175b={'raw':![],'where':{}};var _0x441a42={};var _0x1ea029={'count':0x0,'rows':[]};return db['CmList'][_0xbcf6('0x56')]({'where':{'id':_0x5d42b0[_0xbcf6('0x47')]['id']}})[_0xbcf6('0x25')](handleEntityNotFound(_0x4edb30,null))[_0xbcf6('0x25')](function(_0x1670e6){if(_0x1670e6){_0x441a42[_0xbcf6('0x30')]=_[_0xbcf6('0x33')](db['Disposition'][_0xbcf6('0x57')]);_0x441a42['query']=_[_0xbcf6('0x33')](_0x5d42b0[_0xbcf6('0x32')]);_0x441a42[_0xbcf6('0x3b')]=_[_0xbcf6('0x34')](_0x441a42['model'],_0x441a42[_0xbcf6('0x32')]);_0x55175b['attributes']=_[_0xbcf6('0x34')](_0x441a42[_0xbcf6('0x30')],qs[_0xbcf6('0x35')](_0x5d42b0[_0xbcf6('0x32')][_0xbcf6('0x35')]));_0x55175b[_0xbcf6('0x36')]=_0x55175b[_0xbcf6('0x36')][_0xbcf6('0x37')]?_0x55175b[_0xbcf6('0x36')]:_0x441a42[_0xbcf6('0x30')];if(!_0x5d42b0[_0xbcf6('0x32')]['hasOwnProperty'](_0xbcf6('0x38'))){_0x55175b[_0xbcf6('0x20')]=qs['limit'](_0x5d42b0['query'][_0xbcf6('0x20')]);_0x55175b[_0xbcf6('0x1d')]=qs[_0xbcf6('0x1d')](_0x5d42b0[_0xbcf6('0x32')][_0xbcf6('0x1d')]);}_0x55175b[_0xbcf6('0x39')]=qs[_0xbcf6('0x3a')](_0x5d42b0['query'][_0xbcf6('0x3a')]);_0x55175b[_0xbcf6('0x3d')]=qs[_0xbcf6('0x3b')](_[_0xbcf6('0x58')](_0x5d42b0[_0xbcf6('0x32')],_0x441a42[_0xbcf6('0x3b')]));_0x55175b[_0xbcf6('0x3d')]['ListId']=_0x1670e6['id'];if(_0x5d42b0[_0xbcf6('0x32')][_0xbcf6('0x3c')]){_0x55175b[_0xbcf6('0x3d')]=_[_0xbcf6('0x3f')](_0x55175b['where'],{'$or':_[_0xbcf6('0x31')](_0x55175b[_0xbcf6('0x36')],function(_0x52695c){var _0x3d7a8d={};_0x3d7a8d[_0x52695c]={'$like':'%'+_0x5d42b0[_0xbcf6('0x32')]['filter']+'%'};return _0x3d7a8d;})});}_0x55175b=_[_0xbcf6('0x3f')]({},_0x55175b,_0x5d42b0[_0xbcf6('0x40')]);return db['Disposition'][_0xbcf6('0x1f')]({'where':_0x55175b['where']})[_0xbcf6('0x25')](function(_0x4406c6){_0x1ea029[_0xbcf6('0x1f')]=_0x4406c6;if(_0x5d42b0['query']['includeAll']){_0x55175b[_0xbcf6('0x42')]=[{'all':!![]}];}return db[_0xbcf6('0x54')]['findAll'](_0x55175b);})[_0xbcf6('0x25')](function(_0xfedc7c){_0x1ea029['rows']=_0xfedc7c;return _0x1ea029;});}})[_0xbcf6('0x25')](respondWithFilteredResult(_0x4edb30,_0x55175b))['catch'](handleError(_0x4edb30,null));};exports[_0xbcf6('0x59')]=function(_0x4664a8,_0x2f1f6a,_0x3e9817){return db[_0xbcf6('0x2c')][_0xbcf6('0x51')]({'where':{'id':_0x4664a8[_0xbcf6('0x47')]['id']}})[_0xbcf6('0x25')](handleEntityNotFound(_0x2f1f6a,null))[_0xbcf6('0x25')](function(_0x1b89d2){if(_0x1b89d2){return _0x1b89d2[_0xbcf6('0x59')](_0x4664a8[_0xbcf6('0x32')][_0xbcf6('0x5a')]);}})[_0xbcf6('0x25')](respondWithStatusCode(_0x2f1f6a,null))[_0xbcf6('0x45')](handleError(_0x2f1f6a,null));};exports[_0xbcf6('0x5b')]=function(_0x5cc8f1,_0x2b49ea,_0x26abcc){return db[_0xbcf6('0x2c')][_0xbcf6('0x51')]({'where':{'id':_0x5cc8f1[_0xbcf6('0x47')]['id']}})[_0xbcf6('0x25')](handleEntityNotFound(_0x2b49ea,null))[_0xbcf6('0x25')](function(_0x20af64){if(_0x20af64){var _0x129136=[];var _0x1b0871={'success':[],'errors':[]};return db[_0xbcf6('0x5c')][_0xbcf6('0x52')]()[_0xbcf6('0x25')](function(_0xa66bac){if(_0x5cc8f1['body'][_0xbcf6('0x5d')]&&_[_0xbcf6('0x5e')](_0x5cc8f1[_0xbcf6('0x49')][_0xbcf6('0x5d')])){if(_0x5cc8f1['body']['tags'][_0xbcf6('0x37')]){_0x5cc8f1[_0xbcf6('0x49')][_0xbcf6('0x5d')]=_0x5cc8f1['body'][_0xbcf6('0x5d')][_0xbcf6('0x5f')](';')+';';}else{_0x5cc8f1[_0xbcf6('0x49')]['tags']=null;}}else{_0x5cc8f1[_0xbcf6('0x49')][_0xbcf6('0x5d')]=null;}if(_0x5cc8f1[_0xbcf6('0x49')]&&_[_0xbcf6('0x5e')](_0x5cc8f1[_0xbcf6('0x49')])){for(var _0x1f9fa5=0x0;_0x1f9fa5<_0x5cc8f1[_0xbcf6('0x49')][_0xbcf6('0x37')];_0x1f9fa5+=0x1){_0x5cc8f1['body'][_0x1f9fa5]['ListId']=_0x5cc8f1[_0xbcf6('0x47')]['id'];_0x129136[_0xbcf6('0x60')](_0x5cc8f1[_0xbcf6('0x49')][_0x1f9fa5]);}return BPromise[_0xbcf6('0x61')](_0x129136,function(_0x2c9b1d){return db[_0xbcf6('0x5c')]['create'](_[_0xbcf6('0x62')](_0x2c9b1d,[_0xbcf6('0x5a'),'id'])||{},{'fields':_[_0xbcf6('0x33')](_0xa66bac),'raw':!![]})[_0xbcf6('0x25')](function(_0x3f989a){_0x1b0871['success'][_0xbcf6('0x60')](_0x3f989a[_0xbcf6('0x63')]);})['catch'](function(_0x2d354e){_0x1b0871[_0xbcf6('0x64')][_0xbcf6('0x60')]({'data':_0x2c9b1d,'error':_0x2d354e['message']});});})['then'](function(_0x5e4d24){return _0x1b0871;})[_0xbcf6('0x45')](function(_0x1c7f57){return _0x1c7f57;});}else{_0x2b49ea[_0xbcf6('0x1b')](0x190)['json']({'message':_0xbcf6('0x65')});}});}})[_0xbcf6('0x25')](respondWithResult(_0x2b49ea,null))[_0xbcf6('0x45')](handleError(_0x2b49ea,null));};exports[_0xbcf6('0x66')]=function(_0x5f2ed0,_0x25e1ed,_0x27d3a9){var _0x11ce27;return db['CmList'][_0xbcf6('0x51')]({'where':{'id':_0x5f2ed0[_0xbcf6('0x47')]['id']},'include':[{'model':db['CmCustomField'],'as':_0xbcf6('0x67')}]})[_0xbcf6('0x25')](handleEntityNotFound(_0x25e1ed,null))[_0xbcf6('0x25')](function(_0x17b22a){if(_0x17b22a){_0x11ce27=_0x17b22a;return db[_0xbcf6('0x5c')][_0xbcf6('0x57')];}})['then'](function(_0x442ccb){if(_0x442ccb){var _0x55e325={};var _0x1911b5={};_0x1911b5[_0xbcf6('0x30')]=_[_0xbcf6('0x68')](_[_0xbcf6('0x33')](_0x442ccb),_[_0xbcf6('0x31')](_0x11ce27[_0xbcf6('0x67')],function(_0x3c71d0){return util['format'](_0xbcf6('0x69'),_0x3c71d0['id']);}));_0x1911b5['query']=_[_0xbcf6('0x33')](_0x5f2ed0[_0xbcf6('0x32')]);_0x1911b5[_0xbcf6('0x3b')]=_['intersection'](_0x1911b5['model'],_0x1911b5[_0xbcf6('0x32')]);_0x55e325[_0xbcf6('0x36')]=_['intersection'](_0x1911b5[_0xbcf6('0x30')],qs[_0xbcf6('0x35')](_0x5f2ed0[_0xbcf6('0x32')][_0xbcf6('0x35')]));_0x55e325[_0xbcf6('0x36')]=_0x55e325[_0xbcf6('0x36')][_0xbcf6('0x37')]?_0x55e325[_0xbcf6('0x36')]:_0x1911b5[_0xbcf6('0x30')];if(!_0x5f2ed0[_0xbcf6('0x32')][_0xbcf6('0x6a')](_0xbcf6('0x38'))){_0x55e325[_0xbcf6('0x20')]=qs[_0xbcf6('0x20')](_0x5f2ed0[_0xbcf6('0x32')][_0xbcf6('0x20')]);_0x55e325[_0xbcf6('0x1d')]=qs[_0xbcf6('0x1d')](_0x5f2ed0[_0xbcf6('0x32')][_0xbcf6('0x1d')]);}_0x55e325[_0xbcf6('0x39')]=qs[_0xbcf6('0x3a')](_0x5f2ed0[_0xbcf6('0x32')][_0xbcf6('0x3a')]);_0x55e325[_0xbcf6('0x3d')]=qs['filters'](_[_0xbcf6('0x58')](_0x5f2ed0[_0xbcf6('0x32')],_0x1911b5[_0xbcf6('0x3b')]));_0x55e325[_0xbcf6('0x6b')]=!![];if(_0x5f2ed0[_0xbcf6('0x32')]['filter']){_0x55e325[_0xbcf6('0x3d')]=_['merge'](_0x55e325[_0xbcf6('0x3d')],{'$or':_['map'](_0x55e325[_0xbcf6('0x36')],function(_0x48c185){var _0x682b11={};_0x682b11[_0x48c185]={'$like':'%'+_0x5f2ed0['query'][_0xbcf6('0x3c')]+'%'};return _0x682b11;})});}_0x55e325=_[_0xbcf6('0x3f')]({},_0x55e325,_0x5f2ed0[_0xbcf6('0x40')]);return _0x11ce27['getContacts'](_0x55e325);}})['then'](respondWithResult(_0x25e1ed,null))[_0xbcf6('0x45')](handleError(_0x25e1ed,null));};exports['getContactsCsv']=function(_0x3af64f,_0x5bead3,_0x1a7261){var _0x104ca0;var _0x4dda76;var _0x1edc1d;var _0x44039a=_0x3af64f['params']['id'];csv_results=[];return db[_0xbcf6('0x6c')][_0xbcf6('0x43')]({'attributes':['id',_0xbcf6('0x2b')],'raw':!![],'order':[_0xbcf6('0x6d')]})[_0xbcf6('0x25')](function(_0x368c61){_0x104ca0=_0x368c61;var _0x199cd7=_[_0xbcf6('0x33')](db[_0xbcf6('0x5c')]['rawAttributes']);return db[_0xbcf6('0x6e')][_0xbcf6('0x43')]({'raw':!![],'attributes':['id',_0xbcf6('0x6f')]})[_0xbcf6('0x25')](function(_0x41e03d){_0x4dda76=_0x41e03d;var _0x24c31b=squel['select']()[_0xbcf6('0x35')](_0x199cd7)[_0xbcf6('0x70')]('cm_contacts','c')[_0xbcf6('0x3d')](_0xbcf6('0x71'),_0x44039a)['where'](_0xbcf6('0x72'))['distinct']();for(var _0x1ca7c7=0x0;_0x1ca7c7<_0x4dda76[_0xbcf6('0x37')];_0x1ca7c7++){_0x24c31b[_0xbcf6('0x73')](_0xbcf6('0x74')+_0x4dda76[_0x1ca7c7]['id'],_0xbcf6('0x75')+_0x4dda76[_0x1ca7c7][_0xbcf6('0x6f')]);}for(var _0x1ca7c7=0x0;_0x1ca7c7<_0x104ca0[_0xbcf6('0x37')];_0x1ca7c7++){_0x24c31b[_0xbcf6('0x73')](squel['select']()['field']('item')[_0xbcf6('0x70')](_0xbcf6('0x76'))[_0xbcf6('0x3d')](_0xbcf6('0x77'),_0x104ca0[_0x1ca7c7]['id'])[_0xbcf6('0x3d')](_0xbcf6('0x78')),_0xbcf6('0x79')+_0x104ca0[_0x1ca7c7][_0xbcf6('0x2b')]);_0x24c31b[_0xbcf6('0x73')](squel[_0xbcf6('0x7a')]()[_0xbcf6('0x73')]('description')['from'](_0xbcf6('0x76'))[_0xbcf6('0x3d')]('ItemTypeId\x20=\x20?',_0x104ca0[_0x1ca7c7]['id'])[_0xbcf6('0x3d')](_0xbcf6('0x78')),_0xbcf6('0x7b')+_0x104ca0[_0x1ca7c7]['name']);}var _0x45ec84=[];_0x45ec84['push'](_0x24c31b['toString']());BPromise['each'](_0x45ec84,handleQuery)[_0xbcf6('0x25')](function(_0x384e4c){handleQuery(_0x24c31b[_0xbcf6('0x7c')]());var _0x5664c4=csv_results[0x0];if(!_['isEmpty'](_0x5664c4)){var _0x279320=toCsv(_0x5664c4);var _0x19be5f=Date[_0xbcf6('0x7d')]();fs[_0xbcf6('0x7e')](util['format'](_0xbcf6('0x7f'),_0x44039a,_0x19be5f),_0x279320);_0x5bead3[_0xbcf6('0x80')](_0xbcf6('0x81'),_0xbcf6('0x82')+util[_0xbcf6('0x83')](_0xbcf6('0x84'),_0x44039a,_0x19be5f));_0x5bead3[_0xbcf6('0x80')](_0xbcf6('0x85'),_0xbcf6('0x86'));return _0x5bead3[_0xbcf6('0x87')](util[_0xbcf6('0x83')](_0xbcf6('0x7f'),_0x44039a,_0x19be5f));}else{return _0x5bead3[_0xbcf6('0x88')](0xcc);}});});});};exports[_0xbcf6('0x89')]=function(_0x537b55,_0x1e9810,_0xb3c1d7){var _0x32ff0a;delete _0x537b55[_0xbcf6('0x49')]['id'];return db[_0xbcf6('0x2c')][_0xbcf6('0x56')]({'where':{'id':_0x537b55[_0xbcf6('0x47')]['id']}})['then'](handleEntityNotFound(_0x1e9810,null))['then'](function(_0x1d3de2){if(_0x1d3de2){return db[_0xbcf6('0x8a')][_0xbcf6('0x8b')](function(_0x3874b6){return db[_0xbcf6('0x6e')][_0xbcf6('0x48')](_0x537b55[_0xbcf6('0x49')],{'transaction':_0x3874b6})[_0xbcf6('0x25')](function(_0x518f61){_0x32ff0a=_0x518f61;return _0x1d3de2[_0xbcf6('0x8c')](_0x518f61,{'transaction':_0x3874b6});})[_0xbcf6('0x25')](function(){var _0x4b4f52={'type':db['Sequelize'][_0xbcf6('0x8d')],'transaction':_0x3874b6};switch(_0x537b55[_0xbcf6('0x49')][_0xbcf6('0x2e')]){case _0xbcf6('0x8e'):_0x4b4f52['type']=db['Sequelize']['TEXT'];break;case _0xbcf6('0x8f'):_0x4b4f52[_0xbcf6('0x2e')]=db[_0xbcf6('0x90')]['INTEGER'];break;case _0xbcf6('0x91'):_0x4b4f52['type']=db[_0xbcf6('0x90')][_0xbcf6('0x92')];_0x4b4f52[_0xbcf6('0x93')]=![];break;default:}return db[_0xbcf6('0x8a')][_0xbcf6('0x94')]['addColumn'](_0xbcf6('0x95'),util[_0xbcf6('0x83')](_0xbcf6('0x96'),_0x32ff0a['id']),_0x4b4f52);})[_0xbcf6('0x25')](function(){return _0x32ff0a;});});}})[_0xbcf6('0x25')](respondWithResult(_0x1e9810,null))['catch'](handleError(_0x1e9810,null));};exports[_0xbcf6('0x97')]=function(_0x24f510,_0x40e3d2,_0x5868ee){var _0x5894bc={};var _0x16a806={};var _0x13bef7;var _0x3f3f94;return db[_0xbcf6('0x2c')][_0xbcf6('0x56')]({'where':{'id':_0x24f510['params']['id']}})[_0xbcf6('0x25')](handleEntityNotFound(_0x40e3d2,null))['then'](function(_0xe069d9){if(_0xe069d9){_0x13bef7=_0xe069d9;_0x16a806[_0xbcf6('0x30')]=_[_0xbcf6('0x33')](db[_0xbcf6('0x6e')][_0xbcf6('0x57')]);_0x16a806[_0xbcf6('0x32')]=_[_0xbcf6('0x33')](_0x24f510[_0xbcf6('0x32')]);_0x16a806[_0xbcf6('0x3b')]=_[_0xbcf6('0x34')](_0x16a806['model'],_0x16a806[_0xbcf6('0x32')]);_0x5894bc[_0xbcf6('0x36')]=_[_0xbcf6('0x34')](_0x16a806[_0xbcf6('0x30')],qs[_0xbcf6('0x35')](_0x24f510[_0xbcf6('0x32')]['fields']));_0x5894bc[_0xbcf6('0x36')]=_0x5894bc[_0xbcf6('0x36')][_0xbcf6('0x37')]?_0x5894bc[_0xbcf6('0x36')]:_0x16a806[_0xbcf6('0x30')];_0x5894bc[_0xbcf6('0x39')]=qs['sort'](_0x24f510[_0xbcf6('0x32')][_0xbcf6('0x3a')]);_0x5894bc[_0xbcf6('0x3d')]=qs[_0xbcf6('0x3b')](_['pick'](_0x24f510[_0xbcf6('0x32')],_0x16a806[_0xbcf6('0x3b')]));_0x5894bc[_0xbcf6('0x3d')]=_[_0xbcf6('0x3f')](_0x5894bc[_0xbcf6('0x3d')],{'$or':[{'ListId':_0xe069d9['id']},{'ListId':null}]});if(_0x24f510[_0xbcf6('0x32')][_0xbcf6('0x3c')]){_0x5894bc[_0xbcf6('0x3d')]=_['merge'](_0x5894bc[_0xbcf6('0x3d')],{'$or':_[_0xbcf6('0x31')](_0x5894bc[_0xbcf6('0x36')],function(_0x57974f){var _0x518ce1={};_0x518ce1[_0x57974f]={'$like':'%'+_0x24f510[_0xbcf6('0x32')][_0xbcf6('0x3c')]+'%'};return _0x518ce1;})});}_0x5894bc=_[_0xbcf6('0x3f')]({},_0x5894bc,_0x24f510[_0xbcf6('0x40')]);return db['CmCustomField']['findAndCountAll'](_0x5894bc);}})[_0xbcf6('0x25')](respondWithResult(_0x40e3d2,null))['catch'](handleError(_0x40e3d2,null));};exports[_0xbcf6('0x98')]=function(_0x5ddedc,_0x5e1490){return db[_0xbcf6('0x6e')][_0xbcf6('0x99')]({'where':{'ListId':null}})['then'](handleEntityNotFound(_0x5e1490,null))[_0xbcf6('0x25')](function(_0x43a787){return _0x43a787;})[_0xbcf6('0x25')](respondWithResult(_0x5e1490,null))[_0xbcf6('0x45')](handleError(_0x5e1490,null));};exports[_0xbcf6('0x9a')]=function(_0x22931e,_0x34760d,_0x19ee15){return db[_0xbcf6('0x2c')][_0xbcf6('0x51')]({'where':{'id':_0x22931e[_0xbcf6('0x47')]['id']}})['then'](handleEntityNotFound(_0x34760d,null))[_0xbcf6('0x25')](function(_0x4b95fc){if(_0x4b95fc){return _0x4b95fc[_0xbcf6('0x9a')](_0x22931e['body'][_0xbcf6('0x5a')],_[_0xbcf6('0x62')](_0x22931e[_0xbcf6('0x49')],[_0xbcf6('0x5a'),'id'])||{})['spread'](function(_0x11995a){for(var _0x5de09b=0x0;_0x5de09b<_0x22931e[_0xbcf6('0x49')][_0xbcf6('0x5a')][_0xbcf6('0x37')];_0x5de09b+=0x1){socket[_0xbcf6('0x9b')](_0xbcf6('0x9c'),{'UserId':Number(_0x22931e[_0xbcf6('0x49')]['ids'][_0x5de09b]),'CmListId':Number(_0x22931e[_0xbcf6('0x47')]['id'])});}return _0x11995a;});}})[_0xbcf6('0x25')](respondWithResult(_0x34760d,null))['catch'](handleError(_0x34760d,null));};exports[_0xbcf6('0x9d')]=function(_0x2a6eb5,_0x211934,_0x314a34){return db[_0xbcf6('0x2c')]['find']({'where':{'id':_0x2a6eb5['params']['id']}})['then'](handleEntityNotFound(_0x211934,null))[_0xbcf6('0x25')](function(_0x336bca){if(_0x336bca){return _0x336bca['removeAgents'](_0x2a6eb5[_0xbcf6('0x32')]['ids'])['then'](function(){if(_['isArray'](_0x2a6eb5[_0xbcf6('0x32')]['ids'])){for(var _0x2a8d1a=0x0;_0x2a8d1a<_0x2a6eb5[_0xbcf6('0x32')][_0xbcf6('0x5a')][_0xbcf6('0x37')];_0x2a8d1a+=0x1){socket['emit']('userCmList:remove',{'UserId':Number(_0x2a6eb5['query']['ids'][_0x2a8d1a]),'CmListId':Number(_0x2a6eb5[_0xbcf6('0x47')]['id'])});}}else{socket['emit'](_0xbcf6('0x9e'),{'UserId':Number(_0x2a6eb5[_0xbcf6('0x32')][_0xbcf6('0x5a')]),'CmListId':Number(_0x2a6eb5[_0xbcf6('0x47')]['id'])});}});}})[_0xbcf6('0x25')](respondWithStatusCode(_0x211934,null))[_0xbcf6('0x45')](handleError(_0x211934,null));};exports[_0xbcf6('0x9f')]=function(_0x28c00b,_0x1629d7,_0x4c9775){var _0x3b4dde={};var _0x41fd2d={};var _0x126973;var _0xc03834;return db[_0xbcf6('0x2c')][_0xbcf6('0x56')]({'where':{'id':_0x28c00b[_0xbcf6('0x47')]['id']}})[_0xbcf6('0x25')](handleEntityNotFound(_0x1629d7,null))[_0xbcf6('0x25')](function(_0x4f0fda){if(_0x4f0fda){_0x126973=_0x4f0fda;_0x41fd2d[_0xbcf6('0x30')]=_[_0xbcf6('0x33')](db[_0xbcf6('0xa0')][_0xbcf6('0x57')]);_0x41fd2d[_0xbcf6('0x32')]=_[_0xbcf6('0x33')](_0x28c00b[_0xbcf6('0x32')]);_0x41fd2d['filters']=_[_0xbcf6('0x34')](_0x41fd2d['model'],_0x41fd2d['query']);_0x3b4dde['attributes']=_[_0xbcf6('0x34')](_0x41fd2d['model'],qs[_0xbcf6('0x35')](_0x28c00b['query'][_0xbcf6('0x35')]));_0x3b4dde[_0xbcf6('0x36')]=_0x3b4dde['attributes']['length']?_0x3b4dde[_0xbcf6('0x36')]:_0x41fd2d['model'];_0x3b4dde[_0xbcf6('0x39')]=qs[_0xbcf6('0x3a')](_0x28c00b['query']['sort']);_0x3b4dde['where']=qs[_0xbcf6('0x3b')](_['pick'](_0x28c00b[_0xbcf6('0x32')],_0x41fd2d[_0xbcf6('0x3b')]));if(_0x28c00b[_0xbcf6('0x32')][_0xbcf6('0x3c')]){_0x3b4dde[_0xbcf6('0x3d')]=_[_0xbcf6('0x3f')](_0x3b4dde[_0xbcf6('0x3d')],{'$or':_['map'](_0x3b4dde[_0xbcf6('0x36')],function(_0x35fa00){var _0x44d77e={};_0x44d77e[_0x35fa00]={'$like':'%'+_0x28c00b[_0xbcf6('0x32')][_0xbcf6('0x3c')]+'%'};return _0x44d77e;})});}_0x3b4dde=_[_0xbcf6('0x3f')]({},_0x3b4dde,_0x28c00b[_0xbcf6('0x40')]);return _0x126973[_0xbcf6('0x9f')](_0x3b4dde);}})['then'](function(_0xc2a5e4){if(_0xc2a5e4){_0xc03834=_0xc2a5e4[_0xbcf6('0x37')];if(!_0x28c00b['query']['hasOwnProperty']('nolimit')){_0x3b4dde['limit']=qs[_0xbcf6('0x20')](_0x28c00b['query']['limit']);_0x3b4dde['offset']=qs['offset'](_0x28c00b[_0xbcf6('0x32')]['offset']);}return _0x126973[_0xbcf6('0x9f')](_0x3b4dde);}})[_0xbcf6('0x25')](function(_0x110bfb){if(_0x110bfb){return _0x110bfb?{'count':_0xc03834,'rows':_0x110bfb}:null;}})[_0xbcf6('0x25')](respondWithResult(_0x1629d7,null))['catch'](handleError(_0x1629d7,null));};function handleQuery(_0x436090){logger['info'](_0x436090);return db['sequelize']['query'](_0x436090)[_0xbcf6('0xa1')](function(_0x15f2aa){csv_results['push'](_0x15f2aa);})[_0xbcf6('0x45')](function(_0x42d753){logger[_0xbcf6('0x4f')](_0x42d753['message']);});}
\ No newline at end of file