Built motion from commit 15aa0e42.|2.6.19
[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 _0x59c3=['send','user','role','admin','params','Invalid\x20user\x20setting\x20id','find','then','body','catch','lodash','ioredis','../../config/logger','api','../../config/environment','../../mysqldb','redis','./user-setting.socket','register','defaults','status','json','update','sendStatus','error','stack','name'];(function(_0x50ed96,_0x19bac2){var _0x193c04=function(_0x3d7769){while(--_0x3d7769){_0x50ed96['push'](_0x50ed96['shift']());}};_0x193c04(++_0x19bac2);}(_0x59c3,0x133));var _0x359c=function(_0x13ea00,_0x12f610){_0x13ea00=_0x13ea00-0x0;var _0x1f7347=_0x59c3[_0x13ea00];return _0x1f7347;};'use strict';var _=require(_0x359c('0x0'));var Redis=require(_0x359c('0x1'));var logger=require(_0x359c('0x2'))(_0x359c('0x3'));var config=require(_0x359c('0x4'));var db=require(_0x359c('0x5'))['db'];var socket=require('socket.io-emitter')(new Redis(config[_0x359c('0x6')]));require(_0x359c('0x7'))[_0x359c('0x8')](socket);config[_0x359c('0x6')]=_[_0x359c('0x9')](config[_0x359c('0x6')],{'host':'localhost','port':0x18eb});function respondWithResult(_0x9c107b,_0x58b390){_0x58b390=_0x58b390||0xc8;return function(_0x3a7d8e){if(_0x3a7d8e){return _0x9c107b[_0x359c('0xa')](_0x58b390)[_0x359c('0xb')](_0x3a7d8e);}};}function saveUpdates(_0x682720){return function(_0x536426){if(_0x536426){return _0x536426[_0x359c('0xc')](_0x682720)['then'](function(_0x15b56d){return _0x15b56d;});}return null;};}function handleEntityNotFound(_0x1d7417){return function(_0xb48a01){if(!_0xb48a01){_0x1d7417[_0x359c('0xd')](0x194);}return _0xb48a01;};}function handleError(_0x160271,_0x218e8b){_0x218e8b=_0x218e8b||0x1f4;return function(_0x5567d7){logger[_0x359c('0xe')](_0x5567d7[_0x359c('0xf')]);if(_0x5567d7[_0x359c('0x10')]){delete _0x5567d7[_0x359c('0x10')];}_0x160271[_0x359c('0xa')](_0x218e8b)[_0x359c('0x11')](_0x5567d7);};}exports[_0x359c('0xc')]=function(_0x246dc1,_0x3a73ca){if(_0x246dc1[_0x359c('0x12')][_0x359c('0x13')]!==_0x359c('0x14'))throw new Error('Unauthorized');if(isNaN(Number(_0x246dc1[_0x359c('0x15')]['id'])))throw new Error(_0x359c('0x16'));return db['UserSetting'][_0x359c('0x17')]({'where':{'id':_0x246dc1[_0x359c('0x15')]['id']}})[_0x359c('0x18')](handleEntityNotFound(_0x3a73ca,null))[_0x359c('0x18')](saveUpdates(_0x246dc1[_0x359c('0x19')],null))[_0x359c('0x18')](respondWithResult(_0x3a73ca,null))[_0x359c('0x1a')](handleError(_0x3a73ca,null));};