Built motion from commit 9d0783e6.|2.6.13
[motion2.git] / server / api / user-setting / user-setting.controller.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
13 // * The SOFTWARE PRODUCT is protected by copyright laws and international *
14 // * copyright treaties, as well as other intellectual property laws and   *
15 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                         *
16 // *                                                                       *
17 // *************************************************************************
18 var _0x3ae9=['then','body','catch','../../config/logger','api','../../config/environment','socket.io-emitter','redis','./user-setting.socket','register','defaults','localhost','status','json','sendStatus','name','update','user','admin','Unauthorized','params','Invalid\x20user\x20setting\x20id','UserSetting','find'];(function(_0x2343ab,_0x16a68e){var _0x4f52fc=function(_0x5405a6){while(--_0x5405a6){_0x2343ab['push'](_0x2343ab['shift']());}};_0x4f52fc(++_0x16a68e);}(_0x3ae9,0xdb));var _0x93ae=function(_0x465028,_0x4570ac){_0x465028=_0x465028-0x0;var _0xb783d4=_0x3ae9[_0x465028];return _0xb783d4;};'use strict';var _=require('lodash');var Redis=require('ioredis');var logger=require(_0x93ae('0x0'))(_0x93ae('0x1'));var config=require(_0x93ae('0x2'));var db=require('../../mysqldb')['db'];var socket=require(_0x93ae('0x3'))(new Redis(config[_0x93ae('0x4')]));require(_0x93ae('0x5'))[_0x93ae('0x6')](socket);config['redis']=_[_0x93ae('0x7')](config['redis'],{'host':_0x93ae('0x8'),'port':0x18eb});function respondWithResult(_0x32564c,_0x2a0972){_0x2a0972=_0x2a0972||0xc8;return function(_0x36e141){if(_0x36e141){return _0x32564c[_0x93ae('0x9')](_0x2a0972)[_0x93ae('0xa')](_0x36e141);}};}function saveUpdates(_0x57d1f6){return function(_0x3874e2){if(_0x3874e2){return _0x3874e2['update'](_0x57d1f6)['then'](function(_0x5a373a){return _0x5a373a;});}return null;};}function handleEntityNotFound(_0x14c3c3){return function(_0x7eb772){if(!_0x7eb772){_0x14c3c3[_0x93ae('0xb')](0x194);}return _0x7eb772;};}function handleError(_0x9eb4ea,_0x2d9be2){_0x2d9be2=_0x2d9be2||0x1f4;return function(_0x3a5011){logger['error'](_0x3a5011['stack']);if(_0x3a5011[_0x93ae('0xc')]){delete _0x3a5011[_0x93ae('0xc')];}_0x9eb4ea['status'](_0x2d9be2)['send'](_0x3a5011);};}exports[_0x93ae('0xd')]=function(_0x4b2127,_0x337f2e){if(_0x4b2127[_0x93ae('0xe')]['role']!==_0x93ae('0xf'))throw new Error(_0x93ae('0x10'));if(isNaN(Number(_0x4b2127[_0x93ae('0x11')]['id'])))throw new Error(_0x93ae('0x12'));return db[_0x93ae('0x13')][_0x93ae('0x14')]({'where':{'id':_0x4b2127['params']['id']}})[_0x93ae('0x15')](handleEntityNotFound(_0x337f2e,null))[_0x93ae('0x15')](saveUpdates(_0x4b2127[_0x93ae('0x16')],null))['then'](respondWithResult(_0x337f2e,null))[_0x93ae('0x17')](handleError(_0x337f2e,null));};