Built motion from commit b5996064.|2.6.21
[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 _0x34b2=['UserSetting','find','body','catch','lodash','ioredis','../../config/logger','api','../../config/environment','../../mysqldb','socket.io-emitter','redis','./user-setting.socket','register','defaults','status','json','then','sendStatus','error','stack','name','update','user','role','Unauthorized','params','Invalid\x20user\x20setting\x20id'];(function(_0x138adb,_0x193fee){var _0x1b27f2=function(_0x5e97a2){while(--_0x5e97a2){_0x138adb['push'](_0x138adb['shift']());}};_0x1b27f2(++_0x193fee);}(_0x34b2,0x11c));var _0x234b=function(_0x63500b,_0x508aa1){_0x63500b=_0x63500b-0x0;var _0x492332=_0x34b2[_0x63500b];return _0x492332;};'use strict';var _=require(_0x234b('0x0'));var Redis=require(_0x234b('0x1'));var logger=require(_0x234b('0x2'))(_0x234b('0x3'));var config=require(_0x234b('0x4'));var db=require(_0x234b('0x5'))['db'];var socket=require(_0x234b('0x6'))(new Redis(config[_0x234b('0x7')]));require(_0x234b('0x8'))[_0x234b('0x9')](socket);config[_0x234b('0x7')]=_[_0x234b('0xa')](config[_0x234b('0x7')],{'host':'localhost','port':0x18eb});function respondWithResult(_0x52fac7,_0x5e71ac){_0x5e71ac=_0x5e71ac||0xc8;return function(_0x2eb07e){if(_0x2eb07e){return _0x52fac7[_0x234b('0xb')](_0x5e71ac)[_0x234b('0xc')](_0x2eb07e);}};}function saveUpdates(_0x36d33f){return function(_0x4e4c50){if(_0x4e4c50){return _0x4e4c50['update'](_0x36d33f)[_0x234b('0xd')](function(_0x3a900b){return _0x3a900b;});}return null;};}function handleEntityNotFound(_0x277a27){return function(_0x30b17b){if(!_0x30b17b){_0x277a27[_0x234b('0xe')](0x194);}return _0x30b17b;};}function handleError(_0x1bd00f,_0x3e4f17){_0x3e4f17=_0x3e4f17||0x1f4;return function(_0x9dcfd3){logger[_0x234b('0xf')](_0x9dcfd3[_0x234b('0x10')]);if(_0x9dcfd3[_0x234b('0x11')]){delete _0x9dcfd3[_0x234b('0x11')];}_0x1bd00f[_0x234b('0xb')](_0x3e4f17)['send'](_0x9dcfd3);};}exports[_0x234b('0x12')]=function(_0x2f72d9,_0x4abf92){if(_0x2f72d9[_0x234b('0x13')][_0x234b('0x14')]!=='admin')throw new Error(_0x234b('0x15'));if(isNaN(Number(_0x2f72d9[_0x234b('0x16')]['id'])))throw new Error(_0x234b('0x17'));return db[_0x234b('0x18')][_0x234b('0x19')]({'where':{'id':_0x2f72d9[_0x234b('0x16')]['id']}})[_0x234b('0xd')](handleEntityNotFound(_0x4abf92,null))[_0x234b('0xd')](saveUpdates(_0x2f72d9[_0x234b('0x1a')],null))['then'](respondWithResult(_0x4abf92,null))[_0x234b('0x1b')](handleError(_0x4abf92,null));};