f16e873630407893839fd98949e6991e3db3545d
[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 _0x6612=['http','request','then','info','Setting,\x20%s,\x20%s','request\x20sent','Setting,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','Setting','find','options','raw','where','attributes','include','model','map','debug','ShowSetting','lodash','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','jayson/promise'];(function(_0x32be39,_0x251f3c){var _0x2ad962=function(_0x292dc5){while(--_0x292dc5){_0x32be39['push'](_0x32be39['shift']());}};_0x2ad962(++_0x251f3c);}(_0x6612,0x106));var _0x2661=function(_0x37bd26,_0x5ad346){_0x37bd26=_0x37bd26-0x0;var _0xe83dc4=_0x6612[_0x37bd26];return _0xe83dc4;};'use strict';var _=require(_0x2661('0x0'));var util=require('util');var moment=require(_0x2661('0x1'));var BPromise=require(_0x2661('0x2'));var rs=require(_0x2661('0x3'));var fs=require('fs');var Redis=require(_0x2661('0x4'));var db=require(_0x2661('0x5'))['db'];var utils=require(_0x2661('0x6'));var logger=require(_0x2661('0x7'))(_0x2661('0x8'));var config=require('../../config/environment');var jayson=require(_0x2661('0x9'));var client=jayson['client'][_0x2661('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x2b3658,_0x5f0540,_0x46f4ee){return new BPromise(function(_0x3ea8bf,_0x5062f7){return client[_0x2661('0xb')](_0x2b3658,_0x46f4ee)[_0x2661('0xc')](function(_0x32a1a8){logger[_0x2661('0xd')](_0x2661('0xe'),_0x5f0540,_0x2661('0xf'));logger['debug'](_0x2661('0x10'),_0x5f0540,_0x2661('0xf'),JSON[_0x2661('0x11')](_0x32a1a8));if(_0x32a1a8[_0x2661('0x12')]){if(_0x32a1a8[_0x2661('0x12')][_0x2661('0x13')]===0x1f4){logger[_0x2661('0x12')]('Setting,\x20%s,\x20%s',_0x5f0540,_0x32a1a8[_0x2661('0x12')][_0x2661('0x14')]);return _0x5062f7(_0x32a1a8[_0x2661('0x12')][_0x2661('0x14')]);}logger[_0x2661('0x12')](_0x2661('0xe'),_0x5f0540,_0x32a1a8[_0x2661('0x12')][_0x2661('0x14')]);return _0x3ea8bf(_0x32a1a8[_0x2661('0x12')]['message']);}else{logger['info']('Setting,\x20%s,\x20%s',_0x5f0540,_0x2661('0xf'));_0x3ea8bf(_0x32a1a8[_0x2661('0x15')][_0x2661('0x14')]);}})[_0x2661('0x16')](function(_0x2cde2f){logger[_0x2661('0x12')]('Setting,\x20%s,\x20%s',_0x5f0540,_0x2cde2f);_0x5062f7(_0x2cde2f);});});}exports['ShowSetting']=function(_0x23bbc8){var _0x24a73f=this;return new Promise(function(_0x218592,_0x28b66c){return db[_0x2661('0x17')][_0x2661('0x18')]({'raw':_0x23bbc8[_0x2661('0x19')]?_0x23bbc8[_0x2661('0x19')][_0x2661('0x1a')]===undefined?!![]:![]:!![],'where':_0x23bbc8[_0x2661('0x19')]?_0x23bbc8['options'][_0x2661('0x1b')]||null:null,'attributes':_0x23bbc8['options']?_0x23bbc8[_0x2661('0x19')][_0x2661('0x1c')]||null:null,'include':_0x23bbc8[_0x2661('0x19')]?_0x23bbc8[_0x2661('0x19')][_0x2661('0x1d')]?_['map'](_0x23bbc8['options'][_0x2661('0x1d')],function(_0x1adbad){return{'model':db[_0x1adbad[_0x2661('0x1e')]],'as':_0x1adbad['as'],'attributes':_0x1adbad[_0x2661('0x1c')],'include':_0x1adbad[_0x2661('0x1d')]?_['map'](_0x1adbad['include'],function(_0x10645f){return{'model':db[_0x10645f['model']],'as':_0x10645f['as'],'attributes':_0x10645f['attributes'],'include':_0x10645f[_0x2661('0x1d')]?_[_0x2661('0x1f')](_0x10645f[_0x2661('0x1d')],function(_0x1f291c){return{'model':db[_0x1f291c[_0x2661('0x1e')]],'as':_0x1f291c['as'],'attributes':_0x1f291c[_0x2661('0x1c')]};}):[]};}):[]};}):[]:[]})[_0x2661('0xc')](function(_0x4db002){logger[_0x2661('0xd')]('ShowSetting',_0x23bbc8);logger[_0x2661('0x20')](_0x2661('0x21'),_0x23bbc8,JSON['stringify'](_0x4db002));_0x218592(_0x4db002);})[_0x2661('0x16')](function(_0x1ecd92){logger[_0x2661('0x12')](_0x2661('0x21'),_0x1ecd92[_0x2661('0x14')],_0x23bbc8);_0x28b66c(_0x24a73f[_0x2661('0x12')](0x1f4,_0x1ecd92[_0x2661('0x14')]));});});};