4eba9746b628f60bd81c978d326e841f22a4822f
[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 _0xc831=['role','admin','Unauthorized','params','Invalid\x20user\x20setting\x20id','find','ioredis','../../config/logger','api','../../config/environment','../../mysqldb','socket.io-emitter','redis','./user-setting.socket','register','localhost','status','json','update','then','sendStatus','name','send'];(function(_0x2f387b,_0x1896d6){var _0x37d45e=function(_0x45d5d7){while(--_0x45d5d7){_0x2f387b['push'](_0x2f387b['shift']());}};_0x37d45e(++_0x1896d6);}(_0xc831,0x103));var _0x1c83=function(_0x539fe6,_0x4e4ed1){_0x539fe6=_0x539fe6-0x0;var _0x31f240=_0xc831[_0x539fe6];return _0x31f240;};'use strict';var _=require('lodash');var Redis=require(_0x1c83('0x0'));var logger=require(_0x1c83('0x1'))(_0x1c83('0x2'));var config=require(_0x1c83('0x3'));var db=require(_0x1c83('0x4'))['db'];var socket=require(_0x1c83('0x5'))(new Redis(config[_0x1c83('0x6')]));require(_0x1c83('0x7'))[_0x1c83('0x8')](socket);config[_0x1c83('0x6')]=_['defaults'](config['redis'],{'host':_0x1c83('0x9'),'port':0x18eb});function respondWithResult(_0x52ec70,_0x1ce77e){_0x1ce77e=_0x1ce77e||0xc8;return function(_0x1953e5){if(_0x1953e5){return _0x52ec70[_0x1c83('0xa')](_0x1ce77e)[_0x1c83('0xb')](_0x1953e5);}};}function saveUpdates(_0x282313){return function(_0x5e1d8d){if(_0x5e1d8d){return _0x5e1d8d[_0x1c83('0xc')](_0x282313)[_0x1c83('0xd')](function(_0x534a07){return _0x534a07;});}return null;};}function handleEntityNotFound(_0x5cd9ee){return function(_0x40f50b){if(!_0x40f50b){_0x5cd9ee[_0x1c83('0xe')](0x194);}return _0x40f50b;};}function handleError(_0x29369e,_0x5db682){_0x5db682=_0x5db682||0x1f4;return function(_0x872a13){logger['error'](_0x872a13['stack']);if(_0x872a13[_0x1c83('0xf')]){delete _0x872a13[_0x1c83('0xf')];}_0x29369e[_0x1c83('0xa')](_0x5db682)[_0x1c83('0x10')](_0x872a13);};}exports[_0x1c83('0xc')]=function(_0x1f1e1d,_0x132759){if(_0x1f1e1d['user'][_0x1c83('0x11')]!==_0x1c83('0x12'))throw new Error(_0x1c83('0x13'));if(isNaN(Number(_0x1f1e1d[_0x1c83('0x14')]['id'])))throw new Error(_0x1c83('0x15'));return db['UserSetting'][_0x1c83('0x16')]({'where':{'id':_0x1f1e1d[_0x1c83('0x14')]['id']}})[_0x1c83('0xd')](handleEntityNotFound(_0x132759,null))[_0x1c83('0xd')](saveUpdates(_0x1f1e1d['body'],null))[_0x1c83('0xd')](respondWithResult(_0x132759,null))['catch'](handleError(_0x132759,null));};