ee160434b5c8054fd867a84e99575a76af3df7d5
[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 _0xd691=['../../config/logger','../../config/environment','../../mysqldb','socket.io-emitter','redis','./user-setting.socket','register','defaults','localhost','json','update','sendStatus','error','stack','name','status','send','user','role','admin','Unauthorized','UserSetting','find','params','then','body','catch','lodash','ioredis'];(function(_0x45d50b,_0x25cfa9){var _0xba96f3=function(_0x54e414){while(--_0x54e414){_0x45d50b['push'](_0x45d50b['shift']());}};_0xba96f3(++_0x25cfa9);}(_0xd691,0xe6));var _0x1d69=function(_0x1d426f,_0x37e919){_0x1d426f=_0x1d426f-0x0;var _0x17f71a=_0xd691[_0x1d426f];return _0x17f71a;};'use strict';var _=require(_0x1d69('0x0'));var Redis=require(_0x1d69('0x1'));var logger=require(_0x1d69('0x2'))('api');var config=require(_0x1d69('0x3'));var db=require(_0x1d69('0x4'))['db'];var socket=require(_0x1d69('0x5'))(new Redis(config[_0x1d69('0x6')]));require(_0x1d69('0x7'))[_0x1d69('0x8')](socket);config[_0x1d69('0x6')]=_[_0x1d69('0x9')](config[_0x1d69('0x6')],{'host':_0x1d69('0xa'),'port':0x18eb});function respondWithResult(_0x5a5b0c,_0x520acb){_0x520acb=_0x520acb||0xc8;return function(_0x267da3){if(_0x267da3){return _0x5a5b0c['status'](_0x520acb)[_0x1d69('0xb')](_0x267da3);}};}function saveUpdates(_0x122b27){return function(_0x1a09f0){if(_0x1a09f0){return _0x1a09f0[_0x1d69('0xc')](_0x122b27)['then'](function(_0x298c17){return _0x298c17;});}return null;};}function handleEntityNotFound(_0xe9eae1){return function(_0x296541){if(!_0x296541){_0xe9eae1[_0x1d69('0xd')](0x194);}return _0x296541;};}function handleError(_0x294e75,_0x5d2092){_0x5d2092=_0x5d2092||0x1f4;return function(_0x5d1c82){logger[_0x1d69('0xe')](_0x5d1c82[_0x1d69('0xf')]);if(_0x5d1c82[_0x1d69('0x10')]){delete _0x5d1c82[_0x1d69('0x10')];}_0x294e75[_0x1d69('0x11')](_0x5d2092)[_0x1d69('0x12')](_0x5d1c82);};}exports[_0x1d69('0xc')]=function(_0x1d98be,_0x276389){if(_0x1d98be[_0x1d69('0x13')][_0x1d69('0x14')]!==_0x1d69('0x15'))throw new Error(_0x1d69('0x16'));if(isNaN(Number(_0x1d98be['params']['id'])))throw new Error('Invalid\x20user\x20setting\x20id');return db[_0x1d69('0x17')][_0x1d69('0x18')]({'where':{'id':_0x1d98be[_0x1d69('0x19')]['id']}})[_0x1d69('0x1a')](handleEntityNotFound(_0x276389,null))[_0x1d69('0x1a')](saveUpdates(_0x1d98be[_0x1d69('0x1b')],null))['then'](respondWithResult(_0x276389,null))[_0x1d69('0x1c')](handleError(_0x276389,null));};