Built motion from commit 85328c08.|2.5.50
[motion2.git] / server / api / cmList / cmList.controller.js
index d326785..ca4a07d 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xedd9=['end','json','count','offset','Content-Range','apply','save','update','then','destroy','get','error','stack','name','send','index','map','CmList','rawAttributes','fieldName','type','model','keys','query','filters','intersection','attributes','fields','hasOwnProperty','nolimit','limit','order','sort','where','pick','filter','merge','options','include','rows','catch','show','params','length','includeAll','find','create','body','user','role','Lists','UserProfileSection','UserProfileResource','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','addDisposition','getDispositions','Disposition','findAll','removeDispositions','addContacts','CmContact','tags','isArray','join','push','omit','ids','success','dataValues','errors','message','Malformed\x20request\x20syntax','getContacts','CmCustomField','concat','cf_%d','raw','getContactsCsv','CustomFields','format','isEmpty','now','writeFileSync','setHeader','Content-disposition','list_%d_%s.csv','Content-type','download','/tmp/list_%d_%s.csv','addCustomField','addCustomFields','Sequelize','TEXT','text','number','INTEGER','BOOLEAN','defaultValue','sequelize','queryInterface','addColumn','findOne','findAndCountAll','addAgents','spread','userCmList:save','removeAgents','emit','userCmList:remove','getAgents','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','path','sox','to-csv','ejs','squel','jsforce','desk.js','querystring','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/environment','../../mysqldb','redis','defaults','localhost','socket.io-emitter','register','sendStatus','status'];(function(_0x26ec36,_0x376167){var _0x23e220=function(_0x48f234){while(--_0x48f234){_0x26ec36['push'](_0x26ec36['shift']());}};_0x23e220(++_0x376167);}(_0xedd9,0xfc));var _0x9edd=function(_0x103032,_0x2183ca){_0x103032=_0x103032-0x0;var _0x10bfd8=_0xedd9[_0x103032];return _0x10bfd8;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0x9edd('0x0'));var rimraf=require(_0x9edd('0x1'));var zipdir=require(_0x9edd('0x2'));var jsonpatch=require(_0x9edd('0x3'));var rp=require(_0x9edd('0x4'));var moment=require(_0x9edd('0x5'));var BPromise=require(_0x9edd('0x6'));var Mustache=require(_0x9edd('0x7'));var util=require('util');var path=require(_0x9edd('0x8'));var sox=require(_0x9edd('0x9'));var csv=require(_0x9edd('0xa'));var ejs=require(_0x9edd('0xb'));var fs=require('fs');var _=require('lodash');var squel=require(_0x9edd('0xc'));var crypto=require('crypto');var jsforce=require(_0x9edd('0xd'));var deskjs=require(_0x9edd('0xe'));var toCsv=require(_0x9edd('0xa'));var querystring=require(_0x9edd('0xf'));var Papa=require('papaparse');var Redis=require(_0x9edd('0x10'));var authService=require('../../components/auth/service');var qs=require(_0x9edd('0x11'));var as=require(_0x9edd('0x12'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x9edd('0x13'))(_0x9edd('0x14'));var utils=require('../../config/utils');var config=require(_0x9edd('0x15'));var db=require(_0x9edd('0x16'))['db'];config[_0x9edd('0x17')]=_[_0x9edd('0x18')](config[_0x9edd('0x17')],{'host':_0x9edd('0x19'),'port':0x18eb});var socket=require(_0x9edd('0x1a'))(new Redis(config[_0x9edd('0x17')]));require('./cmList.socket')[_0x9edd('0x1b')](socket);function respondWithStatusCode(_0x44fc7c,_0x891832){_0x891832=_0x891832||0xcc;return function(_0x4d9a7){if(_0x4d9a7){return _0x44fc7c[_0x9edd('0x1c')](_0x891832);}return _0x44fc7c[_0x9edd('0x1d')](_0x891832)[_0x9edd('0x1e')]();};}function respondWithResult(_0x75a4ab,_0x4ea60f){_0x4ea60f=_0x4ea60f||0xc8;return function(_0x5f5bf4){if(_0x5f5bf4){return _0x75a4ab[_0x9edd('0x1d')](_0x4ea60f)[_0x9edd('0x1f')](_0x5f5bf4);}};}function respondWithFilteredResult(_0x5acf65,_0x1b54c0){return function(_0x35f454){if(_0x35f454){var _0x40ba32=_0x35f454[_0x9edd('0x20')],_0x4d8f33=_0x1b54c0[_0x9edd('0x21')],_0x43dc70=_0x1b54c0['offset']+_0x1b54c0['limit'],_0x5d879c;if(_0x43dc70>=_0x40ba32){_0x43dc70=_0x40ba32;_0x5d879c=0xc8;}else{_0x5d879c=0xce;}_0x5acf65[_0x9edd('0x1d')](_0x5d879c);return _0x5acf65['set'](_0x9edd('0x22'),_0x4d8f33+'-'+_0x43dc70+'/'+_0x40ba32)['json'](_0x35f454);}return null;};}function patchUpdates(_0x535f37){return function(_0x356751){try{jsonpatch[_0x9edd('0x23')](_0x356751,_0x535f37,!![]);}catch(_0x4fb7bf){return BPromise['reject'](_0x4fb7bf);}return _0x356751[_0x9edd('0x24')]();};}function saveUpdates(_0x186186,_0x477878){return function(_0x542172){if(_0x542172){return _0x542172[_0x9edd('0x25')](_0x186186)[_0x9edd('0x26')](function(_0x44a6c1){return _0x44a6c1;});}return null;};}function removeEntity(_0x2ca65f,_0x339a0d){return function(_0x4c75d2){if(_0x4c75d2){return _0x4c75d2[_0x9edd('0x27')]()[_0x9edd('0x26')](function(){var _0x3a1ea5=_0x4c75d2[_0x9edd('0x28')]({'plain':!![]});var _0x310a4d='Lists';return db['UserProfileResource'][_0x9edd('0x27')]({'where':{'type':_0x310a4d,'resourceId':_0x3a1ea5['id']}})[_0x9edd('0x26')](function(){return _0x4c75d2;});})[_0x9edd('0x26')](function(){_0x2ca65f[_0x9edd('0x1d')](0xcc)[_0x9edd('0x1e')]();});}};}function handleEntityNotFound(_0x4fe471,_0x57a2cc){return function(_0x214d0a){if(!_0x214d0a){_0x4fe471[_0x9edd('0x1c')](0x194);}return _0x214d0a;};}function handleError(_0x1c762c,_0x52746a){_0x52746a=_0x52746a||0x1f4;return function(_0x238b22){logger[_0x9edd('0x29')](_0x238b22[_0x9edd('0x2a')]);if(_0x238b22[_0x9edd('0x2b')]){delete _0x238b22['name'];}_0x1c762c[_0x9edd('0x1d')](_0x52746a)[_0x9edd('0x2c')](_0x238b22);};}exports[_0x9edd('0x2d')]=function(_0x12c1bc,_0xbbf08f){var _0x42e664={},_0x209aba={},_0x1fba7b={'count':0x0,'rows':[]};var _0x19b6c1=_[_0x9edd('0x2e')](db[_0x9edd('0x2f')][_0x9edd('0x30')],function(_0x6907a5){return{'name':_0x6907a5[_0x9edd('0x31')],'type':_0x6907a5[_0x9edd('0x32')]['key']};});_0x209aba[_0x9edd('0x33')]=_[_0x9edd('0x2e')](_0x19b6c1,_0x9edd('0x2b'));_0x209aba['query']=_[_0x9edd('0x34')](_0x12c1bc[_0x9edd('0x35')]);_0x209aba[_0x9edd('0x36')]=_[_0x9edd('0x37')](_0x209aba[_0x9edd('0x33')],_0x209aba[_0x9edd('0x35')]);_0x42e664[_0x9edd('0x38')]=_[_0x9edd('0x37')](_0x209aba[_0x9edd('0x33')],qs[_0x9edd('0x39')](_0x12c1bc[_0x9edd('0x35')][_0x9edd('0x39')]));_0x42e664[_0x9edd('0x38')]=_0x42e664[_0x9edd('0x38')]['length']?_0x42e664[_0x9edd('0x38')]:_0x209aba['model'];if(!_0x12c1bc[_0x9edd('0x35')][_0x9edd('0x3a')](_0x9edd('0x3b'))){_0x42e664[_0x9edd('0x3c')]=qs[_0x9edd('0x3c')](_0x12c1bc['query'][_0x9edd('0x3c')]);_0x42e664[_0x9edd('0x21')]=qs[_0x9edd('0x21')](_0x12c1bc[_0x9edd('0x35')][_0x9edd('0x21')]);}_0x42e664[_0x9edd('0x3d')]=qs[_0x9edd('0x3e')](_0x12c1bc[_0x9edd('0x35')][_0x9edd('0x3e')]);_0x42e664[_0x9edd('0x3f')]=qs['filters'](_[_0x9edd('0x40')](_0x12c1bc['query'],_0x209aba[_0x9edd('0x36')]));if(_0x12c1bc['query'][_0x9edd('0x41')]){_0x42e664[_0x9edd('0x3f')]=_[_0x9edd('0x42')](_0x42e664['where'],{'$or':_[_0x9edd('0x2e')](_0x19b6c1,function(_0xcbd0ef){if(_0xcbd0ef[_0x9edd('0x32')]!=='VIRTUAL'){var _0x1b5a43={};_0x1b5a43[_0xcbd0ef['name']]={'$like':'%'+_0x12c1bc[_0x9edd('0x35')][_0x9edd('0x41')]+'%'};return _0x1b5a43;}})});}_0x42e664=_['merge']({},_0x42e664,_0x12c1bc[_0x9edd('0x43')]);var _0x40fdfb={'where':_0x42e664[_0x9edd('0x3f')]};return db[_0x9edd('0x2f')]['count'](_0x40fdfb)[_0x9edd('0x26')](function(_0x5bbdf8){_0x1fba7b[_0x9edd('0x20')]=_0x5bbdf8;if(_0x12c1bc[_0x9edd('0x35')]['includeAll']){_0x42e664[_0x9edd('0x44')]=[{'all':!![]}];}return db['CmList']['findAll'](_0x42e664);})[_0x9edd('0x26')](function(_0x9cab86){_0x1fba7b[_0x9edd('0x45')]=_0x9cab86;return _0x1fba7b;})[_0x9edd('0x26')](respondWithFilteredResult(_0xbbf08f,_0x42e664))[_0x9edd('0x46')](handleError(_0xbbf08f,null));};exports[_0x9edd('0x47')]=function(_0x3ff512,_0x75efbe){var _0x18c149={'raw':![],'where':{'id':_0x3ff512[_0x9edd('0x48')]['id']}},_0x2b081a={};_0x2b081a[_0x9edd('0x33')]=_[_0x9edd('0x34')](db[_0x9edd('0x2f')][_0x9edd('0x30')]);_0x2b081a['query']=_[_0x9edd('0x34')](_0x3ff512[_0x9edd('0x35')]);_0x2b081a[_0x9edd('0x36')]=_[_0x9edd('0x37')](_0x2b081a[_0x9edd('0x33')],_0x2b081a[_0x9edd('0x35')]);_0x18c149[_0x9edd('0x38')]=_['intersection'](_0x2b081a['model'],qs['fields'](_0x3ff512[_0x9edd('0x35')]['fields']));_0x18c149[_0x9edd('0x38')]=_0x18c149[_0x9edd('0x38')][_0x9edd('0x49')]?_0x18c149[_0x9edd('0x38')]:_0x2b081a[_0x9edd('0x33')];if(_0x3ff512['query'][_0x9edd('0x4a')]){_0x18c149[_0x9edd('0x44')]=[{'all':!![]}];}_0x18c149=_[_0x9edd('0x42')]({},_0x18c149,_0x3ff512['options']);return db[_0x9edd('0x2f')][_0x9edd('0x4b')](_0x18c149)[_0x9edd('0x26')](handleEntityNotFound(_0x75efbe,null))[_0x9edd('0x26')](respondWithResult(_0x75efbe,null))[_0x9edd('0x46')](handleError(_0x75efbe,null));};exports[_0x9edd('0x4c')]=function(_0x4d4f33,_0x441e4a){return db[_0x9edd('0x2f')]['create'](_0x4d4f33[_0x9edd('0x4d')],{})[_0x9edd('0x26')](function(_0x4bb324){var _0x2bd089=_0x4d4f33[_0x9edd('0x4e')][_0x9edd('0x28')]({'plain':!![]});if(!_0x2bd089)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x2bd089[_0x9edd('0x4f')]===_0x9edd('0x4e')){var _0x317a60=_0x4bb324[_0x9edd('0x28')]({'plain':!![]});var _0x53f6e3=_0x9edd('0x50');return db[_0x9edd('0x51')][_0x9edd('0x4b')]({'where':{'name':_0x53f6e3,'userProfileId':_0x2bd089['userProfileId']},'raw':!![]})[_0x9edd('0x26')](function(_0x21f6ce){if(_0x21f6ce&&_0x21f6ce['autoAssociation']===0x0){return db[_0x9edd('0x52')]['create']({'name':_0x317a60[_0x9edd('0x2b')],'resourceId':_0x317a60['id'],'type':_0x21f6ce[_0x9edd('0x2b')],'sectionId':_0x21f6ce['id']},{})[_0x9edd('0x26')](function(){return _0x4bb324;});}else{return _0x4bb324;}})[_0x9edd('0x46')](function(_0x1e3c19){logger[_0x9edd('0x29')](_0x9edd('0x53'),_0x1e3c19);throw _0x1e3c19;});}return _0x4bb324;})[_0x9edd('0x26')](respondWithResult(_0x441e4a,0xc9))[_0x9edd('0x46')](handleError(_0x441e4a,null));};exports[_0x9edd('0x25')]=function(_0x31272d,_0x5a3b1d){if(_0x31272d[_0x9edd('0x4d')]['id']){delete _0x31272d[_0x9edd('0x4d')]['id'];}return db[_0x9edd('0x2f')]['find']({'where':{'id':_0x31272d[_0x9edd('0x48')]['id']}})['then'](handleEntityNotFound(_0x5a3b1d,null))['then'](saveUpdates(_0x31272d['body'],null))[_0x9edd('0x26')](respondWithResult(_0x5a3b1d,null))[_0x9edd('0x46')](handleError(_0x5a3b1d,null));};exports[_0x9edd('0x27')]=function(_0x35ddb3,_0x48a900){return db['CmList']['find']({'where':{'id':_0x35ddb3[_0x9edd('0x48')]['id']}})[_0x9edd('0x26')](handleEntityNotFound(_0x48a900,null))[_0x9edd('0x26')](removeEntity(_0x48a900,null))[_0x9edd('0x46')](handleError(_0x48a900,null));};exports[_0x9edd('0x54')]=function(_0x41ec97,_0x25906c){return db[_0x9edd('0x2f')]['describe']()[_0x9edd('0x26')](respondWithResult(_0x25906c,null))['catch'](handleError(_0x25906c,null));};exports[_0x9edd('0x55')]=function(_0x6a1cfc,_0x4b7e68,_0x22b91a){if(_0x6a1cfc[_0x9edd('0x4d')]['id']){delete _0x6a1cfc[_0x9edd('0x4d')]['id'];}return db['CmList'][_0x9edd('0x4b')]({'where':{'id':_0x6a1cfc[_0x9edd('0x48')]['id']}})[_0x9edd('0x26')](handleEntityNotFound(_0x4b7e68,null))[_0x9edd('0x26')](function(_0x1720b1){if(_0x1720b1){_0x6a1cfc[_0x9edd('0x4d')]['ListId']=_0x1720b1['id'];return db['Disposition'][_0x9edd('0x4c')](_0x6a1cfc['body']);}})[_0x9edd('0x26')](respondWithResult(_0x4b7e68,null))[_0x9edd('0x46')](handleError(_0x4b7e68,null));};exports[_0x9edd('0x56')]=function(_0x17d2f2,_0x5df1d7,_0x21ead2){var _0x507cce={'raw':![],'where':{}};var _0x3e5dca={};var _0x344692={'count':0x0,'rows':[]};return db[_0x9edd('0x2f')]['findOne']({'where':{'id':_0x17d2f2[_0x9edd('0x48')]['id']}})['then'](handleEntityNotFound(_0x5df1d7,null))[_0x9edd('0x26')](function(_0x4e1eda){if(_0x4e1eda){_0x3e5dca['model']=_[_0x9edd('0x34')](db['Disposition'][_0x9edd('0x30')]);_0x3e5dca[_0x9edd('0x35')]=_[_0x9edd('0x34')](_0x17d2f2['query']);_0x3e5dca[_0x9edd('0x36')]=_[_0x9edd('0x37')](_0x3e5dca[_0x9edd('0x33')],_0x3e5dca[_0x9edd('0x35')]);_0x507cce[_0x9edd('0x38')]=_['intersection'](_0x3e5dca['model'],qs[_0x9edd('0x39')](_0x17d2f2[_0x9edd('0x35')]['fields']));_0x507cce['attributes']=_0x507cce['attributes'][_0x9edd('0x49')]?_0x507cce['attributes']:_0x3e5dca['model'];if(!_0x17d2f2[_0x9edd('0x35')][_0x9edd('0x3a')]('nolimit')){_0x507cce[_0x9edd('0x3c')]=qs[_0x9edd('0x3c')](_0x17d2f2[_0x9edd('0x35')]['limit']);_0x507cce[_0x9edd('0x21')]=qs['offset'](_0x17d2f2[_0x9edd('0x35')][_0x9edd('0x21')]);}_0x507cce['order']=qs[_0x9edd('0x3e')](_0x17d2f2[_0x9edd('0x35')]['sort']);_0x507cce[_0x9edd('0x3f')]=qs[_0x9edd('0x36')](_[_0x9edd('0x40')](_0x17d2f2[_0x9edd('0x35')],_0x3e5dca['filters']));_0x507cce[_0x9edd('0x3f')]['ListId']=_0x4e1eda['id'];if(_0x17d2f2[_0x9edd('0x35')][_0x9edd('0x41')]){_0x507cce[_0x9edd('0x3f')]=_['merge'](_0x507cce[_0x9edd('0x3f')],{'$or':_[_0x9edd('0x2e')](_0x507cce[_0x9edd('0x38')],function(_0x383cb9){var _0x25626a={};_0x25626a[_0x383cb9]={'$like':'%'+_0x17d2f2[_0x9edd('0x35')][_0x9edd('0x41')]+'%'};return _0x25626a;})});}_0x507cce=_['merge']({},_0x507cce,_0x17d2f2['options']);return db[_0x9edd('0x57')][_0x9edd('0x20')]({'where':_0x507cce[_0x9edd('0x3f')]})[_0x9edd('0x26')](function(_0x1e2126){_0x344692['count']=_0x1e2126;if(_0x17d2f2[_0x9edd('0x35')][_0x9edd('0x4a')]){_0x507cce[_0x9edd('0x44')]=[{'all':!![]}];}return db['Disposition'][_0x9edd('0x58')](_0x507cce);})[_0x9edd('0x26')](function(_0x4b1c12){_0x344692[_0x9edd('0x45')]=_0x4b1c12;return _0x344692;});}})[_0x9edd('0x26')](respondWithFilteredResult(_0x5df1d7,_0x507cce))['catch'](handleError(_0x5df1d7,null));};exports[_0x9edd('0x59')]=function(_0x1e2de6,_0x566be7,_0x3f08ac){return db['CmList']['find']({'where':{'id':_0x1e2de6[_0x9edd('0x48')]['id']}})[_0x9edd('0x26')](handleEntityNotFound(_0x566be7,null))[_0x9edd('0x26')](function(_0x5b56c7){if(_0x5b56c7){return _0x5b56c7[_0x9edd('0x59')](_0x1e2de6[_0x9edd('0x35')]['ids']);}})[_0x9edd('0x26')](respondWithStatusCode(_0x566be7,null))[_0x9edd('0x46')](handleError(_0x566be7,null));};exports[_0x9edd('0x5a')]=function(_0x1ad198,_0x54ac71,_0x5e68db){return db[_0x9edd('0x2f')]['find']({'where':{'id':_0x1ad198[_0x9edd('0x48')]['id']}})[_0x9edd('0x26')](handleEntityNotFound(_0x54ac71,null))[_0x9edd('0x26')](function(_0x3cfd35){if(_0x3cfd35){var _0x195921=[];var _0x4786f8={'success':[],'errors':[]};return db[_0x9edd('0x5b')][_0x9edd('0x54')]()[_0x9edd('0x26')](function(_0x554241){if(_0x1ad198[_0x9edd('0x4d')][_0x9edd('0x5c')]&&_[_0x9edd('0x5d')](_0x1ad198[_0x9edd('0x4d')][_0x9edd('0x5c')])){if(_0x1ad198[_0x9edd('0x4d')][_0x9edd('0x5c')]['length']){_0x1ad198[_0x9edd('0x4d')][_0x9edd('0x5c')]=_0x1ad198['body'][_0x9edd('0x5c')][_0x9edd('0x5e')](';')+';';}else{_0x1ad198['body'][_0x9edd('0x5c')]=null;}}else{_0x1ad198[_0x9edd('0x4d')][_0x9edd('0x5c')]=null;}if(_0x1ad198['body']&&_[_0x9edd('0x5d')](_0x1ad198[_0x9edd('0x4d')])){for(var _0x3f04d3=0x0;_0x3f04d3<_0x1ad198['body']['length'];_0x3f04d3+=0x1){_0x1ad198['body'][_0x3f04d3]['ListId']=_0x1ad198[_0x9edd('0x48')]['id'];_0x195921[_0x9edd('0x5f')](_0x1ad198[_0x9edd('0x4d')][_0x3f04d3]);}return BPromise['each'](_0x195921,function(_0x53e141){return db['CmContact'][_0x9edd('0x4c')](_[_0x9edd('0x60')](_0x53e141,[_0x9edd('0x61'),'id'])||{},{'fields':_[_0x9edd('0x34')](_0x554241),'raw':!![]})[_0x9edd('0x26')](function(_0x18b25e){_0x4786f8[_0x9edd('0x62')][_0x9edd('0x5f')](_0x18b25e[_0x9edd('0x63')]);})[_0x9edd('0x46')](function(_0x2523b5){_0x4786f8[_0x9edd('0x64')]['push']({'data':_0x53e141,'error':_0x2523b5[_0x9edd('0x65')]});});})[_0x9edd('0x26')](function(_0x33b5dc){return _0x4786f8;})[_0x9edd('0x46')](function(_0x104afc){return _0x104afc;});}else{_0x54ac71[_0x9edd('0x1d')](0x190)[_0x9edd('0x1f')]({'message':_0x9edd('0x66')});}});}})['then'](respondWithResult(_0x54ac71,null))['catch'](handleError(_0x54ac71,null));};exports[_0x9edd('0x67')]=function(_0x4ec836,_0x35950b,_0x4a685e){var _0x21c35f;return db[_0x9edd('0x2f')]['find']({'where':{'id':_0x4ec836[_0x9edd('0x48')]['id']},'include':[{'model':db[_0x9edd('0x68')],'as':'CustomFields'}]})[_0x9edd('0x26')](handleEntityNotFound(_0x35950b,null))[_0x9edd('0x26')](function(_0x42d546){if(_0x42d546){_0x21c35f=_0x42d546;return db[_0x9edd('0x5b')][_0x9edd('0x30')];}})['then'](function(_0x33a077){if(_0x33a077){var _0x3ff07e={};var _0x3ec531={};_0x3ec531[_0x9edd('0x33')]=_[_0x9edd('0x69')](_['keys'](_0x33a077),_['map'](_0x21c35f['CustomFields'],function(_0x50316a){return util['format'](_0x9edd('0x6a'),_0x50316a['id']);}));_0x3ec531['query']=_['keys'](_0x4ec836[_0x9edd('0x35')]);_0x3ec531[_0x9edd('0x36')]=_[_0x9edd('0x37')](_0x3ec531[_0x9edd('0x33')],_0x3ec531[_0x9edd('0x35')]);_0x3ff07e[_0x9edd('0x38')]=_[_0x9edd('0x37')](_0x3ec531[_0x9edd('0x33')],qs[_0x9edd('0x39')](_0x4ec836[_0x9edd('0x35')]['fields']));_0x3ff07e[_0x9edd('0x38')]=_0x3ff07e[_0x9edd('0x38')][_0x9edd('0x49')]?_0x3ff07e[_0x9edd('0x38')]:_0x3ec531[_0x9edd('0x33')];if(!_0x4ec836[_0x9edd('0x35')][_0x9edd('0x3a')](_0x9edd('0x3b'))){_0x3ff07e['limit']=qs['limit'](_0x4ec836[_0x9edd('0x35')][_0x9edd('0x3c')]);_0x3ff07e[_0x9edd('0x21')]=qs[_0x9edd('0x21')](_0x4ec836[_0x9edd('0x35')][_0x9edd('0x21')]);}_0x3ff07e[_0x9edd('0x3d')]=qs[_0x9edd('0x3e')](_0x4ec836[_0x9edd('0x35')][_0x9edd('0x3e')]);_0x3ff07e[_0x9edd('0x3f')]=qs[_0x9edd('0x36')](_[_0x9edd('0x40')](_0x4ec836[_0x9edd('0x35')],_0x3ec531['filters']));_0x3ff07e[_0x9edd('0x6b')]=!![];if(_0x4ec836[_0x9edd('0x35')]['filter']){_0x3ff07e[_0x9edd('0x3f')]=_[_0x9edd('0x42')](_0x3ff07e[_0x9edd('0x3f')],{'$or':_[_0x9edd('0x2e')](_0x3ff07e['attributes'],function(_0x3429b6){var _0x398c34={};_0x398c34[_0x3429b6]={'$like':'%'+_0x4ec836[_0x9edd('0x35')][_0x9edd('0x41')]+'%'};return _0x398c34;})});}_0x3ff07e=_[_0x9edd('0x42')]({},_0x3ff07e,_0x4ec836['options']);return _0x21c35f[_0x9edd('0x67')](_0x3ff07e);}})[_0x9edd('0x26')](respondWithResult(_0x35950b,null))[_0x9edd('0x46')](handleError(_0x35950b,null));};exports[_0x9edd('0x6c')]=function(_0xa8d944,_0x59927d,_0x4d0734){var _0x2f8ce1;return db['CmList'][_0x9edd('0x4b')]({'where':{'id':_0xa8d944['params']['id']},'include':[{'model':db[_0x9edd('0x68')],'as':_0x9edd('0x6d')}]})[_0x9edd('0x26')](handleEntityNotFound(_0x59927d,null))[_0x9edd('0x26')](function(_0x2c7245){if(_0x2c7245){_0x2f8ce1=_0x2c7245;return db[_0x9edd('0x5b')]['rawAttributes'];}})[_0x9edd('0x26')](function(_0x33beb7){if(_0x33beb7){var _0x3aae72={};var _0x39d6dd={};_0x39d6dd[_0x9edd('0x33')]=_[_0x9edd('0x69')](_[_0x9edd('0x34')](_0x33beb7),_[_0x9edd('0x2e')](_0x2f8ce1['CustomFields'],function(_0x195088){return util[_0x9edd('0x6e')](_0x9edd('0x6a'),_0x195088['id']);}));_0x39d6dd[_0x9edd('0x35')]=_[_0x9edd('0x34')](_0xa8d944[_0x9edd('0x35')]);_0x39d6dd[_0x9edd('0x36')]=_[_0x9edd('0x37')](_0x39d6dd[_0x9edd('0x33')],_0x39d6dd[_0x9edd('0x35')]);_0x3aae72[_0x9edd('0x38')]=_[_0x9edd('0x37')](_0x39d6dd[_0x9edd('0x33')],qs[_0x9edd('0x39')](_0xa8d944[_0x9edd('0x35')][_0x9edd('0x39')]));_0x3aae72[_0x9edd('0x38')]=_0x3aae72[_0x9edd('0x38')][_0x9edd('0x49')]?_0x3aae72[_0x9edd('0x38')]:_0x39d6dd[_0x9edd('0x33')];if(!_0xa8d944['query'][_0x9edd('0x3a')]('nolimit')){_0x3aae72['limit']=qs[_0x9edd('0x3c')](_0xa8d944[_0x9edd('0x35')][_0x9edd('0x3c')]);_0x3aae72[_0x9edd('0x21')]=qs[_0x9edd('0x21')](_0xa8d944[_0x9edd('0x35')][_0x9edd('0x21')]);}_0x3aae72[_0x9edd('0x3d')]=qs[_0x9edd('0x3e')](_0xa8d944[_0x9edd('0x35')]['sort']);_0x3aae72[_0x9edd('0x3f')]=qs[_0x9edd('0x36')](_['pick'](_0xa8d944['query'],_0x39d6dd[_0x9edd('0x36')]));_0x3aae72[_0x9edd('0x6b')]=!![];if(_0xa8d944[_0x9edd('0x35')][_0x9edd('0x41')]){_0x3aae72['where']=_['merge'](_0x3aae72[_0x9edd('0x3f')],{'$or':_['map'](_0x3aae72[_0x9edd('0x38')],function(_0x24a9d1){var _0x3e2404={};_0x3e2404[_0x24a9d1]={'$like':'%'+_0xa8d944['query']['filter']+'%'};return _0x3e2404;})});}_0x3aae72=_['merge']({},_0x3aae72,_0xa8d944[_0x9edd('0x43')]);return _0x2f8ce1[_0x9edd('0x67')](_0x3aae72);}})[_0x9edd('0x26')](function(_0x5bfbfd){if(!_[_0x9edd('0x6f')](_0x5bfbfd)){var _0x402574=toCsv(_0x5bfbfd);var _0x4f12b9=Date[_0x9edd('0x70')]();fs[_0x9edd('0x71')](util['format']('/tmp/list_%d_%s.csv',_0x2f8ce1['id'],_0x4f12b9),_0x402574);_0x59927d[_0x9edd('0x72')](_0x9edd('0x73'),'attachment;\x20filename='+util[_0x9edd('0x6e')](_0x9edd('0x74'),_0x2f8ce1['id'],_0x4f12b9));_0x59927d['setHeader'](_0x9edd('0x75'),'text/csv');return _0x59927d[_0x9edd('0x76')](util[_0x9edd('0x6e')](_0x9edd('0x77'),_0x2f8ce1['id'],_0x4f12b9));}else{return _0x59927d[_0x9edd('0x1c')](0xcc);}})[_0x9edd('0x46')](handleError(_0x59927d,null));};exports[_0x9edd('0x78')]=function(_0x58bc3c,_0x2fe810,_0x22aa2b){var _0x68047e;delete _0x58bc3c['body']['id'];return db[_0x9edd('0x2f')]['findOne']({'where':{'id':_0x58bc3c[_0x9edd('0x48')]['id']}})[_0x9edd('0x26')](handleEntityNotFound(_0x2fe810,null))[_0x9edd('0x26')](function(_0x41b0ea){if(_0x41b0ea){return db['sequelize']['transaction'](function(_0x4e9242){return db[_0x9edd('0x68')][_0x9edd('0x4c')](_0x58bc3c[_0x9edd('0x4d')],{'transaction':_0x4e9242})['then'](function(_0x41a761){_0x68047e=_0x41a761;return _0x41b0ea[_0x9edd('0x79')](_0x41a761,{'transaction':_0x4e9242});})[_0x9edd('0x26')](function(){var _0xb66eaf={'type':db[_0x9edd('0x7a')][_0x9edd('0x7b')],'transaction':_0x4e9242};switch(_0x58bc3c['body']['type']){case _0x9edd('0x7c'):_0xb66eaf[_0x9edd('0x32')]=db[_0x9edd('0x7a')]['TEXT'];break;case _0x9edd('0x7d'):_0xb66eaf[_0x9edd('0x32')]=db[_0x9edd('0x7a')][_0x9edd('0x7e')];break;case'switch':_0xb66eaf[_0x9edd('0x32')]=db['Sequelize'][_0x9edd('0x7f')];_0xb66eaf[_0x9edd('0x80')]=![];break;default:}return db[_0x9edd('0x81')][_0x9edd('0x82')][_0x9edd('0x83')]('cm_contacts',util[_0x9edd('0x6e')]('cf_%s',_0x68047e['id']),_0xb66eaf);})[_0x9edd('0x26')](function(){return _0x68047e;});});}})['then'](respondWithResult(_0x2fe810,null))[_0x9edd('0x46')](handleError(_0x2fe810,null));};exports['getCustomFields']=function(_0x363c5c,_0x96e3d7,_0x3bc495){var _0x575377={};var _0x244dce={};var _0x7512ea;var _0x1c5038;return db[_0x9edd('0x2f')][_0x9edd('0x84')]({'where':{'id':_0x363c5c[_0x9edd('0x48')]['id']}})[_0x9edd('0x26')](handleEntityNotFound(_0x96e3d7,null))[_0x9edd('0x26')](function(_0x365b27){if(_0x365b27){_0x7512ea=_0x365b27;_0x244dce[_0x9edd('0x33')]=_[_0x9edd('0x34')](db[_0x9edd('0x68')][_0x9edd('0x30')]);_0x244dce[_0x9edd('0x35')]=_[_0x9edd('0x34')](_0x363c5c[_0x9edd('0x35')]);_0x244dce[_0x9edd('0x36')]=_[_0x9edd('0x37')](_0x244dce[_0x9edd('0x33')],_0x244dce[_0x9edd('0x35')]);_0x575377[_0x9edd('0x38')]=_[_0x9edd('0x37')](_0x244dce['model'],qs[_0x9edd('0x39')](_0x363c5c['query'][_0x9edd('0x39')]));_0x575377[_0x9edd('0x38')]=_0x575377[_0x9edd('0x38')][_0x9edd('0x49')]?_0x575377[_0x9edd('0x38')]:_0x244dce['model'];_0x575377[_0x9edd('0x3d')]=qs['sort'](_0x363c5c[_0x9edd('0x35')][_0x9edd('0x3e')]);_0x575377[_0x9edd('0x3f')]=qs[_0x9edd('0x36')](_[_0x9edd('0x40')](_0x363c5c[_0x9edd('0x35')],_0x244dce['filters']));_0x575377[_0x9edd('0x3f')]=_[_0x9edd('0x42')](_0x575377['where'],{'$or':[{'ListId':_0x365b27['id']},{'ListId':null}]});if(_0x363c5c['query']['filter']){_0x575377['where']=_[_0x9edd('0x42')](_0x575377[_0x9edd('0x3f')],{'$or':_[_0x9edd('0x2e')](_0x575377[_0x9edd('0x38')],function(_0x239774){var _0x229a92={};_0x229a92[_0x239774]={'$like':'%'+_0x363c5c[_0x9edd('0x35')][_0x9edd('0x41')]+'%'};return _0x229a92;})});}_0x575377=_[_0x9edd('0x42')]({},_0x575377,_0x363c5c[_0x9edd('0x43')]);return db['CmCustomField'][_0x9edd('0x85')](_0x575377);}})['then'](respondWithResult(_0x96e3d7,null))['catch'](handleError(_0x96e3d7,null));};exports[_0x9edd('0x86')]=function(_0x2dafd2,_0x35e9b9,_0x42a142){return db[_0x9edd('0x2f')]['find']({'where':{'id':_0x2dafd2[_0x9edd('0x48')]['id']}})[_0x9edd('0x26')](handleEntityNotFound(_0x35e9b9,null))[_0x9edd('0x26')](function(_0x181469){if(_0x181469){return _0x181469['addAgents'](_0x2dafd2[_0x9edd('0x4d')][_0x9edd('0x61')],_[_0x9edd('0x60')](_0x2dafd2[_0x9edd('0x4d')],[_0x9edd('0x61'),'id'])||{})[_0x9edd('0x87')](function(_0x55052b){for(var _0x9ff2d3=0x0;_0x9ff2d3<_0x2dafd2[_0x9edd('0x4d')][_0x9edd('0x61')][_0x9edd('0x49')];_0x9ff2d3+=0x1){socket['emit'](_0x9edd('0x88'),{'UserId':_0x2dafd2[_0x9edd('0x4d')][_0x9edd('0x61')][_0x9ff2d3],'CmListId':_0x2dafd2[_0x9edd('0x48')]['id']});}return _0x55052b;});}})[_0x9edd('0x26')](respondWithResult(_0x35e9b9,null))[_0x9edd('0x46')](handleError(_0x35e9b9,null));};exports[_0x9edd('0x89')]=function(_0x39e3b3,_0x4a3955,_0x4a19a0){return db['CmList'][_0x9edd('0x4b')]({'where':{'id':_0x39e3b3[_0x9edd('0x48')]['id']}})[_0x9edd('0x26')](handleEntityNotFound(_0x4a3955,null))[_0x9edd('0x26')](function(_0x223c42){if(_0x223c42){return _0x223c42[_0x9edd('0x89')](_0x39e3b3[_0x9edd('0x35')][_0x9edd('0x61')])[_0x9edd('0x26')](function(){if(_[_0x9edd('0x5d')](_0x39e3b3['query'][_0x9edd('0x61')])){for(var _0x56dc7e=0x0;_0x56dc7e<_0x39e3b3['query'][_0x9edd('0x61')][_0x9edd('0x49')];_0x56dc7e+=0x1){socket[_0x9edd('0x8a')]('userCmList:remove',{'UserId':Number(_0x39e3b3['query']['ids'][_0x56dc7e]),'CmListId':Number(_0x39e3b3['params']['id'])});}}else{socket['emit'](_0x9edd('0x8b'),{'UserId':Number(_0x39e3b3[_0x9edd('0x35')][_0x9edd('0x61')]),'CmListId':Number(_0x39e3b3['params']['id'])});}});}})[_0x9edd('0x26')](respondWithStatusCode(_0x4a3955,null))[_0x9edd('0x46')](handleError(_0x4a3955,null));};exports[_0x9edd('0x8c')]=function(_0x557156,_0x2c2f00,_0x4afe0b){var _0x16a1c8={};var _0x1a2376={};var _0xc84fb7;var _0x259d33;return db['CmList'][_0x9edd('0x84')]({'where':{'id':_0x557156[_0x9edd('0x48')]['id']}})['then'](handleEntityNotFound(_0x2c2f00,null))[_0x9edd('0x26')](function(_0x36e825){if(_0x36e825){_0xc84fb7=_0x36e825;_0x1a2376[_0x9edd('0x33')]=_[_0x9edd('0x34')](db['User'][_0x9edd('0x30')]);_0x1a2376[_0x9edd('0x35')]=_[_0x9edd('0x34')](_0x557156[_0x9edd('0x35')]);_0x1a2376[_0x9edd('0x36')]=_[_0x9edd('0x37')](_0x1a2376[_0x9edd('0x33')],_0x1a2376['query']);_0x16a1c8[_0x9edd('0x38')]=_['intersection'](_0x1a2376[_0x9edd('0x33')],qs[_0x9edd('0x39')](_0x557156['query'][_0x9edd('0x39')]));_0x16a1c8[_0x9edd('0x38')]=_0x16a1c8[_0x9edd('0x38')]['length']?_0x16a1c8[_0x9edd('0x38')]:_0x1a2376[_0x9edd('0x33')];_0x16a1c8[_0x9edd('0x3d')]=qs['sort'](_0x557156[_0x9edd('0x35')]['sort']);_0x16a1c8[_0x9edd('0x3f')]=qs[_0x9edd('0x36')](_[_0x9edd('0x40')](_0x557156[_0x9edd('0x35')],_0x1a2376['filters']));if(_0x557156['query'][_0x9edd('0x41')]){_0x16a1c8[_0x9edd('0x3f')]=_[_0x9edd('0x42')](_0x16a1c8[_0x9edd('0x3f')],{'$or':_[_0x9edd('0x2e')](_0x16a1c8['attributes'],function(_0x1a1938){var _0x235762={};_0x235762[_0x1a1938]={'$like':'%'+_0x557156[_0x9edd('0x35')][_0x9edd('0x41')]+'%'};return _0x235762;})});}_0x16a1c8=_[_0x9edd('0x42')]({},_0x16a1c8,_0x557156[_0x9edd('0x43')]);return _0xc84fb7[_0x9edd('0x8c')](_0x16a1c8);}})[_0x9edd('0x26')](function(_0x3173fa){if(_0x3173fa){_0x259d33=_0x3173fa[_0x9edd('0x49')];if(!_0x557156[_0x9edd('0x35')][_0x9edd('0x3a')](_0x9edd('0x3b'))){_0x16a1c8['limit']=qs[_0x9edd('0x3c')](_0x557156[_0x9edd('0x35')][_0x9edd('0x3c')]);_0x16a1c8[_0x9edd('0x21')]=qs['offset'](_0x557156[_0x9edd('0x35')][_0x9edd('0x21')]);}return _0xc84fb7[_0x9edd('0x8c')](_0x16a1c8);}})['then'](function(_0x910adf){if(_0x910adf){return _0x910adf?{'count':_0x259d33,'rows':_0x910adf}:null;}})['then'](respondWithResult(_0x2c2f00,null))['catch'](handleError(_0x2c2f00,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