Built motion from commit f7863d46.|2.5.41
[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 _0x0c8a=['rpc','../../config/environment','jayson/promise','client','then','request\x20sent','debug','Setting,\x20%s,\x20%s,\x20%s','stringify','error','Setting,\x20%s,\x20%s','message','info','result','catch','Setting','find','options','raw','where','map','model','attributes','include','ShowSetting','lodash','bluebird','ioredis','../../mysqldb','../../config/utils','../../config/logger'];(function(_0x37ce45,_0xda6746){var _0x17d5f7=function(_0x559ab7){while(--_0x559ab7){_0x37ce45['push'](_0x37ce45['shift']());}};_0x17d5f7(++_0xda6746);}(_0x0c8a,0x1ac));var _0xa0c8=function(_0x4bc156,_0x5ab86e){_0x4bc156=_0x4bc156-0x0;var _0x33c7da=_0x0c8a[_0x4bc156];return _0x33c7da;};'use strict';var _=require(_0xa0c8('0x0'));var util=require('util');var moment=require('moment');var BPromise=require(_0xa0c8('0x1'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0xa0c8('0x2'));var db=require(_0xa0c8('0x3'))['db'];var utils=require(_0xa0c8('0x4'));var logger=require(_0xa0c8('0x5'))(_0xa0c8('0x6'));var config=require(_0xa0c8('0x7'));var jayson=require(_0xa0c8('0x8'));var client=jayson[_0xa0c8('0x9')]['http']({'port':0x232a});function respondWithRpcPromise(_0x1b8a1f,_0x39304e,_0x3b5d64){return new BPromise(function(_0x2c0c04,_0x2c6086){return client['request'](_0x1b8a1f,_0x3b5d64)[_0xa0c8('0xa')](function(_0x4634ec){logger['info']('Setting,\x20%s,\x20%s',_0x39304e,_0xa0c8('0xb'));logger[_0xa0c8('0xc')](_0xa0c8('0xd'),_0x39304e,_0xa0c8('0xb'),JSON[_0xa0c8('0xe')](_0x4634ec));if(_0x4634ec[_0xa0c8('0xf')]){if(_0x4634ec['error']['code']===0x1f4){logger[_0xa0c8('0xf')](_0xa0c8('0x10'),_0x39304e,_0x4634ec['error'][_0xa0c8('0x11')]);return _0x2c6086(_0x4634ec['error'][_0xa0c8('0x11')]);}logger[_0xa0c8('0xf')](_0xa0c8('0x10'),_0x39304e,_0x4634ec[_0xa0c8('0xf')][_0xa0c8('0x11')]);return _0x2c0c04(_0x4634ec[_0xa0c8('0xf')][_0xa0c8('0x11')]);}else{logger[_0xa0c8('0x12')](_0xa0c8('0x10'),_0x39304e,'request\x20sent');_0x2c0c04(_0x4634ec[_0xa0c8('0x13')][_0xa0c8('0x11')]);}})[_0xa0c8('0x14')](function(_0x395c2e){logger['error'](_0xa0c8('0x10'),_0x39304e,_0x395c2e);_0x2c6086(_0x395c2e);});});}exports['ShowSetting']=function(_0x56cdb7){var _0x2fe1c3=this;return new Promise(function(_0x350791,_0x33c9f8){return db[_0xa0c8('0x15')][_0xa0c8('0x16')]({'raw':_0x56cdb7[_0xa0c8('0x17')]?_0x56cdb7['options'][_0xa0c8('0x18')]===undefined?!![]:![]:!![],'where':_0x56cdb7[_0xa0c8('0x17')]?_0x56cdb7[_0xa0c8('0x17')][_0xa0c8('0x19')]||null:null,'attributes':_0x56cdb7[_0xa0c8('0x17')]?_0x56cdb7['options']['attributes']||null:null,'include':_0x56cdb7[_0xa0c8('0x17')]?_0x56cdb7[_0xa0c8('0x17')]['include']?_[_0xa0c8('0x1a')](_0x56cdb7[_0xa0c8('0x17')]['include'],function(_0x2c5919){return{'model':db[_0x2c5919[_0xa0c8('0x1b')]],'as':_0x2c5919['as'],'attributes':_0x2c5919[_0xa0c8('0x1c')],'include':_0x2c5919['include']?_['map'](_0x2c5919[_0xa0c8('0x1d')],function(_0x2d3784){return{'model':db[_0x2d3784['model']],'as':_0x2d3784['as'],'attributes':_0x2d3784[_0xa0c8('0x1c')],'include':_0x2d3784[_0xa0c8('0x1d')]?_['map'](_0x2d3784[_0xa0c8('0x1d')],function(_0x534cb1){return{'model':db[_0x534cb1[_0xa0c8('0x1b')]],'as':_0x534cb1['as'],'attributes':_0x534cb1[_0xa0c8('0x1c')]};}):[]};}):[]};}):[]:[]})[_0xa0c8('0xa')](function(_0x52224e){logger[_0xa0c8('0x12')](_0xa0c8('0x1e'),_0x56cdb7);logger['debug'](_0xa0c8('0x1e'),_0x56cdb7,JSON['stringify'](_0x52224e));_0x350791(_0x52224e);})['catch'](function(_0x3bce2c){logger[_0xa0c8('0xf')](_0xa0c8('0x1e'),_0x3bce2c[_0xa0c8('0x11')],_0x56cdb7);_0x33c9f8(_0x2fe1c3['error'](0x1f4,_0x3bce2c['message']));});});};