Built motion from commit 85328c08.|2.5.50
[motion2.git] / server / api / cmList / cmList.controller.js
index b6a3f5f..ca4a07d 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x4a21=['CmContact','tags','isArray','join','each','omit','success','push','Malformed\x20request\x20syntax','getContacts','CmCustomField','CustomFields','concat','cf_%d','raw','getContactsCsv','format','isEmpty','now','writeFileSync','/tmp/list_%d_%s.csv','setHeader','Content-disposition','attachment;\x20filename=','list_%d_%s.csv','text/csv','download','sequelize','transaction','addCustomFields','Sequelize','TEXT','text','INTEGER','switch','BOOLEAN','defaultValue','queryInterface','addColumn','cm_contacts','getCustomFields','findAndCountAll','addAgents','spread','userCmList:save','removeAgents','emit','userCmList:remove','getAgents','User','html-pdf','eml-format','zip-dir','fast-json-patch','moment','bluebird','mustache','util','path','squel','crypto','jsforce','to-csv','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','redis','localhost','socket.io-emitter','./cmList.socket','register','sendStatus','status','end','count','offset','limit','set','Content-Range','json','apply','save','update','then','destroy','get','Lists','UserProfileResource','stack','name','send','index','map','CmList','rawAttributes','fieldName','type','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','sort','where','filter','merge','includeAll','include','findAll','rows','catch','show','options','find','create','body','user','role','userProfileId','autoAssociation','error','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','params','describe','addDisposition','ListId','Disposition','getDispositions','findOne','order','pick','removeDispositions','ids','addContacts'];(function(_0x3f143b,_0x37217a){var _0x257751=function(_0x92a303){while(--_0x92a303){_0x3f143b['push'](_0x3f143b['shift']());}};_0x257751(++_0x37217a);}(_0x4a21,0xc2));var _0x14a2=function(_0x31b31b,_0x5f044e){_0x31b31b=_0x31b31b-0x0;var _0x2c8fc2=_0x4a21[_0x31b31b];return _0x2c8fc2;};'use strict';var pdf=require(_0x14a2('0x0'));var emlformat=require(_0x14a2('0x1'));var rimraf=require('rimraf');var zipdir=require(_0x14a2('0x2'));var jsonpatch=require(_0x14a2('0x3'));var rp=require('request-promise');var moment=require(_0x14a2('0x4'));var BPromise=require(_0x14a2('0x5'));var Mustache=require(_0x14a2('0x6'));var util=require(_0x14a2('0x7'));var path=require(_0x14a2('0x8'));var sox=require('sox');var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var _=require('lodash');var squel=require(_0x14a2('0x9'));var crypto=require(_0x14a2('0xa'));var jsforce=require(_0x14a2('0xb'));var deskjs=require('desk.js');var toCsv=require(_0x14a2('0xc'));var querystring=require(_0x14a2('0xd'));var Papa=require(_0x14a2('0xe'));var Redis=require('ioredis');var authService=require(_0x14a2('0xf'));var qs=require(_0x14a2('0x10'));var as=require(_0x14a2('0x11'));var hardwareService=require(_0x14a2('0x12'));var logger=require(_0x14a2('0x13'))(_0x14a2('0x14'));var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require('../../mysqldb')['db'];config[_0x14a2('0x15')]=_['defaults'](config[_0x14a2('0x15')],{'host':_0x14a2('0x16'),'port':0x18eb});var socket=require(_0x14a2('0x17'))(new Redis(config['redis']));require(_0x14a2('0x18'))[_0x14a2('0x19')](socket);function respondWithStatusCode(_0x537e76,_0x754681){_0x754681=_0x754681||0xcc;return function(_0x19b335){if(_0x19b335){return _0x537e76[_0x14a2('0x1a')](_0x754681);}return _0x537e76[_0x14a2('0x1b')](_0x754681)[_0x14a2('0x1c')]();};}function respondWithResult(_0x41f19f,_0x15ce44){_0x15ce44=_0x15ce44||0xc8;return function(_0x20ab8c){if(_0x20ab8c){return _0x41f19f[_0x14a2('0x1b')](_0x15ce44)['json'](_0x20ab8c);}};}function respondWithFilteredResult(_0x3e6d85,_0xd94e3e){return function(_0x5c242f){if(_0x5c242f){var _0x58d5ea=_0x5c242f[_0x14a2('0x1d')],_0x235216=_0xd94e3e['offset'],_0x13b4c7=_0xd94e3e[_0x14a2('0x1e')]+_0xd94e3e[_0x14a2('0x1f')],_0x3a5cfa;if(_0x13b4c7>=_0x58d5ea){_0x13b4c7=_0x58d5ea;_0x3a5cfa=0xc8;}else{_0x3a5cfa=0xce;}_0x3e6d85[_0x14a2('0x1b')](_0x3a5cfa);return _0x3e6d85[_0x14a2('0x20')](_0x14a2('0x21'),_0x235216+'-'+_0x13b4c7+'/'+_0x58d5ea)[_0x14a2('0x22')](_0x5c242f);}return null;};}function patchUpdates(_0x19c8a7){return function(_0x5aba85){try{jsonpatch[_0x14a2('0x23')](_0x5aba85,_0x19c8a7,!![]);}catch(_0x1f9078){return BPromise['reject'](_0x1f9078);}return _0x5aba85[_0x14a2('0x24')]();};}function saveUpdates(_0x3c9792,_0x54dbe9){return function(_0x3f1454){if(_0x3f1454){return _0x3f1454[_0x14a2('0x25')](_0x3c9792)[_0x14a2('0x26')](function(_0x45885f){return _0x45885f;});}return null;};}function removeEntity(_0x37837b,_0x523d73){return function(_0x4865ac){if(_0x4865ac){return _0x4865ac[_0x14a2('0x27')]()[_0x14a2('0x26')](function(){var _0x3e7559=_0x4865ac[_0x14a2('0x28')]({'plain':!![]});var _0x9a6e98=_0x14a2('0x29');return db[_0x14a2('0x2a')][_0x14a2('0x27')]({'where':{'type':_0x9a6e98,'resourceId':_0x3e7559['id']}})['then'](function(){return _0x4865ac;});})['then'](function(){_0x37837b[_0x14a2('0x1b')](0xcc)[_0x14a2('0x1c')]();});}};}function handleEntityNotFound(_0x272d67,_0x415259){return function(_0x36a9b0){if(!_0x36a9b0){_0x272d67[_0x14a2('0x1a')](0x194);}return _0x36a9b0;};}function handleError(_0x3a31d9,_0x2ae17f){_0x2ae17f=_0x2ae17f||0x1f4;return function(_0x568cbd){logger['error'](_0x568cbd[_0x14a2('0x2b')]);if(_0x568cbd[_0x14a2('0x2c')]){delete _0x568cbd[_0x14a2('0x2c')];}_0x3a31d9[_0x14a2('0x1b')](_0x2ae17f)[_0x14a2('0x2d')](_0x568cbd);};}exports[_0x14a2('0x2e')]=function(_0x3524ef,_0x1fc073){var _0x1d3bf0={},_0x18a746={},_0x268200={'count':0x0,'rows':[]};var _0x3dde25=_[_0x14a2('0x2f')](db[_0x14a2('0x30')][_0x14a2('0x31')],function(_0xd0f167){return{'name':_0xd0f167[_0x14a2('0x32')],'type':_0xd0f167[_0x14a2('0x33')]['key']};});_0x18a746[_0x14a2('0x34')]=_[_0x14a2('0x2f')](_0x3dde25,_0x14a2('0x2c'));_0x18a746[_0x14a2('0x35')]=_[_0x14a2('0x36')](_0x3524ef[_0x14a2('0x35')]);_0x18a746[_0x14a2('0x37')]=_[_0x14a2('0x38')](_0x18a746[_0x14a2('0x34')],_0x18a746[_0x14a2('0x35')]);_0x1d3bf0[_0x14a2('0x39')]=_[_0x14a2('0x38')](_0x18a746[_0x14a2('0x34')],qs['fields'](_0x3524ef[_0x14a2('0x35')][_0x14a2('0x3a')]));_0x1d3bf0['attributes']=_0x1d3bf0['attributes'][_0x14a2('0x3b')]?_0x1d3bf0[_0x14a2('0x39')]:_0x18a746[_0x14a2('0x34')];if(!_0x3524ef[_0x14a2('0x35')][_0x14a2('0x3c')](_0x14a2('0x3d'))){_0x1d3bf0[_0x14a2('0x1f')]=qs[_0x14a2('0x1f')](_0x3524ef[_0x14a2('0x35')][_0x14a2('0x1f')]);_0x1d3bf0[_0x14a2('0x1e')]=qs[_0x14a2('0x1e')](_0x3524ef[_0x14a2('0x35')][_0x14a2('0x1e')]);}_0x1d3bf0['order']=qs[_0x14a2('0x3e')](_0x3524ef[_0x14a2('0x35')][_0x14a2('0x3e')]);_0x1d3bf0[_0x14a2('0x3f')]=qs[_0x14a2('0x37')](_['pick'](_0x3524ef[_0x14a2('0x35')],_0x18a746[_0x14a2('0x37')]),_0x3dde25);if(_0x3524ef[_0x14a2('0x35')][_0x14a2('0x40')]){_0x1d3bf0[_0x14a2('0x3f')]=_[_0x14a2('0x41')](_0x1d3bf0[_0x14a2('0x3f')],{'$or':_[_0x14a2('0x2f')](_0x3dde25,function(_0x185a29){if(_0x185a29['type']!=='VIRTUAL'){var _0x263361={};_0x263361[_0x185a29['name']]={'$like':'%'+_0x3524ef[_0x14a2('0x35')][_0x14a2('0x40')]+'%'};return _0x263361;}})});}_0x1d3bf0=_[_0x14a2('0x41')]({},_0x1d3bf0,_0x3524ef['options']);var _0xcb5032={'where':_0x1d3bf0[_0x14a2('0x3f')]};return db[_0x14a2('0x30')][_0x14a2('0x1d')](_0xcb5032)[_0x14a2('0x26')](function(_0x4c1a6c){_0x268200['count']=_0x4c1a6c;if(_0x3524ef['query'][_0x14a2('0x42')]){_0x1d3bf0[_0x14a2('0x43')]=[{'all':!![]}];}return db[_0x14a2('0x30')][_0x14a2('0x44')](_0x1d3bf0);})[_0x14a2('0x26')](function(_0x3ca5c6){_0x268200[_0x14a2('0x45')]=_0x3ca5c6;return _0x268200;})['then'](respondWithFilteredResult(_0x1fc073,_0x1d3bf0))[_0x14a2('0x46')](handleError(_0x1fc073,null));};exports[_0x14a2('0x47')]=function(_0x29222e,_0x111625){var _0xb89b0f={'raw':![],'where':{'id':_0x29222e['params']['id']}},_0x2ad83b={};_0x2ad83b[_0x14a2('0x34')]=_['keys'](db[_0x14a2('0x30')][_0x14a2('0x31')]);_0x2ad83b[_0x14a2('0x35')]=_[_0x14a2('0x36')](_0x29222e[_0x14a2('0x35')]);_0x2ad83b['filters']=_[_0x14a2('0x38')](_0x2ad83b[_0x14a2('0x34')],_0x2ad83b['query']);_0xb89b0f[_0x14a2('0x39')]=_[_0x14a2('0x38')](_0x2ad83b[_0x14a2('0x34')],qs['fields'](_0x29222e[_0x14a2('0x35')][_0x14a2('0x3a')]));_0xb89b0f['attributes']=_0xb89b0f['attributes'][_0x14a2('0x3b')]?_0xb89b0f[_0x14a2('0x39')]:_0x2ad83b[_0x14a2('0x34')];if(_0x29222e[_0x14a2('0x35')][_0x14a2('0x42')]){_0xb89b0f[_0x14a2('0x43')]=[{'all':!![]}];}_0xb89b0f=_[_0x14a2('0x41')]({},_0xb89b0f,_0x29222e[_0x14a2('0x48')]);return db['CmList'][_0x14a2('0x49')](_0xb89b0f)['then'](handleEntityNotFound(_0x111625,null))['then'](respondWithResult(_0x111625,null))[_0x14a2('0x46')](handleError(_0x111625,null));};exports[_0x14a2('0x4a')]=function(_0x5b2472,_0x3e7297){return db['CmList'][_0x14a2('0x4a')](_0x5b2472[_0x14a2('0x4b')],{})[_0x14a2('0x26')](function(_0x2f6d35){var _0x5e76b3=_0x5b2472[_0x14a2('0x4c')]['get']({'plain':!![]});if(!_0x5e76b3)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x5e76b3[_0x14a2('0x4d')]===_0x14a2('0x4c')){var _0x44efdb=_0x2f6d35[_0x14a2('0x28')]({'plain':!![]});var _0x1ebdbf='Lists';return db['UserProfileSection'][_0x14a2('0x49')]({'where':{'name':_0x1ebdbf,'userProfileId':_0x5e76b3[_0x14a2('0x4e')]},'raw':!![]})['then'](function(_0x1aaf36){if(_0x1aaf36&&_0x1aaf36[_0x14a2('0x4f')]===0x0){return db['UserProfileResource'][_0x14a2('0x4a')]({'name':_0x44efdb[_0x14a2('0x2c')],'resourceId':_0x44efdb['id'],'type':_0x1aaf36[_0x14a2('0x2c')],'sectionId':_0x1aaf36['id']},{})[_0x14a2('0x26')](function(){return _0x2f6d35;});}else{return _0x2f6d35;}})[_0x14a2('0x46')](function(_0xb10568){logger[_0x14a2('0x50')](_0x14a2('0x51'),_0xb10568);throw _0xb10568;});}return _0x2f6d35;})['then'](respondWithResult(_0x3e7297,0xc9))[_0x14a2('0x46')](handleError(_0x3e7297,null));};exports[_0x14a2('0x25')]=function(_0x120ecf,_0x5d4a75){if(_0x120ecf[_0x14a2('0x4b')]['id']){delete _0x120ecf[_0x14a2('0x4b')]['id'];}return db[_0x14a2('0x30')]['find']({'where':{'id':_0x120ecf[_0x14a2('0x52')]['id']}})[_0x14a2('0x26')](handleEntityNotFound(_0x5d4a75,null))[_0x14a2('0x26')](saveUpdates(_0x120ecf[_0x14a2('0x4b')],null))[_0x14a2('0x26')](respondWithResult(_0x5d4a75,null))[_0x14a2('0x46')](handleError(_0x5d4a75,null));};exports[_0x14a2('0x27')]=function(_0x359122,_0x4e5782){return db[_0x14a2('0x30')][_0x14a2('0x49')]({'where':{'id':_0x359122['params']['id']}})[_0x14a2('0x26')](handleEntityNotFound(_0x4e5782,null))['then'](removeEntity(_0x4e5782,null))[_0x14a2('0x46')](handleError(_0x4e5782,null));};exports[_0x14a2('0x53')]=function(_0x42b420,_0x5a42bc){return db['CmList']['describe']()[_0x14a2('0x26')](respondWithResult(_0x5a42bc,null))['catch'](handleError(_0x5a42bc,null));};exports[_0x14a2('0x54')]=function(_0x5a7c82,_0x537259,_0x268a66){if(_0x5a7c82[_0x14a2('0x4b')]['id']){delete _0x5a7c82['body']['id'];}return db['CmList'][_0x14a2('0x49')]({'where':{'id':_0x5a7c82[_0x14a2('0x52')]['id']}})[_0x14a2('0x26')](handleEntityNotFound(_0x537259,null))[_0x14a2('0x26')](function(_0x447883){if(_0x447883){_0x5a7c82[_0x14a2('0x4b')][_0x14a2('0x55')]=_0x447883['id'];return db[_0x14a2('0x56')][_0x14a2('0x4a')](_0x5a7c82[_0x14a2('0x4b')]);}})[_0x14a2('0x26')](respondWithResult(_0x537259,null))[_0x14a2('0x46')](handleError(_0x537259,null));};exports[_0x14a2('0x57')]=function(_0x2f1bb6,_0x5d3734,_0x368ab3){var _0x4637ec={'raw':![],'where':{}};var _0x268022={};var _0x218960={'count':0x0,'rows':[]};return db[_0x14a2('0x30')][_0x14a2('0x58')]({'where':{'id':_0x2f1bb6['params']['id']}})['then'](handleEntityNotFound(_0x5d3734,null))[_0x14a2('0x26')](function(_0x5d37dd){if(_0x5d37dd){_0x268022[_0x14a2('0x34')]=_[_0x14a2('0x36')](db[_0x14a2('0x56')][_0x14a2('0x31')]);_0x268022['query']=_[_0x14a2('0x36')](_0x2f1bb6[_0x14a2('0x35')]);_0x268022[_0x14a2('0x37')]=_['intersection'](_0x268022[_0x14a2('0x34')],_0x268022[_0x14a2('0x35')]);_0x4637ec[_0x14a2('0x39')]=_['intersection'](_0x268022[_0x14a2('0x34')],qs['fields'](_0x2f1bb6[_0x14a2('0x35')][_0x14a2('0x3a')]));_0x4637ec[_0x14a2('0x39')]=_0x4637ec[_0x14a2('0x39')]['length']?_0x4637ec[_0x14a2('0x39')]:_0x268022[_0x14a2('0x34')];if(!_0x2f1bb6[_0x14a2('0x35')][_0x14a2('0x3c')]('nolimit')){_0x4637ec[_0x14a2('0x1f')]=qs[_0x14a2('0x1f')](_0x2f1bb6[_0x14a2('0x35')]['limit']);_0x4637ec[_0x14a2('0x1e')]=qs[_0x14a2('0x1e')](_0x2f1bb6[_0x14a2('0x35')][_0x14a2('0x1e')]);}_0x4637ec[_0x14a2('0x59')]=qs['sort'](_0x2f1bb6[_0x14a2('0x35')][_0x14a2('0x3e')]);_0x4637ec[_0x14a2('0x3f')]=qs['filters'](_[_0x14a2('0x5a')](_0x2f1bb6[_0x14a2('0x35')],_0x268022['filters']));_0x4637ec['where'][_0x14a2('0x55')]=_0x5d37dd['id'];if(_0x2f1bb6[_0x14a2('0x35')][_0x14a2('0x40')]){_0x4637ec[_0x14a2('0x3f')]=_['merge'](_0x4637ec['where'],{'$or':_[_0x14a2('0x2f')](_0x4637ec[_0x14a2('0x39')],function(_0x31f7d1){var _0x3fe737={};_0x3fe737[_0x31f7d1]={'$like':'%'+_0x2f1bb6['query'][_0x14a2('0x40')]+'%'};return _0x3fe737;})});}_0x4637ec=_[_0x14a2('0x41')]({},_0x4637ec,_0x2f1bb6[_0x14a2('0x48')]);return db[_0x14a2('0x56')]['count']({'where':_0x4637ec['where']})[_0x14a2('0x26')](function(_0x3c99ca){_0x218960[_0x14a2('0x1d')]=_0x3c99ca;if(_0x2f1bb6['query'][_0x14a2('0x42')]){_0x4637ec[_0x14a2('0x43')]=[{'all':!![]}];}return db[_0x14a2('0x56')][_0x14a2('0x44')](_0x4637ec);})[_0x14a2('0x26')](function(_0x2bc562){_0x218960[_0x14a2('0x45')]=_0x2bc562;return _0x218960;});}})[_0x14a2('0x26')](respondWithFilteredResult(_0x5d3734,_0x4637ec))[_0x14a2('0x46')](handleError(_0x5d3734,null));};exports['removeDispositions']=function(_0x301cc5,_0x44fbe3,_0xcb9e34){return db[_0x14a2('0x30')][_0x14a2('0x49')]({'where':{'id':_0x301cc5[_0x14a2('0x52')]['id']}})[_0x14a2('0x26')](handleEntityNotFound(_0x44fbe3,null))[_0x14a2('0x26')](function(_0x189fcb){if(_0x189fcb){return _0x189fcb[_0x14a2('0x5b')](_0x301cc5[_0x14a2('0x35')][_0x14a2('0x5c')]);}})[_0x14a2('0x26')](respondWithStatusCode(_0x44fbe3,null))[_0x14a2('0x46')](handleError(_0x44fbe3,null));};exports[_0x14a2('0x5d')]=function(_0x487255,_0x1ececc,_0x66a660){return db[_0x14a2('0x30')][_0x14a2('0x49')]({'where':{'id':_0x487255[_0x14a2('0x52')]['id']}})[_0x14a2('0x26')](handleEntityNotFound(_0x1ececc,null))[_0x14a2('0x26')](function(_0x11dc57){if(_0x11dc57){var _0x730d59=[];var _0x2fc2c4={'success':[],'errors':[]};return db[_0x14a2('0x5e')][_0x14a2('0x53')]()[_0x14a2('0x26')](function(_0x50d8d8){if(_0x487255[_0x14a2('0x4b')][_0x14a2('0x5f')]&&_[_0x14a2('0x60')](_0x487255[_0x14a2('0x4b')]['tags'])){if(_0x487255['body']['tags'][_0x14a2('0x3b')]){_0x487255[_0x14a2('0x4b')][_0x14a2('0x5f')]=_0x487255[_0x14a2('0x4b')][_0x14a2('0x5f')][_0x14a2('0x61')](';')+';';}else{_0x487255['body']['tags']=null;}}else{_0x487255[_0x14a2('0x4b')][_0x14a2('0x5f')]=null;}if(_0x487255['body']&&_[_0x14a2('0x60')](_0x487255[_0x14a2('0x4b')])){for(var _0x134f25=0x0;_0x134f25<_0x487255[_0x14a2('0x4b')]['length'];_0x134f25+=0x1){_0x487255['body'][_0x134f25][_0x14a2('0x55')]=_0x487255[_0x14a2('0x52')]['id'];_0x730d59['push'](_0x487255[_0x14a2('0x4b')][_0x134f25]);}return BPromise[_0x14a2('0x62')](_0x730d59,function(_0x3bcad0){return db[_0x14a2('0x5e')]['create'](_[_0x14a2('0x63')](_0x3bcad0,[_0x14a2('0x5c'),'id'])||{},{'fields':_[_0x14a2('0x36')](_0x50d8d8),'raw':!![]})[_0x14a2('0x26')](function(_0x37f24a){_0x2fc2c4[_0x14a2('0x64')][_0x14a2('0x65')](_0x37f24a['dataValues']);})[_0x14a2('0x46')](function(_0x3dbac0){_0x2fc2c4['errors'][_0x14a2('0x65')]({'data':_0x3bcad0,'error':_0x3dbac0['message']});});})['then'](function(_0x5759bf){return _0x2fc2c4;})[_0x14a2('0x46')](function(_0x1be376){return _0x1be376;});}else{_0x1ececc[_0x14a2('0x1b')](0x190)[_0x14a2('0x22')]({'message':_0x14a2('0x66')});}});}})[_0x14a2('0x26')](respondWithResult(_0x1ececc,null))['catch'](handleError(_0x1ececc,null));};exports[_0x14a2('0x67')]=function(_0x1e36fa,_0x190ddb,_0x238dd){var _0x3febf6;return db[_0x14a2('0x30')][_0x14a2('0x49')]({'where':{'id':_0x1e36fa[_0x14a2('0x52')]['id']},'include':[{'model':db[_0x14a2('0x68')],'as':_0x14a2('0x69')}]})[_0x14a2('0x26')](handleEntityNotFound(_0x190ddb,null))['then'](function(_0x2c0bdf){if(_0x2c0bdf){_0x3febf6=_0x2c0bdf;return db[_0x14a2('0x5e')]['rawAttributes'];}})[_0x14a2('0x26')](function(_0x1892cc){if(_0x1892cc){var _0x41d822={};var _0x2a32e8={};_0x2a32e8[_0x14a2('0x34')]=_[_0x14a2('0x6a')](_[_0x14a2('0x36')](_0x1892cc),_[_0x14a2('0x2f')](_0x3febf6['CustomFields'],function(_0x209b57){return util['format'](_0x14a2('0x6b'),_0x209b57['id']);}));_0x2a32e8[_0x14a2('0x35')]=_[_0x14a2('0x36')](_0x1e36fa[_0x14a2('0x35')]);_0x2a32e8[_0x14a2('0x37')]=_['intersection'](_0x2a32e8[_0x14a2('0x34')],_0x2a32e8['query']);_0x41d822['attributes']=_[_0x14a2('0x38')](_0x2a32e8[_0x14a2('0x34')],qs[_0x14a2('0x3a')](_0x1e36fa[_0x14a2('0x35')][_0x14a2('0x3a')]));_0x41d822[_0x14a2('0x39')]=_0x41d822[_0x14a2('0x39')][_0x14a2('0x3b')]?_0x41d822[_0x14a2('0x39')]:_0x2a32e8[_0x14a2('0x34')];if(!_0x1e36fa[_0x14a2('0x35')]['hasOwnProperty'](_0x14a2('0x3d'))){_0x41d822[_0x14a2('0x1f')]=qs['limit'](_0x1e36fa['query']['limit']);_0x41d822[_0x14a2('0x1e')]=qs['offset'](_0x1e36fa[_0x14a2('0x35')][_0x14a2('0x1e')]);}_0x41d822[_0x14a2('0x59')]=qs[_0x14a2('0x3e')](_0x1e36fa[_0x14a2('0x35')][_0x14a2('0x3e')]);_0x41d822[_0x14a2('0x3f')]=qs[_0x14a2('0x37')](_[_0x14a2('0x5a')](_0x1e36fa[_0x14a2('0x35')],_0x2a32e8['filters']));_0x41d822[_0x14a2('0x6c')]=!![];if(_0x1e36fa['query'][_0x14a2('0x40')]){_0x41d822['where']=_[_0x14a2('0x41')](_0x41d822[_0x14a2('0x3f')],{'$or':_[_0x14a2('0x2f')](_0x41d822['attributes'],function(_0x422531){var _0x3081d8={};_0x3081d8[_0x422531]={'$like':'%'+_0x1e36fa['query'][_0x14a2('0x40')]+'%'};return _0x3081d8;})});}_0x41d822=_['merge']({},_0x41d822,_0x1e36fa['options']);return _0x3febf6[_0x14a2('0x67')](_0x41d822);}})[_0x14a2('0x26')](respondWithResult(_0x190ddb,null))['catch'](handleError(_0x190ddb,null));};exports[_0x14a2('0x6d')]=function(_0x2642a6,_0x24aed8,_0x4b03d6){var _0x42e6ae;return db[_0x14a2('0x30')]['find']({'where':{'id':_0x2642a6['params']['id']},'include':[{'model':db[_0x14a2('0x68')],'as':_0x14a2('0x69')}]})[_0x14a2('0x26')](handleEntityNotFound(_0x24aed8,null))[_0x14a2('0x26')](function(_0x11205e){if(_0x11205e){_0x42e6ae=_0x11205e;return db[_0x14a2('0x5e')][_0x14a2('0x31')];}})[_0x14a2('0x26')](function(_0x884f88){if(_0x884f88){var _0xc93024={};var _0x5637a4={};_0x5637a4[_0x14a2('0x34')]=_['concat'](_[_0x14a2('0x36')](_0x884f88),_[_0x14a2('0x2f')](_0x42e6ae[_0x14a2('0x69')],function(_0x172a51){return util[_0x14a2('0x6e')](_0x14a2('0x6b'),_0x172a51['id']);}));_0x5637a4['query']=_['keys'](_0x2642a6[_0x14a2('0x35')]);_0x5637a4[_0x14a2('0x37')]=_['intersection'](_0x5637a4[_0x14a2('0x34')],_0x5637a4['query']);_0xc93024[_0x14a2('0x39')]=_[_0x14a2('0x38')](_0x5637a4['model'],qs[_0x14a2('0x3a')](_0x2642a6[_0x14a2('0x35')][_0x14a2('0x3a')]));_0xc93024[_0x14a2('0x39')]=_0xc93024[_0x14a2('0x39')][_0x14a2('0x3b')]?_0xc93024[_0x14a2('0x39')]:_0x5637a4[_0x14a2('0x34')];if(!_0x2642a6['query'][_0x14a2('0x3c')](_0x14a2('0x3d'))){_0xc93024['limit']=qs[_0x14a2('0x1f')](_0x2642a6[_0x14a2('0x35')][_0x14a2('0x1f')]);_0xc93024[_0x14a2('0x1e')]=qs['offset'](_0x2642a6[_0x14a2('0x35')][_0x14a2('0x1e')]);}_0xc93024[_0x14a2('0x59')]=qs[_0x14a2('0x3e')](_0x2642a6[_0x14a2('0x35')]['sort']);_0xc93024['where']=qs[_0x14a2('0x37')](_[_0x14a2('0x5a')](_0x2642a6[_0x14a2('0x35')],_0x5637a4[_0x14a2('0x37')]));_0xc93024[_0x14a2('0x6c')]=!![];if(_0x2642a6[_0x14a2('0x35')][_0x14a2('0x40')]){_0xc93024[_0x14a2('0x3f')]=_['merge'](_0xc93024[_0x14a2('0x3f')],{'$or':_[_0x14a2('0x2f')](_0xc93024[_0x14a2('0x39')],function(_0x26e057){var _0x2b6320={};_0x2b6320[_0x26e057]={'$like':'%'+_0x2642a6[_0x14a2('0x35')][_0x14a2('0x40')]+'%'};return _0x2b6320;})});}_0xc93024=_['merge']({},_0xc93024,_0x2642a6['options']);return _0x42e6ae[_0x14a2('0x67')](_0xc93024);}})['then'](function(_0x4f85d7){if(!_[_0x14a2('0x6f')](_0x4f85d7)){var _0x1968ad=toCsv(_0x4f85d7);var _0x32a80a=Date[_0x14a2('0x70')]();fs[_0x14a2('0x71')](util[_0x14a2('0x6e')](_0x14a2('0x72'),_0x42e6ae['id'],_0x32a80a),_0x1968ad);_0x24aed8[_0x14a2('0x73')](_0x14a2('0x74'),_0x14a2('0x75')+util[_0x14a2('0x6e')](_0x14a2('0x76'),_0x42e6ae['id'],_0x32a80a));_0x24aed8['setHeader']('Content-type',_0x14a2('0x77'));return _0x24aed8[_0x14a2('0x78')](util['format'](_0x14a2('0x72'),_0x42e6ae['id'],_0x32a80a));}else{return _0x24aed8[_0x14a2('0x1a')](0xcc);}})[_0x14a2('0x46')](handleError(_0x24aed8,null));};exports['addCustomField']=function(_0x55f2e1,_0x5ca648,_0x534e0f){var _0x3579ba;delete _0x55f2e1[_0x14a2('0x4b')]['id'];return db[_0x14a2('0x30')][_0x14a2('0x58')]({'where':{'id':_0x55f2e1[_0x14a2('0x52')]['id']}})[_0x14a2('0x26')](handleEntityNotFound(_0x5ca648,null))[_0x14a2('0x26')](function(_0x3aa95f){if(_0x3aa95f){return db[_0x14a2('0x79')][_0x14a2('0x7a')](function(_0x13fa0a){return db[_0x14a2('0x68')][_0x14a2('0x4a')](_0x55f2e1[_0x14a2('0x4b')],{'transaction':_0x13fa0a})[_0x14a2('0x26')](function(_0xc76f3b){_0x3579ba=_0xc76f3b;return _0x3aa95f[_0x14a2('0x7b')](_0xc76f3b,{'transaction':_0x13fa0a});})[_0x14a2('0x26')](function(){var _0x6cbdd1={'type':db[_0x14a2('0x7c')][_0x14a2('0x7d')],'transaction':_0x13fa0a};switch(_0x55f2e1['body'][_0x14a2('0x33')]){case _0x14a2('0x7e'):_0x6cbdd1[_0x14a2('0x33')]=db[_0x14a2('0x7c')][_0x14a2('0x7d')];break;case'number':_0x6cbdd1[_0x14a2('0x33')]=db[_0x14a2('0x7c')][_0x14a2('0x7f')];break;case _0x14a2('0x80'):_0x6cbdd1[_0x14a2('0x33')]=db[_0x14a2('0x7c')][_0x14a2('0x81')];_0x6cbdd1[_0x14a2('0x82')]=![];break;default:}return db[_0x14a2('0x79')][_0x14a2('0x83')][_0x14a2('0x84')](_0x14a2('0x85'),util[_0x14a2('0x6e')]('cf_%s',_0x3579ba['id']),_0x6cbdd1);})[_0x14a2('0x26')](function(){return _0x3579ba;});});}})[_0x14a2('0x26')](respondWithResult(_0x5ca648,null))[_0x14a2('0x46')](handleError(_0x5ca648,null));};exports[_0x14a2('0x86')]=function(_0x183b22,_0x2f47cd,_0x860c3){var _0xd50bdf={};var _0x1e5a79={};var _0xfac180;var _0x47a672;return db[_0x14a2('0x30')][_0x14a2('0x58')]({'where':{'id':_0x183b22['params']['id']}})['then'](handleEntityNotFound(_0x2f47cd,null))[_0x14a2('0x26')](function(_0x313fd7){if(_0x313fd7){_0xfac180=_0x313fd7;_0x1e5a79[_0x14a2('0x34')]=_[_0x14a2('0x36')](db[_0x14a2('0x68')]['rawAttributes']);_0x1e5a79['query']=_[_0x14a2('0x36')](_0x183b22['query']);_0x1e5a79[_0x14a2('0x37')]=_[_0x14a2('0x38')](_0x1e5a79['model'],_0x1e5a79[_0x14a2('0x35')]);_0xd50bdf['attributes']=_[_0x14a2('0x38')](_0x1e5a79[_0x14a2('0x34')],qs['fields'](_0x183b22[_0x14a2('0x35')][_0x14a2('0x3a')]));_0xd50bdf[_0x14a2('0x39')]=_0xd50bdf[_0x14a2('0x39')][_0x14a2('0x3b')]?_0xd50bdf[_0x14a2('0x39')]:_0x1e5a79[_0x14a2('0x34')];_0xd50bdf['order']=qs['sort'](_0x183b22[_0x14a2('0x35')][_0x14a2('0x3e')]);_0xd50bdf[_0x14a2('0x3f')]=qs['filters'](_[_0x14a2('0x5a')](_0x183b22[_0x14a2('0x35')],_0x1e5a79['filters']));_0xd50bdf[_0x14a2('0x3f')]=_['merge'](_0xd50bdf[_0x14a2('0x3f')],{'$or':[{'ListId':_0x313fd7['id']},{'ListId':null}]});if(_0x183b22['query'][_0x14a2('0x40')]){_0xd50bdf[_0x14a2('0x3f')]=_['merge'](_0xd50bdf[_0x14a2('0x3f')],{'$or':_['map'](_0xd50bdf['attributes'],function(_0x3ca3a7){var _0x411ccd={};_0x411ccd[_0x3ca3a7]={'$like':'%'+_0x183b22[_0x14a2('0x35')][_0x14a2('0x40')]+'%'};return _0x411ccd;})});}_0xd50bdf=_[_0x14a2('0x41')]({},_0xd50bdf,_0x183b22[_0x14a2('0x48')]);return db[_0x14a2('0x68')][_0x14a2('0x87')](_0xd50bdf);}})[_0x14a2('0x26')](respondWithResult(_0x2f47cd,null))[_0x14a2('0x46')](handleError(_0x2f47cd,null));};exports[_0x14a2('0x88')]=function(_0x1eab3b,_0x317589,_0x3c91e3){return db[_0x14a2('0x30')]['find']({'where':{'id':_0x1eab3b['params']['id']}})['then'](handleEntityNotFound(_0x317589,null))[_0x14a2('0x26')](function(_0x22577d){if(_0x22577d){return _0x22577d[_0x14a2('0x88')](_0x1eab3b[_0x14a2('0x4b')]['ids'],_[_0x14a2('0x63')](_0x1eab3b[_0x14a2('0x4b')],['ids','id'])||{})[_0x14a2('0x89')](function(_0x1bfe89){for(var _0xf43fe4=0x0;_0xf43fe4<_0x1eab3b['body']['ids'][_0x14a2('0x3b')];_0xf43fe4+=0x1){socket['emit'](_0x14a2('0x8a'),{'UserId':_0x1eab3b[_0x14a2('0x4b')][_0x14a2('0x5c')][_0xf43fe4],'CmListId':_0x1eab3b[_0x14a2('0x52')]['id']});}return _0x1bfe89;});}})[_0x14a2('0x26')](respondWithResult(_0x317589,null))[_0x14a2('0x46')](handleError(_0x317589,null));};exports[_0x14a2('0x8b')]=function(_0x49c99e,_0x8e6c04,_0x189aae){return db[_0x14a2('0x30')][_0x14a2('0x49')]({'where':{'id':_0x49c99e[_0x14a2('0x52')]['id']}})[_0x14a2('0x26')](handleEntityNotFound(_0x8e6c04,null))[_0x14a2('0x26')](function(_0x2e2e93){if(_0x2e2e93){return _0x2e2e93[_0x14a2('0x8b')](_0x49c99e['query']['ids'])[_0x14a2('0x26')](function(){if(_[_0x14a2('0x60')](_0x49c99e[_0x14a2('0x35')]['ids'])){for(var _0x4d6bbc=0x0;_0x4d6bbc<_0x49c99e[_0x14a2('0x35')][_0x14a2('0x5c')][_0x14a2('0x3b')];_0x4d6bbc+=0x1){socket[_0x14a2('0x8c')](_0x14a2('0x8d'),{'UserId':Number(_0x49c99e[_0x14a2('0x35')][_0x14a2('0x5c')][_0x4d6bbc]),'CmListId':Number(_0x49c99e[_0x14a2('0x52')]['id'])});}}else{socket[_0x14a2('0x8c')](_0x14a2('0x8d'),{'UserId':Number(_0x49c99e[_0x14a2('0x35')][_0x14a2('0x5c')]),'CmListId':Number(_0x49c99e[_0x14a2('0x52')]['id'])});}});}})[_0x14a2('0x26')](respondWithStatusCode(_0x8e6c04,null))[_0x14a2('0x46')](handleError(_0x8e6c04,null));};exports[_0x14a2('0x8e')]=function(_0x438dcc,_0x44e684,_0xbb8701){var _0x509a10={};var _0x3945f3={};var _0x45e05e;var _0x60f957;return db[_0x14a2('0x30')][_0x14a2('0x58')]({'where':{'id':_0x438dcc[_0x14a2('0x52')]['id']}})[_0x14a2('0x26')](handleEntityNotFound(_0x44e684,null))[_0x14a2('0x26')](function(_0x4b79d7){if(_0x4b79d7){_0x45e05e=_0x4b79d7;_0x3945f3[_0x14a2('0x34')]=_[_0x14a2('0x36')](db[_0x14a2('0x8f')][_0x14a2('0x31')]);_0x3945f3[_0x14a2('0x35')]=_[_0x14a2('0x36')](_0x438dcc[_0x14a2('0x35')]);_0x3945f3[_0x14a2('0x37')]=_[_0x14a2('0x38')](_0x3945f3[_0x14a2('0x34')],_0x3945f3[_0x14a2('0x35')]);_0x509a10[_0x14a2('0x39')]=_['intersection'](_0x3945f3[_0x14a2('0x34')],qs[_0x14a2('0x3a')](_0x438dcc[_0x14a2('0x35')][_0x14a2('0x3a')]));_0x509a10[_0x14a2('0x39')]=_0x509a10[_0x14a2('0x39')][_0x14a2('0x3b')]?_0x509a10[_0x14a2('0x39')]:_0x3945f3[_0x14a2('0x34')];_0x509a10[_0x14a2('0x59')]=qs[_0x14a2('0x3e')](_0x438dcc[_0x14a2('0x35')][_0x14a2('0x3e')]);_0x509a10['where']=qs[_0x14a2('0x37')](_[_0x14a2('0x5a')](_0x438dcc[_0x14a2('0x35')],_0x3945f3[_0x14a2('0x37')]));if(_0x438dcc['query'][_0x14a2('0x40')]){_0x509a10[_0x14a2('0x3f')]=_['merge'](_0x509a10['where'],{'$or':_[_0x14a2('0x2f')](_0x509a10['attributes'],function(_0x231683){var _0x682ac9={};_0x682ac9[_0x231683]={'$like':'%'+_0x438dcc[_0x14a2('0x35')][_0x14a2('0x40')]+'%'};return _0x682ac9;})});}_0x509a10=_[_0x14a2('0x41')]({},_0x509a10,_0x438dcc['options']);return _0x45e05e[_0x14a2('0x8e')](_0x509a10);}})[_0x14a2('0x26')](function(_0x1632ff){if(_0x1632ff){_0x60f957=_0x1632ff[_0x14a2('0x3b')];if(!_0x438dcc['query'][_0x14a2('0x3c')]('nolimit')){_0x509a10['limit']=qs[_0x14a2('0x1f')](_0x438dcc[_0x14a2('0x35')]['limit']);_0x509a10[_0x14a2('0x1e')]=qs['offset'](_0x438dcc[_0x14a2('0x35')][_0x14a2('0x1e')]);}return _0x45e05e[_0x14a2('0x8e')](_0x509a10);}})[_0x14a2('0x26')](function(_0x12f8b0){if(_0x12f8b0){return _0x12f8b0?{'count':_0x60f957,'rows':_0x12f8b0}:null;}})[_0x14a2('0x26')](respondWithResult(_0x44e684,null))[_0x14a2('0x46')](handleError(_0x44e684,null));};
\ No newline at end of file
+var _0x73b7=['User','eml-format','rimraf','zip-dir','fast-json-patch','bluebird','mustache','util','sox','to-csv','lodash','squel','crypto','jsforce','desk.js','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','localhost','socket.io-emitter','./cmList.socket','register','sendStatus','status','end','json','offset','undefined','limit','count','Content-Range','apply','reject','save','update','then','destroy','get','Lists','UserProfileResource','error','stack','name','send','index','map','CmList','rawAttributes','type','key','model','keys','query','filters','intersection','attributes','fields','hasOwnProperty','nolimit','order','sort','pick','merge','where','VIRTUAL','options','findAll','rows','params','includeAll','find','catch','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','addDisposition','ListId','Disposition','findOne','length','filter','include','removeDispositions','ids','addContacts','CmContact','tags','join','isArray','push','omit','success','dataValues','errors','message','Malformed\x20request\x20syntax','getContacts','CmCustomField','concat','CustomFields','cf_%d','getContactsCsv','isEmpty','now','writeFileSync','setHeader','Content-disposition','format','list_%d_%s.csv','text/csv','download','/tmp/list_%d_%s.csv','addCustomField','sequelize','transaction','addCustomFields','Sequelize','text','number','INTEGER','BOOLEAN','defaultValue','queryInterface','addColumn','getCustomFields','findAndCountAll','addAgents','spread','userCmList:save','removeAgents','emit','userCmList:remove','getAgents'];(function(_0xdc2882,_0x3169b7){var _0x1ed287=function(_0xad592a){while(--_0xad592a){_0xdc2882['push'](_0xdc2882['shift']());}};_0x1ed287(++_0x3169b7);}(_0x73b7,0x1bd));var _0x773b=function(_0x4f354a,_0x109a73){_0x4f354a=_0x4f354a-0x0;var _0x4c99a0=_0x73b7[_0x4f354a];return _0x4c99a0;};'use strict';var emlformat=require(_0x773b('0x0'));var rimraf=require(_0x773b('0x1'));var zipdir=require(_0x773b('0x2'));var jsonpatch=require(_0x773b('0x3'));var rp=require('request-promise');var moment=require('moment');var BPromise=require(_0x773b('0x4'));var Mustache=require(_0x773b('0x5'));var util=require(_0x773b('0x6'));var path=require('path');var sox=require(_0x773b('0x7'));var csv=require(_0x773b('0x8'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x773b('0x9'));var squel=require(_0x773b('0xa'));var crypto=require(_0x773b('0xb'));var jsforce=require(_0x773b('0xc'));var deskjs=require(_0x773b('0xd'));var toCsv=require(_0x773b('0x8'));var querystring=require('querystring');var Papa=require('papaparse');var Redis=require(_0x773b('0xe'));var authService=require(_0x773b('0xf'));var qs=require(_0x773b('0x10'));var as=require(_0x773b('0x11'));var hardwareService=require(_0x773b('0x12'));var logger=require(_0x773b('0x13'))(_0x773b('0x14'));var utils=require(_0x773b('0x15'));var config=require(_0x773b('0x16'));var licenseUtil=require(_0x773b('0x17'));var db=require(_0x773b('0x18'))['db'];config[_0x773b('0x19')]=_[_0x773b('0x1a')](config[_0x773b('0x19')],{'host':_0x773b('0x1b'),'port':0x18eb});var socket=require(_0x773b('0x1c'))(new Redis(config[_0x773b('0x19')]));require(_0x773b('0x1d'))[_0x773b('0x1e')](socket);function respondWithStatusCode(_0x515e60,_0x124e54){_0x124e54=_0x124e54||0xcc;return function(_0x4de2bd){if(_0x4de2bd){return _0x515e60[_0x773b('0x1f')](_0x124e54);}return _0x515e60[_0x773b('0x20')](_0x124e54)[_0x773b('0x21')]();};}function respondWithResult(_0x134240,_0x2befe3){_0x2befe3=_0x2befe3||0xc8;return function(_0x21947b){if(_0x21947b){return _0x134240[_0x773b('0x20')](_0x2befe3)[_0x773b('0x22')](_0x21947b);}};}function respondWithFilteredResult(_0x4e0601,_0x463ffd){return function(_0x27d6f5){if(_0x27d6f5){var _0x159173=typeof _0x463ffd[_0x773b('0x23')]===_0x773b('0x24')&&typeof _0x463ffd[_0x773b('0x25')]==='undefined';var _0x4eeb07=_0x27d6f5[_0x773b('0x26')];var _0x4229a6=_0x159173?0x0:_0x463ffd[_0x773b('0x23')];var _0x4b608f=_0x159173?_0x27d6f5['count']:_0x463ffd['offset']+_0x463ffd[_0x773b('0x25')];var _0x1222f6;if(_0x4b608f>=_0x4eeb07){_0x4b608f=_0x4eeb07;_0x1222f6=0xc8;}else{_0x1222f6=0xce;}_0x4e0601['status'](_0x1222f6);return _0x4e0601['set'](_0x773b('0x27'),_0x4229a6+'-'+_0x4b608f+'/'+_0x4eeb07)['json'](_0x27d6f5);}return null;};}function patchUpdates(_0x3d7e36){return function(_0x32a83b){try{jsonpatch[_0x773b('0x28')](_0x32a83b,_0x3d7e36,!![]);}catch(_0x14b89b){return BPromise[_0x773b('0x29')](_0x14b89b);}return _0x32a83b[_0x773b('0x2a')]();};}function saveUpdates(_0x312509,_0x8f443d){return function(_0x4079d9){if(_0x4079d9){return _0x4079d9[_0x773b('0x2b')](_0x312509)[_0x773b('0x2c')](function(_0x5f190f){return _0x5f190f;});}return null;};}function removeEntity(_0x73f994,_0x331016){return function(_0x3b57e5){if(_0x3b57e5){return _0x3b57e5[_0x773b('0x2d')]()[_0x773b('0x2c')](function(){var _0x58d283=_0x3b57e5[_0x773b('0x2e')]({'plain':!![]});var _0x36f046=_0x773b('0x2f');return db[_0x773b('0x30')]['destroy']({'where':{'type':_0x36f046,'resourceId':_0x58d283['id']}})[_0x773b('0x2c')](function(){return _0x3b57e5;});})['then'](function(){_0x73f994[_0x773b('0x20')](0xcc)[_0x773b('0x21')]();});}};}function handleEntityNotFound(_0xe7180d,_0x552f13){return function(_0x29794f){if(!_0x29794f){_0xe7180d[_0x773b('0x1f')](0x194);}return _0x29794f;};}function handleError(_0x585797,_0x1fbb1f){_0x1fbb1f=_0x1fbb1f||0x1f4;return function(_0x1e6861){logger[_0x773b('0x31')](_0x1e6861[_0x773b('0x32')]);if(_0x1e6861[_0x773b('0x33')]){delete _0x1e6861['name'];}_0x585797['status'](_0x1fbb1f)[_0x773b('0x34')](_0x1e6861);};}exports[_0x773b('0x35')]=function(_0x2d30e6,_0x1de3af){var _0x5a0c1c={},_0x1328e5={},_0x44a770={'count':0x0,'rows':[]};var _0x3cd8e4=_[_0x773b('0x36')](db[_0x773b('0x37')][_0x773b('0x38')],function(_0x3b96de){return{'name':_0x3b96de['fieldName'],'type':_0x3b96de[_0x773b('0x39')][_0x773b('0x3a')]};});_0x1328e5[_0x773b('0x3b')]=_[_0x773b('0x36')](_0x3cd8e4,_0x773b('0x33'));_0x1328e5['query']=_[_0x773b('0x3c')](_0x2d30e6[_0x773b('0x3d')]);_0x1328e5[_0x773b('0x3e')]=_[_0x773b('0x3f')](_0x1328e5['model'],_0x1328e5['query']);_0x5a0c1c[_0x773b('0x40')]=_[_0x773b('0x3f')](_0x1328e5[_0x773b('0x3b')],qs['fields'](_0x2d30e6[_0x773b('0x3d')][_0x773b('0x41')]));_0x5a0c1c[_0x773b('0x40')]=_0x5a0c1c[_0x773b('0x40')]['length']?_0x5a0c1c[_0x773b('0x40')]:_0x1328e5[_0x773b('0x3b')];if(!_0x2d30e6[_0x773b('0x3d')][_0x773b('0x42')](_0x773b('0x43'))){_0x5a0c1c[_0x773b('0x25')]=qs[_0x773b('0x25')](_0x2d30e6['query'][_0x773b('0x25')]);_0x5a0c1c[_0x773b('0x23')]=qs[_0x773b('0x23')](_0x2d30e6[_0x773b('0x3d')][_0x773b('0x23')]);}_0x5a0c1c[_0x773b('0x44')]=qs[_0x773b('0x45')](_0x2d30e6[_0x773b('0x3d')][_0x773b('0x45')]);_0x5a0c1c['where']=qs['filters'](_[_0x773b('0x46')](_0x2d30e6[_0x773b('0x3d')],_0x1328e5[_0x773b('0x3e')]),_0x3cd8e4);if(_0x2d30e6['query']['filter']){_0x5a0c1c['where']=_[_0x773b('0x47')](_0x5a0c1c[_0x773b('0x48')],{'$or':_[_0x773b('0x36')](_0x3cd8e4,function(_0x413fc2){if(_0x413fc2[_0x773b('0x39')]!==_0x773b('0x49')){var _0x4f7f41={};_0x4f7f41[_0x413fc2[_0x773b('0x33')]]={'$like':'%'+_0x2d30e6['query']['filter']+'%'};return _0x4f7f41;}})});}_0x5a0c1c=_[_0x773b('0x47')]({},_0x5a0c1c,_0x2d30e6[_0x773b('0x4a')]);var _0x55c7e1={'where':_0x5a0c1c[_0x773b('0x48')]};return db[_0x773b('0x37')][_0x773b('0x26')](_0x55c7e1)['then'](function(_0x24d705){_0x44a770[_0x773b('0x26')]=_0x24d705;if(_0x2d30e6[_0x773b('0x3d')]['includeAll']){_0x5a0c1c['include']=[{'all':!![]}];}return db[_0x773b('0x37')][_0x773b('0x4b')](_0x5a0c1c);})[_0x773b('0x2c')](function(_0x42d619){_0x44a770[_0x773b('0x4c')]=_0x42d619;return _0x44a770;})[_0x773b('0x2c')](respondWithFilteredResult(_0x1de3af,_0x5a0c1c))['catch'](handleError(_0x1de3af,null));};exports['show']=function(_0x2407a4,_0x491390){var _0x41ffc8={'raw':![],'where':{'id':_0x2407a4[_0x773b('0x4d')]['id']}},_0x3770a4={};_0x3770a4[_0x773b('0x3b')]=_['keys'](db['CmList'][_0x773b('0x38')]);_0x3770a4['query']=_[_0x773b('0x3c')](_0x2407a4[_0x773b('0x3d')]);_0x3770a4[_0x773b('0x3e')]=_[_0x773b('0x3f')](_0x3770a4['model'],_0x3770a4[_0x773b('0x3d')]);_0x41ffc8[_0x773b('0x40')]=_[_0x773b('0x3f')](_0x3770a4['model'],qs['fields'](_0x2407a4[_0x773b('0x3d')][_0x773b('0x41')]));_0x41ffc8['attributes']=_0x41ffc8[_0x773b('0x40')]['length']?_0x41ffc8[_0x773b('0x40')]:_0x3770a4['model'];if(_0x2407a4['query'][_0x773b('0x4e')]){_0x41ffc8['include']=[{'all':!![]}];}_0x41ffc8=_[_0x773b('0x47')]({},_0x41ffc8,_0x2407a4[_0x773b('0x4a')]);return db['CmList'][_0x773b('0x4f')](_0x41ffc8)['then'](handleEntityNotFound(_0x491390,null))[_0x773b('0x2c')](respondWithResult(_0x491390,null))[_0x773b('0x50')](handleError(_0x491390,null));};exports['create']=function(_0x4d5050,_0xbcaa13){return db[_0x773b('0x37')][_0x773b('0x51')](_0x4d5050[_0x773b('0x52')],{})[_0x773b('0x2c')](function(_0x35b4fa){var _0x1b1ed9=_0x4d5050[_0x773b('0x53')]['get']({'plain':!![]});if(!_0x1b1ed9)throw new Error(_0x773b('0x54'));if(_0x1b1ed9['role']===_0x773b('0x53')){var _0xdb6f29=_0x35b4fa['get']({'plain':!![]});var _0x21acae=_0x773b('0x2f');return db['UserProfileSection'][_0x773b('0x4f')]({'where':{'name':_0x21acae,'userProfileId':_0x1b1ed9[_0x773b('0x55')]},'raw':!![]})[_0x773b('0x2c')](function(_0x1949aa){if(_0x1949aa&&_0x1949aa[_0x773b('0x56')]===0x0){return db[_0x773b('0x30')][_0x773b('0x51')]({'name':_0xdb6f29[_0x773b('0x33')],'resourceId':_0xdb6f29['id'],'type':_0x1949aa['name'],'sectionId':_0x1949aa['id']},{})[_0x773b('0x2c')](function(){return _0x35b4fa;});}else{return _0x35b4fa;}})[_0x773b('0x50')](function(_0x512b6e){logger[_0x773b('0x31')](_0x773b('0x57'),_0x512b6e);throw _0x512b6e;});}return _0x35b4fa;})[_0x773b('0x2c')](respondWithResult(_0xbcaa13,0xc9))[_0x773b('0x50')](handleError(_0xbcaa13,null));};exports[_0x773b('0x2b')]=function(_0x45c33a,_0x2639fa){if(_0x45c33a[_0x773b('0x52')]['id']){delete _0x45c33a['body']['id'];}return db[_0x773b('0x37')]['find']({'where':{'id':_0x45c33a['params']['id']}})[_0x773b('0x2c')](handleEntityNotFound(_0x2639fa,null))[_0x773b('0x2c')](saveUpdates(_0x45c33a[_0x773b('0x52')],null))[_0x773b('0x2c')](respondWithResult(_0x2639fa,null))['catch'](handleError(_0x2639fa,null));};exports[_0x773b('0x2d')]=function(_0x267ea0,_0x4e2be5){return db[_0x773b('0x37')][_0x773b('0x4f')]({'where':{'id':_0x267ea0[_0x773b('0x4d')]['id']}})[_0x773b('0x2c')](handleEntityNotFound(_0x4e2be5,null))['then'](removeEntity(_0x4e2be5,null))['catch'](handleError(_0x4e2be5,null));};exports['describe']=function(_0x1a3028,_0x551aa1){return db[_0x773b('0x37')][_0x773b('0x58')]()[_0x773b('0x2c')](respondWithResult(_0x551aa1,null))[_0x773b('0x50')](handleError(_0x551aa1,null));};exports[_0x773b('0x59')]=function(_0x58c067,_0x74fe3a,_0x2d7481){if(_0x58c067[_0x773b('0x52')]['id']){delete _0x58c067[_0x773b('0x52')]['id'];}return db[_0x773b('0x37')][_0x773b('0x4f')]({'where':{'id':_0x58c067[_0x773b('0x4d')]['id']}})[_0x773b('0x2c')](handleEntityNotFound(_0x74fe3a,null))[_0x773b('0x2c')](function(_0x5ada0a){if(_0x5ada0a){_0x58c067['body'][_0x773b('0x5a')]=_0x5ada0a['id'];return db[_0x773b('0x5b')][_0x773b('0x51')](_0x58c067[_0x773b('0x52')]);}})[_0x773b('0x2c')](respondWithResult(_0x74fe3a,null))[_0x773b('0x50')](handleError(_0x74fe3a,null));};exports['getDispositions']=function(_0xebf5b8,_0x29c017,_0xa98619){var _0x21ba0e={'raw':![],'where':{}};var _0x2eddc3={};var _0x401b69={'count':0x0,'rows':[]};return db[_0x773b('0x37')][_0x773b('0x5c')]({'where':{'id':_0xebf5b8[_0x773b('0x4d')]['id']}})[_0x773b('0x2c')](handleEntityNotFound(_0x29c017,null))['then'](function(_0x4fb5f6){if(_0x4fb5f6){_0x2eddc3['model']=_[_0x773b('0x3c')](db['Disposition'][_0x773b('0x38')]);_0x2eddc3['query']=_[_0x773b('0x3c')](_0xebf5b8[_0x773b('0x3d')]);_0x2eddc3[_0x773b('0x3e')]=_['intersection'](_0x2eddc3[_0x773b('0x3b')],_0x2eddc3[_0x773b('0x3d')]);_0x21ba0e[_0x773b('0x40')]=_['intersection'](_0x2eddc3[_0x773b('0x3b')],qs[_0x773b('0x41')](_0xebf5b8[_0x773b('0x3d')][_0x773b('0x41')]));_0x21ba0e[_0x773b('0x40')]=_0x21ba0e[_0x773b('0x40')][_0x773b('0x5d')]?_0x21ba0e[_0x773b('0x40')]:_0x2eddc3[_0x773b('0x3b')];if(!_0xebf5b8[_0x773b('0x3d')]['hasOwnProperty'](_0x773b('0x43'))){_0x21ba0e['limit']=qs[_0x773b('0x25')](_0xebf5b8[_0x773b('0x3d')][_0x773b('0x25')]);_0x21ba0e[_0x773b('0x23')]=qs[_0x773b('0x23')](_0xebf5b8[_0x773b('0x3d')][_0x773b('0x23')]);}_0x21ba0e[_0x773b('0x44')]=qs[_0x773b('0x45')](_0xebf5b8[_0x773b('0x3d')][_0x773b('0x45')]);_0x21ba0e[_0x773b('0x48')]=qs['filters'](_[_0x773b('0x46')](_0xebf5b8[_0x773b('0x3d')],_0x2eddc3[_0x773b('0x3e')]));_0x21ba0e[_0x773b('0x48')][_0x773b('0x5a')]=_0x4fb5f6['id'];if(_0xebf5b8[_0x773b('0x3d')][_0x773b('0x5e')]){_0x21ba0e[_0x773b('0x48')]=_['merge'](_0x21ba0e[_0x773b('0x48')],{'$or':_['map'](_0x21ba0e['attributes'],function(_0x4ddff6){var _0x2e9137={};_0x2e9137[_0x4ddff6]={'$like':'%'+_0xebf5b8[_0x773b('0x3d')][_0x773b('0x5e')]+'%'};return _0x2e9137;})});}_0x21ba0e=_[_0x773b('0x47')]({},_0x21ba0e,_0xebf5b8[_0x773b('0x4a')]);return db[_0x773b('0x5b')][_0x773b('0x26')]({'where':_0x21ba0e['where']})[_0x773b('0x2c')](function(_0x628797){_0x401b69[_0x773b('0x26')]=_0x628797;if(_0xebf5b8[_0x773b('0x3d')]['includeAll']){_0x21ba0e[_0x773b('0x5f')]=[{'all':!![]}];}return db[_0x773b('0x5b')][_0x773b('0x4b')](_0x21ba0e);})[_0x773b('0x2c')](function(_0x10ecf0){_0x401b69[_0x773b('0x4c')]=_0x10ecf0;return _0x401b69;});}})[_0x773b('0x2c')](respondWithFilteredResult(_0x29c017,_0x21ba0e))[_0x773b('0x50')](handleError(_0x29c017,null));};exports[_0x773b('0x60')]=function(_0x3fdb51,_0x5d7449,_0x595fe8){return db['CmList'][_0x773b('0x4f')]({'where':{'id':_0x3fdb51[_0x773b('0x4d')]['id']}})['then'](handleEntityNotFound(_0x5d7449,null))[_0x773b('0x2c')](function(_0x5208fc){if(_0x5208fc){return _0x5208fc['removeDispositions'](_0x3fdb51[_0x773b('0x3d')][_0x773b('0x61')]);}})[_0x773b('0x2c')](respondWithStatusCode(_0x5d7449,null))[_0x773b('0x50')](handleError(_0x5d7449,null));};exports[_0x773b('0x62')]=function(_0x4529cc,_0x4fbaa9,_0xa71d51){return db[_0x773b('0x37')][_0x773b('0x4f')]({'where':{'id':_0x4529cc[_0x773b('0x4d')]['id']}})[_0x773b('0x2c')](handleEntityNotFound(_0x4fbaa9,null))[_0x773b('0x2c')](function(_0x1035e5){if(_0x1035e5){var _0x1fa535=[];var _0x1cc743={'success':[],'errors':[]};return db[_0x773b('0x63')]['describe']()['then'](function(_0x25d33f){if(_0x4529cc[_0x773b('0x52')]['tags']&&_['isArray'](_0x4529cc[_0x773b('0x52')][_0x773b('0x64')])){if(_0x4529cc[_0x773b('0x52')][_0x773b('0x64')][_0x773b('0x5d')]){_0x4529cc['body'][_0x773b('0x64')]=_0x4529cc['body'][_0x773b('0x64')][_0x773b('0x65')](';')+';';}else{_0x4529cc['body'][_0x773b('0x64')]=null;}}else{_0x4529cc[_0x773b('0x52')][_0x773b('0x64')]=null;}if(_0x4529cc[_0x773b('0x52')]&&_[_0x773b('0x66')](_0x4529cc[_0x773b('0x52')])){for(var _0x231552=0x0;_0x231552<_0x4529cc[_0x773b('0x52')]['length'];_0x231552+=0x1){_0x4529cc[_0x773b('0x52')][_0x231552][_0x773b('0x5a')]=_0x4529cc['params']['id'];_0x1fa535[_0x773b('0x67')](_0x4529cc[_0x773b('0x52')][_0x231552]);}return BPromise['each'](_0x1fa535,function(_0x160f15){return db['CmContact'][_0x773b('0x51')](_[_0x773b('0x68')](_0x160f15,[_0x773b('0x61'),'id'])||{},{'fields':_[_0x773b('0x3c')](_0x25d33f),'raw':!![]})[_0x773b('0x2c')](function(_0xbcb5f2){_0x1cc743[_0x773b('0x69')][_0x773b('0x67')](_0xbcb5f2[_0x773b('0x6a')]);})['catch'](function(_0x3ebe30){_0x1cc743[_0x773b('0x6b')][_0x773b('0x67')]({'data':_0x160f15,'error':_0x3ebe30[_0x773b('0x6c')]});});})[_0x773b('0x2c')](function(_0x2b36d0){return _0x1cc743;})[_0x773b('0x50')](function(_0x2b8275){return _0x2b8275;});}else{_0x4fbaa9[_0x773b('0x20')](0x190)[_0x773b('0x22')]({'message':_0x773b('0x6d')});}});}})[_0x773b('0x2c')](respondWithResult(_0x4fbaa9,null))[_0x773b('0x50')](handleError(_0x4fbaa9,null));};exports[_0x773b('0x6e')]=function(_0x924c16,_0x28730c,_0x1698b2){var _0x33b5c4;return db[_0x773b('0x37')][_0x773b('0x4f')]({'where':{'id':_0x924c16[_0x773b('0x4d')]['id']},'include':[{'model':db[_0x773b('0x6f')],'as':'CustomFields'}]})['then'](handleEntityNotFound(_0x28730c,null))['then'](function(_0x2c21d4){if(_0x2c21d4){_0x33b5c4=_0x2c21d4;return db[_0x773b('0x63')][_0x773b('0x38')];}})['then'](function(_0x5425cd){if(_0x5425cd){var _0x4efd2f={};var _0x10ad12={};_0x10ad12[_0x773b('0x3b')]=_[_0x773b('0x70')](_['keys'](_0x5425cd),_[_0x773b('0x36')](_0x33b5c4[_0x773b('0x71')],function(_0x2d68d6){return util['format'](_0x773b('0x72'),_0x2d68d6['id']);}));_0x10ad12['query']=_[_0x773b('0x3c')](_0x924c16['query']);_0x10ad12[_0x773b('0x3e')]=_[_0x773b('0x3f')](_0x10ad12[_0x773b('0x3b')],_0x10ad12[_0x773b('0x3d')]);_0x4efd2f[_0x773b('0x40')]=_[_0x773b('0x3f')](_0x10ad12[_0x773b('0x3b')],qs[_0x773b('0x41')](_0x924c16[_0x773b('0x3d')][_0x773b('0x41')]));_0x4efd2f['attributes']=_0x4efd2f[_0x773b('0x40')][_0x773b('0x5d')]?_0x4efd2f[_0x773b('0x40')]:_0x10ad12[_0x773b('0x3b')];if(!_0x924c16[_0x773b('0x3d')][_0x773b('0x42')]('nolimit')){_0x4efd2f['limit']=qs[_0x773b('0x25')](_0x924c16[_0x773b('0x3d')][_0x773b('0x25')]);_0x4efd2f[_0x773b('0x23')]=qs[_0x773b('0x23')](_0x924c16[_0x773b('0x3d')][_0x773b('0x23')]);}_0x4efd2f[_0x773b('0x44')]=qs['sort'](_0x924c16[_0x773b('0x3d')][_0x773b('0x45')]);_0x4efd2f[_0x773b('0x48')]=qs['filters'](_[_0x773b('0x46')](_0x924c16[_0x773b('0x3d')],_0x10ad12[_0x773b('0x3e')]));_0x4efd2f['raw']=!![];if(_0x924c16[_0x773b('0x3d')][_0x773b('0x5e')]){_0x4efd2f[_0x773b('0x48')]=_[_0x773b('0x47')](_0x4efd2f['where'],{'$or':_[_0x773b('0x36')](_0x4efd2f['attributes'],function(_0x1e1153){var _0x328006={};_0x328006[_0x1e1153]={'$like':'%'+_0x924c16[_0x773b('0x3d')][_0x773b('0x5e')]+'%'};return _0x328006;})});}_0x4efd2f=_[_0x773b('0x47')]({},_0x4efd2f,_0x924c16[_0x773b('0x4a')]);return _0x33b5c4[_0x773b('0x6e')](_0x4efd2f);}})[_0x773b('0x2c')](respondWithResult(_0x28730c,null))[_0x773b('0x50')](handleError(_0x28730c,null));};exports[_0x773b('0x73')]=function(_0x49f28c,_0x4e8ef1,_0xb7687e){var _0x2ee76c;return db[_0x773b('0x37')]['find']({'where':{'id':_0x49f28c[_0x773b('0x4d')]['id']},'include':[{'model':db[_0x773b('0x6f')],'as':_0x773b('0x71')}]})[_0x773b('0x2c')](handleEntityNotFound(_0x4e8ef1,null))['then'](function(_0x55eeaf){if(_0x55eeaf){_0x2ee76c=_0x55eeaf;return db['CmContact'][_0x773b('0x38')];}})['then'](function(_0x595e16){if(_0x595e16){var _0x2bc4fd={};var _0x218d03={};_0x218d03[_0x773b('0x3b')]=_['concat'](_[_0x773b('0x3c')](_0x595e16),_[_0x773b('0x36')](_0x2ee76c[_0x773b('0x71')],function(_0x411d2a){return util['format'](_0x773b('0x72'),_0x411d2a['id']);}));_0x218d03['query']=_[_0x773b('0x3c')](_0x49f28c[_0x773b('0x3d')]);_0x218d03[_0x773b('0x3e')]=_[_0x773b('0x3f')](_0x218d03[_0x773b('0x3b')],_0x218d03[_0x773b('0x3d')]);_0x2bc4fd[_0x773b('0x40')]=_[_0x773b('0x3f')](_0x218d03[_0x773b('0x3b')],qs[_0x773b('0x41')](_0x49f28c['query'][_0x773b('0x41')]));_0x2bc4fd[_0x773b('0x40')]=_0x2bc4fd[_0x773b('0x40')][_0x773b('0x5d')]?_0x2bc4fd[_0x773b('0x40')]:_0x218d03[_0x773b('0x3b')];if(!_0x49f28c[_0x773b('0x3d')][_0x773b('0x42')](_0x773b('0x43'))){_0x2bc4fd[_0x773b('0x25')]=qs[_0x773b('0x25')](_0x49f28c['query'][_0x773b('0x25')]);_0x2bc4fd[_0x773b('0x23')]=qs[_0x773b('0x23')](_0x49f28c[_0x773b('0x3d')][_0x773b('0x23')]);}_0x2bc4fd[_0x773b('0x44')]=qs[_0x773b('0x45')](_0x49f28c[_0x773b('0x3d')][_0x773b('0x45')]);_0x2bc4fd[_0x773b('0x48')]=qs[_0x773b('0x3e')](_['pick'](_0x49f28c[_0x773b('0x3d')],_0x218d03['filters']));_0x2bc4fd['raw']=!![];if(_0x49f28c[_0x773b('0x3d')][_0x773b('0x5e')]){_0x2bc4fd[_0x773b('0x48')]=_['merge'](_0x2bc4fd[_0x773b('0x48')],{'$or':_[_0x773b('0x36')](_0x2bc4fd[_0x773b('0x40')],function(_0x3f2557){var _0x3c3816={};_0x3c3816[_0x3f2557]={'$like':'%'+_0x49f28c[_0x773b('0x3d')][_0x773b('0x5e')]+'%'};return _0x3c3816;})});}_0x2bc4fd=_[_0x773b('0x47')]({},_0x2bc4fd,_0x49f28c[_0x773b('0x4a')]);return _0x2ee76c[_0x773b('0x6e')](_0x2bc4fd);}})[_0x773b('0x2c')](function(_0x2400f0){if(!_[_0x773b('0x74')](_0x2400f0)){var _0x25fb72=toCsv(_0x2400f0);var _0x212da9=Date[_0x773b('0x75')]();fs[_0x773b('0x76')](util['format']('/tmp/list_%d_%s.csv',_0x2ee76c['id'],_0x212da9),_0x25fb72);_0x4e8ef1[_0x773b('0x77')](_0x773b('0x78'),'attachment;\x20filename='+util[_0x773b('0x79')](_0x773b('0x7a'),_0x2ee76c['id'],_0x212da9));_0x4e8ef1[_0x773b('0x77')]('Content-type',_0x773b('0x7b'));return _0x4e8ef1[_0x773b('0x7c')](util[_0x773b('0x79')](_0x773b('0x7d'),_0x2ee76c['id'],_0x212da9));}else{return _0x4e8ef1['sendStatus'](0xcc);}})[_0x773b('0x50')](handleError(_0x4e8ef1,null));};exports[_0x773b('0x7e')]=function(_0x579aab,_0x3f6ee5,_0x2b6f8b){var _0x3f718b;delete _0x579aab[_0x773b('0x52')]['id'];return db[_0x773b('0x37')][_0x773b('0x5c')]({'where':{'id':_0x579aab[_0x773b('0x4d')]['id']}})[_0x773b('0x2c')](handleEntityNotFound(_0x3f6ee5,null))[_0x773b('0x2c')](function(_0x144091){if(_0x144091){return db[_0x773b('0x7f')][_0x773b('0x80')](function(_0x5a74df){return db[_0x773b('0x6f')][_0x773b('0x51')](_0x579aab['body'],{'transaction':_0x5a74df})['then'](function(_0x41ab5c){_0x3f718b=_0x41ab5c;return _0x144091[_0x773b('0x81')](_0x41ab5c,{'transaction':_0x5a74df});})[_0x773b('0x2c')](function(){var _0x50ed39={'type':db[_0x773b('0x82')]['TEXT'],'transaction':_0x5a74df};switch(_0x579aab[_0x773b('0x52')][_0x773b('0x39')]){case _0x773b('0x83'):_0x50ed39['type']=db[_0x773b('0x82')]['TEXT'];break;case _0x773b('0x84'):_0x50ed39['type']=db[_0x773b('0x82')][_0x773b('0x85')];break;case'switch':_0x50ed39[_0x773b('0x39')]=db[_0x773b('0x82')][_0x773b('0x86')];_0x50ed39[_0x773b('0x87')]=![];break;default:}return db[_0x773b('0x7f')][_0x773b('0x88')][_0x773b('0x89')]('cm_contacts',util[_0x773b('0x79')]('cf_%s',_0x3f718b['id']),_0x50ed39);})['then'](function(){return _0x3f718b;});});}})[_0x773b('0x2c')](respondWithResult(_0x3f6ee5,null))[_0x773b('0x50')](handleError(_0x3f6ee5,null));};exports[_0x773b('0x8a')]=function(_0xb6a9de,_0x993567,_0x34ce46){var _0x29ad0c={};var _0x2bcb84={};var _0x4fc3e8;var _0x218edd;return db[_0x773b('0x37')]['findOne']({'where':{'id':_0xb6a9de['params']['id']}})[_0x773b('0x2c')](handleEntityNotFound(_0x993567,null))[_0x773b('0x2c')](function(_0x4f57f2){if(_0x4f57f2){_0x4fc3e8=_0x4f57f2;_0x2bcb84[_0x773b('0x3b')]=_[_0x773b('0x3c')](db[_0x773b('0x6f')]['rawAttributes']);_0x2bcb84['query']=_['keys'](_0xb6a9de[_0x773b('0x3d')]);_0x2bcb84[_0x773b('0x3e')]=_['intersection'](_0x2bcb84[_0x773b('0x3b')],_0x2bcb84[_0x773b('0x3d')]);_0x29ad0c[_0x773b('0x40')]=_['intersection'](_0x2bcb84['model'],qs[_0x773b('0x41')](_0xb6a9de[_0x773b('0x3d')][_0x773b('0x41')]));_0x29ad0c[_0x773b('0x40')]=_0x29ad0c[_0x773b('0x40')]['length']?_0x29ad0c['attributes']:_0x2bcb84[_0x773b('0x3b')];_0x29ad0c['order']=qs['sort'](_0xb6a9de[_0x773b('0x3d')]['sort']);_0x29ad0c[_0x773b('0x48')]=qs['filters'](_[_0x773b('0x46')](_0xb6a9de[_0x773b('0x3d')],_0x2bcb84[_0x773b('0x3e')]));_0x29ad0c[_0x773b('0x48')]=_[_0x773b('0x47')](_0x29ad0c[_0x773b('0x48')],{'$or':[{'ListId':_0x4f57f2['id']},{'ListId':null}]});if(_0xb6a9de[_0x773b('0x3d')][_0x773b('0x5e')]){_0x29ad0c[_0x773b('0x48')]=_[_0x773b('0x47')](_0x29ad0c[_0x773b('0x48')],{'$or':_[_0x773b('0x36')](_0x29ad0c[_0x773b('0x40')],function(_0x4c17ed){var _0x492947={};_0x492947[_0x4c17ed]={'$like':'%'+_0xb6a9de['query'][_0x773b('0x5e')]+'%'};return _0x492947;})});}_0x29ad0c=_[_0x773b('0x47')]({},_0x29ad0c,_0xb6a9de[_0x773b('0x4a')]);return db[_0x773b('0x6f')][_0x773b('0x8b')](_0x29ad0c);}})['then'](respondWithResult(_0x993567,null))[_0x773b('0x50')](handleError(_0x993567,null));};exports[_0x773b('0x8c')]=function(_0x4f3856,_0x463d86,_0x44aee){return db[_0x773b('0x37')][_0x773b('0x4f')]({'where':{'id':_0x4f3856[_0x773b('0x4d')]['id']}})[_0x773b('0x2c')](handleEntityNotFound(_0x463d86,null))[_0x773b('0x2c')](function(_0x1412c4){if(_0x1412c4){return _0x1412c4['addAgents'](_0x4f3856[_0x773b('0x52')]['ids'],_[_0x773b('0x68')](_0x4f3856['body'],['ids','id'])||{})[_0x773b('0x8d')](function(_0x37fe5e){for(var _0x1d3e4a=0x0;_0x1d3e4a<_0x4f3856[_0x773b('0x52')][_0x773b('0x61')][_0x773b('0x5d')];_0x1d3e4a+=0x1){socket['emit'](_0x773b('0x8e'),{'UserId':Number(_0x4f3856[_0x773b('0x52')][_0x773b('0x61')][_0x1d3e4a]),'CmListId':Number(_0x4f3856['params']['id'])});}return _0x37fe5e;});}})[_0x773b('0x2c')](respondWithResult(_0x463d86,null))[_0x773b('0x50')](handleError(_0x463d86,null));};exports['removeAgents']=function(_0x11b48c,_0xc57766,_0x3cb377){return db['CmList']['find']({'where':{'id':_0x11b48c[_0x773b('0x4d')]['id']}})['then'](handleEntityNotFound(_0xc57766,null))[_0x773b('0x2c')](function(_0x381d98){if(_0x381d98){return _0x381d98[_0x773b('0x8f')](_0x11b48c['query'][_0x773b('0x61')])['then'](function(){if(_['isArray'](_0x11b48c['query'][_0x773b('0x61')])){for(var _0x562531=0x0;_0x562531<_0x11b48c[_0x773b('0x3d')][_0x773b('0x61')][_0x773b('0x5d')];_0x562531+=0x1){socket[_0x773b('0x90')]('userCmList:remove',{'UserId':Number(_0x11b48c[_0x773b('0x3d')]['ids'][_0x562531]),'CmListId':Number(_0x11b48c[_0x773b('0x4d')]['id'])});}}else{socket['emit'](_0x773b('0x91'),{'UserId':Number(_0x11b48c[_0x773b('0x3d')][_0x773b('0x61')]),'CmListId':Number(_0x11b48c[_0x773b('0x4d')]['id'])});}});}})[_0x773b('0x2c')](respondWithStatusCode(_0xc57766,null))['catch'](handleError(_0xc57766,null));};exports[_0x773b('0x92')]=function(_0x3131e0,_0x2a8b0f,_0x310057){var _0x37d218={};var _0x24a7b0={};var _0x116f0f;var _0x56f388;return db[_0x773b('0x37')][_0x773b('0x5c')]({'where':{'id':_0x3131e0['params']['id']}})['then'](handleEntityNotFound(_0x2a8b0f,null))[_0x773b('0x2c')](function(_0x3c3422){if(_0x3c3422){_0x116f0f=_0x3c3422;_0x24a7b0[_0x773b('0x3b')]=_[_0x773b('0x3c')](db[_0x773b('0x93')][_0x773b('0x38')]);_0x24a7b0[_0x773b('0x3d')]=_[_0x773b('0x3c')](_0x3131e0['query']);_0x24a7b0['filters']=_[_0x773b('0x3f')](_0x24a7b0[_0x773b('0x3b')],_0x24a7b0[_0x773b('0x3d')]);_0x37d218['attributes']=_[_0x773b('0x3f')](_0x24a7b0[_0x773b('0x3b')],qs['fields'](_0x3131e0[_0x773b('0x3d')][_0x773b('0x41')]));_0x37d218[_0x773b('0x40')]=_0x37d218[_0x773b('0x40')][_0x773b('0x5d')]?_0x37d218['attributes']:_0x24a7b0[_0x773b('0x3b')];_0x37d218[_0x773b('0x44')]=qs['sort'](_0x3131e0[_0x773b('0x3d')][_0x773b('0x45')]);_0x37d218[_0x773b('0x48')]=qs[_0x773b('0x3e')](_[_0x773b('0x46')](_0x3131e0[_0x773b('0x3d')],_0x24a7b0['filters']));if(_0x3131e0[_0x773b('0x3d')][_0x773b('0x5e')]){_0x37d218[_0x773b('0x48')]=_['merge'](_0x37d218[_0x773b('0x48')],{'$or':_[_0x773b('0x36')](_0x37d218['attributes'],function(_0x23dcaa){var _0x2b9782={};_0x2b9782[_0x23dcaa]={'$like':'%'+_0x3131e0[_0x773b('0x3d')][_0x773b('0x5e')]+'%'};return _0x2b9782;})});}_0x37d218=_[_0x773b('0x47')]({},_0x37d218,_0x3131e0[_0x773b('0x4a')]);return _0x116f0f[_0x773b('0x92')](_0x37d218);}})[_0x773b('0x2c')](function(_0x6a16fc){if(_0x6a16fc){_0x56f388=_0x6a16fc[_0x773b('0x5d')];if(!_0x3131e0[_0x773b('0x3d')][_0x773b('0x42')](_0x773b('0x43'))){_0x37d218['limit']=qs[_0x773b('0x25')](_0x3131e0[_0x773b('0x3d')][_0x773b('0x25')]);_0x37d218[_0x773b('0x23')]=qs['offset'](_0x3131e0['query'][_0x773b('0x23')]);}return _0x116f0f['getAgents'](_0x37d218);}})['then'](function(_0x4356fe){if(_0x4356fe){return _0x4356fe?{'count':_0x56f388,'rows':_0x4356fe}:null;}})[_0x773b('0x2c')](respondWithResult(_0x2a8b0f,null))['catch'](handleError(_0x2a8b0f,null));};
\ No newline at end of file