e0b6e4d7077d54e1961c8edc0180e54e4bbc30c0
[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 _0x325a=['moment','bluebird','randomstring','ioredis','../../mysqldb','rpc','../../config/environment','jayson/promise','http','request','then','info','debug','Setting,\x20%s,\x20%s,\x20%s','stringify','error','message','Setting,\x20%s,\x20%s','request\x20sent','result','catch','ShowSetting','Setting','find','options','raw','where','attributes','include','map','model','lodash'];(function(_0xe27ee,_0x22ff18){var _0x5924a3=function(_0x1020bc){while(--_0x1020bc){_0xe27ee['push'](_0xe27ee['shift']());}};_0x5924a3(++_0x22ff18);}(_0x325a,0x17f));var _0xa325=function(_0xe4f2c4,_0x415915){_0xe4f2c4=_0xe4f2c4-0x0;var _0x4c96ad=_0x325a[_0xe4f2c4];return _0x4c96ad;};'use strict';var _=require(_0xa325('0x0'));var util=require('util');var moment=require(_0xa325('0x1'));var BPromise=require(_0xa325('0x2'));var rs=require(_0xa325('0x3'));var fs=require('fs');var Redis=require(_0xa325('0x4'));var db=require(_0xa325('0x5'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0xa325('0x6'));var config=require(_0xa325('0x7'));var jayson=require(_0xa325('0x8'));var client=jayson['client'][_0xa325('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x2b1421,_0x17a270,_0x167cae){return new BPromise(function(_0x1d7e3d,_0x55d0df){return client[_0xa325('0xa')](_0x2b1421,_0x167cae)[_0xa325('0xb')](function(_0x2d0365){logger[_0xa325('0xc')]('Setting,\x20%s,\x20%s',_0x17a270,'request\x20sent');logger[_0xa325('0xd')](_0xa325('0xe'),_0x17a270,'request\x20sent',JSON[_0xa325('0xf')](_0x2d0365));if(_0x2d0365[_0xa325('0x10')]){if(_0x2d0365[_0xa325('0x10')]['code']===0x1f4){logger['error']('Setting,\x20%s,\x20%s',_0x17a270,_0x2d0365[_0xa325('0x10')][_0xa325('0x11')]);return _0x55d0df(_0x2d0365[_0xa325('0x10')][_0xa325('0x11')]);}logger[_0xa325('0x10')](_0xa325('0x12'),_0x17a270,_0x2d0365[_0xa325('0x10')][_0xa325('0x11')]);return _0x1d7e3d(_0x2d0365['error'][_0xa325('0x11')]);}else{logger['info'](_0xa325('0x12'),_0x17a270,_0xa325('0x13'));_0x1d7e3d(_0x2d0365[_0xa325('0x14')][_0xa325('0x11')]);}})[_0xa325('0x15')](function(_0x36be8c){logger['error'](_0xa325('0x12'),_0x17a270,_0x36be8c);_0x55d0df(_0x36be8c);});});}exports[_0xa325('0x16')]=function(_0x13e3e9){var _0x47b3e1=this;return new Promise(function(_0x42390e,_0x48f972){return db[_0xa325('0x17')][_0xa325('0x18')]({'raw':_0x13e3e9[_0xa325('0x19')]?_0x13e3e9['options'][_0xa325('0x1a')]===undefined?!![]:![]:!![],'where':_0x13e3e9[_0xa325('0x19')]?_0x13e3e9[_0xa325('0x19')][_0xa325('0x1b')]||null:null,'attributes':_0x13e3e9[_0xa325('0x19')]?_0x13e3e9[_0xa325('0x19')][_0xa325('0x1c')]||null:null,'include':_0x13e3e9[_0xa325('0x19')]?_0x13e3e9['options'][_0xa325('0x1d')]?_[_0xa325('0x1e')](_0x13e3e9[_0xa325('0x19')][_0xa325('0x1d')],function(_0x29929b){return{'model':db[_0x29929b['model']],'as':_0x29929b['as'],'attributes':_0x29929b[_0xa325('0x1c')],'include':_0x29929b[_0xa325('0x1d')]?_[_0xa325('0x1e')](_0x29929b['include'],function(_0x213a23){return{'model':db[_0x213a23['model']],'as':_0x213a23['as'],'attributes':_0x213a23['attributes'],'include':_0x213a23[_0xa325('0x1d')]?_[_0xa325('0x1e')](_0x213a23[_0xa325('0x1d')],function(_0x25ab8a){return{'model':db[_0x25ab8a[_0xa325('0x1f')]],'as':_0x25ab8a['as'],'attributes':_0x25ab8a['attributes']};}):[]};}):[]};}):[]:[]})[_0xa325('0xb')](function(_0x1dea3a){logger[_0xa325('0xc')]('ShowSetting',_0x13e3e9);logger['debug'](_0xa325('0x16'),_0x13e3e9,JSON[_0xa325('0xf')](_0x1dea3a));_0x42390e(_0x1dea3a);})[_0xa325('0x15')](function(_0x181572){logger[_0xa325('0x10')](_0xa325('0x16'),_0x181572[_0xa325('0x11')],_0x13e3e9);_0x48f972(_0x47b3e1[_0xa325('0x10')](0x1f4,_0x181572[_0xa325('0x11')]));});});};