aac73085666f319a2a9f5857641ebab9f5a4bc89
[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 _0x91fc=['info','Setting,\x20%s,\x20%s','request\x20sent','debug','Setting,\x20%s,\x20%s,\x20%s','stringify','error','code','message','catch','ShowSetting','find','options','raw','where','attributes','include','map','model','lodash','util','moment','bluebird','randomstring','../../mysqldb','../../config/logger','../../config/environment','jayson/promise','client','http','request','then'];(function(_0x40341a,_0x12c198){var _0x42ffad=function(_0x341ddf){while(--_0x341ddf){_0x40341a['push'](_0x40341a['shift']());}};_0x42ffad(++_0x12c198);}(_0x91fc,0xb3));var _0xc91f=function(_0x1c3e47,_0xa2a3ad){_0x1c3e47=_0x1c3e47-0x0;var _0x57e88e=_0x91fc[_0x1c3e47];return _0x57e88e;};'use strict';var _=require(_0xc91f('0x0'));var util=require(_0xc91f('0x1'));var moment=require(_0xc91f('0x2'));var BPromise=require(_0xc91f('0x3'));var rs=require(_0xc91f('0x4'));var fs=require('fs');var Redis=require('ioredis');var db=require(_0xc91f('0x5'))['db'];var utils=require('../../config/utils');var logger=require(_0xc91f('0x6'))('rpc');var config=require(_0xc91f('0x7'));var jayson=require(_0xc91f('0x8'));var client=jayson[_0xc91f('0x9')][_0xc91f('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x2b60eb,_0x43f2ae,_0x1442f0){return new BPromise(function(_0x125d85,_0x4c146e){return client[_0xc91f('0xb')](_0x2b60eb,_0x1442f0)[_0xc91f('0xc')](function(_0x129e84){logger[_0xc91f('0xd')](_0xc91f('0xe'),_0x43f2ae,_0xc91f('0xf'));logger[_0xc91f('0x10')](_0xc91f('0x11'),_0x43f2ae,'request\x20sent',JSON[_0xc91f('0x12')](_0x129e84));if(_0x129e84[_0xc91f('0x13')]){if(_0x129e84[_0xc91f('0x13')][_0xc91f('0x14')]===0x1f4){logger['error'](_0xc91f('0xe'),_0x43f2ae,_0x129e84[_0xc91f('0x13')][_0xc91f('0x15')]);return _0x4c146e(_0x129e84[_0xc91f('0x13')][_0xc91f('0x15')]);}logger[_0xc91f('0x13')]('Setting,\x20%s,\x20%s',_0x43f2ae,_0x129e84['error'][_0xc91f('0x15')]);return _0x125d85(_0x129e84[_0xc91f('0x13')][_0xc91f('0x15')]);}else{logger['info'](_0xc91f('0xe'),_0x43f2ae,_0xc91f('0xf'));_0x125d85(_0x129e84['result']['message']);}})[_0xc91f('0x16')](function(_0xd32c81){logger[_0xc91f('0x13')](_0xc91f('0xe'),_0x43f2ae,_0xd32c81);_0x4c146e(_0xd32c81);});});}exports[_0xc91f('0x17')]=function(_0x4ebf91){var _0x430c2b=this;return new Promise(function(_0x59c193,_0x58040f){return db['Setting'][_0xc91f('0x18')]({'raw':_0x4ebf91[_0xc91f('0x19')]?_0x4ebf91['options'][_0xc91f('0x1a')]===undefined?!![]:![]:!![],'where':_0x4ebf91[_0xc91f('0x19')]?_0x4ebf91[_0xc91f('0x19')][_0xc91f('0x1b')]||null:null,'attributes':_0x4ebf91[_0xc91f('0x19')]?_0x4ebf91[_0xc91f('0x19')][_0xc91f('0x1c')]||null:null,'include':_0x4ebf91['options']?_0x4ebf91[_0xc91f('0x19')][_0xc91f('0x1d')]?_['map'](_0x4ebf91[_0xc91f('0x19')][_0xc91f('0x1d')],function(_0x575b7b){return{'model':db[_0x575b7b['model']],'as':_0x575b7b['as'],'attributes':_0x575b7b['attributes'],'include':_0x575b7b[_0xc91f('0x1d')]?_[_0xc91f('0x1e')](_0x575b7b[_0xc91f('0x1d')],function(_0x585904){return{'model':db[_0x585904[_0xc91f('0x1f')]],'as':_0x585904['as'],'attributes':_0x585904['attributes'],'include':_0x585904['include']?_[_0xc91f('0x1e')](_0x585904[_0xc91f('0x1d')],function(_0x54044f){return{'model':db[_0x54044f[_0xc91f('0x1f')]],'as':_0x54044f['as'],'attributes':_0x54044f[_0xc91f('0x1c')]};}):[]};}):[]};}):[]:[]})[_0xc91f('0xc')](function(_0x46e9aa){logger[_0xc91f('0xd')](_0xc91f('0x17'),_0x4ebf91);logger[_0xc91f('0x10')](_0xc91f('0x17'),_0x4ebf91,JSON[_0xc91f('0x12')](_0x46e9aa));_0x59c193(_0x46e9aa);})[_0xc91f('0x16')](function(_0x215b04){logger[_0xc91f('0x13')]('ShowSetting',_0x215b04['message'],_0x4ebf91);_0x58040f(_0x430c2b[_0xc91f('0x13')](0x1f4,_0x215b04['message']));});});};