Built motion from commit b0a9a629.|2.6.33
[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 _0x615a=['Invalid\x20user\x20setting\x20id','UserSetting','find','body','catch','lodash','../../config/logger','../../config/environment','../../mysqldb','socket.io-emitter','redis','register','status','json','then','sendStatus','name','send','update','role','admin','Unauthorized','params'];(function(_0x2e2334,_0x8ffa8b){var _0x31991c=function(_0x14c2bd){while(--_0x14c2bd){_0x2e2334['push'](_0x2e2334['shift']());}};_0x31991c(++_0x8ffa8b);}(_0x615a,0x119));var _0xa615=function(_0x10dc60,_0x2fcce1){_0x10dc60=_0x10dc60-0x0;var _0x47dec5=_0x615a[_0x10dc60];return _0x47dec5;};'use strict';var _=require(_0xa615('0x0'));var Redis=require('ioredis');var logger=require(_0xa615('0x1'))('api');var config=require(_0xa615('0x2'));var db=require(_0xa615('0x3'))['db'];var socket=require(_0xa615('0x4'))(new Redis(config[_0xa615('0x5')]));require('./user-setting.socket')[_0xa615('0x6')](socket);config[_0xa615('0x5')]=_['defaults'](config[_0xa615('0x5')],{'host':'localhost','port':0x18eb});function respondWithResult(_0x44afda,_0x389dd4){_0x389dd4=_0x389dd4||0xc8;return function(_0x2db48d){if(_0x2db48d){return _0x44afda[_0xa615('0x7')](_0x389dd4)[_0xa615('0x8')](_0x2db48d);}};}function saveUpdates(_0x59d2a8){return function(_0x25a604){if(_0x25a604){return _0x25a604['update'](_0x59d2a8)[_0xa615('0x9')](function(_0x3fbfe1){return _0x3fbfe1;});}return null;};}function handleEntityNotFound(_0x5a6664){return function(_0x3b1698){if(!_0x3b1698){_0x5a6664[_0xa615('0xa')](0x194);}return _0x3b1698;};}function handleError(_0x16c90b,_0x32ad53){_0x32ad53=_0x32ad53||0x1f4;return function(_0x2530ec){logger['error'](_0x2530ec['stack']);if(_0x2530ec[_0xa615('0xb')]){delete _0x2530ec['name'];}_0x16c90b[_0xa615('0x7')](_0x32ad53)[_0xa615('0xc')](_0x2530ec);};}exports[_0xa615('0xd')]=function(_0x21eb04,_0x5a5b3e){if(_0x21eb04['user'][_0xa615('0xe')]!==_0xa615('0xf'))throw new Error(_0xa615('0x10'));if(isNaN(Number(_0x21eb04[_0xa615('0x11')]['id'])))throw new Error(_0xa615('0x12'));return db[_0xa615('0x13')][_0xa615('0x14')]({'where':{'id':_0x21eb04[_0xa615('0x11')]['id']}})[_0xa615('0x9')](handleEntityNotFound(_0x5a5b3e,null))[_0xa615('0x9')](saveUpdates(_0x21eb04[_0xa615('0x15')],null))[_0xa615('0x9')](respondWithResult(_0x5a5b3e,null))[_0xa615('0x16')](handleError(_0x5a5b3e,null));};