Built motion from commit 1fa89557.|2.6.10
[motion2.git] / server / api / cmList / cmList.controller.js
index 9e8af21..17cac32 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xfc50=['omit','success','message','getContacts','CustomFields','concat','format','raw','getContactsCsv','OrderBy','CmCustomField','alias','select','from','cm_contacts','c.deletedAt\x20is\x20null','c.cf_','field','cm_contact_has_items','ItemTypeId\x20=\x20?','CmContactId\x20=\x20c.id','additionalPhone_','description','toString','isEmpty','now','writeFileSync','/tmp/list_%d_%s.csv','Content-disposition','attachment;\x20filename=','download','addCustomField','sequelize','transaction','addCustomFields','Sequelize','TEXT','text','number','switch','BOOLEAN','defaultValue','queryInterface','addColumn','cf_%s','findOne','getGlobalCustomFields','findAndCountAll','addAgents','spread','emit','userCmList:save','removeAgents','userCmList:remove','User','getAgents','info','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','bluebird','mustache','path','sox','to-csv','fs-extra','lodash','squel','crypto','jsforce','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','localhost','socket.io-emitter','sendStatus','end','status','json','offset','undefined','limit','count','set','apply','save','update','destroy','then','Lists','error','stack','name','send','index','map','rawAttributes','fieldName','type','key','model','query','keys','filters','intersection','fields','attributes','length','hasOwnProperty','sort','where','pick','filter','VIRTUAL','merge','options','CmList','includeAll','include','findAll','rows','catch','show','params','find','create','body','user','get','UserProfileSection','autoAssociation','UserProfileResource','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','addDisposition','ListId','getDispositions','Disposition','nolimit','order','removeDispositions','ids','addContacts','CmContact','tags','isArray','join','push','each'];(function(_0x50f392,_0x1d8441){var _0x5926f2=function(_0x17df32){while(--_0x17df32){_0x50f392['push'](_0x50f392['shift']());}};_0x5926f2(++_0x1d8441);}(_0xfc50,0x17d));var _0x0fc5=function(_0x3947c9,_0x4d6c97){_0x3947c9=_0x3947c9-0x0;var _0x2e7871=_0xfc50[_0x3947c9];return _0x2e7871;};'use strict';var emlformat=require(_0x0fc5('0x0'));var rimraf=require(_0x0fc5('0x1'));var zipdir=require(_0x0fc5('0x2'));var jsonpatch=require(_0x0fc5('0x3'));var rp=require(_0x0fc5('0x4'));var moment=require('moment');var BPromise=require(_0x0fc5('0x5'));var Mustache=require(_0x0fc5('0x6'));var util=require('util');var path=require(_0x0fc5('0x7'));var sox=require(_0x0fc5('0x8'));var csv=require(_0x0fc5('0x9'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x0fc5('0xa'));var _=require(_0x0fc5('0xb'));var squel=require(_0x0fc5('0xc'));var crypto=require(_0x0fc5('0xd'));var jsforce=require(_0x0fc5('0xe'));var deskjs=require('desk.js');var toCsv=require(_0x0fc5('0x9'));var querystring=require(_0x0fc5('0xf'));var Papa=require(_0x0fc5('0x10'));var Redis=require(_0x0fc5('0x11'));var authService=require(_0x0fc5('0x12'));var qs=require(_0x0fc5('0x13'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x0fc5('0x14'));var logger=require(_0x0fc5('0x15'))(_0x0fc5('0x16'));var utils=require(_0x0fc5('0x17'));var config=require(_0x0fc5('0x18'));var licenseUtil=require(_0x0fc5('0x19'));var db=require(_0x0fc5('0x1a'))['db'];var csv_results;config[_0x0fc5('0x1b')]=_[_0x0fc5('0x1c')](config['redis'],{'host':_0x0fc5('0x1d'),'port':0x18eb});var socket=require(_0x0fc5('0x1e'))(new Redis(config['redis']));require('./cmList.socket')['register'](socket);function respondWithStatusCode(_0x491aa5,_0xf049d8){_0xf049d8=_0xf049d8||0xcc;return function(_0x447382){if(_0x447382){return _0x491aa5[_0x0fc5('0x1f')](_0xf049d8);}return _0x491aa5['status'](_0xf049d8)[_0x0fc5('0x20')]();};}function respondWithResult(_0x84d5db,_0x44fb3e){_0x44fb3e=_0x44fb3e||0xc8;return function(_0x2532cd){if(_0x2532cd){return _0x84d5db[_0x0fc5('0x21')](_0x44fb3e)[_0x0fc5('0x22')](_0x2532cd);}};}function respondWithFilteredResult(_0x2499d0,_0xbea928){return function(_0xb2aae4){if(_0xb2aae4){var _0x2c4cae=typeof _0xbea928[_0x0fc5('0x23')]===_0x0fc5('0x24')&&typeof _0xbea928[_0x0fc5('0x25')]==='undefined';var _0x18ac0a=_0xb2aae4['count'];var _0x3f0454=_0x2c4cae?0x0:_0xbea928[_0x0fc5('0x23')];var _0x2488e5=_0x2c4cae?_0xb2aae4[_0x0fc5('0x26')]:_0xbea928[_0x0fc5('0x23')]+_0xbea928['limit'];var _0x408a8a;if(_0x2488e5>=_0x18ac0a){_0x2488e5=_0x18ac0a;_0x408a8a=0xc8;}else{_0x408a8a=0xce;}_0x2499d0[_0x0fc5('0x21')](_0x408a8a);return _0x2499d0[_0x0fc5('0x27')]('Content-Range',_0x3f0454+'-'+_0x2488e5+'/'+_0x18ac0a)['json'](_0xb2aae4);}return null;};}function patchUpdates(_0x1b3588){return function(_0x3f2587){try{jsonpatch[_0x0fc5('0x28')](_0x3f2587,_0x1b3588,!![]);}catch(_0x1ecdce){return BPromise['reject'](_0x1ecdce);}return _0x3f2587[_0x0fc5('0x29')]();};}function saveUpdates(_0x2966bd,_0x521413){return function(_0x3e8394){if(_0x3e8394){return _0x3e8394[_0x0fc5('0x2a')](_0x2966bd)['then'](function(_0x37cc27){return _0x37cc27;});}return null;};}function removeEntity(_0xa04cc7,_0x5ec4ff){return function(_0x227c4a){if(_0x227c4a){return _0x227c4a[_0x0fc5('0x2b')]()[_0x0fc5('0x2c')](function(){var _0x2b0a00=_0x227c4a['get']({'plain':!![]});var _0x436100=_0x0fc5('0x2d');return db['UserProfileResource'][_0x0fc5('0x2b')]({'where':{'type':_0x436100,'resourceId':_0x2b0a00['id']}})['then'](function(){return _0x227c4a;});})[_0x0fc5('0x2c')](function(){_0xa04cc7['status'](0xcc)[_0x0fc5('0x20')]();});}};}function handleEntityNotFound(_0x44402c,_0x134dd5){return function(_0x3742cd){if(!_0x3742cd){_0x44402c['sendStatus'](0x194);}return _0x3742cd;};}function handleError(_0x637ee1,_0x1e5adb){_0x1e5adb=_0x1e5adb||0x1f4;return function(_0x53b463){logger[_0x0fc5('0x2e')](_0x53b463[_0x0fc5('0x2f')]);if(_0x53b463[_0x0fc5('0x30')]){delete _0x53b463[_0x0fc5('0x30')];}_0x637ee1[_0x0fc5('0x21')](_0x1e5adb)[_0x0fc5('0x31')](_0x53b463);};}exports[_0x0fc5('0x32')]=function(_0x283581,_0xaeee80){var _0x564eb8={},_0x25f148={},_0x44eef4={'count':0x0,'rows':[]};var _0x5d4166=_[_0x0fc5('0x33')](db['CmList'][_0x0fc5('0x34')],function(_0x12c4a5){return{'name':_0x12c4a5[_0x0fc5('0x35')],'type':_0x12c4a5[_0x0fc5('0x36')][_0x0fc5('0x37')]};});_0x25f148[_0x0fc5('0x38')]=_[_0x0fc5('0x33')](_0x5d4166,'name');_0x25f148[_0x0fc5('0x39')]=_[_0x0fc5('0x3a')](_0x283581[_0x0fc5('0x39')]);_0x25f148[_0x0fc5('0x3b')]=_[_0x0fc5('0x3c')](_0x25f148[_0x0fc5('0x38')],_0x25f148[_0x0fc5('0x39')]);_0x564eb8['attributes']=_[_0x0fc5('0x3c')](_0x25f148[_0x0fc5('0x38')],qs[_0x0fc5('0x3d')](_0x283581[_0x0fc5('0x39')][_0x0fc5('0x3d')]));_0x564eb8[_0x0fc5('0x3e')]=_0x564eb8[_0x0fc5('0x3e')][_0x0fc5('0x3f')]?_0x564eb8[_0x0fc5('0x3e')]:_0x25f148['model'];if(!_0x283581[_0x0fc5('0x39')][_0x0fc5('0x40')]('nolimit')){_0x564eb8[_0x0fc5('0x25')]=qs[_0x0fc5('0x25')](_0x283581[_0x0fc5('0x39')][_0x0fc5('0x25')]);_0x564eb8['offset']=qs['offset'](_0x283581[_0x0fc5('0x39')][_0x0fc5('0x23')]);}_0x564eb8['order']=qs[_0x0fc5('0x41')](_0x283581[_0x0fc5('0x39')][_0x0fc5('0x41')]);_0x564eb8[_0x0fc5('0x42')]=qs[_0x0fc5('0x3b')](_[_0x0fc5('0x43')](_0x283581[_0x0fc5('0x39')],_0x25f148['filters']),_0x5d4166);if(_0x283581['query'][_0x0fc5('0x44')]){_0x564eb8[_0x0fc5('0x42')]=_['merge'](_0x564eb8[_0x0fc5('0x42')],{'$or':_[_0x0fc5('0x33')](_0x5d4166,function(_0x34d6c6){if(_0x34d6c6['type']!==_0x0fc5('0x45')){var _0x340fad={};_0x340fad[_0x34d6c6['name']]={'$like':'%'+_0x283581[_0x0fc5('0x39')][_0x0fc5('0x44')]+'%'};return _0x340fad;}})});}_0x564eb8=_[_0x0fc5('0x46')]({},_0x564eb8,_0x283581[_0x0fc5('0x47')]);var _0x1f1ce0={'where':_0x564eb8['where']};return db[_0x0fc5('0x48')][_0x0fc5('0x26')](_0x1f1ce0)['then'](function(_0x54b2c1){_0x44eef4[_0x0fc5('0x26')]=_0x54b2c1;if(_0x283581['query'][_0x0fc5('0x49')]){_0x564eb8[_0x0fc5('0x4a')]=[{'all':!![]}];}return db[_0x0fc5('0x48')][_0x0fc5('0x4b')](_0x564eb8);})[_0x0fc5('0x2c')](function(_0x2097ee){_0x44eef4[_0x0fc5('0x4c')]=_0x2097ee;return _0x44eef4;})[_0x0fc5('0x2c')](respondWithFilteredResult(_0xaeee80,_0x564eb8))[_0x0fc5('0x4d')](handleError(_0xaeee80,null));};exports[_0x0fc5('0x4e')]=function(_0x5846dd,_0x4cf120){var _0x291560={'raw':![],'where':{'id':_0x5846dd[_0x0fc5('0x4f')]['id']}},_0x25a7c1={};_0x25a7c1[_0x0fc5('0x38')]=_[_0x0fc5('0x3a')](db[_0x0fc5('0x48')][_0x0fc5('0x34')]);_0x25a7c1[_0x0fc5('0x39')]=_[_0x0fc5('0x3a')](_0x5846dd[_0x0fc5('0x39')]);_0x25a7c1[_0x0fc5('0x3b')]=_['intersection'](_0x25a7c1[_0x0fc5('0x38')],_0x25a7c1[_0x0fc5('0x39')]);_0x291560[_0x0fc5('0x3e')]=_[_0x0fc5('0x3c')](_0x25a7c1[_0x0fc5('0x38')],qs[_0x0fc5('0x3d')](_0x5846dd['query'][_0x0fc5('0x3d')]));_0x291560[_0x0fc5('0x3e')]=_0x291560[_0x0fc5('0x3e')][_0x0fc5('0x3f')]?_0x291560[_0x0fc5('0x3e')]:_0x25a7c1['model'];if(_0x5846dd[_0x0fc5('0x39')][_0x0fc5('0x49')]){_0x291560['include']=[{'all':!![]}];}_0x291560=_[_0x0fc5('0x46')]({},_0x291560,_0x5846dd['options']);return db['CmList'][_0x0fc5('0x50')](_0x291560)[_0x0fc5('0x2c')](handleEntityNotFound(_0x4cf120,null))[_0x0fc5('0x2c')](respondWithResult(_0x4cf120,null))[_0x0fc5('0x4d')](handleError(_0x4cf120,null));};exports[_0x0fc5('0x51')]=function(_0x3311d0,_0x5e7e1f){return db[_0x0fc5('0x48')]['create'](_0x3311d0[_0x0fc5('0x52')],{})['then'](function(_0x3d0667){var _0x39a1ca=_0x3311d0[_0x0fc5('0x53')][_0x0fc5('0x54')]({'plain':!![]});if(!_0x39a1ca)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x39a1ca['role']===_0x0fc5('0x53')){var _0x24f124=_0x3d0667[_0x0fc5('0x54')]({'plain':!![]});var _0x56f75e=_0x0fc5('0x2d');return db[_0x0fc5('0x55')][_0x0fc5('0x50')]({'where':{'name':_0x56f75e,'userProfileId':_0x39a1ca['userProfileId']},'raw':!![]})[_0x0fc5('0x2c')](function(_0x483b48){if(_0x483b48&&_0x483b48[_0x0fc5('0x56')]===0x0){return db[_0x0fc5('0x57')][_0x0fc5('0x51')]({'name':_0x24f124[_0x0fc5('0x30')],'resourceId':_0x24f124['id'],'type':_0x483b48[_0x0fc5('0x30')],'sectionId':_0x483b48['id']},{})[_0x0fc5('0x2c')](function(){return _0x3d0667;});}else{return _0x3d0667;}})[_0x0fc5('0x4d')](function(_0x1d3508){logger[_0x0fc5('0x2e')](_0x0fc5('0x58'),_0x1d3508);throw _0x1d3508;});}return _0x3d0667;})[_0x0fc5('0x2c')](respondWithResult(_0x5e7e1f,0xc9))[_0x0fc5('0x4d')](handleError(_0x5e7e1f,null));};exports['update']=function(_0x55791d,_0x3f00d8){if(_0x55791d[_0x0fc5('0x52')]['id']){delete _0x55791d[_0x0fc5('0x52')]['id'];}return db[_0x0fc5('0x48')][_0x0fc5('0x50')]({'where':{'id':_0x55791d[_0x0fc5('0x4f')]['id']}})[_0x0fc5('0x2c')](handleEntityNotFound(_0x3f00d8,null))[_0x0fc5('0x2c')](saveUpdates(_0x55791d['body'],null))[_0x0fc5('0x2c')](respondWithResult(_0x3f00d8,null))[_0x0fc5('0x4d')](handleError(_0x3f00d8,null));};exports[_0x0fc5('0x2b')]=function(_0x4d08ed,_0x542d5f){return db[_0x0fc5('0x48')][_0x0fc5('0x50')]({'where':{'id':_0x4d08ed['params']['id']}})['then'](handleEntityNotFound(_0x542d5f,null))[_0x0fc5('0x2c')](removeEntity(_0x542d5f,null))['catch'](handleError(_0x542d5f,null));};exports[_0x0fc5('0x59')]=function(_0x3abf8d,_0x476201){return db['CmList']['describe']()[_0x0fc5('0x2c')](respondWithResult(_0x476201,null))[_0x0fc5('0x4d')](handleError(_0x476201,null));};exports[_0x0fc5('0x5a')]=function(_0x4a9188,_0x43eb63,_0x3159b9){if(_0x4a9188[_0x0fc5('0x52')]['id']){delete _0x4a9188[_0x0fc5('0x52')]['id'];}return db[_0x0fc5('0x48')][_0x0fc5('0x50')]({'where':{'id':_0x4a9188[_0x0fc5('0x4f')]['id']}})[_0x0fc5('0x2c')](handleEntityNotFound(_0x43eb63,null))[_0x0fc5('0x2c')](function(_0x364c2a){if(_0x364c2a){_0x4a9188['body'][_0x0fc5('0x5b')]=_0x364c2a['id'];return db['Disposition'][_0x0fc5('0x51')](_0x4a9188[_0x0fc5('0x52')]);}})[_0x0fc5('0x2c')](respondWithResult(_0x43eb63,null))[_0x0fc5('0x4d')](handleError(_0x43eb63,null));};exports[_0x0fc5('0x5c')]=function(_0x145423,_0x53ac18,_0x543a66){var _0x33acb9={'raw':![],'where':{}};var _0x11b351={};var _0x493083={'count':0x0,'rows':[]};return db[_0x0fc5('0x48')]['findOne']({'where':{'id':_0x145423[_0x0fc5('0x4f')]['id']}})[_0x0fc5('0x2c')](handleEntityNotFound(_0x53ac18,null))[_0x0fc5('0x2c')](function(_0x1fcac2){if(_0x1fcac2){_0x11b351[_0x0fc5('0x38')]=_[_0x0fc5('0x3a')](db[_0x0fc5('0x5d')][_0x0fc5('0x34')]);_0x11b351[_0x0fc5('0x39')]=_[_0x0fc5('0x3a')](_0x145423['query']);_0x11b351[_0x0fc5('0x3b')]=_[_0x0fc5('0x3c')](_0x11b351['model'],_0x11b351[_0x0fc5('0x39')]);_0x33acb9['attributes']=_[_0x0fc5('0x3c')](_0x11b351[_0x0fc5('0x38')],qs[_0x0fc5('0x3d')](_0x145423['query'][_0x0fc5('0x3d')]));_0x33acb9[_0x0fc5('0x3e')]=_0x33acb9[_0x0fc5('0x3e')][_0x0fc5('0x3f')]?_0x33acb9['attributes']:_0x11b351[_0x0fc5('0x38')];if(!_0x145423[_0x0fc5('0x39')][_0x0fc5('0x40')](_0x0fc5('0x5e'))){_0x33acb9[_0x0fc5('0x25')]=qs[_0x0fc5('0x25')](_0x145423[_0x0fc5('0x39')][_0x0fc5('0x25')]);_0x33acb9['offset']=qs[_0x0fc5('0x23')](_0x145423[_0x0fc5('0x39')]['offset']);}_0x33acb9[_0x0fc5('0x5f')]=qs['sort'](_0x145423[_0x0fc5('0x39')][_0x0fc5('0x41')]);_0x33acb9[_0x0fc5('0x42')]=qs[_0x0fc5('0x3b')](_['pick'](_0x145423['query'],_0x11b351[_0x0fc5('0x3b')]));_0x33acb9[_0x0fc5('0x42')][_0x0fc5('0x5b')]=_0x1fcac2['id'];if(_0x145423[_0x0fc5('0x39')][_0x0fc5('0x44')]){_0x33acb9[_0x0fc5('0x42')]=_['merge'](_0x33acb9['where'],{'$or':_['map'](_0x33acb9[_0x0fc5('0x3e')],function(_0x1d8676){var _0x401b0f={};_0x401b0f[_0x1d8676]={'$like':'%'+_0x145423[_0x0fc5('0x39')]['filter']+'%'};return _0x401b0f;})});}_0x33acb9=_[_0x0fc5('0x46')]({},_0x33acb9,_0x145423[_0x0fc5('0x47')]);return db[_0x0fc5('0x5d')][_0x0fc5('0x26')]({'where':_0x33acb9[_0x0fc5('0x42')]})['then'](function(_0x9227bf){_0x493083[_0x0fc5('0x26')]=_0x9227bf;if(_0x145423[_0x0fc5('0x39')][_0x0fc5('0x49')]){_0x33acb9[_0x0fc5('0x4a')]=[{'all':!![]}];}return db[_0x0fc5('0x5d')]['findAll'](_0x33acb9);})[_0x0fc5('0x2c')](function(_0x5e14a6){_0x493083[_0x0fc5('0x4c')]=_0x5e14a6;return _0x493083;});}})[_0x0fc5('0x2c')](respondWithFilteredResult(_0x53ac18,_0x33acb9))[_0x0fc5('0x4d')](handleError(_0x53ac18,null));};exports[_0x0fc5('0x60')]=function(_0x52d414,_0x3a4a05,_0x47cc83){return db['CmList']['find']({'where':{'id':_0x52d414[_0x0fc5('0x4f')]['id']}})['then'](handleEntityNotFound(_0x3a4a05,null))[_0x0fc5('0x2c')](function(_0x45695e){if(_0x45695e){return _0x45695e[_0x0fc5('0x60')](_0x52d414[_0x0fc5('0x39')][_0x0fc5('0x61')]);}})[_0x0fc5('0x2c')](respondWithStatusCode(_0x3a4a05,null))[_0x0fc5('0x4d')](handleError(_0x3a4a05,null));};exports[_0x0fc5('0x62')]=function(_0x43babf,_0x3f43ee,_0x23b7cd){return db[_0x0fc5('0x48')][_0x0fc5('0x50')]({'where':{'id':_0x43babf[_0x0fc5('0x4f')]['id']}})[_0x0fc5('0x2c')](handleEntityNotFound(_0x3f43ee,null))[_0x0fc5('0x2c')](function(_0x433038){if(_0x433038){var _0x1acc42=[];var _0x38530a={'success':[],'errors':[]};return db[_0x0fc5('0x63')][_0x0fc5('0x59')]()[_0x0fc5('0x2c')](function(_0x312e27){if(_0x43babf[_0x0fc5('0x52')][_0x0fc5('0x64')]&&_[_0x0fc5('0x65')](_0x43babf[_0x0fc5('0x52')][_0x0fc5('0x64')])){if(_0x43babf[_0x0fc5('0x52')][_0x0fc5('0x64')][_0x0fc5('0x3f')]){_0x43babf[_0x0fc5('0x52')]['tags']=_0x43babf['body'][_0x0fc5('0x64')][_0x0fc5('0x66')](';')+';';}else{_0x43babf[_0x0fc5('0x52')][_0x0fc5('0x64')]=null;}}else{_0x43babf[_0x0fc5('0x52')][_0x0fc5('0x64')]=null;}if(_0x43babf[_0x0fc5('0x52')]&&_['isArray'](_0x43babf['body'])){for(var _0x1f9188=0x0;_0x1f9188<_0x43babf['body'][_0x0fc5('0x3f')];_0x1f9188+=0x1){_0x43babf[_0x0fc5('0x52')][_0x1f9188][_0x0fc5('0x5b')]=_0x43babf['params']['id'];_0x1acc42[_0x0fc5('0x67')](_0x43babf['body'][_0x1f9188]);}return BPromise[_0x0fc5('0x68')](_0x1acc42,function(_0x26c872){return db[_0x0fc5('0x63')][_0x0fc5('0x51')](_[_0x0fc5('0x69')](_0x26c872,['ids','id'])||{},{'fields':_[_0x0fc5('0x3a')](_0x312e27),'raw':!![]})[_0x0fc5('0x2c')](function(_0x341f39){_0x38530a[_0x0fc5('0x6a')][_0x0fc5('0x67')](_0x341f39['dataValues']);})[_0x0fc5('0x4d')](function(_0x283957){_0x38530a['errors'][_0x0fc5('0x67')]({'data':_0x26c872,'error':_0x283957[_0x0fc5('0x6b')]});});})['then'](function(_0x2348fb){return _0x38530a;})[_0x0fc5('0x4d')](function(_0x2b12c4){return _0x2b12c4;});}else{_0x3f43ee['status'](0x190)[_0x0fc5('0x22')]({'message':'Malformed\x20request\x20syntax'});}});}})[_0x0fc5('0x2c')](respondWithResult(_0x3f43ee,null))[_0x0fc5('0x4d')](handleError(_0x3f43ee,null));};exports[_0x0fc5('0x6c')]=function(_0x137dd7,_0x59c296,_0x1d0107){var _0x3845c0;return db['CmList'][_0x0fc5('0x50')]({'where':{'id':_0x137dd7[_0x0fc5('0x4f')]['id']},'include':[{'model':db['CmCustomField'],'as':_0x0fc5('0x6d')}]})[_0x0fc5('0x2c')](handleEntityNotFound(_0x59c296,null))[_0x0fc5('0x2c')](function(_0x53c255){if(_0x53c255){_0x3845c0=_0x53c255;return db['CmContact'][_0x0fc5('0x34')];}})[_0x0fc5('0x2c')](function(_0x361fb6){if(_0x361fb6){var _0x455254={};var _0x5909aa={};_0x5909aa[_0x0fc5('0x38')]=_[_0x0fc5('0x6e')](_[_0x0fc5('0x3a')](_0x361fb6),_[_0x0fc5('0x33')](_0x3845c0[_0x0fc5('0x6d')],function(_0xd1af70){return util[_0x0fc5('0x6f')]('cf_%d',_0xd1af70['id']);}));_0x5909aa[_0x0fc5('0x39')]=_[_0x0fc5('0x3a')](_0x137dd7[_0x0fc5('0x39')]);_0x5909aa[_0x0fc5('0x3b')]=_[_0x0fc5('0x3c')](_0x5909aa[_0x0fc5('0x38')],_0x5909aa[_0x0fc5('0x39')]);_0x455254[_0x0fc5('0x3e')]=_['intersection'](_0x5909aa[_0x0fc5('0x38')],qs[_0x0fc5('0x3d')](_0x137dd7[_0x0fc5('0x39')][_0x0fc5('0x3d')]));_0x455254[_0x0fc5('0x3e')]=_0x455254[_0x0fc5('0x3e')]['length']?_0x455254[_0x0fc5('0x3e')]:_0x5909aa[_0x0fc5('0x38')];if(!_0x137dd7[_0x0fc5('0x39')][_0x0fc5('0x40')]('nolimit')){_0x455254[_0x0fc5('0x25')]=qs[_0x0fc5('0x25')](_0x137dd7[_0x0fc5('0x39')][_0x0fc5('0x25')]);_0x455254[_0x0fc5('0x23')]=qs[_0x0fc5('0x23')](_0x137dd7[_0x0fc5('0x39')][_0x0fc5('0x23')]);}_0x455254[_0x0fc5('0x5f')]=qs[_0x0fc5('0x41')](_0x137dd7[_0x0fc5('0x39')][_0x0fc5('0x41')]);_0x455254[_0x0fc5('0x42')]=qs[_0x0fc5('0x3b')](_[_0x0fc5('0x43')](_0x137dd7['query'],_0x5909aa[_0x0fc5('0x3b')]));_0x455254[_0x0fc5('0x70')]=!![];if(_0x137dd7[_0x0fc5('0x39')][_0x0fc5('0x44')]){_0x455254[_0x0fc5('0x42')]=_[_0x0fc5('0x46')](_0x455254[_0x0fc5('0x42')],{'$or':_[_0x0fc5('0x33')](_0x455254[_0x0fc5('0x3e')],function(_0x33f45b){var _0x3e3961={};_0x3e3961[_0x33f45b]={'$like':'%'+_0x137dd7[_0x0fc5('0x39')][_0x0fc5('0x44')]+'%'};return _0x3e3961;})});}_0x455254=_[_0x0fc5('0x46')]({},_0x455254,_0x137dd7[_0x0fc5('0x47')]);return _0x3845c0[_0x0fc5('0x6c')](_0x455254);}})[_0x0fc5('0x2c')](respondWithResult(_0x59c296,null))['catch'](handleError(_0x59c296,null));};exports[_0x0fc5('0x71')]=function(_0x5219cf,_0x182282,_0x5527f3){var _0x133e37;var _0x14d36a;var _0x53706e;var _0x34dc55=_0x5219cf[_0x0fc5('0x4f')]['id'];csv_results=[];return db['ContactItemType']['findAll']({'attributes':['id',_0x0fc5('0x30')],'raw':!![],'order':[_0x0fc5('0x72')]})['then'](function(_0x2f45e5){_0x133e37=_0x2f45e5;var _0x16db3e=_['keys'](db[_0x0fc5('0x63')][_0x0fc5('0x34')]);return db[_0x0fc5('0x73')][_0x0fc5('0x4b')]({'raw':!![],'attributes':['id',_0x0fc5('0x74')]})[_0x0fc5('0x2c')](function(_0x2df12b){_0x14d36a=_0x2df12b;var _0x3f21e5=squel[_0x0fc5('0x75')]()[_0x0fc5('0x3d')](_0x16db3e)[_0x0fc5('0x76')](_0x0fc5('0x77'),'c')[_0x0fc5('0x42')]('c.ListId\x20=\x20?',_0x34dc55)[_0x0fc5('0x42')](_0x0fc5('0x78'))['distinct']();for(var _0xef975c=0x0;_0xef975c<_0x14d36a[_0x0fc5('0x3f')];_0xef975c++){_0x3f21e5['field'](_0x0fc5('0x79')+_0x14d36a[_0xef975c]['id'],'customField_'+_0x14d36a[_0xef975c][_0x0fc5('0x74')]);}for(var _0xef975c=0x0;_0xef975c<_0x133e37[_0x0fc5('0x3f')];_0xef975c++){_0x3f21e5['field'](squel[_0x0fc5('0x75')]()[_0x0fc5('0x7a')]('item')['from'](_0x0fc5('0x7b'))[_0x0fc5('0x42')](_0x0fc5('0x7c'),_0x133e37[_0xef975c]['id'])[_0x0fc5('0x42')](_0x0fc5('0x7d')),_0x0fc5('0x7e')+_0x133e37[_0xef975c][_0x0fc5('0x30')]);_0x3f21e5[_0x0fc5('0x7a')](squel[_0x0fc5('0x75')]()[_0x0fc5('0x7a')](_0x0fc5('0x7f'))['from'](_0x0fc5('0x7b'))[_0x0fc5('0x42')](_0x0fc5('0x7c'),_0x133e37[_0xef975c]['id'])[_0x0fc5('0x42')](_0x0fc5('0x7d')),'description_additionalPhone_'+_0x133e37[_0xef975c][_0x0fc5('0x30')]);}var _0x114936=[];_0x114936[_0x0fc5('0x67')](_0x3f21e5[_0x0fc5('0x80')]());BPromise[_0x0fc5('0x68')](_0x114936,handleQuery)[_0x0fc5('0x2c')](function(_0x5bb7f6){handleQuery(_0x3f21e5[_0x0fc5('0x80')]());var _0x1ce16a=csv_results[0x0];if(!_[_0x0fc5('0x81')](_0x1ce16a)){var _0x53b290=toCsv(_0x1ce16a);var _0x373fd6=Date[_0x0fc5('0x82')]();fs[_0x0fc5('0x83')](util[_0x0fc5('0x6f')](_0x0fc5('0x84'),_0x34dc55,_0x373fd6),_0x53b290);_0x182282['setHeader'](_0x0fc5('0x85'),_0x0fc5('0x86')+util['format']('list_%d_%s.csv',_0x34dc55,_0x373fd6));_0x182282['setHeader']('Content-type','text/csv');return _0x182282[_0x0fc5('0x87')](util[_0x0fc5('0x6f')](_0x0fc5('0x84'),_0x34dc55,_0x373fd6));}else{return _0x182282[_0x0fc5('0x1f')](0xcc);}});});});};exports[_0x0fc5('0x88')]=function(_0x470a20,_0x2c5154,_0x52d18a){var _0x3c2926;delete _0x470a20['body']['id'];return db[_0x0fc5('0x48')]['findOne']({'where':{'id':_0x470a20['params']['id']}})['then'](handleEntityNotFound(_0x2c5154,null))['then'](function(_0x25d639){if(_0x25d639){return db[_0x0fc5('0x89')][_0x0fc5('0x8a')](function(_0x49f218){return db[_0x0fc5('0x73')][_0x0fc5('0x51')](_0x470a20['body'],{'transaction':_0x49f218})[_0x0fc5('0x2c')](function(_0x2cd296){_0x3c2926=_0x2cd296;return _0x25d639[_0x0fc5('0x8b')](_0x2cd296,{'transaction':_0x49f218});})[_0x0fc5('0x2c')](function(){var _0x581015={'type':db[_0x0fc5('0x8c')][_0x0fc5('0x8d')],'transaction':_0x49f218};switch(_0x470a20[_0x0fc5('0x52')][_0x0fc5('0x36')]){case _0x0fc5('0x8e'):_0x581015[_0x0fc5('0x36')]=db[_0x0fc5('0x8c')][_0x0fc5('0x8d')];break;case _0x0fc5('0x8f'):_0x581015['type']=db['Sequelize']['INTEGER'];break;case _0x0fc5('0x90'):_0x581015[_0x0fc5('0x36')]=db['Sequelize'][_0x0fc5('0x91')];_0x581015[_0x0fc5('0x92')]=![];break;default:}return db['sequelize'][_0x0fc5('0x93')][_0x0fc5('0x94')](_0x0fc5('0x77'),util[_0x0fc5('0x6f')](_0x0fc5('0x95'),_0x3c2926['id']),_0x581015);})[_0x0fc5('0x2c')](function(){return _0x3c2926;});});}})[_0x0fc5('0x2c')](respondWithResult(_0x2c5154,null))['catch'](handleError(_0x2c5154,null));};exports['getCustomFields']=function(_0x5bd7b2,_0x11f271,_0xd38886){var _0x13ebc6={};var _0x3f09d2={};var _0x5fbfce;var _0x3a554c;return db['CmList'][_0x0fc5('0x96')]({'where':{'id':_0x5bd7b2[_0x0fc5('0x4f')]['id']}})['then'](handleEntityNotFound(_0x11f271,null))['then'](function(_0x2455b8){if(_0x2455b8){_0x5fbfce=_0x2455b8;_0x3f09d2[_0x0fc5('0x38')]=_[_0x0fc5('0x3a')](db[_0x0fc5('0x73')][_0x0fc5('0x34')]);_0x3f09d2[_0x0fc5('0x39')]=_[_0x0fc5('0x3a')](_0x5bd7b2[_0x0fc5('0x39')]);_0x3f09d2[_0x0fc5('0x3b')]=_[_0x0fc5('0x3c')](_0x3f09d2['model'],_0x3f09d2[_0x0fc5('0x39')]);_0x13ebc6[_0x0fc5('0x3e')]=_[_0x0fc5('0x3c')](_0x3f09d2['model'],qs[_0x0fc5('0x3d')](_0x5bd7b2['query'][_0x0fc5('0x3d')]));_0x13ebc6[_0x0fc5('0x3e')]=_0x13ebc6[_0x0fc5('0x3e')]['length']?_0x13ebc6[_0x0fc5('0x3e')]:_0x3f09d2[_0x0fc5('0x38')];_0x13ebc6[_0x0fc5('0x5f')]=qs['sort'](_0x5bd7b2['query']['sort']);_0x13ebc6['where']=qs[_0x0fc5('0x3b')](_[_0x0fc5('0x43')](_0x5bd7b2[_0x0fc5('0x39')],_0x3f09d2[_0x0fc5('0x3b')]));_0x13ebc6[_0x0fc5('0x42')]=_[_0x0fc5('0x46')](_0x13ebc6[_0x0fc5('0x42')],{'$or':[{'ListId':_0x2455b8['id']},{'ListId':null}]});if(_0x5bd7b2[_0x0fc5('0x39')]['filter']){_0x13ebc6['where']=_[_0x0fc5('0x46')](_0x13ebc6['where'],{'$or':_['map'](_0x13ebc6[_0x0fc5('0x3e')],function(_0x3c5208){var _0x550d37={};_0x550d37[_0x3c5208]={'$like':'%'+_0x5bd7b2[_0x0fc5('0x39')][_0x0fc5('0x44')]+'%'};return _0x550d37;})});}_0x13ebc6=_['merge']({},_0x13ebc6,_0x5bd7b2['options']);return db[_0x0fc5('0x73')]['findAndCountAll'](_0x13ebc6);}})['then'](respondWithResult(_0x11f271,null))[_0x0fc5('0x4d')](handleError(_0x11f271,null));};exports[_0x0fc5('0x97')]=function(_0x4df78c,_0x2c6ece){return db['CmCustomField'][_0x0fc5('0x98')]({'where':{'ListId':null}})[_0x0fc5('0x2c')](handleEntityNotFound(_0x2c6ece,null))['then'](function(_0x30da71){return _0x30da71;})['then'](respondWithResult(_0x2c6ece,null))['catch'](handleError(_0x2c6ece,null));};exports[_0x0fc5('0x99')]=function(_0x4f67a9,_0x557d08,_0x26b601){return db[_0x0fc5('0x48')][_0x0fc5('0x50')]({'where':{'id':_0x4f67a9[_0x0fc5('0x4f')]['id']}})[_0x0fc5('0x2c')](handleEntityNotFound(_0x557d08,null))['then'](function(_0x15dfdd){if(_0x15dfdd){return _0x15dfdd[_0x0fc5('0x99')](_0x4f67a9[_0x0fc5('0x52')][_0x0fc5('0x61')],_[_0x0fc5('0x69')](_0x4f67a9['body'],[_0x0fc5('0x61'),'id'])||{})[_0x0fc5('0x9a')](function(_0x29e5c2){for(var _0x4f20d4=0x0;_0x4f20d4<_0x4f67a9[_0x0fc5('0x52')][_0x0fc5('0x61')]['length'];_0x4f20d4+=0x1){socket[_0x0fc5('0x9b')](_0x0fc5('0x9c'),{'UserId':Number(_0x4f67a9[_0x0fc5('0x52')][_0x0fc5('0x61')][_0x4f20d4]),'CmListId':Number(_0x4f67a9[_0x0fc5('0x4f')]['id'])});}return _0x29e5c2;});}})['then'](respondWithResult(_0x557d08,null))[_0x0fc5('0x4d')](handleError(_0x557d08,null));};exports[_0x0fc5('0x9d')]=function(_0x30687d,_0x4ae20d,_0x2ce93){return db[_0x0fc5('0x48')][_0x0fc5('0x50')]({'where':{'id':_0x30687d[_0x0fc5('0x4f')]['id']}})[_0x0fc5('0x2c')](handleEntityNotFound(_0x4ae20d,null))['then'](function(_0x2b9f64){if(_0x2b9f64){return _0x2b9f64[_0x0fc5('0x9d')](_0x30687d[_0x0fc5('0x39')][_0x0fc5('0x61')])[_0x0fc5('0x2c')](function(){if(_[_0x0fc5('0x65')](_0x30687d[_0x0fc5('0x39')][_0x0fc5('0x61')])){for(var _0x597d59=0x0;_0x597d59<_0x30687d[_0x0fc5('0x39')][_0x0fc5('0x61')][_0x0fc5('0x3f')];_0x597d59+=0x1){socket[_0x0fc5('0x9b')](_0x0fc5('0x9e'),{'UserId':Number(_0x30687d[_0x0fc5('0x39')][_0x0fc5('0x61')][_0x597d59]),'CmListId':Number(_0x30687d['params']['id'])});}}else{socket[_0x0fc5('0x9b')]('userCmList:remove',{'UserId':Number(_0x30687d[_0x0fc5('0x39')][_0x0fc5('0x61')]),'CmListId':Number(_0x30687d[_0x0fc5('0x4f')]['id'])});}});}})['then'](respondWithStatusCode(_0x4ae20d,null))[_0x0fc5('0x4d')](handleError(_0x4ae20d,null));};exports['getAgents']=function(_0x106503,_0x69ebd6,_0x3ab7e1){var _0x537891={};var _0x3e9663={};var _0xdba160;var _0x193cbb;return db[_0x0fc5('0x48')][_0x0fc5('0x96')]({'where':{'id':_0x106503[_0x0fc5('0x4f')]['id']}})['then'](handleEntityNotFound(_0x69ebd6,null))[_0x0fc5('0x2c')](function(_0x4cecc5){if(_0x4cecc5){_0xdba160=_0x4cecc5;_0x3e9663[_0x0fc5('0x38')]=_[_0x0fc5('0x3a')](db[_0x0fc5('0x9f')][_0x0fc5('0x34')]);_0x3e9663[_0x0fc5('0x39')]=_[_0x0fc5('0x3a')](_0x106503['query']);_0x3e9663[_0x0fc5('0x3b')]=_['intersection'](_0x3e9663[_0x0fc5('0x38')],_0x3e9663[_0x0fc5('0x39')]);_0x537891[_0x0fc5('0x3e')]=_[_0x0fc5('0x3c')](_0x3e9663[_0x0fc5('0x38')],qs[_0x0fc5('0x3d')](_0x106503['query'][_0x0fc5('0x3d')]));_0x537891[_0x0fc5('0x3e')]=_0x537891[_0x0fc5('0x3e')][_0x0fc5('0x3f')]?_0x537891[_0x0fc5('0x3e')]:_0x3e9663['model'];_0x537891[_0x0fc5('0x5f')]=qs[_0x0fc5('0x41')](_0x106503[_0x0fc5('0x39')]['sort']);_0x537891[_0x0fc5('0x42')]=qs[_0x0fc5('0x3b')](_['pick'](_0x106503[_0x0fc5('0x39')],_0x3e9663[_0x0fc5('0x3b')]));if(_0x106503[_0x0fc5('0x39')]['filter']){_0x537891[_0x0fc5('0x42')]=_[_0x0fc5('0x46')](_0x537891[_0x0fc5('0x42')],{'$or':_['map'](_0x537891['attributes'],function(_0x4b8a07){var _0x47f94f={};_0x47f94f[_0x4b8a07]={'$like':'%'+_0x106503[_0x0fc5('0x39')]['filter']+'%'};return _0x47f94f;})});}_0x537891=_[_0x0fc5('0x46')]({},_0x537891,_0x106503[_0x0fc5('0x47')]);return _0xdba160['getAgents'](_0x537891);}})['then'](function(_0x46d017){if(_0x46d017){_0x193cbb=_0x46d017[_0x0fc5('0x3f')];if(!_0x106503[_0x0fc5('0x39')]['hasOwnProperty'](_0x0fc5('0x5e'))){_0x537891['limit']=qs[_0x0fc5('0x25')](_0x106503[_0x0fc5('0x39')]['limit']);_0x537891[_0x0fc5('0x23')]=qs[_0x0fc5('0x23')](_0x106503[_0x0fc5('0x39')][_0x0fc5('0x23')]);}return _0xdba160[_0x0fc5('0xa0')](_0x537891);}})[_0x0fc5('0x2c')](function(_0x39077c){if(_0x39077c){return _0x39077c?{'count':_0x193cbb,'rows':_0x39077c}:null;}})[_0x0fc5('0x2c')](respondWithResult(_0x69ebd6,null))[_0x0fc5('0x4d')](handleError(_0x69ebd6,null));};function handleQuery(_0x302dad){logger[_0x0fc5('0xa1')](_0x302dad);return db[_0x0fc5('0x89')][_0x0fc5('0x39')](_0x302dad)[_0x0fc5('0x9a')](function(_0x2dbae0){csv_results[_0x0fc5('0x67')](_0x2dbae0);})['catch'](function(_0x277fc2){logger[_0x0fc5('0x2e')](_0x277fc2[_0x0fc5('0x6b')]);});}
\ No newline at end of file
+var _0xbf84=['key','model','map','query','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','sort','where','pick','merge','filter','options','count','includeAll','include','findAll','catch','show','params','keys','create','body','Unable\x20to\x20retrieve\x20the\x20current\x20user','UserProfileSection','find','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','addDisposition','ListId','Disposition','getDispositions','findOne','order','rows','removeDispositions','addContacts','CmContact','tags','isArray','join','push','each','ids','success','errors','Malformed\x20request\x20syntax','getContacts','CmCustomField','CustomFields','concat','cf_%d','ContactItemType','select','cm_contacts','c.ListId\x20=\x20?','c.deletedAt\x20is\x20null','distinct','c.cf_','customField_','alias','field','item','cm_contact_has_items','ItemTypeId\x20=\x20?','additionalPhone_','description','from','CmContactId\x20=\x20c.id','description_additionalPhone_','toString','isEmpty','now','writeFileSync','format','/tmp/list_%d_%s.csv','setHeader','Content-disposition','attachment;\x20filename=','Content-type','text/csv','sequelize','transaction','addCustomFields','Sequelize','TEXT','text','INTEGER','switch','BOOLEAN','queryInterface','addColumn','cf_%s','getCustomFields','getGlobalCustomFields','addAgents','omit','spread','emit','userCmList:save','removeAgents','userCmList:remove','getAgents','info','message','eml-format','rimraf','zip-dir','fast-json-patch','moment','bluebird','util','path','sox','ejs','fs-extra','lodash','jsforce','desk.js','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../mysqldb','redis','defaults','localhost','socket.io-emitter','sendStatus','status','end','offset','undefined','limit','Content-Range','json','apply','reject','save','update','then','destroy','get','Lists','UserProfileResource','error','stack','name','index','CmList','rawAttributes','fieldName','type'];(function(_0x5aa77c,_0x1d441f){var _0x3ab08d=function(_0x49d796){while(--_0x49d796){_0x5aa77c['push'](_0x5aa77c['shift']());}};_0x3ab08d(++_0x1d441f);}(_0xbf84,0x6f));var _0x4bf8=function(_0x2f79ad,_0x3cd8af){_0x2f79ad=_0x2f79ad-0x0;var _0xb5279e=_0xbf84[_0x2f79ad];return _0xb5279e;};'use strict';var emlformat=require(_0x4bf8('0x0'));var rimraf=require(_0x4bf8('0x1'));var zipdir=require(_0x4bf8('0x2'));var jsonpatch=require(_0x4bf8('0x3'));var rp=require('request-promise');var moment=require(_0x4bf8('0x4'));var BPromise=require(_0x4bf8('0x5'));var Mustache=require('mustache');var util=require(_0x4bf8('0x6'));var path=require(_0x4bf8('0x7'));var sox=require(_0x4bf8('0x8'));var csv=require('to-csv');var ejs=require(_0x4bf8('0x9'));var fs=require('fs');var fs_extra=require(_0x4bf8('0xa'));var _=require(_0x4bf8('0xb'));var squel=require('squel');var crypto=require('crypto');var jsforce=require(_0x4bf8('0xc'));var deskjs=require(_0x4bf8('0xd'));var toCsv=require('to-csv');var querystring=require(_0x4bf8('0xe'));var Papa=require('papaparse');var Redis=require(_0x4bf8('0xf'));var authService=require(_0x4bf8('0x10'));var qs=require(_0x4bf8('0x11'));var as=require(_0x4bf8('0x12'));var hardwareService=require(_0x4bf8('0x13'));var logger=require(_0x4bf8('0x14'))(_0x4bf8('0x15'));var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require(_0x4bf8('0x16'))['db'];var csv_results;config[_0x4bf8('0x17')]=_[_0x4bf8('0x18')](config['redis'],{'host':_0x4bf8('0x19'),'port':0x18eb});var socket=require(_0x4bf8('0x1a'))(new Redis(config['redis']));require('./cmList.socket')['register'](socket);function respondWithStatusCode(_0x135fe8,_0x398c99){_0x398c99=_0x398c99||0xcc;return function(_0x5272d2){if(_0x5272d2){return _0x135fe8[_0x4bf8('0x1b')](_0x398c99);}return _0x135fe8[_0x4bf8('0x1c')](_0x398c99)[_0x4bf8('0x1d')]();};}function respondWithResult(_0x22cb73,_0x59c1fd){_0x59c1fd=_0x59c1fd||0xc8;return function(_0x85875c){if(_0x85875c){return _0x22cb73[_0x4bf8('0x1c')](_0x59c1fd)['json'](_0x85875c);}};}function respondWithFilteredResult(_0x1627f7,_0x4f52bc){return function(_0x3aeea3){if(_0x3aeea3){var _0x36b553=typeof _0x4f52bc[_0x4bf8('0x1e')]===_0x4bf8('0x1f')&&typeof _0x4f52bc[_0x4bf8('0x20')]===_0x4bf8('0x1f');var _0x28c431=_0x3aeea3['count'];var _0x21234c=_0x36b553?0x0:_0x4f52bc['offset'];var _0x1ff6ca=_0x36b553?_0x3aeea3['count']:_0x4f52bc[_0x4bf8('0x1e')]+_0x4f52bc[_0x4bf8('0x20')];var _0x3ad29c;if(_0x1ff6ca>=_0x28c431){_0x1ff6ca=_0x28c431;_0x3ad29c=0xc8;}else{_0x3ad29c=0xce;}_0x1627f7['status'](_0x3ad29c);return _0x1627f7['set'](_0x4bf8('0x21'),_0x21234c+'-'+_0x1ff6ca+'/'+_0x28c431)[_0x4bf8('0x22')](_0x3aeea3);}return null;};}function patchUpdates(_0x11afda){return function(_0xb3fcf){try{jsonpatch[_0x4bf8('0x23')](_0xb3fcf,_0x11afda,!![]);}catch(_0x48484f){return BPromise[_0x4bf8('0x24')](_0x48484f);}return _0xb3fcf[_0x4bf8('0x25')]();};}function saveUpdates(_0x35f2c,_0x238ae7){return function(_0x2fd449){if(_0x2fd449){return _0x2fd449[_0x4bf8('0x26')](_0x35f2c)[_0x4bf8('0x27')](function(_0x3120bf){return _0x3120bf;});}return null;};}function removeEntity(_0x3089a5,_0x227087){return function(_0x25212f){if(_0x25212f){return _0x25212f[_0x4bf8('0x28')]()['then'](function(){var _0x8209d6=_0x25212f[_0x4bf8('0x29')]({'plain':!![]});var _0x2fe194=_0x4bf8('0x2a');return db[_0x4bf8('0x2b')]['destroy']({'where':{'type':_0x2fe194,'resourceId':_0x8209d6['id']}})[_0x4bf8('0x27')](function(){return _0x25212f;});})[_0x4bf8('0x27')](function(){_0x3089a5[_0x4bf8('0x1c')](0xcc)[_0x4bf8('0x1d')]();});}};}function handleEntityNotFound(_0xdde05c,_0x3a0dad){return function(_0x4bec4a){if(!_0x4bec4a){_0xdde05c[_0x4bf8('0x1b')](0x194);}return _0x4bec4a;};}function handleError(_0x18a85f,_0x22df78){_0x22df78=_0x22df78||0x1f4;return function(_0x45340c){logger[_0x4bf8('0x2c')](_0x45340c[_0x4bf8('0x2d')]);if(_0x45340c[_0x4bf8('0x2e')]){delete _0x45340c[_0x4bf8('0x2e')];}_0x18a85f[_0x4bf8('0x1c')](_0x22df78)['send'](_0x45340c);};}exports[_0x4bf8('0x2f')]=function(_0x36a029,_0x58d402){var _0x5c7030={},_0xd8a8ba={},_0x446fd0={'count':0x0,'rows':[]};var _0x4cf6fe=_['map'](db[_0x4bf8('0x30')][_0x4bf8('0x31')],function(_0x71453b){return{'name':_0x71453b[_0x4bf8('0x32')],'type':_0x71453b[_0x4bf8('0x33')][_0x4bf8('0x34')]};});_0xd8a8ba[_0x4bf8('0x35')]=_[_0x4bf8('0x36')](_0x4cf6fe,_0x4bf8('0x2e'));_0xd8a8ba[_0x4bf8('0x37')]=_['keys'](_0x36a029[_0x4bf8('0x37')]);_0xd8a8ba[_0x4bf8('0x38')]=_[_0x4bf8('0x39')](_0xd8a8ba[_0x4bf8('0x35')],_0xd8a8ba[_0x4bf8('0x37')]);_0x5c7030[_0x4bf8('0x3a')]=_[_0x4bf8('0x39')](_0xd8a8ba['model'],qs['fields'](_0x36a029[_0x4bf8('0x37')][_0x4bf8('0x3b')]));_0x5c7030[_0x4bf8('0x3a')]=_0x5c7030[_0x4bf8('0x3a')][_0x4bf8('0x3c')]?_0x5c7030[_0x4bf8('0x3a')]:_0xd8a8ba[_0x4bf8('0x35')];if(!_0x36a029[_0x4bf8('0x37')][_0x4bf8('0x3d')](_0x4bf8('0x3e'))){_0x5c7030[_0x4bf8('0x20')]=qs[_0x4bf8('0x20')](_0x36a029[_0x4bf8('0x37')][_0x4bf8('0x20')]);_0x5c7030['offset']=qs[_0x4bf8('0x1e')](_0x36a029[_0x4bf8('0x37')][_0x4bf8('0x1e')]);}_0x5c7030['order']=qs[_0x4bf8('0x3f')](_0x36a029[_0x4bf8('0x37')]['sort']);_0x5c7030[_0x4bf8('0x40')]=qs[_0x4bf8('0x38')](_[_0x4bf8('0x41')](_0x36a029[_0x4bf8('0x37')],_0xd8a8ba[_0x4bf8('0x38')]),_0x4cf6fe);if(_0x36a029['query']['filter']){_0x5c7030[_0x4bf8('0x40')]=_[_0x4bf8('0x42')](_0x5c7030[_0x4bf8('0x40')],{'$or':_[_0x4bf8('0x36')](_0x4cf6fe,function(_0x1e035a){if(_0x1e035a[_0x4bf8('0x33')]!=='VIRTUAL'){var _0x206560={};_0x206560[_0x1e035a[_0x4bf8('0x2e')]]={'$like':'%'+_0x36a029[_0x4bf8('0x37')][_0x4bf8('0x43')]+'%'};return _0x206560;}})});}_0x5c7030=_['merge']({},_0x5c7030,_0x36a029[_0x4bf8('0x44')]);var _0x125e3c={'where':_0x5c7030[_0x4bf8('0x40')]};return db['CmList'][_0x4bf8('0x45')](_0x125e3c)[_0x4bf8('0x27')](function(_0x5aa05a){_0x446fd0[_0x4bf8('0x45')]=_0x5aa05a;if(_0x36a029[_0x4bf8('0x37')][_0x4bf8('0x46')]){_0x5c7030[_0x4bf8('0x47')]=[{'all':!![]}];}return db[_0x4bf8('0x30')][_0x4bf8('0x48')](_0x5c7030);})['then'](function(_0x1a49b9){_0x446fd0['rows']=_0x1a49b9;return _0x446fd0;})['then'](respondWithFilteredResult(_0x58d402,_0x5c7030))[_0x4bf8('0x49')](handleError(_0x58d402,null));};exports[_0x4bf8('0x4a')]=function(_0x384b8b,_0x39308d){var _0x25a8ae={'raw':![],'where':{'id':_0x384b8b[_0x4bf8('0x4b')]['id']}},_0x409c8a={};_0x409c8a[_0x4bf8('0x35')]=_[_0x4bf8('0x4c')](db[_0x4bf8('0x30')]['rawAttributes']);_0x409c8a[_0x4bf8('0x37')]=_[_0x4bf8('0x4c')](_0x384b8b[_0x4bf8('0x37')]);_0x409c8a[_0x4bf8('0x38')]=_[_0x4bf8('0x39')](_0x409c8a[_0x4bf8('0x35')],_0x409c8a[_0x4bf8('0x37')]);_0x25a8ae['attributes']=_['intersection'](_0x409c8a[_0x4bf8('0x35')],qs[_0x4bf8('0x3b')](_0x384b8b['query'][_0x4bf8('0x3b')]));_0x25a8ae[_0x4bf8('0x3a')]=_0x25a8ae[_0x4bf8('0x3a')][_0x4bf8('0x3c')]?_0x25a8ae[_0x4bf8('0x3a')]:_0x409c8a['model'];if(_0x384b8b[_0x4bf8('0x37')][_0x4bf8('0x46')]){_0x25a8ae[_0x4bf8('0x47')]=[{'all':!![]}];}_0x25a8ae=_[_0x4bf8('0x42')]({},_0x25a8ae,_0x384b8b[_0x4bf8('0x44')]);return db['CmList']['find'](_0x25a8ae)[_0x4bf8('0x27')](handleEntityNotFound(_0x39308d,null))[_0x4bf8('0x27')](respondWithResult(_0x39308d,null))[_0x4bf8('0x49')](handleError(_0x39308d,null));};exports[_0x4bf8('0x4d')]=function(_0x59e730,_0x15edf1){return db[_0x4bf8('0x30')][_0x4bf8('0x4d')](_0x59e730[_0x4bf8('0x4e')],{})['then'](function(_0x43d728){var _0x4eb636=_0x59e730['user'][_0x4bf8('0x29')]({'plain':!![]});if(!_0x4eb636)throw new Error(_0x4bf8('0x4f'));if(_0x4eb636['role']==='user'){var _0x380cee=_0x43d728[_0x4bf8('0x29')]({'plain':!![]});var _0x28f029=_0x4bf8('0x2a');return db[_0x4bf8('0x50')][_0x4bf8('0x51')]({'where':{'name':_0x28f029,'userProfileId':_0x4eb636[_0x4bf8('0x52')]},'raw':!![]})[_0x4bf8('0x27')](function(_0xaeb573){if(_0xaeb573&&_0xaeb573[_0x4bf8('0x53')]===0x0){return db[_0x4bf8('0x2b')][_0x4bf8('0x4d')]({'name':_0x380cee[_0x4bf8('0x2e')],'resourceId':_0x380cee['id'],'type':_0xaeb573[_0x4bf8('0x2e')],'sectionId':_0xaeb573['id']},{})[_0x4bf8('0x27')](function(){return _0x43d728;});}else{return _0x43d728;}})[_0x4bf8('0x49')](function(_0x2386a3){logger['error'](_0x4bf8('0x54'),_0x2386a3);throw _0x2386a3;});}return _0x43d728;})[_0x4bf8('0x27')](respondWithResult(_0x15edf1,0xc9))[_0x4bf8('0x49')](handleError(_0x15edf1,null));};exports['update']=function(_0x4cc260,_0x26b857){if(_0x4cc260[_0x4bf8('0x4e')]['id']){delete _0x4cc260[_0x4bf8('0x4e')]['id'];}return db['CmList']['find']({'where':{'id':_0x4cc260[_0x4bf8('0x4b')]['id']}})[_0x4bf8('0x27')](handleEntityNotFound(_0x26b857,null))[_0x4bf8('0x27')](saveUpdates(_0x4cc260['body'],null))[_0x4bf8('0x27')](respondWithResult(_0x26b857,null))[_0x4bf8('0x49')](handleError(_0x26b857,null));};exports[_0x4bf8('0x28')]=function(_0x38d0e2,_0x40eb51){return db[_0x4bf8('0x30')][_0x4bf8('0x51')]({'where':{'id':_0x38d0e2[_0x4bf8('0x4b')]['id']}})[_0x4bf8('0x27')](handleEntityNotFound(_0x40eb51,null))[_0x4bf8('0x27')](removeEntity(_0x40eb51,null))[_0x4bf8('0x49')](handleError(_0x40eb51,null));};exports[_0x4bf8('0x55')]=function(_0xf71a75,_0x56f4c4){return db['CmList'][_0x4bf8('0x55')]()[_0x4bf8('0x27')](respondWithResult(_0x56f4c4,null))[_0x4bf8('0x49')](handleError(_0x56f4c4,null));};exports[_0x4bf8('0x56')]=function(_0x2eb81a,_0x7f7280,_0x5bedd5){if(_0x2eb81a[_0x4bf8('0x4e')]['id']){delete _0x2eb81a[_0x4bf8('0x4e')]['id'];}return db[_0x4bf8('0x30')][_0x4bf8('0x51')]({'where':{'id':_0x2eb81a['params']['id']}})[_0x4bf8('0x27')](handleEntityNotFound(_0x7f7280,null))[_0x4bf8('0x27')](function(_0x45bf48){if(_0x45bf48){_0x2eb81a[_0x4bf8('0x4e')][_0x4bf8('0x57')]=_0x45bf48['id'];return db[_0x4bf8('0x58')][_0x4bf8('0x4d')](_0x2eb81a['body']);}})[_0x4bf8('0x27')](respondWithResult(_0x7f7280,null))['catch'](handleError(_0x7f7280,null));};exports[_0x4bf8('0x59')]=function(_0x1bd655,_0x3d7fdb,_0x281cbc){var _0x4a4ae4={'raw':![],'where':{}};var _0x1f0b8c={};var _0x5c7a9d={'count':0x0,'rows':[]};return db['CmList'][_0x4bf8('0x5a')]({'where':{'id':_0x1bd655[_0x4bf8('0x4b')]['id']}})[_0x4bf8('0x27')](handleEntityNotFound(_0x3d7fdb,null))['then'](function(_0x2a1c3a){if(_0x2a1c3a){_0x1f0b8c[_0x4bf8('0x35')]=_['keys'](db[_0x4bf8('0x58')][_0x4bf8('0x31')]);_0x1f0b8c[_0x4bf8('0x37')]=_[_0x4bf8('0x4c')](_0x1bd655['query']);_0x1f0b8c[_0x4bf8('0x38')]=_['intersection'](_0x1f0b8c[_0x4bf8('0x35')],_0x1f0b8c[_0x4bf8('0x37')]);_0x4a4ae4[_0x4bf8('0x3a')]=_[_0x4bf8('0x39')](_0x1f0b8c[_0x4bf8('0x35')],qs[_0x4bf8('0x3b')](_0x1bd655[_0x4bf8('0x37')][_0x4bf8('0x3b')]));_0x4a4ae4['attributes']=_0x4a4ae4[_0x4bf8('0x3a')][_0x4bf8('0x3c')]?_0x4a4ae4[_0x4bf8('0x3a')]:_0x1f0b8c['model'];if(!_0x1bd655[_0x4bf8('0x37')]['hasOwnProperty']('nolimit')){_0x4a4ae4[_0x4bf8('0x20')]=qs[_0x4bf8('0x20')](_0x1bd655[_0x4bf8('0x37')][_0x4bf8('0x20')]);_0x4a4ae4[_0x4bf8('0x1e')]=qs[_0x4bf8('0x1e')](_0x1bd655[_0x4bf8('0x37')]['offset']);}_0x4a4ae4[_0x4bf8('0x5b')]=qs[_0x4bf8('0x3f')](_0x1bd655[_0x4bf8('0x37')][_0x4bf8('0x3f')]);_0x4a4ae4[_0x4bf8('0x40')]=qs[_0x4bf8('0x38')](_[_0x4bf8('0x41')](_0x1bd655[_0x4bf8('0x37')],_0x1f0b8c[_0x4bf8('0x38')]));_0x4a4ae4[_0x4bf8('0x40')][_0x4bf8('0x57')]=_0x2a1c3a['id'];if(_0x1bd655[_0x4bf8('0x37')][_0x4bf8('0x43')]){_0x4a4ae4[_0x4bf8('0x40')]=_[_0x4bf8('0x42')](_0x4a4ae4[_0x4bf8('0x40')],{'$or':_['map'](_0x4a4ae4[_0x4bf8('0x3a')],function(_0x4a9284){var _0x224bd5={};_0x224bd5[_0x4a9284]={'$like':'%'+_0x1bd655[_0x4bf8('0x37')][_0x4bf8('0x43')]+'%'};return _0x224bd5;})});}_0x4a4ae4=_[_0x4bf8('0x42')]({},_0x4a4ae4,_0x1bd655[_0x4bf8('0x44')]);return db[_0x4bf8('0x58')][_0x4bf8('0x45')]({'where':_0x4a4ae4[_0x4bf8('0x40')]})[_0x4bf8('0x27')](function(_0x1692db){_0x5c7a9d[_0x4bf8('0x45')]=_0x1692db;if(_0x1bd655[_0x4bf8('0x37')]['includeAll']){_0x4a4ae4[_0x4bf8('0x47')]=[{'all':!![]}];}return db[_0x4bf8('0x58')][_0x4bf8('0x48')](_0x4a4ae4);})[_0x4bf8('0x27')](function(_0x3b2fbf){_0x5c7a9d[_0x4bf8('0x5c')]=_0x3b2fbf;return _0x5c7a9d;});}})['then'](respondWithFilteredResult(_0x3d7fdb,_0x4a4ae4))[_0x4bf8('0x49')](handleError(_0x3d7fdb,null));};exports['removeDispositions']=function(_0x46439e,_0xf798f7,_0x2a2719){return db[_0x4bf8('0x30')][_0x4bf8('0x51')]({'where':{'id':_0x46439e[_0x4bf8('0x4b')]['id']}})[_0x4bf8('0x27')](handleEntityNotFound(_0xf798f7,null))[_0x4bf8('0x27')](function(_0x23b3a0){if(_0x23b3a0){return _0x23b3a0[_0x4bf8('0x5d')](_0x46439e[_0x4bf8('0x37')]['ids']);}})[_0x4bf8('0x27')](respondWithStatusCode(_0xf798f7,null))[_0x4bf8('0x49')](handleError(_0xf798f7,null));};exports[_0x4bf8('0x5e')]=function(_0x200a50,_0x4d2a83,_0x5421e5){return db[_0x4bf8('0x30')][_0x4bf8('0x51')]({'where':{'id':_0x200a50[_0x4bf8('0x4b')]['id']}})[_0x4bf8('0x27')](handleEntityNotFound(_0x4d2a83,null))[_0x4bf8('0x27')](function(_0x1f1e82){if(_0x1f1e82){var _0x31e335=[];var _0x13dfb0={'success':[],'errors':[]};return db[_0x4bf8('0x5f')][_0x4bf8('0x55')]()[_0x4bf8('0x27')](function(_0x150aaa){if(_0x200a50[_0x4bf8('0x4e')][_0x4bf8('0x60')]&&_[_0x4bf8('0x61')](_0x200a50['body']['tags'])){if(_0x200a50[_0x4bf8('0x4e')]['tags'][_0x4bf8('0x3c')]){_0x200a50[_0x4bf8('0x4e')][_0x4bf8('0x60')]=_0x200a50[_0x4bf8('0x4e')][_0x4bf8('0x60')][_0x4bf8('0x62')](';')+';';}else{_0x200a50[_0x4bf8('0x4e')][_0x4bf8('0x60')]=null;}}else{_0x200a50['body']['tags']=null;}if(_0x200a50[_0x4bf8('0x4e')]&&_[_0x4bf8('0x61')](_0x200a50['body'])){for(var _0x4dd5c8=0x0;_0x4dd5c8<_0x200a50[_0x4bf8('0x4e')]['length'];_0x4dd5c8+=0x1){_0x200a50[_0x4bf8('0x4e')][_0x4dd5c8][_0x4bf8('0x57')]=_0x200a50['params']['id'];_0x31e335[_0x4bf8('0x63')](_0x200a50[_0x4bf8('0x4e')][_0x4dd5c8]);}return BPromise[_0x4bf8('0x64')](_0x31e335,function(_0xf825f){return db[_0x4bf8('0x5f')][_0x4bf8('0x4d')](_['omit'](_0xf825f,[_0x4bf8('0x65'),'id'])||{},{'fields':_['keys'](_0x150aaa),'raw':!![]})['then'](function(_0xdfc008){_0x13dfb0[_0x4bf8('0x66')]['push'](_0xdfc008['dataValues']);})[_0x4bf8('0x49')](function(_0x31caf2){_0x13dfb0[_0x4bf8('0x67')][_0x4bf8('0x63')]({'data':_0xf825f,'error':_0x31caf2['message']});});})[_0x4bf8('0x27')](function(_0x1cdea4){return _0x13dfb0;})['catch'](function(_0x4c5cd4){return _0x4c5cd4;});}else{_0x4d2a83[_0x4bf8('0x1c')](0x190)[_0x4bf8('0x22')]({'message':_0x4bf8('0x68')});}});}})[_0x4bf8('0x27')](respondWithResult(_0x4d2a83,null))[_0x4bf8('0x49')](handleError(_0x4d2a83,null));};exports[_0x4bf8('0x69')]=function(_0x4981ea,_0x38259c,_0x2eee4d){var _0x29f169;return db[_0x4bf8('0x30')]['find']({'where':{'id':_0x4981ea['params']['id']},'include':[{'model':db[_0x4bf8('0x6a')],'as':_0x4bf8('0x6b')}]})[_0x4bf8('0x27')](handleEntityNotFound(_0x38259c,null))[_0x4bf8('0x27')](function(_0x4af260){if(_0x4af260){_0x29f169=_0x4af260;return db[_0x4bf8('0x5f')][_0x4bf8('0x31')];}})['then'](function(_0x4857e9){if(_0x4857e9){var _0x4ddebc={};var _0x5c41dc={};_0x5c41dc[_0x4bf8('0x35')]=_[_0x4bf8('0x6c')](_[_0x4bf8('0x4c')](_0x4857e9),_[_0x4bf8('0x36')](_0x29f169[_0x4bf8('0x6b')],function(_0x1b9c3c){return util['format'](_0x4bf8('0x6d'),_0x1b9c3c['id']);}));_0x5c41dc[_0x4bf8('0x37')]=_[_0x4bf8('0x4c')](_0x4981ea[_0x4bf8('0x37')]);_0x5c41dc[_0x4bf8('0x38')]=_['intersection'](_0x5c41dc[_0x4bf8('0x35')],_0x5c41dc[_0x4bf8('0x37')]);_0x4ddebc[_0x4bf8('0x3a')]=_[_0x4bf8('0x39')](_0x5c41dc[_0x4bf8('0x35')],qs[_0x4bf8('0x3b')](_0x4981ea[_0x4bf8('0x37')][_0x4bf8('0x3b')]));_0x4ddebc[_0x4bf8('0x3a')]=_0x4ddebc[_0x4bf8('0x3a')][_0x4bf8('0x3c')]?_0x4ddebc['attributes']:_0x5c41dc[_0x4bf8('0x35')];if(!_0x4981ea[_0x4bf8('0x37')][_0x4bf8('0x3d')](_0x4bf8('0x3e'))){_0x4ddebc[_0x4bf8('0x20')]=qs[_0x4bf8('0x20')](_0x4981ea['query'][_0x4bf8('0x20')]);_0x4ddebc[_0x4bf8('0x1e')]=qs[_0x4bf8('0x1e')](_0x4981ea[_0x4bf8('0x37')][_0x4bf8('0x1e')]);}_0x4ddebc[_0x4bf8('0x5b')]=qs[_0x4bf8('0x3f')](_0x4981ea[_0x4bf8('0x37')][_0x4bf8('0x3f')]);_0x4ddebc[_0x4bf8('0x40')]=qs['filters'](_[_0x4bf8('0x41')](_0x4981ea[_0x4bf8('0x37')],_0x5c41dc[_0x4bf8('0x38')]));_0x4ddebc['raw']=!![];if(_0x4981ea[_0x4bf8('0x37')][_0x4bf8('0x43')]){_0x4ddebc[_0x4bf8('0x40')]=_[_0x4bf8('0x42')](_0x4ddebc[_0x4bf8('0x40')],{'$or':_['map'](_0x4ddebc[_0x4bf8('0x3a')],function(_0x3054cf){var _0x529ec0={};_0x529ec0[_0x3054cf]={'$like':'%'+_0x4981ea[_0x4bf8('0x37')][_0x4bf8('0x43')]+'%'};return _0x529ec0;})});}_0x4ddebc=_[_0x4bf8('0x42')]({},_0x4ddebc,_0x4981ea[_0x4bf8('0x44')]);return _0x29f169['getContacts'](_0x4ddebc);}})[_0x4bf8('0x27')](respondWithResult(_0x38259c,null))[_0x4bf8('0x49')](handleError(_0x38259c,null));};exports['getContactsCsv']=function(_0x1dbc75,_0x4eb694,_0x25d01b){var _0x3bafb0;var _0x277b84;var _0x28c5e3;var _0x13d3bd=_0x1dbc75[_0x4bf8('0x4b')]['id'];csv_results=[];return db[_0x4bf8('0x6e')][_0x4bf8('0x48')]({'attributes':['id',_0x4bf8('0x2e')],'raw':!![],'order':['OrderBy']})[_0x4bf8('0x27')](function(_0x1a429f){_0x3bafb0=_0x1a429f;var _0x25aeab=_['keys'](db[_0x4bf8('0x5f')][_0x4bf8('0x31')]);return db[_0x4bf8('0x6a')][_0x4bf8('0x48')]({'raw':!![],'attributes':['id','alias']})['then'](function(_0x545a70){_0x277b84=_0x545a70;var _0x3f34ac=squel[_0x4bf8('0x6f')]()['fields'](_0x25aeab)['from'](_0x4bf8('0x70'),'c')['where'](_0x4bf8('0x71'),_0x13d3bd)[_0x4bf8('0x40')](_0x4bf8('0x72'))[_0x4bf8('0x73')]();for(var _0x3af201=0x0;_0x3af201<_0x277b84[_0x4bf8('0x3c')];_0x3af201++){_0x3f34ac['field'](_0x4bf8('0x74')+_0x277b84[_0x3af201]['id'],_0x4bf8('0x75')+_0x277b84[_0x3af201][_0x4bf8('0x76')]);}for(var _0x3af201=0x0;_0x3af201<_0x3bafb0[_0x4bf8('0x3c')];_0x3af201++){_0x3f34ac[_0x4bf8('0x77')](squel[_0x4bf8('0x6f')]()[_0x4bf8('0x77')](_0x4bf8('0x78'))['from'](_0x4bf8('0x79'))[_0x4bf8('0x40')](_0x4bf8('0x7a'),_0x3bafb0[_0x3af201]['id'])[_0x4bf8('0x40')]('CmContactId\x20=\x20c.id'),_0x4bf8('0x7b')+_0x3bafb0[_0x3af201][_0x4bf8('0x2e')]);_0x3f34ac[_0x4bf8('0x77')](squel[_0x4bf8('0x6f')]()[_0x4bf8('0x77')](_0x4bf8('0x7c'))[_0x4bf8('0x7d')](_0x4bf8('0x79'))[_0x4bf8('0x40')]('ItemTypeId\x20=\x20?',_0x3bafb0[_0x3af201]['id'])[_0x4bf8('0x40')](_0x4bf8('0x7e')),_0x4bf8('0x7f')+_0x3bafb0[_0x3af201][_0x4bf8('0x2e')]);}var _0x1090d0=[];_0x1090d0[_0x4bf8('0x63')](_0x3f34ac[_0x4bf8('0x80')]());BPromise[_0x4bf8('0x64')](_0x1090d0,handleQuery)[_0x4bf8('0x27')](function(_0x57911f){handleQuery(_0x3f34ac[_0x4bf8('0x80')]());var _0x12f9c0=csv_results[0x0];if(!_[_0x4bf8('0x81')](_0x12f9c0)){var _0x46795b=toCsv(_0x12f9c0);var _0x2142e3=Date[_0x4bf8('0x82')]();fs[_0x4bf8('0x83')](util[_0x4bf8('0x84')](_0x4bf8('0x85'),_0x13d3bd,_0x2142e3),_0x46795b);_0x4eb694[_0x4bf8('0x86')](_0x4bf8('0x87'),_0x4bf8('0x88')+util[_0x4bf8('0x84')]('list_%d_%s.csv',_0x13d3bd,_0x2142e3));_0x4eb694['setHeader'](_0x4bf8('0x89'),_0x4bf8('0x8a'));return _0x4eb694['download'](util[_0x4bf8('0x84')](_0x4bf8('0x85'),_0x13d3bd,_0x2142e3));}else{return _0x4eb694[_0x4bf8('0x1b')](0xcc);}});});});};exports['addCustomField']=function(_0x53958b,_0x5ea51d,_0x3270d6){var _0x3b9bae;delete _0x53958b[_0x4bf8('0x4e')]['id'];return db[_0x4bf8('0x30')][_0x4bf8('0x5a')]({'where':{'id':_0x53958b[_0x4bf8('0x4b')]['id']}})[_0x4bf8('0x27')](handleEntityNotFound(_0x5ea51d,null))[_0x4bf8('0x27')](function(_0x5ac9fb){if(_0x5ac9fb){return db[_0x4bf8('0x8b')][_0x4bf8('0x8c')](function(_0x270309){return db[_0x4bf8('0x6a')][_0x4bf8('0x4d')](_0x53958b['body'],{'transaction':_0x270309})[_0x4bf8('0x27')](function(_0x345c39){_0x3b9bae=_0x345c39;return _0x5ac9fb[_0x4bf8('0x8d')](_0x345c39,{'transaction':_0x270309});})[_0x4bf8('0x27')](function(){var _0x5eb608={'type':db[_0x4bf8('0x8e')][_0x4bf8('0x8f')],'transaction':_0x270309};switch(_0x53958b[_0x4bf8('0x4e')]['type']){case _0x4bf8('0x90'):_0x5eb608[_0x4bf8('0x33')]=db[_0x4bf8('0x8e')][_0x4bf8('0x8f')];break;case'number':_0x5eb608[_0x4bf8('0x33')]=db[_0x4bf8('0x8e')][_0x4bf8('0x91')];break;case _0x4bf8('0x92'):_0x5eb608[_0x4bf8('0x33')]=db[_0x4bf8('0x8e')][_0x4bf8('0x93')];_0x5eb608['defaultValue']=![];break;default:}return db[_0x4bf8('0x8b')][_0x4bf8('0x94')][_0x4bf8('0x95')]('cm_contacts',util['format'](_0x4bf8('0x96'),_0x3b9bae['id']),_0x5eb608);})[_0x4bf8('0x27')](function(){return _0x3b9bae;});});}})['then'](respondWithResult(_0x5ea51d,null))[_0x4bf8('0x49')](handleError(_0x5ea51d,null));};exports[_0x4bf8('0x97')]=function(_0x49aca5,_0x1908bc,_0x571789){var _0x5a9e73={};var _0x5bebeb={};var _0x13d504;var _0x4309d8;return db[_0x4bf8('0x30')]['findOne']({'where':{'id':_0x49aca5[_0x4bf8('0x4b')]['id']}})['then'](handleEntityNotFound(_0x1908bc,null))['then'](function(_0x2fd53f){if(_0x2fd53f){_0x13d504=_0x2fd53f;_0x5bebeb[_0x4bf8('0x35')]=_['keys'](db[_0x4bf8('0x6a')][_0x4bf8('0x31')]);_0x5bebeb['query']=_['keys'](_0x49aca5[_0x4bf8('0x37')]);_0x5bebeb[_0x4bf8('0x38')]=_[_0x4bf8('0x39')](_0x5bebeb[_0x4bf8('0x35')],_0x5bebeb['query']);_0x5a9e73[_0x4bf8('0x3a')]=_[_0x4bf8('0x39')](_0x5bebeb[_0x4bf8('0x35')],qs[_0x4bf8('0x3b')](_0x49aca5[_0x4bf8('0x37')][_0x4bf8('0x3b')]));_0x5a9e73['attributes']=_0x5a9e73[_0x4bf8('0x3a')][_0x4bf8('0x3c')]?_0x5a9e73['attributes']:_0x5bebeb[_0x4bf8('0x35')];_0x5a9e73[_0x4bf8('0x5b')]=qs['sort'](_0x49aca5['query'][_0x4bf8('0x3f')]);_0x5a9e73[_0x4bf8('0x40')]=qs[_0x4bf8('0x38')](_[_0x4bf8('0x41')](_0x49aca5[_0x4bf8('0x37')],_0x5bebeb[_0x4bf8('0x38')]));_0x5a9e73[_0x4bf8('0x40')]=_['merge'](_0x5a9e73[_0x4bf8('0x40')],{'$or':[{'ListId':_0x2fd53f['id']},{'ListId':null}]});if(_0x49aca5[_0x4bf8('0x37')][_0x4bf8('0x43')]){_0x5a9e73['where']=_[_0x4bf8('0x42')](_0x5a9e73[_0x4bf8('0x40')],{'$or':_[_0x4bf8('0x36')](_0x5a9e73['attributes'],function(_0x235eee){var _0x2c9d1b={};_0x2c9d1b[_0x235eee]={'$like':'%'+_0x49aca5['query'][_0x4bf8('0x43')]+'%'};return _0x2c9d1b;})});}_0x5a9e73=_[_0x4bf8('0x42')]({},_0x5a9e73,_0x49aca5[_0x4bf8('0x44')]);return db[_0x4bf8('0x6a')]['findAndCountAll'](_0x5a9e73);}})[_0x4bf8('0x27')](respondWithResult(_0x1908bc,null))[_0x4bf8('0x49')](handleError(_0x1908bc,null));};exports[_0x4bf8('0x98')]=function(_0x95e88a,_0x4e4006){return db['CmCustomField']['findAndCountAll']({'where':{'ListId':null}})['then'](handleEntityNotFound(_0x4e4006,null))[_0x4bf8('0x27')](function(_0x3d2346){return _0x3d2346;})[_0x4bf8('0x27')](respondWithResult(_0x4e4006,null))[_0x4bf8('0x49')](handleError(_0x4e4006,null));};exports['addAgents']=function(_0x12a414,_0x3d129c,_0x1e227f){return db[_0x4bf8('0x30')][_0x4bf8('0x51')]({'where':{'id':_0x12a414[_0x4bf8('0x4b')]['id']}})['then'](handleEntityNotFound(_0x3d129c,null))[_0x4bf8('0x27')](function(_0x1894ae){if(_0x1894ae){return _0x1894ae[_0x4bf8('0x99')](_0x12a414['body']['ids'],_[_0x4bf8('0x9a')](_0x12a414[_0x4bf8('0x4e')],[_0x4bf8('0x65'),'id'])||{})[_0x4bf8('0x9b')](function(_0x2530f9){for(var _0x6e200d=0x0;_0x6e200d<_0x12a414[_0x4bf8('0x4e')][_0x4bf8('0x65')][_0x4bf8('0x3c')];_0x6e200d+=0x1){socket[_0x4bf8('0x9c')](_0x4bf8('0x9d'),{'UserId':Number(_0x12a414[_0x4bf8('0x4e')]['ids'][_0x6e200d]),'CmListId':Number(_0x12a414['params']['id'])});}return _0x2530f9;});}})[_0x4bf8('0x27')](respondWithResult(_0x3d129c,null))['catch'](handleError(_0x3d129c,null));};exports[_0x4bf8('0x9e')]=function(_0x5e8fce,_0x2c0887,_0x4d0759){return db['CmList'][_0x4bf8('0x51')]({'where':{'id':_0x5e8fce[_0x4bf8('0x4b')]['id']}})[_0x4bf8('0x27')](handleEntityNotFound(_0x2c0887,null))['then'](function(_0x5d9c78){if(_0x5d9c78){return _0x5d9c78['removeAgents'](_0x5e8fce[_0x4bf8('0x37')][_0x4bf8('0x65')])[_0x4bf8('0x27')](function(){if(_['isArray'](_0x5e8fce[_0x4bf8('0x37')]['ids'])){for(var _0x4e2040=0x0;_0x4e2040<_0x5e8fce[_0x4bf8('0x37')][_0x4bf8('0x65')][_0x4bf8('0x3c')];_0x4e2040+=0x1){socket[_0x4bf8('0x9c')](_0x4bf8('0x9f'),{'UserId':Number(_0x5e8fce[_0x4bf8('0x37')][_0x4bf8('0x65')][_0x4e2040]),'CmListId':Number(_0x5e8fce[_0x4bf8('0x4b')]['id'])});}}else{socket[_0x4bf8('0x9c')](_0x4bf8('0x9f'),{'UserId':Number(_0x5e8fce['query'][_0x4bf8('0x65')]),'CmListId':Number(_0x5e8fce[_0x4bf8('0x4b')]['id'])});}});}})[_0x4bf8('0x27')](respondWithStatusCode(_0x2c0887,null))[_0x4bf8('0x49')](handleError(_0x2c0887,null));};exports['getAgents']=function(_0x29ba4b,_0x5e4ef5,_0x3e3c4f){var _0x26cc3f={};var _0x4774dd={};var _0x37494a;var _0xcd3add;return db[_0x4bf8('0x30')][_0x4bf8('0x5a')]({'where':{'id':_0x29ba4b[_0x4bf8('0x4b')]['id']}})[_0x4bf8('0x27')](handleEntityNotFound(_0x5e4ef5,null))[_0x4bf8('0x27')](function(_0x26df07){if(_0x26df07){_0x37494a=_0x26df07;_0x4774dd[_0x4bf8('0x35')]=_['keys'](db['User'][_0x4bf8('0x31')]);_0x4774dd[_0x4bf8('0x37')]=_['keys'](_0x29ba4b[_0x4bf8('0x37')]);_0x4774dd['filters']=_[_0x4bf8('0x39')](_0x4774dd[_0x4bf8('0x35')],_0x4774dd[_0x4bf8('0x37')]);_0x26cc3f[_0x4bf8('0x3a')]=_[_0x4bf8('0x39')](_0x4774dd[_0x4bf8('0x35')],qs[_0x4bf8('0x3b')](_0x29ba4b[_0x4bf8('0x37')][_0x4bf8('0x3b')]));_0x26cc3f[_0x4bf8('0x3a')]=_0x26cc3f[_0x4bf8('0x3a')]['length']?_0x26cc3f[_0x4bf8('0x3a')]:_0x4774dd[_0x4bf8('0x35')];_0x26cc3f[_0x4bf8('0x5b')]=qs['sort'](_0x29ba4b['query'][_0x4bf8('0x3f')]);_0x26cc3f['where']=qs['filters'](_[_0x4bf8('0x41')](_0x29ba4b[_0x4bf8('0x37')],_0x4774dd['filters']));if(_0x29ba4b['query'][_0x4bf8('0x43')]){_0x26cc3f['where']=_[_0x4bf8('0x42')](_0x26cc3f[_0x4bf8('0x40')],{'$or':_[_0x4bf8('0x36')](_0x26cc3f['attributes'],function(_0xdafbc8){var _0x1c7890={};_0x1c7890[_0xdafbc8]={'$like':'%'+_0x29ba4b[_0x4bf8('0x37')][_0x4bf8('0x43')]+'%'};return _0x1c7890;})});}_0x26cc3f=_['merge']({},_0x26cc3f,_0x29ba4b[_0x4bf8('0x44')]);return _0x37494a[_0x4bf8('0xa0')](_0x26cc3f);}})['then'](function(_0x2264d8){if(_0x2264d8){_0xcd3add=_0x2264d8[_0x4bf8('0x3c')];if(!_0x29ba4b['query'][_0x4bf8('0x3d')](_0x4bf8('0x3e'))){_0x26cc3f[_0x4bf8('0x20')]=qs[_0x4bf8('0x20')](_0x29ba4b[_0x4bf8('0x37')][_0x4bf8('0x20')]);_0x26cc3f[_0x4bf8('0x1e')]=qs[_0x4bf8('0x1e')](_0x29ba4b[_0x4bf8('0x37')][_0x4bf8('0x1e')]);}return _0x37494a[_0x4bf8('0xa0')](_0x26cc3f);}})[_0x4bf8('0x27')](function(_0x21a5a8){if(_0x21a5a8){return _0x21a5a8?{'count':_0xcd3add,'rows':_0x21a5a8}:null;}})[_0x4bf8('0x27')](respondWithResult(_0x5e4ef5,null))[_0x4bf8('0x49')](handleError(_0x5e4ef5,null));};function handleQuery(_0x54b886){logger[_0x4bf8('0xa1')](_0x54b886);return db[_0x4bf8('0x8b')][_0x4bf8('0x37')](_0x54b886)['spread'](function(_0x3d29b5){csv_results[_0x4bf8('0x63')](_0x3d29b5);})['catch'](function(_0x283c4e){logger[_0x4bf8('0x2c')](_0x283c4e[_0x4bf8('0xa2')]);});}
\ No newline at end of file