Built motion from commit 85f716e9.|2.6.8
[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 _0x225a=['client','then','request\x20sent','Setting,\x20%s,\x20%s,\x20%s','stringify','error','code','Setting,\x20%s,\x20%s','message','result','ShowSetting','Setting','options','raw','where','attributes','include','model','map','info','debug','catch','lodash','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','jayson/promise'];(function(_0x1d87ed,_0x112eaf){var _0xaec3c6=function(_0x5c68d0){while(--_0x5c68d0){_0x1d87ed['push'](_0x1d87ed['shift']());}};_0xaec3c6(++_0x112eaf);}(_0x225a,0x1c8));var _0xa225=function(_0x3eedcb,_0x49a36e){_0x3eedcb=_0x3eedcb-0x0;var _0x370962=_0x225a[_0x3eedcb];return _0x370962;};'use strict';var _=require(_0xa225('0x0'));var util=require('util');var moment=require(_0xa225('0x1'));var BPromise=require(_0xa225('0x2'));var rs=require(_0xa225('0x3'));var fs=require('fs');var Redis=require(_0xa225('0x4'));var db=require(_0xa225('0x5'))['db'];var utils=require(_0xa225('0x6'));var logger=require(_0xa225('0x7'))('rpc');var config=require('../../config/environment');var jayson=require(_0xa225('0x8'));var client=jayson[_0xa225('0x9')]['http']({'port':0x232a});function respondWithRpcPromise(_0x158578,_0x4643a9,_0x1fee4b){return new BPromise(function(_0x204f5d,_0xb3579d){return client['request'](_0x158578,_0x1fee4b)[_0xa225('0xa')](function(_0x1efcb1){logger['info']('Setting,\x20%s,\x20%s',_0x4643a9,_0xa225('0xb'));logger['debug'](_0xa225('0xc'),_0x4643a9,_0xa225('0xb'),JSON[_0xa225('0xd')](_0x1efcb1));if(_0x1efcb1[_0xa225('0xe')]){if(_0x1efcb1[_0xa225('0xe')][_0xa225('0xf')]===0x1f4){logger[_0xa225('0xe')](_0xa225('0x10'),_0x4643a9,_0x1efcb1[_0xa225('0xe')][_0xa225('0x11')]);return _0xb3579d(_0x1efcb1['error'][_0xa225('0x11')]);}logger[_0xa225('0xe')]('Setting,\x20%s,\x20%s',_0x4643a9,_0x1efcb1[_0xa225('0xe')][_0xa225('0x11')]);return _0x204f5d(_0x1efcb1[_0xa225('0xe')][_0xa225('0x11')]);}else{logger['info'](_0xa225('0x10'),_0x4643a9,_0xa225('0xb'));_0x204f5d(_0x1efcb1[_0xa225('0x12')]['message']);}})['catch'](function(_0x5a6abc){logger[_0xa225('0xe')](_0xa225('0x10'),_0x4643a9,_0x5a6abc);_0xb3579d(_0x5a6abc);});});}exports[_0xa225('0x13')]=function(_0x421223){var _0x3546ef=this;return new Promise(function(_0x4b66e9,_0x37cefc){return db[_0xa225('0x14')]['find']({'raw':_0x421223[_0xa225('0x15')]?_0x421223[_0xa225('0x15')][_0xa225('0x16')]===undefined?!![]:![]:!![],'where':_0x421223['options']?_0x421223['options'][_0xa225('0x17')]||null:null,'attributes':_0x421223[_0xa225('0x15')]?_0x421223[_0xa225('0x15')][_0xa225('0x18')]||null:null,'include':_0x421223[_0xa225('0x15')]?_0x421223['options']['include']?_['map'](_0x421223[_0xa225('0x15')][_0xa225('0x19')],function(_0x38da46){return{'model':db[_0x38da46[_0xa225('0x1a')]],'as':_0x38da46['as'],'attributes':_0x38da46[_0xa225('0x18')],'include':_0x38da46['include']?_['map'](_0x38da46[_0xa225('0x19')],function(_0x18017b){return{'model':db[_0x18017b['model']],'as':_0x18017b['as'],'attributes':_0x18017b['attributes'],'include':_0x18017b['include']?_[_0xa225('0x1b')](_0x18017b[_0xa225('0x19')],function(_0x1a8ff8){return{'model':db[_0x1a8ff8[_0xa225('0x1a')]],'as':_0x1a8ff8['as'],'attributes':_0x1a8ff8[_0xa225('0x18')]};}):[]};}):[]};}):[]:[]})[_0xa225('0xa')](function(_0x344c38){logger[_0xa225('0x1c')](_0xa225('0x13'),_0x421223);logger[_0xa225('0x1d')](_0xa225('0x13'),_0x421223,JSON[_0xa225('0xd')](_0x344c38));_0x4b66e9(_0x344c38);})[_0xa225('0x1e')](function(_0x34dfd0){logger['error'](_0xa225('0x13'),_0x34dfd0[_0xa225('0x11')],_0x421223);_0x37cefc(_0x3546ef[_0xa225('0xe')](0x1f4,_0x34dfd0['message']));});});};