Built motion from commit c1aa34a0.|2.6.28
[motion2.git] / server / api / user-setting / user-setting.controller.js
index e9d1c25..0278876 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xbf83=['name','status','send','user','role','params','Invalid\x20user\x20setting\x20id','UserSetting','find','body','catch','lodash','../../config/logger','api','../../config/environment','../../mysqldb','socket.io-emitter','register','redis','defaults','json','update','then','sendStatus','stack'];(function(_0x5f12b1,_0x4df658){var _0x3290f7=function(_0x41cbe5){while(--_0x41cbe5){_0x5f12b1['push'](_0x5f12b1['shift']());}};_0x3290f7(++_0x4df658);}(_0xbf83,0x11e));var _0x3bf8=function(_0xb99346,_0xe507d5){_0xb99346=_0xb99346-0x0;var _0xd4881a=_0xbf83[_0xb99346];return _0xd4881a;};'use strict';var _=require(_0x3bf8('0x0'));var Redis=require('ioredis');var logger=require(_0x3bf8('0x1'))(_0x3bf8('0x2'));var config=require(_0x3bf8('0x3'));var db=require(_0x3bf8('0x4'))['db'];var socket=require(_0x3bf8('0x5'))(new Redis(config['redis']));require('./user-setting.socket')[_0x3bf8('0x6')](socket);config[_0x3bf8('0x7')]=_[_0x3bf8('0x8')](config[_0x3bf8('0x7')],{'host':'localhost','port':0x18eb});function respondWithResult(_0x5b0c12,_0x168a20){_0x168a20=_0x168a20||0xc8;return function(_0x2df7c9){if(_0x2df7c9){return _0x5b0c12['status'](_0x168a20)[_0x3bf8('0x9')](_0x2df7c9);}};}function saveUpdates(_0x538bec){return function(_0x2f07a8){if(_0x2f07a8){return _0x2f07a8[_0x3bf8('0xa')](_0x538bec)[_0x3bf8('0xb')](function(_0x281063){return _0x281063;});}return null;};}function handleEntityNotFound(_0x2ee63c){return function(_0xc9f419){if(!_0xc9f419){_0x2ee63c[_0x3bf8('0xc')](0x194);}return _0xc9f419;};}function handleError(_0x5d1274,_0xb88128){_0xb88128=_0xb88128||0x1f4;return function(_0x3e0ab0){logger['error'](_0x3e0ab0[_0x3bf8('0xd')]);if(_0x3e0ab0[_0x3bf8('0xe')]){delete _0x3e0ab0[_0x3bf8('0xe')];}_0x5d1274[_0x3bf8('0xf')](_0xb88128)[_0x3bf8('0x10')](_0x3e0ab0);};}exports[_0x3bf8('0xa')]=function(_0x27b4e1,_0x260445){if(_0x27b4e1[_0x3bf8('0x11')][_0x3bf8('0x12')]!=='admin')throw new Error('Unauthorized');if(isNaN(Number(_0x27b4e1[_0x3bf8('0x13')]['id'])))throw new Error(_0x3bf8('0x14'));return db[_0x3bf8('0x15')][_0x3bf8('0x16')]({'where':{'id':_0x27b4e1['params']['id']}})[_0x3bf8('0xb')](handleEntityNotFound(_0x260445,null))[_0x3bf8('0xb')](saveUpdates(_0x27b4e1[_0x3bf8('0x17')],null))[_0x3bf8('0xb')](respondWithResult(_0x260445,null))[_0x3bf8('0x18')](handleError(_0x260445,null));};
\ No newline at end of file
+var _0x9ef8=['admin','params','find','lodash','ioredis','api','../../config/environment','../../mysqldb','redis','./user-setting.socket','localhost','status','json','then','sendStatus','error','name','send','user','role'];(function(_0x356e5c,_0x23156b){var _0x459517=function(_0x425042){while(--_0x425042){_0x356e5c['push'](_0x356e5c['shift']());}};_0x459517(++_0x23156b);}(_0x9ef8,0x17f));var _0x89ef=function(_0x3d27ba,_0x2671a3){_0x3d27ba=_0x3d27ba-0x0;var _0xf01885=_0x9ef8[_0x3d27ba];return _0xf01885;};'use strict';var _=require(_0x89ef('0x0'));var Redis=require(_0x89ef('0x1'));var logger=require('../../config/logger')(_0x89ef('0x2'));var config=require(_0x89ef('0x3'));var db=require(_0x89ef('0x4'))['db'];var socket=require('socket.io-emitter')(new Redis(config[_0x89ef('0x5')]));require(_0x89ef('0x6'))['register'](socket);config['redis']=_['defaults'](config[_0x89ef('0x5')],{'host':_0x89ef('0x7'),'port':0x18eb});function respondWithResult(_0x24439e,_0x90b5bf){_0x90b5bf=_0x90b5bf||0xc8;return function(_0x46c0da){if(_0x46c0da){return _0x24439e[_0x89ef('0x8')](_0x90b5bf)[_0x89ef('0x9')](_0x46c0da);}};}function saveUpdates(_0x3d204a){return function(_0xbd0084){if(_0xbd0084){return _0xbd0084['update'](_0x3d204a)[_0x89ef('0xa')](function(_0x4687cb){return _0x4687cb;});}return null;};}function handleEntityNotFound(_0x30c8f4){return function(_0x5c5435){if(!_0x5c5435){_0x30c8f4[_0x89ef('0xb')](0x194);}return _0x5c5435;};}function handleError(_0x7f5df1,_0x1c69aa){_0x1c69aa=_0x1c69aa||0x1f4;return function(_0x4b52dc){logger[_0x89ef('0xc')](_0x4b52dc['stack']);if(_0x4b52dc[_0x89ef('0xd')]){delete _0x4b52dc['name'];}_0x7f5df1[_0x89ef('0x8')](_0x1c69aa)[_0x89ef('0xe')](_0x4b52dc);};}exports['update']=function(_0x21ac0b,_0x269192){if(_0x21ac0b[_0x89ef('0xf')][_0x89ef('0x10')]!==_0x89ef('0x11'))throw new Error('Unauthorized');if(isNaN(Number(_0x21ac0b[_0x89ef('0x12')]['id'])))throw new Error('Invalid\x20user\x20setting\x20id');return db['UserSetting'][_0x89ef('0x13')]({'where':{'id':_0x21ac0b[_0x89ef('0x12')]['id']}})['then'](handleEntityNotFound(_0x269192,null))[_0x89ef('0xa')](saveUpdates(_0x21ac0b['body'],null))[_0x89ef('0xa')](respondWithResult(_0x269192,null))['catch'](handleError(_0x269192,null));};
\ No newline at end of file