Built motion from commit 0d14f64c.|2.6.34
[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 _0x61a5=['../../config/environment','../../mysqldb','socket.io-emitter','./user-setting.socket','register','defaults','redis','localhost','status','update','then','error','stack','name','send','user','role','Unauthorized','params','Invalid\x20user\x20setting\x20id','UserSetting','find','body','catch','lodash','../../config/logger','api'];(function(_0x10c467,_0x298f44){var _0x92aaa2=function(_0x233054){while(--_0x233054){_0x10c467['push'](_0x10c467['shift']());}};_0x92aaa2(++_0x298f44);}(_0x61a5,0xf0));var _0x561a=function(_0x687ddc,_0x2092fa){_0x687ddc=_0x687ddc-0x0;var _0x441991=_0x61a5[_0x687ddc];return _0x441991;};'use strict';var _=require(_0x561a('0x0'));var Redis=require('ioredis');var logger=require(_0x561a('0x1'))(_0x561a('0x2'));var config=require(_0x561a('0x3'));var db=require(_0x561a('0x4'))['db'];var socket=require(_0x561a('0x5'))(new Redis(config['redis']));require(_0x561a('0x6'))[_0x561a('0x7')](socket);config['redis']=_[_0x561a('0x8')](config[_0x561a('0x9')],{'host':_0x561a('0xa'),'port':0x18eb});function respondWithResult(_0x2646bd,_0x3d55f8){_0x3d55f8=_0x3d55f8||0xc8;return function(_0xfe091){if(_0xfe091){return _0x2646bd[_0x561a('0xb')](_0x3d55f8)['json'](_0xfe091);}};}function saveUpdates(_0x3db11c){return function(_0x52563e){if(_0x52563e){return _0x52563e[_0x561a('0xc')](_0x3db11c)[_0x561a('0xd')](function(_0x5b3510){return _0x5b3510;});}return null;};}function handleEntityNotFound(_0x34e464){return function(_0x4071ba){if(!_0x4071ba){_0x34e464['sendStatus'](0x194);}return _0x4071ba;};}function handleError(_0x3a1eee,_0x5cc8ed){_0x5cc8ed=_0x5cc8ed||0x1f4;return function(_0x205e99){logger[_0x561a('0xe')](_0x205e99[_0x561a('0xf')]);if(_0x205e99[_0x561a('0x10')]){delete _0x205e99[_0x561a('0x10')];}_0x3a1eee[_0x561a('0xb')](_0x5cc8ed)[_0x561a('0x11')](_0x205e99);};}exports[_0x561a('0xc')]=function(_0x8c1952,_0x4f1e33){if(_0x8c1952[_0x561a('0x12')][_0x561a('0x13')]!=='admin')throw new Error(_0x561a('0x14'));if(isNaN(Number(_0x8c1952[_0x561a('0x15')]['id'])))throw new Error(_0x561a('0x16'));return db[_0x561a('0x17')][_0x561a('0x18')]({'where':{'id':_0x8c1952[_0x561a('0x15')]['id']}})[_0x561a('0xd')](handleEntityNotFound(_0x4f1e33,null))[_0x561a('0xd')](saveUpdates(_0x8c1952[_0x561a('0x19')],null))[_0x561a('0xd')](respondWithResult(_0x4f1e33,null))[_0x561a('0x1a')](handleError(_0x4f1e33,null));};