Built motion from commit 497d3d92.|2.5.43
[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 _0x55b5=['randomstring','../../mysqldb','rpc','../../config/environment','jayson/promise','http','then','info','Setting,\x20%s,\x20%s','request\x20sent','Setting,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','ShowSetting','find','options','where','attributes','include','map','model','debug','lodash','util'];(function(_0x26a9c1,_0x74cb43){var _0x11cbe6=function(_0x1800c4){while(--_0x1800c4){_0x26a9c1['push'](_0x26a9c1['shift']());}};_0x11cbe6(++_0x74cb43);}(_0x55b5,0x132));var _0x555b=function(_0x433b49,_0xc16aa7){_0x433b49=_0x433b49-0x0;var _0x36f74c=_0x55b5[_0x433b49];return _0x36f74c;};'use strict';var _=require(_0x555b('0x0'));var util=require(_0x555b('0x1'));var moment=require('moment');var BPromise=require('bluebird');var rs=require(_0x555b('0x2'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0x555b('0x3'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0x555b('0x4'));var config=require(_0x555b('0x5'));var jayson=require(_0x555b('0x6'));var client=jayson['client'][_0x555b('0x7')]({'port':0x232a});function respondWithRpcPromise(_0x30bc13,_0xc1237b,_0x13d3f5){return new BPromise(function(_0x4d7d87,_0xbca8b0){return client['request'](_0x30bc13,_0x13d3f5)[_0x555b('0x8')](function(_0x113239){logger[_0x555b('0x9')](_0x555b('0xa'),_0xc1237b,_0x555b('0xb'));logger['debug'](_0x555b('0xc'),_0xc1237b,'request\x20sent',JSON[_0x555b('0xd')](_0x113239));if(_0x113239['error']){if(_0x113239[_0x555b('0xe')][_0x555b('0xf')]===0x1f4){logger[_0x555b('0xe')](_0x555b('0xa'),_0xc1237b,_0x113239[_0x555b('0xe')][_0x555b('0x10')]);return _0xbca8b0(_0x113239['error'][_0x555b('0x10')]);}logger[_0x555b('0xe')](_0x555b('0xa'),_0xc1237b,_0x113239['error'][_0x555b('0x10')]);return _0x4d7d87(_0x113239[_0x555b('0xe')][_0x555b('0x10')]);}else{logger[_0x555b('0x9')](_0x555b('0xa'),_0xc1237b,_0x555b('0xb'));_0x4d7d87(_0x113239[_0x555b('0x11')][_0x555b('0x10')]);}})[_0x555b('0x12')](function(_0x2d38b0){logger[_0x555b('0xe')](_0x555b('0xa'),_0xc1237b,_0x2d38b0);_0xbca8b0(_0x2d38b0);});});}exports[_0x555b('0x13')]=function(_0x68b2a4){var _0x221b6e=this;return new Promise(function(_0x98376f,_0xfc13a5){return db['Setting'][_0x555b('0x14')]({'raw':_0x68b2a4[_0x555b('0x15')]?_0x68b2a4[_0x555b('0x15')]['raw']===undefined?!![]:![]:!![],'where':_0x68b2a4[_0x555b('0x15')]?_0x68b2a4[_0x555b('0x15')][_0x555b('0x16')]||null:null,'attributes':_0x68b2a4[_0x555b('0x15')]?_0x68b2a4[_0x555b('0x15')][_0x555b('0x17')]||null:null,'include':_0x68b2a4[_0x555b('0x15')]?_0x68b2a4[_0x555b('0x15')][_0x555b('0x18')]?_[_0x555b('0x19')](_0x68b2a4[_0x555b('0x15')][_0x555b('0x18')],function(_0x45859a){return{'model':db[_0x45859a[_0x555b('0x1a')]],'as':_0x45859a['as'],'attributes':_0x45859a[_0x555b('0x17')],'include':_0x45859a['include']?_[_0x555b('0x19')](_0x45859a[_0x555b('0x18')],function(_0x4ae4af){return{'model':db[_0x4ae4af[_0x555b('0x1a')]],'as':_0x4ae4af['as'],'attributes':_0x4ae4af[_0x555b('0x17')],'include':_0x4ae4af[_0x555b('0x18')]?_[_0x555b('0x19')](_0x4ae4af['include'],function(_0x2bac34){return{'model':db[_0x2bac34[_0x555b('0x1a')]],'as':_0x2bac34['as'],'attributes':_0x2bac34[_0x555b('0x17')]};}):[]};}):[]};}):[]:[]})[_0x555b('0x8')](function(_0xbb1251){logger[_0x555b('0x9')](_0x555b('0x13'),_0x68b2a4);logger[_0x555b('0x1b')](_0x555b('0x13'),_0x68b2a4,JSON[_0x555b('0xd')](_0xbb1251));_0x98376f(_0xbb1251);})[_0x555b('0x12')](function(_0x41ef5a){logger['error'](_0x555b('0x13'),_0x41ef5a['message'],_0x68b2a4);_0xfc13a5(_0x221b6e['error'](0x1f4,_0x41ef5a[_0x555b('0x10')]));});});};