Built motion from commit 85328c08.|2.5.50
[motion2.git] / server / api / cmList / cmList.controller.js
index d62d34d..ca4a07d 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xa820=['to-csv','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/environment','../../mysqldb','redis','defaults','localhost','./cmList.socket','register','status','end','json','count','offset','limit','set','Content-Range','reject','update','then','get','Lists','UserProfileResource','destroy','sendStatus','error','stack','name','index','map','CmList','rawAttributes','type','key','model','keys','filters','intersection','attributes','query','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','options','includeAll','include','findAll','rows','catch','find','create','body','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','user','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','params','describe','addDisposition','ListId','Disposition','getDispositions','findOne','removeDispositions','addContacts','CmContact','tags','isArray','push','each','omit','ids','success','dataValues','message','Malformed\x20request\x20syntax','CmCustomField','concat','CustomFields','format','cf_%d','raw','getContactsCsv','getContacts','isEmpty','now','writeFileSync','/tmp/list_%d_%s.csv','setHeader','attachment;\x20filename=','list_%d_%s.csv','text/csv','download','addCustomField','sequelize','transaction','TEXT','text','Sequelize','number','switch','BOOLEAN','defaultValue','queryInterface','addColumn','getCustomFields','findAndCountAll','addAgents','spread','emit','removeAgents','userCmList:remove','getAgents','User','html-pdf','eml-format','rimraf','zip-dir','request-promise','moment','bluebird','mustache','util','path','lodash','squel','crypto','jsforce','desk.js'];(function(_0x1d80be,_0x3a60ff){var _0xf9a4f3=function(_0x5b8a08){while(--_0x5b8a08){_0x1d80be['push'](_0x1d80be['shift']());}};_0xf9a4f3(++_0x3a60ff);}(_0xa820,0x113));var _0x0a82=function(_0xb0de07,_0x3ca2a0){_0xb0de07=_0xb0de07-0x0;var _0x4633d8=_0xa820[_0xb0de07];return _0x4633d8;};'use strict';var pdf=require(_0x0a82('0x0'));var emlformat=require(_0x0a82('0x1'));var rimraf=require(_0x0a82('0x2'));var zipdir=require(_0x0a82('0x3'));var jsonpatch=require('fast-json-patch');var rp=require(_0x0a82('0x4'));var moment=require(_0x0a82('0x5'));var BPromise=require(_0x0a82('0x6'));var Mustache=require(_0x0a82('0x7'));var util=require(_0x0a82('0x8'));var path=require(_0x0a82('0x9'));var sox=require('sox');var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var _=require(_0x0a82('0xa'));var squel=require(_0x0a82('0xb'));var crypto=require(_0x0a82('0xc'));var jsforce=require(_0x0a82('0xd'));var deskjs=require(_0x0a82('0xe'));var toCsv=require(_0x0a82('0xf'));var querystring=require('querystring');var Papa=require(_0x0a82('0x10'));var Redis=require(_0x0a82('0x11'));var authService=require(_0x0a82('0x12'));var qs=require(_0x0a82('0x13'));var as=require(_0x0a82('0x14'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x0a82('0x15'))(_0x0a82('0x16'));var utils=require('../../config/utils');var config=require(_0x0a82('0x17'));var db=require(_0x0a82('0x18'))['db'];config[_0x0a82('0x19')]=_[_0x0a82('0x1a')](config[_0x0a82('0x19')],{'host':_0x0a82('0x1b'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require(_0x0a82('0x1c'))[_0x0a82('0x1d')](socket);function respondWithStatusCode(_0x52ac1a,_0x38ce0e){_0x38ce0e=_0x38ce0e||0xcc;return function(_0x2e08a2){if(_0x2e08a2){return _0x52ac1a['sendStatus'](_0x38ce0e);}return _0x52ac1a[_0x0a82('0x1e')](_0x38ce0e)[_0x0a82('0x1f')]();};}function respondWithResult(_0x43d65a,_0x45d5f3){_0x45d5f3=_0x45d5f3||0xc8;return function(_0x45da07){if(_0x45da07){return _0x43d65a[_0x0a82('0x1e')](_0x45d5f3)[_0x0a82('0x20')](_0x45da07);}};}function respondWithFilteredResult(_0x38880f,_0x471dff){return function(_0x289497){if(_0x289497){var _0x57db98=_0x289497[_0x0a82('0x21')],_0x40bf22=_0x471dff[_0x0a82('0x22')],_0xe0712f=_0x471dff[_0x0a82('0x22')]+_0x471dff[_0x0a82('0x23')],_0x410ff2;if(_0xe0712f>=_0x57db98){_0xe0712f=_0x57db98;_0x410ff2=0xc8;}else{_0x410ff2=0xce;}_0x38880f[_0x0a82('0x1e')](_0x410ff2);return _0x38880f[_0x0a82('0x24')](_0x0a82('0x25'),_0x40bf22+'-'+_0xe0712f+'/'+_0x57db98)[_0x0a82('0x20')](_0x289497);}return null;};}function patchUpdates(_0x37e11f){return function(_0x5989ff){try{jsonpatch['apply'](_0x5989ff,_0x37e11f,!![]);}catch(_0x509cf3){return BPromise[_0x0a82('0x26')](_0x509cf3);}return _0x5989ff['save']();};}function saveUpdates(_0x509623,_0x9f734d){return function(_0x3412a8){if(_0x3412a8){return _0x3412a8[_0x0a82('0x27')](_0x509623)['then'](function(_0x79f115){return _0x79f115;});}return null;};}function removeEntity(_0x37428e,_0x309788){return function(_0x53be12){if(_0x53be12){return _0x53be12['destroy']()[_0x0a82('0x28')](function(){var _0x4442f5=_0x53be12[_0x0a82('0x29')]({'plain':!![]});var _0x401bc4=_0x0a82('0x2a');return db[_0x0a82('0x2b')][_0x0a82('0x2c')]({'where':{'type':_0x401bc4,'resourceId':_0x4442f5['id']}})[_0x0a82('0x28')](function(){return _0x53be12;});})[_0x0a82('0x28')](function(){_0x37428e['status'](0xcc)[_0x0a82('0x1f')]();});}};}function handleEntityNotFound(_0x30b119,_0x26859e){return function(_0x27c2d0){if(!_0x27c2d0){_0x30b119[_0x0a82('0x2d')](0x194);}return _0x27c2d0;};}function handleError(_0x5778ff,_0x147e3a){_0x147e3a=_0x147e3a||0x1f4;return function(_0x3b6cdd){logger[_0x0a82('0x2e')](_0x3b6cdd[_0x0a82('0x2f')]);if(_0x3b6cdd[_0x0a82('0x30')]){delete _0x3b6cdd[_0x0a82('0x30')];}_0x5778ff[_0x0a82('0x1e')](_0x147e3a)['send'](_0x3b6cdd);};}exports[_0x0a82('0x31')]=function(_0x5dac86,_0x5776bc){var _0x5eeb7d={},_0x9f3e25={},_0x13fb17={'count':0x0,'rows':[]};var _0x40c1dd=_[_0x0a82('0x32')](db[_0x0a82('0x33')][_0x0a82('0x34')],function(_0xb2cd17){return{'name':_0xb2cd17['fieldName'],'type':_0xb2cd17[_0x0a82('0x35')][_0x0a82('0x36')]};});_0x9f3e25[_0x0a82('0x37')]=_[_0x0a82('0x32')](_0x40c1dd,_0x0a82('0x30'));_0x9f3e25['query']=_[_0x0a82('0x38')](_0x5dac86['query']);_0x9f3e25[_0x0a82('0x39')]=_[_0x0a82('0x3a')](_0x9f3e25[_0x0a82('0x37')],_0x9f3e25['query']);_0x5eeb7d[_0x0a82('0x3b')]=_[_0x0a82('0x3a')](_0x9f3e25['model'],qs['fields'](_0x5dac86[_0x0a82('0x3c')][_0x0a82('0x3d')]));_0x5eeb7d[_0x0a82('0x3b')]=_0x5eeb7d['attributes'][_0x0a82('0x3e')]?_0x5eeb7d[_0x0a82('0x3b')]:_0x9f3e25['model'];if(!_0x5dac86[_0x0a82('0x3c')][_0x0a82('0x3f')](_0x0a82('0x40'))){_0x5eeb7d[_0x0a82('0x23')]=qs[_0x0a82('0x23')](_0x5dac86[_0x0a82('0x3c')][_0x0a82('0x23')]);_0x5eeb7d[_0x0a82('0x22')]=qs[_0x0a82('0x22')](_0x5dac86['query'][_0x0a82('0x22')]);}_0x5eeb7d[_0x0a82('0x41')]=qs['sort'](_0x5dac86[_0x0a82('0x3c')][_0x0a82('0x42')]);_0x5eeb7d[_0x0a82('0x43')]=qs['filters'](_[_0x0a82('0x44')](_0x5dac86['query'],_0x9f3e25['filters']),_0x40c1dd);if(_0x5dac86[_0x0a82('0x3c')][_0x0a82('0x45')]){_0x5eeb7d[_0x0a82('0x43')]=_['merge'](_0x5eeb7d['where'],{'$or':_[_0x0a82('0x32')](_0x40c1dd,function(_0x396d98){if(_0x396d98[_0x0a82('0x35')]!=='VIRTUAL'){var _0x241b58={};_0x241b58[_0x396d98['name']]={'$like':'%'+_0x5dac86['query'][_0x0a82('0x45')]+'%'};return _0x241b58;}})});}_0x5eeb7d=_[_0x0a82('0x46')]({},_0x5eeb7d,_0x5dac86[_0x0a82('0x47')]);var _0x4c83f4={'where':_0x5eeb7d[_0x0a82('0x43')]};return db[_0x0a82('0x33')][_0x0a82('0x21')](_0x4c83f4)[_0x0a82('0x28')](function(_0x4941a9){_0x13fb17[_0x0a82('0x21')]=_0x4941a9;if(_0x5dac86[_0x0a82('0x3c')][_0x0a82('0x48')]){_0x5eeb7d[_0x0a82('0x49')]=[{'all':!![]}];}return db[_0x0a82('0x33')][_0x0a82('0x4a')](_0x5eeb7d);})[_0x0a82('0x28')](function(_0x46ef82){_0x13fb17[_0x0a82('0x4b')]=_0x46ef82;return _0x13fb17;})['then'](respondWithFilteredResult(_0x5776bc,_0x5eeb7d))[_0x0a82('0x4c')](handleError(_0x5776bc,null));};exports['show']=function(_0x30f1e9,_0x5238b4){var _0x1121a9={'raw':![],'where':{'id':_0x30f1e9['params']['id']}},_0x5b40f4={};_0x5b40f4[_0x0a82('0x37')]=_[_0x0a82('0x38')](db[_0x0a82('0x33')][_0x0a82('0x34')]);_0x5b40f4[_0x0a82('0x3c')]=_[_0x0a82('0x38')](_0x30f1e9[_0x0a82('0x3c')]);_0x5b40f4[_0x0a82('0x39')]=_[_0x0a82('0x3a')](_0x5b40f4[_0x0a82('0x37')],_0x5b40f4[_0x0a82('0x3c')]);_0x1121a9[_0x0a82('0x3b')]=_[_0x0a82('0x3a')](_0x5b40f4[_0x0a82('0x37')],qs[_0x0a82('0x3d')](_0x30f1e9[_0x0a82('0x3c')]['fields']));_0x1121a9[_0x0a82('0x3b')]=_0x1121a9['attributes'][_0x0a82('0x3e')]?_0x1121a9[_0x0a82('0x3b')]:_0x5b40f4['model'];if(_0x30f1e9[_0x0a82('0x3c')][_0x0a82('0x48')]){_0x1121a9[_0x0a82('0x49')]=[{'all':!![]}];}_0x1121a9=_[_0x0a82('0x46')]({},_0x1121a9,_0x30f1e9[_0x0a82('0x47')]);return db[_0x0a82('0x33')][_0x0a82('0x4d')](_0x1121a9)[_0x0a82('0x28')](handleEntityNotFound(_0x5238b4,null))[_0x0a82('0x28')](respondWithResult(_0x5238b4,null))['catch'](handleError(_0x5238b4,null));};exports['create']=function(_0x4096cc,_0x34ffd9){return db[_0x0a82('0x33')][_0x0a82('0x4e')](_0x4096cc[_0x0a82('0x4f')],{})[_0x0a82('0x28')](function(_0x3483c6){var _0x170f47=_0x4096cc['user'][_0x0a82('0x29')]({'plain':!![]});if(!_0x170f47)throw new Error(_0x0a82('0x50'));if(_0x170f47[_0x0a82('0x51')]===_0x0a82('0x52')){var _0x3310cb=_0x3483c6[_0x0a82('0x29')]({'plain':!![]});var _0xa0d93c=_0x0a82('0x2a');return db[_0x0a82('0x53')][_0x0a82('0x4d')]({'where':{'name':_0xa0d93c,'userProfileId':_0x170f47[_0x0a82('0x54')]},'raw':!![]})[_0x0a82('0x28')](function(_0x199f1b){if(_0x199f1b&&_0x199f1b[_0x0a82('0x55')]===0x0){return db[_0x0a82('0x2b')][_0x0a82('0x4e')]({'name':_0x3310cb['name'],'resourceId':_0x3310cb['id'],'type':_0x199f1b[_0x0a82('0x30')],'sectionId':_0x199f1b['id']},{})['then'](function(){return _0x3483c6;});}else{return _0x3483c6;}})['catch'](function(_0x21bb1b){logger[_0x0a82('0x2e')](_0x0a82('0x56'),_0x21bb1b);throw _0x21bb1b;});}return _0x3483c6;})[_0x0a82('0x28')](respondWithResult(_0x34ffd9,0xc9))[_0x0a82('0x4c')](handleError(_0x34ffd9,null));};exports[_0x0a82('0x27')]=function(_0x408934,_0x45e2c3){if(_0x408934['body']['id']){delete _0x408934[_0x0a82('0x4f')]['id'];}return db[_0x0a82('0x33')][_0x0a82('0x4d')]({'where':{'id':_0x408934[_0x0a82('0x57')]['id']}})[_0x0a82('0x28')](handleEntityNotFound(_0x45e2c3,null))[_0x0a82('0x28')](saveUpdates(_0x408934['body'],null))[_0x0a82('0x28')](respondWithResult(_0x45e2c3,null))[_0x0a82('0x4c')](handleError(_0x45e2c3,null));};exports[_0x0a82('0x2c')]=function(_0x29bce0,_0x31c144){return db[_0x0a82('0x33')][_0x0a82('0x4d')]({'where':{'id':_0x29bce0[_0x0a82('0x57')]['id']}})[_0x0a82('0x28')](handleEntityNotFound(_0x31c144,null))[_0x0a82('0x28')](removeEntity(_0x31c144,null))['catch'](handleError(_0x31c144,null));};exports[_0x0a82('0x58')]=function(_0x41bf43,_0x1c3524){return db['CmList'][_0x0a82('0x58')]()['then'](respondWithResult(_0x1c3524,null))[_0x0a82('0x4c')](handleError(_0x1c3524,null));};exports[_0x0a82('0x59')]=function(_0x249f5c,_0x10427d,_0x300871){if(_0x249f5c[_0x0a82('0x4f')]['id']){delete _0x249f5c[_0x0a82('0x4f')]['id'];}return db[_0x0a82('0x33')][_0x0a82('0x4d')]({'where':{'id':_0x249f5c[_0x0a82('0x57')]['id']}})[_0x0a82('0x28')](handleEntityNotFound(_0x10427d,null))[_0x0a82('0x28')](function(_0x305eed){if(_0x305eed){_0x249f5c['body'][_0x0a82('0x5a')]=_0x305eed['id'];return db[_0x0a82('0x5b')][_0x0a82('0x4e')](_0x249f5c[_0x0a82('0x4f')]);}})[_0x0a82('0x28')](respondWithResult(_0x10427d,null))['catch'](handleError(_0x10427d,null));};exports[_0x0a82('0x5c')]=function(_0x253815,_0x389974,_0x54ab6c){var _0x5dde01={'raw':![],'where':{}};var _0x577aae={};var _0x25fd81={'count':0x0,'rows':[]};return db[_0x0a82('0x33')][_0x0a82('0x5d')]({'where':{'id':_0x253815[_0x0a82('0x57')]['id']}})['then'](handleEntityNotFound(_0x389974,null))[_0x0a82('0x28')](function(_0x403f33){if(_0x403f33){_0x577aae[_0x0a82('0x37')]=_['keys'](db[_0x0a82('0x5b')]['rawAttributes']);_0x577aae[_0x0a82('0x3c')]=_['keys'](_0x253815[_0x0a82('0x3c')]);_0x577aae[_0x0a82('0x39')]=_[_0x0a82('0x3a')](_0x577aae[_0x0a82('0x37')],_0x577aae[_0x0a82('0x3c')]);_0x5dde01[_0x0a82('0x3b')]=_['intersection'](_0x577aae['model'],qs['fields'](_0x253815[_0x0a82('0x3c')][_0x0a82('0x3d')]));_0x5dde01[_0x0a82('0x3b')]=_0x5dde01[_0x0a82('0x3b')][_0x0a82('0x3e')]?_0x5dde01[_0x0a82('0x3b')]:_0x577aae[_0x0a82('0x37')];if(!_0x253815[_0x0a82('0x3c')][_0x0a82('0x3f')]('nolimit')){_0x5dde01['limit']=qs['limit'](_0x253815[_0x0a82('0x3c')]['limit']);_0x5dde01[_0x0a82('0x22')]=qs[_0x0a82('0x22')](_0x253815[_0x0a82('0x3c')]['offset']);}_0x5dde01[_0x0a82('0x41')]=qs[_0x0a82('0x42')](_0x253815[_0x0a82('0x3c')][_0x0a82('0x42')]);_0x5dde01['where']=qs[_0x0a82('0x39')](_['pick'](_0x253815[_0x0a82('0x3c')],_0x577aae[_0x0a82('0x39')]));_0x5dde01[_0x0a82('0x43')][_0x0a82('0x5a')]=_0x403f33['id'];if(_0x253815[_0x0a82('0x3c')]['filter']){_0x5dde01[_0x0a82('0x43')]=_[_0x0a82('0x46')](_0x5dde01['where'],{'$or':_[_0x0a82('0x32')](_0x5dde01[_0x0a82('0x3b')],function(_0x5162a1){var _0x3e90b7={};_0x3e90b7[_0x5162a1]={'$like':'%'+_0x253815['query'][_0x0a82('0x45')]+'%'};return _0x3e90b7;})});}_0x5dde01=_['merge']({},_0x5dde01,_0x253815[_0x0a82('0x47')]);return db[_0x0a82('0x5b')][_0x0a82('0x21')]({'where':_0x5dde01[_0x0a82('0x43')]})[_0x0a82('0x28')](function(_0x258e4e){_0x25fd81[_0x0a82('0x21')]=_0x258e4e;if(_0x253815[_0x0a82('0x3c')][_0x0a82('0x48')]){_0x5dde01[_0x0a82('0x49')]=[{'all':!![]}];}return db['Disposition'][_0x0a82('0x4a')](_0x5dde01);})[_0x0a82('0x28')](function(_0x5213ac){_0x25fd81[_0x0a82('0x4b')]=_0x5213ac;return _0x25fd81;});}})[_0x0a82('0x28')](respondWithFilteredResult(_0x389974,_0x5dde01))[_0x0a82('0x4c')](handleError(_0x389974,null));};exports['removeDispositions']=function(_0x28895d,_0x4046e4,_0x2cf584){return db['CmList'][_0x0a82('0x4d')]({'where':{'id':_0x28895d[_0x0a82('0x57')]['id']}})[_0x0a82('0x28')](handleEntityNotFound(_0x4046e4,null))['then'](function(_0x1c50df){if(_0x1c50df){return _0x1c50df[_0x0a82('0x5e')](_0x28895d[_0x0a82('0x3c')]['ids']);}})['then'](respondWithStatusCode(_0x4046e4,null))[_0x0a82('0x4c')](handleError(_0x4046e4,null));};exports[_0x0a82('0x5f')]=function(_0x322aad,_0x371035,_0x3ac331){return db['CmList']['find']({'where':{'id':_0x322aad[_0x0a82('0x57')]['id']}})[_0x0a82('0x28')](handleEntityNotFound(_0x371035,null))[_0x0a82('0x28')](function(_0x5f3cfc){if(_0x5f3cfc){var _0x1dd262=[];var _0x223c14={'success':[],'errors':[]};return db[_0x0a82('0x60')]['describe']()[_0x0a82('0x28')](function(_0x2d4462){if(_0x322aad['body'][_0x0a82('0x61')]&&_['isArray'](_0x322aad[_0x0a82('0x4f')]['tags'])){if(_0x322aad[_0x0a82('0x4f')][_0x0a82('0x61')][_0x0a82('0x3e')]){_0x322aad['body'][_0x0a82('0x61')]=_0x322aad[_0x0a82('0x4f')][_0x0a82('0x61')]['join'](';')+';';}else{_0x322aad['body']['tags']=null;}}else{_0x322aad[_0x0a82('0x4f')][_0x0a82('0x61')]=null;}if(_0x322aad['body']&&_[_0x0a82('0x62')](_0x322aad[_0x0a82('0x4f')])){for(var _0x59959d=0x0;_0x59959d<_0x322aad[_0x0a82('0x4f')][_0x0a82('0x3e')];_0x59959d+=0x1){_0x322aad[_0x0a82('0x4f')][_0x59959d][_0x0a82('0x5a')]=_0x322aad[_0x0a82('0x57')]['id'];_0x1dd262[_0x0a82('0x63')](_0x322aad[_0x0a82('0x4f')][_0x59959d]);}return BPromise[_0x0a82('0x64')](_0x1dd262,function(_0x1ac7ef){return db['CmContact']['create'](_[_0x0a82('0x65')](_0x1ac7ef,[_0x0a82('0x66'),'id'])||{},{'fields':_['keys'](_0x2d4462),'raw':!![]})[_0x0a82('0x28')](function(_0x20b26e){_0x223c14[_0x0a82('0x67')][_0x0a82('0x63')](_0x20b26e[_0x0a82('0x68')]);})[_0x0a82('0x4c')](function(_0xb79141){_0x223c14['errors'][_0x0a82('0x63')]({'data':_0x1ac7ef,'error':_0xb79141[_0x0a82('0x69')]});});})[_0x0a82('0x28')](function(_0x1437e6){return _0x223c14;})['catch'](function(_0x232847){return _0x232847;});}else{_0x371035[_0x0a82('0x1e')](0x190)['json']({'message':_0x0a82('0x6a')});}});}})[_0x0a82('0x28')](respondWithResult(_0x371035,null))['catch'](handleError(_0x371035,null));};exports['getContacts']=function(_0x22d4a0,_0x30d1f9,_0x218316){var _0x135bb8;return db[_0x0a82('0x33')]['find']({'where':{'id':_0x22d4a0[_0x0a82('0x57')]['id']},'include':[{'model':db[_0x0a82('0x6b')],'as':'CustomFields'}]})['then'](handleEntityNotFound(_0x30d1f9,null))[_0x0a82('0x28')](function(_0x346db7){if(_0x346db7){_0x135bb8=_0x346db7;return db[_0x0a82('0x60')][_0x0a82('0x34')];}})[_0x0a82('0x28')](function(_0x63b23e){if(_0x63b23e){var _0x5c5458={};var _0x3cd466={};_0x3cd466[_0x0a82('0x37')]=_[_0x0a82('0x6c')](_[_0x0a82('0x38')](_0x63b23e),_['map'](_0x135bb8[_0x0a82('0x6d')],function(_0x45a9ef){return util[_0x0a82('0x6e')](_0x0a82('0x6f'),_0x45a9ef['id']);}));_0x3cd466[_0x0a82('0x3c')]=_[_0x0a82('0x38')](_0x22d4a0[_0x0a82('0x3c')]);_0x3cd466[_0x0a82('0x39')]=_['intersection'](_0x3cd466[_0x0a82('0x37')],_0x3cd466['query']);_0x5c5458['attributes']=_['intersection'](_0x3cd466['model'],qs[_0x0a82('0x3d')](_0x22d4a0['query'][_0x0a82('0x3d')]));_0x5c5458[_0x0a82('0x3b')]=_0x5c5458[_0x0a82('0x3b')][_0x0a82('0x3e')]?_0x5c5458['attributes']:_0x3cd466['model'];if(!_0x22d4a0[_0x0a82('0x3c')][_0x0a82('0x3f')](_0x0a82('0x40'))){_0x5c5458[_0x0a82('0x23')]=qs['limit'](_0x22d4a0[_0x0a82('0x3c')][_0x0a82('0x23')]);_0x5c5458[_0x0a82('0x22')]=qs[_0x0a82('0x22')](_0x22d4a0['query'][_0x0a82('0x22')]);}_0x5c5458[_0x0a82('0x41')]=qs[_0x0a82('0x42')](_0x22d4a0[_0x0a82('0x3c')]['sort']);_0x5c5458[_0x0a82('0x43')]=qs[_0x0a82('0x39')](_[_0x0a82('0x44')](_0x22d4a0[_0x0a82('0x3c')],_0x3cd466['filters']));_0x5c5458[_0x0a82('0x70')]=!![];if(_0x22d4a0[_0x0a82('0x3c')]['filter']){_0x5c5458['where']=_[_0x0a82('0x46')](_0x5c5458['where'],{'$or':_['map'](_0x5c5458[_0x0a82('0x3b')],function(_0x136088){var _0x28d7fd={};_0x28d7fd[_0x136088]={'$like':'%'+_0x22d4a0['query'][_0x0a82('0x45')]+'%'};return _0x28d7fd;})});}_0x5c5458=_['merge']({},_0x5c5458,_0x22d4a0[_0x0a82('0x47')]);return _0x135bb8['getContacts'](_0x5c5458);}})[_0x0a82('0x28')](respondWithResult(_0x30d1f9,null))[_0x0a82('0x4c')](handleError(_0x30d1f9,null));};exports[_0x0a82('0x71')]=function(_0x436f12,_0x53abf3,_0x38886f){var _0x318aa9;return db[_0x0a82('0x33')][_0x0a82('0x4d')]({'where':{'id':_0x436f12[_0x0a82('0x57')]['id']},'include':[{'model':db[_0x0a82('0x6b')],'as':'CustomFields'}]})[_0x0a82('0x28')](handleEntityNotFound(_0x53abf3,null))[_0x0a82('0x28')](function(_0x2985f4){if(_0x2985f4){_0x318aa9=_0x2985f4;return db[_0x0a82('0x60')][_0x0a82('0x34')];}})[_0x0a82('0x28')](function(_0x23f863){if(_0x23f863){var _0x57ef3d={};var _0x24bd94={};_0x24bd94['model']=_[_0x0a82('0x6c')](_['keys'](_0x23f863),_[_0x0a82('0x32')](_0x318aa9['CustomFields'],function(_0x450820){return util[_0x0a82('0x6e')](_0x0a82('0x6f'),_0x450820['id']);}));_0x24bd94[_0x0a82('0x3c')]=_[_0x0a82('0x38')](_0x436f12['query']);_0x24bd94[_0x0a82('0x39')]=_[_0x0a82('0x3a')](_0x24bd94['model'],_0x24bd94[_0x0a82('0x3c')]);_0x57ef3d['attributes']=_[_0x0a82('0x3a')](_0x24bd94[_0x0a82('0x37')],qs[_0x0a82('0x3d')](_0x436f12['query'][_0x0a82('0x3d')]));_0x57ef3d[_0x0a82('0x3b')]=_0x57ef3d['attributes'][_0x0a82('0x3e')]?_0x57ef3d[_0x0a82('0x3b')]:_0x24bd94[_0x0a82('0x37')];if(!_0x436f12[_0x0a82('0x3c')][_0x0a82('0x3f')](_0x0a82('0x40'))){_0x57ef3d['limit']=qs[_0x0a82('0x23')](_0x436f12[_0x0a82('0x3c')][_0x0a82('0x23')]);_0x57ef3d[_0x0a82('0x22')]=qs['offset'](_0x436f12['query'][_0x0a82('0x22')]);}_0x57ef3d[_0x0a82('0x41')]=qs[_0x0a82('0x42')](_0x436f12['query']['sort']);_0x57ef3d[_0x0a82('0x43')]=qs[_0x0a82('0x39')](_[_0x0a82('0x44')](_0x436f12[_0x0a82('0x3c')],_0x24bd94[_0x0a82('0x39')]));_0x57ef3d[_0x0a82('0x70')]=!![];if(_0x436f12[_0x0a82('0x3c')][_0x0a82('0x45')]){_0x57ef3d[_0x0a82('0x43')]=_[_0x0a82('0x46')](_0x57ef3d[_0x0a82('0x43')],{'$or':_[_0x0a82('0x32')](_0x57ef3d[_0x0a82('0x3b')],function(_0x27ba2f){var _0x31d395={};_0x31d395[_0x27ba2f]={'$like':'%'+_0x436f12[_0x0a82('0x3c')][_0x0a82('0x45')]+'%'};return _0x31d395;})});}_0x57ef3d=_[_0x0a82('0x46')]({},_0x57ef3d,_0x436f12[_0x0a82('0x47')]);return _0x318aa9[_0x0a82('0x72')](_0x57ef3d);}})[_0x0a82('0x28')](function(_0x3e5796){if(!_[_0x0a82('0x73')](_0x3e5796)){var _0x1bbc87=toCsv(_0x3e5796);var _0x1d03c3=Date[_0x0a82('0x74')]();fs[_0x0a82('0x75')](util[_0x0a82('0x6e')](_0x0a82('0x76'),_0x318aa9['id'],_0x1d03c3),_0x1bbc87);_0x53abf3[_0x0a82('0x77')]('Content-disposition',_0x0a82('0x78')+util[_0x0a82('0x6e')](_0x0a82('0x79'),_0x318aa9['id'],_0x1d03c3));_0x53abf3[_0x0a82('0x77')]('Content-type',_0x0a82('0x7a'));return _0x53abf3[_0x0a82('0x7b')](util['format'](_0x0a82('0x76'),_0x318aa9['id'],_0x1d03c3));}else{return _0x53abf3['sendStatus'](0xcc);}})[_0x0a82('0x4c')](handleError(_0x53abf3,null));};exports[_0x0a82('0x7c')]=function(_0x55a4df,_0x4efc8b,_0x301814){var _0xfd6ad4;delete _0x55a4df[_0x0a82('0x4f')]['id'];return db[_0x0a82('0x33')]['findOne']({'where':{'id':_0x55a4df['params']['id']}})[_0x0a82('0x28')](handleEntityNotFound(_0x4efc8b,null))[_0x0a82('0x28')](function(_0x425f19){if(_0x425f19){return db[_0x0a82('0x7d')][_0x0a82('0x7e')](function(_0x463ac2){return db[_0x0a82('0x6b')][_0x0a82('0x4e')](_0x55a4df[_0x0a82('0x4f')],{'transaction':_0x463ac2})[_0x0a82('0x28')](function(_0x20c155){_0xfd6ad4=_0x20c155;return _0x425f19['addCustomFields'](_0x20c155,{'transaction':_0x463ac2});})[_0x0a82('0x28')](function(){var _0x4e086a={'type':db['Sequelize'][_0x0a82('0x7f')],'transaction':_0x463ac2};switch(_0x55a4df[_0x0a82('0x4f')][_0x0a82('0x35')]){case _0x0a82('0x80'):_0x4e086a['type']=db[_0x0a82('0x81')][_0x0a82('0x7f')];break;case _0x0a82('0x82'):_0x4e086a[_0x0a82('0x35')]=db[_0x0a82('0x81')]['INTEGER'];break;case _0x0a82('0x83'):_0x4e086a[_0x0a82('0x35')]=db['Sequelize'][_0x0a82('0x84')];_0x4e086a[_0x0a82('0x85')]=![];break;default:}return db[_0x0a82('0x7d')][_0x0a82('0x86')][_0x0a82('0x87')]('cm_contacts',util[_0x0a82('0x6e')]('cf_%s',_0xfd6ad4['id']),_0x4e086a);})['then'](function(){return _0xfd6ad4;});});}})[_0x0a82('0x28')](respondWithResult(_0x4efc8b,null))[_0x0a82('0x4c')](handleError(_0x4efc8b,null));};exports[_0x0a82('0x88')]=function(_0x3fa812,_0x1bd6ac,_0x27e8d0){var _0x4df072={};var _0x1a8790={};var _0x146f89;var _0x1cd9cf;return db[_0x0a82('0x33')][_0x0a82('0x5d')]({'where':{'id':_0x3fa812[_0x0a82('0x57')]['id']}})[_0x0a82('0x28')](handleEntityNotFound(_0x1bd6ac,null))[_0x0a82('0x28')](function(_0x4c8e5c){if(_0x4c8e5c){_0x146f89=_0x4c8e5c;_0x1a8790[_0x0a82('0x37')]=_[_0x0a82('0x38')](db[_0x0a82('0x6b')][_0x0a82('0x34')]);_0x1a8790[_0x0a82('0x3c')]=_['keys'](_0x3fa812['query']);_0x1a8790[_0x0a82('0x39')]=_['intersection'](_0x1a8790['model'],_0x1a8790[_0x0a82('0x3c')]);_0x4df072[_0x0a82('0x3b')]=_[_0x0a82('0x3a')](_0x1a8790['model'],qs['fields'](_0x3fa812[_0x0a82('0x3c')][_0x0a82('0x3d')]));_0x4df072[_0x0a82('0x3b')]=_0x4df072[_0x0a82('0x3b')][_0x0a82('0x3e')]?_0x4df072[_0x0a82('0x3b')]:_0x1a8790[_0x0a82('0x37')];_0x4df072[_0x0a82('0x41')]=qs[_0x0a82('0x42')](_0x3fa812[_0x0a82('0x3c')][_0x0a82('0x42')]);_0x4df072[_0x0a82('0x43')]=qs[_0x0a82('0x39')](_[_0x0a82('0x44')](_0x3fa812[_0x0a82('0x3c')],_0x1a8790[_0x0a82('0x39')]));_0x4df072['where']=_[_0x0a82('0x46')](_0x4df072['where'],{'$or':[{'ListId':_0x4c8e5c['id']},{'ListId':null}]});if(_0x3fa812[_0x0a82('0x3c')][_0x0a82('0x45')]){_0x4df072[_0x0a82('0x43')]=_['merge'](_0x4df072[_0x0a82('0x43')],{'$or':_[_0x0a82('0x32')](_0x4df072['attributes'],function(_0x4a361d){var _0x2ff894={};_0x2ff894[_0x4a361d]={'$like':'%'+_0x3fa812[_0x0a82('0x3c')][_0x0a82('0x45')]+'%'};return _0x2ff894;})});}_0x4df072=_[_0x0a82('0x46')]({},_0x4df072,_0x3fa812[_0x0a82('0x47')]);return db['CmCustomField'][_0x0a82('0x89')](_0x4df072);}})[_0x0a82('0x28')](respondWithResult(_0x1bd6ac,null))['catch'](handleError(_0x1bd6ac,null));};exports[_0x0a82('0x8a')]=function(_0x437b51,_0x106116,_0x1f72d8){return db['CmList'][_0x0a82('0x4d')]({'where':{'id':_0x437b51[_0x0a82('0x57')]['id']}})['then'](handleEntityNotFound(_0x106116,null))[_0x0a82('0x28')](function(_0x43327c){if(_0x43327c){return _0x43327c['addAgents'](_0x437b51[_0x0a82('0x4f')][_0x0a82('0x66')],_['omit'](_0x437b51[_0x0a82('0x4f')],[_0x0a82('0x66'),'id'])||{})[_0x0a82('0x8b')](function(_0x8ee0b2){for(var _0x5083ed=0x0;_0x5083ed<_0x437b51[_0x0a82('0x4f')][_0x0a82('0x66')][_0x0a82('0x3e')];_0x5083ed+=0x1){socket[_0x0a82('0x8c')]('userCmList:save',{'UserId':_0x437b51['body'][_0x0a82('0x66')][_0x5083ed],'CmListId':_0x437b51[_0x0a82('0x57')]['id']});}return _0x8ee0b2;});}})[_0x0a82('0x28')](respondWithResult(_0x106116,null))['catch'](handleError(_0x106116,null));};exports[_0x0a82('0x8d')]=function(_0x2e5eaf,_0x182aa5,_0x23a0d1){return db['CmList'][_0x0a82('0x4d')]({'where':{'id':_0x2e5eaf[_0x0a82('0x57')]['id']}})[_0x0a82('0x28')](handleEntityNotFound(_0x182aa5,null))[_0x0a82('0x28')](function(_0x1a1601){if(_0x1a1601){return _0x1a1601[_0x0a82('0x8d')](_0x2e5eaf[_0x0a82('0x3c')][_0x0a82('0x66')])[_0x0a82('0x28')](function(){if(_[_0x0a82('0x62')](_0x2e5eaf['query'][_0x0a82('0x66')])){for(var _0x28a087=0x0;_0x28a087<_0x2e5eaf[_0x0a82('0x3c')]['ids']['length'];_0x28a087+=0x1){socket[_0x0a82('0x8c')](_0x0a82('0x8e'),{'UserId':Number(_0x2e5eaf[_0x0a82('0x3c')][_0x0a82('0x66')][_0x28a087]),'CmListId':Number(_0x2e5eaf[_0x0a82('0x57')]['id'])});}}else{socket['emit'](_0x0a82('0x8e'),{'UserId':Number(_0x2e5eaf[_0x0a82('0x3c')][_0x0a82('0x66')]),'CmListId':Number(_0x2e5eaf[_0x0a82('0x57')]['id'])});}});}})[_0x0a82('0x28')](respondWithStatusCode(_0x182aa5,null))[_0x0a82('0x4c')](handleError(_0x182aa5,null));};exports[_0x0a82('0x8f')]=function(_0x17bb55,_0x4ff572,_0x55ab69){var _0xbf52a3={};var _0x286c65={};var _0x56a473;var _0x458520;return db['CmList'][_0x0a82('0x5d')]({'where':{'id':_0x17bb55['params']['id']}})['then'](handleEntityNotFound(_0x4ff572,null))[_0x0a82('0x28')](function(_0xfcb92f){if(_0xfcb92f){_0x56a473=_0xfcb92f;_0x286c65[_0x0a82('0x37')]=_[_0x0a82('0x38')](db[_0x0a82('0x90')]['rawAttributes']);_0x286c65[_0x0a82('0x3c')]=_['keys'](_0x17bb55[_0x0a82('0x3c')]);_0x286c65[_0x0a82('0x39')]=_[_0x0a82('0x3a')](_0x286c65['model'],_0x286c65['query']);_0xbf52a3['attributes']=_['intersection'](_0x286c65['model'],qs[_0x0a82('0x3d')](_0x17bb55['query'][_0x0a82('0x3d')]));_0xbf52a3[_0x0a82('0x3b')]=_0xbf52a3['attributes'][_0x0a82('0x3e')]?_0xbf52a3[_0x0a82('0x3b')]:_0x286c65[_0x0a82('0x37')];_0xbf52a3['order']=qs[_0x0a82('0x42')](_0x17bb55[_0x0a82('0x3c')][_0x0a82('0x42')]);_0xbf52a3[_0x0a82('0x43')]=qs[_0x0a82('0x39')](_[_0x0a82('0x44')](_0x17bb55[_0x0a82('0x3c')],_0x286c65[_0x0a82('0x39')]));if(_0x17bb55[_0x0a82('0x3c')][_0x0a82('0x45')]){_0xbf52a3[_0x0a82('0x43')]=_[_0x0a82('0x46')](_0xbf52a3[_0x0a82('0x43')],{'$or':_[_0x0a82('0x32')](_0xbf52a3[_0x0a82('0x3b')],function(_0x3ae7d8){var _0x59854f={};_0x59854f[_0x3ae7d8]={'$like':'%'+_0x17bb55[_0x0a82('0x3c')]['filter']+'%'};return _0x59854f;})});}_0xbf52a3=_[_0x0a82('0x46')]({},_0xbf52a3,_0x17bb55['options']);return _0x56a473[_0x0a82('0x8f')](_0xbf52a3);}})['then'](function(_0x46472b){if(_0x46472b){_0x458520=_0x46472b[_0x0a82('0x3e')];if(!_0x17bb55[_0x0a82('0x3c')][_0x0a82('0x3f')]('nolimit')){_0xbf52a3['limit']=qs[_0x0a82('0x23')](_0x17bb55['query'][_0x0a82('0x23')]);_0xbf52a3[_0x0a82('0x22')]=qs[_0x0a82('0x22')](_0x17bb55[_0x0a82('0x3c')]['offset']);}return _0x56a473[_0x0a82('0x8f')](_0xbf52a3);}})['then'](function(_0x584570){if(_0x584570){return _0x584570?{'count':_0x458520,'rows':_0x584570}:null;}})[_0x0a82('0x28')](respondWithResult(_0x4ff572,null))['catch'](handleError(_0x4ff572,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