Built motion from commit 25580385.|2.6.2
[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 _0x5af0=['../../config/logger','api','../../config/environment','../../mysqldb','socket.io-emitter','redis','register','defaults','localhost','status','json','sendStatus','stack','name','send','update','user','role','admin','Unauthorized','params','Invalid\x20user\x20setting\x20id','UserSetting','find','body','then','catch','lodash','ioredis'];(function(_0x3a88d5,_0x55b44b){var _0x34c22e=function(_0x33964a){while(--_0x33964a){_0x3a88d5['push'](_0x3a88d5['shift']());}};_0x34c22e(++_0x55b44b);}(_0x5af0,0x1eb));var _0x05af=function(_0x5c036b,_0x39fd65){_0x5c036b=_0x5c036b-0x0;var _0x1b27b1=_0x5af0[_0x5c036b];return _0x1b27b1;};'use strict';var _=require(_0x05af('0x0'));var Redis=require(_0x05af('0x1'));var logger=require(_0x05af('0x2'))(_0x05af('0x3'));var config=require(_0x05af('0x4'));var db=require(_0x05af('0x5'))['db'];var socket=require(_0x05af('0x6'))(new Redis(config[_0x05af('0x7')]));require('./user-setting.socket')[_0x05af('0x8')](socket);config['redis']=_[_0x05af('0x9')](config[_0x05af('0x7')],{'host':_0x05af('0xa'),'port':0x18eb});function respondWithResult(_0x4a963b,_0xfbaa9a){_0xfbaa9a=_0xfbaa9a||0xc8;return function(_0x4e120b){if(_0x4e120b){return _0x4a963b[_0x05af('0xb')](_0xfbaa9a)[_0x05af('0xc')](_0x4e120b);}};}function saveUpdates(_0x1d8343){return function(_0x4c8690){if(_0x4c8690){return _0x4c8690['update'](_0x1d8343)['then'](function(_0x47e5ad){return _0x47e5ad;});}return null;};}function handleEntityNotFound(_0xb5fb8a){return function(_0x34c228){if(!_0x34c228){_0xb5fb8a[_0x05af('0xd')](0x194);}return _0x34c228;};}function handleError(_0x48680f,_0x408a12){_0x408a12=_0x408a12||0x1f4;return function(_0x4dc76d){logger['error'](_0x4dc76d[_0x05af('0xe')]);if(_0x4dc76d[_0x05af('0xf')]){delete _0x4dc76d[_0x05af('0xf')];}_0x48680f[_0x05af('0xb')](_0x408a12)[_0x05af('0x10')](_0x4dc76d);};}exports[_0x05af('0x11')]=function(_0xf57ece,_0x2fd2d4){if(_0xf57ece[_0x05af('0x12')][_0x05af('0x13')]!==_0x05af('0x14'))throw new Error(_0x05af('0x15'));if(isNaN(Number(_0xf57ece[_0x05af('0x16')]['id'])))throw new Error(_0x05af('0x17'));return db[_0x05af('0x18')][_0x05af('0x19')]({'where':{'id':_0xf57ece[_0x05af('0x16')]['id']}})['then'](handleEntityNotFound(_0x2fd2d4,null))['then'](saveUpdates(_0xf57ece[_0x05af('0x1a')],null))[_0x05af('0x1b')](respondWithResult(_0x2fd2d4,null))[_0x05af('0x1c')](handleError(_0x2fd2d4,null));};