e38c895dd3ab9e8e575035a7f11e38903fc686b9
[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 _0x607f=['code','message','Setting','options','raw','where','include','map','model','attributes','ShowSetting','debug','stringify','catch','lodash','moment','bluebird','randomstring','ioredis','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','http','request','then','info','Setting,\x20%s,\x20%s','request\x20sent','error'];(function(_0x7ba534,_0x53faf5){var _0x166ef1=function(_0x3aa12c){while(--_0x3aa12c){_0x7ba534['push'](_0x7ba534['shift']());}};_0x166ef1(++_0x53faf5);}(_0x607f,0x125));var _0xf607=function(_0x49fc4c,_0x4f5ce7){_0x49fc4c=_0x49fc4c-0x0;var _0x1c3880=_0x607f[_0x49fc4c];return _0x1c3880;};'use strict';var _=require(_0xf607('0x0'));var util=require('util');var moment=require(_0xf607('0x1'));var BPromise=require(_0xf607('0x2'));var rs=require(_0xf607('0x3'));var fs=require('fs');var Redis=require(_0xf607('0x4'));var db=require('../../mysqldb')['db'];var utils=require(_0xf607('0x5'));var logger=require(_0xf607('0x6'))(_0xf607('0x7'));var config=require(_0xf607('0x8'));var jayson=require(_0xf607('0x9'));var client=jayson['client'][_0xf607('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x2c4562,_0x481a93,_0x5aa49d){return new BPromise(function(_0x134a06,_0x1badaf){return client[_0xf607('0xb')](_0x2c4562,_0x5aa49d)[_0xf607('0xc')](function(_0x30d181){logger[_0xf607('0xd')](_0xf607('0xe'),_0x481a93,_0xf607('0xf'));logger['debug']('Setting,\x20%s,\x20%s,\x20%s',_0x481a93,_0xf607('0xf'),JSON['stringify'](_0x30d181));if(_0x30d181[_0xf607('0x10')]){if(_0x30d181[_0xf607('0x10')][_0xf607('0x11')]===0x1f4){logger[_0xf607('0x10')](_0xf607('0xe'),_0x481a93,_0x30d181[_0xf607('0x10')][_0xf607('0x12')]);return _0x1badaf(_0x30d181[_0xf607('0x10')][_0xf607('0x12')]);}logger[_0xf607('0x10')](_0xf607('0xe'),_0x481a93,_0x30d181[_0xf607('0x10')][_0xf607('0x12')]);return _0x134a06(_0x30d181[_0xf607('0x10')][_0xf607('0x12')]);}else{logger[_0xf607('0xd')](_0xf607('0xe'),_0x481a93,_0xf607('0xf'));_0x134a06(_0x30d181['result'][_0xf607('0x12')]);}})['catch'](function(_0x578d2a){logger[_0xf607('0x10')](_0xf607('0xe'),_0x481a93,_0x578d2a);_0x1badaf(_0x578d2a);});});}exports['ShowSetting']=function(_0x1a2fd2){var _0x1c6745=this;return new Promise(function(_0x5b859b,_0x4542f6){return db[_0xf607('0x13')]['find']({'raw':_0x1a2fd2['options']?_0x1a2fd2[_0xf607('0x14')][_0xf607('0x15')]===undefined?!![]:![]:!![],'where':_0x1a2fd2[_0xf607('0x14')]?_0x1a2fd2[_0xf607('0x14')][_0xf607('0x16')]||null:null,'attributes':_0x1a2fd2[_0xf607('0x14')]?_0x1a2fd2[_0xf607('0x14')]['attributes']||null:null,'include':_0x1a2fd2[_0xf607('0x14')]?_0x1a2fd2[_0xf607('0x14')][_0xf607('0x17')]?_[_0xf607('0x18')](_0x1a2fd2[_0xf607('0x14')][_0xf607('0x17')],function(_0x1bae93){return{'model':db[_0x1bae93[_0xf607('0x19')]],'as':_0x1bae93['as'],'attributes':_0x1bae93[_0xf607('0x1a')],'include':_0x1bae93[_0xf607('0x17')]?_[_0xf607('0x18')](_0x1bae93[_0xf607('0x17')],function(_0x5a9ecb){return{'model':db[_0x5a9ecb[_0xf607('0x19')]],'as':_0x5a9ecb['as'],'attributes':_0x5a9ecb[_0xf607('0x1a')],'include':_0x5a9ecb[_0xf607('0x17')]?_['map'](_0x5a9ecb['include'],function(_0x166c9b){return{'model':db[_0x166c9b[_0xf607('0x19')]],'as':_0x166c9b['as'],'attributes':_0x166c9b[_0xf607('0x1a')]};}):[]};}):[]};}):[]:[]})[_0xf607('0xc')](function(_0x9b6d8c){logger[_0xf607('0xd')](_0xf607('0x1b'),_0x1a2fd2);logger[_0xf607('0x1c')](_0xf607('0x1b'),_0x1a2fd2,JSON[_0xf607('0x1d')](_0x9b6d8c));_0x5b859b(_0x9b6d8c);})[_0xf607('0x1e')](function(_0x1e4776){logger[_0xf607('0x10')](_0xf607('0x1b'),_0x1e4776[_0xf607('0x12')],_0x1a2fd2);_0x4542f6(_0x1c6745[_0xf607('0x10')](0x1f4,_0x1e4776[_0xf607('0x12')]));});});};