Built motion from commit 775e2a94.|2.6.3
[motion2.git] / server / api / squareProject / squareProject.controller.js
index 855272d..b6edd9d 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x126f=['../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/license/util','../../mysqldb','redis','localhost','socket.io-emitter','./squareProject.socket','register','sendStatus','status','end','json','offset','undefined','limit','count','set','Content-Range','apply','reject','update','then','destroy','get','SquareProjects','UserProfileResource','error','stack','name','send','index','map','SquareProject','rawAttributes','fieldName','key','model','filters','intersection','query','attributes','fields','length','hasOwnProperty','nolimit','sort','where','pick','filter','merge','type','options','includeAll','findAll','rows','catch','show','keys','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','params','addUsers','omit','ids','removeUsers','isArray','userSquareProject:remove','findOne','User','getUsers','eml-format','rimraf','zip-dir','fast-json-patch','bluebird','mustache','util','path','to-csv','ejs','fs-extra','lodash','squel','jsforce','querystring','ioredis','../../components/auth/service','../../components/parsers/qs'];(function(_0x2a60a6,_0x3968ff){var _0x574216=function(_0x39eddd){while(--_0x39eddd){_0x2a60a6['push'](_0x2a60a6['shift']());}};_0x574216(++_0x3968ff);}(_0x126f,0x1d8));var _0xf126=function(_0x35dfe6,_0x4244fa){_0x35dfe6=_0x35dfe6-0x0;var _0x59651c=_0x126f[_0x35dfe6];return _0x59651c;};'use strict';var emlformat=require(_0xf126('0x0'));var rimraf=require(_0xf126('0x1'));var zipdir=require(_0xf126('0x2'));var jsonpatch=require(_0xf126('0x3'));var rp=require('request-promise');var moment=require('moment');var BPromise=require(_0xf126('0x4'));var Mustache=require(_0xf126('0x5'));var util=require(_0xf126('0x6'));var path=require(_0xf126('0x7'));var sox=require('sox');var csv=require(_0xf126('0x8'));var ejs=require(_0xf126('0x9'));var fs=require('fs');var fs_extra=require(_0xf126('0xa'));var _=require(_0xf126('0xb'));var squel=require(_0xf126('0xc'));var crypto=require('crypto');var jsforce=require(_0xf126('0xd'));var deskjs=require('desk.js');var toCsv=require(_0xf126('0x8'));var querystring=require(_0xf126('0xe'));var Papa=require('papaparse');var Redis=require(_0xf126('0xf'));var authService=require(_0xf126('0x10'));var qs=require(_0xf126('0x11'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xf126('0x12'));var logger=require(_0xf126('0x13'))(_0xf126('0x14'));var utils=require(_0xf126('0x15'));var config=require('../../config/environment');var licenseUtil=require(_0xf126('0x16'));var db=require(_0xf126('0x17'))['db'];config[_0xf126('0x18')]=_['defaults'](config['redis'],{'host':_0xf126('0x19'),'port':0x18eb});var socket=require(_0xf126('0x1a'))(new Redis(config['redis']));require(_0xf126('0x1b'))[_0xf126('0x1c')](socket);function respondWithStatusCode(_0x54ae44,_0x5c4210){_0x5c4210=_0x5c4210||0xcc;return function(_0x110c64){if(_0x110c64){return _0x54ae44[_0xf126('0x1d')](_0x5c4210);}return _0x54ae44[_0xf126('0x1e')](_0x5c4210)[_0xf126('0x1f')]();};}function respondWithResult(_0x51fc45,_0x3428cf){_0x3428cf=_0x3428cf||0xc8;return function(_0x309c69){if(_0x309c69){return _0x51fc45[_0xf126('0x1e')](_0x3428cf)[_0xf126('0x20')](_0x309c69);}};}function respondWithFilteredResult(_0x1d9e25,_0xb3c56e){return function(_0xc1f9ec){if(_0xc1f9ec){var _0x3c8b83=typeof _0xb3c56e[_0xf126('0x21')]===_0xf126('0x22')&&typeof _0xb3c56e[_0xf126('0x23')]===_0xf126('0x22');var _0x2fa7e6=_0xc1f9ec[_0xf126('0x24')];var _0x32c6b9=_0x3c8b83?0x0:_0xb3c56e[_0xf126('0x21')];var _0x451211=_0x3c8b83?_0xc1f9ec[_0xf126('0x24')]:_0xb3c56e[_0xf126('0x21')]+_0xb3c56e[_0xf126('0x23')];var _0xe82625;if(_0x451211>=_0x2fa7e6){_0x451211=_0x2fa7e6;_0xe82625=0xc8;}else{_0xe82625=0xce;}_0x1d9e25[_0xf126('0x1e')](_0xe82625);return _0x1d9e25[_0xf126('0x25')](_0xf126('0x26'),_0x32c6b9+'-'+_0x451211+'/'+_0x2fa7e6)['json'](_0xc1f9ec);}return null;};}function patchUpdates(_0x39bbed){return function(_0x569fa9){try{jsonpatch[_0xf126('0x27')](_0x569fa9,_0x39bbed,!![]);}catch(_0x26eb26){return BPromise[_0xf126('0x28')](_0x26eb26);}return _0x569fa9['save']();};}function saveUpdates(_0x29d018,_0x726083){return function(_0x5044b4){if(_0x5044b4){return _0x5044b4[_0xf126('0x29')](_0x29d018)[_0xf126('0x2a')](function(_0x17b12a){return _0x17b12a;});}return null;};}function removeEntity(_0xc76220,_0x42d1b9){return function(_0xf4d040){if(_0xf4d040){return _0xf4d040[_0xf126('0x2b')]()[_0xf126('0x2a')](function(){var _0x1f0fb3=_0xf4d040[_0xf126('0x2c')]({'plain':!![]});var _0x3eef2c=_0xf126('0x2d');return db[_0xf126('0x2e')]['destroy']({'where':{'type':_0x3eef2c,'resourceId':_0x1f0fb3['id']}})[_0xf126('0x2a')](function(){return _0xf4d040;});})[_0xf126('0x2a')](function(){_0xc76220['status'](0xcc)[_0xf126('0x1f')]();});}};}function handleEntityNotFound(_0x1e38ca,_0xfea39d){return function(_0x4af0e8){if(!_0x4af0e8){_0x1e38ca['sendStatus'](0x194);}return _0x4af0e8;};}function handleError(_0x20719a,_0x2db676){_0x2db676=_0x2db676||0x1f4;return function(_0x16cf4e){logger[_0xf126('0x2f')](_0x16cf4e[_0xf126('0x30')]);if(_0x16cf4e[_0xf126('0x31')]){delete _0x16cf4e['name'];}_0x20719a['status'](_0x2db676)[_0xf126('0x32')](_0x16cf4e);};}exports[_0xf126('0x33')]=function(_0x520dd6,_0x2f2e3b){var _0x18b756={},_0x3da34b={},_0x7a7d20={'count':0x0,'rows':[]};var _0x4e0a43=_[_0xf126('0x34')](db[_0xf126('0x35')][_0xf126('0x36')],function(_0x8712f3){return{'name':_0x8712f3[_0xf126('0x37')],'type':_0x8712f3['type'][_0xf126('0x38')]};});_0x3da34b[_0xf126('0x39')]=_[_0xf126('0x34')](_0x4e0a43,_0xf126('0x31'));_0x3da34b['query']=_['keys'](_0x520dd6['query']);_0x3da34b[_0xf126('0x3a')]=_[_0xf126('0x3b')](_0x3da34b[_0xf126('0x39')],_0x3da34b[_0xf126('0x3c')]);_0x18b756[_0xf126('0x3d')]=_[_0xf126('0x3b')](_0x3da34b[_0xf126('0x39')],qs[_0xf126('0x3e')](_0x520dd6[_0xf126('0x3c')][_0xf126('0x3e')]));_0x18b756['attributes']=_0x18b756['attributes'][_0xf126('0x3f')]?_0x18b756['attributes']:_0x3da34b[_0xf126('0x39')];if(!_0x520dd6['query'][_0xf126('0x40')](_0xf126('0x41'))){_0x18b756['limit']=qs['limit'](_0x520dd6[_0xf126('0x3c')][_0xf126('0x23')]);_0x18b756[_0xf126('0x21')]=qs[_0xf126('0x21')](_0x520dd6[_0xf126('0x3c')]['offset']);}_0x18b756['order']=qs[_0xf126('0x42')](_0x520dd6[_0xf126('0x3c')]['sort']);_0x18b756[_0xf126('0x43')]=qs[_0xf126('0x3a')](_[_0xf126('0x44')](_0x520dd6[_0xf126('0x3c')],_0x3da34b['filters']),_0x4e0a43);if(_0x520dd6[_0xf126('0x3c')][_0xf126('0x45')]){_0x18b756[_0xf126('0x43')]=_[_0xf126('0x46')](_0x18b756['where'],{'$or':_[_0xf126('0x34')](_0x4e0a43,function(_0x589b77){if(_0x589b77[_0xf126('0x47')]!=='VIRTUAL'){var _0x330cbe={};_0x330cbe[_0x589b77[_0xf126('0x31')]]={'$like':'%'+_0x520dd6['query'][_0xf126('0x45')]+'%'};return _0x330cbe;}})});}_0x18b756=_[_0xf126('0x46')]({},_0x18b756,_0x520dd6[_0xf126('0x48')]);var _0x49471d={'where':_0x18b756[_0xf126('0x43')]};return db[_0xf126('0x35')][_0xf126('0x24')](_0x49471d)['then'](function(_0x1bbbf1){_0x7a7d20[_0xf126('0x24')]=_0x1bbbf1;if(_0x520dd6['query'][_0xf126('0x49')]){_0x18b756['include']=[{'all':!![]}];}return db[_0xf126('0x35')][_0xf126('0x4a')](_0x18b756);})[_0xf126('0x2a')](function(_0x58d137){_0x7a7d20[_0xf126('0x4b')]=_0x58d137;return _0x7a7d20;})[_0xf126('0x2a')](respondWithFilteredResult(_0x2f2e3b,_0x18b756))[_0xf126('0x4c')](handleError(_0x2f2e3b,null));};exports[_0xf126('0x4d')]=function(_0xa56354,_0x5b6cb3){var _0x57820c={'raw':![],'where':{'id':_0xa56354['params']['id']}},_0x43b876={};_0x43b876[_0xf126('0x39')]=_['keys'](db[_0xf126('0x35')][_0xf126('0x36')]);_0x43b876[_0xf126('0x3c')]=_[_0xf126('0x4e')](_0xa56354['query']);_0x43b876[_0xf126('0x3a')]=_[_0xf126('0x3b')](_0x43b876[_0xf126('0x39')],_0x43b876[_0xf126('0x3c')]);_0x57820c[_0xf126('0x3d')]=_[_0xf126('0x3b')](_0x43b876[_0xf126('0x39')],qs[_0xf126('0x3e')](_0xa56354[_0xf126('0x3c')][_0xf126('0x3e')]));_0x57820c['attributes']=_0x57820c['attributes'][_0xf126('0x3f')]?_0x57820c[_0xf126('0x3d')]:_0x43b876[_0xf126('0x39')];if(_0xa56354['query'][_0xf126('0x49')]){_0x57820c['include']=[{'all':!![]}];}_0x57820c=_['merge']({},_0x57820c,_0xa56354['options']);return db[_0xf126('0x35')][_0xf126('0x4f')](_0x57820c)[_0xf126('0x2a')](handleEntityNotFound(_0x5b6cb3,null))['then'](respondWithResult(_0x5b6cb3,null))['catch'](handleError(_0x5b6cb3,null));};exports[_0xf126('0x50')]=function(_0x4c1b8b,_0x2a9b3b){return db['SquareProject'][_0xf126('0x50')](_0x4c1b8b[_0xf126('0x51')],{})['then'](function(_0x2b0db8){var _0x89bef=_0x4c1b8b[_0xf126('0x52')][_0xf126('0x2c')]({'plain':!![]});if(!_0x89bef)throw new Error(_0xf126('0x53'));if(_0x89bef[_0xf126('0x54')]==='user'){var _0x4b9c7d=_0x2b0db8['get']({'plain':!![]});var _0x41b18e='SquareProjects';return db['UserProfileSection'][_0xf126('0x4f')]({'where':{'name':_0x41b18e,'userProfileId':_0x89bef[_0xf126('0x55')]},'raw':!![]})[_0xf126('0x2a')](function(_0x319cb0){if(_0x319cb0&&_0x319cb0[_0xf126('0x56')]===0x0){return db[_0xf126('0x2e')][_0xf126('0x50')]({'name':_0x4b9c7d['name'],'resourceId':_0x4b9c7d['id'],'type':_0x319cb0[_0xf126('0x31')],'sectionId':_0x319cb0['id']},{})['then'](function(){return _0x2b0db8;});}else{return _0x2b0db8;}})[_0xf126('0x4c')](function(_0x3f8b05){logger['error'](_0xf126('0x57'),_0x3f8b05);throw _0x3f8b05;});}return _0x2b0db8;})[_0xf126('0x2a')](respondWithResult(_0x2a9b3b,0xc9))[_0xf126('0x4c')](handleError(_0x2a9b3b,null));};exports[_0xf126('0x29')]=function(_0x2819f5,_0x545628){if(_0x2819f5[_0xf126('0x51')]['id']){delete _0x2819f5[_0xf126('0x51')]['id'];}return db[_0xf126('0x35')]['find']({'where':{'id':_0x2819f5['params']['id']}})['then'](handleEntityNotFound(_0x545628,null))[_0xf126('0x2a')](saveUpdates(_0x2819f5[_0xf126('0x51')],null))['then'](respondWithResult(_0x545628,null))[_0xf126('0x4c')](handleError(_0x545628,null));};exports[_0xf126('0x2b')]=function(_0x469b65,_0xf7a6cc){return db['SquareProject'][_0xf126('0x4f')]({'where':{'id':_0x469b65['params']['id']}})[_0xf126('0x2a')](handleEntityNotFound(_0xf7a6cc,null))[_0xf126('0x2a')](removeEntity(_0xf7a6cc,null))[_0xf126('0x4c')](handleError(_0xf7a6cc,null));};exports['addUsers']=function(_0x46ff26,_0x1077c7,_0x40c1f6){return db[_0xf126('0x35')]['find']({'where':{'id':_0x46ff26[_0xf126('0x58')]['id']}})[_0xf126('0x2a')](handleEntityNotFound(_0x1077c7,null))[_0xf126('0x2a')](function(_0x3780e0){if(_0x3780e0){return _0x3780e0[_0xf126('0x59')](_0x46ff26[_0xf126('0x51')]['ids'],_[_0xf126('0x5a')](_0x46ff26[_0xf126('0x51')],[_0xf126('0x5b'),'id'])||{});}})[_0xf126('0x2a')](respondWithResult(_0x1077c7,null))['catch'](handleError(_0x1077c7,null));};exports[_0xf126('0x5c')]=function(_0xcf00b,_0x4831fd,_0x5d988d){return db[_0xf126('0x35')]['find']({'where':{'id':_0xcf00b[_0xf126('0x58')]['id']}})[_0xf126('0x2a')](handleEntityNotFound(_0x4831fd,null))[_0xf126('0x2a')](function(_0x18090f){if(_0x18090f){return _0x18090f['removeUsers'](_0xcf00b['query'][_0xf126('0x5b')])['then'](function(){if(_[_0xf126('0x5d')](_0xcf00b[_0xf126('0x3c')][_0xf126('0x5b')])){for(var _0x5484e9=0x0;_0x5484e9<_0xcf00b[_0xf126('0x3c')][_0xf126('0x5b')][_0xf126('0x3f')];_0x5484e9+=0x1){socket['emit']('userSquareProject:remove',{'UserId':Number(_0xcf00b[_0xf126('0x3c')][_0xf126('0x5b')][_0x5484e9]),'SquareProjectId':Number(_0xcf00b[_0xf126('0x58')]['id'])});}}else{socket['emit'](_0xf126('0x5e'),{'UserId':Number(_0xcf00b[_0xf126('0x3c')][_0xf126('0x5b')]),'SquareProjectId':Number(_0xcf00b[_0xf126('0x58')]['id'])});}});}})[_0xf126('0x2a')](respondWithStatusCode(_0x4831fd,null))[_0xf126('0x4c')](handleError(_0x4831fd,null));};exports['getUsers']=function(_0x3df4fe,_0x73c4cc,_0x392c1c){var _0x5fcf95={};var _0x2fc398={};var _0x127f2b;var _0x2ef15a;return db[_0xf126('0x35')][_0xf126('0x5f')]({'where':{'id':_0x3df4fe[_0xf126('0x58')]['id']}})[_0xf126('0x2a')](handleEntityNotFound(_0x73c4cc,null))['then'](function(_0x661280){if(_0x661280){_0x127f2b=_0x661280;_0x2fc398[_0xf126('0x39')]=_['keys'](db[_0xf126('0x60')][_0xf126('0x36')]);_0x2fc398['query']=_[_0xf126('0x4e')](_0x3df4fe[_0xf126('0x3c')]);_0x2fc398[_0xf126('0x3a')]=_[_0xf126('0x3b')](_0x2fc398[_0xf126('0x39')],_0x2fc398[_0xf126('0x3c')]);_0x5fcf95[_0xf126('0x3d')]=_[_0xf126('0x3b')](_0x2fc398[_0xf126('0x39')],qs[_0xf126('0x3e')](_0x3df4fe[_0xf126('0x3c')][_0xf126('0x3e')]));_0x5fcf95[_0xf126('0x3d')]=_0x5fcf95[_0xf126('0x3d')][_0xf126('0x3f')]?_0x5fcf95[_0xf126('0x3d')]:_0x2fc398['model'];_0x5fcf95['order']=qs['sort'](_0x3df4fe['query'][_0xf126('0x42')]);_0x5fcf95[_0xf126('0x43')]=qs['filters'](_[_0xf126('0x44')](_0x3df4fe[_0xf126('0x3c')],_0x2fc398[_0xf126('0x3a')]));if(_0x3df4fe[_0xf126('0x3c')][_0xf126('0x45')]){_0x5fcf95[_0xf126('0x43')]=_[_0xf126('0x46')](_0x5fcf95[_0xf126('0x43')],{'$or':_[_0xf126('0x34')](_0x5fcf95[_0xf126('0x3d')],function(_0x3e3af2){var _0x371ca8={};_0x371ca8[_0x3e3af2]={'$like':'%'+_0x3df4fe[_0xf126('0x3c')][_0xf126('0x45')]+'%'};return _0x371ca8;})});}_0x5fcf95=_['merge']({},_0x5fcf95,_0x3df4fe['options']);return _0x127f2b[_0xf126('0x61')](_0x5fcf95);}})[_0xf126('0x2a')](function(_0x1ec082){if(_0x1ec082){_0x2ef15a=_0x1ec082[_0xf126('0x3f')];if(!_0x3df4fe[_0xf126('0x3c')]['hasOwnProperty'](_0xf126('0x41'))){_0x5fcf95[_0xf126('0x23')]=qs[_0xf126('0x23')](_0x3df4fe['query']['limit']);_0x5fcf95[_0xf126('0x21')]=qs[_0xf126('0x21')](_0x3df4fe[_0xf126('0x3c')][_0xf126('0x21')]);}return _0x127f2b[_0xf126('0x61')](_0x5fcf95);}})['then'](function(_0x27a73f){if(_0x27a73f){return _0x27a73f?{'count':_0x2ef15a,'rows':_0x27a73f}:null;}})[_0xf126('0x2a')](respondWithResult(_0x73c4cc,null))[_0xf126('0x4c')](handleError(_0x73c4cc,null));};
\ No newline at end of file
+var _0x752b=['User','order','lodash','ioredis','../../config/logger','../../config/environment','redis','defaults','localhost','./squareProject.socket','sendStatus','status','end','json','offset','undefined','limit','count','Content-Range','destroy','then','SquareProjects','UserProfileResource','stringify','error','stack','name','send','connect','agi','port','127.0.0.1','index','map','SquareProject','rawAttributes','fieldName','key','query','keys','filters','intersection','model','attributes','fields','length','nolimit','sort','where','pick','merge','type','VIRTUAL','filter','options','includeAll','include','findAll','rows','catch','show','find','create','body','user','role','get','UserProfileSection','autoAssociation','update','params','production','addUsers','ids','omit','isArray','emit','userSquareProject:remove','getUsers','findOne'];(function(_0xa464c9,_0x7c86d8){var _0x3d73c4=function(_0x5c2056){while(--_0x5c2056){_0xa464c9['push'](_0xa464c9['shift']());}};_0x3d73c4(++_0x7c86d8);}(_0x752b,0xf2));var _0xb752=function(_0x4fdc36,_0x1246f2){_0x4fdc36=_0x4fdc36-0x0;var _0x287f61=_0x752b[_0x4fdc36];return _0x287f61;};'use strict';var _=require(_0xb752('0x0'));var Redis=require(_0xb752('0x1'));var qs=require('../../components/parsers/qs');var logger=require(_0xb752('0x2'))('api');var config=require(_0xb752('0x3'));var db=require('../../mysqldb')['db'];config[_0xb752('0x4')]=_[_0xb752('0x5')](config[_0xb752('0x4')],{'host':_0xb752('0x6'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xb752('0x4')]));require(_0xb752('0x7'))['register'](socket);function respondWithStatusCode(_0x4b3168,_0x4c87f){_0x4c87f=_0x4c87f||0xcc;return function(_0x3d50c0){if(_0x3d50c0){return _0x4b3168[_0xb752('0x8')](_0x4c87f);}return _0x4b3168[_0xb752('0x9')](_0x4c87f)[_0xb752('0xa')]();};}function respondWithResult(_0x115395,_0x130914){_0x130914=_0x130914||0xc8;return function(_0x5ed86e){if(_0x5ed86e){return _0x115395[_0xb752('0x9')](_0x130914)[_0xb752('0xb')](_0x5ed86e);}};}function respondWithFilteredResult(_0x353572,_0x170287){return function(_0x39909e){if(_0x39909e){var _0xf045f4=typeof _0x170287[_0xb752('0xc')]===_0xb752('0xd')&&typeof _0x170287[_0xb752('0xe')]==='undefined';var _0x46891c=_0x39909e[_0xb752('0xf')];var _0x56f187=_0xf045f4?0x0:_0x170287[_0xb752('0xc')];var _0x2bcac2=_0xf045f4?_0x39909e[_0xb752('0xf')]:_0x170287['offset']+_0x170287[_0xb752('0xe')];var _0x4d811d;if(_0x2bcac2>=_0x46891c){_0x2bcac2=_0x46891c;_0x4d811d=0xc8;}else{_0x4d811d=0xce;}_0x353572[_0xb752('0x9')](_0x4d811d);return _0x353572['set'](_0xb752('0x10'),_0x56f187+'-'+_0x2bcac2+'/'+_0x46891c)[_0xb752('0xb')](_0x39909e);}return null;};}function saveUpdates(_0x256385){return function(_0x4f7aa2){if(_0x4f7aa2){return _0x4f7aa2['update'](_0x256385)['then'](function(_0x3d4622){return _0x3d4622;});}return null;};}function removeEntity(_0x54f60a){return function(_0x200420){if(_0x200420){return _0x200420[_0xb752('0x11')]()[_0xb752('0x12')](function(){var _0x12b7ec=_0x200420['get']({'plain':!![]});var _0x2613c9=_0xb752('0x13');return db[_0xb752('0x14')]['destroy']({'where':{'type':_0x2613c9,'resourceId':_0x12b7ec['id']}})[_0xb752('0x12')](function(){return _0x200420;});})[_0xb752('0x12')](function(){return createAgiSocket();})[_0xb752('0x12')](function(_0x29f029){_0x29f029['end'](JSON[_0xb752('0x15')]({'id':_0x200420['id'],'deleted':!![]}));})[_0xb752('0x12')](function(){_0x54f60a[_0xb752('0x9')](0xcc)[_0xb752('0xa')]();});}};}function handleEntityNotFound(_0x55623b){return function(_0x12d03f){if(!_0x12d03f){_0x55623b['sendStatus'](0x194);}return _0x12d03f;};}function handleError(_0x1439d0,_0x27417a){_0x27417a=_0x27417a||0x1f4;return function(_0x103ed7){logger[_0xb752('0x16')](_0x103ed7[_0xb752('0x17')]);if(_0x103ed7['name']){delete _0x103ed7[_0xb752('0x18')];}_0x1439d0[_0xb752('0x9')](_0x27417a)[_0xb752('0x19')](_0x103ed7);};}function createAgiSocket(){try{var _0x3e46c2=require('net');var _0x2e0153=new _0x3e46c2['Socket']();return _0x2e0153[_0xb752('0x1a')](config[_0xb752('0x1b')][_0xb752('0x1c')]||0x11dd,_0xb752('0x1d'));}catch(_0x5d21b2){throw _0x5d21b2;}}exports[_0xb752('0x1e')]=function(_0x31d147,_0x40aad2){var _0x3c40c0={},_0x43e8f1={},_0x2cba9b={'count':0x0,'rows':[]};var _0x4bf7c7=_[_0xb752('0x1f')](db[_0xb752('0x20')][_0xb752('0x21')],function(_0x5f4041){return{'name':_0x5f4041[_0xb752('0x22')],'type':_0x5f4041['type'][_0xb752('0x23')]};});_0x43e8f1['model']=_[_0xb752('0x1f')](_0x4bf7c7,_0xb752('0x18'));_0x43e8f1[_0xb752('0x24')]=_[_0xb752('0x25')](_0x31d147[_0xb752('0x24')]);_0x43e8f1[_0xb752('0x26')]=_[_0xb752('0x27')](_0x43e8f1[_0xb752('0x28')],_0x43e8f1['query']);_0x3c40c0[_0xb752('0x29')]=_[_0xb752('0x27')](_0x43e8f1[_0xb752('0x28')],qs[_0xb752('0x2a')](_0x31d147[_0xb752('0x24')]['fields']));_0x3c40c0[_0xb752('0x29')]=_0x3c40c0['attributes'][_0xb752('0x2b')]?_0x3c40c0[_0xb752('0x29')]:_0x43e8f1[_0xb752('0x28')];if(!_0x31d147['query']['hasOwnProperty'](_0xb752('0x2c'))){_0x3c40c0[_0xb752('0xe')]=qs[_0xb752('0xe')](_0x31d147[_0xb752('0x24')][_0xb752('0xe')]);_0x3c40c0[_0xb752('0xc')]=qs['offset'](_0x31d147['query']['offset']);}_0x3c40c0['order']=qs[_0xb752('0x2d')](_0x31d147['query'][_0xb752('0x2d')]);_0x3c40c0[_0xb752('0x2e')]=qs[_0xb752('0x26')](_[_0xb752('0x2f')](_0x31d147['query'],_0x43e8f1['filters']),_0x4bf7c7);if(_0x31d147[_0xb752('0x24')]['filter']){_0x3c40c0[_0xb752('0x2e')]=_[_0xb752('0x30')](_0x3c40c0[_0xb752('0x2e')],{'$or':_[_0xb752('0x1f')](_0x4bf7c7,function(_0x18351e){if(_0x18351e[_0xb752('0x31')]!==_0xb752('0x32')){var _0x458063={};_0x458063[_0x18351e[_0xb752('0x18')]]={'$like':'%'+_0x31d147[_0xb752('0x24')][_0xb752('0x33')]+'%'};return _0x458063;}})});}_0x3c40c0=_[_0xb752('0x30')]({},_0x3c40c0,_0x31d147[_0xb752('0x34')]);var _0x1f2a2c={'where':_0x3c40c0[_0xb752('0x2e')]};return db['SquareProject']['count'](_0x1f2a2c)[_0xb752('0x12')](function(_0x2852cf){_0x2cba9b[_0xb752('0xf')]=_0x2852cf;if(_0x31d147['query'][_0xb752('0x35')]){_0x3c40c0[_0xb752('0x36')]=[{'all':!![]}];}return db[_0xb752('0x20')][_0xb752('0x37')](_0x3c40c0);})[_0xb752('0x12')](function(_0x31ff29){_0x2cba9b[_0xb752('0x38')]=_0x31ff29;return _0x2cba9b;})['then'](respondWithFilteredResult(_0x40aad2,_0x3c40c0))[_0xb752('0x39')](handleError(_0x40aad2,null));};exports[_0xb752('0x3a')]=function(_0x4f56c1,_0x30e86e){var _0x574a26={'raw':![],'where':{'id':_0x4f56c1['params']['id']}},_0x1191d6={};_0x1191d6[_0xb752('0x28')]=_[_0xb752('0x25')](db['SquareProject'][_0xb752('0x21')]);_0x1191d6[_0xb752('0x24')]=_[_0xb752('0x25')](_0x4f56c1['query']);_0x1191d6[_0xb752('0x26')]=_[_0xb752('0x27')](_0x1191d6[_0xb752('0x28')],_0x1191d6[_0xb752('0x24')]);_0x574a26[_0xb752('0x29')]=_[_0xb752('0x27')](_0x1191d6['model'],qs[_0xb752('0x2a')](_0x4f56c1['query']['fields']));_0x574a26[_0xb752('0x29')]=_0x574a26[_0xb752('0x29')][_0xb752('0x2b')]?_0x574a26[_0xb752('0x29')]:_0x1191d6[_0xb752('0x28')];if(_0x4f56c1['query'][_0xb752('0x35')]){_0x574a26[_0xb752('0x36')]=[{'all':!![]}];}_0x574a26=_[_0xb752('0x30')]({},_0x574a26,_0x4f56c1['options']);return db[_0xb752('0x20')][_0xb752('0x3b')](_0x574a26)['then'](handleEntityNotFound(_0x30e86e,null))[_0xb752('0x12')](respondWithResult(_0x30e86e,null))['catch'](handleError(_0x30e86e,null));};exports['create']=function(_0x338c67,_0x477db4){return db[_0xb752('0x20')][_0xb752('0x3c')](_0x338c67[_0xb752('0x3d')],{})[_0xb752('0x12')](function(_0x292ff4){var _0x340c32=_0x338c67[_0xb752('0x3e')]['get']({'plain':!![]});if(!_0x340c32)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x340c32[_0xb752('0x3f')]===_0xb752('0x3e')){var _0x5a5e52=_0x292ff4[_0xb752('0x40')]({'plain':!![]});var _0x1cbec7=_0xb752('0x13');return db[_0xb752('0x41')]['find']({'where':{'name':_0x1cbec7,'userProfileId':_0x340c32['userProfileId']},'raw':!![]})['then'](function(_0x34df8c){if(_0x34df8c&&_0x34df8c[_0xb752('0x42')]===0x0){return db['UserProfileResource']['create']({'name':_0x5a5e52[_0xb752('0x18')],'resourceId':_0x5a5e52['id'],'type':_0x34df8c[_0xb752('0x18')],'sectionId':_0x34df8c['id']},{})['then'](function(){return _0x292ff4;});}else{return _0x292ff4;}})[_0xb752('0x39')](function(_0x5b93e3){logger[_0xb752('0x16')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x5b93e3);throw _0x5b93e3;});}return _0x292ff4;})[_0xb752('0x12')](respondWithResult(_0x477db4,0xc9))['catch'](handleError(_0x477db4,null));};exports[_0xb752('0x43')]=function(_0x57b60c,_0x840b90){if(_0x57b60c[_0xb752('0x3d')]['id']){delete _0x57b60c['body']['id'];}return db[_0xb752('0x20')][_0xb752('0x3b')]({'where':{'id':_0x57b60c[_0xb752('0x44')]['id']}})['then'](handleEntityNotFound(_0x840b90,null))[_0xb752('0x12')](saveUpdates(_0x57b60c[_0xb752('0x3d')],null))[_0xb752('0x12')](function(_0x3da7a7){if(!_0x3da7a7)return;var _0x5532cc=_0x3da7a7[_0xb752('0x40')]({'plain':!![]});return _0x5532cc;})[_0xb752('0x12')](function(_0x3b45c2){var _0x253b7a=new Redis(config['redis']);_0x253b7a['publish'](_0xb752('0x1b'),JSON[_0xb752('0x15')](_[_0xb752('0x2f')](_0x3b45c2,['id',_0xb752('0x18'),_0xb752('0x45')])));return _0x3b45c2;})[_0xb752('0x12')](respondWithResult(_0x840b90,null))[_0xb752('0x39')](handleError(_0x840b90,null));};exports[_0xb752('0x11')]=function(_0x5c1bf6,_0x8b14d1){return db[_0xb752('0x20')][_0xb752('0x3b')]({'where':{'id':_0x5c1bf6['params']['id']}})[_0xb752('0x12')](handleEntityNotFound(_0x8b14d1,null))['then'](removeEntity(_0x8b14d1,null))[_0xb752('0x39')](handleError(_0x8b14d1,null));};exports[_0xb752('0x46')]=function(_0x28c88e,_0x37f817){return db['SquareProject'][_0xb752('0x3b')]({'where':{'id':_0x28c88e[_0xb752('0x44')]['id']}})[_0xb752('0x12')](handleEntityNotFound(_0x37f817,null))['then'](function(_0x41dd91){if(_0x41dd91){return _0x41dd91[_0xb752('0x46')](_0x28c88e['body'][_0xb752('0x47')],_[_0xb752('0x48')](_0x28c88e[_0xb752('0x3d')],[_0xb752('0x47'),'id'])||{});}})[_0xb752('0x12')](respondWithResult(_0x37f817,null))[_0xb752('0x39')](handleError(_0x37f817,null));};exports['removeUsers']=function(_0x2521e2,_0x48bc4f){return db[_0xb752('0x20')][_0xb752('0x3b')]({'where':{'id':_0x2521e2[_0xb752('0x44')]['id']}})['then'](handleEntityNotFound(_0x48bc4f,null))[_0xb752('0x12')](function(_0x2d066b){if(_0x2d066b){return _0x2d066b['removeUsers'](_0x2521e2[_0xb752('0x24')][_0xb752('0x47')])[_0xb752('0x12')](function(){if(_[_0xb752('0x49')](_0x2521e2[_0xb752('0x24')][_0xb752('0x47')])){for(var _0x5da9df=0x0;_0x5da9df<_0x2521e2[_0xb752('0x24')]['ids']['length'];_0x5da9df+=0x1){socket[_0xb752('0x4a')]('userSquareProject:remove',{'UserId':Number(_0x2521e2[_0xb752('0x24')]['ids'][_0x5da9df]),'SquareProjectId':Number(_0x2521e2[_0xb752('0x44')]['id'])});}}else{socket[_0xb752('0x4a')](_0xb752('0x4b'),{'UserId':Number(_0x2521e2[_0xb752('0x24')][_0xb752('0x47')]),'SquareProjectId':Number(_0x2521e2[_0xb752('0x44')]['id'])});}});}})[_0xb752('0x12')](respondWithStatusCode(_0x48bc4f,null))[_0xb752('0x39')](handleError(_0x48bc4f,null));};exports[_0xb752('0x4c')]=function(_0x5c3bbc,_0x208141){var _0x5edf84={};var _0x59c977={};var _0x1fa3b0;var _0x53c348;return db[_0xb752('0x20')][_0xb752('0x4d')]({'where':{'id':_0x5c3bbc[_0xb752('0x44')]['id']}})[_0xb752('0x12')](handleEntityNotFound(_0x208141,null))[_0xb752('0x12')](function(_0x2b0da8){if(_0x2b0da8){_0x1fa3b0=_0x2b0da8;_0x59c977['model']=_[_0xb752('0x25')](db[_0xb752('0x4e')][_0xb752('0x21')]);_0x59c977[_0xb752('0x24')]=_['keys'](_0x5c3bbc[_0xb752('0x24')]);_0x59c977[_0xb752('0x26')]=_[_0xb752('0x27')](_0x59c977[_0xb752('0x28')],_0x59c977[_0xb752('0x24')]);_0x5edf84[_0xb752('0x29')]=_[_0xb752('0x27')](_0x59c977[_0xb752('0x28')],qs[_0xb752('0x2a')](_0x5c3bbc[_0xb752('0x24')][_0xb752('0x2a')]));_0x5edf84[_0xb752('0x29')]=_0x5edf84[_0xb752('0x29')][_0xb752('0x2b')]?_0x5edf84[_0xb752('0x29')]:_0x59c977[_0xb752('0x28')];_0x5edf84[_0xb752('0x4f')]=qs[_0xb752('0x2d')](_0x5c3bbc[_0xb752('0x24')]['sort']);_0x5edf84[_0xb752('0x2e')]=qs[_0xb752('0x26')](_[_0xb752('0x2f')](_0x5c3bbc[_0xb752('0x24')],_0x59c977[_0xb752('0x26')]));if(_0x5c3bbc[_0xb752('0x24')][_0xb752('0x33')]){_0x5edf84[_0xb752('0x2e')]=_[_0xb752('0x30')](_0x5edf84[_0xb752('0x2e')],{'$or':_[_0xb752('0x1f')](_0x5edf84[_0xb752('0x29')],function(_0x1a76af){var _0x418bbc={};_0x418bbc[_0x1a76af]={'$like':'%'+_0x5c3bbc['query'][_0xb752('0x33')]+'%'};return _0x418bbc;})});}_0x5edf84=_[_0xb752('0x30')]({},_0x5edf84,_0x5c3bbc[_0xb752('0x34')]);return _0x1fa3b0[_0xb752('0x4c')](_0x5edf84);}})[_0xb752('0x12')](function(_0x58a823){if(_0x58a823){_0x53c348=_0x58a823[_0xb752('0x2b')];if(!_0x5c3bbc[_0xb752('0x24')]['hasOwnProperty'](_0xb752('0x2c'))){_0x5edf84[_0xb752('0xe')]=qs[_0xb752('0xe')](_0x5c3bbc[_0xb752('0x24')][_0xb752('0xe')]);_0x5edf84['offset']=qs[_0xb752('0xc')](_0x5c3bbc[_0xb752('0x24')][_0xb752('0xc')]);}return _0x1fa3b0[_0xb752('0x4c')](_0x5edf84);}})[_0xb752('0x12')](function(_0x2bdfa2){if(_0x2bdfa2){return _0x2bdfa2?{'count':_0x53c348,'rows':_0x2bdfa2}:null;}})[_0xb752('0x12')](respondWithResult(_0x208141,null))[_0xb752('0x39')](handleError(_0x208141,null));};
\ No newline at end of file