1 // *************************************************************************
3 // * xCALLY Motion - The Omnichannel Contact Center *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved *
6 // *************************************************************************
8 // * Email: info@xcally.com *
9 // * Website: https://www.xcally.com *
11 // *************************************************************************
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. *
17 // *************************************************************************
18 var _0xbfda=['status','json','update','then','sendStatus','error','stack','name','send','user','admin','Unauthorized','params','Invalid\x20user\x20setting\x20id','UserSetting','find','catch','lodash','ioredis','../../config/logger','../../config/environment','socket.io-emitter','redis','./user-setting.socket','register','defaults','localhost'];(function(_0x5447aa,_0x3afc00){var _0xb21e53=function(_0x2d05f6){while(--_0x2d05f6){_0x5447aa['push'](_0x5447aa['shift']());}};_0xb21e53(++_0x3afc00);}(_0xbfda,0x1dc));var _0xabfd=function(_0x5c72ee,_0x5a8bf8){_0x5c72ee=_0x5c72ee-0x0;var _0x231876=_0xbfda[_0x5c72ee];return _0x231876;};'use strict';var _=require(_0xabfd('0x0'));var Redis=require(_0xabfd('0x1'));var logger=require(_0xabfd('0x2'))('api');var config=require(_0xabfd('0x3'));var db=require('../../mysqldb')['db'];var socket=require(_0xabfd('0x4'))(new Redis(config[_0xabfd('0x5')]));require(_0xabfd('0x6'))[_0xabfd('0x7')](socket);config['redis']=_[_0xabfd('0x8')](config['redis'],{'host':_0xabfd('0x9'),'port':0x18eb});function respondWithResult(_0x537d54,_0x27ca51){_0x27ca51=_0x27ca51||0xc8;return function(_0x49368e){if(_0x49368e){return _0x537d54[_0xabfd('0xa')](_0x27ca51)[_0xabfd('0xb')](_0x49368e);}};}function saveUpdates(_0x1b4264){return function(_0x3ddf0e){if(_0x3ddf0e){return _0x3ddf0e[_0xabfd('0xc')](_0x1b4264)[_0xabfd('0xd')](function(_0x557b3f){return _0x557b3f;});}return null;};}function handleEntityNotFound(_0x3d3448){return function(_0xfef859){if(!_0xfef859){_0x3d3448[_0xabfd('0xe')](0x194);}return _0xfef859;};}function handleError(_0x285d2c,_0x3d779a){_0x3d779a=_0x3d779a||0x1f4;return function(_0x2b2469){logger[_0xabfd('0xf')](_0x2b2469[_0xabfd('0x10')]);if(_0x2b2469[_0xabfd('0x11')]){delete _0x2b2469[_0xabfd('0x11')];}_0x285d2c[_0xabfd('0xa')](_0x3d779a)[_0xabfd('0x12')](_0x2b2469);};}exports[_0xabfd('0xc')]=function(_0x53e590,_0x1c0216){if(_0x53e590[_0xabfd('0x13')]['role']!==_0xabfd('0x14'))throw new Error(_0xabfd('0x15'));if(isNaN(Number(_0x53e590[_0xabfd('0x16')]['id'])))throw new Error(_0xabfd('0x17'));return db[_0xabfd('0x18')][_0xabfd('0x19')]({'where':{'id':_0x53e590[_0xabfd('0x16')]['id']}})[_0xabfd('0xd')](handleEntityNotFound(_0x1c0216,null))[_0xabfd('0xd')](saveUpdates(_0x53e590['body'],null))[_0xabfd('0xd')](respondWithResult(_0x1c0216,null))[_0xabfd('0x1a')](handleError(_0x1c0216,null));};