889ce75fec471d4e1ea2b6c249b9c999754d1d29
[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 _0x773b=['map','model','ShowSetting','catch','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','http','request','then','info','Setting,\x20%s,\x20%s','debug','Setting,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','code','error','message','result','options','raw','where','attributes','include'];(function(_0x20a584,_0xe384a5){var _0x4b41a8=function(_0x2127c6){while(--_0x2127c6){_0x20a584['push'](_0x20a584['shift']());}};_0x4b41a8(++_0xe384a5);}(_0x773b,0x164));var _0xb773=function(_0x25d064,_0x1a2364){_0x25d064=_0x25d064-0x0;var _0x496991=_0x773b[_0x25d064];return _0x496991;};'use strict';var _=require(_0xb773('0x0'));var util=require(_0xb773('0x1'));var moment=require(_0xb773('0x2'));var BPromise=require(_0xb773('0x3'));var rs=require(_0xb773('0x4'));var fs=require('fs');var Redis=require(_0xb773('0x5'));var db=require(_0xb773('0x6'))['db'];var utils=require(_0xb773('0x7'));var logger=require(_0xb773('0x8'))('rpc');var config=require(_0xb773('0x9'));var jayson=require('jayson/promise');var client=jayson['client'][_0xb773('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x315878,_0x61bdfa,_0x417f2d){return new BPromise(function(_0x55e617,_0x46803a){return client[_0xb773('0xb')](_0x315878,_0x417f2d)[_0xb773('0xc')](function(_0x274893){logger[_0xb773('0xd')](_0xb773('0xe'),_0x61bdfa,'request\x20sent');logger[_0xb773('0xf')](_0xb773('0x10'),_0x61bdfa,_0xb773('0x11'),JSON[_0xb773('0x12')](_0x274893));if(_0x274893['error']){if(_0x274893['error'][_0xb773('0x13')]===0x1f4){logger[_0xb773('0x14')]('Setting,\x20%s,\x20%s',_0x61bdfa,_0x274893['error']['message']);return _0x46803a(_0x274893[_0xb773('0x14')][_0xb773('0x15')]);}logger[_0xb773('0x14')](_0xb773('0xe'),_0x61bdfa,_0x274893[_0xb773('0x14')][_0xb773('0x15')]);return _0x55e617(_0x274893[_0xb773('0x14')][_0xb773('0x15')]);}else{logger[_0xb773('0xd')](_0xb773('0xe'),_0x61bdfa,_0xb773('0x11'));_0x55e617(_0x274893[_0xb773('0x16')][_0xb773('0x15')]);}})['catch'](function(_0xc291dc){logger['error'](_0xb773('0xe'),_0x61bdfa,_0xc291dc);_0x46803a(_0xc291dc);});});}exports['ShowSetting']=function(_0x9350e9){var _0x455e01=this;return new Promise(function(_0x5223bf,_0x200ff0){return db['Setting']['find']({'raw':_0x9350e9[_0xb773('0x17')]?_0x9350e9[_0xb773('0x17')][_0xb773('0x18')]===undefined?!![]:![]:!![],'where':_0x9350e9[_0xb773('0x17')]?_0x9350e9[_0xb773('0x17')][_0xb773('0x19')]||null:null,'attributes':_0x9350e9[_0xb773('0x17')]?_0x9350e9[_0xb773('0x17')][_0xb773('0x1a')]||null:null,'include':_0x9350e9['options']?_0x9350e9[_0xb773('0x17')]['include']?_['map'](_0x9350e9[_0xb773('0x17')]['include'],function(_0x3faa7a){return{'model':db[_0x3faa7a['model']],'as':_0x3faa7a['as'],'attributes':_0x3faa7a[_0xb773('0x1a')],'include':_0x3faa7a[_0xb773('0x1b')]?_[_0xb773('0x1c')](_0x3faa7a[_0xb773('0x1b')],function(_0x139308){return{'model':db[_0x139308[_0xb773('0x1d')]],'as':_0x139308['as'],'attributes':_0x139308['attributes'],'include':_0x139308[_0xb773('0x1b')]?_[_0xb773('0x1c')](_0x139308[_0xb773('0x1b')],function(_0x116dc5){return{'model':db[_0x116dc5[_0xb773('0x1d')]],'as':_0x116dc5['as'],'attributes':_0x116dc5[_0xb773('0x1a')]};}):[]};}):[]};}):[]:[]})[_0xb773('0xc')](function(_0x480a31){logger['info'](_0xb773('0x1e'),_0x9350e9);logger['debug'](_0xb773('0x1e'),_0x9350e9,JSON[_0xb773('0x12')](_0x480a31));_0x5223bf(_0x480a31);})[_0xb773('0x1f')](function(_0x59c629){logger['error'](_0xb773('0x1e'),_0x59c629[_0xb773('0x15')],_0x9350e9);_0x200ff0(_0x455e01[_0xb773('0x14')](0x1f4,_0x59c629[_0xb773('0x15')]));});});};