de8758871cae1eacaaaf5487c6c14c5fdf96c5ee
[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 _0x3c6d=['UserSetting','find','body','catch','lodash','ioredis','../../config/logger','api','../../mysqldb','socket.io-emitter','redis','./user-setting.socket','register','localhost','status','update','then','sendStatus','error','stack','name','send','user','admin','Unauthorized','params','Invalid\x20user\x20setting\x20id'];(function(_0x2aed90,_0x3424a6){var _0x36edd8=function(_0x246af4){while(--_0x246af4){_0x2aed90['push'](_0x2aed90['shift']());}};_0x36edd8(++_0x3424a6);}(_0x3c6d,0x199));var _0xd3c6=function(_0xb9ae87,_0x402833){_0xb9ae87=_0xb9ae87-0x0;var _0x32c1f0=_0x3c6d[_0xb9ae87];return _0x32c1f0;};'use strict';var _=require(_0xd3c6('0x0'));var Redis=require(_0xd3c6('0x1'));var logger=require(_0xd3c6('0x2'))(_0xd3c6('0x3'));var config=require('../../config/environment');var db=require(_0xd3c6('0x4'))['db'];var socket=require(_0xd3c6('0x5'))(new Redis(config[_0xd3c6('0x6')]));require(_0xd3c6('0x7'))[_0xd3c6('0x8')](socket);config[_0xd3c6('0x6')]=_['defaults'](config[_0xd3c6('0x6')],{'host':_0xd3c6('0x9'),'port':0x18eb});function respondWithResult(_0x438b25,_0x303abf){_0x303abf=_0x303abf||0xc8;return function(_0x341f8a){if(_0x341f8a){return _0x438b25[_0xd3c6('0xa')](_0x303abf)['json'](_0x341f8a);}};}function saveUpdates(_0x4e0fc6){return function(_0x63e5ac){if(_0x63e5ac){return _0x63e5ac[_0xd3c6('0xb')](_0x4e0fc6)[_0xd3c6('0xc')](function(_0x4ed22f){return _0x4ed22f;});}return null;};}function handleEntityNotFound(_0x1b7e6d){return function(_0x5c14ec){if(!_0x5c14ec){_0x1b7e6d[_0xd3c6('0xd')](0x194);}return _0x5c14ec;};}function handleError(_0x48856f,_0x5603c8){_0x5603c8=_0x5603c8||0x1f4;return function(_0x260608){logger[_0xd3c6('0xe')](_0x260608[_0xd3c6('0xf')]);if(_0x260608[_0xd3c6('0x10')]){delete _0x260608[_0xd3c6('0x10')];}_0x48856f[_0xd3c6('0xa')](_0x5603c8)[_0xd3c6('0x11')](_0x260608);};}exports[_0xd3c6('0xb')]=function(_0x34fbd3,_0x393a30){if(_0x34fbd3[_0xd3c6('0x12')]['role']!==_0xd3c6('0x13'))throw new Error(_0xd3c6('0x14'));if(isNaN(Number(_0x34fbd3[_0xd3c6('0x15')]['id'])))throw new Error(_0xd3c6('0x16'));return db[_0xd3c6('0x17')][_0xd3c6('0x18')]({'where':{'id':_0x34fbd3[_0xd3c6('0x15')]['id']}})[_0xd3c6('0xc')](handleEntityNotFound(_0x393a30,null))[_0xd3c6('0xc')](saveUpdates(_0x34fbd3[_0xd3c6('0x19')],null))[_0xd3c6('0xc')](respondWithResult(_0x393a30,null))[_0xd3c6('0x1a')](handleError(_0x393a30,null));};