Built motion from commit 5ae82ce5.|2.6.7
[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 _0xf874=['status','update','then','sendStatus','error','stack','name','role','Unauthorized','params','Invalid\x20user\x20setting\x20id','UserSetting','find','body','catch','lodash','../../config/logger','api','../../config/environment','../../mysqldb','socket.io-emitter','redis','./user-setting.socket','defaults'];(function(_0x4e9628,_0x250573){var _0x27bc8c=function(_0xb3b7ae){while(--_0xb3b7ae){_0x4e9628['push'](_0x4e9628['shift']());}};_0x27bc8c(++_0x250573);}(_0xf874,0x177));var _0x4f87=function(_0x29019b,_0x816250){_0x29019b=_0x29019b-0x0;var _0x378e6e=_0xf874[_0x29019b];return _0x378e6e;};'use strict';var _=require(_0x4f87('0x0'));var Redis=require('ioredis');var logger=require(_0x4f87('0x1'))(_0x4f87('0x2'));var config=require(_0x4f87('0x3'));var db=require(_0x4f87('0x4'))['db'];var socket=require(_0x4f87('0x5'))(new Redis(config[_0x4f87('0x6')]));require(_0x4f87('0x7'))['register'](socket);config[_0x4f87('0x6')]=_[_0x4f87('0x8')](config['redis'],{'host':'localhost','port':0x18eb});function respondWithResult(_0x497346,_0x4ac62f){_0x4ac62f=_0x4ac62f||0xc8;return function(_0x55a9b0){if(_0x55a9b0){return _0x497346[_0x4f87('0x9')](_0x4ac62f)['json'](_0x55a9b0);}};}function saveUpdates(_0x1bcbde){return function(_0x434b3f){if(_0x434b3f){return _0x434b3f[_0x4f87('0xa')](_0x1bcbde)[_0x4f87('0xb')](function(_0x4dfb28){return _0x4dfb28;});}return null;};}function handleEntityNotFound(_0x25dea7){return function(_0x364d09){if(!_0x364d09){_0x25dea7[_0x4f87('0xc')](0x194);}return _0x364d09;};}function handleError(_0x1777bb,_0x1faa4e){_0x1faa4e=_0x1faa4e||0x1f4;return function(_0x442128){logger[_0x4f87('0xd')](_0x442128[_0x4f87('0xe')]);if(_0x442128[_0x4f87('0xf')]){delete _0x442128[_0x4f87('0xf')];}_0x1777bb[_0x4f87('0x9')](_0x1faa4e)['send'](_0x442128);};}exports[_0x4f87('0xa')]=function(_0x16833c,_0x501ee7){if(_0x16833c['user'][_0x4f87('0x10')]!=='admin')throw new Error(_0x4f87('0x11'));if(isNaN(Number(_0x16833c[_0x4f87('0x12')]['id'])))throw new Error(_0x4f87('0x13'));return db[_0x4f87('0x14')][_0x4f87('0x15')]({'where':{'id':_0x16833c[_0x4f87('0x12')]['id']}})[_0x4f87('0xb')](handleEntityNotFound(_0x501ee7,null))[_0x4f87('0xb')](saveUpdates(_0x16833c[_0x4f87('0x16')],null))[_0x4f87('0xb')](respondWithResult(_0x501ee7,null))[_0x4f87('0x17')](handleError(_0x501ee7,null));};