a044b22e8fac23c6f730e5175e02ccdd04fbb5ac
[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 _0x6ce9=['sendStatus','error','stack','name','send','user','role','admin','Unauthorized','params','Invalid\x20user\x20setting\x20id','UserSetting','find','body','lodash','ioredis','../../config/logger','../../mysqldb','redis','./user-setting.socket','register','localhost','status','json','update','then'];(function(_0x12e7cb,_0x5c66e0){var _0x59d202=function(_0x14bd04){while(--_0x14bd04){_0x12e7cb['push'](_0x12e7cb['shift']());}};_0x59d202(++_0x5c66e0);}(_0x6ce9,0x76));var _0x96ce=function(_0x129254,_0x5e26af){_0x129254=_0x129254-0x0;var _0x2a0488=_0x6ce9[_0x129254];return _0x2a0488;};'use strict';var _=require(_0x96ce('0x0'));var Redis=require(_0x96ce('0x1'));var logger=require(_0x96ce('0x2'))('api');var config=require('../../config/environment');var db=require(_0x96ce('0x3'))['db'];var socket=require('socket.io-emitter')(new Redis(config[_0x96ce('0x4')]));require(_0x96ce('0x5'))[_0x96ce('0x6')](socket);config[_0x96ce('0x4')]=_['defaults'](config[_0x96ce('0x4')],{'host':_0x96ce('0x7'),'port':0x18eb});function respondWithResult(_0x1a24c7,_0x569a40){_0x569a40=_0x569a40||0xc8;return function(_0x1abd8c){if(_0x1abd8c){return _0x1a24c7[_0x96ce('0x8')](_0x569a40)[_0x96ce('0x9')](_0x1abd8c);}};}function saveUpdates(_0x4a7278){return function(_0x4b4ba8){if(_0x4b4ba8){return _0x4b4ba8[_0x96ce('0xa')](_0x4a7278)[_0x96ce('0xb')](function(_0x19d1c2){return _0x19d1c2;});}return null;};}function handleEntityNotFound(_0x296e57){return function(_0x150f93){if(!_0x150f93){_0x296e57[_0x96ce('0xc')](0x194);}return _0x150f93;};}function handleError(_0x45711e,_0x897942){_0x897942=_0x897942||0x1f4;return function(_0x1e3c4a){logger[_0x96ce('0xd')](_0x1e3c4a[_0x96ce('0xe')]);if(_0x1e3c4a['name']){delete _0x1e3c4a[_0x96ce('0xf')];}_0x45711e[_0x96ce('0x8')](_0x897942)[_0x96ce('0x10')](_0x1e3c4a);};}exports['update']=function(_0x1743b3,_0x37bc3a){if(_0x1743b3[_0x96ce('0x11')][_0x96ce('0x12')]!==_0x96ce('0x13'))throw new Error(_0x96ce('0x14'));if(isNaN(Number(_0x1743b3[_0x96ce('0x15')]['id'])))throw new Error(_0x96ce('0x16'));return db[_0x96ce('0x17')][_0x96ce('0x18')]({'where':{'id':_0x1743b3[_0x96ce('0x15')]['id']}})[_0x96ce('0xb')](handleEntityNotFound(_0x37bc3a,null))[_0x96ce('0xb')](saveUpdates(_0x1743b3[_0x96ce('0x19')],null))[_0x96ce('0xb')](respondWithResult(_0x37bc3a,null))['catch'](handleError(_0x37bc3a,null));};