Built motion from commit efa66e19.|2.6.22
[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 _0x7808=['request\x20sent','Setting,\x20%s,\x20%s,\x20%s','error','code','message','Setting,\x20%s,\x20%s','result','catch','find','options','raw','where','attributes','map','include','model','ShowSetting','debug','stringify','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','rpc','../../config/environment','jayson/promise','then','info'];(function(_0x6e5677,_0x42a7b9){var _0x12be5e=function(_0x284ac4){while(--_0x284ac4){_0x6e5677['push'](_0x6e5677['shift']());}};_0x12be5e(++_0x42a7b9);}(_0x7808,0x1f3));var _0x8780=function(_0x472340,_0x3a7ad1){_0x472340=_0x472340-0x0;var _0x309b3a=_0x7808[_0x472340];return _0x309b3a;};'use strict';var _=require(_0x8780('0x0'));var util=require(_0x8780('0x1'));var moment=require(_0x8780('0x2'));var BPromise=require(_0x8780('0x3'));var rs=require(_0x8780('0x4'));var fs=require('fs');var Redis=require(_0x8780('0x5'));var db=require(_0x8780('0x6'))['db'];var utils=require(_0x8780('0x7'));var logger=require('../../config/logger')(_0x8780('0x8'));var config=require(_0x8780('0x9'));var jayson=require(_0x8780('0xa'));var client=jayson['client']['http']({'port':0x232a});function respondWithRpcPromise(_0x2201e6,_0xa94d32,_0x35a58b){return new BPromise(function(_0x3183e0,_0x1118f7){return client['request'](_0x2201e6,_0x35a58b)[_0x8780('0xb')](function(_0x5d78f9){logger[_0x8780('0xc')]('Setting,\x20%s,\x20%s',_0xa94d32,_0x8780('0xd'));logger['debug'](_0x8780('0xe'),_0xa94d32,_0x8780('0xd'),JSON['stringify'](_0x5d78f9));if(_0x5d78f9[_0x8780('0xf')]){if(_0x5d78f9[_0x8780('0xf')][_0x8780('0x10')]===0x1f4){logger[_0x8780('0xf')]('Setting,\x20%s,\x20%s',_0xa94d32,_0x5d78f9[_0x8780('0xf')]['message']);return _0x1118f7(_0x5d78f9[_0x8780('0xf')][_0x8780('0x11')]);}logger[_0x8780('0xf')](_0x8780('0x12'),_0xa94d32,_0x5d78f9[_0x8780('0xf')][_0x8780('0x11')]);return _0x3183e0(_0x5d78f9[_0x8780('0xf')][_0x8780('0x11')]);}else{logger[_0x8780('0xc')](_0x8780('0x12'),_0xa94d32,_0x8780('0xd'));_0x3183e0(_0x5d78f9[_0x8780('0x13')][_0x8780('0x11')]);}})[_0x8780('0x14')](function(_0x2c8380){logger[_0x8780('0xf')]('Setting,\x20%s,\x20%s',_0xa94d32,_0x2c8380);_0x1118f7(_0x2c8380);});});}exports['ShowSetting']=function(_0x4d1172){var _0x4466f0=this;return new Promise(function(_0x58fccc,_0x3329d5){return db['Setting'][_0x8780('0x15')]({'raw':_0x4d1172['options']?_0x4d1172[_0x8780('0x16')][_0x8780('0x17')]===undefined?!![]:![]:!![],'where':_0x4d1172[_0x8780('0x16')]?_0x4d1172[_0x8780('0x16')][_0x8780('0x18')]||null:null,'attributes':_0x4d1172[_0x8780('0x16')]?_0x4d1172[_0x8780('0x16')][_0x8780('0x19')]||null:null,'include':_0x4d1172[_0x8780('0x16')]?_0x4d1172[_0x8780('0x16')]['include']?_[_0x8780('0x1a')](_0x4d1172[_0x8780('0x16')]['include'],function(_0x38aec8){return{'model':db[_0x38aec8['model']],'as':_0x38aec8['as'],'attributes':_0x38aec8['attributes'],'include':_0x38aec8['include']?_[_0x8780('0x1a')](_0x38aec8['include'],function(_0x578d6b){return{'model':db[_0x578d6b['model']],'as':_0x578d6b['as'],'attributes':_0x578d6b[_0x8780('0x19')],'include':_0x578d6b[_0x8780('0x1b')]?_[_0x8780('0x1a')](_0x578d6b[_0x8780('0x1b')],function(_0x19c406){return{'model':db[_0x19c406[_0x8780('0x1c')]],'as':_0x19c406['as'],'attributes':_0x19c406[_0x8780('0x19')]};}):[]};}):[]};}):[]:[]})['then'](function(_0x1c45e5){logger['info'](_0x8780('0x1d'),_0x4d1172);logger[_0x8780('0x1e')](_0x8780('0x1d'),_0x4d1172,JSON[_0x8780('0x1f')](_0x1c45e5));_0x58fccc(_0x1c45e5);})[_0x8780('0x14')](function(_0x5be81c){logger[_0x8780('0xf')](_0x8780('0x1d'),_0x5be81c[_0x8780('0x11')],_0x4d1172);_0x3329d5(_0x4466f0[_0x8780('0xf')](0x1f4,_0x5be81c['message']));});});};