Built motion from commit 1ea47bf4.|2.6.34
[motion2.git] / server / api / user-setting / user-setting.controller.js
index 403050c..e476d17 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x70e0=['ioredis','../../config/logger','../../mysqldb','socket.io-emitter','redis','./user-setting.socket','status','json','update','then','sendStatus','error','stack','name','send','Unauthorized','params','find','catch','lodash'];(function(_0x3ee672,_0x353727){var _0x277f57=function(_0x19ab2c){while(--_0x19ab2c){_0x3ee672['push'](_0x3ee672['shift']());}};_0x277f57(++_0x353727);}(_0x70e0,0x17b));var _0x070e=function(_0x3e3060,_0x44238e){_0x3e3060=_0x3e3060-0x0;var _0x24ed39=_0x70e0[_0x3e3060];return _0x24ed39;};'use strict';var _=require(_0x070e('0x0'));var Redis=require(_0x070e('0x1'));var logger=require(_0x070e('0x2'))('api');var config=require('../../config/environment');var db=require(_0x070e('0x3'))['db'];var socket=require(_0x070e('0x4'))(new Redis(config[_0x070e('0x5')]));require(_0x070e('0x6'))['register'](socket);config[_0x070e('0x5')]=_['defaults'](config[_0x070e('0x5')],{'host':'localhost','port':0x18eb});function respondWithResult(_0x56e420,_0x5032e5){_0x5032e5=_0x5032e5||0xc8;return function(_0x35ab0c){if(_0x35ab0c){return _0x56e420[_0x070e('0x7')](_0x5032e5)[_0x070e('0x8')](_0x35ab0c);}};}function saveUpdates(_0x2611e6){return function(_0x111743){if(_0x111743){return _0x111743[_0x070e('0x9')](_0x2611e6)[_0x070e('0xa')](function(_0x4e99e6){return _0x4e99e6;});}return null;};}function handleEntityNotFound(_0x49b2fb){return function(_0x50f4eb){if(!_0x50f4eb){_0x49b2fb[_0x070e('0xb')](0x194);}return _0x50f4eb;};}function handleError(_0x12bb37,_0xb8d819){_0xb8d819=_0xb8d819||0x1f4;return function(_0xa927a2){logger[_0x070e('0xc')](_0xa927a2[_0x070e('0xd')]);if(_0xa927a2[_0x070e('0xe')]){delete _0xa927a2[_0x070e('0xe')];}_0x12bb37[_0x070e('0x7')](_0xb8d819)[_0x070e('0xf')](_0xa927a2);};}exports['update']=function(_0x5dca0f,_0x24baba){if(_0x5dca0f['user']['role']!=='admin')throw new Error(_0x070e('0x10'));if(isNaN(Number(_0x5dca0f[_0x070e('0x11')]['id'])))throw new Error('Invalid\x20user\x20setting\x20id');return db['UserSetting'][_0x070e('0x12')]({'where':{'id':_0x5dca0f[_0x070e('0x11')]['id']}})[_0x070e('0xa')](handleEntityNotFound(_0x24baba,null))[_0x070e('0xa')](saveUpdates(_0x5dca0f['body'],null))['then'](respondWithResult(_0x24baba,null))[_0x070e('0x13')](handleError(_0x24baba,null));};
\ No newline at end of file
+var _0x9f75=['register','defaults','status','json','then','stack','name','send','update','user','role','Invalid\x20user\x20setting\x20id','find','params','body','catch','lodash','../../config/logger','api','socket.io-emitter','redis','./user-setting.socket'];(function(_0x9468f4,_0x34f4b7){var _0x11d27d=function(_0x22be17){while(--_0x22be17){_0x9468f4['push'](_0x9468f4['shift']());}};_0x11d27d(++_0x34f4b7);}(_0x9f75,0x15a));var _0x59f7=function(_0x5e32f9,_0x5bb66c){_0x5e32f9=_0x5e32f9-0x0;var _0x1e98ad=_0x9f75[_0x5e32f9];return _0x1e98ad;};'use strict';var _=require(_0x59f7('0x0'));var Redis=require('ioredis');var logger=require(_0x59f7('0x1'))(_0x59f7('0x2'));var config=require('../../config/environment');var db=require('../../mysqldb')['db'];var socket=require(_0x59f7('0x3'))(new Redis(config[_0x59f7('0x4')]));require(_0x59f7('0x5'))[_0x59f7('0x6')](socket);config['redis']=_[_0x59f7('0x7')](config[_0x59f7('0x4')],{'host':'localhost','port':0x18eb});function respondWithResult(_0x5483bc,_0xeb6d1e){_0xeb6d1e=_0xeb6d1e||0xc8;return function(_0x15903b){if(_0x15903b){return _0x5483bc[_0x59f7('0x8')](_0xeb6d1e)[_0x59f7('0x9')](_0x15903b);}};}function saveUpdates(_0x33bfc3){return function(_0x2c0fac){if(_0x2c0fac){return _0x2c0fac['update'](_0x33bfc3)[_0x59f7('0xa')](function(_0xdc23c7){return _0xdc23c7;});}return null;};}function handleEntityNotFound(_0x296a8d){return function(_0x2db28a){if(!_0x2db28a){_0x296a8d['sendStatus'](0x194);}return _0x2db28a;};}function handleError(_0x41b739,_0x4d345b){_0x4d345b=_0x4d345b||0x1f4;return function(_0x15a74d){logger['error'](_0x15a74d[_0x59f7('0xb')]);if(_0x15a74d[_0x59f7('0xc')]){delete _0x15a74d['name'];}_0x41b739['status'](_0x4d345b)[_0x59f7('0xd')](_0x15a74d);};}exports[_0x59f7('0xe')]=function(_0x2c75a2,_0x328bc5){if(_0x2c75a2[_0x59f7('0xf')][_0x59f7('0x10')]!=='admin')throw new Error('Unauthorized');if(isNaN(Number(_0x2c75a2['params']['id'])))throw new Error(_0x59f7('0x11'));return db['UserSetting'][_0x59f7('0x12')]({'where':{'id':_0x2c75a2[_0x59f7('0x13')]['id']}})[_0x59f7('0xa')](handleEntityNotFound(_0x328bc5,null))[_0x59f7('0xa')](saveUpdates(_0x2c75a2[_0x59f7('0x14')],null))[_0x59f7('0xa')](respondWithResult(_0x328bc5,null))[_0x59f7('0x15')](handleError(_0x328bc5,null));};
\ No newline at end of file