Built motion from commit bab6f49e.|2.6.17
[motion2.git] / server / api / setting / setting.rpc.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 _0xbb69=['randomstring','ioredis','../../config/utils','rpc','../../config/environment','jayson/promise','client','then','info','Setting,\x20%s,\x20%s','request\x20sent','Setting,\x20%s,\x20%s,\x20%s','stringify','error','message','catch','Setting','find','options','raw','where','include','map','model','attributes','ShowSetting','debug','lodash','util','moment','bluebird'];(function(_0xa464c9,_0x7c86d8){var _0x3d73c4=function(_0x5c2056){while(--_0x5c2056){_0xa464c9['push'](_0xa464c9['shift']());}};_0x3d73c4(++_0x7c86d8);}(_0xbb69,0x113));var _0x9bb6=function(_0x23b374,_0xae4a8f){_0x23b374=_0x23b374-0x0;var _0x5e2d52=_0xbb69[_0x23b374];return _0x5e2d52;};'use strict';var _=require(_0x9bb6('0x0'));var util=require(_0x9bb6('0x1'));var moment=require(_0x9bb6('0x2'));var BPromise=require(_0x9bb6('0x3'));var rs=require(_0x9bb6('0x4'));var fs=require('fs');var Redis=require(_0x9bb6('0x5'));var db=require('../../mysqldb')['db'];var utils=require(_0x9bb6('0x6'));var logger=require('../../config/logger')(_0x9bb6('0x7'));var config=require(_0x9bb6('0x8'));var jayson=require(_0x9bb6('0x9'));var client=jayson[_0x9bb6('0xa')]['http']({'port':0x232a});function respondWithRpcPromise(_0x4e31d6,_0x258c80,_0x59dbb7){return new BPromise(function(_0x591490,_0x2c2e78){return client['request'](_0x4e31d6,_0x59dbb7)[_0x9bb6('0xb')](function(_0x16e7ab){logger[_0x9bb6('0xc')](_0x9bb6('0xd'),_0x258c80,_0x9bb6('0xe'));logger['debug'](_0x9bb6('0xf'),_0x258c80,_0x9bb6('0xe'),JSON[_0x9bb6('0x10')](_0x16e7ab));if(_0x16e7ab[_0x9bb6('0x11')]){if(_0x16e7ab[_0x9bb6('0x11')]['code']===0x1f4){logger[_0x9bb6('0x11')](_0x9bb6('0xd'),_0x258c80,_0x16e7ab[_0x9bb6('0x11')][_0x9bb6('0x12')]);return _0x2c2e78(_0x16e7ab[_0x9bb6('0x11')][_0x9bb6('0x12')]);}logger[_0x9bb6('0x11')](_0x9bb6('0xd'),_0x258c80,_0x16e7ab[_0x9bb6('0x11')]['message']);return _0x591490(_0x16e7ab[_0x9bb6('0x11')]['message']);}else{logger[_0x9bb6('0xc')](_0x9bb6('0xd'),_0x258c80,'request\x20sent');_0x591490(_0x16e7ab['result'][_0x9bb6('0x12')]);}})[_0x9bb6('0x13')](function(_0x1d1584){logger[_0x9bb6('0x11')](_0x9bb6('0xd'),_0x258c80,_0x1d1584);_0x2c2e78(_0x1d1584);});});}exports['ShowSetting']=function(_0x3868f6){var _0x149620=this;return new Promise(function(_0x2a4c11,_0x2827de){return db[_0x9bb6('0x14')][_0x9bb6('0x15')]({'raw':_0x3868f6[_0x9bb6('0x16')]?_0x3868f6[_0x9bb6('0x16')][_0x9bb6('0x17')]===undefined?!![]:![]:!![],'where':_0x3868f6['options']?_0x3868f6[_0x9bb6('0x16')][_0x9bb6('0x18')]||null:null,'attributes':_0x3868f6[_0x9bb6('0x16')]?_0x3868f6[_0x9bb6('0x16')]['attributes']||null:null,'include':_0x3868f6['options']?_0x3868f6['options'][_0x9bb6('0x19')]?_[_0x9bb6('0x1a')](_0x3868f6[_0x9bb6('0x16')][_0x9bb6('0x19')],function(_0x166535){return{'model':db[_0x166535[_0x9bb6('0x1b')]],'as':_0x166535['as'],'attributes':_0x166535['attributes'],'include':_0x166535['include']?_['map'](_0x166535[_0x9bb6('0x19')],function(_0x10619e){return{'model':db[_0x10619e[_0x9bb6('0x1b')]],'as':_0x10619e['as'],'attributes':_0x10619e['attributes'],'include':_0x10619e[_0x9bb6('0x19')]?_[_0x9bb6('0x1a')](_0x10619e[_0x9bb6('0x19')],function(_0x46cc07){return{'model':db[_0x46cc07[_0x9bb6('0x1b')]],'as':_0x46cc07['as'],'attributes':_0x46cc07[_0x9bb6('0x1c')]};}):[]};}):[]};}):[]:[]})[_0x9bb6('0xb')](function(_0x4e8f29){logger[_0x9bb6('0xc')](_0x9bb6('0x1d'),_0x3868f6);logger[_0x9bb6('0x1e')](_0x9bb6('0x1d'),_0x3868f6,JSON[_0x9bb6('0x10')](_0x4e8f29));_0x2a4c11(_0x4e8f29);})[_0x9bb6('0x13')](function(_0x56df95){logger['error'](_0x9bb6('0x1d'),_0x56df95[_0x9bb6('0x12')],_0x3868f6);_0x2827de(_0x149620['error'](0x1f4,_0x56df95[_0x9bb6('0x12')]));});});};