62f4d94b378fbe45f3360e82dc20690555fbcfd5
[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 _0x2c7c=['debug','Setting,\x20%s,\x20%s,\x20%s','request\x20sent','error','code','Setting,\x20%s,\x20%s','message','catch','ShowSetting','find','options','raw','attributes','include','map','model','lodash','bluebird','ioredis','../../mysqldb','rpc','../../config/environment','jayson/promise','client','http','then','info'];(function(_0x199572,_0x33e667){var _0x13cfa3=function(_0x53c075){while(--_0x53c075){_0x199572['push'](_0x199572['shift']());}};_0x13cfa3(++_0x33e667);}(_0x2c7c,0xe8));var _0xc2c7=function(_0x14e894,_0x2924cf){_0x14e894=_0x14e894-0x0;var _0x3c3d72=_0x2c7c[_0x14e894];return _0x3c3d72;};'use strict';var _=require(_0xc2c7('0x0'));var util=require('util');var moment=require('moment');var BPromise=require(_0xc2c7('0x1'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xc2c7('0x2'));var db=require(_0xc2c7('0x3'))['db'];var utils=require('../../config/utils');var logger=require('../../config/logger')(_0xc2c7('0x4'));var config=require(_0xc2c7('0x5'));var jayson=require(_0xc2c7('0x6'));var client=jayson[_0xc2c7('0x7')][_0xc2c7('0x8')]({'port':0x232a});function respondWithRpcPromise(_0xbb24cd,_0x184566,_0x56676f){return new BPromise(function(_0x56c1da,_0x5493d6){return client['request'](_0xbb24cd,_0x56676f)[_0xc2c7('0x9')](function(_0x1af4aa){logger[_0xc2c7('0xa')]('Setting,\x20%s,\x20%s',_0x184566,'request\x20sent');logger[_0xc2c7('0xb')](_0xc2c7('0xc'),_0x184566,_0xc2c7('0xd'),JSON['stringify'](_0x1af4aa));if(_0x1af4aa['error']){if(_0x1af4aa[_0xc2c7('0xe')][_0xc2c7('0xf')]===0x1f4){logger['error'](_0xc2c7('0x10'),_0x184566,_0x1af4aa[_0xc2c7('0xe')][_0xc2c7('0x11')]);return _0x5493d6(_0x1af4aa['error'][_0xc2c7('0x11')]);}logger[_0xc2c7('0xe')]('Setting,\x20%s,\x20%s',_0x184566,_0x1af4aa[_0xc2c7('0xe')][_0xc2c7('0x11')]);return _0x56c1da(_0x1af4aa['error'][_0xc2c7('0x11')]);}else{logger['info'](_0xc2c7('0x10'),_0x184566,'request\x20sent');_0x56c1da(_0x1af4aa['result'][_0xc2c7('0x11')]);}})[_0xc2c7('0x12')](function(_0x3546c6){logger[_0xc2c7('0xe')](_0xc2c7('0x10'),_0x184566,_0x3546c6);_0x5493d6(_0x3546c6);});});}exports[_0xc2c7('0x13')]=function(_0x15c785){var _0x404956=this;return new Promise(function(_0x19f1b5,_0x5b1152){return db['Setting'][_0xc2c7('0x14')]({'raw':_0x15c785[_0xc2c7('0x15')]?_0x15c785[_0xc2c7('0x15')][_0xc2c7('0x16')]===undefined?!![]:![]:!![],'where':_0x15c785['options']?_0x15c785[_0xc2c7('0x15')]['where']||null:null,'attributes':_0x15c785[_0xc2c7('0x15')]?_0x15c785[_0xc2c7('0x15')][_0xc2c7('0x17')]||null:null,'include':_0x15c785['options']?_0x15c785[_0xc2c7('0x15')][_0xc2c7('0x18')]?_[_0xc2c7('0x19')](_0x15c785[_0xc2c7('0x15')][_0xc2c7('0x18')],function(_0x1eb4e4){return{'model':db[_0x1eb4e4[_0xc2c7('0x1a')]],'as':_0x1eb4e4['as'],'attributes':_0x1eb4e4[_0xc2c7('0x17')],'include':_0x1eb4e4[_0xc2c7('0x18')]?_[_0xc2c7('0x19')](_0x1eb4e4[_0xc2c7('0x18')],function(_0x4423ef){return{'model':db[_0x4423ef[_0xc2c7('0x1a')]],'as':_0x4423ef['as'],'attributes':_0x4423ef[_0xc2c7('0x17')],'include':_0x4423ef['include']?_[_0xc2c7('0x19')](_0x4423ef['include'],function(_0x2ec59b){return{'model':db[_0x2ec59b[_0xc2c7('0x1a')]],'as':_0x2ec59b['as'],'attributes':_0x2ec59b[_0xc2c7('0x17')]};}):[]};}):[]};}):[]:[]})[_0xc2c7('0x9')](function(_0xef3744){logger['info'](_0xc2c7('0x13'),_0x15c785);logger[_0xc2c7('0xb')](_0xc2c7('0x13'),_0x15c785,JSON['stringify'](_0xef3744));_0x19f1b5(_0xef3744);})[_0xc2c7('0x12')](function(_0x1d1f8f){logger[_0xc2c7('0xe')](_0xc2c7('0x13'),_0x1d1f8f[_0xc2c7('0x11')],_0x15c785);_0x5b1152(_0x404956[_0xc2c7('0xe')](0x1f4,_0x1d1f8f['message']));});});};