bde2dce0f96ca929f5a39c127cdf3bdbd3bb9b29
[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 _0xc58c=['map','ShowSetting','stringify','lodash','moment','bluebird','randomstring','../../config/utils','../../config/logger','rpc','client','http','request','info','request\x20sent','debug','error','code','message','Setting,\x20%s,\x20%s','result','catch','Setting','find','options','raw','attributes','include','model'];(function(_0x1a546d,_0x14b9f3){var _0x27aef1=function(_0x3d4e71){while(--_0x3d4e71){_0x1a546d['push'](_0x1a546d['shift']());}};_0x27aef1(++_0x14b9f3);}(_0xc58c,0x199));var _0xcc58=function(_0x36eb4b,_0x1229ec){_0x36eb4b=_0x36eb4b-0x0;var _0x5c832c=_0xc58c[_0x36eb4b];return _0x5c832c;};'use strict';var _=require(_0xcc58('0x0'));var util=require('util');var moment=require(_0xcc58('0x1'));var BPromise=require(_0xcc58('0x2'));var rs=require(_0xcc58('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require(_0xcc58('0x4'));var logger=require(_0xcc58('0x5'))(_0xcc58('0x6'));var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson[_0xcc58('0x7')][_0xcc58('0x8')]({'port':0x232a});function respondWithRpcPromise(_0x1080c7,_0x3ede66,_0x155610){return new BPromise(function(_0x5521ce,_0x5edd78){return client[_0xcc58('0x9')](_0x1080c7,_0x155610)['then'](function(_0x293fa0){logger[_0xcc58('0xa')]('Setting,\x20%s,\x20%s',_0x3ede66,_0xcc58('0xb'));logger[_0xcc58('0xc')]('Setting,\x20%s,\x20%s,\x20%s',_0x3ede66,_0xcc58('0xb'),JSON['stringify'](_0x293fa0));if(_0x293fa0[_0xcc58('0xd')]){if(_0x293fa0['error'][_0xcc58('0xe')]===0x1f4){logger[_0xcc58('0xd')]('Setting,\x20%s,\x20%s',_0x3ede66,_0x293fa0[_0xcc58('0xd')][_0xcc58('0xf')]);return _0x5edd78(_0x293fa0[_0xcc58('0xd')]['message']);}logger[_0xcc58('0xd')](_0xcc58('0x10'),_0x3ede66,_0x293fa0[_0xcc58('0xd')]['message']);return _0x5521ce(_0x293fa0[_0xcc58('0xd')][_0xcc58('0xf')]);}else{logger[_0xcc58('0xa')]('Setting,\x20%s,\x20%s',_0x3ede66,_0xcc58('0xb'));_0x5521ce(_0x293fa0[_0xcc58('0x11')]['message']);}})[_0xcc58('0x12')](function(_0x32e1a8){logger[_0xcc58('0xd')](_0xcc58('0x10'),_0x3ede66,_0x32e1a8);_0x5edd78(_0x32e1a8);});});}exports['ShowSetting']=function(_0x1d3a48){var _0x4a43c9=this;return new Promise(function(_0x4b9e08,_0x5edb9d){return db[_0xcc58('0x13')][_0xcc58('0x14')]({'raw':_0x1d3a48['options']?_0x1d3a48[_0xcc58('0x15')][_0xcc58('0x16')]===undefined?!![]:![]:!![],'where':_0x1d3a48[_0xcc58('0x15')]?_0x1d3a48[_0xcc58('0x15')]['where']||null:null,'attributes':_0x1d3a48[_0xcc58('0x15')]?_0x1d3a48[_0xcc58('0x15')][_0xcc58('0x17')]||null:null,'include':_0x1d3a48[_0xcc58('0x15')]?_0x1d3a48[_0xcc58('0x15')]['include']?_['map'](_0x1d3a48['options'][_0xcc58('0x18')],function(_0x70bade){return{'model':db[_0x70bade[_0xcc58('0x19')]],'as':_0x70bade['as'],'attributes':_0x70bade[_0xcc58('0x17')],'include':_0x70bade['include']?_[_0xcc58('0x1a')](_0x70bade['include'],function(_0x4a6cd1){return{'model':db[_0x4a6cd1[_0xcc58('0x19')]],'as':_0x4a6cd1['as'],'attributes':_0x4a6cd1[_0xcc58('0x17')],'include':_0x4a6cd1[_0xcc58('0x18')]?_['map'](_0x4a6cd1[_0xcc58('0x18')],function(_0x1989ac){return{'model':db[_0x1989ac[_0xcc58('0x19')]],'as':_0x1989ac['as'],'attributes':_0x1989ac[_0xcc58('0x17')]};}):[]};}):[]};}):[]:[]})['then'](function(_0xb21990){logger[_0xcc58('0xa')](_0xcc58('0x1b'),_0x1d3a48);logger['debug'](_0xcc58('0x1b'),_0x1d3a48,JSON[_0xcc58('0x1c')](_0xb21990));_0x4b9e08(_0xb21990);})[_0xcc58('0x12')](function(_0x4bdffe){logger[_0xcc58('0xd')]('ShowSetting',_0x4bdffe[_0xcc58('0xf')],_0x1d3a48);_0x5edb9d(_0x4a43c9[_0xcc58('0xd')](0x1f4,_0x4bdffe[_0xcc58('0xf')]));});});};