b86eefa2ea29483e51dab29ae40745963aa7198b
[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 _0xb377=['UserSetting','find','catch','lodash','ioredis','../../config/logger','api','../../config/environment','../../mysqldb','socket.io-emitter','redis','./user-setting.socket','register','defaults','status','json','update','then','sendStatus','error','stack','name','send','user','role','admin','Unauthorized','params','Invalid\x20user\x20setting\x20id'];(function(_0x23231b,_0x52d86c){var _0x180a5b=function(_0x4d183e){while(--_0x4d183e){_0x23231b['push'](_0x23231b['shift']());}};_0x180a5b(++_0x52d86c);}(_0xb377,0x1b6));var _0x7b37=function(_0x1c8485,_0x4c60ed){_0x1c8485=_0x1c8485-0x0;var _0x564fc6=_0xb377[_0x1c8485];return _0x564fc6;};'use strict';var _=require(_0x7b37('0x0'));var Redis=require(_0x7b37('0x1'));var logger=require(_0x7b37('0x2'))(_0x7b37('0x3'));var config=require(_0x7b37('0x4'));var db=require(_0x7b37('0x5'))['db'];var socket=require(_0x7b37('0x6'))(new Redis(config[_0x7b37('0x7')]));require(_0x7b37('0x8'))[_0x7b37('0x9')](socket);config[_0x7b37('0x7')]=_[_0x7b37('0xa')](config['redis'],{'host':'localhost','port':0x18eb});function respondWithResult(_0x409d34,_0x4cb89b){_0x4cb89b=_0x4cb89b||0xc8;return function(_0x5afdb8){if(_0x5afdb8){return _0x409d34[_0x7b37('0xb')](_0x4cb89b)[_0x7b37('0xc')](_0x5afdb8);}};}function saveUpdates(_0x62d37a){return function(_0x23d483){if(_0x23d483){return _0x23d483[_0x7b37('0xd')](_0x62d37a)[_0x7b37('0xe')](function(_0x4610cd){return _0x4610cd;});}return null;};}function handleEntityNotFound(_0x39c4ef){return function(_0x59bd03){if(!_0x59bd03){_0x39c4ef[_0x7b37('0xf')](0x194);}return _0x59bd03;};}function handleError(_0x20f993,_0x4a51b0){_0x4a51b0=_0x4a51b0||0x1f4;return function(_0x5e5fb5){logger[_0x7b37('0x10')](_0x5e5fb5[_0x7b37('0x11')]);if(_0x5e5fb5[_0x7b37('0x12')]){delete _0x5e5fb5[_0x7b37('0x12')];}_0x20f993[_0x7b37('0xb')](_0x4a51b0)[_0x7b37('0x13')](_0x5e5fb5);};}exports[_0x7b37('0xd')]=function(_0x6de05b,_0x1262cd){if(_0x6de05b[_0x7b37('0x14')][_0x7b37('0x15')]!==_0x7b37('0x16'))throw new Error(_0x7b37('0x17'));if(isNaN(Number(_0x6de05b[_0x7b37('0x18')]['id'])))throw new Error(_0x7b37('0x19'));return db[_0x7b37('0x1a')][_0x7b37('0x1b')]({'where':{'id':_0x6de05b['params']['id']}})['then'](handleEntityNotFound(_0x1262cd,null))[_0x7b37('0xe')](saveUpdates(_0x6de05b['body'],null))['then'](respondWithResult(_0x1262cd,null))[_0x7b37('0x1c')](handleError(_0x1262cd,null));};